Search in sources :

Example 6 with TopComponent

use of org.openide.windows.TopComponent in project Universal-G-Code-Sender by winder.

the class EditGcodeFile method closeOpenFile.

private void closeOpenFile() {
    updateListener(false);
    Collection<TopComponent> editors = getCurrentlyOpenedEditors();
    for (TopComponent editor : editors) {
        editor.close();
    }
}
Also used : TopComponent(org.openide.windows.TopComponent)

Example 7 with TopComponent

use of org.openide.windows.TopComponent in project Universal-G-Code-Sender by winder.

the class EditGcodeFile method getCurrentlyOpenedEditors.

/**
 * Get all the windows in the "Editor" mode, then filter to just editors.
 */
private Collection<TopComponent> getCurrentlyOpenedEditors() {
    final ArrayList<TopComponent> result = new ArrayList<>();
    Collection<TopComponent> comps = TopComponent.getRegistry().getOpened();
    for (TopComponent tc : comps) {
        Node[] arr = tc.getActivatedNodes();
        for (int j = 0; arr != null && j < arr.length; j++) {
            EditorCookie ec = arr[j].getCookie(EditorCookie.class);
            if (ec != null) {
                result.add(tc);
            }
        }
    }
    return result;
}
Also used : Node(org.openide.nodes.Node) EditorCookie(org.openide.cookies.EditorCookie) ArrayList(java.util.ArrayList) TopComponent(org.openide.windows.TopComponent)

Aggregations

TopComponent (org.openide.windows.TopComponent)7 MMDEditorSupport (com.igormaznitsa.nbmindmap.nb.editor.MMDEditorSupport)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 MultiViewElementCallback (org.netbeans.core.spi.multiview.MultiViewElementCallback)1 EditorCookie (org.openide.cookies.EditorCookie)1 Node (org.openide.nodes.Node)1 Lookup (org.openide.util.Lookup)1 Mode (org.openide.windows.Mode)1