public Editor addCommitLog(String title, Editor commitLog) { boolean notExist = !_commitLogs.contains(commitLog); LOG.assertTrue(notExist); //noinspection ConstantConditions if (notExist) { DefaultActionGroup actions = new DefaultActionGroup(); actions.add(new CopyContentAction(commitLog)); addTab( title, commitLog.getComponent(), true, false, false, true, actions, COMMIT_LOG_HELP_ID); _commitLogs.add(commitLog); } return commitLog; }
@NotNull public EditorWindow[] getOrderedWindows() { final ArrayList<EditorWindow> res = new ArrayList<EditorWindow>(); // Collector for windows in tree ordering: class Inner { final void collect(final JPanel panel) { final Component comp = panel.getComponent(0); if (comp instanceof Splitter) { final Splitter splitter = (Splitter) comp; collect((JPanel) splitter.getFirstComponent()); collect((JPanel) splitter.getSecondComponent()); } else if (comp instanceof JPanel || comp instanceof JBTabs) { final EditorWindow window = findWindowWith(comp); if (window != null) { res.add(window); } } } } // get root component and traverse splitters tree: if (getComponentCount() != 0) { final Component comp = getComponent(0); LOG.assertTrue(comp instanceof JPanel); final JPanel panel = (JPanel) comp; if (panel.getComponentCount() != 0) { new Inner().collect(panel); } } LOG.assertTrue(res.size() == myWindows.size()); return res.toArray(new EditorWindow[res.size()]); }
private void updateFileIconLater(VirtualFile file) { myFilesToUpdateIconsFor.add(file); myIconUpdaterAlarm.cancelAllRequests(); myIconUpdaterAlarm.addRequest( new Runnable() { public void run() { if (myManager.getProject().isDisposed()) return; for (VirtualFile file : myFilesToUpdateIconsFor) { updateFileIconImmediately(file); } myFilesToUpdateIconsFor.clear(); } }, 200, ModalityState.stateForComponent(this)); }
public EditorWindow getOrCreateCurrentWindow(final VirtualFile file) { final List<EditorWindow> windows = findWindows(file); if (getCurrentWindow() == null) { final Iterator<EditorWindow> iterator = myWindows.iterator(); if (!windows.isEmpty()) { setCurrentWindow(windows.get(0), false); } else if (iterator.hasNext()) { setCurrentWindow(iterator.next(), false); } else { createCurrentWindow(); } } else if (!windows.isEmpty()) { if (!windows.contains(getCurrentWindow())) { setCurrentWindow(windows.get(0), false); } } return getCurrentWindow(); }
@NotNull public EditorWindow[] getWindows() { return myWindows.toArray(new EditorWindow[myWindows.size()]); }
public void clear() { removeAll(); myWindows.clear(); setCurrentWindow(null); repaint(); // revalidate doesn't repaint correctly after "Close All" }