/** * Convenience method to add a workspace tab. This method initialises the tab. */ public void addTab(final WorkspaceTab workspaceTab) { tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), workspaceTab); workspaceTabs.add(workspaceTab); try { workspaceTab.initialise(); } catch (Exception e) { tabbedPane.remove(workspaceTab); tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), createErrorPanel(e)); } }
/** * Disposes of the tabbed workspace. This removes any tabs in the workspace and disposes of them. */ @Override public void dispose() { save(); // Remove the tabs and call their dispose method for (WorkspaceTab tab : workspaceTabs) { try { tab.dispose(); logger.info("Disposed of '{}' tab", tab.getLabel()); } catch (Exception e) { logger.warn("The {} tab threw an exception whilst being disposed.", tab.getLabel(), e); } } workspaceTabs.clear(); tabbedPane.removeAll(); super.dispose(); logger.info("Disposed of workspace"); } }
/** * Convenience method to add a workspace tab. This method initialises the tab. */ public void addTab(WorkspaceTab workspaceTab) { tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), workspaceTab); workspaceTabs.add(workspaceTab); try { workspaceTab.initialise(); } catch (Exception e) { tabbedPane.remove(workspaceTab); tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), createErrorPanel(e)); } }
/** * Convenience method to add a workspace tab. This method initialises the tab. */ public void addTab(WorkspaceTab workspaceTab) { tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), workspaceTab); workspaceTabs.add(workspaceTab); try { workspaceTab.initialise(); } catch (Exception e) { tabbedPane.remove(workspaceTab); tabbedPane.addTab(workspaceTab.getLabel(), workspaceTab.getIcon(), createErrorPanel(e)); } }
public void save() { try { super.save(); // Save out tabs TabbedWorkspaceStateManager man = new TabbedWorkspaceStateManager(this); man.save(); for (WorkspaceTab tab : getWorkspaceTabs()){ tab.save(); logger.info("Saved tab state for '{}' tab", tab.getLabel()); } logger.info("Saved workspace"); } catch (Exception e) { logger.error("An error occurred whilst saving the workspace", e); } }
public void actionPerformed(ActionEvent event) { TabbedWorkspace workspace = (TabbedWorkspace) getWorkspace(); Set<String> extensions = new HashSet<>(); extensions.add("xml"); String fileName = workspace.getSelectedTab().getLabel().replace(' ', '_') + ".layout.xml"; File f = UIUtil.saveFile((Window) SwingUtilities.getAncestorOfClass(Window.class, workspace), "Save layout to", "XML Layout", extensions, fileName); if (f == null) { return; } try { f.getParentFile().mkdirs(); FileWriter writer = new FileWriter(f); ((WorkspaceViewsTab) workspace.getSelectedTab()).getViewsPane().saveViews(writer); writer.close(); JOptionPane.showMessageDialog(workspace, "Layout saved to: " + f); } catch (IOException e) { logger.error("An error occurred when saving a tab layout to {}.", f, e); JOptionPane.showMessageDialog(workspace, "There was a problem saving the layout", "Error", JOptionPane.ERROR_MESSAGE); } }
public void actionPerformed(ActionEvent event) { TabbedWorkspace workspace = (TabbedWorkspace) getWorkspace(); try { Set<String> extensions = new HashSet<String>(); extensions.add("xml"); String fileName = workspace.getSelectedTab().getLabel().replace(' ', '_') + ".layout.xml"; File f = UIUtil.saveFile((Window) SwingUtilities.getAncestorOfClass(Window.class, workspace), "Save layout to", "XML Layout", extensions, fileName); if (f == null) { return; } f.getParentFile().mkdirs(); FileWriter writer = new FileWriter(f); ((WorkspaceViewsTab) workspace.getSelectedTab()).getViewsPane().saveViews(writer); writer.close(); JOptionPane.showMessageDialog(workspace, "Layout saved to: " + f); } catch (IOException e) { LOGGER.error(e); JOptionPane.showMessageDialog(workspace, "There was a problem saving the layout", "Error", JOptionPane.ERROR_MESSAGE); } }
public void actionPerformed(ActionEvent event) { TabbedWorkspace workspace = (TabbedWorkspace) getWorkspace(); try { Set<String> extensions = new HashSet<String>(); extensions.add("xml"); String fileName = workspace.getSelectedTab().getLabel().replace(' ', '_') + ".layout.xml"; File f = UIUtil.saveFile((Window) SwingUtilities.getAncestorOfClass(Window.class, workspace), "Save layout to", "XML Layout", extensions, fileName); if (f == null) { return; } f.getParentFile().mkdirs(); FileWriter writer = new FileWriter(f); ((WorkspaceViewsTab) workspace.getSelectedTab()).getViewsPane().saveViews(writer); writer.close(); JOptionPane.showMessageDialog(workspace, "Layout saved to: " + f); } catch (IOException e) { LOGGER.error(e); JOptionPane.showMessageDialog(workspace, "There was a problem saving the layout", "Error", JOptionPane.ERROR_MESSAGE); } }