Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 18338 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java (-19 / +21 lines)
Lines 27-32 Link Here
27
import org.eclipse.debug.core.ILaunchManager;
27
import org.eclipse.debug.core.ILaunchManager;
28
import org.eclipse.debug.ui.DebugUITools;
28
import org.eclipse.debug.ui.DebugUITools;
29
import org.eclipse.debug.ui.IDebugModelPresentation;
29
import org.eclipse.debug.ui.IDebugModelPresentation;
30
import org.eclipse.debug.ui.ILaunchFilter;
30
import org.eclipse.debug.ui.ILaunchShortcut;
31
import org.eclipse.debug.ui.ILaunchShortcut;
31
import org.eclipse.jdt.core.IJavaElement;
32
import org.eclipse.jdt.core.IJavaElement;
32
import org.eclipse.jdt.core.IType;
33
import org.eclipse.jdt.core.IType;
Lines 43-49 Link Here
43
import org.eclipse.jface.viewers.StructuredSelection;
44
import org.eclipse.jface.viewers.StructuredSelection;
44
import org.eclipse.jface.window.Window;
45
import org.eclipse.jface.window.Window;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.ui.IActionFilter;
47
import org.eclipse.ui.IEditorInput;
47
import org.eclipse.ui.IEditorInput;
48
import org.eclipse.ui.IEditorPart;
48
import org.eclipse.ui.IEditorPart;
49
import org.eclipse.ui.IWorkbenchPage;
49
import org.eclipse.ui.IWorkbenchPage;
Lines 51-57 Link Here
51
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
51
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
52
import org.eclipse.ui.editors.text.WorkspaceOperationRunner;
52
import org.eclipse.ui.editors.text.WorkspaceOperationRunner;
53
53
54
public class JavaAppletLaunchShortcut implements ILaunchShortcut, IActionFilter {
54
public class JavaAppletLaunchShortcut implements ILaunchShortcut, ILaunchFilter {
55
55
56
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
56
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
57
57
Lines 271-277 Link Here
271
	/* (non-Javadoc)
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
272
	 * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
273
	 */
273
	 */
274
	public boolean testAttribute(Object target, String name, String value) {
274
	public boolean testAttribute(IResource target, String name, String value) {
275
		if ("ContextualLaunchActionFilter".equals(name)) { //$NON-NLS-1$
275
		if ("ContextualLaunchActionFilter".equals(name)) { //$NON-NLS-1$
276
			return isApplet(target);
276
			return isApplet(target);
277
		} else if ("NameMatches".equals(name)) { //$NON-NLS-1$
277
		} else if ("NameMatches".equals(name)) { //$NON-NLS-1$
Lines 279-301 Link Here
279
		}
279
		}
280
		return false;
280
		return false;
281
	}
281
	}
282
	
282
	/**
283
	private boolean nameMatches(Object target, String value) {
283
	 * Test if the name of the target resource matches a pattern.
284
		try {
284
	 * 
285
			Object[] selections = ((IStructuredSelection) target).toArray();
285
	 * @param target selected resource from workspace
286
			IResource resource = (IResource) selections[0];
286
	 * @param value regular expression pattern to test
287
			String filename = resource.getName();
287
	 * @return true if the pattern matches the resource name, false otherwise
288
			StringMatcher sm = new StringMatcher(value, true, false);
288
	 */
289
			return sm.match(filename);
289
	private boolean nameMatches(IResource resource, String pattern) {
290
		} catch (ClassCastException e) {
290
		String filename = resource.getName();
291
			return false;
291
		StringMatcher sm = new StringMatcher(pattern, true, false);
292
		}
292
		return sm.match(filename);
293
	}
293
	}
294
	
294
	/**
295
	private boolean isApplet(Object target) {
295
	 * Check if the specified resource is an Applet.
296
		if (target != null && target instanceof IStructuredSelection) {
296
	 * @return <code>true</code> if the target resource is an Applet,
297
			Object[] selections = ((IStructuredSelection )target).toArray();
297
	 * <code>false</code> otherwise.
298
			IResource resource = (IResource)selections[0];
298
	 */
299
	private boolean isApplet(IResource resource) {
300
		if (resource != null) {
299
			try {
301
			try {
300
				Set result= new HashSet();
302
				Set result= new HashSet();
301
				AppletLaunchConfigurationUtils.collectTypes(resource, new NullProgressMonitor(), result);
303
				AppletLaunchConfigurationUtils.collectTypes(resource, new NullProgressMonitor(), result);
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java (-18 / +22 lines)
Lines 25-30 Link Here
25
import org.eclipse.debug.core.ILaunchManager;
25
import org.eclipse.debug.core.ILaunchManager;
26
import org.eclipse.debug.ui.DebugUITools;
26
import org.eclipse.debug.ui.DebugUITools;
27
import org.eclipse.debug.ui.IDebugModelPresentation;
27
import org.eclipse.debug.ui.IDebugModelPresentation;
28
import org.eclipse.debug.ui.ILaunchFilter;
28
import org.eclipse.debug.ui.ILaunchShortcut;
29
import org.eclipse.debug.ui.ILaunchShortcut;
29
import org.eclipse.jdt.core.IClassFile;
30
import org.eclipse.jdt.core.IClassFile;
30
import org.eclipse.jdt.core.ICompilationUnit;
31
import org.eclipse.jdt.core.ICompilationUnit;
Lines 46-52 Link Here
46
import org.eclipse.jface.window.Window;
47
import org.eclipse.jface.window.Window;
47
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Shell;
49
import org.eclipse.swt.widgets.Shell;
49
import org.eclipse.ui.IActionFilter;
50
import org.eclipse.ui.IEditorInput;
50
import org.eclipse.ui.IEditorInput;
51
import org.eclipse.ui.IEditorPart;
51
import org.eclipse.ui.IEditorPart;
52
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
52
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
Lines 54-60 Link Here
54
/**
54
/**
55
 * Performs single click launching for local Java applications.
55
 * Performs single click launching for local Java applications.
56
 */
56
 */
57
public class JavaApplicationLaunchShortcut implements ILaunchShortcut, IActionFilter {
57
public class JavaApplicationLaunchShortcut implements ILaunchShortcut, ILaunchFilter {
58
	
58
	
59
	/**
59
	/**
60
	 * @param search the java elements to search for a main type
60
	 * @param search the java elements to search for a main type
Lines 270-276 Link Here
270
	/* (non-Javadoc)
270
	/* (non-Javadoc)
271
	 * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
271
	 * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
272
	 */
272
	 */
273
	public boolean testAttribute(Object target, String name, String value) {
273
	public boolean testAttribute(IResource target, String name, String value) {
274
		if ("ContextualLaunchActionFilter".equals(name)) { //$NON-NLS-1$
274
		if ("ContextualLaunchActionFilter".equals(name)) { //$NON-NLS-1$
275
			return hasMain(target);
275
			return hasMain(target);
276
		} else if ("NameMatches".equals(name)) { //$NON-NLS-1$
276
		} else if ("NameMatches".equals(name)) { //$NON-NLS-1$
Lines 279-301 Link Here
279
		return false;
279
		return false;
280
	}
280
	}
281
	
281
	
282
	private boolean nameMatches(Object target, String value) {
282
	/**
283
		try {
283
	 * Test if the name of the target resource matches a pattern.
284
			Object[] selections = ((IStructuredSelection) target).toArray();
284
	 * 
285
			IResource resource = (IResource) selections[0];
285
	 * @param target selected resource from workspace
286
			String filename = resource.getName();
286
	 * @param value regular expression pattern to test
287
			StringMatcher sm = new StringMatcher(value, true, false);
287
	 * @return true if the pattern matches the resource name, false otherwise
288
			return sm.match(filename);
288
	 */
289
		} catch (ClassCastException e) {
289
	private boolean nameMatches(IResource target, String regexp) {
290
			return false;
290
		String filename = target.getName();
291
		}
291
		StringMatcher sm = new StringMatcher(regexp, true, false);
292
		return sm.match(filename);
292
	}
293
	}
293
	
294
	
294
	private boolean hasMain(Object target) {
295
	/**
295
		if (target != null && target instanceof IStructuredSelection) {
296
	 * Look for a Java main() method in the specified resource.
296
			Object[] selections = ((IStructuredSelection )target).toArray();
297
	 * @return true if the target resource has a <code>main</code> method,
297
			IResource resource = (IResource)selections[0];
298
	 * <code>false</code> otherwise.
298
			IJavaElement element = JavaCore.create(resource);
299
	 */
300
	private boolean hasMain(IResource target) {
301
		if (target != null) {
302
			IJavaElement element = JavaCore.create(target);
299
			if (element instanceof ICompilationUnit) {
303
			if (element instanceof ICompilationUnit) {
300
				ICompilationUnit cu = (ICompilationUnit) element;
304
				ICompilationUnit cu = (ICompilationUnit) element;
301
				IType mainType= cu.getType(Signature.getQualifier(cu.getElementName()));
305
				IType mainType= cu.getType(Signature.getQualifier(cu.getElementName()));

Return to bug 18338