use of org.eclipse.core.runtime.IAdaptable in project che by eclipse.
the class JavaSearchScopeFactory method addJavaElements.
private void addJavaElements(Set<IJavaElement> javaElements, IWorkingSet workingSet) {
if (workingSet == null)
return;
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
try {
IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
javaElements.addAll(Arrays.asList(projects));
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return;
}
IAdaptable[] elements = workingSet.getElements();
for (int i = 0; i < elements.length; i++) {
IJavaElement javaElement = (IJavaElement) elements[i].getAdapter(IJavaElement.class);
if (javaElement != null) {
addJavaElements(javaElements, javaElement);
continue;
}
IResource resource = (IResource) elements[i].getAdapter(IResource.class);
if (resource != null) {
addJavaElements(javaElements, resource);
}
// else we don't know what to do with it, ignore.
}
}
use of org.eclipse.core.runtime.IAdaptable in project che by eclipse.
the class Changes method getModifiedFiles.
private static void getModifiedFiles(List<IFile> result, Change[] changes) {
for (int i = 0; i < changes.length; i++) {
Change change = changes[i];
Object modifiedElement = change.getModifiedElement();
if (modifiedElement instanceof IAdaptable) {
IFile file = (IFile) ((IAdaptable) modifiedElement).getAdapter(IFile.class);
if (file != null)
result.add(file);
}
if (change instanceof CompositeChange) {
getModifiedFiles(result, ((CompositeChange) change).getChildren());
}
}
}
use of org.eclipse.core.runtime.IAdaptable in project flux by eclipse.
the class SyncDisconnectHandler method getSelectedProjects.
protected IProject[] getSelectedProjects(ISelection selection) {
List<IProject> selectedProjects = new ArrayList<IProject>();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object[] selectedObjects = structuredSelection.toArray();
for (int i = 0; i < selectedObjects.length; i++) {
if (selectedObjects[i] instanceof IAdaptable) {
IProject project = (IProject) ((IAdaptable) selectedObjects[i]).getAdapter(IProject.class);
if (project != null) {
selectedProjects.add(project);
}
}
}
}
return (IProject[]) selectedProjects.toArray(new IProject[selectedProjects.size()]);
}
use of org.eclipse.core.runtime.IAdaptable in project jop by jop-devel.
the class ToggleJOPNatureAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
if (selection instanceof IStructuredSelection) {
for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext(); ) {
Object element = it.next();
IProject project = null;
if (element instanceof IProject) {
project = (IProject) element;
} else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
}
if (project != null) {
toggleNature(project);
System.err.println(project + " > Nature");
PropertyTester jopPropTest = new JOPNaturePropertyTester();
jopPropTest.test(project, "hasJOPNature", null, null);
}
}
}
}
use of org.eclipse.core.runtime.IAdaptable in project translationstudio8 by heartsome.
the class ProjectExplorer method updateTitle.
/**
* The superclass does not deal with the content description, handle it
* here.
*
* @noreference
*/
public void updateTitle() {
super.updateTitle();
Object input = getCommonViewer().getInput();
if (input == null || input instanceof IAggregateWorkingSet) {
//$NON-NLS-1$
setContentDescription("");
return;
}
if (!(input instanceof IResource)) {
if (input instanceof IAdaptable) {
IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input).getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
setContentDescription(wbadapter.getLabel(input));
return;
}
}
setContentDescription(input.toString());
return;
}
IResource res = (IResource) input;
setContentDescription(res.getName());
}
Aggregations