Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivian Kong2008-08-08 19:34:13 -0400
committerVivian Kong2008-08-08 19:34:13 -0400
commit95e3cd02e172d5010b49db1de825e24bebb63413 (patch)
tree9d3a3ec4d98a0709e93314283e1c2e131d34f4e6
parent61690dceb9b0b3f11a2f7d1af5e7412c3139a737 (diff)
downloadorg.eclipse.cdt-95e3cd02e172d5010b49db1de825e24bebb63413.tar.gz
org.eclipse.cdt-95e3cd02e172d5010b49db1de825e24bebb63413.tar.xz
org.eclipse.cdt-95e3cd02e172d5010b49db1de825e24bebb63413.zip
fix for bug 237327
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java19
3 files changed, 52 insertions, 17 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java
new file mode 100644
index 0000000000..8912250fd3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * QNX Software System
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IActionFilter;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * An implementation of the IWorkbenchAdapter for CElements.
+ */
+public class CActionFilter implements IActionFilter {
+
+ public CActionFilter() {
+ }
+
+ public boolean testAttribute(Object target, String name, String value) {
+ ICElement element = (ICElement) target;
+ IResource resource = element.getResource();
+ if (resource != null) {
+ IActionFilter filter = (IActionFilter) resource.getAdapter(IActionFilter.class);
+ if (filter != null) {
+ return filter.testAttribute(resource, name, value);
+ }
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
index 08258886b9..8440bb5fa4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* QNX Software System
* Anton Leherbauer (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
@@ -41,6 +42,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
};
private static CWorkbenchAdapter fgCWorkbenchAdapter;
+ private static CActionFilter fgCActionFilter;
/**
* @see CElementAdapterFactory#getAdapterList
@@ -70,7 +72,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
} else if (IWorkbenchAdapter.class.equals(key)) {
return getWorkbenchAdapter(celem);
} else if (IActionFilter.class.equals(key)) {
- return getWorkbenchAdapter(celem);
+ return getActionFilter(celem);
}
return null;
}
@@ -103,4 +105,11 @@ public class CElementAdapterFactory implements IAdapterFactory {
}
return fgCWorkbenchAdapter;
}
+
+ private IActionFilter getActionFilter(ICElement celement) {
+ if (fgCActionFilter == null) {
+ fgCActionFilter = new CActionFilter();
+ }
+ return fgCActionFilter;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
index a9c3e1d9a5..12e2cabba1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
@@ -17,15 +18,13 @@ import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.model.IWorkbenchAdapter;
/**
- * An imlementation of the IWorkbenchAdapter for CElements.
+ * An implementation of the IWorkbenchAdapter for CElements.
*/
-public class CWorkbenchAdapter implements IWorkbenchAdapter, IActionFilter {
+public class CWorkbenchAdapter implements IWorkbenchAdapter {
private static final Object[] fgEmptyArray = new Object[0];
private CElementImageProvider fImageProvider;
@@ -84,16 +83,4 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter, IActionFilter {
}
return null;
}
-
- public boolean testAttribute(Object target, String name, String value) {
- ICElement element = (ICElement)target;
- IResource resource = element.getResource();
- if (resource != null) {
- IActionFilter filter = (IActionFilter)resource.getAdapter(IActionFilter.class);
- if (filter != null) {
- return filter.testAttribute(resource, name, value);
- }
- }
- return false;
- }
}

Back to the top