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


Java ActionProvider.invokeAction方法代码示例

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


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

示例1: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void invokeAction() {
    Project p = MainProjectManager.getDefault ().getMainProject ();
    ActionProvider actionProvider = p.getLookup ().lookup (
            ActionProvider.class
        );
    if (Arrays.asList(actionProvider.getSupportedActions ()).contains(ActionProvider.COMMAND_DEBUG_STEP_INTO) &&
        actionProvider.isActionEnabled(ActionProvider.COMMAND_DEBUG_STEP_INTO, p.getLookup())) {

        actionProvider.invokeAction (
                ActionProvider.COMMAND_DEBUG_STEP_INTO,
                p.getLookup ()
            );
    } else {
        Utilities.disabledActionBeep();
        setEnabled (
            ActionsManager.ACTION_STEP_INTO,
            false
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:StepIntoActionProvider.java

示例2: rerun

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public void rerun() {
    if ((properties.getProperty("test.includes") != null && properties.getProperty("test.includes").endsWith(".xml")) ||    //NOI18N
            (properties.getProperty("test.class") != null && properties.getProperty("test.class").endsWith(".xml"))) {   //NOI18N
        if (properties.getProperty("continue.after.failing.tests") == null) {   //NOI18N
            properties.setProperty("continue.after.failing.tests", "true");  //NOI18N
        }
        try {
            runAnt(FileUtil.toFileObject(scriptFile), targets, properties);
        } catch (IOException ex) {
            LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        }
    } else {
        Project project = testSession.getProject();
        if(ProjectManager.getDefault().isValid(project)) {
            ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
            String[] actionNames = getActionNames(targets);
            if (actionProvider != null) {
                if (Arrays.asList(actionProvider.getSupportedActions()).contains(actionNames[0])
                        && actionProvider.isActionEnabled(actionNames[0], lookup)) {
                    actionProvider.invokeAction(actionNames[0], lookup);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TestNGExecutionManager.java

示例3: runAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void runAction(String action) {
    Project project = getProject();
    if (project != null) {
        Lookup lookup = project.getLookup();
        if (fileForDocument != null) {
            try {
                DataObject dobj = DataObject.find(fileForDocument);
                lookup = dobj.getLookup();
            } catch (DataObjectNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        ActionProvider provider = project.getLookup().lookup(ActionProvider.class);
        if (provider != null) {
            if (provider.isActionEnabled(action, lookup)) {
                provider.invokeAction(action, lookup);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CoverageSideBar.java

示例4: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public void invokeAction(String command, Lookup context) throws IllegalArgumentException {
    for (ActionProvider ap : lkpResult.allInstances()) {
        if (Arrays.asList(ap.getSupportedActions()).contains(command) &&
            ap.isActionEnabled(command, context)) {
            ap.invokeAction(command, context);
            return;
        }
    }
    throw new IllegalArgumentException(String.format(command));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LookupProviderSupport.java

示例5: perform

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@NbBundle.Messages({
    "ERR_CannotBuildProject=Could not build the project",
    "ERR_ProjectBuildFailed=Project build failed, please check Output window",
})
@Override
public void perform(Project project) {
    ActionProvider p = project.getLookup().lookup(ActionProvider.class);
    // check whether the is CoS enabled fo the project
    if (ShellProjectUtils.isCompileOnSave(project)) {
        doRunShell(project);
        return;
    }
    if (p == null || !p.isActionEnabled(ActionProvider.COMMAND_BUILD, Lookups.singleton(project))) {
        StatusDisplayer.getDefault().setStatusText(Bundle.ERR_CannotBuildProject());
        return;
    }
    p.invokeAction(ActionProvider.COMMAND_BUILD, Lookups.fixed(project, new ActionProgress() {
        @Override
        protected void started() {
            // no op
        }

        @Override
        public void finished(boolean success) {
            if (success) {
                doRunShell(project);
            } else {
                StatusDisplayer.getDefault().setStatusText(Bundle.ERR_ProjectBuildFailed());
            }
        }
    }));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:REPLAction2.java

示例6: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public void invokeAction(String command, Lookup context) throws IllegalArgumentException {
    for (ActionProvider ap : delegates()) {
        if (Arrays.asList(ap.getSupportedActions()).contains(command) && ap.isActionEnabled(command, context)) {
            LOG.log(Level.FINE, "delegating {0} on {1} to {2}", new Object[] {command, context, ap});
            ap.invokeAction(command, context);
            return;
        }
    }
    throw new IllegalArgumentException(command);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LookupMergerImpl.java

示例7: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public static void invokeAction(Project project, String s) {
    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);

    if (ap == null) {
        return; // fail early
    }

    ap.invokeAction(s, Lookup.getDefault());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ProjectUtilities.java

示例8: runAllTests

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void runAllTests(ActionEvent evt) {//GEN-FIRST:event_runAllTests
    Lookup lookup = project.getLookup();
    ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
    CoverageProvider coverageProvider = CoverageManagerImpl.getProvider(project);
    String action = ActionProvider.COMMAND_TEST;
    if (coverageProvider != null && coverageProvider.getTestAllAction() != null) {
        action = coverageProvider.getTestAllAction();
    }
    if (actionProvider != null) {
        if (actionProvider.isActionEnabled(ActionProvider.COMMAND_TEST, lookup)) {
            actionProvider.invokeAction(action, lookup);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CoverageReportTopComponent.java

示例9: createLauncher

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public Launcher createLauncher(final Session session) {
    return new Launcher() {

        @Override
        public void launch(boolean rerun) {
            if (rerun) {
                RunConfig config = (RunConfig)session.getAttribute("mvn-run-checker.config");
                if (config != null) {
                    RunUtils.executeMaven(config);
                }
            } else {
                Project p = session.getProject();
                if (p == null) {
                    FileObject f = session.getFile();
                    if (f != null) {
                        p = FileOwnerQuery.getOwner(f);
                    }
                }
                if (p != null) {
                    ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
                    if (ap != null) {
                        ap.invokeAction(session.getCommand(), session.getContext());
                    }
                }
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:RunCheckerImpl.java

示例10: actionPerformed

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
protected void actionPerformed( final Lookup context ) {
    Runnable r = new Runnable() {
        //the tricky part here is that context can change in the time between AWT and RP execution.
        //unfortunately the ActionProviders from project need the lookup to see if the command is supported.
        // that sort of renders the ActionUtils.mineData() method useless here. Unless we are able to create a mock lookup with only projects and files.
        @Override
        public void run() {
    
    if (command != null) {
        final Project[] projects = ActionsUtil.getProjectsFromLookup( context, command );
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                if ( projects.length == 1 ) {            
                    ActionProvider ap = projects[0].getLookup().lookup(ActionProvider.class);
                    ap.invokeAction( command, context );
                    return;
                }

                ActionProvider provider = globalProvider(context);
                if (provider != null) {
                    provider.invokeAction(command, context);
                }
            }
        };
        //ActionProvider is supposed to run in awt
        if (SwingUtilities.isEventDispatchThread()) {
            r2.run();
        } else {
            SwingUtilities.invokeLater(r2);
        }            
    } else if (performer != null) {
        Collection<? extends DataObject> dobjs = context.lookupAll(DataObject.class);
        if (dobjs.size() == 1) {
            performer.perform(dobjs.iterator().next().getPrimaryFile());
        }
    }
               }
    };
    //no clear way of waiting for RP finishing the task, a lot of tests rely on sync execution.
    if (Boolean.getBoolean("sync.project.execution")) {
        r.run();
    } else {
        RP.post(r);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:FileAction.java

示例11: createFromTemplate

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@NbBundle.Messages({
    "MSG_NoVersion=No version attribute specified for the Maven project",
    "MSG_NoArtifactId=No artifactId attribute specified for the Maven project",
    "MSG_NoGroupId=No groupId attribute specified for the Maven project",
})
@Override
protected List<FileObject> createFromTemplate(CreateDescriptor desc) throws IOException {
    Properties archetype = new Properties();
    try (InputStream is = desc.getTemplate().getInputStream()) {
        archetype.load(is);
    }
    mergeProperties(desc, archetype);
    
    String version = archetype.getProperty("version"); // NOI18N
    if (version == null) {
        throw new IOException(Bundle.MSG_NoVersion());
    }
    String artifactId = archetype.getProperty("artifactId"); // NOI18N
    if (version == null) {
        throw new IOException(Bundle.MSG_NoArtifactId());
    }
    String groupId = archetype.getProperty("groupId"); // NOI18N
    if (version == null) {
        throw new IOException(Bundle.MSG_NoGroupId());
    }
    String packageName = archetype.getProperty("package"); // NOI18N
    ProjectInfo pi = new ProjectInfo(groupId, artifactId, version, packageName);
    Archetype arch = new Archetype();
    arch.setArtifactId(archetype.getProperty("archetypeArtifactId")); // NOI18N
    arch.setGroupId(archetype.getProperty("archetypeGroupId")); // NOI18N
    arch.setVersion(archetype.getProperty("archetypeVersion")); // NOI18N
    File projDir = desc.getValue(CommonProjectActions.PROJECT_PARENT_FOLDER);
    if (projDir == null) {
        projDir = FileUtil.toFile(desc.getTarget()).getParentFile();
    }
    if (projDir == null) {
        throw new IOException(CommonProjectActions.PROJECT_PARENT_FOLDER + " not specified");
    }
    
    Map<String, String> filteredProperties = 
            NbCollections.checkedMapByFilter(archetype, String.class, String.class, false);
    final File toCreate = new File(projDir, pi.artifactId);
    ArchetypeWizards.createFromArchetype(toCreate, pi, arch, filteredProperties, true);
    FileObject fo = FileUtil.toFileObject(toCreate);

    List<FileObject> fos = new ArrayList<>();
    collectPomDirs(fo, fos);
    final String toOpen = archetype.getProperty("archetypeOpen"); // NOI18N
    if (toOpen != null) {
        collectFiles(fo, fos, toOpen.split(",")); // NOI18N
    }

    if ("true".equals(archetype.getProperty("archetypeBuild"))) { // NOI18N
        Project prj = ProjectManager.getDefault().findProject(fo);
        ActionProvider ap = prj == null ? null : prj.getLookup().lookup(ActionProvider.class);
        if (ap != null) {
            ap.invokeAction(ActionProvider.COMMAND_BUILD, prj.getLookup());
        }
    }
    return fos;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:62,代码来源:ArchetypeTemplateHandler.java


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