Lines 46-51
Link Here
|
46 |
|
46 |
|
47 |
import java.awt.*; |
47 |
import java.awt.*; |
48 |
import java.awt.event.*; |
48 |
import java.awt.event.*; |
|
|
49 |
import java.beans.PropertyChangeEvent; |
50 |
import java.beans.PropertyChangeListener; |
49 |
import java.util.Enumeration; |
51 |
import java.util.Enumeration; |
50 |
import java.util.HashSet; |
52 |
import java.util.HashSet; |
51 |
import java.util.Set; |
53 |
import java.util.Set; |
Lines 72-81
Link Here
|
72 |
MultiViewModel model; |
74 |
MultiViewModel model; |
73 |
private MouseListener buttonMouseListener = null; |
75 |
private MouseListener buttonMouseListener = null; |
74 |
private JComponent toolbarPanel; |
76 |
private JComponent toolbarPanel; |
|
|
77 |
private JComponent toolbarPanelSplit; |
75 |
JPanel componentPanel; /** package private for tests */ |
78 |
JPanel componentPanel; /** package private for tests */ |
|
|
79 |
JPanel componentPanelSplit; /** package private for tests */ |
76 |
private CardLayout cardLayout; |
80 |
private CardLayout cardLayout; |
|
|
81 |
private CardLayout cardLayoutSplit; |
77 |
private Set<MultiViewElement> alreadyAddedElements; |
82 |
private Set<MultiViewElement> alreadyAddedElements; |
|
|
83 |
private Set<MultiViewElement> alreadyAddedElementsSplit; |
78 |
private JToolBar bar; |
84 |
private JToolBar bar; |
|
|
85 |
private JToolBar barSplit; |
86 |
|
87 |
private JSplitPane splitPane; |
88 |
private AWTEventListener awtEventListener; |
89 |
private boolean isTopLeft = true; |
90 |
private JPanel topLeftComponent; |
91 |
private JPanel bottomRightComponent; |
92 |
private Dimension barMinSize; |
93 |
private Dimension panelMinSizep; |
94 |
private MultiViewDescription[] topBottomDescriptions = null; |
95 |
private PropertyChangeListener splitterPropertyChangeListener; |
96 |
private boolean removeSplit = false; |
97 |
private MultiViewPeer mvPeer; |
98 |
private boolean hiddenTriggeredByMultiViewButton = false; |
79 |
|
99 |
|
80 |
private static final boolean AQUA = "Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N |
100 |
private static final boolean AQUA = "Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N |
81 |
|
101 |
|
Lines 124-140
Link Here
|
124 |
int prefHeight = -1; |
144 |
int prefHeight = -1; |
125 |
int prefWidth = -1; |
145 |
int prefWidth = -1; |
126 |
for (int i = 0; i < descs.length; i++) { |
146 |
for (int i = 0; i < descs.length; i++) { |
127 |
JToggleButton button = createButton(descs[i]); |
147 |
boolean shouldCreateToggleButton = true; |
128 |
model.getButtonGroup().add(button); |
148 |
if(descs[i] instanceof ContextAwareDescription) { |
129 |
GridBagConstraints cons = new GridBagConstraints(); |
149 |
shouldCreateToggleButton = !((ContextAwareDescription)descs[i]).isSplitDescription(); |
130 |
cons.anchor = GridBagConstraints.WEST; |
150 |
} |
131 |
prefHeight = Math.max(button.getPreferredSize().height, prefHeight); |
151 |
if (shouldCreateToggleButton) { |
132 |
bar.add(button, cons); |
152 |
JToggleButton button = createButton(descs[i]); |
133 |
prefWidth = Math.max(button.getPreferredSize().width, prefWidth); |
153 |
model.getButtonGroup().add(button); |
134 |
if (descs[i] == model.getActiveDescription()) { |
154 |
GridBagConstraints cons = new GridBagConstraints(); |
135 |
active = button; |
155 |
cons.anchor = GridBagConstraints.WEST; |
136 |
|
156 |
prefHeight = Math.max(button.getPreferredSize().height, prefHeight); |
137 |
} |
157 |
bar.add(button, cons); |
|
|
158 |
prefWidth = Math.max(button.getPreferredSize().width, prefWidth); |
159 |
if (descs[i] == model.getActiveDescription()) { |
160 |
active = button; |
161 |
} |
162 |
} |
138 |
} |
163 |
} |
139 |
Enumeration en = model.getButtonGroup().getElements(); |
164 |
Enumeration en = model.getButtonGroup().getElements(); |
140 |
while (en.hasMoreElements()) { |
165 |
while (en.hasMoreElements()) { |
Lines 158-164
Link Here
|
158 |
} |
183 |
} |
159 |
|
184 |
|
160 |
|
185 |
|
161 |
void switchToCard(MultiViewElement elem, String id) { |
186 |
MultiViewDescription getTopComponentDescription() { |
|
|
187 |
return topBottomDescriptions == null ? model.getActiveDescription() : topBottomDescriptions[0]; |
188 |
} |
189 |
|
190 |
MultiViewDescription getBottomComponentDescription() { |
191 |
return topBottomDescriptions == null ? model.getActiveDescription() : topBottomDescriptions[1]; |
192 |
} |
193 |
|
194 |
void peerClearSplit() { |
195 |
MultiViewDescription activeDescription = topBottomDescriptions[0]; |
196 |
Toolkit.getDefaultToolkit().removeAWTEventListener(getAWTEventListener()); |
197 |
splitPane.removePropertyChangeListener(splitterPropertyChangeListener); |
198 |
removeAll(); |
199 |
splitPane = null; |
200 |
topBottomDescriptions = null; |
201 |
isTopLeft = true; |
202 |
topLeftComponent = null; |
203 |
bottomRightComponent = null; |
204 |
alreadyAddedElementsSplit = null; |
205 |
awtEventListener = null; |
206 |
barSplit = null; |
207 |
cardLayoutSplit = null; |
208 |
componentPanelSplit = null; |
209 |
toolbarPanelSplit = null; |
210 |
splitterPropertyChangeListener = null; |
211 |
mvPeer = null; |
212 |
|
213 |
add(bar, BorderLayout.NORTH); |
214 |
add(componentPanel, BorderLayout.CENTER); |
215 |
model.setActiveDescription(activeDescription); |
216 |
} |
217 |
|
218 |
private void setupSplit() { |
219 |
topLeftComponent = new JPanel(new BorderLayout()); |
220 |
barMinSize = bar.getMinimumSize(); |
221 |
panelMinSizep = componentPanel.getMinimumSize(); |
222 |
topLeftComponent.add(bar, BorderLayout.NORTH); |
223 |
topLeftComponent.add(componentPanel, BorderLayout.CENTER); |
224 |
|
225 |
bottomRightComponent = new JPanel(); |
226 |
barSplit = new JToolBar(); |
227 |
Border b = (Border)UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N |
228 |
barSplit.setBorder(b); |
229 |
barSplit.setFloatable(false); |
230 |
barSplit.setFocusable(true); |
231 |
if( "Windows".equals( UIManager.getLookAndFeel().getID()) |
232 |
&& !isXPTheme()) { |
233 |
barSplit.setRollover(true); |
234 |
} else if( AQUA ) { |
235 |
barSplit.setBackground(UIManager.getColor("NbExplorerView.background")); |
236 |
} |
237 |
|
238 |
bottomRightComponent.setLayout(new BorderLayout()); |
239 |
bottomRightComponent.add(barSplit, BorderLayout.NORTH); |
240 |
startTogglingSplit(); |
241 |
setToolbarBarVisibleSplit(bar.isVisible()); |
242 |
|
243 |
componentPanelSplit = new JPanel(); |
244 |
cardLayoutSplit = new CardLayout(); |
245 |
componentPanelSplit.setLayout(cardLayoutSplit); |
246 |
bottomRightComponent.add(componentPanelSplit, BorderLayout.CENTER); |
247 |
alreadyAddedElementsSplit = new HashSet<MultiViewElement>(); |
248 |
|
249 |
MultiViewDescription[] descs = model.getDescriptions(); |
250 |
MultiViewDescription def = model.getActiveDescription(); |
251 |
GridBagLayout grid = new GridBagLayout(); |
252 |
barSplit.setLayout(grid); |
253 |
JToggleButton activeSplit = null; |
254 |
int prefHeight = -1; |
255 |
int prefWidth = -1; |
256 |
for (int i = 0; i < descs.length; i++) { |
257 |
if (descs[i] instanceof ContextAwareDescription && ((ContextAwareDescription)descs[i]).isSplitDescription()) { |
258 |
JToggleButton button = createButton(descs[i]); |
259 |
model.getButtonGroupSplit().add(button); |
260 |
GridBagConstraints cons = new GridBagConstraints(); |
261 |
cons.anchor = GridBagConstraints.WEST; |
262 |
prefHeight = Math.max(button.getPreferredSize().height, prefHeight); |
263 |
barSplit.add(button, cons); |
264 |
prefWidth = Math.max(button.getPreferredSize().width, prefWidth); |
265 |
if (descs[i].getDisplayName().startsWith(def.getDisplayName())) { |
266 |
activeSplit = button; |
267 |
} |
268 |
} |
269 |
} |
270 |
Enumeration en = model.getButtonGroupSplit().getElements(); |
271 |
while (en.hasMoreElements()) { |
272 |
JToggleButton but = (JToggleButton)en.nextElement(); |
273 |
Insets ins = but.getBorder().getBorderInsets(but); |
274 |
but.setPreferredSize(new Dimension(prefWidth + 10, prefHeight)); |
275 |
but.setMinimumSize(new Dimension(prefWidth + 10, prefHeight)); |
276 |
|
277 |
} |
278 |
if (activeSplit != null) { |
279 |
activeSplit.setSelected(true); |
280 |
} |
281 |
|
282 |
toolbarPanelSplit = getEmptyInnerToolBar(); |
283 |
GridBagConstraints cons = new GridBagConstraints(); |
284 |
cons.anchor = GridBagConstraints.EAST; |
285 |
cons.fill = GridBagConstraints.BOTH; |
286 |
cons.gridwidth = GridBagConstraints.REMAINDER; |
287 |
cons.weightx = 1; |
288 |
|
289 |
barSplit.add(toolbarPanelSplit, cons); |
290 |
} |
291 |
|
292 |
void peerSplitComponent(int orientation, MultiViewPeer mvPeer, MultiViewDescription defaultDesc, MultiViewDescription defaultDescClone) { |
293 |
MultiViewDescription[] descriptions = model.getDescriptions(); |
294 |
this.mvPeer = mvPeer; |
295 |
|
296 |
MultiViewDescription activeDescription = model.getActiveDescription(); |
297 |
if (splitPane == null) { |
298 |
splitPane = new JSplitPane(); |
299 |
topBottomDescriptions = new MultiViewDescription[2]; |
300 |
if (defaultDesc != null && defaultDescClone != null) {// called during deserialization |
301 |
topBottomDescriptions[0] = defaultDesc; |
302 |
topBottomDescriptions[1] = defaultDescClone; |
303 |
} else { |
304 |
int activeDescIndex = 0; |
305 |
for (int i = 0; i < descriptions.length; i++) { |
306 |
MultiViewDescription multiViewDescription = descriptions[i]; |
307 |
if (multiViewDescription.getDisplayName().equals(activeDescription.getDisplayName())) { |
308 |
activeDescIndex = i; |
309 |
break; |
310 |
} |
311 |
} |
312 |
topBottomDescriptions[0] = descriptions[activeDescIndex]; |
313 |
topBottomDescriptions[1] = descriptions[activeDescIndex + 1]; |
314 |
} |
315 |
|
316 |
setupSplit(); |
317 |
splitPane.setOneTouchExpandable(true); |
318 |
splitPane.setContinuousLayout(true); |
319 |
splitPane.setResizeWeight(0.5); |
320 |
|
321 |
removeAll(); |
322 |
Toolkit.getDefaultToolkit().addAWTEventListener(getAWTEventListener(), MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK); |
323 |
add(splitPane, BorderLayout.CENTER); |
324 |
|
325 |
|
326 |
MultiViewDescription bottomDescription = topBottomDescriptions[1]; |
327 |
isTopLeft = false; |
328 |
model.setActiveDescription(bottomDescription); |
329 |
if (defaultDesc != null && defaultDescClone != null) {// called during deserialization |
330 |
selecteAppropriateButton(); |
331 |
} |
332 |
|
333 |
MultiViewDescription topDescription = topBottomDescriptions[0]; |
334 |
isTopLeft = true; |
335 |
model.setActiveDescription(topDescription); |
336 |
if (defaultDesc != null && defaultDescClone != null) {// called during deserialization |
337 |
selecteAppropriateButton(); |
338 |
} |
339 |
} else { |
340 |
topLeftComponent = (JPanel) splitPane.getTopComponent(); |
341 |
bottomRightComponent = (JPanel) splitPane.getBottomComponent(); |
342 |
} |
343 |
if(orientation != splitPane.getOrientation()) { |
344 |
splitPane.removePropertyChangeListener(splitterPropertyChangeListener); |
345 |
splitterPropertyChangeListener = null; |
346 |
} |
347 |
splitPane.setOrientation(orientation); |
348 |
splitPane.setTopComponent(topLeftComponent); |
349 |
splitPane.setBottomComponent(bottomRightComponent); |
350 |
splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, getSplitterPropertyChangeListener(orientation)); |
351 |
topLeftComponent.setMinimumSize(new Dimension(0, 0)); |
352 |
bottomRightComponent.setMinimumSize(new Dimension(0, 0)); |
353 |
} |
354 |
|
355 |
private void selecteAppropriateButton() { |
356 |
Enumeration en = model.getButtonGroupSplit().getElements(); |
357 |
while (en.hasMoreElements()) { |
358 |
JToggleButton but = (JToggleButton) en.nextElement(); |
359 |
MultiViewDescription buttonsDescription = ((TabsButtonModel) but.getModel()).getButtonsDescription(); |
360 |
if (buttonsDescription == (isTopLeft ? topBottomDescriptions[0] : topBottomDescriptions[1])) { |
361 |
but.setSelected(true); |
362 |
} |
363 |
} |
364 |
} |
365 |
|
366 |
private PropertyChangeListener getSplitterPropertyChangeListener(final int orientation) { |
367 |
if (splitterPropertyChangeListener == null) { |
368 |
splitterPropertyChangeListener = new PropertyChangeListener() { |
369 |
@Override |
370 |
public void propertyChange(PropertyChangeEvent pce) { |
371 |
if (splitPane != null) { |
372 |
int current = Integer.parseInt(pce.getNewValue().toString()); |
373 |
int dividerSize = splitPane.getDividerSize(); |
374 |
int splitSize; |
375 |
int topMinSize; |
376 |
int bottomMinSize; |
377 |
if (orientation == JSplitPane.VERTICAL_SPLIT) { |
378 |
splitSize = splitPane.getHeight(); |
379 |
topMinSize = (int) topLeftComponent.getMinimumSize().getHeight(); |
380 |
bottomMinSize = (int) bottomRightComponent.getMinimumSize().getHeight(); |
381 |
} else { |
382 |
splitSize = splitPane.getWidth(); |
383 |
topMinSize = (int) topLeftComponent.getMinimumSize().getWidth(); |
384 |
bottomMinSize = (int) bottomRightComponent.getMinimumSize().getWidth(); |
385 |
} |
386 |
int min = topMinSize; |
387 |
int max = splitSize - bottomMinSize - dividerSize; |
388 |
if (current <= min || current >= max) { |
389 |
removeSplit = true; |
390 |
} else { |
391 |
removeSplit = false; |
392 |
} |
393 |
} |
394 |
} |
395 |
}; |
396 |
} |
397 |
return splitterPropertyChangeListener; |
398 |
} |
399 |
|
400 |
|
401 |
@NbBundle.Messages({"LBL_ClearAllSplitsDialogMessage=Do you really want to clear the split?", |
402 |
"LBL_ClearAllSplitsDialogTitle=Clear Split"}) |
403 |
private AWTEventListener getAWTEventListener() { |
404 |
if (awtEventListener == null) { |
405 |
awtEventListener = new AWTEventListener() { |
406 |
@Override |
407 |
public void eventDispatched(AWTEvent event) { |
408 |
MouseEvent e = (MouseEvent) event; |
409 |
if (splitPane != null && e.getID() == MouseEvent.MOUSE_PRESSED) { |
410 |
MultiViewDescription activeDescription = null; |
411 |
Point locationOnScreen = e.getLocationOnScreen(); |
412 |
SwingUtilities.convertPointFromScreen(locationOnScreen, splitPane); |
413 |
Component component = e.getComponent(); |
414 |
while(component != null && component != splitPane) { |
415 |
component = component.getParent(); |
416 |
} |
417 |
if (component == splitPane && splitPane.getTopComponent().getBounds().contains(locationOnScreen)) { |
418 |
isTopLeft = true; |
419 |
activeDescription = topBottomDescriptions[0]; |
420 |
} else if (component == splitPane && splitPane.getBottomComponent().getBounds().contains(locationOnScreen)) { |
421 |
isTopLeft = false; |
422 |
activeDescription = topBottomDescriptions[1]; |
423 |
} |
424 |
if (activeDescription != null) { |
425 |
if (!model.getActiveDescription().equals(activeDescription) || |
426 |
((ContextAwareDescription)model.getActiveDescription()).isSplitDescription() != ((ContextAwareDescription)activeDescription).isSplitDescription()) { |
427 |
model.setActiveDescription(activeDescription); |
428 |
} |
429 |
} |
430 |
} else if (splitPane != null && e.getID() == MouseEvent.MOUSE_RELEASED) { |
431 |
if (removeSplit) { |
432 |
if (e.getClickCount() != 0) { |
433 |
return; |
434 |
} |
435 |
if (mvPeer != null) { |
436 |
mvPeer.peerClearSplit(); |
437 |
bar.setMinimumSize(barMinSize); |
438 |
componentPanel.setMinimumSize(panelMinSizep); |
439 |
} |
440 |
removeSplit = false; |
441 |
} |
442 |
} |
443 |
} |
444 |
}; |
445 |
} |
446 |
return awtEventListener; |
447 |
} |
448 |
|
449 |
private void changeSplitOrientation(int orientation) { |
450 |
splitPane.removePropertyChangeListener(splitterPropertyChangeListener); |
451 |
splitterPropertyChangeListener = null; |
452 |
splitPane.setOrientation(orientation); |
453 |
splitPane.setDividerLocation(0.5); |
454 |
splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, getSplitterPropertyChangeListener(orientation)); |
455 |
} |
456 |
|
457 |
boolean isHiddenTriggeredByMultiViewButton() { |
458 |
return hiddenTriggeredByMultiViewButton; |
459 |
} |
460 |
|
461 |
boolean isShowing(MultiViewDescription descr) { |
462 |
if(descr == null) { |
463 |
return false; |
464 |
} |
465 |
if(splitPane == null) { |
466 |
return model.getActiveDescription() == descr; |
467 |
} |
468 |
return isTopLeft ? topBottomDescriptions[1] == descr : topBottomDescriptions[0] == descr; |
469 |
} |
470 |
|
471 |
void switchToCard(MultiViewElement elem, String id, boolean isSplitElement) { |
472 |
if (isSplitElement) { |
473 |
switchToCardSplit(elem, id); |
474 |
return; |
475 |
} |
162 |
if (! alreadyAddedElements.contains(elem)) { |
476 |
if (! alreadyAddedElements.contains(elem)) { |
163 |
componentPanel.add(elem.getVisualRepresentation(), id); |
477 |
componentPanel.add(elem.getVisualRepresentation(), id); |
164 |
alreadyAddedElements.add(elem); |
478 |
alreadyAddedElements.add(elem); |
Lines 166-171
Link Here
|
166 |
cardLayout.show(componentPanel, id); |
480 |
cardLayout.show(componentPanel, id); |
167 |
} |
481 |
} |
168 |
|
482 |
|
|
|
483 |
private void switchToCardSplit(MultiViewElement elem, String id) { |
484 |
if (!alreadyAddedElementsSplit.contains(elem)) { |
485 |
componentPanelSplit.add(elem.getVisualRepresentation(), id); |
486 |
alreadyAddedElementsSplit.add(elem); |
487 |
} |
488 |
cardLayoutSplit.show(componentPanelSplit, id); |
489 |
} |
490 |
|
169 |
/** Part of 130919 fix - don't hold visual representations after close */ |
491 |
/** Part of 130919 fix - don't hold visual representations after close */ |
170 |
void peerComponentClosed() { |
492 |
void peerComponentClosed() { |
171 |
if (componentPanel != null) { |
493 |
if (componentPanel != null) { |
Lines 174-192
Link Here
|
174 |
if (alreadyAddedElements != null) { |
496 |
if (alreadyAddedElements != null) { |
175 |
alreadyAddedElements.clear(); |
497 |
alreadyAddedElements.clear(); |
176 |
} |
498 |
} |
|
|
499 |
if (componentPanelSplit != null) { |
500 |
componentPanelSplit.removeAll(); |
501 |
} |
502 |
if (alreadyAddedElementsSplit != null) { |
503 |
alreadyAddedElementsSplit.clear(); |
504 |
} |
177 |
} |
505 |
} |
178 |
|
506 |
|
179 |
void changeActiveManually(MultiViewDescription desc) { |
507 |
void changeActiveManually(MultiViewDescription desc) { |
180 |
Enumeration en = model.getButtonGroup().getElements(); |
508 |
Enumeration en = model.getButtonGroup().getElements(); |
|
|
509 |
MultiViewDescription activeDescription = model.getActiveDescription(); |
510 |
if (activeDescription instanceof ContextAwareDescription && ((ContextAwareDescription) activeDescription).isSplitDescription()) { |
511 |
en = model.getButtonGroupSplit().getElements(); |
512 |
} |
181 |
while (en.hasMoreElements()) { |
513 |
while (en.hasMoreElements()) { |
182 |
JToggleButton obj = (JToggleButton)en.nextElement(); |
514 |
JToggleButton obj = (JToggleButton)en.nextElement(); |
183 |
|
515 |
|
184 |
if (obj.getModel() instanceof TabsComponent.TabsButtonModel) { |
516 |
if (obj.getModel() instanceof TabsComponent.TabsButtonModel) { |
185 |
TabsButtonModel btnmodel = (TabsButtonModel)obj.getModel(); |
517 |
TabsButtonModel btnmodel = (TabsButtonModel)obj.getModel(); |
186 |
if (btnmodel.getButtonsDescription().equals(desc)) { |
518 |
if (btnmodel.getButtonsDescription().getDisplayName().equals(desc.getDisplayName())) { |
187 |
obj.setSelected(true); |
519 |
if (splitPane != null) { |
188 |
MultiViewElement elem = model.getElementForDescription(desc); |
520 |
TabsComponent.this.hiddenTriggeredByMultiViewButton = true; |
189 |
elem.getVisualRepresentation().requestFocus(); |
521 |
if (((ContextAwareDescription) activeDescription).isSplitDescription()) { |
|
|
522 |
model.getButtonGroupSplit().setSelected(obj.getModel(), true); |
523 |
TabsComponent.this.isTopLeft = false; |
524 |
TabsComponent.this.topBottomDescriptions[1] = btnmodel.getButtonsDescription(); |
525 |
} else { |
526 |
model.getButtonGroup().setSelected(obj.getModel(), true); |
527 |
TabsComponent.this.isTopLeft = true; |
528 |
TabsComponent.this.topBottomDescriptions[0] = btnmodel.getButtonsDescription(); |
529 |
} |
530 |
model.fireActivateCurrent(); |
531 |
TabsComponent.this.hiddenTriggeredByMultiViewButton = false; |
532 |
} else { |
533 |
obj.setSelected(true); |
534 |
MultiViewElement elem = model.getElementForDescription(desc); |
535 |
elem.getVisualRepresentation().requestFocus(); |
536 |
} |
190 |
break; |
537 |
break; |
191 |
} |
538 |
} |
192 |
} |
539 |
} |
Lines 195-200
Link Here
|
195 |
|
542 |
|
196 |
void changeVisibleManually(MultiViewDescription desc) { |
543 |
void changeVisibleManually(MultiViewDescription desc) { |
197 |
Enumeration en = model.getButtonGroup().getElements(); |
544 |
Enumeration en = model.getButtonGroup().getElements(); |
|
|
545 |
MultiViewDescription activeDescription = model.getActiveDescription(); |
546 |
if (activeDescription instanceof ContextAwareDescription && ((ContextAwareDescription) activeDescription).isSplitDescription()) { |
547 |
en = model.getButtonGroupSplit().getElements(); |
548 |
desc = model.getActiveDescription(); |
549 |
} |
198 |
while (en.hasMoreElements()) { |
550 |
while (en.hasMoreElements()) { |
199 |
JToggleButton obj = (JToggleButton)en.nextElement(); |
551 |
JToggleButton obj = (JToggleButton)en.nextElement(); |
200 |
|
552 |
|
Lines 232-238
Link Here
|
232 |
return button; |
584 |
return button; |
233 |
} |
585 |
} |
234 |
|
586 |
|
235 |
void setInnerToolBar(JComponent innerbar) { |
587 |
void setInnerToolBar(JComponent innerbar, boolean isSplitElement) { |
|
|
588 |
if (isSplitElement) { |
589 |
setInnerToolBarSplit(innerbar); |
590 |
return; |
591 |
} |
236 |
synchronized (getTreeLock()) { |
592 |
synchronized (getTreeLock()) { |
237 |
if (toolbarPanel != null) { |
593 |
if (toolbarPanel != null) { |
238 |
bar.remove(toolbarPanel); |
594 |
bar.remove(toolbarPanel); |
Lines 264-269
Link Here
|
264 |
bar.repaint(); |
620 |
bar.repaint(); |
265 |
} |
621 |
} |
266 |
} |
622 |
} |
|
|
623 |
|
624 |
private void setInnerToolBarSplit(JComponent innerbar) { |
625 |
synchronized (getTreeLock()) { |
626 |
if (toolbarPanelSplit != null) { |
627 |
barSplit.remove(toolbarPanelSplit); |
628 |
} |
629 |
if (innerbar == null) { |
630 |
innerbar = getEmptyInnerToolBar(); |
631 |
} |
632 |
innerbar.putClientProperty(TOOLBAR_MARKER, "X"); //NOI18N |
633 |
// need to set it to null, because CloneableEditor set's the border for the editor bar part only.. |
634 |
if (!AQUA) { |
635 |
innerbar.setBorder(null); |
636 |
} else { |
637 |
innerbar.setBorder (BorderFactory.createEmptyBorder(2, 0, 2, 0)); |
638 |
} |
639 |
toolbarPanelSplit = innerbar; |
640 |
GridBagConstraints cons = new GridBagConstraints(); |
641 |
cons.anchor = GridBagConstraints.EAST; |
642 |
cons.fill = GridBagConstraints.BOTH; |
643 |
cons.gridwidth = GridBagConstraints.REMAINDER; |
644 |
cons.weightx = 1; |
645 |
toolbarPanelSplit.setMinimumSize(new Dimension(10, 10)); |
646 |
// cons.gridwidth = GridBagConstraints.REMAINDER; |
647 |
|
648 |
barSplit.add(toolbarPanelSplit, cons); |
649 |
|
650 |
// rootcycle is the tabscomponent.. |
651 |
// toolbarPanel.setFocusCycleRoot(false); |
652 |
barSplit.revalidate(); |
653 |
barSplit.repaint(); |
654 |
} |
655 |
} |
267 |
|
656 |
|
268 |
void setToolbarBarVisible(boolean visible) { |
657 |
void setToolbarBarVisible(boolean visible) { |
269 |
if (toolbarVisible == visible) { |
658 |
if (toolbarVisible == visible) { |
Lines 272-277
Link Here
|
272 |
toolbarVisible = visible; |
661 |
toolbarVisible = visible; |
273 |
bar.setVisible(visible); |
662 |
bar.setVisible(visible); |
274 |
} |
663 |
} |
|
|
664 |
|
665 |
void setToolbarBarVisibleSplit(boolean visible) { |
666 |
if (toolbarVisible == visible) { |
667 |
return; |
668 |
} |
669 |
toolbarVisible = visible; |
670 |
barSplit.setVisible(visible); |
671 |
} |
275 |
|
672 |
|
276 |
|
673 |
|
277 |
|
674 |
|
Lines 338-343
Link Here
|
338 |
input.put(stroke, "TogglesGoDown");//NOI18N |
735 |
input.put(stroke, "TogglesGoDown");//NOI18N |
339 |
} |
736 |
} |
340 |
|
737 |
|
|
|
738 |
void startTogglingSplit() { |
739 |
ActionMap map = barSplit.getActionMap(); |
740 |
Action act = new TogglesGoEastAction(); |
741 |
// JToolbar action name |
742 |
map.put("navigateRight", act);//NOI18N |
743 |
InputMap input = barSplit.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); |
744 |
|
745 |
act = new TogglesGoWestAction(); |
746 |
// JToolbar action name |
747 |
map.put("navigateLeft", act);//NOI18N |
748 |
|
749 |
act = new TogglesGoDownAction(); |
750 |
map.put("TogglesGoDown", act);//NOI18N |
751 |
// JToolbar action name |
752 |
map.put("navigateUp", act);//NOI18N |
753 |
KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE"); //NOI18N |
754 |
input.put(stroke, "TogglesGoDown");//NOI18N |
755 |
} |
756 |
|
341 |
|
757 |
|
342 |
private class TogglesGoWestAction extends AbstractAction { |
758 |
private class TogglesGoWestAction extends AbstractAction { |
343 |
|
759 |
|
Lines 421-426
Link Here
|
421 |
AbstractButton b = (AbstractButton)e.getComponent(); |
837 |
AbstractButton b = (AbstractButton)e.getComponent(); |
422 |
MultiViewModel model = TabsComponent.this.model; |
838 |
MultiViewModel model = TabsComponent.this.model; |
423 |
if (model != null) { |
839 |
if (model != null) { |
|
|
840 |
if (TabsComponent.this.splitPane != null) { |
841 |
ButtonModel buttonModel = b.getModel(); |
842 |
if (buttonModel instanceof TabsButtonModel) { |
843 |
MultiViewDescription buttonsDescription = ((TabsButtonModel) buttonModel).getButtonsDescription(); |
844 |
TabsComponent.this.hiddenTriggeredByMultiViewButton = true; |
845 |
if(((ContextAwareDescription)buttonsDescription).isSplitDescription()) { |
846 |
model.getButtonGroupSplit().setSelected(b.getModel(), true); |
847 |
TabsComponent.this.isTopLeft = false; |
848 |
TabsComponent.this.topBottomDescriptions[1] = buttonsDescription; |
849 |
} else { |
850 |
model.getButtonGroup().setSelected(b.getModel(), true); |
851 |
TabsComponent.this.isTopLeft = true; |
852 |
TabsComponent.this.topBottomDescriptions[0] = buttonsDescription; |
853 |
} |
854 |
model.fireActivateCurrent(); |
855 |
TabsComponent.this.hiddenTriggeredByMultiViewButton = false; |
856 |
} |
857 |
return; |
858 |
} |
424 |
model.getButtonGroup().setSelected(b.getModel(), true); |
859 |
model.getButtonGroup().setSelected(b.getModel(), true); |
425 |
model.fireActivateCurrent(); |
860 |
model.fireActivateCurrent(); |
426 |
} |
861 |
} |