当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.getConfigObject方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileUtil.getConfigObject方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getConfigObject方法的具体用法?Java FileUtil.getConfigObject怎么用?Java FileUtil.getConfigObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileUtil的用法示例。


在下文中一共展示了FileUtil.getConfigObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyRegistered

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Test public void verifyRegistered() {
    final String path = "Actions/Test/html-test.instance";
    final FileObject fo = FileUtil.getConfigFile(path);
    assertNotNull(fo, "Registration found");
    Action a = FileUtil.getConfigObject(path, Action.class);
    assertNotNull(a, "Action found");
    assertEquals(a.getValue(Action.NAME), "Open me!");
    
    assertEquals(fo.getAttribute("class"), OpenHTMLRegistrationTest.class.getCanonicalName(), "Fully qualified name");
    assertEquals(fo.getAttribute("method"), "main");
    
    class FOMap extends HashMap<String,Object> {

        @Override
        public Object get(Object key) {
            return fo.getAttribute(key.toString());
        }
    }

    Pages.R r = new Pages.R(new FOMap());
    Object[] arr = r.getTechIds();
    assertEquals(arr.length, 3, "Three different ids");
    assertEquals(arr[0], "uno");
    assertEquals(arr[1], "duo");
    assertEquals(arr[2], "tre");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:OpenHTMLRegistrationTest.java

示例2: setShowEditorToolbar

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static boolean setShowEditorToolbar( boolean show ) {
    boolean res = true;
    Action toggleEditorToolbar = FileUtil.getConfigObject( "Editors/Actions/toggle-toolbar.instance", Action.class ); //NOI18N
    if( null != toggleEditorToolbar ) {
        if( toggleEditorToolbar instanceof Presenter.Menu ) {
            JMenuItem menuItem = ((Presenter.Menu)toggleEditorToolbar).getMenuPresenter();
            if( menuItem instanceof JCheckBoxMenuItem ) {
                JCheckBoxMenuItem checkBoxMenu = ( JCheckBoxMenuItem ) menuItem;
                res = checkBoxMenu.isSelected();
                if( checkBoxMenu.isSelected() != show ) {
                    try {
                        toggleEditorToolbar.actionPerformed( new ActionEvent( menuItem, 0, "")); //NOII18N
                    } catch( Exception ex ) {
                        //don't worry too much if it isn't working, we're just trying to be helpful here
                        Logger.getLogger( EditorOnlyDisplayer.class.getName()).log( Level.FINE, null, ex );
                    }
                }
            }
        }
    }

    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EditorOnlyDisplayer.java

示例3: forID

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Locates a specific action programmatically.
 * The action will typically have been registered using {@link ActionRegistration}.
 * <p>Normally an {@link ActionReference} will suffice to insert the action
 * into various UI elements (typically using {@link Utilities#actionsForPath}),
 * but in special circumstances you may need to find a single known action.
 * This method is just a shortcut for using {@link FileUtil#getConfigObject}
 * with the correct arguments, plus using {@link AcceleratorBinding#setAccelerator}.
 * @param category as in {@link ActionID#category}
 * @param id as in {@link ActionID#id}
 * @return the action registered under that ID, or null
 * @throws IllegalArgumentException if a corresponding {@link ActionID} would have been rejected
 * @since 7.42
 */
public static Action forID(String category, String id) throws IllegalArgumentException {
    // copied from ActionProcessor:
    if (category.startsWith("Actions/")) {
        throw new IllegalArgumentException("category should not start with Actions/: " + category);
    }
    if (!FQN.matcher(id).matches()) {
        throw new IllegalArgumentException("id must be valid fully qualified name: " + id);
    }
    String path = "Actions/" + category + "/" + id.replace('.', '-') + ".instance";
    Action a = FileUtil.getConfigObject(path, Action.class);
    if (a == null) {
        return null;
    }
    FileObject def = FileUtil.getConfigFile(path);
    if (def != null) {
        AcceleratorBinding.setAccelerator(a, def);
    }
    return a;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Actions.java

示例4: close

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
void close() {
    if (isQuery) {
        RefactoringPanelContainer.getUsagesComponent().removePanel(this);
    } else {
        RefactoringPanelContainer.getRefactoringComponent().removePanel(this);
    }
    if(isVisible) {
        Action action = FileUtil.getConfigObject("Actions/Window/org-netbeans-core-windows-actions-SwitchToRecentDocumentAction.instance", Action.class); //NOI18N
        if(action != null) {
            action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null));
        }
    }
    closeNotify();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:RefactoringPanel.java

示例5: resolve

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public Future<Result> resolve() {
    FutureTask<Result> toRet = new FutureTask<Result>(new Callable<Result>() {
        
        @Override
        public Result call() throws Exception {
            NotifyDescriptor.Confirmation action = new NotifyDescriptor.Confirmation("You can either define netbeans.installation property in .m2/settings.xml file to point to currently running IDE or open the associated nbm-application project.", "Resolve missing NetBeans platform");
            String prop = "Define property";
            String open = "Open Application project";
            action.setOptions(new Object[] { prop, open, NotifyDescriptor.CANCEL_OPTION});
            Object result = DialogDisplayer.getDefault().notify(action);
            if (prop.equals(result)) {
                RunIDEInstallationChecker.setRunningIDEAsInstallation();
                return Result.create(Status.RESOLVED);
            }
            if (open.equals(result)) {
                final Action act = FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-OpenProject.instance", Action.class);
                if (act != null) {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            act.actionPerformed(null);
                        }
                    });
                }
            }
            return Result.create(Status.UNRESOLVED);
        }
    });
    toRet.run();
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:MissingNbInstallationProblemProvider.java

示例6: getIntentHandlers

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static SortedSet<IntentHandler> getIntentHandlers(
        Intent intent) {

    FileObject f = FileUtil.getConfigFile("Services/Intent/Handlers");
    if (f == null) {
        return null;
    }
    SortedSet<IntentHandler> candidates = new TreeSet<>();
    for (FileObject fo : f.getChildren()) {
        if ("instance".equals(fo.getExt())) {
            Object pattern = fo.getAttribute("uriPattern");
            Object displayName = fo.getAttribute("displayName");
            Object position = fo.getAttribute("position");
            Object actions = fo.getAttribute("actions");
            if (pattern instanceof String && displayName instanceof String
                    && position instanceof Integer
                    && actions instanceof String) {
                if (canSupport((String) pattern, (String) actions, intent)) {
                    try {
                        IntentHandler ih = FileUtil.getConfigObject(
                                fo.getPath(), IntentHandler.class);
                        candidates.add(ih);
                    } catch (Exception e) {
                        LOG.log(Level.INFO,
                                "Cannot instantiate handler for " //NOI18N
                                + fo.getPath(), e);
                    }
                }
            } else {
                LOG.log(Level.FINE, "Invalid URI handler {0}", fo.getPath());
            }
        }
    }
    return candidates;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:Intent.java

示例7: getAcceleratedAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static Action getAcceleratedAction(String path) {
    // or use Actions.forID
    Action a = FileUtil.getConfigObject(path, Action.class);
    FileObject fo = FileUtil.getConfigFile(path);
    if(fo != null) {
        AcceleratorBinding.setAccelerator(a, fo);
    }
    return a;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:Utils.java

示例8: missingNavigatorAPIHack

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
static void missingNavigatorAPIHack(
        @NonNull final ActionEvent ev,
        @NonNull final JavaSource context,
        @NullAllowed final JTextComponent target) {
    final Action openNavigator = FileUtil.getConfigObject(
            "Actions/Window/org-netbeans-modules-navigator-ShowNavigatorAction.instance",
            Action.class);
    if (openNavigator != null) {
        openNavigator.actionPerformed(ev);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                NavigatorHandler.activateNavigator();
                final Collection<? extends NavigatorPanel> panels = getPanels(context);
                NavigatorPanel cmp = null;
                for (NavigatorPanel panel : panels) {
                    if (panel.getComponent().getClass() == ClassMemberPanelUI.class) {
                        cmp = panel;
                        break;
                    }
                }
                if (cmp != null) {
                    NavigatorHandler.activatePanel(cmp);
                    ((ClassMemberPanelUI)cmp.getComponent()).setContext(context, target);
                }
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ShowMembersAction.java

示例9: testSharedClassObject

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testSharedClassObject() throws Exception {
    Shared instance = SharedClassObject.findObject(Shared.class, true);
    FileObject data = FileUtil.createData(root, "dir/" + Shared.class.getName().replace('.', '-') + ".instance");
    Lookup l = Lookups.forPath("dir");
    assertSame(instance, l.lookup(Shared.class));
    
    Shared created = FileUtil.getConfigObject(data.getPath(), Shared.class);
    assertSame("Config file found", instance, created);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SharedClassObjectFactoryTest.java

示例10: btnGlobalActionPerformed

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
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"));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LicenseHeadersPanel.java

示例11: installKeybindings

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void installKeybindings(JTextComponent component) {
// Register Escape key
       registerKeybinding(ACTION_ESCAPE, ESCAPE,
       KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
       ExtKit.escapeAction, component);

       // Register up key
       registerKeybinding(ACTION_COMPLETION_UP, COMPLETION_UP,
       KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
       BaseKit.upAction, component);

       // Register down key
       registerKeybinding(ACTION_COMPLETION_DOWN, COMPLETION_DOWN,
       KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
       BaseKit.downAction, component);

       // Register PgDn key
       registerKeybinding(ACTION_COMPLETION_PGDN, COMPLETION_PGDN,
       KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
       BaseKit.pageDownAction, component);

       // Register PgUp key
       registerKeybinding(ACTION_COMPLETION_PGUP, COMPLETION_PGUP,
       KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
       BaseKit.pageUpAction, component);

       // Register home key
       registerKeybinding(ACTION_COMPLETION_BEGIN, COMPLETION_BEGIN,
       KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
       BaseKit.beginLineAction, component);

       // Register end key
       registerKeybinding(ACTION_COMPLETION_END, COMPLETION_END,
       KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
       BaseKit.endLineAction, component);

       Action action = FileUtil.getConfigObject("Actions/Source/org-netbeans-modules-editor-hints-FixAction.instance", Action.class); //NOI18N
       KeyStroke ks = action != null ? (KeyStroke) action.getValue(Action.ACCELERATOR_KEY) : null;
       registerKeybinding(ACTION_COMPLETION_SUBITEMS_SHOW, COMPLETION_SUBITEMS_SHOW,
       ks != null ? ks : KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_MASK),
       null, component);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:CompletionScrollPane.java

示例12: testNullForFolders

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testNullForFolders() throws Exception {
    FileObject data = FileUtil.createFolder(root, "dir/" + Shared.class.getName().replace('.', '-') + ".instance");
    Shared nul = FileUtil.getConfigObject(data.getPath(), Shared.class);
    assertNull("No object for folders", nul);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:RecognizeInstanceFilesTest.java

示例13: getShowLogAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
static Action getShowLogAction() {
    return FileUtil.getConfigObject("Actions/View/org-netbeans-core-actions-LogAction.instance", Action.class); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:IssuePanel.java

示例14: getGlobalKitAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
protected Action getGlobalKitAction() {
    return FileUtil.getConfigObject("Editors/private/GlobalFormatAction.instance", Action.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:MainMenuAction.java


注:本文中的org.openide.filesystems.FileUtil.getConfigObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。