List of usage examples for org.eclipse.jface.viewers StructuredSelection size
@Override public int size()
From source file:org.eclipse.php.composer.ui.editor.composer.DependencySection.java
License:Open Source License
@SuppressWarnings("unchecked") private void handleUpdate() { StructuredSelection selection = ((StructuredSelection) dependencyViewer.getSelection()); Iterator<Object> it = selection.iterator(); String[] names = new String[selection.size()]; List<VersionedPackage> deps = new ArrayList<VersionedPackage>(); for (int i = 0; it.hasNext(); i++) { VersionedPackage dep = (VersionedPackage) it.next(); deps.add(dep);/*from w w w . j av a 2 s.co m*/ names[i] = dep.getName(); } updateJob.setPackages(names); updateJob.schedule(); }
From source file:org.eclipse.php.composer.ui.editor.composer.RepositoriesSection.java
License:Open Source License
@SuppressWarnings("unchecked") private void handleRemove() { StructuredSelection selection = ((StructuredSelection) repositoryViewer.getSelection()); Iterator<Object> it = selection.iterator(); String[] names = new String[selection.size()]; List<Repository> repos = new ArrayList<Repository>(); for (int i = 0; it.hasNext(); i++) { Repository repo = (Repository) it.next(); repos.add(repo);//from w ww.j ava 2s . c o m names[i] = repo.getName(); } String title = selection.size() > 1 ? Messages.RepositoriesSection_RemoveDialogTitlePlural : Messages.RepositoriesSection_RemoveDialogTitle; MessageDialog diag = new MessageDialog(repositoryViewer.getTable().getShell(), title, null, NLS.bind(Messages.RepositoriesSection_RemoveDialogMessage, StringUtils.join(names, ", ")), //$NON-NLS-1$ MessageDialog.WARNING, new String[] { Messages.RepositoriesSection_YesButton, Messages.RepositoriesSection_NoButton }, 0); if (diag.open() == Dialog.OK) { for (Repository repo : repos) { composerPackage.getRepositories().remove(repo); } } }
From source file:org.eclipse.plugin.worldwind.wizard.WeatherWizardPage.java
License:Open Source License
private void handleListSelection(StructuredSelection selection) { try {/*w w w .jav a2s. c o m*/ // clear any error messages setErrorMessage(null); int selectedIdx = combo.getSelectionIndex(); dataSets = new ParserUtils.HTTPDataSet[selection.size()]; logger.debug("selectionChanged " + selection + " combo idx=" + selectedIdx); int i = 0, j = 0; if (selectedIdx == 0) { // navy: add selected datasets to instance var dataSets for (Object element : selection.toArray()) { j = 0; for (ParserUtils.HTTPDataSet ds : nrl) { if (ds.name.equals((String) element)) { logger.debug("Adding NRL dataset " + nrl.get(j).name); dataSets[i] = nrl.get(j); break; } j++; } i++; } } else { // GOES: add goes data to instance for (Object element : selection.toArray()) { j = 0; for (ParserUtils.HTTPDataSet ds : goes) { if (ds.name.equals((String) element)) { logger.debug("Adding GOES dataset " + goes.get(j).name); dataSets[i] = goes.get(j); break; } j++; } i++; } } loadNextPage(); setPageComplete(true); } catch (Exception e) { //e.printStackTrace(); setErrorMessage(e.getClass().getName() + ": " + e.getMessage()); setPageComplete(false); } }
From source file:org.eclipse.scout.rt.ui.rap.basic.tree.RwtScoutTree.java
License:Open Source License
/** * @param event/*from w w w. j ava 2s . co m*/ */ private void handleUiDoubleClick(StructuredSelection sel) { @SuppressWarnings("unchecked") ITreeNode[] nodes = (ITreeNode[]) sel.toList().toArray(new ITreeNode[sel.size()]); if (nodes != null && nodes.length == 1) { // if not leaf expand collapse if (!nodes[0].isLeaf()) { // invert expansion setExpansionFromUi(nodes[0], !getUiTreeViewer().getExpandedState(nodes[0])); } else { handleUiNodeAction(nodes[0]); if (getScoutObject().isCheckable()) { handleUiNodeClick(nodes[0]); } } } }
From source file:org.eclipse.scout.rt.ui.rap.util.RwtUtility.java
License:Open Source License
@SuppressWarnings("unchecked") public static <T> T[] getItemsOfSelection(Class<T> t, StructuredSelection selection) { T[] result = (T[]) Array.newInstance(t, selection.size()); int i = 0;//w w w. j a va 2 s. c o m for (Object o : selection.toArray()) { result[i++] = (T) o; } return result; }
From source file:org.eclipse.sirius.diagram.ui.tools.api.properties.MiscPropertySection.java
License:Open Source License
/** * {@inheritDoc}// www .ja v a 2 s . c om * * @see org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, * org.eclipse.jface.viewers.ISelection) */ @Override public void setInput(final IWorkbenchPart part, final ISelection selection) { if (selection.isEmpty() || !(selection instanceof StructuredSelection)) { super.setInput(part, selection); return; } final StructuredSelection structuredSelection = (StructuredSelection) selection; final ArrayList<Object> transformedSelection = new ArrayList<Object>(structuredSelection.size()); final Iterator<?> it = structuredSelection.iterator(); while (it.hasNext()) { final Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.properties.ExtensionSemanticPropertiesSection.java
License:Open Source License
/** * {@inheritDoc}//from ww w .j av a 2 s .com * * @see org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, * org.eclipse.jface.viewers.ISelection) */ @Override public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) { this.part = workbenchPart; if (selection.isEmpty() || !(selection instanceof StructuredSelection)) { super.setInput(workbenchPart, selection); return; } final StructuredSelection structuredSelection = (StructuredSelection) selection; transformedSelection = new ArrayList<Object>(structuredSelection.size()); final Iterator<?> it = structuredSelection.iterator(); while (it.hasNext()) { final Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } super.setInput(workbenchPart, new StructuredSelection(transformedSelection)); }
From source file:org.eclipse.sirius.tests.swtbot.EdgeWithMultipleLabelsTest.java
License:Open Source License
private void validateSelectedLabel(String label, Class<? extends EditPart> labelClass) { StructuredSelection selection = (StructuredSelection) editor.getSelection(); Assert.assertEquals(1, selection.size()); Assert.assertTrue(labelClass.isInstance(selection.getFirstElement())); Assert.assertEquals(label, ((AbstractDEdgeNameEditPart) selection.getFirstElement()).getEditText()); }
From source file:org.eclipse.sirius.tests.swtbot.layout.EdgeWithPathLayoutTest.java
License:Open Source License
protected ConnectionEditPart getSelectedConnection() { ISelection selection = editor.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof ConnectionEditPart) { return (ConnectionEditPart) structuredSelection.getFirstElement(); }// w ww . ja v a2 s . c o m } return null; }
From source file:org.eclipse.sirius.tests.swtbot.sequence.AbstractSequenceDiagramTestCase.java
License:Open Source License
protected SequenceMessageEditPart getSelectedMessage() { ISelection selection = editor.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof SequenceMessageEditPart) { return (SequenceMessageEditPart) structuredSelection.getFirstElement(); }// www. jav a 2 s .c o m } return null; }