Lines 42-48
Link Here
|
42 |
* made subject to such option by the copyright holder. |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
43 |
*/ |
44 |
|
44 |
|
45 |
package org.openide.awt; |
45 |
package org.netbeans.core.windows.view.ui; |
46 |
|
46 |
|
47 |
import java.awt.*; |
47 |
import java.awt.*; |
48 |
import java.awt.event.ActionEvent; |
48 |
import java.awt.event.ActionEvent; |
Lines 56-76
Link Here
|
56 |
import java.util.regex.Pattern; |
56 |
import java.util.regex.Pattern; |
57 |
import javax.swing.*; |
57 |
import javax.swing.*; |
58 |
import javax.swing.plaf.UIResource; |
58 |
import javax.swing.plaf.UIResource; |
|
|
59 |
import org.netbeans.core.windows.actions.MaximizeWindowAction; |
60 |
import org.openide.awt.CloseButtonFactory; |
61 |
import org.openide.awt.TabbedPaneFactory; |
59 |
import org.openide.util.Exceptions; |
62 |
import org.openide.util.Exceptions; |
60 |
import org.openide.util.Utilities; |
63 |
import org.openide.util.Utilities; |
|
|
64 |
import org.openide.windows.TopComponent; |
61 |
|
65 |
|
62 |
/** |
66 |
/** |
63 |
* Copy of original CloseButtonTabbedPane from the NetBeans 3.4 winsys. Old code never dies. |
67 |
* Copy of original CloseButtonTabbedPane from the NetBeans 3.4 winsys. Old code never dies. |
|
|
68 |
* (moved from openide.awt module) |
64 |
* |
69 |
* |
65 |
* @author Tran Duc Trung |
70 |
* @author Tran Duc Trung |
66 |
* @author S. Aubrecht |
71 |
* @author S. Aubrecht |
67 |
* @since 6.10.0 |
72 |
* @since 2.52 |
68 |
* |
73 |
* |
69 |
*/ |
74 |
*/ |
70 |
final class CloseButtonTabbedPane extends JTabbedPane implements PropertyChangeListener { |
75 |
final class CloseButtonTabbedPane extends JTabbedPane implements PropertyChangeListener { |
71 |
|
76 |
|
72 |
static final String PROP_CLOSE = "close"; |
|
|
73 |
|
74 |
CloseButtonTabbedPane() { |
77 |
CloseButtonTabbedPane() { |
75 |
// close tab via middle button |
78 |
// close tab via middle button |
76 |
addMouseListener(new MouseAdapter() { |
79 |
addMouseListener(new MouseAdapter() { |
Lines 96-101
Link Here
|
96 |
lastIdx = -1; |
99 |
lastIdx = -1; |
97 |
} |
100 |
} |
98 |
} |
101 |
} |
|
|
102 |
|
103 |
@Override |
104 |
public void mouseClicked( MouseEvent e ) { |
105 |
if( e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton( e ) ) { |
106 |
//toggle maximize |
107 |
TopComponent tc = ( TopComponent ) SwingUtilities.getAncestorOfClass( TopComponent.class, CloseButtonTabbedPane.this ); |
108 |
if( null != tc ) { |
109 |
MaximizeWindowAction mwa = new MaximizeWindowAction(tc); |
110 |
if( mwa.isEnabled() ) |
111 |
mwa.actionPerformed(null); |
112 |
} |
113 |
} |
114 |
} |
115 |
|
116 |
|
99 |
}); |
117 |
}); |
100 |
//Bugfix #28263: Disable focus. |
118 |
//Bugfix #28263: Disable focus. |
101 |
setFocusable(false); |
119 |
setFocusable(false); |
Lines 110-131
Link Here
|
110 |
} |
128 |
} |
111 |
|
129 |
|
112 |
private class CBTPPolicy extends FocusTraversalPolicy { |
130 |
private class CBTPPolicy extends FocusTraversalPolicy { |
|
|
131 |
@Override |
113 |
public Component getComponentAfter(Container aContainer, Component aComponent) { |
132 |
public Component getComponentAfter(Container aContainer, Component aComponent) { |
114 |
return sel(); |
133 |
return sel(); |
115 |
} |
134 |
} |
116 |
|
135 |
|
|
|
136 |
@Override |
117 |
public Component getComponentBefore(Container aContainer, Component aComponent) { |
137 |
public Component getComponentBefore(Container aContainer, Component aComponent) { |
118 |
return sel(); |
138 |
return sel(); |
119 |
} |
139 |
} |
120 |
|
140 |
|
|
|
141 |
@Override |
121 |
public Component getFirstComponent(Container aContainer) { |
142 |
public Component getFirstComponent(Container aContainer) { |
122 |
return sel(); |
143 |
return sel(); |
123 |
} |
144 |
} |
124 |
|
145 |
|
|
|
146 |
@Override |
125 |
public Component getLastComponent(Container aContainer) { |
147 |
public Component getLastComponent(Container aContainer) { |
126 |
return sel(); |
148 |
return sel(); |
127 |
} |
149 |
} |
128 |
|
150 |
|
|
|
151 |
@Override |
129 |
public Component getDefaultComponent(Container aContainer) { |
152 |
public Component getDefaultComponent(Container aContainer) { |
130 |
return sel(); |
153 |
return sel(); |
131 |
} |
154 |
} |
Lines 359-365
Link Here
|
359 |
} |
382 |
} |
360 |
|
383 |
|
361 |
private void fireCloseRequest(Component c) { |
384 |
private void fireCloseRequest(Component c) { |
362 |
firePropertyChange(PROP_CLOSE, null, c); |
385 |
firePropertyChange(TabbedPaneFactory.PROP_CLOSE, null, c); |
363 |
if (getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { |
386 |
if (getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { |
364 |
int idx = getSelectedIndex(); |
387 |
int idx = getSelectedIndex(); |
365 |
if (idx > 0) { |
388 |
if (idx > 0) { |
Lines 438-443
Link Here
|
438 |
return super.getBackgroundAt(index); |
461 |
return super.getBackgroundAt(index); |
439 |
} |
462 |
} |
440 |
|
463 |
|
|
|
464 |
@Override |
441 |
public void propertyChange(PropertyChangeEvent evt) { |
465 |
public void propertyChange(PropertyChangeEvent evt) { |
442 |
if (evt.getSource() instanceof Component) { |
466 |
if (evt.getSource() instanceof Component) { |
443 |
assert evt.getPropertyName().equals(TabbedPaneFactory.NO_CLOSE_BUTTON); |
467 |
assert evt.getPropertyName().equals(TabbedPaneFactory.NO_CLOSE_BUTTON); |