org.eclipse.debug.core.ILaunchManager Java Examples

The following examples show how to use org.eclipse.debug.core.ILaunchManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TLCModelFactory.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * @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;
}
 
Example #2
Source File: PyUnitServer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * As we need to be able to relaunch, we store the configuration and launch here (although the relaunch won't be
 * actually done in this class, this is the place to get information on it).
 * 
 * @param config used to get the configuration of the launch.
 * @param launch the actual launch
 * @throws IOException
 */
public PyUnitServer(PythonRunnerConfig config, ILaunch launch) throws IOException {
    initializeDispatches();
    port = SocketUtil.findUnusedLocalPorts(1)[0];
    this.webServer = new WebServer(port);
    XmlRpcServer serverToHandleRawInput = this.webServer.getXmlRpcServer();
    serverToHandleRawInput.setHandlerMapping(new XmlRpcHandlerMapping() {

        @Override
        public XmlRpcHandler getHandler(String handlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException {
            return handler;
        }
    });

    this.webServer.start();

    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    launchManager.addLaunchListener(this.launchListener);
    this.launch = launch;
    this.configuration = config.getLaunchConfiguration();
}
 
Example #3
Source File: TLCModelFactory.java    From tlaplus with MIT License 6 votes vote down vote up
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++) {
			final ILaunchConfiguration launchConfiguration = launchConfigurations[i];
			if (aFile.equals(launchConfiguration.getFile())) {
				return launchConfiguration.getAdapter(Model.class);
			}
		}
	} catch (CoreException shouldNeverHappen) {
		shouldNeverHappen.printStackTrace();
	}
	
	return null;
}
 
Example #4
Source File: LaunchHandler.java    From corrosion with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Looks up an existing cargo test launch configuration with the arguments
 * specified in {@code command} for the given {@code project}. If no such launch
 * configuration exists, creates a new one. The launch configuration is then
 * run.
 *
 * @param command rls.run command with all information needed to run cargo test
 * @param project the context project for which the launch configuration is
 *                looked up / created
 */
private static void createAndStartCargoTest(RLSRunCommand command, IProject project) {
	CargoArgs args = CargoArgs.fromAllArguments(command.args);
	Map<String, String> envMap = command.env;

	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = manager
			.getLaunchConfigurationType(CargoTestDelegate.CARGO_TEST_LAUNCH_CONFIG_TYPE_ID);
	try {
		// check if launch config already exists
		ILaunchConfiguration[] launchConfigurations = manager.getLaunchConfigurations(type);

		Set<Entry<String, String>> envMapEntries = envMap.entrySet();
		// prefer running existing launch configuration with same parameters
		ILaunchConfiguration launchConfig = Arrays.stream(launchConfigurations)
				.filter((l) -> matchesTestLaunchConfig(l, project, args, envMapEntries)).findAny()
				.orElseGet(() -> createCargoLaunchConfig(manager, type, project, args, envMap));

		if (launchConfig != null) {
			DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
		}
	} catch (CoreException e) {
		CorrosionPlugin.logError(e);
	}
}
 
Example #5
Source File: LangLaunchConfigurationDelegate.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public final ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
	try {
		buildTargetSettings = getBuildTargetSettings(configuration);
		buildTarget = buildTargetSettings.getValidBuildTarget();
		processLauncher = getValidLaunchInfo(configuration, buildTargetSettings);
	} catch(CommonException ce) {
		throw EclipseCore.createCoreException(ce);
	}
	
	if(ILaunchManager.RUN_MODE.equals(mode)) {
		return getLaunchForRunMode(configuration, mode);
	}
	if(ILaunchManager.DEBUG_MODE.equals(mode)) {
		return getLaunchForDebugMode(configuration, mode);
	}
	throw abort_UnsupportedMode(mode);
}
 
Example #6
Source File: DataflowPipelineLaunchDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
  when(pipelineOptionsHierarchyFactory.forProject(
          eq(project), eq(MajorVersion.ONE), any(IProgressMonitor.class)))
      .thenReturn(pipelineOptionsHierarchy);

  credential = new GoogleCredential.Builder()
      .setJsonFactory(mock(JsonFactory.class))
      .setTransport(mock(HttpTransport.class))
      .setClientSecrets("clientId", "clientSecret").build();
  credential.setRefreshToken("fake-refresh-token");
  when(loginService.getCredential("[email protected]")).thenReturn(credential);

  when(dependencyManager.getProjectMajorVersion(project)).thenReturn(MajorVersion.ONE);
  dataflowDelegate = new DataflowPipelineLaunchDelegate(javaDelegate,
      pipelineOptionsHierarchyFactory, dependencyManager, workspaceRoot, loginService);

  pipelineArguments.put("accountEmail", "");
  when(configurationWorkingCopy.getAttribute(
      eq(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES), anyMapOf(String.class, String.class)))
      .thenReturn(environmentMap);
}
 
Example #7
Source File: CordovaCLI.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: ReportOSGiLaunchDelegate.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IVMRunner getVMRunner( ILaunchConfiguration configuration,
		String mode ) throws CoreException
{
	if ( ( helper.debugType & DEBUG_TYPE_JAVA_CLASS ) == DEBUG_TYPE_JAVA_CLASS )
	{
		mode = ILaunchManager.DEBUG_MODE;
	}
	else
	{
		mode = ILaunchManager.RUN_MODE;
	}

	return new ReportDebuggerVMRunner( super.getVMRunner( configuration,
			mode ),
			( helper.debugType & DEBUG_TYPE_JAVA_SCRIPT ) == DEBUG_TYPE_JAVA_SCRIPT,
			this );
}
 
Example #9
Source File: LocalAppEngineServerLaunchConfigurationDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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);

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

  Integer port = config.getPort();
  assertNotNull(port);
  assertEquals(9999, (int) port);
  verify(launchConfiguration)
      .getAttribute(eq(LocalAppEngineServerBehaviour.SERVER_PORT_ATTRIBUTE_NAME), anyInt());
  verify(server, never()).getAttribute(anyString(), anyInt());
}
 
Example #10
Source File: WebAppLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: PyUnitServer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Disposes of the pyunit server. When the launch is terminated or removed from the launch manager, it's
 * automatically disposed.
 */
public void dispose() {
    if (!disposed) {
        disposed = true;
        try {
            ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
            launchManager.removeLaunchListener(this.launchListener);
        } catch (Throwable e1) {
            Log.log(e1);
        }

        if (this.webServer != null) {
            try {
                this.webServer.shutdown();
            } catch (Throwable e) {
                //Ignore anything here
            }
            this.webServer = null;
        }

        for (IPyUnitServerListener listener : this.listeners) {
            listener.notifyDispose();
        }
        this.listeners.clear();
    }
}
 
Example #12
Source File: LaunchModes.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #13
Source File: Model.java    From tlaplus with MIT License 6 votes vote down vote up
public Model copyIntoForeignSpec(final Spec foreignSpec, final String newModelName) {
	final IProject foreignProject = foreignSpec.getProject();
	final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	final ILaunchConfigurationType launchConfigurationType
			= launchManager.getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);
	final String sanitizedNewName = sanitizeName(newModelName);
	final String wholeName = fullyQualifiedNameFromSpecNameAndModelName(foreignSpec.getName(), sanitizedNewName);
	
	try {
		final ILaunchConfigurationWorkingCopy copy = launchConfigurationType.newInstance(foreignProject, wholeName);
		copyAttributesFromForeignModelToWorkingCopy(this, copy);
        copy.setAttribute(IConfigurationConstants.SPEC_NAME, foreignSpec.getName());
           copy.setAttribute(IConfigurationConstants.MODEL_NAME, sanitizedNewName);
           return copy.doSave().getAdapter(Model.class);
	} catch (CoreException e) {
		TLCActivator.logError("Error cloning foreign model.", e);
		return null;
	}
}
 
Example #14
Source File: FatJarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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()]);
}
 
Example #15
Source File: LaunchConfigurationUtils.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <br> Finds Modula launch associated with the given project, if any (there should be only one)
 * @param project project to query
 * @return
 */
public static ILaunch getLaunch(IProject project) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunch[] launches = launchManager.getLaunches();
	for (ILaunch launch : launches) {
		try {
			IProject launchProject = getProject(launch.getLaunchConfiguration());
			if (launchProject == null){
				continue;
			}
			if (Objects.equal(launchProject, project)) {
				return launch;
			}
		} catch (CoreException e) {
		}
	}
	return null;
}
 
Example #16
Source File: LocalAppEngineServerLaunchConfigurationDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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);

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

  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());
}
 
Example #17
Source File: KubeUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Starts a separate port forward launch
 */
public static PortForwardInfo launchPortForward(CodewindApplication app, int localPort, int port) throws Exception {
	// Check the app (throws an exception if there is a problem)
	checkApp(app);

	// Get the command
	List<String> commandList = getPortForwardCommand(app, localPort, port);
	String title = NLS.bind(Messages.PortForwardTitle, localPort + ":" + port);

	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(UtilityLaunchConfigDelegate.LAUNCH_CONFIG_ID);
	ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance((IContainer) null, app.name);
	workingCopy.setAttribute(CodewindLaunchConfigDelegate.CONNECTION_ID_ATTR, app.connection.getConid());
	workingCopy.setAttribute(CodewindLaunchConfigDelegate.PROJECT_ID_ATTR, app.projectID);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.TITLE_ATTR, title);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.COMMAND_ATTR, commandList);
	CodewindLaunchConfigDelegate.setConfigAttributes(workingCopy, app);
	ILaunchConfiguration launchConfig = workingCopy.doSave();
	ILaunch launch = launchConfig.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
	return new PortForwardInfo(localPort, port, launch);
}
 
Example #18
Source File: GcpLocalRunTab.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static Map<String, String> getEnvironmentMap(ILaunchConfiguration configuration) {
  // Don't return an immutable map such as Collections.emptyMap().
  Map<String, String> emptyMap = new HashMap<>();
  try {
    return configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, emptyMap);
  } catch (CoreException e) {
    logger.log(Level.WARNING, "Can't get value from launch configuration.", e); //$NON-NLS-1$
    return emptyMap;
  }
}
 
Example #19
Source File: LaunchPipelineShortcut.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void launchNew(LaunchableResource resource, String mode) {
  try {
    ILaunchManager launchManager = getLaunchManager();

    String launchConfigurationName =
        launchManager.generateLaunchConfigurationName(resource.getLaunchName());
    ILaunchConfigurationType configurationType =
        getDataflowLaunchConfigurationType(launchManager);
    ILaunchConfigurationWorkingCopy configuration =
        configurationType.newInstance(null, launchConfigurationName);

    configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
        resource.getProjectName());
    IMethod mainMethod = resource.getMainMethod();
    if (mainMethod != null && mainMethod.exists()) {
      configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
          mainMethod.getDeclaringType().getFullyQualifiedName());
    }

    String groupIdentifier =
        mode.equals(ILaunchManager.RUN_MODE) ? IDebugUIConstants.ID_RUN_LAUNCH_GROUP
            : IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
    int returnStatus =
        DebugUITools.openLaunchConfigurationDialog(DataflowUiPlugin.getActiveWindowShell(),
            configuration, groupIdentifier, null);
    if (returnStatus == Window.OK) {
      configuration.doSave();
    }
  } catch (CoreException e) {
    // TODO: Handle
    DataflowUiPlugin.logError(e, "Error while launching new Launch Configuration for project %s",
        resource.getProjectName());
  }
}
 
Example #20
Source File: LaunchHelperTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvariantToModuleOrder() throws CoreException {
  appEngineStandardProject1.withAppEngineServiceId("default");
  IModule module1 = appEngineStandardProject1.getModule();
  appEngineStandardProject2.withAppEngineServiceId("other");
  IModule module2 = appEngineStandardProject2.getModule();

  handler.launch(new IModule[] {module1, module2}, ILaunchManager.DEBUG_MODE);
  assertEquals("new server should have been created", 1, tracker.getServers().size());

  // because we don't actually launch the servers, we won't get an ExecutionException
  handler.launch(new IModule[] {module2, module1}, ILaunchManager.DEBUG_MODE);
  assertEquals("no new servers should be created", 1, tracker.getServers().size());
}
 
Example #21
Source File: JUnitTestRunListener.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
public JUnitTestRunListener( ILaunchManager launchManager,
                             ResourceManager resourceManager,
                             ProgressUI progressUI )
{
  this.launchListener = new LaunchTerminatedListener();
  this.resourceManager = resourceManager;
  this.progressUI = progressUI;
  this.launchManager = launchManager;
  this.launchManager.addLaunchListener( launchListener );
}
 
Example #22
Source File: LaunchShortcutTest.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void launchShortcut__DartProjectNoLaunchConfig__NewLaunchConfigIsCreated() throws Exception {
	String projectName = RandomString.make(8);
	String mainClass = RandomString.make(4) + ".dart";
	ProjectUtil.createDartProject(projectName);

	ProjectExplorer projectExplorer = new ProjectExplorer();
	projectExplorer.open();
	projectExplorer.getProject(projectName).select();

	new ContextMenuItem(new WithMnemonicTextMatcher("Run As"), new RegexMatcher("\\d Run as Dart Program"))
			.select();

	new WaitUntil(new ShellIsActive("Edit Configuration"));
	new LabeledCombo("Project:").setSelection(projectName);
	new LabeledText("Main class:").setText(mainClass);
	new PushButton("Run").click();
	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

	// Find last launch configuration for selected project.
	ILaunchConfiguration launchConfiguration = null;
	for (ILaunchConfiguration conf : manager.getLaunchConfigurations()) {
		if (conf.getAttribute(Constants.LAUNCH_SELECTED_PROJECT, "").equalsIgnoreCase(projectName)) { //$NON-NLS-1$
			launchConfiguration = conf;
		}
	}

	assertNotNull(launchConfiguration);
	assertEquals(launchConfiguration.getAttribute("main_class", ""), mainClass);

	// Cleanup
	launchConfiguration.delete();
}
 
Example #23
Source File: BaseDebugView.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
    IViewSite viewSite = getViewSite();
    if (viewSite != null) {
        configureToolBar(viewSite);
    }

    parent.setLayout(new GridLayout(1, true));

    viewer = new TreeViewer(parent);
    provider = createContentProvider();
    viewer.setContentProvider(provider);
    viewer.setLabelProvider(new PyDebugModelPresentation(false));

    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTree());

    MenuManager menuManager = new MenuManager();
    Menu menu = menuManager.createContextMenu(viewer.getTree());
    viewer.getTree().setMenu(menu);
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(menuManager, viewer);
    site.setSelectionProvider(viewer);

    this.parent = parent;

    listener = createListener();
    if (listener != null) {
        DebugPlugin plugin = DebugPlugin.getDefault();

        ILaunchManager launchManager = plugin.getLaunchManager();
        launchManager.addLaunchListener(listener);

        plugin.addDebugEventListener(listener);
    }
}
 
Example #24
Source File: LocalAppEngineServerLaunchConfigurationDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testLaunch_noNullPointerExceptionWhenLaunchHasNoConfiguration() throws CoreException {
  ILaunch launch = mock(ILaunch.class);
  ILaunch[] launches = new ILaunch[] {launch};
  when(launch.getLaunchConfiguration()).thenReturn(null);

  new LocalAppEngineServerLaunchConfigurationDelegate().checkConflictingLaunches(null,
      ILaunchManager.RUN_MODE, mock(RunConfiguration.class), launches);
}
 
Example #25
Source File: TypeScriptCompilerLaunchHelper.java    From typescript.java with MIT License 5 votes vote down vote up
private static ILaunchConfigurationWorkingCopy createEmptyLaunchConfiguration(String namePrefix)
		throws CoreException {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager
			.getLaunchConfigurationType(TypeScriptCompilerLaunchConstants.LAUNCH_CONFIGURATION_ID);
	ILaunchConfigurationWorkingCopy launchConfiguration = launchConfigurationType.newInstance(null,
			launchManager.generateLaunchConfigurationName(namePrefix));
	return launchConfiguration;
}
 
Example #26
Source File: LaunchModeDropDownActionTest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() {
  launchManager = mock( ILaunchManager.class );
  when( launchManager.getLaunchModes() ).thenReturn( new ILaunchMode[ 0 ] );
  DialogSettings dialogSettings = new DialogSettings( "section-name" );
  launchModeSetting = new LaunchModeSetting( launchManager, dialogSettings );
}
 
Example #27
Source File: BuildUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Runs a ant build for project according to specified configuration
 * 
 * @param monitor
 *            progress monitor
 * @param cfg
 *            build configuration name
 * @param project
 *            project to be build (for platform project will build whole
 *            platform)
 */
public static void refreshAndBuild(IProgressMonitor monitor, String cfg, IProject project)
		throws InvocationTargetException {
	boolean isAutoBuildEnabled = isAutoBuildEnabled();
	enableAutoBuild(false);
	String projectLocation = project.getLocation().toString() + File.separator + "build.xml";
	String projectName = project.getName();
	if (!projectName.equals(PLATFORM_NAME)) {
		cfg = cfg + "_" + projectName;
	}
	try {

		ILaunchConfiguration launchCfg = getLaunchConfig(cfg);
		if (launchCfg == null) {
			if (cfg.contains(PLATFORM_BUILD_CONFIG)) {
				launchCfg = createAntBuildConfig(cfg, "all", projectLocation, projectName);
			} else if (cfg.contains(PLATFORM_CLEAN_BUILD_CONFIG)) {
				launchCfg = createAntBuildConfig(cfg, "clean,all", projectLocation, project.getName());
			}
		}
		
		if (launchCfg != null ) {
			launchCfg.launch(ILaunchManager.RUN_MODE, monitor);
		}

		if (cfg.equals(PLATFORM_CLEAN_BUILD_CONFIG)) {
			refreshWorkspaceAndBuild(monitor);
		} else if (!cfg.equals(PLATFORM_CLEAN_BUILD_CONFIG) && !cfg.equals(PLATFORM_BUILD_CONFIG)) { // NOSONAR
			refreshPlatformAndCurrentProject(project);
		}

	} catch (CoreException e) {
		throw new InvocationTargetException(e);
	}

	if (isAutoBuildEnabled) {
		enableAutoBuild(true);
	}
}
 
Example #28
Source File: LaunchShortcut.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
private void launchProject(IProject project, String mode) {
	if (project == null) {
		MessageDialog.openError(PlatformUIUtil.getActiveShell(), Messages.Launch_ConfigurationRequired_Title,
				Messages.Launch_ConfigurationRequired_Body);
		return;
	}

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

	ILaunchConfigurationType type = manager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_ID);

	try {
		// Find last launch configuration for selected project.
		ILaunchConfiguration launchConfiguration = null;
		for (ILaunchConfiguration conf : manager.getLaunchConfigurations(type)) {
			if (conf.getAttribute(Constants.LAUNCH_SELECTED_PROJECT, "").equalsIgnoreCase(project.getName())) { //$NON-NLS-1$
				launchConfiguration = conf;
			}
		}

		if (launchConfiguration != null) {
			DebugUITools.launch(launchConfiguration, mode);
		} else {
			ILaunchConfigurationWorkingCopy copy = type.newInstance(null, manager.generateLaunchConfigurationName(
					LaunchConfigurationsMessages.CreateLaunchConfigurationAction_New_configuration_2));

			copy.setAttribute(Constants.LAUNCH_SELECTED_PROJECT, project.getName());
			copy.setAttribute(Constants.LAUNCH_MAIN_CLASS, project.getPersistentProperty(StagehandGenerator.QN_ENTRYPOINT));

			int result = DebugUITools.openLaunchConfigurationDialog(PlatformUIUtil.getActiveShell(), copy,
					Constants.LAUNCH_GROUP, null);

			if (result == Window.OK) {
				copy.doSave();
			}
		}
	} catch (CoreException e) {
		LOG.log(DartLog.createError("Could not save new launch configuration", e)); //$NON-NLS-1$
	}
}
 
Example #29
Source File: WebAppLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Finds and returns an <b>existing</b> configuration to re-launch for the given URL, or <code>null</code> if there is
 * no existing configuration.
 *
 * @return a configuration to use for launching the given type or <code>null
 *         </code> if none
 * @throws CoreException
 */
protected ILaunchConfiguration findLaunchConfiguration(IResource resource, String startupUrl, boolean isExternal)
    throws CoreException {

  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType typeid = launchManager.getLaunchConfigurationType(WebAppLaunchConfiguration.TYPE_ID);
  ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(typeid);

  return searchMatchingUrlAndProject(startupUrl, resource.getProject(), isExternal, configs);
}
 
Example #30
Source File: LaunchHelperTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test(expected = CoreException.class)
public void failsWithClashingServiceIds() throws CoreException {
  appEngineStandardProject1.withAppEngineServiceId("other");
  IModule module1 = appEngineStandardProject1.getModule();
  appEngineStandardProject2.withAppEngineServiceId("other");
  IModule module2 = appEngineStandardProject2.getModule();

  handler.launch(new IModule[] {module1, module2}, ILaunchManager.DEBUG_MODE);
}