public void addWorkspace(final Workspace workspace) { if (!workspaceFrameMap.containsKey(workspace)) { // Add the workspace final WorkspaceFrame frame = new WorkspaceFrame(workspace); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (doClose(workspace)){ // Remove the listener frame.removeWindowListener(this); frame.dispose(); } } }); workspaceFrameMap.put(workspace, frame); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setVisible(true); } }
public WorkspaceFrame(Workspace workspace) { this.workspace = workspace; menuActions = new HashSet<ProtegeAction>(); createUI(); restoreMetrics(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (OSUtils.isOSX()){ ProtegeAppleApplication.getInstance().setEditorKit(null); } saveMetrics(); removeWindowListener(this); } public void windowActivated(WindowEvent event) { if (OSUtils.isOSX()){ ProtegeAppleApplication.getInstance().setEditorKit(WorkspaceFrame.this.workspace.getEditorKit()); } } }); }
public void windowClosing(WindowEvent e) { if (doClose(workspace)) { // Remove the listener frame.removeWindowListener(this); frame.dispose(); } } });
private void createUI() { JPanel contentPane = new JPanel(new BorderLayout(0, 0)); setContentPane(contentPane); // Menu bar createMenuBar(); // Add the workspace to the frame contentPane.add(workspace); workspace.initialiseExtraMenuItems(getJMenuBar()); String title = workspace.getTitle(); if (title != null) { setTitle(title); } setIconImage(((ImageIcon) Icons.getIcon("logo32.gif")).getImage()); Optional<JComponent> statusArea = workspace.getStatusArea(); statusArea.ifPresent(sa -> contentPane.add(sa, BorderLayout.SOUTH)); }
protected void restoreMetrics() { Preferences p = PreferencesManager.getInstance().getApplicationPreferences(getClass().getName()); int w = p.getInt(SIZE_X, 800); int h = p.getInt(SIZE_Y, 600); setSize(w, h); Point defLoc = getDefaultLocation(); int x = p.getInt(LOC_X, defLoc.x); int y = p.getInt(LOC_Y, defLoc.y); setLocation(x, y); setSize(w, h); }
public void ancestorAdded(AncestorEvent event) { // add a listener for when the window gets activated ProtegeManager.getInstance().getFrame(workspace).addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent event) { handleWindowActivated(); } }); workspace.removeAncestorListener(this); }
public void windowClosing(WindowEvent e) { if (OSUtils.isOSX()){ ProtegeAppleApplication.getInstance().setEditorKit(null); } saveMetrics(); removeWindowListener(this); }
protected void saveMetrics() { Preferences p = PreferencesManager.getInstance().getApplicationPreferences(getClass().getName()); p.putInt(LOC_X, getLocation().x); p.putInt(LOC_Y, getLocation().y); p.putInt(SIZE_X, getSize().width); p.putInt(SIZE_Y, getSize().height); }
private Point getDefaultLocation() { Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameDim = getSize(); return new Point((screenDim.width - frameDim.width) / 2, (screenDim.height - frameDim.height) / 2); }
public void removeWorkspace(Workspace workspace) { WorkspaceFrame frame = workspaceFrameMap.get(workspace); if (frame != null) { frame.dispose(); workspaceFrameMap.remove(workspace); } }
public JMenu getMenu(String name) { for (int i = 0; i < getJMenuBar().getMenuCount(); i++) { JMenu menu = getJMenuBar().getMenu(i); if (menu.getText() != null) { if (menu.getText().equals(name)) { return menu; } } } JMenu menu = new JMenu(name); getJMenuBar().add(menu); return menu; }
private void createUI() { JPanel contentPane = new JPanel(new BorderLayout(7, 7)); setContentPane(contentPane); // Menu bar createMenuBar(); // Add the workspace to the frame contentPane.add(workspace); workspace.initialiseExtraMenuItems(getJMenuBar()); String title = workspace.getTitle(); if (title != null) { setTitle(title); } setIconImage(((ImageIcon) Icons.getIcon("logo32.gif")).getImage()); JComponent statusArea = workspace.getStatusArea(); if (statusArea != null) { contentPane.add(statusArea, BorderLayout.SOUTH); } }
protected void restoreMetrics() { Preferences p = PreferencesManager.getInstance().getApplicationPreferences(getClass().getName()); int w = p.getInt(SIZE_X, DEFAULT_WIDTH); int h = p.getInt(SIZE_Y, DEFAULT_HEIGHT); setSize(w, h); Point defLoc = getDefaultLocation(); int x = p.getInt(LOC_X, defLoc.x); int y = p.getInt(LOC_Y, defLoc.y); setLocation(x, y); setSize(w, h); }
public void ancestorAdded(AncestorEvent event) { // add a listener for when the window gets activated ProtegeManager.getInstance().getFrame(workspace).addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent event) { handleWindowActivated(); } }); workspace.removeAncestorListener(this); }
public void windowClosing(WindowEvent e) { if (OSUtils.isOSX()){ ProtegeAppleApplication.getInstance().setEditorKit(null); } saveMetrics(); removeWindowListener(this); }
protected void saveMetrics() { Preferences p = PreferencesManager.getInstance().getApplicationPreferences(getClass().getName()); p.putInt(LOC_X, getLocation().x); p.putInt(LOC_Y, getLocation().y); p.putInt(SIZE_X, getSize().width); p.putInt(SIZE_Y, getSize().height); }
private Point getDefaultLocation() { Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameDim = getSize(); return new Point((screenDim.width - frameDim.width) / 2, (screenDim.height - frameDim.height) / 2); }
public void removeWorkspace(Workspace workspace) { WorkspaceFrame frame = workspaceFrameMap.get(workspace); if (frame != null) { frame.dispose(); workspaceFrameMap.remove(workspace); } }
public JMenu getMenu(String name) { for (int i = 0; i < getJMenuBar().getMenuCount(); i++) { JMenu menu = getJMenuBar().getMenu(i); if (menu.getText() != null) { if (menu.getText().equals(name)) { return menu; } } } JMenu menu = new JMenu(name); getJMenuBar().add(menu); return menu; }
private void createUI() { JPanel contentPane = new JPanel(new BorderLayout(7, 7)); setContentPane(contentPane); // Menu bar createMenuBar(); // Add the workspace to the frame contentPane.add(workspace); workspace.initialiseExtraMenuItems(getJMenuBar()); String title = workspace.getTitle(); if (title != null) { setTitle(title); } setIconImage(((ImageIcon) Icons.getIcon("logo32.gif")).getImage()); JComponent statusArea = workspace.getStatusArea(); if (statusArea != null) { contentPane.add(statusArea, BorderLayout.SOUTH); } }