@Messages("CTL_CloseAllWindowsActionName=Close All") private class CloseAllWindowsAction extends AbstractAction { public CloseAllWindowsAction() { super(Bundle.CTL_CloseAllWindowsActionName()); } @Override public void actionPerformed(ActionEvent e) { new CloseOtherWindowsAction(-1).actionPerformed(e); } }
@Messages("CTL_CloseWindowActionName=Close") private class CloseWindowAction extends AbstractAction { private final int tabIndex; public CloseWindowAction(int tabIndex) { super(Bundle.CTL_CloseWindowActionName()); this.tabIndex = tabIndex; } @Override public void actionPerformed(ActionEvent e) { TabData tab = tabbedContainer.getModel().getTab(tabIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); closeInternalFrame(internalFrame); } }
@Messages("CTL_RenameActionName=Rename") private class RenameWorkspaceAction extends AbstractAction { public RenameWorkspaceAction() { super(Bundle.CTL_RenameActionName()); } @Override public void actionPerformed(ActionEvent e) { NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine("Name:", "Rename Workspace"); d.setInputText(WorkspaceTopComponent.this.getDisplayName()); Object result = DialogDisplayer.getDefault().notify(d); if (NotifyDescriptor.OK_OPTION.equals(result)) { WorkspaceTopComponent.this.setDisplayName(d.getInputText()); } } }
@Messages("CTL_TileSingleActionName=Tile Single") private class TileSingleAction extends AbstractAction { public TileSingleAction() { super(Bundle.CTL_TileSingleActionName()); } @Override public void actionPerformed(ActionEvent e) { int desktopWidth = desktopPane.getWidth(); int desktopHeight = desktopPane.getHeight(); JInternalFrame[] internalFrames = desktopPane.getAllFrames(); for (JInternalFrame internalFrame : internalFrames) { internalFrame.setBounds(0, 0, desktopWidth, desktopHeight); } } }
@Messages("CTL_MaximizeWindowActionName=Maximise") private class MaximizeWindowAction extends AbstractAction { private final int tabIndex; public MaximizeWindowAction(int tabIndex) { super(Bundle.CTL_MaximizeWindowActionName()); this.tabIndex = tabIndex; } @Override public void actionPerformed(ActionEvent e) { TabData tab = tabbedContainer.getModel().getTab(tabIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); try { internalFrame.setMaximum(true); } catch (PropertyVetoException e1) { // ok } } }
@Messages("CTL_DockActionName=Dock") private class DockAction extends AbstractAction { private int tabIndex; public DockAction(int tabIndex) { super(Bundle.CTL_DockActionName()); this.tabIndex = tabIndex; } @Override public void actionPerformed(ActionEvent e) { TabData tab = tabbedContainer.getModel().getTab(tabIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); TopComponent topComponent = dockInternalFrame(internalFrame); if (topComponent != null) { topComponent.requestActive(); } } }
@Messages("CTL_DockGroupActionName=Dock Group") private class DockGroupAction extends AbstractAction { public DockGroupAction() { super(Bundle.CTL_DockGroupActionName()); } @Override public void actionPerformed(ActionEvent e) { Set<JInternalFrame> internalFrameSet = frameToTabMap.keySet(); JInternalFrame[] internalFrames = internalFrameSet.toArray(new JInternalFrame[internalFrameSet.size()]); TopComponent topComponent = null; for (JInternalFrame internalFrame : internalFrames) { topComponent = dockInternalFrame(internalFrame); } if (topComponent != null) { topComponent.requestActive(); } } }
@Messages("CTL_TileHorizontallyActionName=Tile Horizontally") private class TileHorizontallyAction extends AbstractAction { public TileHorizontallyAction() { super(Bundle.CTL_TileHorizontallyActionName()); } @Override public void actionPerformed(ActionEvent e) { int desktopWidth = desktopPane.getWidth(); int desktopHeight = desktopPane.getHeight(); int windowCount = frameToTabMap.size(); int windowWidth = desktopWidth / windowCount; List<TabData> tabs = tabbedContainer.getModel().getTabs(); for (int windowIndex = 0; windowIndex < windowCount; windowIndex++) { TabData tab = tabs.get(windowIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); internalFrame.setBounds(windowIndex * windowWidth, 0, windowWidth, desktopHeight); } } }
@Messages("CTL_TileVerticallyActionName=Tile Vertically") private class TileVerticallyAction extends AbstractAction { public TileVerticallyAction() { super(Bundle.CTL_TileVerticallyActionName()); } @Override public void actionPerformed(ActionEvent e) { int desktopWidth = desktopPane.getWidth(); int desktopHeight = desktopPane.getHeight(); int windowCount = frameToTabMap.size(); int windowHeight = desktopHeight / windowCount; List<TabData> tabs = tabbedContainer.getModel().getTabs(); for (int windowIndex = 0; windowIndex < windowCount; windowIndex++) { TabData tab = tabs.get(windowIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); internalFrame.setBounds(0, windowIndex * windowHeight, desktopWidth, windowHeight); } } }
@Messages("CTL_CloseOtherWindowsActionName=Close Others") private class CloseOtherWindowsAction extends AbstractAction { private final int tabIndex; public CloseOtherWindowsAction(int tabIndex) { super(Bundle.CTL_CloseOtherWindowsActionName()); this.tabIndex = tabIndex; } @Override public void actionPerformed(ActionEvent e) { TabData tab = tabbedContainer.getModel().getTab(tabIndex); JInternalFrame selectedInternalFrame = tabToFrameMap.get(tab); Set<JInternalFrame> internalFrameSet = frameToTabMap.keySet(); JInternalFrame[] internalFrames = internalFrameSet.toArray(new JInternalFrame[internalFrameSet.size()]); for (JInternalFrame internalFrame : internalFrames) { if (internalFrame != selectedInternalFrame) { closeInternalFrame(internalFrame); } } } }
@Messages("CTL_FloatGroupIntoWorkspaceActionName=Float Group into Workspace") public static class FloatGroupIntoWorkspaceAction extends AbstractAction { private TopComponent window; public FloatGroupIntoWorkspaceAction(TopComponent window) { super(Bundle.CTL_FloatGroupIntoWorkspaceActionName()); this.window = window; } @Override public void actionPerformed(ActionEvent e) { WorkspaceTopComponent workspaceTopComponent = FloatIntoWorkspaceAction.promptForWorkspaces(); if (workspaceTopComponent != null) { workspaceTopComponent.requestActive(); Mode mode = WindowManager.getDefault().findMode(window); if (mode != null) { TopComponent[] topComponents = WindowManager.getDefault().getOpenedTopComponents(mode); for (TopComponent topComponent : topComponents) { if (!(topComponent instanceof WorkspaceTopComponent)) { workspaceTopComponent.addTopComponent(topComponent); } } } } } }
@Messages("CTL_TileEvenlyActionName=Tile Evenly") private class TileEvenlyAction extends AbstractAction { public TileEvenlyAction() { super(Bundle.CTL_TileEvenlyActionName()); } @Override public void actionPerformed(ActionEvent e) { int desktopWidth = desktopPane.getWidth(); int desktopHeight = desktopPane.getHeight(); int windowCount = frameToTabMap.size(); Dimension matrixSize = TileUtilities.computeMatrixSizeForEqualAreaTiling(windowCount); int windowWidth = desktopWidth / matrixSize.width; int windowHeight = desktopHeight / matrixSize.height; List<TabData> tabs = tabbedContainer.getModel().getTabs(); int windowIndex = 0; for (int j = 0; j < matrixSize.height; j++) { for (int i = 0; i < matrixSize.width; i++) { if (windowIndex < windowCount) { TabData tab = tabs.get(windowIndex); JInternalFrame internalFrame = tabToFrameMap.get(tab); internalFrame.setBounds(i * windowWidth, j * windowHeight, windowWidth, windowHeight); } windowIndex++; } } } }
@Messages({ "CTL_FloatIntoWorkspaceActionName=Float into Workspace", "LBL_FloatIntoWorkspaceActionName=Workspaces:",
preferredID = "WorkspaceTopComponent" @Messages({ "CTL_WorkspaceTopComponentNameBase=Workspace", "CTL_WorkspaceTopComponentDescription=Provides an internal desktop for document windows",
@Messages("CTL_WorkspaceTopComponentFrameUnnamed=Unnamed") public void addTopComponent(TopComponent topComponent) {