org.openide.filesystems.FileUtil.getConfigObject()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(84)

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

FileUtil.getConfigObject介绍

[英]Finds a config object under given path. The path contains the extension of a file e.g.:

Actions/Edit/org-openide-actions-CopyAction.instance 
Services/Browsers/swing-browser.settings

[中]在给定路径下查找配置对象。路径包含文件的扩展名,例如:

Actions/Edit/org-openide-actions-CopyAction.instance 
Services/Browsers/swing-browser.settings

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

Action a = FileUtil.getConfigObject(path, Action.class);
if (a == null) {
  return null;

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-project-ant-ui

private void btnGlobalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGlobalActionPerformed
  // TODO add your handling code here:
  Action action = FileUtil.getConfigObject("Actions/System/org-netbeans-modules-templates-actions-TemplatesAction.instance", Action.class);
  if (action != null) {
    System.setProperty("org.netbeans.modules.templates.actions.TemplatesAction.preselect", "Licenses");
    action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "perform"));
  } else {
    Exceptions.printStackTrace(new Exception("Actions/System/org-netbeans-modules-templates-actions-TemplatesAction.instance not found"));
  }
}//GEN-LAST:event_btnGlobalActionPerformed

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

private void addGruntActions(List<Action> actions) {
  ClientProjectEnhancedBrowserImplementation cfg = project.getEnhancedBrowserImpl();
  if (cfg == null) {
    return;
  }
  ActionProvider actionProvider = cfg.getActionProvider();
  if (actionProvider == null) {
    return;
  }
  Set<String> supportedActions = new HashSet<>(Arrays.asList(actionProvider.getSupportedActions()));
  boolean grunt = project.getProjectDirectory().getFileObject("Gruntfile.js") !=null;
  boolean buildSupported = supportedActions.contains(ActionProvider.COMMAND_BUILD) || grunt;
  boolean rebuildSupported = supportedActions.contains(ActionProvider.COMMAND_REBUILD) || grunt;
  boolean cleanSupported = supportedActions.contains(ActionProvider.COMMAND_CLEAN) || grunt;
  int index = 1; // right after New... action
  if (buildSupported
      || rebuildSupported
      || cleanSupported) {
    actions.add(index++, null);
  }
  if (buildSupported) {
    actions.add(index++, FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-BuildProject.instance", Action.class)); // NOI18N
  }
  if (rebuildSupported) {
    actions.add(index++, FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-RebuildProject.instance", Action.class)); // NOI18N
  }
  if (cleanSupported) {
    actions.add(index++, FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-CleanProject.instance", Action.class)); // NOI18N
  }
}

代码示例来源:origin: senbox-org/snap-desktop

private void addAboutBoxPlugins(JTabbedPane tabbedPane, FileObject configFile) {
    FileObject aboutBoxPanels[] = configFile.getChildren();
    List<FileObject> orderedAboutBoxPanels = FileUtil.getOrder(Arrays.asList(aboutBoxPanels), true);
    for (FileObject aboutBoxFileObject : orderedAboutBoxPanels) {
      JComponent panel = FileUtil.getConfigObject(aboutBoxFileObject.getPath(), JComponent.class);
      if (panel != null) {
        String displayName = (String) aboutBoxFileObject.getAttribute("displayName");
        if (displayName != null && !displayName.trim().isEmpty()) {
          Icon icon = null;
          String iconPath = (String) aboutBoxFileObject.getAttribute("iconPath");
          if (iconPath != null && !iconPath.trim().isEmpty()) {
            Image image = ImageUtilities.loadImage(iconPath, false);
            if (image != null) {
              icon = new ImageIcon(image);
            }
          }
          tabbedPane.addTab(displayName, icon, panel);
        }
      }
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-intent

if (canSupport((String) pattern, (String) actions, intent)) {
  try {
    IntentHandler ih = FileUtil.getConfigObject(
        fo.getPath(), IntentHandler.class);
    candidates.add(ih);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring

public static PopupDelegateCompletionItem createImplementItem(int substitutionOffset, JTextComponent component) {
  Action action = FileUtil.getConfigObject("Editors/Actions/generate-code.instance", Action.class); // NOI18N
  if (action != null) {
    String rightText = "";
    BaseKit kit = Utilities.getKit(component);
    if (kit != null) {
      Action a = kit.getActionByName((String)action.getValue(Action.NAME));
      MultiKeymap keymap = kit.getKeymap();
      if (keymap != null) {
        KeyStroke[] keys = keymap.getKeyStrokesForAction(a);
        if (keys != null && keys.length > 0) {
          KeyStroke ks = keys[0];
          String keyModifiersText = KeyEvent.getKeyModifiersText(ks.getModifiers());
          if (keyModifiersText.length() > 0) {
            rightText = keyModifiersText + "+" + KeyEvent.getKeyText(ks.getKeyCode()); // NOI18N
          } else {
            rightText = KeyEvent.getKeyText(ks.getKeyCode());
          }
        }
      }
    }
    return new PopupDelegateCompletionItem(substitutionOffset, action, rightText);
  }
  return null;
}

代码示例来源:origin: senbox-org/snap-desktop

@Test
public void testAddRemoveAction() throws Exception {
  AbstractAction realAction = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
    }
  };
  FileObject actionFile = SnapUtils.addAction(realAction, "Test/Action");
  assertNotNull(actionFile);
  assertNotNull(actionFile.getParent());
  assertEquals("application/x-nbsettings", actionFile.getMIMEType());
  assertEquals("Test/Action", actionFile.getParent().getPath());
  assertEquals("instance", actionFile.getExt());
  Action action = FileUtil.getConfigObject(actionFile.getPath(), Action.class);
  assertNotNull(action);
  assertEquals(TransientAction.class, action.getClass());
  assertSame(realAction, ((TransientAction) action).getDelegate());
  boolean ok = SnapUtils.removeAction(actionFile);
  assertEquals(true, ok);
  action = FileUtil.getConfigObject(actionFile.getPath(), Action.class);
  assertNull(action);
}

代码示例来源:origin: senbox-org/snap-desktop

@Test
public void testAddRemoveActionReference() throws Exception {
  AbstractAction realAction = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
    }
  };
  FileObject actionFile = SnapUtils.addAction(realAction, "Test/Action");
  FileObject actionRef1File = SnapUtils.addActionReference(actionFile, "Test/Refs1", 10);
  assertNotNull(actionRef1File);
  assertNotNull(actionRef1File.getParent());
  assertEquals("Test/Refs1", actionRef1File.getParent().getPath());
  assertEquals("shadow", actionRef1File.getExt());
  assertEquals("content/unknown", actionRef1File.getMIMEType());
  Action refAction = FileUtil.getConfigObject(actionRef1File.getPath(), Action.class);
  assertNotNull(refAction);
  assertEquals(TransientAction.class, refAction.getClass());
  assertSame(realAction, ((TransientAction) refAction).getDelegate());
  boolean ok = SnapUtils.removeActionReference(actionFile);
  assertEquals(false, ok);
  ok = SnapUtils.removeActionReference(actionRef1File);
  assertEquals(true, ok);
  refAction = FileUtil.getConfigObject(actionRef1File.getPath(), Action.class);
  assertNull(refAction);
}

相关文章

微信公众号

最新文章

更多