List of usage examples for org.eclipse.jface.viewers StructuredSelection EMPTY
StructuredSelection EMPTY
To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.
Click Source Link
From source file:it.eng.spagobi.meta.editor.business.BusinessModelEditor.java
License:Mozilla Public License
/** * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the current one. *///from w w w . j a v a 2 s . c o m public void setCurrentViewer(Viewer viewer) { // If it is changing... if (currentViewer != viewer) { if (selectionChangedListener == null) { // Create the listener on demand. selectionChangedListener = new ISelectionChangedListener() { // This just notifies those things that are affected by the section. @Override public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { selectionProvider.setSelection(selectionChangedEvent.getSelection()); } }; } // Stop listening to the old one. if (currentViewer != null) { currentViewer.removeSelectionChangedListener(selectionChangedListener); } // Start listening to the new one. if (viewer != null) { viewer.addSelectionChangedListener(selectionChangedListener); } // Remember it. // currentViewer = viewer; // Set the editors selection based on the current viewer's selection. selectionProvider .setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); } }
From source file:joachimeichborn.geotag.ui.parts.PicturesView.java
License:Open Source License
private void initializePictureList(final Composite aParent) { pictureViewer = new TableViewer(aParent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER); pictureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); pictureViewer.getTable().setHeaderVisible(true); final PictureViewerComparator comparator = new PictureViewerComparator(); pictureViewer.setComparator(comparator); for (final String columnHeader : COLUMNS) { final TableViewerColumn viewverColumn = new TableViewerColumn(pictureViewer, SWT.NONE); final TableColumn column = viewverColumn.getColumn(); column.setWidth(100);/*from ww w . j av a2 s . c o m*/ column.setText(columnHeader); column.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent aEvent) { comparator.setColumn(columnHeader); pictureViewer.getTable().setSortDirection(comparator.getDirection()); pictureViewer.getTable().setSortColumn(column); pictureViewer.refresh(); } }); } pictureViewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent aEvent) { switch (aEvent.character) { case 0x01: { pictureViewer.setSelection(new StructuredSelection(picturesRepo.getPictures())); break; } case SWT.DEL: { final PictureSelection selectedPictures = new PictureSelection( pictureViewer.getStructuredSelection()); pictureViewer.setSelection(StructuredSelection.EMPTY); picturesRepo.removePictures(selectedPictures.getSelection()); break; } } } }); bindPictureViewer(); pictureViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); logger.fine("Selected " + selection.size() + " pictures"); final PictureSelection pictures = new PictureSelection(selection); selectionService.setSelection(pictures); } }); }
From source file:joachimeichborn.geotag.ui.parts.TracksView.java
License:Open Source License
private void initializeTracksList(final Composite aParent) { trackViewer = new TableViewer(aParent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER); trackViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); trackViewer.getTable().setHeaderVisible(true); final TrackViewerComparator comparator = new TrackViewerComparator(); trackViewer.setComparator(comparator); for (final String columnHeader : COLUMNS) { final TableViewerColumn viewerColumn = new TableViewerColumn(trackViewer, SWT.NONE); final TableColumn column = viewerColumn.getColumn(); column.setWidth(100);//from w w w . j a va 2s.co m column.setText(columnHeader); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent aEvent) { comparator.setColumn(columnHeader); trackViewer.getTable().setSortDirection(comparator.getDirection()); trackViewer.getTable().setSortColumn(column); trackViewer.refresh(); } }); } trackViewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent aEvent) { switch (aEvent.character) { case 0x01: { trackViewer.setSelection(new StructuredSelection(tracksRepo.getTracks())); break; } case SWT.DEL: { final TrackSelection selectedTracks = new TrackSelection(trackViewer.getStructuredSelection()); trackViewer.setSelection(StructuredSelection.EMPTY); tracksRepo.removeTracks(selectedTracks.getSelection()); break; } } } }); bindTracksViewer(); trackViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); LOGGER.fine("Selected " + selection.size() + " tracks"); final TrackSelection tracks = new TrackSelection(selection); selectionService.setSelection(tracks); } }); }
From source file:melnorme.lang.ide.ui.editor.structure.AbstractContentOutlinePage.java
License:Open Source License
@Override public ISelection getSelection() { if (treeViewer == null) { return StructuredSelection.EMPTY; }//ww w .j av a 2 s. c o m return treeViewer.getSelection(); }
From source file:melnorme.lang.ide.ui.editor.structure.AbstractLangStructureEditor.java
License:Open Source License
public StructuredSelection getSelectedElementAsStructureSelection() { StructureElement selectedElement = getSelectedElement(); if (selectedElement == null) { return StructuredSelection.EMPTY; }//from w w w. j av a 2s . co m return new StructuredSelection(selectedElement); }
From source file:mil.jpeojtrs.sca.dcd.diagram.part.DcdNewDiagramFileWizard.java
License:Open Source License
/** * @generated/*from www . j a v a 2 s .c o m*/ */ public DcdNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) { assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$ myFileCreationPage = new WizardNewFileCreationPage(Messages.DcdNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); myFileCreationPage.setTitle(Messages.DcdNewDiagramFileWizard_CreationPageTitle); myFileCreationPage.setDescription(NLS.bind(Messages.DcdNewDiagramFileWizard_CreationPageDescription, DeviceConfigurationEditPart.MODEL_ID)); IPath filePath; String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment()); if (domainModelURI.isPlatformResource()) { filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true)); } else if (domainModelURI.isFile()) { filePath = new Path(domainModelURI.trimSegments(1).toFileString()); } else { // TODO : use some default path throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$ } myFileCreationPage.setContainerFullPath(filePath); myFileCreationPage.setFileName(DcdDiagramEditorUtil.getUniqueFileName(filePath, fileName, "dcd_diagramV2")); //$NON-NLS-1$ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage( Messages.DcdNewDiagramFileWizard_RootSelectionPageName); diagramRootElementSelectionPage.setTitle(Messages.DcdNewDiagramFileWizard_RootSelectionPageTitle); diagramRootElementSelectionPage .setDescription(Messages.DcdNewDiagramFileWizard_RootSelectionPageDescription); diagramRootElementSelectionPage.setModelElement(diagramRoot); myEditingDomain = editingDomain; }
From source file:mil.jpeojtrs.sca.sad.diagram.part.SadNewDiagramFileWizard.java
License:Open Source License
/** * @generated//from www .j av a 2 s .c om */ public SadNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) { assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$ myFileCreationPage = new WizardNewFileCreationPage(Messages.SadNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); myFileCreationPage.setTitle(Messages.SadNewDiagramFileWizard_CreationPageTitle); myFileCreationPage.setDescription(NLS.bind(Messages.SadNewDiagramFileWizard_CreationPageDescription, SoftwareAssemblyEditPart.MODEL_ID)); IPath filePath; String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment()); if (domainModelURI.isPlatformResource()) { filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true)); } else if (domainModelURI.isFile()) { filePath = new Path(domainModelURI.trimSegments(1).toFileString()); } else { // TODO : use some default path throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$ } myFileCreationPage.setContainerFullPath(filePath); myFileCreationPage.setFileName(SadDiagramEditorUtil.getUniqueFileName(filePath, fileName, "sad_diagramV2")); //$NON-NLS-1$ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage( Messages.SadNewDiagramFileWizard_RootSelectionPageName); diagramRootElementSelectionPage.setTitle(Messages.SadNewDiagramFileWizard_RootSelectionPageTitle); diagramRootElementSelectionPage .setDescription(Messages.SadNewDiagramFileWizard_RootSelectionPageDescription); diagramRootElementSelectionPage.setModelElement(diagramRoot); myEditingDomain = editingDomain; }
From source file:net.bioclipse.cdk.jchempaint.view.JChemPaintView.java
License:Open Source License
public ISelection getSelection() { ICDKMolecule mol;//w ww . ja v a2 s . co m try { mol = new CDKMolecule((IAtomContainer) ac.clone()); return new StructuredSelection(mol); } catch (CloneNotSupportedException e) { logger.debug("Could not clone atomcontainer"); } return StructuredSelection.EMPTY; }
From source file:net.bioclipse.cdk.jchempaint.widgets.JChemPaintEditorWidget.java
License:Open Source License
public ISelection getSelection() { RendererModel rendererModel = getRenderer2DModel(); if (rendererModel == null) if (source != null) return new StructuredSelection(source); else/* w w w .ja v a 2 s .c o m*/ return StructuredSelection.EMPTY; List<CDKChemObject<?>> selection = new LinkedList<CDKChemObject<?>>(); IChemObjectSelection sel = rendererModel.getSelection(); IAtomContainer modelSelection = sel.getConnectedAtomContainer(); if (modelSelection != null) { for (IAtom atom : modelSelection.atoms()) { selection.add(createCDKChemObject(atom)); } for (IBond bond : modelSelection.bonds()) { selection.add(createCDKChemObject(bond)); } } if (selection.isEmpty() && source != null) { return new StructuredSelection(source); } return new StructuredSelection(selection); }
From source file:net.bioclipse.cdk.ui.actions.CreateSmilesAction.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection sel) { if (sel instanceof IStructuredSelection) selection = (IStructuredSelection) sel; else//from w ww .j a va 2s. c om selection = StructuredSelection.EMPTY; }