use of org.eclipse.jface.viewers.IStructuredSelection 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.jface.viewers.IStructuredSelection 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.jface.viewers.IStructuredSelection in project gfm_viewer by satyagraha.
the class GenerateMarkdownPreview method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
LOGGER.fine("");
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
for (@SuppressWarnings("rawtypes") Iterator items = selection.iterator(); items.hasNext(); ) {
Object item = items.next();
if (item instanceof IFile) {
scheduler.generateIFile((IFile) item);
} else if (item instanceof IFolder) {
scheduler.generateIFolder((IFolder) item);
} else {
LOGGER.fine("unexpected selection: " + item);
}
}
return null;
}
use of org.eclipse.jface.viewers.IStructuredSelection in project gfm_viewer by satyagraha.
the class ShowMarkdownFile method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
LOGGER.fine("");
IStructuredSelection structuredSelection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof IFile) {
ViewManager.activateView(event, MarkdownView.ID);
IFile iFile = (IFile) firstElement;
try {
DIManager.getDefault().getInjector(Scope.PAGE).getInstance(ViewerActions.class).showMarkdownFile(iFile);
} catch (IOException e) {
throw new ExecutionException("could not show file", e);
}
} else {
LOGGER.fine("unexpected selection: " + firstElement);
}
return null;
}
use of org.eclipse.jface.viewers.IStructuredSelection in project dbeaver by serge-rider.
the class NavigatorHandlerObjectOpen method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
final IStructuredSelection structSelection = (IStructuredSelection) selection;
for (Iterator<?> iter = structSelection.iterator(); iter.hasNext(); ) {
Object element = iter.next();
DBNNode node = null;
if (element instanceof IResource) {
openResource((IResource) element, HandlerUtil.getActiveWorkbenchWindow(event));
continue;
} else if (element instanceof DBNNode) {
node = (DBNNode) element;
} else {
DBSObject object = RuntimeUtils.getObjectAdapter(element, DBSObject.class);
if (object != null) {
node = getNodeByObject(object);
}
}
if (node != null) {
NavigatorUtils.openNavigatorNode(node, HandlerUtil.getActiveWorkbenchWindow(event));
}
}
}
return null;
}
Aggregations