This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 169099
Collapse All | Expand All

(-)a/core.windows/manifest.mf (-1 / +1 lines)
Lines 6-10 Link Here
6
OpenIDE-Module-Recommends: org.netbeans.core.windows.nativeaccess.NativeWindowSystem
6
OpenIDE-Module-Recommends: org.netbeans.core.windows.nativeaccess.NativeWindowSystem
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
8
AutoUpdate-Essential-Module: true
8
AutoUpdate-Essential-Module: true
9
OpenIDE-Module-Specification-Version: 2.42
9
OpenIDE-Module-Specification-Version: 2.43
10
10
(-)a/core.windows/nbproject/project.xml (-1 / +1 lines)
Lines 85-91 Link Here
85
                    <build-prerequisite/>
85
                    <build-prerequisite/>
86
                    <compile-dependency/>
86
                    <compile-dependency/>
87
                    <run-dependency>
87
                    <run-dependency>
88
                        <specification-version>1.27</specification-version>
88
                        <specification-version>1.33</specification-version>
89
                    </run-dependency>
89
                    </run-dependency>
90
                </dependency>
90
                </dependency>
91
                <dependency>
91
                <dependency>
(-)a/core.windows/src/org/netbeans/core/windows/view/dnd/DragAndDropFeedbackVisualizer.java (-1 / +1 lines)
Lines 59-65 Link Here
59
import javax.swing.SwingUtilities;
59
import javax.swing.SwingUtilities;
60
import org.netbeans.core.windows.nativeaccess.NativeWindowSystem;
60
import org.netbeans.core.windows.nativeaccess.NativeWindowSystem;
61
import org.netbeans.core.windows.options.WinSysPrefs;
61
import org.netbeans.core.windows.options.WinSysPrefs;
62
import org.netbeans.core.windows.view.ui.Tabbed;
62
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
63
63
64
/**
64
/**
65
 *
65
 *
(-)a/core.windows/src/org/netbeans/core/windows/view/dnd/DragWindow.java (-1 / +1 lines)
Lines 62-68 Link Here
62
import javax.swing.SwingUtilities;
62
import javax.swing.SwingUtilities;
63
import javax.swing.Timer;
63
import javax.swing.Timer;
64
import org.netbeans.core.windows.options.WinSysPrefs;
64
import org.netbeans.core.windows.options.WinSysPrefs;
65
import org.netbeans.core.windows.view.ui.Tabbed;
65
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
66
66
67
/**
67
/**
68
 *
68
 *
(-)a/core.windows/src/org/netbeans/core/windows/view/dnd/TopComponentDragSupport.java (-18 / +9 lines)
Lines 47-52 Link Here
47
47
48
48
49
49
50
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
50
import java.awt.AWTEvent;
51
import java.awt.AWTEvent;
51
import java.awt.Color;
52
import java.awt.Color;
52
import java.awt.Component;
53
import java.awt.Component;
Lines 273-290 Link Here
273
        TopComponent tc = null;
274
        TopComponent tc = null;
274
        Tabbed tabbed;
275
        Tabbed tabbed;
275
276
276
        if(srcComp instanceof Tabbed) {
277
        if(srcComp instanceof Tabbed.Accessor) {
277
            tabbed = (Tabbed)srcComp;
278
            tabbed = ((Tabbed.Accessor)srcComp).getTabbed();
278
        } else {
279
        } else {
279
            tabbed = (Tabbed)SwingUtilities.getAncestorOfClass(Tabbed.class, srcComp);
280
            Tabbed.Accessor acc = (Tabbed.Accessor)SwingUtilities.getAncestorOfClass(Tabbed.Accessor.class, srcComp);
280
        }
281
            tabbed = acc != null ? acc.getTabbed() : null;
281
        if (tabbed == null) {
282
            if(srcComp instanceof Tabbed.Accessor) {
283
                tabbed = ((Tabbed.Accessor)srcComp).getTabbed();
284
            } else {
285
                Tabbed.Accessor acc = (Tabbed.Accessor)SwingUtilities.getAncestorOfClass(Tabbed.Accessor.class, srcComp);
286
                tabbed = acc != null ? acc.getTabbed() : null;
287
            }
288
        }
282
        }
289
        if(tabbed == null) {
283
        if(tabbed == null) {
290
            return;
284
            return;
Lines 396-408 Link Here
396
        addListening();
390
        addListening();
397
        hackESC = false;
391
        hackESC = false;
398
        
392
        
399
        Tabbed tabbed = (Tabbed) SwingUtilities.getAncestorOfClass (Tabbed.class,
393
        Tabbed tabbed = null;
400
            startingComp);
394
        Tabbed.Accessor acc = (Tabbed.Accessor) SwingUtilities.getAncestorOfClass (Tabbed.Accessor.class,
401
        if (tabbed == null) {
395
                                                                                    startingComp);
402
            Tabbed.Accessor acc = (Tabbed.Accessor) SwingUtilities.getAncestorOfClass (Tabbed.Accessor.class,
396
        tabbed = acc != null ? acc.getTabbed() : null;
403
                                                                                       startingComp);
404
            tabbed = acc != null ? acc.getTabbed() : null;
405
        }
406
        
397
        
407
        int tabIndex = -1;
398
        int tabIndex = -1;
408
        Image img = createDragImage();
399
        Image img = createDragImage();
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/AbstractModeContainer.java (-1 / +2 lines)
Lines 46-51 Link Here
46
package org.netbeans.core.windows.view.ui;
46
package org.netbeans.core.windows.view.ui;
47
47
48
48
49
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
49
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.WindowManagerImpl;
51
import org.netbeans.core.windows.WindowManagerImpl;
51
import org.netbeans.core.windows.view.ModeContainer;
52
import org.netbeans.core.windows.view.ModeContainer;
Lines 206-212 Link Here
206
    // Support for TopComponentDroppable
207
    // Support for TopComponentDroppable
207
    protected Shape getIndicationForLocation(Point location) {
208
    protected Shape getIndicationForLocation(Point location) {
208
        return tabbedHandler.getIndicationForLocation(location,
209
        return tabbedHandler.getIndicationForLocation(location,
209
            windowDnDManager.getStartingTransfer(),
210
            windowDnDManager.getStartingTransfer().getTopComponent(),
210
            windowDnDManager.getStartingPoint(),
211
            windowDnDManager.getStartingPoint(),
211
            isAttachingPossible());
212
            isAttachingPossible());
212
    }
213
    }
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/DefaultSeparateContainer.java (-7 / +7 lines)
Lines 46-51 Link Here
46
package org.netbeans.core.windows.view.ui;
46
package org.netbeans.core.windows.view.ui;
47
47
48
48
49
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
49
import java.text.MessageFormat;
50
import java.text.MessageFormat;
50
import javax.swing.plaf.basic.BasicHTML;
51
import javax.swing.plaf.basic.BasicHTML;
51
import org.netbeans.core.windows.Constants;
52
import org.netbeans.core.windows.Constants;
Lines 68-73 Link Here
68
import java.util.logging.Logger;
69
import java.util.logging.Logger;
69
import org.netbeans.core.windows.options.WinSysPrefs;
70
import org.netbeans.core.windows.options.WinSysPrefs;
70
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
71
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
72
import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory;
73
import org.netbeans.swing.tabcontrol.customtabs.TabbedType;
74
import org.openide.util.Lookup;
71
import org.openide.windows.WindowManager;
75
import org.openide.windows.WindowManager;
72
76
73
77
Lines 118-130 Link Here
118
    
122
    
119
    @Override
123
    @Override
120
    protected Tabbed createTabbed() {
124
    protected Tabbed createTabbed() {
121
        Tabbed tabbed;
125
        TabbedComponentFactory factory = Lookup.getDefault().lookup(TabbedComponentFactory.class);
122
        if(getKind() == Constants.MODE_KIND_EDITOR) {
126
        TabbedType type = getKind() == Constants.MODE_KIND_EDITOR ? TabbedType.EDITOR : TabbedType.VIEW;
123
            tabbed = new TabbedAdapter(Constants.MODE_KIND_EDITOR);
127
        return factory.createTabbedComponent( type, new TabbedAdapter.WinsysInfo(getKind()));
124
        } else {
125
            tabbed = new TabbedAdapter(Constants.MODE_KIND_VIEW);
126
        }
127
        return tabbed;    
128
    }    
128
    }    
129
    
129
    
130
    @Override
130
    @Override
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/DefaultSplitContainer.java (-7 / +8 lines)
Lines 46-51 Link Here
46
package org.netbeans.core.windows.view.ui;
46
package org.netbeans.core.windows.view.ui;
47
47
48
48
49
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
49
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.WindowManagerImpl;
51
import org.netbeans.core.windows.WindowManagerImpl;
51
import org.netbeans.core.windows.view.ModeView;
52
import org.netbeans.core.windows.view.ModeView;
Lines 59-64 Link Here
59
import java.awt.*;
60
import java.awt.*;
60
import org.netbeans.core.windows.ModeImpl;
61
import org.netbeans.core.windows.ModeImpl;
61
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
62
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
63
import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory;
64
import org.netbeans.swing.tabcontrol.customtabs.TabbedType;
65
import org.openide.util.Lookup;
62
import org.openide.windows.Mode;
66
import org.openide.windows.Mode;
63
67
64
68
Lines 96-109 Link Here
96
        return panel;
100
        return panel;
97
    }
101
    }
98
    
102
    
103
    @Override
99
    protected Tabbed createTabbed() {
104
    protected Tabbed createTabbed() {
100
        Tabbed tabbed;
105
        TabbedComponentFactory factory = Lookup.getDefault().lookup(TabbedComponentFactory.class);
101
        if(getKind() == Constants.MODE_KIND_EDITOR) {
106
        TabbedType type = getKind() == Constants.MODE_KIND_EDITOR ? TabbedType.EDITOR : TabbedType.VIEW;
102
            tabbed = new TabbedAdapter(Constants.MODE_KIND_EDITOR);
107
        return factory.createTabbedComponent( type, new TabbedAdapter.WinsysInfo(getKind()));
103
        } else {
104
            tabbed = new TabbedAdapter(Constants.MODE_KIND_VIEW);
105
        }
106
        return tabbed;    
107
    }    
108
    }    
108
    
109
    
109
    protected void updateTitle(String title) {
110
    protected void updateTitle(String title) {
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/Tabbed.java (-144 lines)
Lines 1-144 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
46
package org.netbeans.core.windows.view.ui;
47
48
49
import org.openide.windows.TopComponent;
50
51
import javax.swing.*;
52
import javax.swing.event.ChangeListener;
53
import java.awt.*;
54
import java.awt.event.ActionListener;
55
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
56
57
58
/**
59
 * Interface describing component which is used inside <code>SimpleContainer</code>.
60
 * There will be at two implementations one for view and second one for editor type.
61
 *
62
 * @author  Peter Zavadsky
63
 */
64
public interface Tabbed {
65
66
    public void requestAttention(TopComponent tc);
67
68
    public void cancelRequestAttention(TopComponent tc);
69
    
70
    public void addTopComponent(String name, Icon icon, TopComponent tc, String toolTip);
71
72
    public void insertComponent(String name, Icon icon, Component comp, String toolTip, int position);
73
    
74
    public void setTopComponents(TopComponent[] tcs, TopComponent selected);
75
    
76
    public int getTabCount();
77
    
78
    public TopComponent[] getTopComponents();
79
    
80
    public TopComponent getTopComponentAt(int index);
81
    
82
    public int indexOf(Component tc);
83
    
84
    public void removeComponent(Component comp);
85
    
86
    public void setTitleAt(int index, String title);
87
    
88
    public void setIconAt(int index, Icon icon);
89
    
90
    public void setToolTipTextAt(int index, String toolTip);
91
    
92
    public void setSelectedComponent(Component comp);
93
    
94
    public TopComponent getSelectedTopComponent();
95
96
    public void addChangeListener(ChangeListener listener);
97
    
98
    public void removeChangeListener(ChangeListener listener);
99
100
    public void addActionListener (ActionListener al);
101
102
    public void removeActionListener (ActionListener al);
103
104
    public void setActive(boolean active);
105
    
106
    public int tabForCoordinate(Point p);
107
   
108
    public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer,
109
            Point startingPoint, boolean attachingPossible);
110
    
111
    public Object getConstraintForLocation(Point location, boolean attachingPossible);
112
    
113
    public Image createImageOfTab (int tabIndex);
114
    
115
    /** Accessor for visual component holding components */
116
    public Component getComponent();
117
    
118
    /** Allows tabbed implementors to speficy content of popup menu on tab
119
     * with given index. Incoming actions are default set by winsys
120
     */
121
    public Action[] getPopupActions(Action[] defaultActions, int tabIndex);
122
    
123
    /** Returns bounds of tab with given index */
124
    public Rectangle getTabBounds(int tabIndex);
125
    
126
    /**
127
     * @return Bounds of the area which displays the tab headers.
128
     * @since 2.32
129
     */
130
    public Rectangle getTabsArea();
131
    
132
    public boolean isTransparent();
133
    
134
    public void setTransparent( boolean transparent );
135
    
136
    /** Interface for simple accessing of Tabbed instance */
137
    public interface Accessor {
138
139
        public Tabbed getTabbed ();
140
141
    } // end of Accessor
142
143
}
144
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/TabbedHandler.java (-4 / +4 lines)
Lines 46-51 Link Here
46
package org.netbeans.core.windows.view.ui;
46
package org.netbeans.core.windows.view.ui;
47
47
48
48
49
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
49
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.Constants;
50
import org.netbeans.core.windows.actions.ActionUtils;
51
import org.netbeans.core.windows.actions.ActionUtils;
51
import org.netbeans.core.windows.actions.MaximizeWindowAction;
52
import org.netbeans.core.windows.actions.MaximizeWindowAction;
Lines 69-75 Link Here
69
import java.util.logging.Logger;
70
import java.util.logging.Logger;
70
import org.netbeans.core.windows.ModeImpl;
71
import org.netbeans.core.windows.ModeImpl;
71
import org.netbeans.core.windows.Switches;
72
import org.netbeans.core.windows.Switches;
72
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
73
import org.netbeans.core.windows.view.ui.slides.SlideBar;
73
import org.netbeans.core.windows.view.ui.slides.SlideBar;
74
import org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent;
74
import org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent;
75
import org.netbeans.core.windows.view.ui.slides.SlideOperationFactory;
75
import org.netbeans.core.windows.view.ui.slides.SlideOperationFactory;
Lines 299-305 Link Here
299
    }
299
    }
300
    
300
    
301
    // DnD>>
301
    // DnD>>
302
    public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer,
302
    public Shape getIndicationForLocation(Point location, TopComponent startingTransfer,
303
    Point startingPoint, boolean attachingPossible) {
303
    Point startingPoint, boolean attachingPossible) {
304
        return tabbed.getIndicationForLocation(location, startingTransfer,
304
        return tabbed.getIndicationForLocation(location, startingTransfer,
305
                                            startingPoint, attachingPossible);
305
                                            startingPoint, attachingPossible);
Lines 463-475 Link Here
463
    /** Possibly invokes the (un)maximization. */
463
    /** Possibly invokes the (un)maximization. */
464
    public static void handleMaximization(TabActionEvent tae) {
464
    public static void handleMaximization(TabActionEvent tae) {
465
        Component c = (Component) tae.getSource();
465
        Component c = (Component) tae.getSource();
466
        while (c != null && !(c instanceof Tabbed))
466
        while (c != null && !(c instanceof Tabbed.Accessor))
467
            c = c.getParent();
467
            c = c.getParent();
468
        if (c == null) {
468
        if (c == null) {
469
            return;
469
            return;
470
        }
470
        }
471
        
471
        
472
        final Tabbed tab = (Tabbed) c;
472
        final Tabbed tab = ((Tabbed.Accessor) c).getTabbed();
473
        TopComponent tc = tab.getTopComponentAt(tae.getTabIndex());
473
        TopComponent tc = tab.getTopComponentAt(tae.getTabIndex());
474
        // perform action
474
        // perform action
475
        MaximizeWindowAction mwa = new MaximizeWindowAction(tc);
475
        MaximizeWindowAction mwa = new MaximizeWindowAction(tc);
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBar.java (-2 / +2 lines)
Lines 79-85 Link Here
79
import org.netbeans.core.windows.ModeImpl;
79
import org.netbeans.core.windows.ModeImpl;
80
import org.netbeans.core.windows.Switches;
80
import org.netbeans.core.windows.Switches;
81
import org.netbeans.core.windows.WindowManagerImpl;
81
import org.netbeans.core.windows.WindowManagerImpl;
82
import org.netbeans.core.windows.view.ui.Tabbed;
82
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
83
import org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter;
83
import org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter;
84
import org.netbeans.swing.tabcontrol.SlideBarDataModel;
84
import org.netbeans.swing.tabcontrol.SlideBarDataModel;
85
import org.netbeans.swing.tabcontrol.SlidingButton;
85
import org.netbeans.swing.tabcontrol.SlidingButton;
Lines 407-413 Link Here
407
    public Tabbed getTabbed () {
407
    public Tabbed getTabbed () {
408
        return tabbed;
408
        return tabbed;
409
    }
409
    }
410
    
410
411
    /********* implementation of WinsysInfoForTabbedContainer **************/
411
    /********* implementation of WinsysInfoForTabbedContainer **************/
412
    
412
    
413
    public WinsysInfoForTabbedContainer createWinsysInfo() {
413
    public WinsysInfoForTabbedContainer createWinsysInfo() {
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBarContainer.java (-1 / +1 lines)
Lines 69-75 Link Here
69
import org.netbeans.core.windows.view.ui.AbstractModeContainer;
69
import org.netbeans.core.windows.view.ui.AbstractModeContainer;
70
import org.netbeans.core.windows.view.ui.ModeComponent;
70
import org.netbeans.core.windows.view.ui.ModeComponent;
71
import org.netbeans.core.windows.view.dnd.TopComponentDroppable;
71
import org.netbeans.core.windows.view.dnd.TopComponentDroppable;
72
import org.netbeans.core.windows.view.ui.Tabbed;
72
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
73
import org.openide.windows.TopComponent;
73
import org.openide.windows.TopComponent;
74
74
75
75
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/slides/TabbedSlideAdapter.java (-4 / +3 lines)
Lines 65-78 Link Here
65
import org.netbeans.core.windows.ModeImpl;
65
import org.netbeans.core.windows.ModeImpl;
66
import org.netbeans.core.windows.WindowManagerImpl;
66
import org.netbeans.core.windows.WindowManagerImpl;
67
import org.netbeans.core.windows.actions.ActionUtils;
67
import org.netbeans.core.windows.actions.ActionUtils;
68
import org.netbeans.core.windows.view.ui.Tabbed;
69
import org.netbeans.swing.tabcontrol.DefaultTabDataModel;
68
import org.netbeans.swing.tabcontrol.DefaultTabDataModel;
70
import org.netbeans.core.windows.view.dnd.DragAndDropFeedbackVisualizer;
69
import org.netbeans.core.windows.view.dnd.DragAndDropFeedbackVisualizer;
71
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
72
import org.netbeans.swing.tabcontrol.SlideBarDataModel;
70
import org.netbeans.swing.tabcontrol.SlideBarDataModel;
73
import org.netbeans.swing.tabcontrol.TabData;
71
import org.netbeans.swing.tabcontrol.TabData;
74
import org.netbeans.swing.tabcontrol.TabDataModel;
72
import org.netbeans.swing.tabcontrol.TabDataModel;
75
import org.netbeans.swing.tabcontrol.TabbedContainer;
73
import org.netbeans.swing.tabcontrol.TabbedContainer;
74
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
76
import org.openide.util.ChangeSupport;
75
import org.openide.util.ChangeSupport;
77
import org.openide.windows.TopComponent;
76
import org.openide.windows.TopComponent;
78
77
Lines 83-89 Link Here
83
 *
82
 *
84
 * @author Dafe Simonek
83
 * @author Dafe Simonek
85
 */
84
 */
86
public final class TabbedSlideAdapter implements Tabbed {
85
public final class TabbedSlideAdapter extends Tabbed {
87
    
86
    
88
    /** data model of informations about top components in container */
87
    /** data model of informations about top components in container */
89
    private TabDataModel dataModel;
88
    private TabDataModel dataModel;
Lines 313-319 Link Here
313
    }
312
    }
314
    
313
    
315
    @Override
314
    @Override
316
    public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer, 
315
    public Shape getIndicationForLocation(Point location, TopComponent startingTransfer, 
317
                            Point startingPoint, boolean attachingPossible) {
316
                            Point startingPoint, boolean attachingPossible) {
318
        
317
        
319
//        int tab = tabForCoordinate(location);
318
//        int tab = tabForCoordinate(location);
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/tabcontrol/TabbedAdapter.java (-282 / +344 lines)
Lines 52-58 Link Here
52
import org.netbeans.core.windows.Constants;
52
import org.netbeans.core.windows.Constants;
53
import org.netbeans.core.windows.Debug;
53
import org.netbeans.core.windows.Debug;
54
import org.netbeans.core.windows.WindowManagerImpl;
54
import org.netbeans.core.windows.WindowManagerImpl;
55
import org.netbeans.core.windows.view.ui.Tabbed;
55
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
56
import org.netbeans.swing.tabcontrol.ComponentConverter;
56
import org.netbeans.swing.tabcontrol.ComponentConverter;
57
import org.netbeans.swing.tabcontrol.TabData;
57
import org.netbeans.swing.tabcontrol.TabData;
58
import org.netbeans.swing.tabcontrol.TabbedContainer;
58
import org.netbeans.swing.tabcontrol.TabbedContainer;
Lines 64-75 Link Here
64
import javax.swing.event.ChangeEvent;
64
import javax.swing.event.ChangeEvent;
65
import javax.swing.event.ChangeListener;
65
import javax.swing.event.ChangeListener;
66
import java.awt.*;
66
import java.awt.*;
67
import java.util.ArrayList;
67
import java.awt.event.ActionListener;
68
import java.util.Arrays;
68
import java.util.Arrays;
69
import org.netbeans.core.windows.ModeImpl;
69
import org.netbeans.core.windows.ModeImpl;
70
import org.netbeans.core.windows.Switches;
70
import org.netbeans.core.windows.Switches;
71
import org.netbeans.core.windows.actions.ActionUtils;
71
import org.netbeans.core.windows.actions.ActionUtils;
72
import org.netbeans.core.windows.view.dnd.TopComponentDraggable;
73
import org.netbeans.swing.tabcontrol.TabDisplayer;
72
import org.netbeans.swing.tabcontrol.TabDisplayer;
74
import org.netbeans.swing.tabcontrol.WinsysInfoForTabbedContainer;
73
import org.netbeans.swing.tabcontrol.WinsysInfoForTabbedContainer;
75
import org.netbeans.swing.tabcontrol.event.TabActionEvent;
74
import org.netbeans.swing.tabcontrol.event.TabActionEvent;
Lines 81-87 Link Here
81
 *
80
 *
82
 * @author  Tim Boudreau
81
 * @author  Tim Boudreau
83
 */
82
 */
84
public class TabbedAdapter extends TabbedContainer implements Tabbed, Tabbed.Accessor, SlideController {
83
public class TabbedAdapter extends TabbedContainer implements Tabbed.Accessor, SlideController {
85
    
84
    
86
    public static final int DOCUMENT = 1;
85
    public static final int DOCUMENT = 1;
87
    
86
    
Lines 93-100 Link Here
93
    private PropertyChangeListener tooltipListener, weakTooltipListener;
92
    private PropertyChangeListener tooltipListener, weakTooltipListener;
94
93
95
    /** Creates a new instance of TabbedAdapter */
94
    /** Creates a new instance of TabbedAdapter */
96
    public TabbedAdapter (int type) {
95
    public TabbedAdapter (int type, WinsysInfoForTabbedContainer winsysInfo) {
97
        super (null, type, new WinsysInfo(type));
96
        super (null, type, winsysInfo);
98
        getSelectionModel().addChangeListener(new ChangeListener() {
97
        getSelectionModel().addChangeListener(new ChangeListener() {
99
            @Override
98
            @Override
100
            public void stateChanged (ChangeEvent ce) {
99
            public void stateChanged (ChangeEvent ce) {
Lines 104-201 Link Here
104
                }
103
                }
105
            }
104
            }
106
        });
105
        });
107
//        Color fillC = (Color)UIManager.get("nb_workplace_fill"); //NOI18N
108
//        if (fillC != null) setBackground (fillC);
109
    }
106
    }
110
    
107
    
111
    @Override
112
    public void addTopComponent(String name, javax.swing.Icon icon, TopComponent tc, String toolTip) {
113
        insertComponent (name, icon, tc, toolTip, getTabCount());
114
    }
115
    
116
    @Override
117
    public TopComponent getTopComponentAt(int index) {
118
        if (index == -1 || index >= getModel().size()) {
119
            return null;
120
        }
121
        return (TopComponent)getModel().getTab(index).getComponent();
122
    }
123
    
124
    @Override
125
    public TopComponent getSelectedTopComponent() {
126
        int i = getSelectionModel().getSelectedIndex();
127
        return i == -1 ? null : getTopComponentAt(i);
128
    }
129
    
130
    @Override
131
    public void requestAttention (TopComponent tc) {
132
        int idx = indexOf(tc);
133
        if (idx >= 0) {
134
            requestAttention(idx);
135
        } else {
136
            Logger.getAnonymousLogger().fine(
137
                "RequestAttention on component unknown to container: " + tc); //NOI18N
138
        }
139
    }
140
141
    @Override
142
    public void cancelRequestAttention (TopComponent tc) {
143
        int idx = indexOf(tc);
144
        if (idx >= 0) {
145
            cancelRequestAttention(idx);
146
        } else {
147
            throw new IllegalArgumentException ("TopComponent " + tc 
148
                + " is not a child of this container"); //NOI18N
149
        }
150
    }    
151
152
    @Override
153
    public void insertComponent(String name, javax.swing.Icon icon, Component comp, String toolTip, int position) {
154
        TabData td = new TabData (comp, icon, name, toolTip);
155
        
156
        if(DEBUG) {
157
            debugLog("InsertTab: " + name + " hash:" + System.identityHashCode(comp)); // NOI18N
158
        }
159
        
160
        getModel().addTab(position, td);
161
        comp.addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comp));
162
    }
163
 
164
    @Override
165
    public void setSelectedComponent(Component comp) {
166
        int i = indexOf (comp);
167
        if (i == -1 && null != comp) {
168
            throw new IllegalArgumentException (
169
                "Component not a child of this control: " + comp); //NOI18N
170
        } else {
171
            getSelectionModel().setSelectedIndex(i);
172
        }
173
    }
174
    
175
    @Override
176
    public TopComponent[] getTopComponents() {
177
        ComponentConverter cc = getComponentConverter();
178
        TabData[] td = (TabData[]) getModel().getTabs().toArray(new TabData[0]);
179
        TopComponent[] result = new TopComponent[getModel().size()];
180
        for (int i=0; i < td.length; i++) {
181
            result[i] = (TopComponent) cc.getComponent(td[i]);
182
        }
183
        return result;
184
    }
185
    
186
    @Override
187
    public void removeComponent(Component comp) {
188
        int i=indexOf(comp);
189
        getModel().removeTab(i);
190
        comp.removePropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comp));
191
        if (getModel().size() == 0) {
192
            revalidate();
193
            repaint();
194
        }
195
    }
196
108
197
    public void addComponents(Component[] comps, String[] names, javax.swing.Icon[] icons, String[] tips) {
109
    public void addComponents(Component[] comps, String[] names, javax.swing.Icon[] icons, String[] tips) {
198
        ArrayList al = new ArrayList (comps.length);
199
        TabData[] data = new TabData[comps.length];
110
        TabData[] data = new TabData[comps.length];
200
        for (int i=0; i < comps.length; i++) {
111
        for (int i=0; i < comps.length; i++) {
201
            TabData td = new TabData (comps[i], icons[i], names[i], tips[i]);
112
            TabData td = new TabData (comps[i], icons[i], names[i], tips[i]);
Lines 205-269 Link Here
205
        getModel().addTabs (0, data);
116
        getModel().addTabs (0, data);
206
    }
117
    }
207
118
208
    @Override
209
    public void setTopComponents(TopComponent[] tcs, TopComponent selected) {
210
        // #100144 - correct null selection and log, probably some problem in
211
        // winsys model consistency, but without reproduction no chance to find out
212
        if (selected == null && tcs.length > 0) {
213
            selected = tcs[0];
214
            Logger.getLogger(TabbedAdapter.class.getName()).warning(
215
                    "Selected component is null although open components are " +
216
                    Arrays.asList(tcs));
217
        }
218
        int sizeBefore = getModel().size();
219
220
        detachTooltipListeners(getModel().getTabs());
221
        
222
        TabData[] data = new TabData[tcs.length];
223
        int toSelect=-1;
224
        for(int i = 0; i < tcs.length; i++) {
225
            TopComponent tc = tcs[i];
226
            Image icon = tc.getIcon();
227
            String displayName = WindowManagerImpl.getInstance().getTopComponentDisplayName(tc);
228
            data[i] = new TabData(
229
                tc,
230
                icon == null ? null : new ImageIcon(icon),
231
                displayName == null ? "" : displayName, // NOI18N
232
                tc.getToolTipText());
233
            if (selected == tcs[i]) {
234
                toSelect = i;
235
            }
236
            tc.addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(tc));
237
        }
238
239
        //DO NOT DELETE THIS ASSERTION AGAIN!
240
        //If it triggered, it means there is a problem in the state of the
241
        //window system's model.  If it is just diagnostic logging, there
242
        //*will* be an exception later, it just won't contain any useful
243
        //information. See issue 39914 for what happens if it is deleted.
244
        assert selected != null && toSelect != -1 : "Tried to set a selected component that was " +
245
            " not in the array of open components. ToSelect: " + selected + " ToSelectName=" + selected.getDisplayName() +
246
            " ToSelectClass=" + selected.getClass() + 
247
            " open components: " + Arrays.asList(tcs);
248
        
249
        getModel().setTabs(data);
250
        
251
        if (toSelect != -1) {
252
            getSelectionModel().setSelectedIndex(toSelect);
253
        } else if (selected != null) {
254
            //Assertions are off
255
            Logger.getAnonymousLogger().warning("Tried to" +
256
            "set a selected component that was not in the array of open " +
257
            "components.  ToSelect: " + selected + " components: " + 
258
            Arrays.asList(tcs));
259
        }
260
        int sizeNow = getModel().size();
261
        if (sizeBefore != 0 && sizeNow == 0) {
262
            //issue 40076, ensure repaint if the control has been emptied.
263
            revalidate();
264
            repaint();
265
        }
266
    }
267
119
268
    /** Removes tooltip listeners from given tabs */
120
    /** Removes tooltip listeners from given tabs */
269
    private void detachTooltipListeners(List tabs) {
121
    private void detachTooltipListeners(List tabs) {
Lines 275-361 Link Here
275
        }
127
        }
276
    }
128
    }
277
    
129
    
278
    // DnD>>
279
    /** Finds tab which contains x coordinate of given location point.
280
     * @param location The point for which a constraint is required
281
     * @return Integer object representing found tab index. Returns null if
282
     * no such tab can be found.
283
     */
284
    @Override
285
    public Object getConstraintForLocation(Point location, boolean attachingPossible) {
286
        //#47909
287
        // first process the tabs when mouse is inside the tabs area..
288
        int tab = tabForCoordinate(location);
289
        if (tab != -1) {
290
            int index = dropIndexOfPoint(location);
291
            return index < 0 ? null : Integer.valueOf(index);
292
        }
293
        // ----
294
        if(attachingPossible) {
295
            String s = getSideForLocation(location);
296
            if(s != null) {
297
                return s;
298
            }
299
        }
300
        int index = dropIndexOfPoint(location);
301
        return index < 0 ? null : Integer.valueOf(index);
302
    }
303
304
    /** Computes and returns feedback indication shape for given location
305
     * point.
306
     * TBD - extend for various feedback types
307
     * @return Shape representing feedback indication
308
     */
309
    @Override
310
    public Shape getIndicationForLocation(Point location,
311
        TopComponentDraggable startingTransfer, Point startingPoint, boolean attachingPossible) {
312
313
        Rectangle rect = getBounds();
314
        rect.setLocation(0, 0);
315
        
316
        TopComponent draggedTC = startingTransfer.getTopComponent();
317
        //#47909
318
        int tab = tabForCoordinate(location);
319
        // first process the tabs when mouse is inside the tabs area..
320
        // need to process before the side resolution.
321
        if (tab != -1) {
322
            Shape s = getDropIndication(draggedTC, location);
323
            if(s != null) {
324
                return s;
325
            }
326
        }
327
        
328
        String side;
329
        if(attachingPossible) {
330
            side = getSideForLocation(location);
331
        } else {
332
            side = null;
333
        }
334
        
335
        double ratio = Constants.DROP_TO_SIDE_RATIO;
336
        if(side == Constants.TOP) {
337
            return new Rectangle(0, 0, rect.width, (int)(rect.height * ratio));
338
        } else if(side == Constants.LEFT) {
339
            return new Rectangle(0, 0, (int)(rect.width * ratio), rect.height);
340
        } else if(side == Constants.RIGHT) {
341
            return new Rectangle(rect.width - (int)(rect.width * ratio), 0, (int)(rect.width * ratio), rect.height);
342
        } else if(side == Constants.BOTTOM) {
343
            return new Rectangle(0, rect.height - (int)(rect.height * ratio), rect.width, (int)(rect.height * ratio));
344
        }
345
346
        // #47909 now check shape again.. when no sides were checked, assume changing tabs when in component center.
347
        Shape s = getDropIndication(draggedTC, location);
348
        if(s != null) {
349
            return s;
350
        }
351
        
352
        if( startingTransfer.isTopComponentTransfer() && startingPoint != null 
353
            && indexOf(startingTransfer.getTopComponent()) != -1) {
354
            return getStartingIndication(startingPoint, location);
355
        }
356
        
357
        return rect;
358
    }
359
130
360
    private String getSideForLocation(Point location) {
131
    private String getSideForLocation(Point location) {
361
        Rectangle bounds = getBounds();
132
        Rectangle bounds = getBounds();
Lines 420-443 Link Here
420
    // DnD<<
191
    // DnD<<
421
192
422
    
193
    
423
    /** Registers ChangeListener to receive events.
424
     * @param listener The listener to register.
425
     *
426
     */
427
    @Override
428
    public void addChangeListener(ChangeListener listener) {
429
        cs.addChangeListener(listener);
430
    }    
431
    
432
    /** Removes ChangeListener from the list of listeners.
433
     * @param listener The listener to remove.
434
     *
435
     */
436
    @Override
437
    public void removeChangeListener(ChangeListener listener) {
438
        cs.removeChangeListener(listener);
439
    }
440
    
441
    /** Notifies all registered listeners about the event. */
194
    /** Notifies all registered listeners about the event. */
442
    private void fireStateChanged() {
195
    private void fireStateChanged() {
443
        if (!SwingUtilities.isEventDispatchThread()) {
196
        if (!SwingUtilities.isEventDispatchThread()) {
Lines 472-496 Link Here
472
        Debug.log(TabbedAdapter.class, message);
225
        Debug.log(TabbedAdapter.class, message);
473
    }
226
    }
474
    
227
    
475
    @Override
476
    public Component getComponent() {
477
        return this;
478
    }
479
    
480
    /** Add action for enabling auto hide of views */
481
    @Override
482
    public Action[] getPopupActions(Action[] defaultActions, int tabIndex) {
483
        if( tabIndex < 0 ) {
484
            ModeImpl mode = getModeImpl();
485
            if( null != mode )
486
                return ActionUtils.createDefaultPopupActions( mode );
487
            return null;
488
        }
489
        return defaultActions;
490
    }
491
    
492
    private ModeImpl getModeImpl() {
228
    private ModeImpl getModeImpl() {
493
        TopComponent[] topComponents = getTopComponents();
229
        TopComponent[] topComponents = tabbedImpl.getTopComponents();
494
        if( topComponents.length < 1 )
230
        if( topComponents.length < 1 )
495
            return null;
231
            return null;
496
        return ( ModeImpl ) WindowManagerImpl.getInstance().findMode( topComponents[0] );
232
        return ( ModeImpl ) WindowManagerImpl.getInstance().findMode( topComponents[0] );
Lines 525-546 Link Here
525
    
261
    
526
    @Override
262
    @Override
527
    public Tabbed getTabbed() {
263
    public Tabbed getTabbed() {
528
        return this;
264
        return tabbedImpl;
529
    }
530
    
531
    @Override
532
    public Rectangle getTabBounds(int tabIndex) {
533
        return getTabRect(tabIndex, new Rectangle());
534
    }
535
    
536
    @Override
537
    public Rectangle getTabsArea() {
538
        return getUI().getTabsArea();
539
    }
265
    }
540
266
541
    /********* implementation of WinsysInfoForTabbed ********/
267
    /********* implementation of WinsysInfoForTabbed ********/
542
    
268
    
543
    static class WinsysInfo extends WinsysInfoForTabbedContainer {
269
    public static class WinsysInfo extends WinsysInfoForTabbedContainer {
544
        private int containerType;
270
        private int containerType;
545
        public WinsysInfo( int containerType ) {
271
        public WinsysInfo( int containerType ) {
546
            this.containerType = containerType;
272
            this.containerType = containerType;
Lines 628-633 Link Here
628
        }
354
        }
629
        return weakTooltipListener;
355
        return weakTooltipListener;
630
    }
356
    }
357
    
358
    private final Tabbed tabbedImpl = new Tabbed() {
359
360
        @Override
361
        public void addTopComponent(String name, javax.swing.Icon icon, TopComponent tc, String toolTip) {
362
            insertComponent (name, icon, tc, toolTip, getTabCount());
363
        }
364
365
        @Override
366
        public TopComponent getTopComponentAt(int index) {
367
            if (index == -1 || index >= getModel().size()) {
368
                return null;
369
            }
370
            return (TopComponent)getModel().getTab(index).getComponent();
371
        }
372
373
        @Override
374
        public TopComponent getSelectedTopComponent() {
375
            int i = getSelectionModel().getSelectedIndex();
376
            return i == -1 ? null : getTopComponentAt(i);
377
        }
378
379
        @Override
380
        public void requestAttention (TopComponent tc) {
381
            int idx = indexOf(tc);
382
            if (idx >= 0) {
383
                TabbedAdapter.this.requestAttention(idx);
384
            } else {
385
                Logger.getAnonymousLogger().fine(
386
                    "RequestAttention on component unknown to container: " + tc); //NOI18N
387
            }
388
        }
389
390
        @Override
391
        public void cancelRequestAttention (TopComponent tc) {
392
            int idx = indexOf(tc);
393
            if (idx >= 0) {
394
                TabbedAdapter.this.cancelRequestAttention(idx);
395
            } else {
396
                throw new IllegalArgumentException ("TopComponent " + tc 
397
                    + " is not a child of this container"); //NOI18N
398
            }
399
        }    
400
401
        @Override
402
        public void insertComponent(String name, javax.swing.Icon icon, Component comp, String toolTip, int position) {
403
            TabData td = new TabData (comp, icon, name, toolTip);
404
405
            if(DEBUG) {
406
                debugLog("InsertTab: " + name + " hash:" + System.identityHashCode(comp)); // NOI18N
407
            }
408
409
            getModel().addTab(position, td);
410
            comp.addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comp));
411
        }
412
413
        @Override
414
        public void setSelectedComponent(Component comp) {
415
            int i = indexOf (comp);
416
            if (i == -1 && null != comp) {
417
                throw new IllegalArgumentException (
418
                    "Component not a child of this control: " + comp); //NOI18N
419
            } else {
420
                getSelectionModel().setSelectedIndex(i);
421
            }
422
        }
423
424
        @Override
425
        public TopComponent[] getTopComponents() {
426
            ComponentConverter cc = getComponentConverter();
427
            TabData[] td = (TabData[]) getModel().getTabs().toArray(new TabData[0]);
428
            TopComponent[] result = new TopComponent[getModel().size()];
429
            for (int i=0; i < td.length; i++) {
430
                result[i] = (TopComponent) cc.getComponent(td[i]);
431
            }
432
            return result;
433
        }
434
435
        @Override
436
        public void removeComponent(Component comp) {
437
            int i=indexOf(comp);
438
            getModel().removeTab(i);
439
            comp.removePropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comp));
440
            if (getModel().size() == 0) {
441
                revalidate();
442
                repaint();
443
            }
444
        }
445
446
        @Override
447
        public Rectangle getTabBounds(int tabIndex) {
448
            return getTabRect(tabIndex, new Rectangle());
449
        }
450
451
        @Override
452
        public Rectangle getTabsArea() {
453
            return getUI().getTabsArea();
454
        }
455
456
        @Override
457
        public void setTopComponents(TopComponent[] tcs, TopComponent selected) {
458
            // #100144 - correct null selection and log, probably some problem in
459
            // winsys model consistency, but without reproduction no chance to find out
460
            if (selected == null && tcs.length > 0) {
461
                selected = tcs[0];
462
                Logger.getLogger(TabbedAdapter.class.getName()).warning(
463
                        "Selected component is null although open components are " +
464
                        Arrays.asList(tcs));
465
            }
466
            int sizeBefore = getModel().size();
467
468
            detachTooltipListeners(getModel().getTabs());
469
470
            TabData[] data = new TabData[tcs.length];
471
            int toSelect=-1;
472
            for(int i = 0; i < tcs.length; i++) {
473
                TopComponent tc = tcs[i];
474
                Image icon = tc.getIcon();
475
                String displayName = WindowManagerImpl.getInstance().getTopComponentDisplayName(tc);
476
                data[i] = new TabData(
477
                    tc,
478
                    icon == null ? null : new ImageIcon(icon),
479
                    displayName == null ? "" : displayName, // NOI18N
480
                    tc.getToolTipText());
481
                if (selected == tcs[i]) {
482
                    toSelect = i;
483
                }
484
                tc.addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(tc));
485
            }
486
487
            //DO NOT DELETE THIS ASSERTION AGAIN!
488
            //If it triggered, it means there is a problem in the state of the
489
            //window system's model.  If it is just diagnostic logging, there
490
            //*will* be an exception later, it just won't contain any useful
491
            //information. See issue 39914 for what happens if it is deleted.
492
            assert selected != null && toSelect != -1 : "Tried to set a selected component that was " +
493
                " not in the array of open components. ToSelect: " + selected + " ToSelectName=" + selected.getDisplayName() +
494
                " ToSelectClass=" + selected.getClass() + 
495
                " open components: " + Arrays.asList(tcs);
496
497
            getModel().setTabs(data);
498
499
            if (toSelect != -1) {
500
                getSelectionModel().setSelectedIndex(toSelect);
501
            } else if (selected != null) {
502
                //Assertions are off
503
                Logger.getAnonymousLogger().warning("Tried to" +
504
                "set a selected component that was not in the array of open " +
505
                "components.  ToSelect: " + selected + " components: " + 
506
                Arrays.asList(tcs));
507
            }
508
            int sizeNow = getModel().size();
509
            if (sizeBefore != 0 && sizeNow == 0) {
510
                //issue 40076, ensure repaint if the control has been emptied.
511
                revalidate();
512
                repaint();
513
            }
514
        }
515
        // DnD>>
516
        /** Finds tab which contains x coordinate of given location point.
517
        * @param location The point for which a constraint is required
518
        * @return Integer object representing found tab index. Returns null if
519
        * no such tab can be found.
520
        */
521
        @Override
522
        public Object getConstraintForLocation(Point location, boolean attachingPossible) {
523
            //#47909
524
            // first process the tabs when mouse is inside the tabs area..
525
            int tab = tabForCoordinate(location);
526
            if (tab != -1) {
527
                int index = dropIndexOfPoint(location);
528
                return index < 0 ? null : Integer.valueOf(index);
529
            }
530
            // ----
531
            if(attachingPossible) {
532
                String s = getSideForLocation(location);
533
                if(s != null) {
534
                    return s;
535
                }
536
            }
537
            int index = dropIndexOfPoint(location);
538
            return index < 0 ? null : Integer.valueOf(index);
539
        }
540
541
        /** Computes and returns feedback indication shape for given location
542
        * point.
543
        * TBD - extend for various feedback types
544
        * @return Shape representing feedback indication
545
        */
546
        @Override
547
        public Shape getIndicationForLocation(Point location,
548
            TopComponent startingTransfer, Point startingPoint, boolean attachingPossible) {
549
550
            Rectangle rect = getBounds();
551
            rect.setLocation(0, 0);
552
553
            TopComponent draggedTC = startingTransfer;
554
            //#47909
555
            int tab = tabForCoordinate(location);
556
            // first process the tabs when mouse is inside the tabs area..
557
            // need to process before the side resolution.
558
            if (tab != -1) {
559
                Shape s = getDropIndication(draggedTC, location);
560
                if(s != null) {
561
                    return s;
562
                }
563
            }
564
565
            String side;
566
            if(attachingPossible) {
567
                side = getSideForLocation(location);
568
            } else {
569
                side = null;
570
            }
571
572
            double ratio = Constants.DROP_TO_SIDE_RATIO;
573
            if(side == Constants.TOP) {
574
                return new Rectangle(0, 0, rect.width, (int)(rect.height * ratio));
575
            } else if(side == Constants.LEFT) {
576
                return new Rectangle(0, 0, (int)(rect.width * ratio), rect.height);
577
            } else if(side == Constants.RIGHT) {
578
                return new Rectangle(rect.width - (int)(rect.width * ratio), 0, (int)(rect.width * ratio), rect.height);
579
            } else if(side == Constants.BOTTOM) {
580
                return new Rectangle(0, rect.height - (int)(rect.height * ratio), rect.width, (int)(rect.height * ratio));
581
            }
582
583
            // #47909 now check shape again.. when no sides were checked, assume changing tabs when in component center.
584
            Shape s = getDropIndication(draggedTC, location);
585
            if(s != null) {
586
                return s;
587
            }
588
589
            if( null != startingTransfer && startingPoint != null 
590
                && indexOf(startingTransfer) != -1) {
591
                return getStartingIndication(startingPoint, location);
592
            }
593
594
            return rect;
595
        }
596
597
        @Override
598
        public Component getComponent() {
599
            return TabbedAdapter.this;
600
        }
601
602
        /** Add action for enabling auto hide of views */
603
        @Override
604
        public Action[] getPopupActions(Action[] defaultActions, int tabIndex) {
605
            if( tabIndex < 0 ) {
606
                ModeImpl mode = getModeImpl();
607
                if( null != mode )
608
                    return ActionUtils.createDefaultPopupActions( mode );
609
                return null;
610
            }
611
            return defaultActions;
612
        }
613
614
        /** Registers ChangeListener to receive events.
615
        * @param listener The listener to register.
616
        *
617
        */
618
        @Override
619
        public void addChangeListener(ChangeListener listener) {
620
            cs.addChangeListener(listener);
621
        }    
622
623
        /** Removes ChangeListener from the list of listeners.
624
        * @param listener The listener to remove.
625
        *
626
        */
627
        @Override
628
        public void removeChangeListener(ChangeListener listener) {
629
            cs.removeChangeListener(listener);
630
        }
631
632
        @Override
633
        public int getTabCount() {
634
            return TabbedAdapter.this.getTabCount();
635
        }
636
637
        @Override
638
        public int indexOf( Component tc ) {
639
            return TabbedAdapter.this.indexOf( tc );
640
        }
641
642
        @Override
643
        public void setTitleAt( int index, String title ) {
644
            TabbedAdapter.this.setTitleAt( index, title );
645
        }
646
647
        @Override
648
        public void setIconAt( int index, Icon icon ) {
649
            TabbedAdapter.this.setIconAt( index, icon );
650
        }
651
652
        @Override
653
        public void setToolTipTextAt( int index, String toolTip ) {
654
            TabbedAdapter.this.setToolTipTextAt( index, toolTip );
655
        }
656
657
        @Override
658
        public void addActionListener( ActionListener al ) {
659
            TabbedAdapter.this.addActionListener( al );
660
        }
661
662
        @Override
663
        public void removeActionListener( ActionListener al ) {
664
            TabbedAdapter.this.removeActionListener( al );
665
        }
666
667
        @Override
668
        public void setActive( boolean active ) {
669
            TabbedAdapter.this.setActive( active );
670
        }
671
672
        @Override
673
        public int tabForCoordinate( Point p ) {
674
            return TabbedAdapter.this.tabForCoordinate( p );
675
        }
676
677
        @Override
678
        public Image createImageOfTab( int tabIndex ) {
679
            return TabbedAdapter.this.createImageOfTab( tabIndex );
680
        }
681
682
        @Override
683
        public boolean isTransparent() {
684
            return TabbedAdapter.this.isTransparent();
685
        }
686
687
        @Override
688
        public void setTransparent( boolean transparent ) {
689
            TabbedAdapter.this.setTransparent( transparent );
690
        }
691
    
692
    };
631
693
632
    /** Listening to changes of tooltips of currently asociated top components */
694
    /** Listening to changes of tooltips of currently asociated top components */
633
    private class ToolTipListener implements PropertyChangeListener {
695
    private class ToolTipListener implements PropertyChangeListener {

Return to bug 169099