@Override public void handleCloseTab(int tabIndex, JTabbedPane tabbedPane) { WorkspaceTab workspaceTab = (WorkspaceTab) tabbedPane.getComponentAt(tabIndex); workspaceTab.getWorkspace().removeTab(workspaceTab); try { workspaceTab.dispose(); } catch (Exception e) { logger.error("An error occurred whilst disposing of a tab.", e); } } }
public ViewsPaneMemento(WorkspaceTab workspaceTab) { initialCongigFileURL = workspaceTab.getDefaultViewConfigurationFile(); viewPaneId = workspaceTab.getId(); }
/** * 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)); } }
public WorkspaceTab addTabForPlugin(WorkspaceTabPlugin plugin) { WorkspaceTab tab = null; try { tab = plugin.newInstance(); addTab(tab); } catch (Throwable e) { if (tab != null) { String msg = "An error occurred when creating the " + plugin.getLabel() + " tab."; tab.setLayout(new BorderLayout()); tab.add(ComponentFactory.createExceptionComponent(msg, e, null)); } LOGGER.warn(e); } return tab; }
public WorkspaceTab getWorkspaceTab(String id) { for (WorkspaceTab tab : getWorkspaceTabs()) { if (tab.getId().equals(id)) { return tab; } } return null; }
/** * 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(); } catch (Exception e) { LOGGER.warn("BAD TAB: " + tab.getClass().getSimpleName() + " - Exception during dispose: " + e.getMessage()); } } workspaceTabs.clear(); tabbedPane.removeAll(); super.dispose(); } }
/** * 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"); } }
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 save() { super.save(); viewsPane.saveViews(); }
public WorkspaceTab newInstance() throws InstantiationException, ClassNotFoundException, IllegalAccessException { ExtensionInstantiator<WorkspaceTab> instantiator = new ExtensionInstantiator<>(extension); WorkspaceTab tab = instantiator.instantiate(); tab.setup(this); return tab; }
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 WorkspaceTab addTabForPlugin(WorkspaceTabPlugin plugin) { WorkspaceTab tab = null; try { tab = plugin.newInstance(); addTab(tab); } catch (Throwable e) { if (tab != null) { String msg = "An error occurred when creating the " + plugin.getLabel() + " tab."; tab.setLayout(new BorderLayout()); tab.add(ComponentFactory.createExceptionComponent(msg, e, null)); } LOGGER.warn(e); } return tab; }
public boolean containsTab(String tabId) { for (WorkspaceTab tab : getWorkspaceTabs()) { if (tab.getId().equals(tabId)) { return true; } } return false; }
/** * 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(); } catch (Exception e) { LOGGER.warn("BAD TAB: " + tab.getClass().getSimpleName() + " - Exception during dispose: " + e.getMessage()); } } workspaceTabs.clear(); tabbedPane.removeAll(); super.dispose(); } }
public void save() { super.save(); viewsPane.saveViews(); }
public WorkspaceTab newInstance() throws InstantiationException, ClassNotFoundException, IllegalAccessException { ExtensionInstantiator<WorkspaceTab> instantiator = new ExtensionInstantiator<WorkspaceTab>(extension); WorkspaceTab tab = instantiator.instantiate(); tab.setup(this); return tab; }
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); } }
/** * 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 ViewsPaneMemento(WorkspaceTab workspaceTab) { initialCongigFileURL = workspaceTab.getDefaultViewConfigurationFile(); viewPaneId = workspaceTab.getId(); }
public WorkspaceTab addTabForPlugin(WorkspaceTabPlugin plugin) { WorkspaceTab tab = null; try { tab = plugin.newInstance(); addTab(tab); } catch (Throwable e) { if (tab != null) { String msg = "An error occurred when creating the " + plugin.getLabel() + " tab."; tab.setLayout(new BorderLayout()); tab.add(ComponentFactory.createExceptionComponent(msg, e, null)); } logger.error("An error occurred when attempting to instantiate a tab plugin. " + "Tab plugin Id: {}. Error details: {}", plugin.getId(), e); } return tab; }