private ILaunchConfiguration getRunningLaunchConfiguration() { Set<IProject> projects = new HashSet<IProject>( Arrays.asList(ProjectUtil.getProjects(repository))); ILaunchManager launchManager = DebugPlugin.getDefault() .getLaunchManager(); ILaunch[] launches = launchManager.getLaunches(); for (ILaunch launch : launches) { if (launch.isTerminated()) continue; ISourceLocator locator = launch.getSourceLocator(); if (locator instanceof ISourceLookupDirector) { ISourceLookupDirector director = (ISourceLookupDirector) locator; ISourceContainer[] containers = director.getSourceContainers(); if (isAnyProjectInSourceContainers(containers, projects)) return launch.getLaunchConfiguration(); } } return null; }
private ISourceLookupDirector read(ILaunchConfiguration config) throws CoreException { String memento = config.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); if (memento == null) { return null; } String type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); if (type == null) { type = config.getType().getSourceLocatorId(); } ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ISourceLocator locator = launchManager.newSourceLocator(type); if (locator instanceof IPersistableSourceLocator2 == false) { return null; } ISourceLookupDirector director = (ISourceLookupDirector) locator; director.initializeFromMemento(memento, config); return director; }
protected ISourceLookupDirector getSourceLookupDirector() { ISourceLookupDirector commonSourceLookupDirector = new AbstractSourceLookupDirector() { @Override public void initializeParticipants() { } }; ArrayList2<ISourceContainer> containers = new ArrayList2<>(); containers.add(new LangAbsolutePathSourceContainer()); containers.add(new ProgramRelativePathSourceContainer()); customizeDefaultSourceContainers(containers); commonSourceLookupDirector.setSourceContainers(containers.toArray(ISourceContainer.class)); return commonSourceLookupDirector; }
protected void setSourceLocator(ILaunch launch) throws CoreException { ILaunchConfiguration configuration = launch.getLaunchConfiguration(); if (configuration != null && launch.getSourceLocator() == null) { ISourceLookupDirector sourceLocator = new JavaSourceLookupDirector(); ISourcePathComputer locator = getLaunchManager().getSourcePathComputer(SOURCE_LOCATOR); if (locator != null) { sourceLocator.setSourcePathComputer(locator); sourceLocator.initializeDefaults(configuration); launch.setSourceLocator(sourceLocator); } } }
private static List<IJavaProject> getPossibleAdditions0(final ISourceLookupDirector director) { final List<IProject> mavenProjects = new ArrayList<IProject>(); for (final IMavenProjectFacade mavenProject : MavenPlugin.getMavenProjectRegistry().getProjects()) { mavenProjects.add(mavenProject.getProject()); } final List<IJavaProject> javaProjects = new ArrayList<IJavaProject>(); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); try { for (final IJavaProject javaProject : JavaCore.create(root).getJavaProjects()) { if (mavenProjects.contains(javaProject.getProject())) { javaProjects.add(javaProject); } } } catch (final JavaModelException e) { final IStatus status = new Status(IStatus.ERROR, SourceLookupPlugin.getInstance().getBundle().getSymbolicName(), "Can't retrieve Java projects.", e); SourceLookupPlugin.getInstance().getLog().log(status); } for (final ISourceContainer container : director.getSourceContainers()) { if (container.getType().getId().equals(MyMvnSourceContainerTypeDelegate.TYPE_ID)) { javaProjects.remove(((MyMvnSourceContainer) container).getJavaProject()); } } return javaProjects; }
public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { final SourceNameMapperContainer originalContainer = (SourceNameMapperContainer) containers[0]; SourceNameMapperContainerDialog.PresetFieldValues params = new SourceNameMapperContainerDialog.PresetFieldValues() { public ISourceContainer getContainer() { return originalContainer.getTargetContainer(); } public String getPrefix() { return originalContainer.getPrefix(); } }; return openDialog(shell, director, params); }
private ISourceContainer[] openDialog(Shell shell, ISourceLookupDirector director, SourceNameMapperContainerDialog.PresetFieldValues params) { SourceNameMapperContainerDialog dialog = new SourceNameMapperContainerDialog(shell, director, params); dialog.open(); SourceNameMapperContainerDialog.Result dialogResult = dialog.getResult(); if (dialogResult == null) { return new ISourceContainer[0]; } ISourceContainer result = new SourceNameMapperContainer(dialogResult.getResultPrefix(), dialogResult.getResultContainer()); return new ISourceContainer[] { result }; }
public SourceNameMapperContainerDialog(Shell shell, ISourceLookupDirector director, PresetFieldValues initialParams) { super(shell); setShellStyle(getShellStyle() | SWT.RESIZE); this.director = director; this.initialParams = initialParams; }
@Override public void sourceContainersChanged(ISourceLookupDirector director) { delegateContainers.clear(); ISourceContainer[] containers = director.getSourceContainers(); for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; if (container.getType().getId().equals(ArchiveSourceContainer.TYPE_ID)) { IFile file = ((ArchiveSourceContainer)container).getFile(); IProject project = file.getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject.exists()) { try { IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); for (int j = 0; j < roots.length; j++) { IPackageFragmentRoot root = roots[j]; if (file.equals(root.getUnderlyingResource())) { delegateContainers.put(container, new PackageFragmentRootSourceContainer(root)); } else { IPath path = root.getSourceAttachmentPath(); if (path != null) { if (file.getFullPath().equals(path)) { delegateContainers.put(container, new PackageFragmentRootSourceContainer(root)); } } } } } catch (JavaModelException e) { } } } } }
@Override public boolean canAddSourceContainers(final ISourceLookupDirector director) { return !getPossibleAdditions0(director).isEmpty(); }
public void init(ISourceLookupDirector director) { if (director instanceof ChromiumSourceDirector) { chromiumSourceDirector = (ChromiumSourceDirector) director; } }
public ReverseSourceLookup(ISourceLookupDirector sourceDirector) { this.sourceDirector = sourceDirector; }
public void init(ISourceLookupDirector director) { }
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { return openDialog(shell, director, null); }
public boolean canAddSourceContainers(ISourceLookupDirector director) { return true; }
public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { return containers.length == 1; }