Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2005-05-25 19:37:34 +0000
committerDarin Wright2005-05-25 19:37:34 +0000
commitfc7c3ef3b41aef67634e6b53ae00645f57f0c0a2 (patch)
tree7b569477860a9e933b8ef935aed3526584fed225 /org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java
parent163a2e39a71da47b5db29912e37782d65bc0c1c4 (diff)
downloadeclipse.platform.debug-fc7c3ef3b41aef67634e6b53ae00645f57f0c0a2.tar.gz
eclipse.platform.debug-fc7c3ef3b41aef67634e6b53ae00645f57f0c0a2.tar.xz
eclipse.platform.debug-fc7c3ef3b41aef67634e6b53ae00645f57f0c0a2.zip
Bug 96432 - Debug/Run As "Ant build" shows up for Java files
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java
index e42672aaf..c6c33ad07 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.regex.Pattern;
import org.eclipse.core.expressions.PropertyTester;
@@ -18,8 +22,11 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.ui.IPathEditorInput;
/**
* ResourceExtender provides property testers for the XML expression language
@@ -41,7 +48,31 @@ public class ResourceExtender extends PropertyTester {
*/
public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
IResource resource = (IResource) ((IAdaptable) receiver).getAdapter(IResource.class);
- if (resource != null) {
+ if (resource == null) {
+ if (PROPERTY_MATCHES_CONTENT_TYPE.equals(method)) {
+ IPathEditorInput editorInput = (IPathEditorInput) ((IAdaptable) receiver).getAdapter(IPathEditorInput.class);
+ if (editorInput != null) {
+ IPath path= editorInput.getPath();
+ File file= path.toFile();
+ if (file.exists()) {
+ try {
+ FileReader reader= new FileReader(file);
+ IContentType contentType= Platform.getContentTypeManager().getContentType((String)expectedValue);
+ IContentDescription description= contentType.getDescriptionFor(reader, IContentDescription.ALL);
+ reader.close();
+ if (description != null) {
+ IContentType type = description.getContentType();
+ return type != null && expectedValue.equals(type.getId());
+ }
+ } catch (FileNotFoundException e) {
+ return false;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ }
+ }
+ } else {
if (PROPERTY_MATCHES_PATTERN.equals(method)) { //$NON-NLS-1$
String fileName = resource.getName();
String expected = (String) expectedValue;

Back to the top