mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Fixed bug 237327.
This commit is contained in:
parent
77b67de31f
commit
59915ca750
3 changed files with 52 additions and 17 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui;
|
package org.eclipse.cdt.internal.ui;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
|
||||||
};
|
};
|
||||||
|
|
||||||
private static CWorkbenchAdapter fgCWorkbenchAdapter;
|
private static CWorkbenchAdapter fgCWorkbenchAdapter;
|
||||||
|
private static CActionFilter fgCActionFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CElementAdapterFactory#getAdapterList
|
* @see CElementAdapterFactory#getAdapterList
|
||||||
|
@ -70,7 +72,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
|
||||||
} else if (IWorkbenchAdapter.class.equals(key)) {
|
} else if (IWorkbenchAdapter.class.equals(key)) {
|
||||||
return getWorkbenchAdapter(celem);
|
return getWorkbenchAdapter(celem);
|
||||||
} else if (IActionFilter.class.equals(key)) {
|
} else if (IActionFilter.class.equals(key)) {
|
||||||
return getWorkbenchAdapter(celem);
|
return getActionFilter(celem);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -103,4 +105,11 @@ public class CElementAdapterFactory implements IAdapterFactory {
|
||||||
}
|
}
|
||||||
return fgCWorkbenchAdapter;
|
return fgCWorkbenchAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IActionFilter getActionFilter(ICElement celement) {
|
||||||
|
if (fgCActionFilter == null) {
|
||||||
|
fgCActionFilter = new CActionFilter();
|
||||||
|
}
|
||||||
|
return fgCActionFilter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui;
|
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.internal.ui.viewsupport.CElementImageProvider;
|
||||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.ui.IActionFilter;
|
|
||||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
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 static final Object[] fgEmptyArray = new Object[0];
|
||||||
private CElementImageProvider fImageProvider;
|
private CElementImageProvider fImageProvider;
|
||||||
|
@ -84,16 +83,4 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter, IActionFilter {
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue