use of org.eclipse.core.resources.mapping.ResourceMapping in project che by eclipse.
the class CopyModifications method copy.
public void copy(IPackageFragmentRoot sourceFolder, CopyArguments javaArgs, CopyArguments resourceArgs) {
add(sourceFolder, javaArgs, null);
ResourceMapping mapping = JavaElementResourceMapping.create(sourceFolder);
if (mapping != null) {
add(mapping, resourceArgs, null);
}
IResource sourceResource = sourceFolder.getResource();
if (sourceResource != null) {
getResourceModifications().addCopyDelta(sourceResource, resourceArgs);
IFile classpath = getClasspathFile((IResource) resourceArgs.getDestination());
if (classpath != null) {
getResourceModifications().addChanged(classpath);
}
}
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project che by eclipse.
the class CopyModifications method copy.
public void copy(ICompilationUnit unit, CopyArguments javaArgs, CopyArguments resourceArgs) {
add(unit, javaArgs, null);
ResourceMapping mapping = JavaElementResourceMapping.create(unit);
if (mapping != null) {
add(mapping, resourceArgs, null);
}
if (unit.getResource() != null) {
getResourceModifications().addCopyDelta(unit.getResource(), resourceArgs);
}
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project che by eclipse.
the class CreateCopyOfCompilationUnitChange method perform.
@Override
public Change perform(IProgressMonitor monitor) throws CoreException {
ResourceMapping mapping = JavaElementResourceMapping.create(fOldCu);
final Change result = super.perform(monitor);
markAsExecuted(fOldCu, mapping);
return result;
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project yamcs-studio by yamcs.
the class OpenActionProvider method addOpenWithMenu.
private void addOpenWithMenu(IMenuManager aMenu) {
IStructuredSelection ss = (IStructuredSelection) getContext().getSelection();
if (ss == null || ss.size() != 1) {
return;
}
Object o = ss.getFirstElement();
// first try IResource
IAdaptable openable = Adapters.adapt(o, IResource.class);
// otherwise try ResourceMapping
if (openable == null) {
openable = Adapters.adapt(o, ResourceMapping.class);
} else if (((IResource) openable).getType() != IResource.FILE) {
openable = null;
}
if (openable != null) {
IMenuManager submenu = new MenuManager("Open With", ICommonMenuConstants.GROUP_OPEN_WITH);
submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
submenu.add(new OpenWithMenu(viewSite.getPage(), openable));
submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS));
if (submenu.getItems().length > 2 && submenu.isEnabled()) {
aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
}
}
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project polymap4-core by Polymap4.
the class ResourceMappingPropertyTester method test.
public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
if (!(receiver instanceof ResourceMapping))
return false;
if (!method.equals(PROJECT_PERSISTENT_PROPERTY))
return false;
// Note: we currently say the test is satisfied if any project associated
// with the mapping satisfies the test.
IProject[] projects = ((ResourceMapping) receiver).getProjects();
if (projects.length == 0)
return false;
String propertyName;
String expectedVal;
if (args.length == 0) {
propertyName = toString(expectedValue);
// any value will do
expectedVal = null;
} else if (args.length == 1) {
propertyName = toString(args[0]);
// any value will do
expectedVal = null;
} else {
propertyName = toString(args[0]);
expectedVal = toString(args[1]);
}
QualifiedName key = toQualifedName(propertyName);
boolean found = false;
for (int i = 0; i < projects.length; i++) {
try {
Object actualVal = projects[i].getPersistentProperty(key);
// the value is not set, so keep looking on other projects
if (actualVal == null)
continue;
// record that we have found at least one value
found = true;
// expected value of null means we expect *any* value, rather than expecting no value
if (expectedVal == null)
continue;
// if the value we find does not match, then the property is not satisfied
if (!expectedVal.equals(actualVal.toString()))
return false;
} catch (CoreException e) {
// ignore
}
}
// if any projects had the property set, the condition is satisfied
return found;
}
Aggregations