Java Code Examples for org.openide.windows.Mode#getSelectedTopComponent()

The following examples show how to use org.openide.windows.Mode#getSelectedTopComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the file selected in the editor.
 * 
 * @return file selected in the editor.
 */
private static FileObject selectedEditorFile() {
    WindowManager manager = WindowManager.getDefault();
    TopComponent.Registry registry = manager.getRegistry();
    TopComponent active = registry.getActivated();
    if ((active == null) || !manager.isOpenedEditorTopComponent(active)) {
        active = null;
        for (Mode mode : manager.getModes()) {
            if (manager.isEditorMode(mode)) {
                active = mode.getSelectedTopComponent();
                if (active != null) {
                    break;
                }
            }
        }
    }
    FileObject selectedFile = null;
    if (active != null) {
        selectedFile = active.getLookup().lookup(FileObject.class);
    }
    return selectedFile;
}
 
Example 2
Source File: EditorTopComponent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 3
Source File: EditorTopComponent.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 4
Source File: EditorTopComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 5
Source File: FormEditorSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void checkFormGroupVisibility() {
    // when active TopComponent changes, check if we should open or close
    // the form editor group of windows (Inspector, Palette, Properties)
    WindowManager wm = WindowManager.getDefault();
    final TopComponentGroup group = wm.findTopComponentGroup("form"); // NOI18N
    if (group == null)
        return; // group not found (should not happen)
    
    boolean designerSelected = false;
    Iterator it = wm.getModes().iterator();
    while (it.hasNext()) {
        Mode mode = (Mode) it.next();
        TopComponent selected = mode.getSelectedTopComponent();
        if (getSelectedElementType(selected) == FORM_ELEMENT_INDEX) {
            designerSelected = true;
            break;
        }
    }

    if (designerSelected && !Boolean.TRUE.equals(groupVisible)) {
        // Bug 116008: calling group.open() first time may cause hiding the
        // FormDesigner (some winsys multiview initialization mess), calling
        // this method again and hiding the group. By setting the groupVisible
        // to false we make the re-entrant call effectively do nothing.
        groupVisible = Boolean.FALSE;
        group.open();
        groupVisible = Boolean.TRUE;
        final TopComponentGroup paletteGroup = wm.findTopComponentGroup( "commonpalette" ); // NOI18N
        if( null != paletteGroup ) {
            paletteGroup.open();
        }
    }
    else if (!designerSelected && !Boolean.FALSE.equals(groupVisible)) {
        group.close();
        groupVisible = Boolean.FALSE;
    }
}
 
Example 6
Source File: AddWatchAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void openWatchesView() {
    // open watches view
    TopComponent watchesView = WindowManager.getDefault().findTopComponent("watchesView"); // NOI18N
    if (watchesView != null && watchesView.isOpened()) {
        Mode mw = WindowManager.getDefault().findMode(watchesView);
        if (mw != null && mw.getSelectedTopComponent() == watchesView) {
            return ; // Watches is already selected
        }
    }
    String viewName = VariablesViewButtons.isWatchesViewNested() ? "localsView" : "watchesView";
    ViewActions.openComponent (viewName, false).requestVisible();
}
 
Example 7
Source File: EditorTopComponent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 8
Source File: EditorTopComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 9
Source File: EditorTopComponent.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 10
Source File: EditorTopComponent.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 11
Source File: EditorTopComponent.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}
 
Example 12
Source File: MMDGraphEditor.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
  final Mode editor = WindowManager.getDefault().findMode("editor");
  if (editor != null) {
    final TopComponent component = editor.getSelectedTopComponent();
    if (component instanceof MMDGraphEditor) {
      ((MMDGraphEditor) component).findTextPanel.activate();
    }
  }
}