List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:com.google.dart.eclipse.wizards.ProjectComposite.java
License:Open Source License
protected AbstractSample getCurrentSample() { if (addSampleContentCheckbox.getSelection()) { IStructuredSelection selection = (IStructuredSelection) samplesListViewer.getSelection(); if (selection.isEmpty()) { return null; } else {/* w ww. j ava2 s . c om*/ return (AbstractSample) selection.getFirstElement(); } } else { return null; } }
From source file:com.google.dart.eclipse.wizards.SamplesComposite.java
License:Open Source License
protected AbstractSample getCurrentSample() { if (addSampleContentCheckbox.getSelection()) { IStructuredSelection selection = (IStructuredSelection) samplesViewer.getSelection(); if (selection.isEmpty()) { return null; } else {/*from w ww . jav a 2 s. c o m*/ return (AbstractSample) selection.getFirstElement(); } } else { return null; } }
From source file:com.google.dart.tools.debug.ui.internal.util.LaunchUtils.java
License:Open Source License
public static IResource getSelectedResource(IWorkbenchWindow window) { IWorkbenchPage page = window.getActivePage(); if (page == null) { return null; }/* ww w. j a va 2 s . c o m*/ IWorkbenchPart part = page.getActivePart(); if (part instanceof IEditorPart) { IEditorPart epart = (IEditorPart) part; return (IResource) epart.getEditorInput().getAdapter(IResource.class); } else if (part != null) { IWorkbenchPartSite site = part.getSite(); if (site != null) { ISelectionProvider provider = site.getSelectionProvider(); if (provider != null) { ISelection selection = provider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (!ss.isEmpty()) { Iterator<?> iterator = ss.iterator(); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof DartElement) { next = ((DartElement) next).getResource(); } if (next instanceof IResource) { return (IResource) next; } else if (next != null) { IResource resource = (IResource) Platform.getAdapterManager().getAdapter(next, IResource.class); if (resource != null) { return resource; } } } } } } } } if (page.getActiveEditor() != null) { return (IResource) page.getActiveEditor().getEditorInput().getAdapter(IResource.class); } return null; }
From source file:com.google.dart.tools.debug.ui.internal.view.ShowInspectorAction.java
License:Open Source License
@Override public synchronized void run() { IStructuredSelection sel = selectionProvider.getCurrentSelection(); if (sel != null && !sel.isEmpty()) { Object obj = sel.getFirstElement(); if (obj instanceof IVariable) { try { obj = ((IVariable) obj).getValue(); } catch (DebugException e) { }/*from w w w. j a v a 2 s. c o m*/ } if (obj instanceof IValue) { ObjectInspectorView.inspect((IValue) obj); return; } } DartToolsPlugin.showView("com.google.dart.tools.debug.objectInspectorView"); }
From source file:com.google.dart.tools.internal.corext.refactoring.RefactoringAvailabilityTester.java
License:Open Source License
public static boolean isConvertMethodToGetterAvailable(IStructuredSelection selection) throws DartModelException { if (selection.isEmpty() || selection.size() != 1) { return false; }/* w w w . j av a 2 s . co m*/ Object first = selection.getFirstElement(); return first instanceof Method && isConvertMethodToGetterAvailable((Method) first); }
From source file:com.google.dart.tools.internal.corext.refactoring.RefactoringAvailabilityTester.java
License:Open Source License
public static boolean isInlineMethodAvailable(IStructuredSelection selection) throws DartModelException { if (selection.isEmpty() || selection.size() != 1) { return false; }//from w w w. jav a 2 s. c om Object first = selection.getFirstElement(); return first instanceof Method && isInlineMethodAvailable((Method) first); }
From source file:com.google.dart.tools.internal.search.ui.text.FileSearchPage.java
License:Open Source License
@Override protected void fillContextMenu(IMenuManager mgr) { super.fillContextMenu(mgr); addSortActions(mgr);//from w w w .j av a 2 s. com fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection())); fActionGroup.fillContextMenu(mgr); FileSearchQuery query = (FileSearchQuery) getInput().getQuery(); if (query.getSearchString().length() > 0) { IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection(); if (!selection.isEmpty()) { ReplaceAction replaceSelection = new ReplaceAction(getSite().getShell(), (FileSearchResult) getInput(), selection.toArray()); replaceSelection.setText(SearchMessages.ReplaceAction_label_selected); mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection); } ReplaceAction replaceAll = new ReplaceAction(getSite().getShell(), (FileSearchResult) getInput(), null); replaceAll.setText(SearchMessages.ReplaceAction_label_all); mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll); } }
From source file:com.google.dart.tools.search.internal.ui.text.NewTextSearchActionGroup.java
License:Open Source License
@Override public void fillContextMenu(IMenuManager menu) { ISelection selection = getContext().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (!ss.isEmpty()) { addOpenMenu(menu, ss);//from ww w.ja va2 s .co m } } }
From source file:com.google.dart.tools.ui.actions.CleanFoldersAction.java
License:Open Source License
@Override public void selectionChanged(IStructuredSelection selection) { if (!selection.isEmpty() && allSelectedAreProjects(selection)) { setEnabled(true);/* w w w . j a v a2 s.c om*/ return; } setEnabled(false); }
From source file:com.google.dart.tools.ui.actions.CleanFoldersAction.java
License:Open Source License
@Override protected void doRun(IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) { if (!selection.isEmpty()) { List<IProject> projects = new ArrayList<IProject>(); List<String> projectLoc = new ArrayList<String>(); for (Object sel : selection.toArray()) { projects.add((IProject) sel); projectLoc.add(((IProject) sel).getLocation().toOSString()); }//w w w . j a va 2 s.co m if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { DartCore.getAnalysisServer().analysis_reanalyze(projectLoc); } else { CleanLibrariesJob job = new CleanLibrariesJob(projects); job.schedule(); } } }