org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants Java Examples

The following examples show how to use org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants. 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: AbstractSarlLaunchShortcut.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Collect the listing of {@link ILaunchConfiguration}s that apply to the given element.
 *
 * @param projectName the name of the project.
 * @param fullyQualifiedName the element.
 * @return the list of {@link ILaunchConfiguration}s or an empty list, never {@code null}
 * @throws CoreException if something is going wrong.
 */
protected List<ILaunchConfiguration> getCandidates(String projectName,
		String fullyQualifiedName) throws CoreException {
	final ILaunchConfigurationType ctype = getLaunchManager().getLaunchConfigurationType(getConfigurationType());
	List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
	final ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(ctype);
	candidateConfigs = new ArrayList<>(configs.length);
	for (int i = 0; i < configs.length; i++) {
		final ILaunchConfiguration config = configs[i];
		if (Objects.equals(
				getElementQualifiedName(config),
				fullyQualifiedName)
				&& Objects.equals(
						config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""), //$NON-NLS-1$
						projectName)) {
			candidateConfigs.add(config);
		}
	}
	return candidateConfigs;
}
 
Example #2
Source File: CompilerLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: BOSWebServerManager.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createLaunchConfiguration(final IServer server, final IProgressMonitor monitor)
        throws CoreException {
    ILaunchConfiguration conf = server.getLaunchConfiguration(false, Repository.NULL_PROGRESS_MONITOR);
    if (conf == null) {
        conf = server.getLaunchConfiguration(true,
                Repository.NULL_PROGRESS_MONITOR);
    }
    ILaunchConfigurationWorkingCopy workingCopy = conf.getWorkingCopy();
    final String args = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
    if (!args.contains(tomcatInstanceLocation)) {
        conf = server.getLaunchConfiguration(true,
                Repository.NULL_PROGRESS_MONITOR);
        workingCopy = conf.getWorkingCopy();
    }
    configureLaunchConfiguration(workingCopy);
}
 
Example #4
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 #5
Source File: FlexMavenPackagedProjectStagingDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #6
Source File: FatJarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static Object[] getSelectedElementsWithoutContainedChildren(ILaunchConfiguration launchconfig, JarPackageData data, IRunnableContext context, MultiStatus status) throws CoreException {
	if (launchconfig == null)
		return new Object[0];

	String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$

	IPath[] classpath= getClasspath(launchconfig);
	IPackageFragmentRoot[] classpathResources= getRequiredPackageFragmentRoots(classpath, projectName, status);

	String mainClass= getMainClass(launchconfig, status);
	IType mainType= findMainMethodByName(mainClass, classpathResources, context);
	if (mainType == null) {
		status.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_error_noMainMethod));
	}
	data.setManifestMainClass(mainType);

	return classpathResources;
}
 
Example #7
Source File: StandardScriptVMRunner.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks and forwards an error from the specified process
 * 
 * @param process
 * @throws CoreException
 */
private void checkErrorMessage( IProcess process ) throws CoreException
{
	IStreamsProxy streamsProxy = process.getStreamsProxy( );
	if ( streamsProxy != null )
	{
		String errorMessage = streamsProxy.getErrorStreamMonitor( )
				.getContents( );
		if ( errorMessage.length( ) == 0 )
		{
			errorMessage = streamsProxy.getOutputStreamMonitor( )
					.getContents( );
		}
		if ( errorMessage.length( ) != 0 )
		{
			abort( errorMessage,
					null,
					IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR );
		}
	}
}
 
Example #8
Source File: SARLRuntimeEnvironmentTab.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("synthetic-access")
public IProject getProject() {
	ILaunchConfiguration config = getLaunchConfigurationWorkingCopy();
	if (config == null) {
		config = getLaunchConfiguration();
	}
	if (config != null) {
		try {
			final String name = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
			if (name != null && name.length() > 0) {
				final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
				if (project.exists()) {
					return project;
				}
			}
		} catch (CoreException e) {
			SARLEclipsePlugin.getDefault().log(e);
		}
	}
	return null;
}
 
Example #9
Source File: LaunchConfigurationUpdater.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the launch configuration by delegating to each
 * {@link ILaunchConfigurationProcessor}.
 * <p>
 * This method saves the launch configuration's working copy.
 *
 * @throws CoreException
 */
public void update() throws CoreException {
  ILaunchConfigurationWorkingCopy launchConfigWc = launchConfig.getWorkingCopy();

  for (ILaunchConfigurationProcessor processor : PROCESSORS) {
    try {
      processor.update(launchConfigWc, javaProject, programArgs, vmArgs);
    } catch (Throwable e) {
      GdtPlugin.getLogger().logError(e, "Launch configuration processor failed to run");
    }
  }

  launchConfigWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
      LaunchConfigurationProcessorUtilities.createArgsString(programArgs));
  launchConfigWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
      LaunchConfigurationProcessorUtilities.createArgsString(vmArgs));

  launchConfigWc.doSave();
}
 
Example #10
Source File: LocalAppEngineServerLaunchConfigurationDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testGenerateRunConfiguration_withProgramArgs() throws CoreException {
  // DebugPlugin.parseArguments() only supports double-quotes on Windows
  when(launchConfiguration
      .getAttribute(eq(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS), anyString()))
          .thenReturn("e f \"g h\"");

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

  assertNotNull(config.getAdditionalArguments());
  assertEquals(Arrays.asList("e", "f", "g h"), config.getAdditionalArguments());
  verify(launchConfiguration)
      .getAttribute(eq(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS), anyString());
}
 
Example #11
Source File: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #12
Source File: LaunchConfigurationProcessorUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Uses the processor to update the given configuration.
 */
public static void updateViaProcessor(
    ILaunchConfigurationProcessor processor,
    ILaunchConfigurationWorkingCopy configuration) {
  IJavaProject javaProject = LaunchConfigurationUtilities.getJavaProject(configuration);
  if (javaProject != null && javaProject.exists()) {
    try {
      List<String> programArgs = parseProgramArgs(configuration);
      List<String> vmArgs = parseVmArgs(configuration);
      processor.update(configuration, javaProject, programArgs, vmArgs);
      configuration.setAttribute(
          IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
          LaunchConfigurationProcessorUtilities.createArgsString(programArgs));
      configuration.setAttribute(
          IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
          LaunchConfigurationProcessorUtilities.createArgsString(vmArgs));
    } catch (Throwable e) {
      CorePluginLog.logError(e, "Could not update the launch configuration");
    }
  }
}
 
Example #13
Source File: DataflowPipelineLaunchDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private ILaunchConfiguration mockILaunchConfiguration() throws CoreException {
  ILaunchConfiguration configuration = mock(ILaunchConfiguration.class);
  String configurationName = "testConfiguration";
  when(configuration.getName()).thenReturn(configurationName);

  PipelineRunner runner = PipelineRunner.BLOCKING_DATAFLOW_PIPELINE_RUNNER;
  when(configuration.getAttribute(eq(PipelineConfigurationAttr.RUNNER_ARGUMENT.toString()),
      anyString())).thenReturn(runner.getRunnerName());

  String projectName = "Test-project,Name";
  when(configuration.getAttribute(eq(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME),
      anyString())).thenReturn(projectName);
  when(workspaceRoot.getProject(projectName)).thenReturn(project);
  when(project.exists()).thenReturn(true);

  return configuration;
}
 
Example #14
Source File: FixedFatJarExportPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
protected LaunchConfigurationElement[] getLaunchConfigurations() {
	ArrayList<ExistingLaunchConfigurationElement> result= new ArrayList<>();

	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: FixedFatJarExportPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
public Object[] getSelectedElementsWithoutContainedChildren(ILaunchConfiguration launchconfig, JarPackageData data, IRunnableContext context, MultiStatus status) throws CoreException {
	if (launchconfig == null)
		return new Object[0];

	String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$

	IPath[] classpath= getClasspath(launchconfig);
	IPackageFragmentRoot[] classpathResources= getRequiredPackageFragmentRoots(classpath, projectName, status);

	String mainClass= getMainClass(launchconfig, status);
	IType mainType= findMainMethodByName(mainClass, classpathResources, context);
	if (mainType == null) {
		status.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_error_noMainMethod));
	}
	data.setManifestMainClass(mainType);

	return classpathResources;
}
 
Example #16
Source File: LaunchShortcut.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException
{
    final List<String> args = new LinkedList<> ();

    args.addAll ( profile.getJvmArguments () );

    for ( final SystemProperty p : profile.getProperty () )
    {
        addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () );
    }

    for ( final Map.Entry<String, String> entry : getInitialProperties ().entrySet () )
    {
        addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false );
    }

    final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$
    if ( dataJson.exists () )
    {
        addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$
    }

    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) );
    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) );
}
 
Example #17
Source File: FatJarAntExporter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String getMainClass(ILaunchConfiguration launchConfig, MultiStatus status) {
	String result= null;
	if (launchConfig != null) {
		try {
			result= launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null);
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
	}
	if (result == null) {
		status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_LaunchConfigurationWithoutMainType_warning));
		result= ""; //$NON-NLS-1$
	}
	return result;
}
 
Example #18
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public String getAgentLaunchingArguments(ILaunchConfiguration configuration) {
	try {
		return Strings.nullToEmpty(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
				(String) null));
	} catch (CoreException e) {
		return null;
	}
}
 
Example #19
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public String getJRELaunchingArguments(ILaunchConfiguration configuration) {
	try {
		return Strings.nullToEmpty(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null));
	} catch (CoreException e) {
		return null;
	}
}
 
Example #20
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public String getProjectName(ILaunchConfiguration configuration) {
	try {
		return Strings.emptyToNull(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null));
	} catch (CoreException e) {
		return null;
	}
}
 
Example #21
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public String getMain(ILaunchConfiguration configuration) {
	try {
		return Strings.emptyToNull(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null));
	} catch (CoreException e) {
		return null;
	}
}
 
Example #22
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void setRuntimeConfiguration(ILaunchConfigurationWorkingCopy configuration, ISREInstall sre,
		Boolean useSystemSre, Boolean useProjectSre, boolean resetJavaMainClass) {
	boolean system = useSystemSre == null ? DEFAULT_USE_SYSTEM_SRE : useSystemSre.booleanValue();
	boolean project = useProjectSre == null ? DEFAULT_USE_PROJECT_SRE : useProjectSre.booleanValue();
	if (system && project) {
		system = true;
		project = false;
	}
	// Save the SRE specific parameters
	if (sre != null) {
		configuration.setAttribute(
				ATTR_SARL_RUNTIME_ENVIRONMENT,
				sre.getId());
		final String mainClass = sre.getMainClass();
		if (resetJavaMainClass) {
			if (Strings.isNullOrEmpty(mainClass)) {
				configuration.removeAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME);
			} else {
				setMainJavaClass(configuration, mainClass);
			}
		}
	} else {
		configuration.removeAttribute(ATTR_SARL_RUNTIME_ENVIRONMENT);
		if (resetJavaMainClass) {
			configuration.removeAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME);
		}
	}
	// Save the boolean configuration flags
	configuration.setAttribute(ATTR_USE_SYSTEM_SARL_RUNTIME_ENVIRONMENT, system);
	configuration.setAttribute(ATTR_USE_PROJECT_SARL_RUNTIME_ENVIRONMENT, project);
	// Use the default JRE
	configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
}
 
Example #23
Source File: FatJarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String getMainClass(ILaunchConfiguration launchConfig, MultiStatus status) {
	String result= null;
	if (launchConfig != null) {
		try {
			result= launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null);
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
	}
	if (result == null) {
		status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_LaunchConfigurationWithoutMainType_warning));
		result= ""; //$NON-NLS-1$
	}
	return result;
}
 
Example #24
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public ILaunchConfiguration newApplicationLaunchConfiguration(String projectName, String launchConfigurationName,
		String fullyQualifiedNameOfClass, Class<? extends IRuntimeClasspathProvider> classPathProvider) throws CoreException {
	final String name = Strings.isNullOrEmpty(launchConfigurationName)
			? simpleName(fullyQualifiedNameOfClass) : launchConfigurationName;
	final ILaunchConfigurationWorkingCopy wc = initLaunchConfiguration(getApplicationLaunchConfigurationType(), projectName,
			name, false);
	setMainJavaClass(wc, fullyQualifiedNameOfClass);
	if (classPathProvider != null) {
		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, classPathProvider.getName());
	}
	return wc.doSave();
}
 
Example #25
Source File: WebAppLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void setDefaults(ILaunchConfigurationWorkingCopy configuration, IProject project) {
  // Set the default main type so it shows up when the launcher is created.
  configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, ModuleClasspathProvider.computeProviderId(project));

  // Set the default server port
  LaunchConfigurationProcessorUtilities.updateViaProcessor(new PortArgumentProcessor(), configuration);
}
 
Example #26
Source File: WebAppLaunchDelegate.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return Returns {@code}false if unsuccessful in adding the VM arguments and the launch should be cancelled.
 */
@Deprecated
private boolean addVmArgs(ILaunchConfiguration configuration) throws CoreException {
  IProject project = getJavaProject(configuration).getProject();

  ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
  String vmArgs = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");

  return true;
}
 
Example #27
Source File: FixedFatJarExportPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static String getMainClass(ILaunchConfiguration launchConfig, MultiStatus status) {
	String result= null;
	if (launchConfig != null) {
		try {
			result= launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null);
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
	}
	if (result == null) {
		status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_LaunchConfigurationWithoutMainType_warning));
		result= ""; //$NON-NLS-1$
	}
	return result;
}
 
Example #28
Source File: ClasspathProviderProcessor.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public void update(ILaunchConfigurationWorkingCopy launchConfig,
    IJavaProject javaProject, List<String> programArgs, List<String> vmArgs)
    throws CoreException {

  launchConfig.setAttribute(
      IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
      ModuleClasspathProvider.computeProviderId(javaProject.getProject()));
}
 
Example #29
Source File: GwtSuperDevModeCodeServerLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creating a new launch config, setup the default arguments.<br/>
 * <br/>
 * If the project doesn't have focus, the updateViaProcessors will not run.
 */
public static void setDefaults(ILaunchConfigurationWorkingCopy launchConfig, IProject project) {
  launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, ModuleClasspathProvider.computeProviderId(project));

  // Turn on Super Dev Mode
  GWTLaunchConfigurationWorkingCopy.setSuperDevModeEnabled(launchConfig, true);

  // Update program arg for - main type
  LaunchConfigurationProcessorUtilities.updateViaProcessor(new SuperDevModeCodeServerMainTypeProcessor(), launchConfig);

  // Update program arg for - GWT module
  LaunchConfigurationProcessorUtilities.updateViaProcessor(new ModuleArgumentProcessor(), launchConfig);
}
 
Example #30
Source File: GWTJUnitLaunchUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void setDefaults(ILaunchConfigurationWorkingCopy wc) {

    try {
      wc.setAttribute(
          IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
          JavaRuntime.getJavaProject(wc) == null
              ? null
              : ModuleClasspathProvider.computeProviderId(JavaRuntime.getJavaProject(
                  wc).getProject()));
    } catch (CoreException ce) {
      GWTPluginLog.logError(ce);
    }

    wc.setAttribute(GWTLaunchConstants.ATTR_LOG_LEVEL,
        GWTLaunchConstants.Defaults.LOG_LEVEL);

    wc.setAttribute(GWTLaunchConstants.ATTR_OBFUSCATION,
        GWTLaunchConstants.Defaults.OBFUSCATION);

    wc.setAttribute(GWTLaunchConstants.ATTR_WEB_MODE,
        GWTLaunchConstants.Defaults.WEB_MODE);

    wc.setAttribute(GWTLaunchConstants.ATTR_NOT_HEADLESS,
        GWTLaunchConstants.Defaults.NOT_HEADLESS);

    // Override the default output directory for web mode tests
    wc.setAttribute(GWTLaunchConstants.ATTR_OUT_DIR,
        GWTLaunchConstants.Defaults.OUT_DIR_TEST);
  }