Java 类org.eclipse.debug.core.ILaunchManager 实例源码

项目:brjs-JsTestDriver    文件:JavascriptLaunchConfigurationHelper.java   
public ILaunchConfiguration getLaunchConfiguration(String projectName) {
  try {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager
        .getLaunchConfigurationType(JSTD_LAUNCH_CONFIGURATION_TYPE);
    ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(type);
    for (ILaunchConfiguration launchConfiguration : launchConfigurations) {
      String configProjectName =
          launchConfiguration.getAttribute(LaunchConfigurationConstants.PROJECT_NAME,
              "");
      if (configProjectName.equals(projectName)
          && isValidToRun(projectName, launchConfiguration)) {
        return launchConfiguration;
      }
    }
  } catch (CoreException e) {
    //logger.logException(e);
  }
  return null;
}
项目:n4js    文件:AbstractRunnerLaunchShortcut.java   
/**
 * Launch a file, using the file information, which means using default launch configurations.
 */
protected void launchFile(IFile originalFileToRun, String mode) {
    final String runnerId = getRunnerId();
    final String path = originalFileToRun.getFullPath().toOSString();
    final URI moduleToRun = URI.createPlatformResourceURI(path, true);

    final String implementationId = chooseImplHelper.chooseImplementationIfRequired(runnerId, moduleToRun);
    if (implementationId == ChooseImplementationHelper.CANCEL)
        return;

    RunConfiguration runConfig = runnerFrontEnd.createConfiguration(runnerId, implementationId, moduleToRun);

    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID());
    DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode);
    // execution dispatched to proper delegate LaunchConfigurationDelegate
}
项目:com.onpositive.prefeditor    文件:FolderSelectionDialog.java   
private void addLaunchCfg() {
    try {
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type = manager
                .getLaunchConfigurationType("org.eclipse.pde.ui.RuntimeWorkbench");
        ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);
        List<ILaunchConfiguration> configList = Arrays.asList(lcs);
        List<String> configs = configList.stream().map(config -> config.getName()).collect(Collectors.toList());
        ComboDialog dialog = new ComboDialog(getShell(), true);
        dialog.setTitle("Choose launch config");
        dialog.setInfoText("Choose Eclipse launch conguration to edit it's configuration settings");
        dialog.setAllowedValues(configs);
        if (dialog.open() == OK) {
            String selectedName = dialog.getValue();
            ILaunchConfiguration selectedConfig = configList.stream().filter(config -> selectedName.equals(config.getName())).findFirst().get();
            String configLocation = getConfigLocation(selectedConfig);
            valueAdded(new File(configLocation, ".settings").getAbsolutePath());
            buttonPressed(IDialogConstants.OK_ID);
        }
    } catch (CoreException e) {
        PrefEditorPlugin.log(e);
    }
}
项目:eclemma    文件:ContextualLaunchableTester.java   
private IConfigurationElement findEnablementConfiguration(
    String delegateShortcutID) {
  IConfigurationElement[] configs = Platform.getExtensionRegistry()
      .getConfigurationElementsFor("org.eclipse.debug.ui.launchShortcuts"); //$NON-NLS-1$
  for (final IConfigurationElement config : configs) {
    if (!delegateShortcutID.equals(config.getAttribute("id")))continue; //$NON-NLS-1$
    String modes = config.getAttribute("modes"); //$NON-NLS-1$
    if (modes == null)
      continue;
    if (!Arrays.asList(modes.split("\\W")).contains(ILaunchManager.RUN_MODE))continue; //$NON-NLS-1$
    IConfigurationElement[] launch = config.getChildren("contextualLaunch"); //$NON-NLS-1$
    if (launch.length != 1)
      continue;
    IConfigurationElement[] enablement = launch[0]
        .getChildren(ExpressionTagNames.ENABLEMENT);
    if (enablement.length == 1)
      return enablement[0];
  }
  return null;
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegate.java   
@VisibleForTesting
static ILaunchConfiguration createMavenPackagingLaunchConfiguration(IProject project)
    throws CoreException {
  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType launchConfigurationType = launchManager
      .getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

  String launchConfigName = "CT4E App Engine flexible Maven deploy artifact packaging "
      + project.getLocation().toString().replaceAll("[^a-zA-Z0-9]", "_");

  ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(
      null /*container*/, launchConfigName);
  workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
  // IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND;
  workingCopy.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true);
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, project.getLocation().toString());
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, "package");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, "${project}");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true);

  IPath jreContainerPath = getJreContainerPath(project);
  workingCopy.setAttribute(
      IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreContainerPath.toString());

  return workingCopy;
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegateTest.java   
@Test
public void testGenerateRunConfiguration() throws CoreException {
  when(launchConfiguration.getAttribute(anyString(), anyString()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());
  when(launchConfiguration.getAttribute(anyString(), anyInt()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());
  when(server.getAttribute(anyString(), anyString()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());
  when(server.getAttribute(anyString(), anyInt()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());

  DefaultRunConfiguration config = new LocalAppEngineServerLaunchConfigurationDelegate()
      .generateServerRunConfiguration(launchConfiguration, server, ILaunchManager.RUN_MODE);
  assertNull(config.getHost());
  assertEquals((Integer) LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT, config.getPort());
  assertNull(config.getApiPort());
  assertNull(config.getJvmFlags());
  verify(server, atLeastOnce()).getHost();
  verify(launchConfiguration, atLeastOnce()).getAttribute(anyString(), anyInt());
  verify(server, atLeastOnce()).getAttribute(anyString(), anyInt());
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegateTest.java   
@Test
public void testGenerateRunConfiguration_withServerPort() throws CoreException {
  when(launchConfiguration.getAttribute(anyString(), anyString()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());
  when(launchConfiguration
      .getAttribute(eq(LocalAppEngineServerBehaviour.SERVER_PORT_ATTRIBUTE_NAME), anyInt()))
          .thenReturn(9999);

  DefaultRunConfiguration config = new LocalAppEngineServerLaunchConfigurationDelegate()
      .generateServerRunConfiguration(launchConfiguration, server, ILaunchManager.RUN_MODE);

  assertNotNull(config.getPort());
  assertEquals(9999, (int) config.getPort());
  verify(launchConfiguration)
      .getAttribute(eq(LocalAppEngineServerBehaviour.SERVER_PORT_ATTRIBUTE_NAME), anyInt());
  verify(server, never()).getAttribute(anyString(), anyInt());
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegateTest.java   
@Test
public void testGenerateRunConfiguration_withAdminPortWhenDevAppserver2() throws CoreException {
  Assume.assumeTrue(LocalAppEngineServerLaunchConfigurationDelegate.DEV_APPSERVER2);

  when(launchConfiguration.getAttribute(anyString(), anyString()))
      .thenAnswer(AdditionalAnswers.returnsSecondArg());
  when(launchConfiguration
      .getAttribute(eq(LocalAppEngineServerBehaviour.ADMIN_PORT_ATTRIBUTE_NAME), anyInt()))
          .thenReturn(9999);

  DefaultRunConfiguration config = new LocalAppEngineServerLaunchConfigurationDelegate()
      .generateServerRunConfiguration(launchConfiguration, server, ILaunchManager.RUN_MODE);

  assertNull(config.getAdminPort());
  verify(launchConfiguration, never())
      .getAttribute(eq(LocalAppEngineServerBehaviour.ADMIN_PORT_ATTRIBUTE_NAME), anyInt());
  verify(server, never())
      .getAttribute(eq(LocalAppEngineServerBehaviour.ADMIN_PORT_ATTRIBUTE_NAME), anyInt());
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegateTest.java   
@Test
public void testGenerateRunConfiguration_withEnvironment() throws CoreException {
  Map<String, String> definedMap = new HashMap<>();
  definedMap.put("foo", "bar");
  definedMap.put("baz", "${env_var:PATH}");
  when(launchConfiguration.getAttribute(eq(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES),
      anyMapOf(String.class, String.class)))
      .thenReturn(definedMap);

  DefaultRunConfiguration config = new LocalAppEngineServerLaunchConfigurationDelegate()
      .generateServerRunConfiguration(launchConfiguration, server, ILaunchManager.RUN_MODE);

  Map<String, String> parsedEnvironment = config.getEnvironment();
  assertNotNull(parsedEnvironment);
  assertEquals("bar", parsedEnvironment.get("foo"));
  assertEquals(System.getenv("PATH"), parsedEnvironment.get("baz"));
  verify(launchConfiguration).getAttribute(eq(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES),
      anyMapOf(String.class, String.class));
  verify(launchConfiguration, atLeastOnce())
      .getAttribute(eq(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES),
      anyBoolean());
}
项目:google-cloud-eclipse    文件:LaunchModes.java   
@Override
@SuppressWarnings("rawtypes")
public Map getParameterValues() {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  Map<String, String> modes = new HashMap<>();
  for (String modeId : LocalAppEngineServerLaunchConfigurationDelegate.SUPPORTED_LAUNCH_MODES) {
    ILaunchMode mode = manager.getLaunchMode(modeId);
    if (mode != null) {
      // label is intended to be shown in menus and buttons and often has
      // embedded '&' for mnemonics, which isn't useful here
      String label = mode.getLabel();
      label = label.replace("&", "");
      modes.put(label, mode.getIdentifier());
    }
  }
  return modes;
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegateTest.java   
@Test
public void testCreateMavenPackagingLaunchConfiguration() throws CoreException {
  IProject project = projectCreator.getProject();

  ILaunchConfiguration launchConfig =
      FlexMavenPackagedProjectStagingDelegate.createMavenPackagingLaunchConfiguration(project);

  boolean privateConfig = launchConfig.getAttribute(ILaunchManager.ATTR_PRIVATE, false);
  assertTrue(privateConfig);

  boolean launchInBackground = launchConfig.getAttribute(
      "org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", false);
  assertTrue(launchInBackground);

  String jreContainerPath = launchConfig.getAttribute(
      IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, "");
  assertEquals("org.eclipse.jdt.launching.JRE_CONTAINER/"
      + "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7", jreContainerPath);

  String pomDirectory = launchConfig.getAttribute(MavenLaunchConstants.ATTR_POM_DIR, "");
  assertEquals(project.getLocation().toString(), pomDirectory);

  String mavenGoals = launchConfig.getAttribute(MavenLaunchConstants.ATTR_GOALS, "");
  assertEquals("package", mavenGoals);
}
项目:turnus.orcc    文件:OrccCodeAnalysisLaunchShortcut.java   
private ILaunchConfiguration[] getConfigurations(IFile file) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_CODE_ANALYSIS);
    try {
        // configurations that match the given resource
        List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();

        // candidates
        ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type);
        String name = FileUtils.getRelativePath(file);
        for (ILaunchConfiguration config : candidates) {
            String fileName = config.getAttribute(CAL_XDF.longName(), "");
            if (fileName.equals(name)) {
                configs.add(config);
            }
        }

        return configs.toArray(new ILaunchConfiguration[] {});
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:turnus.orcc    文件:OrccNumaExecutionLaunchShortcut.java   
private ILaunchConfiguration[] getConfigurations(IFile file) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_NUMA_EXECUTION_ANALYSIS);
    try {
        // configurations that match the given resource
        List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();

        // candidates
        ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type);
        String name = FileUtils.getRelativePath(file);
        for (ILaunchConfiguration config : candidates) {
            String fileName = config.getAttribute(CAL_XDF.longName(), "");
            if (fileName.equals(name)) {
                configs.add(config);
            }
        }

        return configs.toArray(new ILaunchConfiguration[] {});
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:turnus.orcc    文件:TabuSearchPerformanceEstimationLaunchShortcut.java   
private ILaunchConfiguration[] getConfigurations(IFile file) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_TABU_PERFORMANCE_ESTMATION_ANALYSIS);
    try {
        // configurations that match the given resource
        List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();

        // candidates
        ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type);
        String name = FileUtils.getRelativePath(file);
        for (ILaunchConfiguration config : candidates) {
            String fileName = config.getAttribute(CAL_XDF.longName(), "");
            if (fileName.equals(name)) {
                configs.add(config);
            }
        }

        return configs.toArray(new ILaunchConfiguration[] {});
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:turnus.orcc    文件:OrccDynamicExecutionLaunchShortcut.java   
private ILaunchConfiguration[] getConfigurations(IFile file) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager
            .getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_EXECUTION_ANALYSIS);
    try {
        // configurations that match the given resource
        List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();

        // candidates
        ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type);
        String name = FileUtils.getRelativePath(file);
        for (ILaunchConfiguration config : candidates) {
            String fileName = config.getAttribute(CAL_XDF.longName(), "");
            if (fileName.equals(name)) {
                configs.add(config);
            }
        }

        return configs.toArray(new ILaunchConfiguration[] {});
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:turnus.orcc    文件:OrccDynamicInterpreterLaunchShortcut.java   
private ILaunchConfiguration[] getConfigurations(IFile file) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_INTERPRETER_ANALYSIS);
    try {
        // configurations that match the given resource
        List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();

        // candidates
        ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type);
        String name = FileUtils.getRelativePath(file);
        for (ILaunchConfiguration config : candidates) {
            String fileName = config.getAttribute(CAL_XDF.longName(), "");
            if (fileName.equals(name)) {
                configs.add(config);
            }
        }

        return configs.toArray(new ILaunchConfiguration[] {});
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:EclipsePlugins    文件:JavaLaunchShortcut.java   
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION);
    ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName());
    config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName());
    config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true);
    config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
    IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
    Map<String, Argument> def = connector.getDefaultArguments();
    Map<String, String> argMap = new HashMap<String, String>(def.size());
    argMap.put("hostname", getHostname(activeProj));
    argMap.put("port", "8348");
    WPILibJavaPlugin.logInfo(argMap.toString());
    config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap);
    return config;
}
项目:EclipsePlugins    文件:JavaLaunchShortcut.java   
private void startDebugConfig(final ILaunchConfigurationWorkingCopy config) 
        throws CoreException, InterruptedException {
    int remainingAttempts = DEBUG_ATTACH_ATTEMPTS;

    // Retry until success or rethrow of exception on failure
    while (true) {
        try {
            WPILibJavaPlugin.logInfo("Attemping to attach debugger...");
            config.launch(ILaunchManager.DEBUG_MODE, null);
            WPILibJavaPlugin.logInfo("Debugger attached.");
            break;
        } catch (CoreException e) {
            if (--remainingAttempts > 0) {
                String errorMsg = MessageFormat.format("Unable to attach debugger. "
                        + "{0} attempts remain - waiting {1} second(s) before retrying...", 
                        remainingAttempts, DEBUG_ATTACH_RETRY_DELAY_SEC);
                WPILibJavaPlugin.logError(errorMsg, null);
                Thread.sleep(DEBUG_ATTACH_RETRY_DELAY_SEC * 1000);
            } else {
                throw e;
            }
        }
    }
}
项目:tlaplus    文件:TLCModelFactory.java   
/**
 * @see Model#getByName(String)
 */
public static Model getByName(final String fullQualifiedModelName) {
    Assert.isNotNull(fullQualifiedModelName);
    Assert.isLegal(!fullQualifiedModelName.contains(Model.SPEC_MODEL_DELIM), "Not a full-qualified model name.");

       final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
       final ILaunchConfigurationType launchConfigurationType = launchManager
               .getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);

    try {
        final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType);
        for (int i = 0; i < launchConfigurations.length; i++) {
            // Can do equals here because of full qualified name.
            final ILaunchConfiguration launchConfiguration = launchConfigurations[i];
            if (fullQualifiedModelName.equals(launchConfiguration.getName())) {
                return launchConfiguration.getAdapter(Model.class);
            }
        }
    } catch (CoreException shouldNeverHappen) {
        shouldNeverHappen.printStackTrace();
    }

    return null;
}
项目:tlaplus    文件:TLCModelFactory.java   
public static Model getBy(final IFile aFile) {
    Assert.isNotNull(aFile);

       final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
       final ILaunchConfigurationType launchConfigurationType = launchManager
               .getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);

    try {
        final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType);
        for (int i = 0; i < launchConfigurations.length; i++) {
            // Can do equals here because of full qualified name.
            final ILaunchConfiguration launchConfiguration = launchConfigurations[i];
            if (aFile.equals(launchConfiguration.getFile())) {
                return launchConfiguration.getAdapter(Model.class);
            }
        }
    } catch (CoreException shouldNeverHappen) {
        shouldNeverHappen.printStackTrace();
    }

    return null;
}
项目:cft    文件:JavaPackageFragmentRootHandler.java   
protected ILaunchConfiguration createConfiguration(IType type)
        throws CoreException {

    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

    ILaunchConfigurationType configType = manager
            .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);

    ILaunchConfigurationWorkingCopy workingCopy = configType.newInstance(
            null, manager.generateLaunchConfigurationName(type
                    .getTypeQualifiedName('.')));
    workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
            type.getFullyQualifiedName());
    workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type
                    .getJavaProject().getElementName());
    workingCopy.setMappedResources(new IResource[] { type
            .getUnderlyingResource() });
    return workingCopy.doSave();
}
项目:jsbuild-eclipse    文件:JSBuildFileLaunchShortcut.java   
/**
 * Delegate method to launch the specified <code>ILaunchConfiguration</code>
 * in the specified mode
 * 
 * @param mode
 *            the mode to launch in
 * @param configuration
 *            the <code>ILaunchConfiguration</code> to launch
 */
private void launch(String mode, ILaunchConfiguration configuration) {
    if (fShowDialog) {
        /*
         * // Offer to save dirty editors before opening the dialog as the
         * contents // of an Ant editor often affect the contents of the
         * dialog. if (!DebugUITools.saveBeforeLaunch()) { return; }
         */
        IStatus status = new Status(IStatus.INFO,
                JSBuildFileUIPlugin.PLUGIN_ID, STATUS_INIT_RUN_ANT, "",
                null);
        String groupId;
        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
            groupId = IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
        } else {
            groupId = org.eclipse.ui.externaltools.internal.model.IExternalToolConstants.ID_EXTERNAL_TOOLS_LAUNCH_GROUP;
        }
        DebugUITools.openLaunchConfigurationDialog(JSBuildFileUIPlugin
                .getActiveWorkbenchWindow().getShell(), configuration,
                groupId, status);
    } else {
        DebugUITools.launch(configuration, mode);
    }
}
项目:agui_eclipse_plugin    文件:AguiLaunchController.java   
/**
 * Looks for and returns an existing {@link ILaunchConfiguration} object for a
 * specified project.
 * @param manager The {@link ILaunchManager}.
 * @param type The {@link ILaunchConfigurationType}.
 * @param projectName The name of the project
 * @return an existing <code>ILaunchConfiguration</code> object matching the project, or
 *      <code>null</code>.
 */
public static ILaunchConfiguration findConfig(ILaunchManager manager,
        ILaunchConfigurationType type, String projectName) {
    try {
        ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);

        for (ILaunchConfiguration config : configs) {
            if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")
                    .equals(projectName)) {  //$NON-NLS-1$
                return config;
            }
        }
    } catch (CoreException e) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                "Launch Error", e.getStatus().getMessage());
    }

    // didn't find anything that matches. Return null
    return null;
}
项目:gerrit-tools    文件:BranchOperationUI.java   
private ILaunchConfiguration getRunningLaunchConfiguration() {
    Set<IProject> projects = new HashSet<IProject>(
            Arrays.asList(ProjectUtil.getProjects(repository)));

    ILaunchManager launchManager = DebugPlugin.getDefault()
            .getLaunchManager();
    ILaunch[] launches = launchManager.getLaunches();
    for (ILaunch launch : launches) {
        if (launch.isTerminated())
            continue;
        ISourceLocator locator = launch.getSourceLocator();
        if (locator instanceof ISourceLookupDirector) {
            ISourceLookupDirector director = (ISourceLookupDirector) locator;
            ISourceContainer[] containers = director.getSourceContainers();
            if (isAnyProjectInSourceContainers(containers, projects))
                return launch.getLaunchConfiguration();
        }
    }
    return null;
}
项目:testability-explorer    文件:TestabilityLaunchConfigurationHelper.java   
public ILaunchConfiguration getLaunchConfiguration(String projectName) {
  try {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager
        .getLaunchConfigurationType(TestabilityConstants.TESTABILITY_LAUNCH_CONFIGURATION_TYPE);
    ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(type);
    for (ILaunchConfiguration launchConfiguration : launchConfigurations) {
      String configProjectName =
          launchConfiguration.getAttribute(TestabilityConstants.CONFIGURATION_ATTR_PROJECT_NAME,
              "");
      if (configProjectName.equals(projectName)
          && isValidToRun(projectName, launchConfiguration)) {
        return launchConfiguration;
      }
    }
  } catch (CoreException e) {
    logger.logException(e);
  }
  return null;
}
项目:testability-explorer    文件:TestabilityLaunchConfigurationHelper.java   
public boolean isExistingLaunchConfigWithRunOnBuildOtherThanCurrent(
    String projectName, String launchConfigName) {
  try {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager
        .getLaunchConfigurationType(TestabilityConstants.TESTABILITY_LAUNCH_CONFIGURATION_TYPE);
    ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(type);
    for (ILaunchConfiguration launchConfiguration : launchConfigurations) {
      String configProjectName =
          launchConfiguration.getAttribute(TestabilityConstants.CONFIGURATION_ATTR_PROJECT_NAME,
              "");
      boolean runOnEveryBuild =
          launchConfiguration.getAttribute(TestabilityConstants.CONFIGURATION_ATTR_RUN_ON_BUILD,
              false);
      String configName = launchConfiguration.getName();
      boolean isProjectNameEqual = configProjectName.equals(projectName);
      boolean isLaunchConfigNameEqual = launchConfigName.equals(configName); 
      if (isProjectNameEqual && runOnEveryBuild && !isLaunchConfigNameEqual) {
        return true;
      }
    }
  } catch (CoreException e) {
    logger.logException(e);
  }
  return false;
}
项目:gwt-eclipse-plugin    文件:LaunchConfigurationUtilities.java   
/**
 * @param typeIds launch configuration type ids that will be searched for, or
 *          empty to match all
 * @throws CoreException
 */
public static List<ILaunchConfiguration> getLaunchConfigurations(
    IProject project, String... typeIds) throws CoreException {
  Set<String> setOfTypeIds = new HashSet<String>(Arrays.asList(typeIds));
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  List<ILaunchConfiguration> launchConfigs = new ArrayList<ILaunchConfiguration>();
  for (ILaunchConfiguration launchConfig : manager.getLaunchConfigurations()) {
    IJavaProject javaProject = getJavaProject(launchConfig);
    boolean typeIdIsOk = setOfTypeIds.isEmpty()
        || setOfTypeIds.contains(launchConfig.getType().getIdentifier());
    if (javaProject != null && project.equals(javaProject.getProject())
        && typeIdIsOk) {
      launchConfigs.add(launchConfig);
    }
  }

  return launchConfigs;
}
项目:gwt-eclipse-plugin    文件:GwtSuperDevModeCodeServerLaunchUtil.java   
/**
 * Create a new GWT SDM Code Server Configuration. This will occur when running the debug
 * configuration from shortcut.
 */
public static ILaunchConfiguration createLaunchConfig(String launchConfigName, final IProject project)
    throws CoreException, OperationCanceledException {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type = manager.getLaunchConfigurationType(GwtSuperDevModeLaunchConfiguration.TYPE_ID);
  ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchConfigName);

  // Project name
  LaunchConfigurationUtilities.setProjectName(launchConfig, project.getName());

  launchConfig.setMappedResources(new IResource[] {project});

  setDefaults(launchConfig, project);

  // Save the new launch configuration
  ILaunchConfiguration ilaunchConfig = launchConfig.doSave();

  return ilaunchConfig;
}
项目:gwt-eclipse-plugin    文件:NewProjectCreatorTool.java   
private static void removeLaunchConfig(String launchConfigName) throws Exception {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  try {
    ILaunchConfiguration[] launchConfigs = manager.getLaunchConfigurations();
    for (ILaunchConfiguration launchConfig : launchConfigs) {
      if (launchConfig.getName().equals(launchConfigName)) {
        launchConfig.delete();
        break;
      }
    }

  } catch (CoreException e) {
    GWTPluginLog.logError(e);
    throw new Exception("Could not remove existing Java launch configuration");
  }
}
项目:gwt-eclipse-plugin    文件:SwtBotLaunchManagerActions.java   
public static void terminateAllLaunchConfigs(SWTBot bot) {
  SwtBotUtils.print("Terminating Launches");

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = manager.getLaunches();
  if (launches == null || launches.length == 0) {
    SwtBotUtils.print("No Launches to terminate");
  }

  for (ILaunch launch : launches) {
    if (!launch.isTerminated()) {
      try {
        launch.terminate();
      } catch (DebugException e) {
        SwtBotUtils.printError("Could not terminate launch." + e.getMessage());
      }
    }
  }

  SwtBotWorkbenchActions.waitForIdle(bot);

  SwtBotUtils.print("Terminated Launches");
}
项目:gwt-eclipse-plugin    文件:WebAppLaunchUtil.java   
public static ILaunchConfiguration findConfigurationByName(String name) {
  try {
    String configTypeStr = WebAppLaunchConfiguration.TYPE_ID;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType typeid = launchManager.getLaunchConfigurationType(configTypeStr);
    ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(typeid);

    for (ILaunchConfiguration config : configs) {
      if (config.getName().equals(name)) {
        return config;
      }
    }
  } catch (CoreException e) {
    CorePluginLog.logError(e);
  }
  return null;
}
项目:gwt-eclipse-plugin    文件:CompilerLaunchShortcut.java   
private ILaunchConfigurationWorkingCopy createLaunchConfigWorkingCopy(String launchConfigName, IProject project)
    throws CoreException {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type = manager.getLaunchConfigurationType(CompilerLaunchConfiguration.TYPE_ID);

  final ILaunchConfigurationWorkingCopy config = type.newInstance(null, launchConfigName);

  // Main type
  GWTLaunchConfigurationWorkingCopy.setMainType(config, GwtLaunchConfigurationProcessorUtilities.GWT_COMPILER);

  // project name
  LaunchConfigurationUtilities.setProjectName(config, project.getName());

  // classpath
  config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
      ModuleClasspathProvider.computeProviderId(project));

  // Link the launch configuration to the project.
  // This will cause the launch config to be deleted automatically if the project is deleted.
  config.setMappedResources(new IResource[] { project });

  // Modules
  LaunchConfigurationProcessorUtilities.updateViaProcessor(new ModuleArgumentProcessor(), config);

  return config;
}
项目:eclipseforces    文件:AbstractLauncher.java   
public final void launch() {
  try {
    ILaunchConfigurationWorkingCopy workingCopy = createLaunchWorkingCopy();
    setUpConfiguration(workingCopy);
    final ILaunchConfiguration configuration = workingCopy.doSave();
    if(shouldRun())
      Utilities.runInDisplayThread(new Runnable() {

        public void run() {
          // must be called from ui thread
          DebugUITools.launch(configuration, ILaunchManager.RUN_MODE);
        }

      });
  } catch (Exception e) {
    Utilities.showException(e);
  }
}
项目:chromedevtools    文件:ChromiumRemoteTab.java   
private ISourceLookupDirector read(ILaunchConfiguration config) throws CoreException {
  String memento = config.getAttribute(
      ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
  if (memento == null) {
    return null;
  }
  String type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
  if (type == null) {
    type = config.getType().getSourceLocatorId();
  }
  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ISourceLocator locator = launchManager.newSourceLocator(type);
  if (locator instanceof IPersistableSourceLocator2 == false) {
    return null;
  }
  ISourceLookupDirector director = (ISourceLookupDirector) locator;
  director.initializeFromMemento(memento, config);
  return director;
}
项目:coordination    文件:CoordinatedModelExecutionContext.java   
private ILaunch createAndLaunchConfiguration(ExecutionMode executionMode,
        IProgressMonitor monitor, URI launchURI) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    String launchPathName = launchURI.toPlatformString(true);
    String tmpProjectName = launchPathName.substring(1, launchPathName.length());
    String projectName = tmpProjectName.substring(0, tmpProjectName.indexOf('/'));
    IProject launchProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    IFile launchFile = launchProject.getFile(launchPathName.replaceFirst("/"+projectName+"/", ""));
    ILaunchConfiguration launch = manager.getLaunchConfiguration(launchFile);
    try {
        ILaunch startedLaunch = launch.launch(ILaunchManager.DEBUG_MODE, monitor);
        return startedLaunch;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
项目:APICloud-Studio    文件:LocalWebServer.java   
public IStatus start(String mode, IProgressMonitor monitor)
{
    if (!ILaunchManager.RUN_MODE.equals(mode))
    {
        return new Status(IStatus.ERROR, WebServerCorePlugin.PLUGIN_ID, Messages.LocalWebServer_ServerModeError);
    }
    try
    {
        startServer(host, port);
        testConnection(getBaseURL());
    }
    catch (CoreException e)
    {
        return e.getStatus();
    }
    return Status.OK_STATUS;
}
项目:Eclipse-Postfix-Code-Completion    文件:FatJarPackageWizardPage.java   
private LaunchConfigurationElement[] getLaunchConfigurations() {
    ArrayList<ExistingLaunchConfigurationElement> result= new ArrayList<ExistingLaunchConfigurationElement>();

    try {
        ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type= manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
        ILaunchConfiguration[] launchconfigs= manager.getLaunchConfigurations(type);

        for (int i= 0; i < launchconfigs.length; i++) {
            ILaunchConfiguration launchconfig= launchconfigs[i];
            if (!launchconfig.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false)) {
                String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
                result.add(new ExistingLaunchConfigurationElement(launchconfig, projectName));
            }
        }
    } catch (CoreException e) {
        JavaPlugin.log(e);
    }

    return result.toArray(new LaunchConfigurationElement[result.size()]);
}
项目:thym    文件:CordovaCLI.java   
protected ILaunchConfiguration getLaunchConfiguration(String label){
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
    try {
        ILaunchConfiguration cfg = type.newInstance(null, "cordova");
        ILaunchConfigurationWorkingCopy wc = cfg.getWorkingCopy();
        wc.setAttribute(IProcess.ATTR_PROCESS_LABEL, label);
        if(additionalEnvProps != null && !additionalEnvProps.isEmpty()){
            wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,additionalEnvProps);
        }
        cfg = wc.doSave();
        return cfg;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}