-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqGetOpenEditorWindows
Node[] arr = TopComponent.getRegistry().getCurrentNodes();
for (int i = 0; i < arr.length; i++) {
EditorCookie ec = (EditorCookie) arr[i].getCookie(EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
// USE panes
}
}
}
Note that EditorCookie.getOpenPanes() is deprecated (https://netbeans.org/bugzilla/show_bug.cgi?id=223383). Use org.openide.text.NbDocument.findRecentEditorPane(EditorCookie)
instead.
Set<TopComponent> comps = TopComponent.getRegistry().getOpened();
for (TopComponent tc: comps) {
Node[] arr = tc.getActivatedNodes();
for (int j = 0; j < arr.length; j++) {
EditorCookie ec = (EditorCookie) arr[j].getCookie(EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
// USE panes
}
}
}
}
private Collection<TopComponent> getCurrentOpenedEditors() {
final ArrayList<TopComponent> result = new ArrayList<TopComponent>();
final WindowManager wm = WindowManager.getDefault();
for (Mode mode : wm.getModes()) {
if (wm.isEditorMode(mode)) {
//result.addAll(Arrays.asList(mode.getTopComponents())); OR even faster
result.addAll(Arrays.asList(wm.getOpenedTopComponents(mode)));
}
}
return result;
}
private TopComponent getCurrentEditor() {
Set<? extends Mode> modes = WindowManager.getDefault().getModes();
for (Mode mode : modes) {
if ("editor".equals(mode.getName())) {
return mode.getSelectedTopComponent();
}
}
return null;
}
//or
private TopComponent getCurrentEditor() {
Mode editor = WindowManager.getDefault().findMode("editor");
return editor.getSelectedTopComponent();
}
<hr/> Reference- Editor Windows Reactivated <hr/>
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqGetOpenEditorWindows , that was last modified by NetBeans user Markiewb on 2016-10-26T20:35:35Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.