diff --git a/CHANGELOG.md b/CHANGELOG.md index 973247b..043d5f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. * feat: test UI behavior with Assertj-Swing-JUnit (#7) * refactor: annotate deprecations, avoid access to internal class of other class(#6) * refactor: avoid redundant casts (#6) +* refactor: DockingDesktop class not to initialize in static context(#12) ## [v3.0.5-2] * chore: use nexus-publish plugin to release diff --git a/src/main/java/com/vlsolutions/swing/docking/DockingDesktop.java b/src/main/java/com/vlsolutions/swing/docking/DockingDesktop.java index 6ace23a..190b922 100644 --- a/src/main/java/com/vlsolutions/swing/docking/DockingDesktop.java +++ b/src/main/java/com/vlsolutions/swing/docking/DockingDesktop.java @@ -47,7 +47,6 @@ import java.awt.Rectangle; import java.awt.Window; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; @@ -60,10 +59,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; +import java.util.*; import javax.swing.AbstractAction; import javax.swing.JComponent; import javax.swing.JLayeredPane; @@ -91,7 +87,7 @@ /** * The DockingDesktop is the main class of the VLDocking Framework. *
- * It is the equivalent of what is JDesktopPane for JInternalWindow : a JLayeredPane customized to include : + * It is the equivalent of what is JDesktopPane for JInternalWindow: a JLayeredPane customized to include : *
* As of version 2.1, this method call is forwarded to the DockingContext
*/
@@ -664,7 +644,7 @@ public void unregisterDockable(Dockable dockable) {
/**
* Returns a String containing the version of the docking framework in the format M.m.r where M is the
- * major , m the minor and r the release.
+ * major, m the minor and r the release.
*
* @since 2.0
*/
@@ -687,8 +667,8 @@ public static String getDockingFrameworkBuildDate() {
* @param base
* the reference dockable
* @param dockable
- * a dockable to add at the same position than base
. if base is not already child
- * of a tabbedpane, a new tabbedpane will be created and inserted at base's location.
+ * a dockable to add at the same position instead of base
. if base is not already
+ * child of a tabbedpane, a new tabbedpane will be created and inserted at base's location.
* @param order
* the tab order of view in its tabbed pane.
*
@@ -703,7 +683,7 @@ public void createTab(Dockable base, Dockable dockable, int order) {
* Optional added tab selection.
*
* @param base
- * an existing dockable, either displayed in a DockableContainer or in a
+ * the existing dockable, either displayed in a DockableContainer or in a
* TabbedDockableContainer.
*
* If base is displayed by a DockableContainer, this container will be replaced by a @@ -746,15 +726,7 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele // currentState might be null CLOSED HIDDEN DOCKED FLOATING - DockableState newState = null; // 2005/10/06 - support for floatable - // tabs : the future state can be docked - // or floating - if (base.getDockKey().getLocation() == DockableState.Location.FLOATING) { - RelativeDockablePosition position = new RelativeDockablePosition(dockingPanel, dockable); - newState = new DockableState(this, dockable, base.getDockKey().getLocation(), position); - } else { - newState = new DockableState(this, dockable, base.getDockKey().getLocation()); - } + DockableState newState = getDockableState(base, dockable); DockableStateWillChangeEvent dswe = new DockableStateWillChangeEvent(currentState, newState); DockingActionEvent dae = new DockingActionCreateTabEvent(this, dockable, currentLocation, @@ -786,27 +758,20 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele // done earlier (in dropRemove() ) } - // if ( currentState != null && (!currentState.isFloating()) && - // newState.isFloating()){ - if (currentState != null && currentState.isFloating() && newState.isFloating()) { - // this case is when dragging a floating dockable into another - // floating window - Window w = SwingUtilities.getWindowAncestor(dockable.getComponent()); - Window w2 = SwingUtilities.getWindowAncestor(base.getComponent()); - if (w == null) { - // the dockable has already been removed - } else if (w != w2) { + if (currentState != null && newState.isFloating()) { + if (currentState.isFloating()) { + // this case is when dragging a floating dockable into another + // floating window + Window w = SwingUtilities.getWindowAncestor(dockable.getComponent()); + if (w != null) { + remove(dockable); + } + } else { + // from !floating to floating: // when creating a floating tab, we have to manually remove the // dockable remove(dockable); - } else { // else same window : no need to remove it - remove(dockable); } - } else if (currentState != null && (!currentState.isFloating()) && newState.isFloating()) { - // from !floating to floating : - // when creating a floating tab, we have to manually remove the - // dockable - remove(dockable); } if (!newState.isFloating()) { @@ -828,13 +793,8 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele baseTab.addDockable(base, 0); baseTab.addDockable(dockable, 1); - ((JTabbedPane) baseTab).addChangeListener(focusHandler); // our best - // way - // to - // track - // selection - // (focus) - // changes + // our best way to track selection (focus) changes + ((JTabbedPane) baseTab).addChangeListener(focusHandler); DockingUtilities.replaceChild(((Component) baseOldContainer).getParent(), (Component) baseOldContainer, (Component) baseTab); @@ -845,7 +805,7 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele // context.registerDockable(dockable); //2007/08/11 context.setDockableState(dockable, newState); - if (newState.isFloating() && !currentState.isFloating()) { + if (newState.isFloating() && currentState != null && !currentState.isFloating()) { // we need to store the return information storePreviousFloatingState(dockable, currentState); } @@ -862,13 +822,26 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele DockingUtilities.updateResizeWeights(dockingPanel); } + private DockableState getDockableState(Dockable base, Dockable dockable) { + DockableState newState; + // 2005/10/06 - support for float-able tabs: + // the future state can be docked or floating + if (base.getDockKey().getLocation() == DockableState.Location.FLOATING) { + RelativeDockablePosition position = new RelativeDockablePosition(dockingPanel, dockable); + newState = new DockableState(this, dockable, base.getDockKey().getLocation(), position); + } else { + newState = new DockableState(this, dockable, base.getDockKey().getLocation()); + } + return newState; + } + /** * Splits a Dockable in 2 parts, if possible. *
* The base dockable is the reference, the second newDockable will be added according to the position * parameter. *
- * If base is contained in a non splitable container (like a tab of DockTabbedPane) then, a splitable + * If the base is contained in a non-splitable container (like a tab of DockTabbedPane) then, a splittable * ancestor will be searched (until the root desktop pane is reached) to apply splitting. * * @param base @@ -878,9 +851,9 @@ private void createTab(Dockable base, Dockable dockable, int order, boolean sele * @param position * position of newDockable relative to base * @param proportion - * proportion of the initial dockable space taken by the new dockable a negative proportion, - * like -1, will be ignored (and split will be based on component preferred sizes and weights). - * This parameter is an alternative to DockingDesktop.setDockableHeight() and + * the proportion of the initial dockable space taken by the new dockable a negative + * proportion, like -1, will be ignored (and split will be based on component preferred sizes + * and weights). This parameter is an alternative to DockingDesktop.setDockableHeight() and * setDockableWidth() methods * @see DockingDesktop#setDockableHeight(com.vlsolutions.swing.docking.Dockable, double) * @see DockingDesktop#setDockableWidth(com.vlsolutions.swing.docking.Dockable, double) @@ -920,16 +893,7 @@ public void split(Dockable base, Dockable newDockable, DockingConstants.Split po newDockable, DockableContainerFactory.ParentType.PARENT_SPLIT_CONTAINER); dockableContainer.installDocking(this); - // create a new splitcontainer that will replace baseDockable's - // container - SplitContainer split; - if (position == DockingConstants.SPLIT_TOP || position == DockingConstants.SPLIT_BOTTOM) { - split = new SplitContainer(JSplitPane.VERTICAL_SPLIT); - } else /* - * if (position == DockingConstants.SPLIT_LEFT || position == DockingConstants.SPLIT_RIGHT) - */ { - split = new SplitContainer(JSplitPane.HORIZONTAL_SPLIT); - } + SplitContainer split = getSplitContainer(position); Component left, right; @@ -985,6 +949,20 @@ public void split(Dockable base, Dockable newDockable, DockingConstants.Split po } } + // create a new splitcontainer that will replace baseDockable's + // container + private SplitContainer getSplitContainer(DockingConstants.Split position) { + SplitContainer split; + if (position == DockingConstants.SPLIT_TOP || position == DockingConstants.SPLIT_BOTTOM) { + split = new SplitContainer(JSplitPane.VERTICAL_SPLIT); + } else /* + * if (position == DockingConstants.SPLIT_LEFT || position == DockingConstants.SPLIT_RIGHT) + */ { + split = new SplitContainer(JSplitPane.HORIZONTAL_SPLIT); + } + return split; + } + /** * Splits a Dockable in 2 parts, if possible. *
@@ -1047,13 +1025,7 @@ public void splitComponent(Component base, Dockable dockable, DockingConstants.S
DockableState currentState = getDockableState(dockable);
DockableState.Location currentLocation = getLocation(currentState);
- boolean stateChange = false;
- if (currentState == null) {
- stateChange = true;
- } else if (currentState.getLocation() != futureLocation) {
- stateChange = true;
- }
-
+ boolean stateChange = currentState != null && currentState.getLocation() != futureLocation;
DockableState newState = new DockableState(this, dockable, futureLocation);
// DockableState.DOCKED);
DockableStateWillChangeEvent dswe = new DockableStateWillChangeEvent(currentState, newState);
@@ -1071,8 +1043,8 @@ public void splitComponent(Component base, Dockable dockable, DockingConstants.S
}
Container oldContainer = (Container) DockingUtilities.findSingleDockableContainer(dockable);
- int oldWidth = 0;
- int oldHeight = 0;
+ int oldWidth;
+ int oldHeight;
if (oldContainer != null) {
oldWidth = oldContainer.getWidth();
oldHeight = oldContainer.getHeight();
@@ -1085,16 +1057,7 @@ public void splitComponent(Component base, Dockable dockable, DockingConstants.S
dockable, DockableContainerFactory.ParentType.PARENT_SPLIT_CONTAINER);
dockableContainer.installDocking(this);
- // create a new splitcontainer that will replace baseDockable's
- // container
- SplitContainer split;
- if (position == DockingConstants.SPLIT_TOP || position == DockingConstants.SPLIT_BOTTOM) {
- split = new SplitContainer(JSplitPane.VERTICAL_SPLIT);
- } else /*
- * if (position == DockingConstants.SPLIT_LEFT || position == DockingConstants.SPLIT_RIGHT)
- */ {
- split = new SplitContainer(JSplitPane.HORIZONTAL_SPLIT);
- }
+ SplitContainer split = getSplitContainer(position);
if (base != dockingPanel) { // 2005/11/08 support for splitting from
// dockingPanel
@@ -1143,12 +1106,10 @@ public void splitComponent(Component base, Dockable dockable, DockingConstants.S
context.setDockableState(dockable, newState);
- if (stateChange) {
- if (futureLocation == DockableState.Location.FLOATING) {
- // splitting from ? (should be Docked) to floating
- // we have to store a return state.
- storePreviousFloatingState(dockable, currentState);
- }
+ if (stateChange && futureLocation == DockableState.Location.FLOATING) {
+ // splitting from ? (should be Docked) to floating
+ // we have to store a return state.
+ storePreviousFloatingState(dockable, currentState);
}
dockable.getDockKey().setLocation(futureLocation);
@@ -1209,16 +1170,7 @@ private void splitTab(Component base, TabbedDockableContainer tdc, DockingConsta
oldHeight = base.getHeight() / 2;
}
- // create a new splitcontainer that will replace baseDockable's
- // container
- SplitContainer split;
- if (position == DockingConstants.SPLIT_TOP || position == DockingConstants.SPLIT_BOTTOM) {
- split = new SplitContainer(JSplitPane.VERTICAL_SPLIT);
- } else /*
- * if (position == DockingConstants.SPLIT_LEFT || position == DockingConstants.SPLIT_RIGHT)
- */ {
- split = new SplitContainer(JSplitPane.HORIZONTAL_SPLIT);
- }
+ SplitContainer split = getSplitContainer(position);
if (base != dockingPanel) { // 2005/11/08 support for splitting from
// dockingPanel
@@ -1381,7 +1333,7 @@ public void remove(Dockable dockable) {
// if (dockingPanel.isAncestorOf(dockable.getComponent())){ //2005/10/06
// ...
DockableState.Location dockLocation = dockable.getDockKey().getLocation();
- SingleDockableContainer dockableContainer = null;
+ SingleDockableContainer dockableContainer;
Container parentOfSdc = null;
boolean isChildOfCompoundDockable = false; // v2.1
@@ -1401,14 +1353,8 @@ public void remove(Dockable dockable) {
if (dockLocation == DockableState.Location.FLOATING) {
FloatingDockableContainer fdc = (FloatingDockableContainer) SwingUtilities
.getWindowAncestor(dockable.getComponent());
- if (parentOfSdc instanceof TabbedDockableContainer) {
- // dockable was contained in a tab on the floatable : we must
- // not dispose the window
- } else if (isChildOfCompoundDockable) {
- // dockable was a child of a compound dockable : don't dispose
- } else {
+ if (!(parentOfSdc instanceof TabbedDockableContainer) && !isChildOfCompoundDockable) {
DockingUtilities.dispose(fdc);
- // ((JDialog)dlg).dispose();
}
} else if (dockLocation == DockableState.Location.HIDDEN) {
// DockableState state = (DockableState)
@@ -1428,7 +1374,6 @@ public void remove(Dockable dockable) {
// so we just use the standard removing pattern
dockableContainer = DockingUtilities.findSingleDockableContainer(dockable);
- parentOfSdc = ((JComponent) dockableContainer).getParent();
removeContainer(dockableContainer);
} else {
// single auto-hide dockable
@@ -1659,13 +1604,6 @@ public void restore(final Dockable dockable) {
}
DockableState currentState = getDockableState(dockable);
- @SuppressWarnings("null")
- boolean stateChange;
- if (currentState == null) {
- stateChange = false;
- } else {
- stateChange = currentState.isMaximized();
- }
DockableState newState = new DockableState(this, dockable, DockableState.Location.DOCKED);
DockableState.Location currentLocation = getLocation(currentState);
@@ -1689,7 +1627,7 @@ public void restore(final Dockable dockable) {
}
((SingleDockableContainer) maximizedComponent).uninstallDocking(this);
- SingleDockableContainer sdc = null;
+ SingleDockableContainer sdc;
if (dummyMaximedReplacer.getParent() instanceof TabbedDockableContainer) {
sdc = DockableContainerFactory.getFactory().createDockableContainer(dockable,
DockableContainerFactory.ParentType.PARENT_TABBED_CONTAINER);
@@ -1705,12 +1643,7 @@ public void restore(final Dockable dockable) {
dockable.getDockKey().setLocation(DockableState.Location.DOCKED);
fireDockingAction(dae, new DockableStateChangeEvent(currentState, newState));
- SwingUtilities.invokeLater(new Runnable() {
-
- public void run() {
- dockable.getComponent().requestFocus();
- }
- });
+ SwingUtilities.invokeLater(() -> dockable.getComponent().requestFocus());
sdc.installDocking(this);
@@ -1770,9 +1703,7 @@ public void setFloating(final Dockable dockable, boolean floating, Point screenP
// from floating..to floating. It's still possible, if the
// component was previously tabbed (now it will have its
// own window
- if (DockingUtilities.findTabbedDockableContainer(dockable) != null) {
- // ok, it was tabbed and floating
- } else {
+ if (DockingUtilities.findTabbedDockableContainer(dockable) == null) {
throw new IllegalArgumentException("floating not tabbed");
}
break;
@@ -1905,17 +1836,15 @@ public void setFloating(final Dockable dockable, boolean floating, Point screenP
if (isDockingActionAccepted(dae, event)) {
removePreviousFloatingState(dockable);
- Container parentOfSdc = null; // 2005/10/07
+ Container parentOfSdc; // 2005/10/07
parentOfSdc = ((JComponent) dockableContainer).getParent();
removeContainer(dockableContainer);
FloatingDockableContainer fdc = (FloatingDockableContainer) SwingUtilities
.getWindowAncestor(dockable.getComponent());
- if (parentOfSdc instanceof TabbedDockableContainer) {
- // dockable was contained in a tab on the floatable : we
- // must not dispose the window
- } else {
+ // when dockable was contained in a tab on the floatable : we
+ // must not dispose the window
+ if (!(parentOfSdc instanceof TabbedDockableContainer)) {
DockingUtilities.dispose(fdc);
- // ((JDialog)fdc).dispose();
}
context.setDockableState(dockable, newState);
@@ -1964,7 +1893,7 @@ void setFloating(final TabbedDockableContainer tdc, Point screenPosition) {
if (!currentState.isDocked()) {
throw new IllegalArgumentException("not docked");
} else {
- if (checkDockableStateWillChange(tdc, DockableState.Location.FLOATING)) {
+ if (checkDockableStateWillChangeToFloating(tdc)) {
RelativeDockablePosition position = new RelativeDockablePosition(dockingPanel, firstDockable);
// no veto has been raised by the compound dockables
Dimension previousSize = ((Component) tdc).getSize();
@@ -1986,7 +1915,7 @@ void setFloating(final TabbedDockableContainer tdc, Point screenPosition) {
}
DockingUtilities.setVisible(fdc, true);
// dialog.setVisible(true);
- fireStateChanged(tdc, DockableState.Location.FLOATING, position);
+ fireStateChanged(tdc, position);
DockingUtilities.updateResizeWeights(dockingPanel);
revalidate();
}
@@ -2001,13 +1930,12 @@ private void storePreviousFloatingStates(TabbedDockableContainer tdc) {
}
}
- private boolean checkDockableStateWillChange(TabbedDockableContainer tdc,
- DockableState.Location futureLocation) {
+ private boolean checkDockableStateWillChangeToFloating(TabbedDockableContainer tdc) {
for (int i = 0; i < tdc.getTabCount(); i++) {
Dockable d = tdc.getDockableAt(i);
DockableState currentState = getDockableState(d);
DockableState.Location currentLocation = getLocation(currentState);
- DockableState newState = new DockableState(this, d, futureLocation, null);
+ DockableState newState = new DockableState(this, d, DockableState.Location.FLOATING, null);
DockableStateWillChangeEvent event = new DockableStateWillChangeEvent(currentState, newState);
DockingActionEvent dae = new DockingActionSimpleStateChangeEvent(this, d, currentLocation,
newState.getLocation());
@@ -2018,13 +1946,12 @@ private boolean checkDockableStateWillChange(TabbedDockableContainer tdc,
return true;
}
- private void fireStateChanged(TabbedDockableContainer tdc, DockableState.Location futureLocation,
- RelativeDockablePosition position) {
+ private void fireStateChanged(TabbedDockableContainer tdc, RelativeDockablePosition position) {
for (int i = 0; i < tdc.getTabCount(); i++) {
Dockable d = tdc.getDockableAt(i);
DockableState currentState = getDockableState(d);
DockableState.Location currentLocation = getLocation(currentState);
- DockableState newState = new DockableState(this, d, futureLocation, position);
+ DockableState newState = new DockableState(this, d, DockableState.Location.FLOATING, position);
context.setDockableState(d, newState);
d.getDockKey().setLocation(DockableState.Location.FLOATING);
@@ -2034,13 +1961,12 @@ private void fireStateChanged(TabbedDockableContainer tdc, DockableState.Locatio
}
}
- private DockableState removePreviousFloatingStates(TabbedDockableContainer tdc) {
+ private void removePreviousFloatingStates(TabbedDockableContainer tdc) {
DockableState first = removePreviousFloatingState(tdc.getDockableAt(0));
for (int i = 1; i < tdc.getTabCount(); i++) {
Dockable d = tdc.getDockableAt(i);
removePreviousFloatingState(d);
}
- return first;
}
/**
@@ -2059,8 +1985,9 @@ private DockableState removePreviousFloatingState(Dockable dockable) {
if (dockable instanceof CompoundDockable) {
// we also need to clear states of the compound children
ArrayList children = DockingUtilities.findCompoundDockableChildren((CompoundDockable) dockable);
- for (int i = 0; i < children.size(); i++) {
- Dockable d = (Dockable) children.get(i);
+ for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) {
+ Object child = children.get(i);
+ Dockable d = (Dockable) child;
previousFloatingDockableStates.remove(d);
}
}
@@ -2088,8 +2015,9 @@ private void storePreviousFloatingState(Dockable dockable, DockableState state)
// share the
// same return position
ArrayList children = DockingUtilities.findCompoundDockableChildren((CompoundDockable) dockable);
- for (int i = 0; i < children.size(); i++) {
- Dockable d = (Dockable) children.get(i);
+ for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) {
+ Object child = children.get(i);
+ Dockable d = (Dockable) child;
previousFloatingDockableStates.put(d,
new DockableState(this, d, state.getLocation(), state.getPosition()));
}
@@ -2137,10 +2065,11 @@ private void moveFloatingWindows() { // 2005/10/10
int dx = newLocation.x - lastWindowLocation.x;
int dy = newLocation.y - lastWindowLocation.y;
Window[] childWindow = w.getOwnedWindows();
- for (int i = 0; i < childWindow.length; i++) {
- if (childWindow[i] instanceof FloatingDockableContainer && childWindow[i].isVisible()) {
- Point p = childWindow[i].getLocation();
- childWindow[i].setLocation(p.x + dx, p.y + dy);
+ for (int i = 0, childWindowLength = childWindow.length; i < childWindowLength; i++) {
+ Window window = childWindow[i];
+ if (window instanceof FloatingDockableContainer && window.isVisible()) {
+ Point p = window.getLocation();
+ window.setLocation(p.x + dx, p.y + dy);
}
}
}
@@ -2228,7 +2157,7 @@ protected void removeContainer(SingleDockableContainer dc) {
boolean invalidateDesktop = true; // always, except for floating
// dockables
- Component parent = ((Component) dc).getParent();
+ Container parent = ((Component) dc).getParent();
if (parent != null) {
try {
if (parent instanceof SplitContainer) {
@@ -2257,7 +2186,7 @@ protected void removeContainer(SingleDockableContainer dc) {
((JTabbedPane) tparent).removeChangeListener(focusHandler);
boolean floating = last.getDockKey().getLocation() == DockableState.Location.FLOATING;
- DockableContainer lastContainer = null;
+ DockableContainer lastContainer;
if (floating) {
lastContainer = DockableContainerFactory.getFactory().createDockableContainer(
last, DockableContainerFactory.ParentType.PARENT_DETACHED_WINDOW);
@@ -2277,7 +2206,7 @@ protected void removeContainer(SingleDockableContainer dc) {
// do
invalidateDesktop = false;
} else {
- ((Container) parent).remove((Component) dc);
+ parent.remove((Component) dc);
// throw new
// IllegalStateException("View is not contained in desktop hierarchy "
// + parent);
@@ -2289,7 +2218,7 @@ protected void removeContainer(SingleDockableContainer dc) {
dockingPanel.repaint();
}
} catch (Exception e) {
- e.printStackTrace();
+ log.atError().setCause(e).log();
}
}
}
@@ -2403,8 +2332,9 @@ public void close(Dockable dockable) {
*/
private void updateCompoundChildrenState(CompoundDockable cDockable, DockableState.Location state) {
ArrayList children = DockingUtilities.findCompoundDockableChildren(cDockable);
- for (int i = 0; i < children.size(); i++) {
- Dockable d = (Dockable) children.get(i);
+ for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) {
+ Object child = children.get(i);
+ Dockable d = (Dockable) child;
d.getDockKey().setLocation(state);
DockableState childState = getDockableState(d);
DockableState childNewState = new DockableState(this, d, state);
@@ -2430,8 +2360,9 @@ public void closeAllOtherDockablesInTab(Dockable exception) {
dockables.add(tabContainer.getDockableAt(i));
}
}
- for (int i = 0; i < dockables.size(); i++) {
- Dockable d = (Dockable) dockables.get(i);
+ for (int i = 0, dockablesSize = dockables.size(); i < dockablesSize; i++) {
+ Object dockable = dockables.get(i);
+ Dockable d = (Dockable) dockable;
if (d.getDockKey().isCloseEnabled()) {
this.close(d);
}
@@ -2458,8 +2389,9 @@ public void closeAllDockablesInTab(Dockable base) {
for (int i = 0; i < tabContainer.getTabCount(); i++) {
dockables.add(tabContainer.getDockableAt(i));
}
- for (int i = 0; i < dockables.size(); i++) {
- Dockable d = (Dockable) dockables.get(i);
+ for (int i = 0, dockablesSize = dockables.size(); i < dockablesSize; i++) {
+ Object dockable = dockables.get(i);
+ Dockable d = (Dockable) dockable;
if (d.getDockKey().isCloseEnabled()) {
this.close(d);
}
@@ -2511,8 +2443,8 @@ public void setAutoHide(Dockable dockable, boolean hide) {
}
btn.init(dockable, zone);
- borderPanes[zone].setVisible(true); // border may not be
- // visible
+ // border may not be visible
+ borderPanes[zone].setVisible(true);
borderPanes[zone].add(btn);
borderPanes[zone].revalidate();
} else { // btn already existing, show it again
@@ -2647,9 +2579,7 @@ public DockableState[] getDockables() {
*/
public void installDockableDragSources(DockableDragSource[] sources) {
if (sources != null) {
- for (int i = 0; i < sources.length; i++) {
- installDockableDragSource(sources[i]);
- }
+ Arrays.stream(sources).forEach(this::installDockableDragSource);
}
}
@@ -2960,7 +2890,7 @@ private void xmlWriteCompoundDockableWithRelativePosition(CompoundDockable docka
private void xmlWriteFloatingDockable(Dockable dockable, PrintWriter out) throws IOException {
DockableState state = context.getDockableState(dockable);
- RelativeDockablePosition position = (RelativeDockablePosition) state.getPosition();
+ RelativeDockablePosition position = state.getPosition();
boolean isCompound = dockable instanceof CompoundDockable;
if (isCompound) {
out.println("