Java Code Examples for org.eclipse.jface.viewers.IStructuredSelection#isEmpty()
The following examples show how to use
org.eclipse.jface.viewers.IStructuredSelection#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssignWorkingSetsAction.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public boolean updateSelection(IStructuredSelection selection) { if (selection == null || selection.isEmpty()) { return false; } final Object[] selectedElements = selection.toArray(); final IProject[] selectedProjects = Arrays2.filter(selectedElements, IProject.class); // only enable this action for project-only selections if (selectedElements.length != selectedProjects.length) { return false; } // also check whether the active manager is {@link ManualAssociationAwareWorkingSetManager} if (!(broker.getActiveManager() instanceof ManualAssociationAwareWorkingSetManager)) { return false; } else { return true; } }
Example 2
Source File: RulePreferencePage.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void exportAll() { // save selection IStructuredSelection selectionSave= (IStructuredSelection)tableViewer.getSelection(); // select all tableViewer.getTable().selectAll(); IStructuredSelection selection= (IStructuredSelection)tableViewer.getSelection(); if(selection.isEmpty()) { MessageDialog.openError(getShell(), LogViewerPlugin.getResourceString("preferences.ruleseditor.export.error.title"), //$NON-NLS-1$ LogViewerPlugin.getResourceString("preferences.ruleseditor.export.error.select.items.text")); //$NON-NLS-1$ return; } else { //export Collection<RulePreferenceData> itemArray= new ArrayList<RulePreferenceData>(); itemArray.addAll(selection.toList()); export(itemArray.toArray(new RulePreferenceData[itemArray.size()])); } // restore selection tableViewer.setSelection(selectionSave, true); }
Example 3
Source File: NavigatorCommonViewer.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void expandAll() { getControl().setRedraw(false); NavigatorContentProvider.FILE_CHILDREN_ENABLED = false; final IStructuredSelection currentSelection = (IStructuredSelection) getSelection(); if (currentSelection == null || currentSelection.isEmpty()) { super.expandAll(); } else { final Iterator<?> it = currentSelection.iterator(); while (it.hasNext()) { final Object o = it.next(); if (o instanceof TopLevelFolder) { expandToLevel(o, CommonViewer.ALL_LEVELS); // 2 } else if (o instanceof IContainer) { expandToLevel(o, CommonViewer.ALL_LEVELS); } } } NavigatorContentProvider.FILE_CHILDREN_ENABLED = true; this.refresh(false); getControl().setRedraw(true); }
Example 4
Source File: TextSpanLinkHelper.java From typescript.java with MIT License | 6 votes |
private NavigationTextSpan getSpan(IStructuredSelection selection) { if (selection.isEmpty()) { return null; } Object element = selection.getFirstElement(); if (element instanceof NavigationTextSpan) { return (NavigationTextSpan) element; } if (element instanceof NavigationBarItem) { NavigationBarItem item = (NavigationBarItem) element; if (item.hasSpans()) { return item.getSpans().get(0); } } return null; }
Example 5
Source File: RunCamelProcess.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public void init(TreeViewer viewer, IStructuredSelection selection) { boolean canWork = !selection.isEmpty() && selection.size() == 1; // if // (DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().isUserReadOnlyOnCurrentProject()) // { // canWork = false; // } if (canWork) { Object o = selection.getFirstElement(); RepositoryNode node = (RepositoryNode) o; switch (node.getType()) { case REPOSITORY_ELEMENT: if (node.getParent() == null || node.getParent().getContentType() != CamelRepositoryNodeType.repositoryRoutesType) { canWork = false; } // Avoid showing in route test case if (node.getObjectType().getType().equals(TEST_CONTAINER)) { canWork = false; } break; default: canWork = false; } RepositoryNode parent = node.getParent(); if (canWork && parent != null && parent instanceof BinRepositoryNode) { canWork = false; } } setEnabled(canWork); }
Example 6
Source File: ProjectSelectorSelectionChangedListener.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override public void selectionChanged(SelectionChangedEvent event) { projectSelector.clearStatusLink(); latestQueryJob = null; IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.isEmpty()) { return; } GcpProject project = (GcpProject) selection.getFirstElement(); String email = accountSelector.getSelectedEmail(); String createAppLink = MessageFormat.format(CREATE_APP_LINK, project.getId(), UrlEscapers.urlFormParameterEscaper().escape(email)); boolean queryCached = project.hasAppEngineInfo(); if (queryCached) { if (project.getAppEngine() == AppEngine.NO_APPENGINE_APPLICATION) { projectSelector.setStatusLink( Messages.getString("projectselector.missing.appengine.application.link", createAppLink), createAppLink /* tooltip */); } } else { // The project has never been queried. Credential credential = accountSelector.getSelectedCredential(); Predicate<Job> isLatestQueryJob = job -> job == latestQueryJob; latestQueryJob = new AppEngineApplicationQueryJob(project, credential, projectRepository, projectSelector, createAppLink, isLatestQueryJob); latestQueryJob.schedule(); } }
Example 7
Source File: JimpleContentOutlinePage.java From JAADAS with GNU General Public License v3.0 | 5 votes |
public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection)event.getSelection(); if (!selection.isEmpty()) { Object elem = selection.getFirstElement(); if (elem instanceof JimpleOutlineObject) { String toHighlight = ((JimpleOutlineObject)elem).getLabel(); int start = getJimpleFileParser().getStartOfSelected(toHighlight); int length = getJimpleFileParser().getLength(toHighlight); getEd().selectAndReveal(start, length); } } }
Example 8
Source File: MoveAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IMember[] getSelectedMembers(IStructuredSelection selection){ if (selection.isEmpty()) return null; for (Iterator<?> iter= selection.iterator(); iter.hasNext(); ) { if (! (iter.next() instanceof IMember)) return null; } return convertToMemberArray(selection.toArray()); }
Example 9
Source File: TreeMapper.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) */ @SuppressWarnings("unchecked") public void setSelection(ISelection selection) { IStructuredSelection strSelection = (IStructuredSelection)selection; if (strSelection.isEmpty()) { currentSelection = new StructuredSelection(); fireMouseExited(selectedMapping, mappingsToFigures.get(selectedMapping)); } else { M mapping = (M) strSelection.getFirstElement(); fireMappingSelection(mapping, mappingsToFigures.get(mapping)); } }
Example 10
Source File: ModifyParametersAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IMethod getSingleSelectedMethod(IStructuredSelection selection){ if (selection.isEmpty() || selection.size() != 1) return null; if (selection.getFirstElement() instanceof IMethod) return (IMethod)selection.getFirstElement(); return null; }
Example 11
Source File: TLCErrorView.java From tlaplus with MIT License | 5 votes |
private void handleValueViewerUpdate(final IStructuredSelection structuredSelection) { if (!structuredSelection.isEmpty()) { // Set selection to the selected element (or the first if there are multiple // selections), and show its string representation in the value viewer (the lower sub-window). final Object selection = structuredSelection.getFirstElement(); if (selection instanceof TLCState) { final TLCState state; if ((filteredStateIndexMap.size() != 0) && !valueReflectsFiltering.getSelection()) { final Integer index = filteredStateIndexMap.get(selection); if (index != null) { state = unfilteredInput.getStates(TLCError.Length.ALL).get(index.intValue()); } else { TLCUIActivator.getDefault().logWarning("Could not find mapped index for state."); state = (TLCState) selection; } } else { state = (TLCState) selection; } valueViewer.setDocument(new Document(state.getConjunctiveDescription(true))); } else { valueViewer.setDocument(new Document(selection.toString())); } } else { valueViewer.setDocument(NO_VALUE_DOCUMENT()); } }
Example 12
Source File: OpenAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean checkEnabled(IStructuredSelection selection) { if (selection.isEmpty()) return false; for (Iterator<?> iter= selection.iterator(); iter.hasNext();) { Object element= iter.next(); if (element instanceof ISourceReference) continue; if (element instanceof IFile) continue; if (JavaModelUtil.isOpenableStorage(element)) continue; return false; } return true; }
Example 13
Source File: DotnetExportWizardPage.java From aCute with Eclipse Public License 2.0 | 5 votes |
public String getTargetFramework() { IStructuredSelection selection = (IStructuredSelection) frameworkViewer.getSelection(); if (selection.isEmpty()) { return ""; //$NON-NLS-1$ } return (String) selection.getFirstElement(); }
Example 14
Source File: MoveAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IMethod getSingleSelectedMethod(IStructuredSelection selection) { if (selection.isEmpty() || selection.size() != 1) return null; Object first= selection.getFirstElement(); if (! (first instanceof IMethod)) return null; return (IMethod) first; }
Example 15
Source File: CutAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(IStructuredSelection selection) { if (!selection.isEmpty()) { // cannot cut top-level types. this deletes the cu and then you cannot paste because the cu is gone. if (!containsOnlyElementsInsideCompilationUnits(selection) || containsTopLevelTypes(selection)) { setEnabled(false); return; } fCopyToClipboardAction.selectionChanged(selection); setEnabled(fCopyToClipboardAction.isEnabled() && RefactoringAvailabilityTester.isDeleteAvailable(selection)); } else setEnabled(false); }
Example 16
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Gets the first selected edit part in layout editor. Whenever the user has * deselected all edit parts, the contents edit part should be returned. * * @return the first selected EditPart or root edit part */ public static EditPart getCurrentEditPart( ) { EditPartViewer viewer = getLayoutEditPartViewer( ); if ( viewer == null ) return null; IStructuredSelection targets = (IStructuredSelection) viewer.getSelection( ); if ( targets.isEmpty( ) ) return null; return (EditPart) targets.getFirstElement( ); }
Example 17
Source File: InsertCubeInLayoutAction.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean canDrop( Object transfer, Object target ) { if ( target != null && transfer instanceof CubeHandle ) { SlotHandle targetSlot = getTargetSlotHandle( target, ICrosstabConstants.CROSSTAB_EXTENSION_NAME ); //$NON-NLS-1$ if ( targetSlot != null ) { if ( DNDUtil.handleValidateTargetCanContainType( targetSlot, "Crosstab" ) && DNDUtil.handleValidateTargetCanContainMore( targetSlot, 0 ) ) return true; } else { IStructuredSelection models = InsertInLayoutUtil.editPart2Model( new StructuredSelection( target ) ); if ( !models.isEmpty( ) ) { Object model = DNDUtil.unwrapToModel( models.getFirstElement( ) ); if ( model instanceof DesignElementHandle ) { DesignElementHandle targetHandle = (DesignElementHandle) model; if ( targetHandle.canContain( DEUtil.getDefaultContentName( targetHandle ), ICrosstabConstants.CROSSTAB_EXTENSION_NAME ) ) return true; } } } } return false; }
Example 18
Source File: XViewerCustomizeDialog.java From nebula with Eclipse Public License 2.0 | 5 votes |
private CustomizeData getCustTableSelection() { IStructuredSelection selection = (IStructuredSelection) custTable.getViewer().getSelection(); if (selection.isEmpty()) { return null; } Iterator<?> i = selection.iterator(); return (CustomizeData) i.next(); }
Example 19
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isInlineMethodAvailable(final IStructuredSelection selection) throws JavaModelException { if (selection.isEmpty() || selection.size() != 1) return false; final Object first= selection.getFirstElement(); return (first instanceof IMethod) && isInlineMethodAvailable(((IMethod) first)); }
Example 20
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isIntroduceIndirectionAvailable(final IStructuredSelection selection) throws JavaModelException { if (selection.isEmpty() || selection.size() != 1) return false; final Object first= selection.getFirstElement(); return (first instanceof IMethod) && isIntroduceIndirectionAvailable(((IMethod) first)); }