To obtain an instance of the ToolWindowManager interface
you have to instantiate the
MyDoggyToolWindowManager class which provides the default implementation.
Use the following:
ToolWindowManager twManager = new MyDoggyToolWindowManager(...);
or
ToolWindowManager toolWindowManager = new MyDoggyToolWindowManager( Locale.getDefault() // A Locale instance );
MyDoggyToolWindowManager is implemented like a JPanel so you can use it like any other component.
For example:
JFrame frame = new JFrame("MyDoggy-Set..."); ... MyDoggyToolWindowManager myDoggyToolWindowManager = new MyDoggyToolWindowManager(); ... frame.getContentPane().add(myDoggyToolWindowManager);
Warning: to be able to use all the toolwindow types (Sliding, Floating Live, etc.), ensure that the toolwindow manager has as window ancestor an object implementing the RootPaneContainer interface (i.e. JFrame, JWindow, JApplet, ...).
ToolWindowManager twManager = new MyDoggyToolWindowManager(...); ToolWindow debugTool = twManager.registerToolWindow( "Debug", // Tool Window identifier "Debug Tool", // Tool Window Title debugIcon, // Tool Window Icon debugComponent, // Tool Window component ToolWindowAnchor.LEFT // Tool Window anchor );
ToolWindowManager twManager = new MyDoggyToolWindowManager(...); twManager.unregisterToolWindow("Debug");
ToolWindowManager twManager = new MyDoggyToolWindowManager(...); Object debugToolAlias = new DebugToolAlias(); twManager.addAlias(debugTool, debugToolAlias);
To obtain the instance of the ToolWindowManagerDescriptor for a specific ToolWindowManager use the following:
ToolWindowManagerDescriptor descriptor = twManager.getToolWindowManagerDescriptor();
After you have obtained an instance of the ToolWindowManagerDescriptor for a specific ToolWindowManager use the following to change to PushAwayMode:
ToolWindowManagerDescriptor descriptor = twManager.getToolWindowManagerDescriptor(); descriptor.setPushAwayMode(PushAwayMode.MOST_RECENT);
To retrieve the current PushAwayMode use the following:
ToolWindowManagerDescriptor descriptor = twManager.getToolWindowManagerDescriptor(); PushAwayMode pushAwayMode = descriptor.getPushAwayMode();
After you have obtained an instance of the ToolWindowManagerDescriptor for a specific ToolWindowManager use the following to set a corner component:
ToolWindowManagerDescriptor descriptor = twManager.getToolWindowManagerDescriptor(); descriptor.setCornerComponent( ToolWindowManagerDescriptor.Corner.NORD_WEST, new JLabel("NW"));
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.setVisibile(true); // false to hide
The tool shows or hides the component in a way that depends on tool window type.
There is an another way to show a tool. You can use the aggregate methedo
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.aggregate();
The method is used to set to the true value the visible property of the tool. The tool becomes visible in a special way. In fact, if there is another tool visible with the same anchor than these two tools will be aggregate to be visible both.
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.setActive(true); // false to deactivate
The tool grabs the focus from focus owner and becomes active.
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.setAnchor(ToolWindowAnchor.TOP);
The anchor specifies the position of the tool when it is anchored to the docking system.
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.setFlashing(true); // false to disable
Sets the flashing mode. If the flashing mode is enabled then the toolwindow representative button
will be flashing until the tool will be made visible. If the tool is visible but not active then
the toolwindow title bar will be flashing until the tool will be made visible.
You can use
setFlashing(int)
to enable flashing for a specific duration.
ToolWindow tool = toolWindowManager.getToolWindow(0); tool.setAnchor(ToolWindowAnchor.TOP);
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following:
DockedTypeDescriptor desc = (DockedTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.DOCKED); desc.setPopupMenuEnabled(true); // false to denie.
So you can Specifies whether the popup menu of the representative anchor button of the tool should be enabled.
DockedTypeDescriptor desc = (DockedTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.DOCKED); JMenu menu = desc.getToolsMenu(); menu.addJMenuItem(new JMenuItem("Hello World!!!");
The user can add specific menu items to the popup menu of the representative anchor button of the tool using the result of this method invocation.
DockedTypeDescriptor desc = (DockedTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.DOCKED); desc.setDockLength(150);
Sets the width or heigth, based on anchor of tool window, of the dock panel. This value is used by DOCKED and SLIDING tool window type.
DockedTypeDescriptor desc = (DockedTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.DOCKED); desc.setToolWindowActionHandler(new ToolWindowActionHandler(){...});
DockedTypeDescriptor desc = (DockedTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.DOCKED); desc.setPreviewEnabled(true); // false to disable
Sets the preview mode. If the preview mode is enabled then when the mouse waits
on the toolwindow representative button after a delay time the preview will become visible.
You can use
setPreviewTransparentRatio
and
setPreviewDelay
methods
to set transparency paramenters and delay.
SlidingTypeDescriptor desc = (SlidingTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.SLIDING); desc.setTransparentMode(true); // false to disable
Sets the transparent mode. If the transparent mode is enabled then when the toolwindow's content
losts the focus it becomes transparent. This facility is os-independent.
You can use
setTransparentRatio
and
setTransparentDelay
methods
to set transparency paramenters and delay.
SlidingTypeDescriptor desc = (SlidingTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.SLIDING); desc.setEnabled(true); // false to disable
Enables or disables this mode, depending on the value of the parameterenabled. An enabled mode can used by user. This Mode is enabled initially by default.
FloatingTypeDescriptor desc = (FloatingTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.SLIDING); desc.setTransparentMode(true); // false to disable
Sets the transparent mode. If the transparent mode is enabled then when
the window used by
FLOATING
and
FLOATING_FREE
type losts
the focus it becomes transparent. This facility is os-dependent.
You can use
setTransparentRatio
and
setTransparentDelay
methods
to set transparency paramenters and delay.
FloatingTypeDescriptor desc = (FloatingTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.SLIDING); desc.setEnabled(true); // false to disable
Enables or disables this mode, depending on the value of the parameterenabled. An enabled mode can used by user. This Mode is enabled initially by default.
FloatingTypeDescriptor desc = (FloatingTypeDescriptor) debugTool.getTypeDescriptor(ToolWindowType.SLIDING); desc.setPosition(150, 220);
Sets the window location. This location is also used the first time the window becomes visible. The top-left corner of the new location is specified by the x and y parameters in the system coordinate space.
ToolWindowGroup group = toolWindowManager.getToolWindowGroup("group_name");
Returns the tool window group to which this manager maps the specified name. If the manager contains no mapping for this name then the manager create a new instance of ToolWindowGroup and associates the group created with the specified name in this manager.
toolWindowManager.removeToolWindowGroup("group_name");
Removes the tool window group for this name from this manager if it is present.
boolean contains = toolWindowManager.containsGroup("group_name");
Returns true if this manager contains a group for the specified name.
ToolWindowGroup group = toolWindowManager.getToolWindowGroup("group_name"); ToolWindow debugTool = toolWindowManager.getToolWindow("Debug"); group.addToolWindow(debugTool);
Appends the specified tool window to the end of this group.
ToolWindowGroup group = toolWindowManager.getToolWindowGroup("group_name"); ToolWindow debugTool = toolWindowManager.getToolWindow("Debug"); group.removeToolWindow(debugTool);
Removes the occurrence in this group of the specified tool window.
ToolWindowGroup group = toolWindowManager.getToolWindowGroup("group_name"); group.setVisible(true);
Invokes setVisible(visible) on all toolwindows contained in this group in proper sequence.
ToolWindowGroup group = toolWindowManager.getToolWindowGroup("group_name"); group.addToolWindowGroupListener(listener);
Registers listener so that it will receive events when the groups are made visibile or invisible, when a tool is added or removed. If listener listener is null, no exception is thrown and no action is performed.
ContentManager contentManager = toolWindowManager.getContentManager(); Content tools = ContentcontentManager.addContent("Tools" // Content Key "Tools", // Content title null, // Content Item toolsContent, // Content component "ToolWindows" // Content tooltip text );
Adds a component represented by a unique identifier key with a title and/or icon, either of which can be null.
ContentManager contentManager = toolWindowManager.getContentManager(); contentManager.removeContent(tools);
Removes the content from the manager.
ContentManager contentManager = toolWindowManager.getContentManager(); Content content = contentManager.getSelectedContent();
Returns the selected content, or null if the selection is empty.
ContentManager contentManager = toolWindowManager.getContentManager(); ContentManagerUI contentManagerUI = new ... TODO contentManager.setContentManagerUI(contentManagerUI);
Sets the content manager ui to contentManagerUI.
ContentManager contentManager = toolWindowManager.getContentManager(); contentManager.setEnabled(false); // or true to enable
Enables or disables the content manager. If the content manager is disable the whole space will be available for toolwindows.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI();
Returns the content manager ui.
toolWindowManager.getContentManager().setContentManagerUI(new MyDoggyDesktopContentManagerUI());
Sets the content manager ui.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); contentManagerUI.setCloseable(true); contentManagerUI.setsetDetachable(true);
Sets the 'Closeable' and/or 'Detachable' property of all contents registered to content manager.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); contentManagerUI.addContentManagerUIListener(listener);
Registers listener so that it will receive events when a content is removed or detached using the ui. For the remove action you can apply a veto to the action. If listener listener is null, no exception is thrown and no action is performed.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); Content content = toolWindowManager.getContentManager().getContent(0); ContentUI contentUi = contentManagerUI.getContentUI(content);
Returns the ui part to which this manager maps the specified content.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); Content content = toolWindowManager.getContentManager().getContent(0); ContentUI contentUi = contentManagerUI.getContentUI(content); assert contentUi.getContent() == content;
Returns the Content contropart of a ContentUI instance.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); Content content = toolWindowManager.getContentManager().getContent(0); ContentUI contentUi = contentManagerUI.getContentUI(content); contentUi.setCloseable(true); contentUi.setDetachable(true);
Sets the 'Closeable' and/or 'Detachable' property of a specific ContentUI.
ContentManagerUI contentManagerUI = toolWindowManager.getContentManager().getContentManagerUI(); Content content = toolWindowManager.getContentManager().getContent(0); ContentUI contentUi = contentManagerUI.getContentUI(content); contentUi.setTransparentMode(true); contentUi.setTransparentRatio(0.7f); contentUi.setTransparentDelay(1000);
Sets the transparent mode. If the transparent mode is enabled then when the content is detached and the window containing the content losts the focus then the window becomes transparent. This facility is os-dependent.
To obtain the instance of the PersistenceDelegate for a specific ToolWindowManager use the following:
PersistenceDelegate pstDelegate = twManager.getPersistenceDelegate();
After you have obtained an instance of the PersistenceDelegate for a specific ToolWindowManager use the following to store the workspace:
PersistenceDelegate pstDelegate = twManager.getPersistenceDelegate(); try { FileOutputStream output = new FileOutputStream("workspace.xml"); twManager.getPersistenceDelegate().save(output); output.close(); } catch (Exception e) { e.printStackTrace(); }
After you have obtained an instance of the PersistenceDelegate for a specific ToolWindowManager use the following to apply a saved workspace to the current workspace:
PersistenceDelegate pstDelegate = twManager.getPersistenceDelegate(); try { FileInputStream inputStream = new FileInputStream("workspace.xml"); pstDelegate.apply(inputStream); inputStream.close(); } catch (Exception e1) { e1.printStackTrace(); }
Using merge(InputStream, MergePolicy) method, you can decide the method's behaviour relative to the tools already visible when the method is called.
PersistenceDelegate pstDelegate = twManager.getPersistenceDelegate(); try { FileInputStream inputStream = new FileInputStream("workspace.xml"); pstDelegate.merge( inputStream, PersistenceDelegate.MergePolicy.RESET); inputStream.close(); } catch (Exception e1) { e1.printStackTrace(); }