org.openide.windows.Mode.getSelectedTopComponent()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.openide.windows.Mode.getSelectedTopComponent()方法的一些代码示例,展示了Mode.getSelectedTopComponent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mode.getSelectedTopComponent()方法的具体详情如下:
包路径:org.openide.windows.Mode
类名称:Mode
方法名:getSelectedTopComponent

Mode.getSelectedTopComponent介绍

[英]Gets selected TopComponent in this mode.
[中]在此模式下获取选定的TopComponent

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io

public void propertyChange (PropertyChangeEvent evt) {
      if (! TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName ()))
        return;
//            System.out.println ("!! Global Context Lookup Result = " + Utilities.actionsGlobalContext ().lookupAll (Object.class));
      Mode m = findEditorMode ();
      TopComponent component = m != null ? m.getSelectedTopComponent () : null;
      if (result != null)
        result.removeLookupListener (this);
      result = component != null ? component.getLookup ().lookupResult (DataEditorView.class) : null;
      if (result != null)
        result.addLookupListener (this);
      update ();
    }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private TopComponent selectedEditorComponent() {
  Mode editor = WindowManager.getDefault().findMode("editor");//NOI18N
  TopComponent tc = editor.getSelectedTopComponent();
  TopComponent topComponent = getTopComponent(EditorRegistry.lastFocusedComponent());
  if (topComponent == tc) {
    return tc;
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync

private List<FacesModel> getVisibleModels() {
    List<FacesModel> visibleModels = new ArrayList<FacesModel>();
    for(Mode mode : WindowManager.getDefault().getModes()) {
      TopComponent tc = mode.getSelectedTopComponent();
      if(tc != null && tc.isOpened() && isMultiViewTopComponent(tc)){
        TopComponent topComponent = getSelectedMultiView(tc);
        if(topComponent != null && isDesignerTopComponent(topComponent)) {
//                    DataObject dObj = topComponent.getActivatedNodes()[0].getLookup().lookup(DataObject.class);
          // XXX #131996 Defend against possible NPE's.
          org.openide.nodes.Node[] activatedNodes = topComponent.getActivatedNodes();
          if (activatedNodes == null || activatedNodes.length == 0) {
            info(new NullPointerException("TopComponent doesn't have any activated nodes, topComponent="
                + topComponent + ", nodes=" + activatedNodes)); // NOI18N
            continue;
          }
          DataObject dObj = activatedNodes[0].getLookup().lookup(DataObject.class);
          if (dObj == null) {
            info(new NullPointerException("Activated node from top component"
                + " doesn't contain DataObject in its first activated node lookup, topComponent="
                + topComponent + ", node=" + activatedNodes[0])); // NOI18N
            continue;
          }
          visibleModels.add((FacesModel)getModel(dObj.getPrimaryFile()));
        }
      }
    }
    return visibleModels;
  }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

TopComponent tc = editor.getSelectedTopComponent();
dropDownMenu.add(new InsertLinkAction(issues[i], outbox, isIssueRelated(tc)));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect

/**
 * 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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private void insertLink() {
  Mode editor = WindowManager.getDefault().findMode("editor"); //NOI18N
  TopComponent tc = editor.getSelectedTopComponent();
  if (getTopComponent(EditorRegistry.lastFocusedComponent()) == tc) {
    insertLinkToEditor();
  } else if (tc != null && isIssueRelated(tc)) {
    insertLinkToIssue();
  } else {
    insertLinkToEditor();
  }
}
private void insertLinkToEditor() {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

TopComponent tc = editor.getSelectedTopComponent();
if (getTopComponent(EditorRegistry.lastFocusedComponent()) == tc) {
  insertLinkToEditor();

相关文章