/** Returns true iff there exist a session in the desktop. */ private boolean existsSession() { JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0); for (JInternalFrame allFrame : allFrames) { Object o = allFrame.getContentPane().getComponents()[0]; if (o instanceof SessionEditor) { return true; } } return false; }
public SessionEditor getFrontmostSessionEditor() { JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0); if (allFrames.length == 0) { return null; } JInternalFrame frontmostFrame = allFrames[0]; Object o = frontmostFrame.getContentPane().getComponents()[0]; boolean isSessionEditor = o instanceof SessionEditor; return isSessionEditor ? (SessionEditor) o : null; }
public void closeEmptySessions() { JInternalFrame[] frames = desktopPane.getAllFramesInLayer(0); for (JInternalFrame frame : frames) { Object o = frame.getContentPane().getComponents()[0]; if (o instanceof SessionEditor) { SessionEditor sessionEditor = (SessionEditor) o; SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench(); Graph graph = workbench.getGraph(); if (graph.getNumNodes() == 0) { frame.dispose(); } } } }
public void closeFrontmostSession() { JInternalFrame[] frames = desktopPane.getAllFramesInLayer(0); if (frames.length > 0) { frames[0].dispose(); Map<SessionEditor, JInternalFrame> framesMap = this.framesMap; for (Iterator<SessionEditor> i = framesMap.keySet().iterator(); i.hasNext(); ) { SessionEditor key = i.next(); JInternalFrame value = framesMap.get(key); if (value == frames[0]) { i.remove(); break; } } } }
public boolean existsSessionByName(String filename) { JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0); for (JInternalFrame allFrame : allFrames) { Object o = allFrame.getContentPane().getComponents()[0]; if (o instanceof SessionEditor) { SessionEditor editor = (SessionEditor) o; String editorName = editor.getName(); if (editorName.equals(filename)) { return true; } } } return false; }