List of usage examples for org.eclipse.jface.viewers StructuredSelection size
@Override public int size()
From source file:com.svcdelivery.liquibase.eclipse.ui.preferences.LiquibasePreferencePage.java
License:Apache License
private ServiceReference<LiquibaseService> getSelectedLibrary() { ServiceReference<LiquibaseService> ref = null; ISelection selection = versionViewer.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; if (ss.size() == 1) { ref = (ServiceReference<LiquibaseService>) ss.getFirstElement(); }/*from w w w . ja v a2 s .co m*/ } return ref; }
From source file:com.svcdelivery.liquibase.eclipse.ui.preferences.LiquibasePreferencePage.java
License:Apache License
@Override public boolean performOk() { StructuredSelection selection = (StructuredSelection) versionViewer.getSelection(); if (selection.size() == 1) { ServiceReference<LiquibaseService> svc = (ServiceReference<LiquibaseService>) selection .getFirstElement();//from www . ja v a2 s . c o m Activator.getDefault().setDefaultLiquibaseService(svc); } return super.performOk(); }
From source file:com.vectrace.MercurialEclipse.synchronize.actions.MercurialSynchronizePageActionGroup.java
License:Open Source License
private void addUndoMenu(IMenuManager menu) { MenuManager submenu = new MenuManager(Messages.getString("MercurialSynchronizePageActionGroup.Undo"), //$NON-NLS-1$ MercurialEclipsePlugin.getImageDescriptor("undo_edit.gif"), null); //$NON-NLS-1$ menu.insertBefore(ISynchronizePageConfiguration.NAVIGATE_GROUP, submenu); ISelection selection = getContext().getSelection(); if (!(selection instanceof StructuredSelection)) { return;// w w w. j a va 2 s. com } StructuredSelection stSelection = (StructuredSelection) selection; if (stSelection.size() != 1) { return; } Object object = stSelection.iterator().next(); if (object instanceof WorkingChangeSet) { return; } if (object instanceof ChangesetGroup) { ChangesetGroup csGroup = ((ChangesetGroup) object); if (csGroup.getChangesets().isEmpty() || csGroup.getDirection() != Direction.OUTGOING) { return; } HgRoot hgRoot = csGroup.getChangesets().iterator().next().getHgRoot(); menu.insertBefore(ISynchronizePageConfiguration.NAVIGATE_GROUP, new RollbackSynchronizeAction( Messages.getString("MercurialSynchronizePageActionGroup.Rollback"), //$NON-NLS-1$ getConfiguration(), hgRoot, null)); } else if (object instanceof ChangeSet) { ChangeSet changeSet = (ChangeSet) object; if (changeSet.getDirection() != Direction.OUTGOING) { return; } HgRoot hgRoot = changeSet.getHgRoot(); submenu.add( new BackoutSynchronizeAction(Messages.getString("MercurialSynchronizePageActionGroup.Backout"), //$NON-NLS-1$ getConfiguration(), hgRoot, changeSet)); submenu.add(new StripSynchronizeAction(Messages.getString("MercurialSynchronizePageActionGroup.Strip"), //$NON-NLS-1$ getConfiguration(), hgRoot, changeSet)); } }
From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.sheet.EnsembleDescriptionPropertySection.java
License:Open Source License
/** * @generated//www . jav a 2 s .com */ @Override public void setInput(final IWorkbenchPart part, final ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return; } final StructuredSelection structuredSelection = ((StructuredSelection) selection); final ArrayList<Object> transformedSelection = new ArrayList<Object>(structuredSelection.size()); for (final Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { final Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:edu.washington.cs.cupid.usage.events.CupidEventBuilder.java
License:Open Source License
public static CupidEventBuilder contextEvent(final Class<?> view, IWorkbenchPart source, ISelection selection, final Plugin plugin) { Map<String, String> data = Maps.newHashMap(); data.put("empty", Boolean.toString(selection.isEmpty())); data.put("selectionClass", selection.getClass().getName()); if (!selection.isEmpty() && selection instanceof StructuredSelection) { StructuredSelection structured = ((StructuredSelection) selection); data.put("size", Integer.toString(structured.size())); if (structured.getFirstElement() == null) { data.put("dataClass", null); } else {// w w w. j a va 2 s . c o m data.put("dataClass", structured.getFirstElement().getClass().getName()); } } data.put("sourceClass", source.getClass().getName()); data.put("sourceTitle", source.getTitle()); return new CupidEventBuilder(EventConstants.SELECTION_CONTEXT_WHAT, view, plugin).addData(data); }
From source file:es.cv.gvcase.mdt.common.actions.OpenUpperDiagramPopupMenuContributionPolicy.java
License:Open Source License
public boolean appliesTo(ISelection selection, IConfigurationElement configuration) { IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor();//from w w w .j a v a 2 s.c o m if (activeEditor instanceof CachedResourcesDiagramEditor == false && activeEditor instanceof MOSKittMultiPageEditor == false) { return false; } if (selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; if (ss.size() <= 0 || ss.size() > 1) { return false; } Object object = ss.getFirstElement(); if (object instanceof IGraphicalEditPart) { if (((IGraphicalEditPart) object).getNotationView() instanceof Diagram) { Diagram diagram = (Diagram) ((IGraphicalEditPart) object).getNotationView(); if (MultiDiagramUtil.getUpperDiagram(diagram) != null) { return true; } } } } return false; }
From source file:es.cv.gvcase.mdt.common.part.DiagramElementsSelectionPage.java
License:Open Source License
/** * Handle add button selected.//from w w w.j a v a2s .c om */ protected void handleAddButtonSelected() { StructuredSelection selection = getCandidateElementsSelection(); if (selection == null) { return; } if (selection.size() == 1) { Object element = selection.getFirstElement(); if (element instanceof EObject) { addToMemberElements((EObject) element); } } else { for (Object element : selection.toList()) { if (element instanceof EObject) { addToMemberElements((EObject) element); } } } refreshMembersViewer(); refreshCandidatesViewer(); // enable add buttons depending on candidate elements selected selection = getCandidateElementsSelection(); enableAddButtons(selection != null && selection.size() > 0); }
From source file:es.cv.gvcase.mdt.common.part.DiagramElementsSelectionPage.java
License:Open Source License
/** * Handle add referenced elements button selected. *///from w w w . j a va 2 s .c o m protected void handleAddReferencedElementsButtonSelected() { StructuredSelection selection = getCandidateElementsSelection(); if (selection == null) { return; } if (selection.size() == 1) { if (!(selection.getFirstElement() instanceof EObject)) { return; } Object element = selection.getFirstElement(); if (element instanceof EObject) { addToMemberElements((EObject) element); // Add related elements that have to be drawn on diagram addToMemberElements(getReferencedElements((EObject) element)); } } else { for (Object element : selection.toList()) { if (element instanceof EObject) { addToMemberElements((EObject) element); // Add related elements that have to be drawn on diagram addToMemberElements(getReferencedElements((EObject) element)); } } } refreshMembersViewer(); refreshCandidatesViewer(); // enable add buttons depending on candidate elements selected selection = getCandidateElementsSelection(); enableAddButtons(selection != null && selection.size() > 0); }
From source file:es.cv.gvcase.mdt.common.part.DiagramElementsSelectionPage.java
License:Open Source License
/** * Handle add referencing elements button selected. *//*from www . j a v a2s. c o m*/ protected void handleAddReferencingElementsButtonSelected() { StructuredSelection selection = getCandidateElementsSelection(); if (selection == null) { return; } if (selection.size() == 1) { if (!(selection.getFirstElement() instanceof EObject)) { return; } Object element = selection.getFirstElement(); if (element instanceof EObject) { addToMemberElements((EObject) element); // Add related elements that have to be drawn on diagram addToMemberElements(getReferencingElements((EObject) element)); } } else { for (Object element : selection.toList()) { if (element instanceof EObject) { addToMemberElements((EObject) element); // Add related elements that have to be drawn on diagram addToMemberElements(getReferencingElements((EObject) element)); } } } refreshMembersViewer(); refreshCandidatesViewer(); // enable add buttons depending on candidate elements selected selection = getCandidateElementsSelection(); enableAddButtons(selection != null && selection.size() > 0); }
From source file:es.cv.gvcase.mdt.common.part.DiagramElementsSelectionPage.java
License:Open Source License
/** * Handle add all related elements button selected. *///from w w w . j a v a 2 s. c o m protected void handleAddAllRelatedElementsButtonSelected() { StructuredSelection selection = getCandidateElementsSelection(); if (selection == null) { return; } if (selection.size() == 1) { if (!(selection.getFirstElement() instanceof EObject)) { return; } Object element = selection.getFirstElement(); if (element instanceof EObject) { addToMemberElements((EObject) element); // Add related elements that have to be drawn on diagram addToMemberElements(getAllRelatedElements((EObject) element)); } } else { for (Object element : selection.toList()) { if (element instanceof EObject) { // Add related elements that have to be drawn on diagram addToMemberElements(getAllRelatedElements((EObject) element)); } } } refreshMembersViewer(); refreshCandidatesViewer(); // enable add buttons depending on candidate elements selected selection = getCandidateElementsSelection(); enableAddButtons(selection != null && selection.size() > 0); }