Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 80018 Details for
Bug 57515
[search] java search participant for launch configs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch recreated against HEAD.
jdt-search-launch.patch (text/plain), 19.13 KB, created by
Peter Nehrer
on 2007-10-09 23:34:46 EDT
(
hide
)
Description:
Patch recreated against HEAD.
Filename:
MIME Type:
Creator:
Peter Nehrer
Created:
2007-10-09 23:34:46 EDT
Size:
19.13 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.24 >diff -u -r1.24 MANIFEST.MF >--- META-INF/MANIFEST.MF 19 Sep 2007 16:07:40 -0000 1.24 >+++ META-INF/MANIFEST.MF 10 Oct 2007 03:33:07 -0000 >@@ -22,6 +22,7 @@ > org.eclipse.jdt.internal.debug.ui.launcher;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.monitors;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.propertypages;x-internal:=true, >+ org.eclipse.jdt.internal.debug.ui.search;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.snippeteditor;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.sourcelookup;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.threadgroups;x-internal:=true, >@@ -43,7 +44,8 @@ > org.eclipse.ltk.core.refactoring;bundle-version="[3.3.0,4.0.0)", > org.eclipse.ui.console;bundle-version="[3.2.0,4.0.0)", > org.eclipse.jdt.core.manipulation;bundle-version="[1.1.0,2.0.0)", >- org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)" >+ org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)", >+ org.eclipse.search;bundle-version="[3.3.0,4.0.0)" > Eclipse-LazyStart: true > Import-Package: com.ibm.icu.text > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.properties,v >retrieving revision 1.209 >diff -u -r1.209 plugin.properties >--- plugin.properties 10 Sep 2007 15:00:43 -0000 1.209 >+++ plugin.properties 10 Oct 2007 03:33:05 -0000 >@@ -294,3 +294,5 @@ > preference.transfer.jres.description=Preferences related to system libraries used to build, run, and debug Java applications. > preference.transfer.logicalStructures=Java Logical Structures > preference.transfer.logicalStructures.description=Preferences related to logical structures used for debugging Java applications. >+ >+LaunchConfigurationQueryParticipant.name = Java Launch Configuration >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.xml,v >retrieving revision 1.465 >diff -u -r1.465 plugin.xml >--- plugin.xml 4 Oct 2007 02:47:25 -0000 1.465 >+++ plugin.xml 10 Oct 2007 03:33:07 -0000 >@@ -3377,4 +3377,13 @@ > vmInstallType="org.eclipse.jdt.launching.EEVMType"> > </vmInstallPage> > </extension> >+ <extension >+ point="org.eclipse.jdt.ui.queryParticipants"> >+ <queryParticipant >+ class="org.eclipse.jdt.internal.debug.ui.search.LaunchConfigurationQueryParticipant" >+ id="org.eclipse.jdt.internal.debug.ui.search.LaunchConfigurationQueryParticipant" >+ name="%LaunchConfigurationQueryParticipant.name" >+ nature="org.eclipse.jdt.core.javanature"> >+ </queryParticipant> >+ </extension> > </plugin> >Index: ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 Ecliptical Software Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Ecliptical Software Inc. - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.search; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public final class SearchMessages extends NLS { >+ >+ private static final String BUNDLE_NAME= "org.eclipse.jdt.internal.debug.ui.search.SearchMessages";//$NON-NLS-1$ >+ >+ private SearchMessages() { >+ // Do not instantiate >+ } >+ >+ public static String LaunchConfigurationQueryParticipant_search_errors; >+ >+ static { >+ NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class); >+ } >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/search/LaunchConfigurationQueryParticipant.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/search/LaunchConfigurationQueryParticipant.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/search/LaunchConfigurationQueryParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/search/LaunchConfigurationQueryParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,402 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 Ecliptical Software Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Ecliptical Software Inc. - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.search; >+ >+import java.util.StringTokenizer; >+import java.util.regex.Pattern; >+ >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchMode; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.debug.ui.ILaunchGroup; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.search.IJavaSearchConstants; >+import org.eclipse.jdt.core.search.IJavaSearchScope; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.ui.search.ElementQuerySpecification; >+import org.eclipse.jdt.ui.search.IMatchPresentation; >+import org.eclipse.jdt.ui.search.IQueryParticipant; >+import org.eclipse.jdt.ui.search.ISearchRequestor; >+import org.eclipse.jdt.ui.search.PatternQuerySpecification; >+import org.eclipse.jdt.ui.search.QuerySpecification; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.resource.LocalResourceManager; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.DecoratingLabelProvider; >+import org.eclipse.jface.viewers.DecorationOverlayIcon; >+import org.eclipse.jface.viewers.ILabelDecorator; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.search.ui.text.Match; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.part.IShowInTarget; >+import org.eclipse.ui.part.ShowInContext; >+ >+public class LaunchConfigurationQueryParticipant implements IQueryParticipant { >+ >+ private UIParticipant uiParticipant; >+ >+ public int estimateTicks(QuerySpecification query) { >+ if (isValid(query)) >+ return 50; >+ >+ return 0; >+ } >+ >+ public synchronized IMatchPresentation getUIParticipant() { >+ if (uiParticipant == null) >+ uiParticipant = new UIParticipant(); >+ >+ return uiParticipant; >+ } >+ >+ public void search(ISearchRequestor requestor, QuerySpecification query, >+ IProgressMonitor monitor) throws CoreException { >+ if (!isValid(query)) >+ return; >+ >+ monitor.beginTask("", 11); //$NON-NLS-1$ >+ try { >+ Pattern pattern = null; >+ if (query instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementQuery = (ElementQuerySpecification) query; >+ IType type = (IType) elementQuery.getElement(); >+ pattern = Pattern.compile(quotePattern(type >+ .getFullyQualifiedName('$'))); >+ } >+ >+ if (query instanceof PatternQuerySpecification) { >+ PatternQuerySpecification patternQuery = (PatternQuerySpecification) query; >+ int flags = patternQuery.isCaseSensitive() ? 0 >+ : Pattern.CASE_INSENSITIVE; >+ String quotedPattern = quotePattern(patternQuery.getPattern()); >+ pattern = Pattern.compile(quotedPattern, flags); >+ } >+ >+ monitor.worked(1); >+ if (monitor.isCanceled()) >+ throw new OperationCanceledException(); >+ >+ MultiStatus multiStatus = new MultiStatus( >+ JDIDebugUIPlugin.getUniqueIdentifier(), >+ 0, >+ SearchMessages.LaunchConfigurationQueryParticipant_search_errors, >+ null); >+ try { >+ searchLaunchConfigurations(requestor, query.getScope(), >+ pattern, new SubProgressMonitor(monitor, 7)); >+ } catch (CoreException e) { >+ multiStatus.merge(e.getStatus()); >+ } >+ >+ try { >+ searchLaunches(requestor, query.getScope(), pattern, >+ new SubProgressMonitor(monitor, 3)); >+ } catch (CoreException e) { >+ multiStatus.merge(e.getStatus()); >+ } >+ >+ if (!multiStatus.isOK()) >+ throw new CoreException(multiStatus); >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ private String quotePattern(String pattern) { >+ StringTokenizer t = new StringTokenizer(pattern, ".?*", true); //$NON-NLS-1$ >+ StringBuffer buf = new StringBuffer(); >+ while (t.hasMoreTokens()) { >+ String token = t.nextToken(); >+ switch (token.charAt(0)) { >+ case '.': >+ buf.append('\\'); >+ break; >+ case '?': >+ case '*': >+ buf.append('.'); >+ break; >+ } >+ >+ buf.append(token); >+ } >+ >+ return buf.toString(); >+ } >+ >+ private boolean isValid(QuerySpecification query) { >+ switch (query.getLimitTo()) { >+ case IJavaSearchConstants.REFERENCES: >+ case IJavaSearchConstants.ALL_OCCURRENCES: >+ break; >+ default: >+ return false; >+ } >+ >+ if (query instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementQuery = (ElementQuerySpecification) query; >+ return elementQuery.getElement().getElementType() == IJavaElement.TYPE; >+ } >+ >+ if (query instanceof PatternQuerySpecification) { >+ PatternQuerySpecification patternQuery = (PatternQuerySpecification) query; >+ switch (patternQuery.getSearchFor()) { >+ case IJavaSearchConstants.UNKNOWN: >+ case IJavaSearchConstants.TYPE: >+ case IJavaSearchConstants.CLASS: >+ case IJavaSearchConstants.CLASS_AND_INTERFACE: >+ case IJavaSearchConstants.CLASS_AND_ENUM: >+ return true; >+ } >+ >+ return false; >+ } >+ >+ return false; >+ } >+ >+ private boolean matches(IJavaSearchScope scope, >+ ILaunchConfiguration config, IWorkspaceRoot workspaceRoot, >+ Pattern pattern) throws CoreException { >+ String mainTypeName = config.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, >+ (String) null); >+ if (mainTypeName == null) >+ return false; >+ >+ mainTypeName = VariablesPlugin.getDefault().getStringVariableManager() >+ .performStringSubstitution(mainTypeName); >+ >+ // use associated project to limit search scope >+ String projectName = config.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, >+ (String) null); >+ if (projectName != null) { >+ IPath[] projectsAndJars = scope.enclosingProjectsAndJars(); >+ IPath projectPath = workspaceRoot.getProject(projectName) >+ .getFullPath(); >+ boolean found = false; >+ for (int j = 0; j < projectsAndJars.length; ++j) { >+ if (projectsAndJars[j].equals(projectPath)) { >+ found = true; >+ break; >+ } >+ } >+ >+ if (!found) >+ return false; >+ } >+ >+ return pattern.matcher(mainTypeName).matches(); >+ } >+ >+ private void searchLaunchConfigurations(ISearchRequestor requestor, >+ IJavaSearchScope scope, Pattern pattern, IProgressMonitor monitor) >+ throws CoreException { >+ ILaunchConfiguration[] configs = DebugPlugin.getDefault() >+ .getLaunchManager().getLaunchConfigurations(); >+ >+ MultiStatus multiStatus = new MultiStatus(JDIDebugUIPlugin >+ .getUniqueIdentifier(), 0, null, null); >+ monitor.beginTask("", configs.length); //$NON-NLS-1$ >+ try { >+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace() >+ .getRoot(); >+ for (int i = 0; i < configs.length; ++i) { >+ monitor.worked(1); >+ if (monitor.isCanceled()) >+ throw new OperationCanceledException(); >+ >+ monitor.subTask(configs[i].getName()); >+ >+ try { >+ if (matches(scope, configs[i], workspaceRoot, pattern)) >+ requestor.reportMatch(new Match(configs[i], 0, 0)); >+ } catch (CoreException e) { >+ multiStatus.add(e.getStatus()); >+ } >+ } >+ } finally { >+ monitor.done(); >+ } >+ >+ if (!multiStatus.isOK()) >+ throw new CoreException(multiStatus); >+ } >+ >+ private void searchLaunches(ISearchRequestor requestor, >+ IJavaSearchScope scope, Pattern pattern, IProgressMonitor monitor) >+ throws CoreException { >+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); >+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager() >+ .getLaunches(); >+ >+ MultiStatus multiStatus = new MultiStatus(JDIDebugUIPlugin >+ .getUniqueIdentifier(), 0, null, null); >+ monitor.beginTask("", launches.length); //$NON-NLS-1$ >+ ILabelProvider lp = null; >+ try { >+ // TODO not sure if this is generally OK in a non-UI thread >+ lp = DebugUITools.newDebugModelPresentation(); >+ for (int i = 0; i < launches.length; ++i) { >+ monitor.worked(1); >+ if (monitor.isCanceled()) >+ throw new OperationCanceledException(); >+ >+ monitor.subTask(lp.getText(launches[i])); >+ ILaunchConfiguration config = launches[i] >+ .getLaunchConfiguration(); >+ if (config == null) >+ continue; >+ >+ try { >+ IProcess[] procs = launches[i].getProcesses(); >+ if (procs.length == 0) >+ continue; >+ >+ if (matches(scope, config, workspaceRoot, pattern)) >+ requestor.reportMatch(new Match(procs[0], 0, 0)); >+ } catch (CoreException e) { >+ multiStatus.add(e.getStatus()); >+ } >+ } >+ } finally { >+ if (lp != null) >+ lp.dispose(); >+ >+ monitor.done(); >+ } >+ >+ if (!multiStatus.isOK()) >+ throw new CoreException(multiStatus); >+ } >+ >+ private static class UIParticipant implements IMatchPresentation { >+ >+ public ILabelProvider createLabelProvider() { >+ return new DecoratingLabelProvider(DebugUITools >+ .newDebugModelPresentation(), new DebugModelDecorator()); >+ } >+ >+ public void showMatch(Match match, int currentOffset, >+ int currentLength, boolean activate) throws PartInitException { >+ if (match.getElement() instanceof IProcess) { >+ // show the process in debug view >+ IViewPart view = JDIDebugUIPlugin.getActivePage().showView( >+ IDebugUIConstants.ID_DEBUG_VIEW, >+ null, >+ activate ? IWorkbenchPage.VIEW_ACTIVATE >+ : IWorkbenchPage.VIEW_CREATE); >+ IShowInTarget target = null; >+ if (view instanceof IShowInTarget) >+ target = (IShowInTarget) view; >+ else >+ target = (IShowInTarget) view >+ .getAdapter(IShowInTarget.class); >+ >+ if (target != null) { >+ final IShowInTarget t = target; >+ final ShowInContext context = new ShowInContext(null, >+ new StructuredSelection(match.getElement())); >+ JDIDebugUIPlugin.getStandardDisplay().asyncExec( >+ new Runnable() { >+ public void run() { >+ t.show(context); >+ } >+ }); >+ } >+ >+ return; >+ } >+ >+ if (match.getElement() instanceof ILaunchConfiguration) { >+ if (activate) { >+ // open the launch config in launch dialog >+ ILaunchConfiguration config = (ILaunchConfiguration) match >+ .getElement(); >+ // find the first available group for any of the supported >+ // modes >+ ILaunchMode[] modes = DebugPlugin.getDefault() >+ .getLaunchManager().getLaunchModes(); >+ ILaunchGroup group = null; >+ for (int i = 0; i < modes.length; ++i) { >+ group = DebugUITools.getLaunchGroup(config, modes[i] >+ .getIdentifier()); >+ if (group != null) >+ break; >+ } >+ >+ if (group == null) >+ return; >+ >+ DebugUITools.openLaunchConfigurationDialog(JDIDebugUIPlugin >+ .getActiveWorkbenchShell(), config, group >+ .getIdentifier(), Status.OK_STATUS); >+ } >+ } >+ } >+ } >+ >+ private static class DebugModelDecorator extends BaseLabelProvider >+ implements ILabelDecorator { >+ >+ private LocalResourceManager registry; >+ >+ public Image decorateImage(Image image, Object element) { >+ Rectangle bounds = image.getBounds(); >+ if (bounds.width >= 20) >+ return null; >+ >+ if (registry == null) >+ registry = new LocalResourceManager(JFaceResources >+ .getResources()); >+ >+ // pad the icon to match JDT icon width >+ // TODO is there a more generic way? >+ DecorationOverlayIcon result = new DecorationOverlayIcon(image, >+ new ImageDescriptor[0], new Point(20, 16)); >+ return (Image) registry.get(result); >+ } >+ >+ public String decorateText(String text, Object element) { >+ return null; >+ } >+ >+ public void dispose() { >+ if (registry != null) >+ registry.dispose(); >+ >+ super.dispose(); >+ } >+ } >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.properties >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.properties >diff -N ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/search/SearchMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+############################################################################### >+# Copyright (c) 2007 Ecliptical Software Inc. and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# Ecliptical Software Inc. - initial API and implementation >+############################################################################### >+ >+LaunchConfigurationQueryParticipant_search_errors=Errors occurred while searching launch configurations.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57515
:
78490
|
79106
|
80018
|
80481