📄 dockingmanager.java
字号:
* Docks the specified {@code Component} into the CENTER region of the
* specified {@code DockingPort}. If the {@code DockingManager} finds a
* valid {@code Dockable} instance mapped to the specified {@code Component},
* the {@code Dockable} will be docked into the {@code DockingPort}. If the
* {@code Component} or {@code DockingPort} is {@code null}, or a valid
* {@code Dockable} cannot be found for the specified {@code Component},
* this method returns {@code false}. Otherwise, this method returns
* {@code true} if the docking operation was successful and {@code false} if
* the docking operation cannot be completed. This method defers processing
* to {@code dock(Component dockable , DockingPort port, String region)}.
*
* @param dockable
* the {@code Component} to be docked.
* @param port
* the {@code DockingPort} into which the specified
* {@code Component} will be docked.
* @return {@code true} if the docking operation was successful,
* {@code false} otherwise.
* @see #dock(Component, DockingPort, String)
*/
public static boolean dock(Component dockable, DockingPort port) {
return dock(dockable, port, CENTER_REGION);
}
/**
* Docks the specified {@code Component} into the supplied region of the
* specified {@code DockingPort}. If the {@code DockingManager} finds a
* valid {@code Dockable} instance mapped to the specified {@code Component},
* the {@code Dockable} will be docked into the {@code DockingPort}. If the
* {@code Component} or {@code DockingPort} is {@code null}, or a valid
* {@code Dockable} cannot be found for the specified {@code Component},
* this method returns {@code false}. Otherwise, this method returns
* {@code true} if the docking operation was successful and {@code false} if
* the docking operation cannot be completed. This method defers processing
* to {@code dock(Dockable dockable, DockingPort port, String region)}.
*
* @param dockable
* the {@code Component} to be docked.
* @param port
* the {@code DockingPort} into which the specified
* {@code Component} will be docked.
* @param region
* the region into which to dock the specified {@code Component}
* @return {@code true} if the docking operation was successful,
* {@code false} if the docking operation cannot be completed.
* @see #dock(Dockable, DockingPort, String)
*/
public static boolean dock(Component dockable, DockingPort port,
String region) {
Dockable d = resolveDockable(dockable);
return dock(d, port, region);
}
/**
* Docks the specified {@code Dockable} into the supplied region of the
* specified {@code DockingPort}. If the {@code Dockable} or
* {@code DockingPort} is {@code null}, this method returns {@code false}.
* Otherwise, this method returns {@code true} if the docking operation was
* successful and {@code false} if the docking operation cannot be
* completed.
*
* This method determines the {@code DockingStrategy} to be used for the
* specified {@code DockingPort} and defers processing to the
* {@code DockingStrategy}. This method's return value will be based upon
* the {@code DockingStrategy} implementation and is subject to conditions
* such as whether the supplied region is deemed valid, whether the
* {@code DockingStrategy} allows this particular {@code Dockable} to be
* docked into the supplied region of the specified {@code DockingPort},
* and so on. The {@code DockingStrategy} used is obtained by a call to
* {@code getDockingStrategy(Object obj)} and may be controlled via
* {@code setDockingStrategy(Class c, DockingStrategy strategy)}, supplying
* a {@code DockingPort} implementation class and a customized
* {@code DockingStrategy}.
*
* @param dockable
* the {@code Dockable} to be docked.
* @param port
* the {@code DockingPort} into which the specified
* {@code Component} will be docked.
* @param region
* the region into which to dock the specified {@code Dockable}
* @return {@code true} if the docking operation was successful,
* {@code false} otherwise.
* @see DockingStrategy#dock(Dockable, DockingPort, String)
* @see #getDockingStrategy(Object)
* @see #setDockingStrategy(Class, DockingStrategy)
*/
public static boolean dock(Dockable dockable, DockingPort port,
String region) {
if (dockable == null)
return false;
DockingStrategy strategy = getDockingStrategy(port);
if (strategy != null) {
return strategy.dock(dockable, port, region);
}
return false; // TODO think of changing it to runtime exception I
// don't see a situation when there would be no docker.
}
private static Dockable resolveDockable(Component comp) {
if (comp == null)
return null;
Dockable d = getDockable(comp);
if (d == null)
d = registerDockable(comp);
return d;
}
/**
* Docks the specified {@code Component} relative to another already-docked
* {@code Component} in the CENTER region. Valid {@code Dockable} instances
* are looked up for both {@code Component} parameters and processing is
* deferred to {@code dock(Dockable dockable, Dockable parent)}. If a valid
* {@code Dockable} cannot be resolved for either {@code Component}, then
* this method returns {@code false}. The "parent" {@code Dockable} must
* currently be docked. If not, this method will return {@code false}.
* Otherwise, its parent {@code DockingPort} will be resolved and the new
* {@code Dockable} will be docked into the {@code DockingPort} relative to
* the "parent" {@code Dockable}.
*
* @param dockable
* the {@code Component} to be docked
* @param parent
* the {@code Component} used as a reference point for docking
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
* @see DockingManager#dock(Dockable, Dockable)
*/
public static boolean dock(Component dockable, Component parent) {
return dock(resolveDockable(dockable), resolveDockable(parent));
}
/**
* Docks the specified {@code Dockable} relative to another already-docked
* {@code Dockable} in the CENTER region. The "parent" {@code Dockable} must
* currently be docked. If not, this method will return {@code false}.
* Otherwise, its parent {@code DockingPort} will be resolved and the new
* {@code Dockable} will be docked into the {@code DockingPort} relative to
* the "parent" {@code Dockable}. This method defers processing to
* {@code dock(Dockable dockable, Dockable parent, String region)} and
* returns {@code false} if any of the input parameters are {@code null}.
*
* @param dockable
* the {@code Dockable} to be docked
* @param parent
* the {@code Dockable} used as a reference point for docking
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
* @see #dock(Dockable, Dockable, String)
*/
public static boolean dock(Dockable dockable, Dockable parent) {
return dock(dockable, parent, CENTER_REGION);
}
/**
* Docks the specified {@code Component} relative to another already-docked
* {@code Component} in the specified region. Valid {@code Dockable}
* instances will be looked up for each of the {@code Component} parameters.
* If a valid {@code Dockable} is not found for either {@code Component},
* then this method returns {@code false}. The "parent" {@code Dockable}
* must currently be docked. If not, this method will return {@code false}.
* Otherwise, its parent {@code DockingPort} will be resolved and the new
* {@code Dockable} will be docked into the {@code DockingPort} relative to
* the "parent" {@code Dockable}. This method defers processing to
* {@code dock(Component dockable, Component parent, String region, float proportion)}
* and returns {@code false} if any of the input parameters are {@code null}.
* If the specified region is other than CENTER, then a split layout should
* result. This method supplies a split proportion of 0.5F, resulting in
* equal distribution of space between the dockable and parent parameters if
* docking is successful.
*
* @param dockable
* the {@code Component} to be docked
* @param parent
* the {@code Component} used as a reference point for docking
* @param region
* the relative docking region into which {@code dockable} will
* be docked
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
* @see #dock(Component, Component, String, float)
*/
public static boolean dock(Component dockable, Component parent,
String region) {
return dock(dockable, parent, region, 0.5f);
}
/**
* Docks the specified {@code Dockable} relative to another already-docked
* {@code Dockable} in the specified region. The "parent" {@code Dockable}
* must currently be docked. If not, this method will return {@code false}.
* Otherwise, its parent {@code DockingPort} will be resolved and the new
* {@code Dockable} will be docked into the {@code DockingPort} relative to
* the "parent" {@code Dockable}. This method defers processing to
* {@code dock(Dockable dockable, Dockable parent, String region, float proportion)}
* and returns {@code false} if any of the input parameters are {@code null}.
* If the specified region is other than CENTER, then a split layout should
* result. This method supplies a split proportion of 0.5F, resulting in
* equal distribution of space between the dockable and parent parameters if
* docking is successful.
*
* @param dockable
* the {@code Dockable} to be docked
* @param parent
* the {@code Dockable} used as a reference point for docking
* @param region
* the docking region into which {@code dockable} will be docked
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
* @see #dock(Dockable, Dockable, String, float)
*/
public static boolean dock(Dockable dockable, Dockable parent, String region) {
return dock(dockable, parent, region, 0.5f);
}
/**
* Docks the specified {@code Component} relative to another already-docked
* {@code Component} in the specified region with the specified split
* proportion. Valid {@code Dockable} instances will be looked up for each
* of the {@code Component} parameters. If a valid {@code Dockable} is not
* found for either {@code Component}, then this method returns
* {@code false}. The "parent" {@code Dockable} must currently be docked.
* If not, this method will return {@code false}. Otherwise, its parent
* {@code DockingPort} will be resolved and the new {@code Dockable} will be
* docked into the {@code DockingPort} relative to the "parent"
* {@code Dockable}. If the specified region is CENTER, then the
* {@code proportion} parameter is ignored. Otherwise, a split layout should
* result with the proportional space specified in the {@code proportion}
* parameter allotted to the {@code dockable} argument. This method defers
* processing to
* {@code dock(Dockable dockable, Dockable parent, String region, float proportion)}.
*
* @param dockable
* the {@code Component} to be docked
* @param parent
* the {@code Component} used as a reference point for docking
* @param region
* the relative docking region into which {@code dockable} will
* be docked
* @param proportion
* the proportional space to allot the {@code dockable} argument
* if the docking operation results in a split layout.
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
*/
public static boolean dock(Component dockable, Component parent,
String region, float proportion) {
Dockable newDockable = resolveDockable(dockable);
Dockable parentDockable = resolveDockable(parent);
return dock(newDockable, parentDockable, region, proportion);
}
/**
* Docks the specified {@code Dockable} relative to another already-docked
* {@code Dockable} in the specified region with the specified split
* proportion. The "parent" {@code Dockable} must currently be docked. If
* not, this method will return {@code false}. Otherwise, its parent
* {@code DockingPort} will be resolved and the new {@code Dockable} will be
* docked into the {@code DockingPort} relative to the "parent"
* {@code Dockable}. If the specified region is CENTER, then the
* {@code proportion} parameter is ignored. Otherwise, a split layout should
* result with the proportional space specified in the {@code proportion}
* parameter allotted to the {@code dockable} argument.
*
* @param dockable
* the {@code Dockable} to be docked
* @param parent
* the {@code Dockable} used as a reference point for docking
* @param region
* the docking region into which {@code dockable} will be docked
* @param proportion
* the proportional space to allot the {@code dockable} argument
* if the docking operation results in a split layout.
* @return {@code true} if the docking operation was successful;
* {@code false} otherwise.
*/
public static boolean dock(Dockable dockable, Dockable parent,
String region, float proportion) {
return DockingUtility
.dockRelative(dockable, parent, region, proportion);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -