@Override public void migrate(ILaunchConfiguration candidate) throws CoreException { ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy(); updateResourceMapping(wc); wc.doSave(); }
@Override public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException { String pName = candidate.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING); if(pName.equals(EMPTY_STRING)) { return false; } if (!isAvailable(pName)) { return false; } IResource[] mapped = candidate.getMappedResources(); IResource target = getResource(candidate); if (target == null) { return mapped != null; } if (mapped == null) { return true; } if (mapped.length != 1) { return true; } return !target.equals(mapped[0]); }
/** * Updates the resource mapping for the given launch configuration. * * @param wc working copy * @throws CoreException if an exception occurs updating resource mapping. */ public static void updateResourceMapping(ILaunchConfigurationWorkingCopy wc) throws CoreException { IResource resource = getResource(wc); IResource[] resources = null; if (resource != null) { resources = new IResource[]{resource}; } wc.setMappedResources(resources); }
/** * Updates the resource mapping for the given launch configuration. * * @param wc working copy * @throws CoreException if an exception occurs updating resource mapping. */ public static void updateResourceMapping(ILaunchConfigurationWorkingCopy wc) throws CoreException { IResource resource = getResource(wc); IResource[] resources = null; if (resource != null) { resources = new IResource[]{resource}; } wc.setMappedResources(resources); }
@Override public void migrate(ILaunchConfiguration candidate) throws CoreException { ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy(); updateResourceMapping(wc); wc.doSave(); }
@Override public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException { String pName = candidate.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING); if(pName.equals(EMPTY_STRING)) { return false; } if (!isAvailable(pName)) { return false; } IResource[] mapped = candidate.getMappedResources(); IResource target = getResource(candidate); if (target == null) { return mapped != null; } if (mapped == null) { return true; } if (mapped.length != 1) { return true; } return !target.equals(mapped[0]); }
/** * Maps the config to associated java resource * * @param config */ protected void mapResources(ILaunchConfigurationWorkingCopy config) { try { //CONTEXTLAUNCHING IJavaProject javaProject = getJavaProject(); if (javaProject != null && javaProject.exists() && javaProject.isOpen()) { JavaMigrationDelegate.updateResourceMapping(config); } } catch(CoreException ce) { setErrorMessage(ce.getStatus().getMessage()); } }
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewProjectName); JavaMigrationDelegate.updateResourceMapping(wc);
/** initialize the launch configuration. * * @param configurationType the name of the configuration type to create. * @param projectName the name of the project. * @param id the identifier of the launch configuration. * @param resetJavaMainClass indicates if the JAva main class should be reset from the SRE configuration. * @return the created launch configuration. * @throws CoreException if the configuration cannot be created. * @since 0.7 */ protected ILaunchConfigurationWorkingCopy initLaunchConfiguration(String configurationType, String projectName, String id, boolean resetJavaMainClass) throws CoreException { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(configurationType); final ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, launchManager.generateLaunchConfigurationName(id)); setProjectName(wc, projectName); setDefaultContextIdentifier(wc, null); setLaunchingFlags(wc, DEFAULT_SHOW_LOGO, DEFAULT_SHOW_LOG_INFO, DEFAULT_OFFLINE); setRuntimeConfiguration(wc, SARLRuntime.getDefaultSREInstall(), DEFAULT_USE_SYSTEM_SRE, DEFAULT_USE_PROJECT_SRE, resetJavaMainClass); JavaMigrationDelegate.updateResourceMapping(wc); return wc; }
/** * Creates and saves template launch configuration for the given scrapbook file. */ public static ILaunchConfiguration createLaunchConfigurationTemplate(IFile page) throws CoreException { ILaunchConfigurationType lcType = getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); String name = MessageFormat.format(SnippetMessages.getString("ScrapbookLauncher.17"), new String[]{page.getName()}); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy wc = lcType.newInstance(null, name); wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain"); //$NON-NLS-1$ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, page.getProject().getName()); wc.setAttribute(SCRAPBOOK_LAUNCH, SCRAPBOOK_LAUNCH); wc.setAttribute(SCRAPBOOK_FILE_PATH, page.getFullPath().toString()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.jdt.debug.ui.scrapbookSourcepathProvider"); //$NON-NLS-1$ JavaMigrationDelegate.updateResourceMapping(wc); ILaunchConfiguration config = wc.doSave(); setLaunchConfigMemento(page, config.getMemento()); return config; }