/** * (non-Javadoc) * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) **/ @Override public boolean isValid(ILaunchConfiguration launchConfig) { setErrorMessage(null); setMessage(null); // TODO fix LaunchConfigurationMainTab validation // String text = fileText.getText(); // if (text.length() > 0) { // IPath path = new Path(text); // if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == // null) { // setErrorMessage("Specified file does not exist"); // return false; // } // } else { // setMessage("Specify an file"); // } return true; }
/** * Creates an {@link ILaunchConfiguration} containing the information of this instance, only available when run * within the Eclipse IDE. If an {@link ILaunchConfiguration} with the same name has been run before, the instance * from the launch manager is used. This is usually done in the {@code ILaunchShortcut}. * * @see #fromLaunchConfiguration(ILaunchConfiguration) */ public ILaunchConfiguration toLaunchConfiguration() throws CoreException { ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configurationType); boolean configurationHasChanged = false; for (ILaunchConfiguration config : configs) { if (configName.equals(config.getName())) { configurationHasChanged = hasConfigurationChanged(config); if (!configurationHasChanged) { return config; } } } IContainer container = null; ILaunchConfigurationWorkingCopy workingCopy = configurationType.newInstance(container, configName); workingCopy.setAttribute(XT_FILE_TO_RUN, xtFileToRun); workingCopy.setAttribute(WORKING_DIRECTORY, workingDirectory.getAbsolutePath()); return workingCopy.doSave(); }
/** * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in * case of error. * * @see TestConfiguration#readPersistentValues() */ public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) { try { final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (equals(testConfig, config)) return config; } final IContainer container = null; final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName()); workingCopy.setAttributes(testConfig.readPersistentValues()); return workingCopy.doSave(); } catch (Exception e) { throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e); } }
/** * 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)); } }
/** * Converts a {@link RunConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in * case of error. * * @see RunConfiguration#readPersistentValues() */ public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, RunConfiguration runConfig) { try { final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (equals(runConfig, config)) return config; } final IContainer container = null; final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, runConfig.getName()); workingCopy.setAttributes(runConfig.readPersistentValues()); return workingCopy.doSave(); } catch (Exception e) { throw new WrappedException("could not convert N4JS RunConfiguration to Eclipse ILaunchConfiguration", e); } }
private boolean checkFileToRunSupportedByRunner(ILaunchConfiguration launchConfig, IResource resource, @SuppressWarnings("unused") URI resourceUri) { // note: we know the resource is an IFile because FILE is the only type returned by #getAcceptedResourceTypes() final IFile fileToRun = (IFile) resource; final String runnerId = RunnerUiUtils.getRunnerId(launchConfig, false); if (runnerId == null) { setErrorMessage("cannot read runner ID from launch configuration"); return false; } final Object[] args = new Object[] { runnerId }; // FIXME IDE-1393 once RunnerFrontEnd#canRun() has property tester logic, call it here boolean isSupported = supportTester.test( fileToRun, SupportingRunnerPropertyTester.PROPERTY_IS_SUPPORTING_RUNNER, args, ""); if (!isSupported) { setErrorMessage("runner cannot handle provided file to run"); return false; } return true; }
/** * Read the N4JS runner ID from the given Eclipse launch configuration. Will throw exceptions if 'failFast' is * <code>true</code>, otherwise will return <code>null</code> in case of error. */ public static String getRunnerId(ILaunchConfiguration launchConfig, boolean failFast) { try { // 1) simple case: runnerId already defined in launchConfig final String id = launchConfig.getAttribute(RunConfiguration.RUNNER_ID, (String) null); if (id != null) return id; // 2) tricky case: not set yet, so have to go via the ILaunchConfigurationType or the launchConfig final ILaunchConfigurationType launchConfigType = launchConfig.getType(); return getRunnerId(launchConfigType, failFast); } catch (CoreException e) { if (failFast) throw new WrappedException(e); return null; } }
/** * Gets the first {@link EObject instruction}. * * @param configuration * the {@link ILaunchConfiguration} * @return the first {@link EObject instruction} */ protected EObject getFirstInstruction(ILaunchConfiguration configuration) { EObject res = null; final ResourceSet rs = getResourceSet(); try { rs.getResource(URI.createPlatformResourceURI(configuration.getAttribute(RESOURCE_URI, ""), true), true); res = rs.getEObject(URI.createURI(configuration.getAttribute(FIRST_INSTRUCTION_URI, ""), true), true); } catch (CoreException e) { Activator.getDefault().error(e); } return res; }
/** * {@inheritDoc} * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ public void initializeFrom(final ILaunchConfiguration configuration) { super.initializeFrom(configuration); disableUpdate = true; siriusResourceURIText.setText(""); try { siriusResourceURIText.setText(configuration.getAttribute( AbstractDSLLaunchConfigurationDelegate.RESOURCE_URI, "")); } catch (CoreException e) { Activator.getDefault().error(e); } disableUpdate = false; }
/** * {@inheritDoc} * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ public void initializeFrom(final ILaunchConfiguration configuration) { disableUpdate = true; resourceURIText.setText(""); firstInstructionURIText.setText(""); try { resourceURIText.setText(configuration.getAttribute( AbstractDSLLaunchConfigurationDelegate.RESOURCE_URI, "")); firstInstructionURIText.setText(configuration.getAttribute( AbstractDSLLaunchConfigurationDelegate.FIRST_INSTRUCTION_URI, "")); } catch (CoreException e) { Activator.getDefault().error(e); } disableUpdate = false; }
@Override public void initializeFrom(ILaunchConfiguration config) { try { mpg.initialize(getModels(config)); fProjText.setText(config.getAttribute(CONFIG_PROJECT, "")); fModelText.setText(getMainModel(config)); fOmitEmptyEdgeElementsButton.setSelection(Boolean.parseBoolean(config.getAttribute(GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_OMIT_EMPTY_EDGE_DESCRIPTION, "false"))); fStartNodeText.setText(config.getAttribute(CONFIG_LAUNCH_STARTNODE, "")); fRemoveBlockedElementsButton.setSelection( new Boolean(config.getAttribute(CONFIG_LAUNCH_REMOVE_BLOCKED_ELEMENT_CONFIGURATION, "true"))); BuildPolicy bp = getMainPathGenerators(config); if (bp!=null) { comboViewer.setSelection(new StructuredSelection (bp), true); } } catch (CoreException e) { ResourceManager.logException(e); } }
private ModelData[] getModels(ILaunchConfiguration config) throws CoreException { List<ModelData> temp = new ArrayList<ModelData>(); String paths = config.getAttribute(CONFIG_GRAPH_MODEL_PATHS, ""); if (paths == null || paths.trim().length() == 0) return new ModelData[0]; StringTokenizer st = new StringTokenizer(paths, ";"); st.nextToken(); // the main model path st.nextToken(); // main model : Always "1" st.nextToken(); // the main path generator while (st.hasMoreTokens()) { String path = st.nextToken(); IFile file = (IFile) ResourceManager .getResource(new Path(path).toString()); if (file==null) continue; ModelData data = new ModelData(file); boolean selected = st.nextToken().equalsIgnoreCase("1"); String pathGenerator = st.nextToken(); data.setSelected(selected); data.setSelectedPolicy(pathGenerator); temp.add(data); } ModelData[] ret = new ModelData[temp.size()]; temp.toArray(ret); return ret; }
private ModelData[] getModels(ILaunchConfiguration config) throws CoreException { List<ModelData> temp = new ArrayList<ModelData>(); String paths = config.getAttribute(CONFIG_GRAPH_MODEL_PATHS, ""); if (paths == null || paths.trim().length() == 0) return new ModelData[0]; StringTokenizer st = new StringTokenizer(paths, ";"); st.nextToken(); // the main model path st.nextToken(); // main model : Always "1" st.nextToken(); // the main path generator while (st.hasMoreTokens()) { String path = st.nextToken(); IFile file = (IFile) ResourceManager .getResource(new Path(path).toString()); if (file==null) continue; ModelData data = new ModelData(file); boolean selected = st.nextToken().equalsIgnoreCase("1"); String pathGenerator = st.nextToken(); data.setSelected(selected); data.setSelectedPolicy(pathGenerator); if (selected) temp.add(data); } ModelData[] ret = new ModelData[temp.size()]; temp.toArray(ret); return ret; }
@Override public void initializeFrom(ILaunchConfiguration config) { try { mpg.initialize(getModels(config)); fProjText.setText(config.getAttribute(CONFIG_PROJECT, "")); fModelText.setText(getMainModel(config)); fPrintUnvisitedButton .setSelection(Boolean.parseBoolean(config.getAttribute(CONFIG_UNVISITED_ELEMENT, "false"))); fVerbosedButton.setSelection(Boolean.parseBoolean(config.getAttribute(CONFIG_VERBOSE, "false"))); fStartNodeText.setText(config.getAttribute(CONFIG_LAUNCH_STARTNODE, "")); fRemoveBlockedElementsButton.setSelection( new Boolean(config.getAttribute(CONFIG_LAUNCH_REMOVE_BLOCKED_ELEMENT_CONFIGURATION, "true"))); BuildPolicy bp = getMainPathGenerators(config); if (bp!=null) { comboViewer.setSelection(new StructuredSelection (bp), true); } } catch (CoreException e) { ResourceManager.logException(e); } }
public static void cleanWorkspace() throws CoreException { IProject[] projects = getRoot().getProjects(); deleteProjects(projects); IProject[] otherProjects = getRoot().getProjects(IContainer.INCLUDE_HIDDEN); deleteProjects(otherProjects); ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(GW4ELaunchShortcut.GW4ELAUNCHCONFIGURATIONTYPE); ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configType); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; config.delete(); } }
private ILaunchConfiguration findConfig() { if (cachedGenerated != null) { return cachedGenerated; } try { for (ILaunchConfiguration config : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(getType())) { if (config.getName().equals(generator.fullName(cfg))) { cachedGenerated = config; break; } } } catch (CoreException e) { LcDslInternalHelper.log(IStatus.WARNING, "cannot lookup launch configuration", e); } return cachedGenerated; }
private void launch(LaunchConfig config, String mode, boolean build, boolean wait, File log, boolean removeAfterLaunch) { ILaunchConfiguration c = generate(config); if (c == null) { throw new RuntimeException("Cannot generate " + config.getName()); } try { try { if (StandaloneLaunchConfigExecutor.launchProcess(c, mode, build, wait, log) != 0) { throw new RuntimeException("Failed to run " + config.getName()); } } finally { if (removeAfterLaunch) { c.delete(); } } } catch (CoreException e) { throw new RuntimeException("Internal error when running " + config.getName(), e); } }
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); } }
private static ILaunchConfiguration chooseLaunchConfiguration(String workingDir, String operation) { try { ILaunchConfigurationType ngLaunchConfigurationType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(AngularCLILaunchConstants.LAUNCH_CONFIGURATION_ID); ILaunchConfiguration[] ngConfigurations = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(ngLaunchConfigurationType); for (ILaunchConfiguration conf : ngConfigurations) { if (workingDir.equals(conf.getAttribute(AngularCLILaunchConstants.WORKING_DIR, (String) null)) && operation.equals(conf.getAttribute(AngularCLILaunchConstants.OPERATION, (String) null))) { return conf; } } } catch (CoreException e) { TypeScriptCorePlugin.logError(e, e.getMessage()); } return null; }
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; } }
public Object[] getElements(Object inputElement) { PropertyVariable[] elements = new PropertyVariable[0]; ILaunchConfiguration config = (ILaunchConfiguration) inputElement; Map<String, String> m; try { m = config.getAttribute(launchConfigurationPropertyMapAttributeName, (Map<String, String>) null); } catch (CoreException e) { IDEUtil.logError("Error reading configuration", e); return elements; } if (m != null && !m.isEmpty()) { elements = new PropertyVariable[m.size()]; String[] varNames = new String[m.size()]; m.keySet().toArray(varNames); for (int i = 0; i < m.size(); i++) { elements[i] = new PropertyVariable(varNames[i], (String) m.get(varNames[i])); } } return elements; }
private void chooseAndLaunch(IFile file, ILaunchConfiguration[] configs, String mode) { ILaunchConfiguration config = null; if (configs.length == 0) { config = createConfiguration(file); } else if (configs.length == 1) { config = configs[0]; } else { config = chooseConfiguration(configs); } if (config != null) { Shell shell = getShell(); DebugUITools.openLaunchConfigurationDialogOnGroup(shell, new StructuredSelection(config), IDebugUIConstants.ID_RUN_LAUNCH_GROUP); } }
@Test public void testMergeSession2() throws Exception { ILaunchConfiguration launch = new DummyLaunchConfiguration(); ICoverageSession s0 = new DummySession(launch); ICoverageSession s1 = new DummySession(launch); manager.addSession(s0, false, null); manager.addSession(s1, false, null); listener.clear(); final ICoverageSession m0 = manager.mergeSessions(Arrays.asList(s0, s1), "Merged", new NullProgressMonitor()); assertEquals("Merged", m0.getDescription()); assertSame(launch, m0.getLaunchConfiguration()); assertEquals(Arrays.asList(m0), manager.getSessions()); assertEquals(m0, manager.getActiveSession()); reflistener.sessionAdded(m0); reflistener.sessionActivated(m0); reflistener.sessionRemoved(s0); reflistener.sessionRemoved(s1); assertEquals(reflistener, listener); }
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; } }
@BeforeClass public static void setup() throws Exception { openCoverageView(); JavaProjectKit project = new JavaProjectKit(); project.enableJava5(); final IPackageFragmentRoot root = project.createSourceFolder(); final IPackageFragment fragment = project.createPackage(root, "example"); project.createCompilationUnit(fragment, "Example.java", "package example; class Example { public static void main(String[] args) throws Exception { Thread.sleep(30000); } }"); JavaProjectKit.waitForBuild(); ILaunchConfiguration launchConfiguration = project.createLaunchConfiguration("example.Example"); launch1 = launchConfiguration.launch(CoverageTools.LAUNCH_MODE, null); launch2 = launchConfiguration.launch(CoverageTools.LAUNCH_MODE, null); }
private void renameLaunch(final Spec newSpec, String newModelName) { try { // create the model with the new name final ILaunchConfigurationWorkingCopy copy = this.launchConfig .copy(newSpec.getName() + SPEC_MODEL_DELIM + newModelName); copy.setAttribute(SPEC_NAME, newSpec.getName()); copy.setAttribute(ModelHelper.MODEL_NAME, newModelName); copy.setContainer(newSpec.getProject()); final ILaunchConfiguration renamed = copy.doSave(); // delete the old model this.launchConfig.delete(); this.launchConfig = renamed; } catch (CoreException e) { TLCActivator.logError("Error renaming model.", e); } }
/** * @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; }
public void testPrettyPrintConstants2() throws CoreException { final List<String> values = new ArrayList<String>(); values.add("X;;X;1;0"); values.add("Y;;{a1, b1};1;0"); values.add("Z;;{s1, s2};1;1"); values.add("W;;1;0;0"); values.add("V;;V;1;0"); values.add("U;;42;0;0"); final ILaunchConfiguration config = new DummyLaunchConfig( IModelConfigurationConstants.MODEL_PARAMETER_CONSTANTS, values); final String constants = ModelHelper.prettyPrintConstants(config, "\n"); final String[] split = constants.split("\n"); assertEquals(5, split.length); assertEquals("U <- 42", split[0]); assertEquals("W <- 1", split[1]); assertEquals("Y <- {a1, b1}", split[2]); assertEquals("Z <- s{s1, s2}", split[3]); assertEquals("Model values: V, X", split[4]); }
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; }
@Test public void testFromLaunchConfigurationCopiesArgumentsFromLaunchConfiguration() throws CoreException { ILaunchConfiguration launchConfiguration = mock(ILaunchConfiguration.class); Map<String, String> requiredArgumentValues = ImmutableMap.of( "Spam", "foo", "Ham", "bar", "Eggs", "baz"); when(launchConfiguration.getAttribute( eq(PipelineConfigurationAttr.ALL_ARGUMENT_VALUES.toString()), Matchers.anyMapOf(String.class, String.class))) .thenReturn(requiredArgumentValues); PipelineRunner runner = PipelineRunner.DATAFLOW_PIPELINE_RUNNER; when(launchConfiguration.getAttribute(eq(PipelineConfigurationAttr.RUNNER_ARGUMENT.toString()), anyString())).thenReturn(runner.getRunnerName()); PipelineLaunchConfiguration pipelineLaunchConfig = PipelineLaunchConfiguration.fromLaunchConfiguration(launchConfiguration); assertEquals(requiredArgumentValues, pipelineLaunchConfig.getArgumentValues()); assertEquals(runner, pipelineLaunchConfig.getRunner()); }
@Override protected IPath getDeployArtifact(IPath safeWorkingDirectory, IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 100); try { ILaunchConfiguration config = createMavenPackagingLaunchConfiguration(project); ILaunch launch = config.launch("run", subMonitor.newChild(10)); if (!waitUntilLaunchTerminates(launch, subMonitor.newChild(90))) { throw new OperationCanceledException(); } return getFinalArtifactPath(project); } catch (InterruptedException ex) { throw new OperationCanceledException(); } }
/** * Initialize the widget from the given configuration * * @param configuration * @throws CoreException */ public static void initializeFrom(ILaunchWidget<?> widget, ILaunchConfiguration configuration) throws CoreException { String id = widget.getId(); if(configuration.hasAttribute(id)){ String value = configuration.getAttribute(id, ""); widget.setRawValue(value); }else{ widget.reset(); } // FIXME /* if (!value.isEmpty()) { widget.setRawValue(value); } else { widget.reset(); }*/ }
@SuppressWarnings("unchecked") public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (!Model.class.equals(adapterType)) { return null; } if (adaptableObject instanceof ILaunchConfiguration) { final ILaunchConfiguration launchConfiguration = (ILaunchConfiguration) adaptableObject; // The ILC instances change all the time due to working copies being // created dynamically upon save. Thus, map the various ILC's to one // model by using the canonical IFile that all ILC instances are // technically represented by. final IFile key = launchConfiguration.getFile(); Assert.isNotNull(key); if (!launch2model.containsKey(key)) { launch2model.put(key, new Model(launchConfiguration)); } return (T) launch2model.get(key); } return null; }
/** * Returns whether a launch should proceed. This method is called first * in the launch sequence providing an opportunity for this launch delegate * to abort the launch. * * <br>2. method called on launch * @return whether the launch should proceed * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { // check the config existence if (!config.exists()) { return false; } try { monitor.beginTask("Reading model parameters", 1); } finally { // finish the monitor monitor.done(); } return true; }
/** * Find any applicable launch configurations. */ private ILaunchConfiguration[] getLaunchConfigurations(IModule[] modules) { // First check if there's a server with exactly these modules Collection<IServer> servers = launcher.findExistingServers(modules, /* exact */ true, null); if (servers.isEmpty()) { // otherwise check if there's a server with at least these modules servers = launcher.findExistingServers(modules, /* exact */ false, null); } Collection<ILaunchConfiguration> launchConfigs = new ArrayList<>(); for (IServer server : servers) { // Could filter out running servers, but then more servers are created try { ILaunchConfiguration launchConfig = server.getLaunchConfiguration(false, null); if (launchConfig != null) { launchConfigs.add(launchConfig); } } catch (CoreException ex) { /* ignore */ } } return launchConfigs.toArray(new ILaunchConfiguration[launchConfigs.size()]); }