Java Code Examples for org.eclipse.debug.core.ILaunchConfiguration#getAttributes()

The following examples show how to use org.eclipse.debug.core.ILaunchConfiguration#getAttributes() . 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: TestConfigurationConverter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Converts an {@link ILaunchConfiguration} to a {@link TestConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see TestConfiguration#writePersistentValues(Map)
 */
public TestConfiguration toTestConfiguration(ILaunchConfiguration launchConfig) {
	try {
		final Map<String, Object> properties = launchConfig.getAttributes();
		// special treatment of name required:
		// name is already included in 'properties', but we have to make sure that the name is up-to-date
		// in case the name of the launch configuration has been changed after the launch configuration
		// was created via method #toLaunchConfiguration()
		properties.put(RunConfiguration.NAME, launchConfig.getName());
		TestConfiguration testConfig = testerFrontEnd.createConfiguration(properties);
		testConfig.setLaunchConfigurationTypeIdentifier(launchConfig.getType().getIdentifier());
		return testConfig;
	} catch (Exception e) {
		throw new WrappedException("could not convert Eclipse ILaunchConfiguration to N4JS TestConfiguration", e);
	}
}
 
Example 2
Source File: RunConfigurationConverter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Converts an {@link ILaunchConfiguration} to a {@link RunConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see RunConfiguration#writePersistentValues(Map)
 */
public RunConfiguration toRunConfiguration(ILaunchConfiguration launchConfig) throws CoreException {
	try {
		final Map<String, Object> properties = launchConfig.getAttributes();
		// special treatment of name required:
		// name is already included in 'properties', but we have to make sure that the name is up-to-date
		// in case the name of the launch configuration has been changed after the launch configuration
		// was created via method #toLaunchConfiguration()
		properties.put(RunConfiguration.NAME, launchConfig.getName());
		return runnerFrontEnd.createConfiguration(properties);
	} catch (Exception e) {
		String msg = "Error occurred while trying to launch module.";
		if (null != e.getMessage()) {
			msg += "\nReason: " + e.getMessage();
		}
		throw new CoreException(new Status(ERROR, PLUGIN_ID, msg, e));
	}
}
 
Example 3
Source File: Model.java    From tlaplus with MIT License 5 votes vote down vote up
private void copyAttributesFromForeignModelToWorkingCopy(final Model foreignModel,
		final ILaunchConfigurationWorkingCopy copy) throws CoreException {
	final ILaunchConfiguration foreignILC = foreignModel.getLaunchConfiguration();
	final Map<String, Object> workingCopyAttributes = copy.getAttributes();
	final Map<String, Object> foreignAttributes = foreignILC.getAttributes();

	for (final Map.Entry<String, Object> me : foreignAttributes.entrySet()) {
		copy.setAttribute(me.getKey(), me.getValue());
		workingCopyAttributes.remove(me.getKey());
	}
	
	for (final String key : workingCopyAttributes.keySet()) {
		copy.removeAttribute(key);
	}
}
 
Example 4
Source File: ViewerManager.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Closes the target output document using the DDE command from the
    * default viewer, or the most recently launched preview. This method
    * is probably fragile since the process and launches handling in
    * Texlipse is too weak to always know what documents are locked and
    * needs closing.  
    * 
    * @throws CoreException
    */
   public static void closeOutputDocument() throws CoreException {
	
       ViewerAttributeRegistry registry = new ViewerAttributeRegistry();
	
   	// Check to see if we have a running launch configuration which should
       // override the DDE close command
 	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    
    for (int i = 0; i < launches.length; i++) {
    	ILaunch l = launches[i];
    	ILaunchConfiguration configuration = l.getLaunchConfiguration();
    	if (configuration != null && configuration.exists() && configuration.getType().getIdentifier().equals(
    			TexLaunchConfigurationDelegate.CONFIGURATION_ID)) {
    		Map regMap = configuration.getAttributes();
	        registry.setValues(regMap);
	        break;
    	}
	}
    
   	ViewerManager mgr = new ViewerManager(registry, null);    	
	
	 if (!mgr.initialize()) {
         return;
     }
	
	// Can only close documents opened by DDE commands themselves
	Process process = mgr.getExisting();        
	if (process != null) {       
		mgr.sendDDECloseCommand();
           
		try {
               Thread.sleep(500); // A small delay required
           } catch (InterruptedException e) {
               // swallow
           }

           returnFocusToEclipse(false);
	}
}