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:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ImportTracePackageWizard w = new ImportTracePackageWizard(); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return Boolean.FALSE; }//from w w w. java2 s . c om ISelection currentSelection = HandlerUtil.getCurrentSelection(event); IStructuredSelection sec = StructuredSelection.EMPTY; if (currentSelection instanceof IStructuredSelection) { sec = (IStructuredSelection) currentSelection; } w.init(PlatformUI.getWorkbench(), sec); WizardDialog dialog = new WizardDialog(window.getShell(), w); dialog.open(); return null; }
From source file:fr.inria.linuxtools.tmf.ui.editors.TmfEventsEditor.java
License:Open Source License
/** * @since 2.0//from ww w .j av a 2s .c om */ @Override public ISelection getSelection() { if (fEventsTable == null) { return StructuredSelection.EMPTY; } return fEventsTable.getSelection(); }
From source file:fr.inria.linuxtools.tmf.ui.viewers.events.TmfEventsTable.java
License:Open Source License
/** * Advanced constructor, where we also define which column data to use. * * @param parent//from w ww. j ava 2 s . co m * The parent composite UI object * @param cacheSize * The size of the event table cache * @param columnData * The column data to use for this table */ public TmfEventsTable(final Composite parent, int cacheSize, final ColumnData[] columnData) { super("TmfEventsTable"); //$NON-NLS-1$ fComposite = new Composite(parent, SWT.NONE); final GridLayout gl = new GridLayout(1, false); gl.marginHeight = 0; gl.marginWidth = 0; gl.verticalSpacing = 0; fComposite.setLayout(gl); fSashForm = new SashForm(fComposite, SWT.HORIZONTAL); fSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Create a virtual table final int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION; fTable = new TmfVirtualTable(fSashForm, style); // Set the table layout final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); fTable.setLayoutData(layoutData); // Some cosmetic enhancements fTable.setHeaderVisible(true); fTable.setLinesVisible(true); // Set the columns setColumnHeaders(columnData); // Set the default column field ids if this is not a subclass if (Arrays.equals(columnData, COLUMN_DATA)) { fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP); fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_SOURCE); fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE); fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE); fTable.getColumns()[4].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT); } // Set the frozen row for header row fTable.setFrozenRowCount(1); // Create the header row cell editor createHeaderEditor(); // Handle the table item selection fTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (e.item == null) { return; } updateStatusLine(null); if (fTable.getSelectionIndices().length > 0) { if (e.item.getData(Key.RANK) instanceof Long) { fSelectedRank = (Long) e.item.getData(Key.RANK); fRawViewer.selectAndReveal((Long) e.item.getData(Key.RANK)); } if (e.item.getData(Key.TIMESTAMP) instanceof ITmfTimestamp) { final ITmfTimestamp ts = (ITmfTimestamp) e.item.getData(Key.TIMESTAMP); if (fTable.getSelectionIndices().length == 1) { fSelectedBeginTimestamp = ts; } if (fSelectedBeginTimestamp != null) { if (fSelectedBeginTimestamp.compareTo(ts) <= 0) { broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, fSelectedBeginTimestamp, ts)); if (fTable.getSelectionIndices().length == 2) { updateStatusLine(ts.getDelta(fSelectedBeginTimestamp)); } } else { broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, ts, fSelectedBeginTimestamp)); updateStatusLine(fSelectedBeginTimestamp.getDelta(ts)); } } } else { if (fTable.getSelectionIndices().length == 1) { fSelectedBeginTimestamp = null; } } } if (e.item.getData() != null) { fireSelectionChanged(new SelectionChangedEvent(TmfEventsTable.this, new StructuredSelection(e.item.getData()))); } else { fireSelectionChanged(new SelectionChangedEvent(TmfEventsTable.this, StructuredSelection.EMPTY)); } } }); int realCacheSize = Math.max(cacheSize, Display.getDefault().getBounds().height / fTable.getItemHeight()); realCacheSize = Math.min(realCacheSize, MAX_CACHE_SIZE); fCache = new TmfEventsCache(realCacheSize, this); // Handle the table item requests fTable.addListener(SWT.SetData, new Listener() { @Override public void handleEvent(final Event event) { final TableItem item = (TableItem) event.item; int index = event.index - 1; // -1 for the header row if (event.index == 0) { setHeaderRowItemData(item); return; } if (fTable.getData(Key.FILTER_OBJ) != null) { if ((event.index == 1) || (event.index == (fTable.getItemCount() - 1))) { setFilterStatusRowItemData(item); return; } index = index - 1; // -1 for top filter status row } final CachedEvent cachedEvent = fCache.getEvent(index); if (cachedEvent != null) { setItemData(item, cachedEvent.event, cachedEvent.rank); return; } // Else, fill the cache asynchronously (and off the UI thread) event.doit = false; } }); fTable.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(final MouseEvent event) { if (event.button != 1) { return; } // Identify the selected row final Point point = new Point(event.x, event.y); final TableItem item = fTable.getItem(point); if (item != null) { final Rectangle imageBounds = item.getImageBounds(0); imageBounds.width = BOOKMARK_IMAGE.getBounds().width; if (imageBounds.contains(point)) { final Long rank = (Long) item.getData(Key.RANK); if (rank != null) { toggleBookmark(rank); } } } } }); final Listener tooltipListener = new Listener() { Shell tooltipShell = null; @Override public void handleEvent(final Event event) { switch (event.type) { case SWT.MouseHover: final TableItem item = fTable.getItem(new Point(event.x, event.y)); if (item == null) { return; } final Long rank = (Long) item.getData(Key.RANK); if (rank == null) { return; } final String tooltipText = (String) item.getData(Key.BOOKMARK); final Rectangle bounds = item.getImageBounds(0); bounds.width = BOOKMARK_IMAGE.getBounds().width; if (!bounds.contains(event.x, event.y)) { return; } if ((tooltipShell != null) && !tooltipShell.isDisposed()) { tooltipShell.dispose(); } tooltipShell = new Shell(fTable.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); tooltipShell.setBackground( PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); final FillLayout layout = new FillLayout(); layout.marginWidth = 2; tooltipShell.setLayout(layout); final Label label = new Label(tooltipShell, SWT.WRAP); String text = rank.toString() + (tooltipText != null ? ": " + tooltipText : ""); //$NON-NLS-1$ //$NON-NLS-2$ label.setForeground( PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); label.setBackground( PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label.setText(text); label.addListener(SWT.MouseExit, this); label.addListener(SWT.MouseDown, this); label.addListener(SWT.MouseWheel, this); final Point size = tooltipShell.computeSize(SWT.DEFAULT, SWT.DEFAULT); /* * Bug in Linux. The coordinates of the event have an origin that excludes the table header but * the method toDisplay() expects coordinates relative to an origin that includes the table header. */ int y = event.y; if (System.getProperty("os.name").contains("Linux")) { //$NON-NLS-1$ //$NON-NLS-2$ y += fTable.getHeaderHeight(); } Point pt = fTable.toDisplay(event.x, y); pt.x += BOOKMARK_IMAGE.getBounds().width; pt.y += item.getBounds().height; tooltipShell.setBounds(pt.x, pt.y, size.x, size.y); tooltipShell.setVisible(true); break; case SWT.Dispose: case SWT.KeyDown: case SWT.MouseMove: case SWT.MouseExit: case SWT.MouseDown: case SWT.MouseWheel: if (tooltipShell != null) { tooltipShell.dispose(); tooltipShell = null; } break; default: break; } } }; fTable.addListener(SWT.MouseHover, tooltipListener); fTable.addListener(SWT.Dispose, tooltipListener); fTable.addListener(SWT.KeyDown, tooltipListener); fTable.addListener(SWT.MouseMove, tooltipListener); fTable.addListener(SWT.MouseExit, tooltipListener); fTable.addListener(SWT.MouseDown, tooltipListener); fTable.addListener(SWT.MouseWheel, tooltipListener); // Create resources createResources(); ColorSettingsManager.addColorSettingsListener(this); fTable.setItemCount(1); // +1 for header row fRawViewer = new TmfRawEventViewer(fSashForm, SWT.H_SCROLL | SWT.V_SCROLL); fRawViewer.addSelectionListener(new Listener() { @Override public void handleEvent(final Event e) { if (e.data instanceof Long) { final long rank = (Long) e.data; int index = (int) rank; if (fTable.getData(Key.FILTER_OBJ) != null) { index = fCache.getFilteredEventIndex(rank) + 1; // +1 for top filter status row } fTable.setSelection(index + 1); // +1 for header row fSelectedRank = rank; updateStatusLine(null); } else if (e.data instanceof ITmfLocation) { // DOES NOT WORK: rank undefined in context from seekLocation() // ITmfLocation<?> location = (ITmfLocation<?>) e.data; // TmfContext context = fTrace.seekLocation(location); // fTable.setSelection((int) context.getRank()); return; } else { return; } final TableItem[] selection = fTable.getSelection(); if ((selection != null) && (selection.length > 0)) { final TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData(Key.TIMESTAMP); if (ts != null) { broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, ts)); } } } }); fSashForm.setWeights(new int[] { 1, 1 }); fRawViewer.setVisible(false); createPopupMenu(); }
From source file:fr.inria.linuxtools.tmf.ui.viewers.events.TmfEventsTable.java
License:Open Source License
/** * @since 2.0/*from w w w . ja v a 2 s .c o m*/ */ @Override public ISelection getSelection() { if (fTable == null || fTable.isDisposed()) { return StructuredSelection.EMPTY; } List<Object> list = new ArrayList<>(fTable.getSelection().length); for (TableItem item : fTable.getSelection()) { if (item.getData() != null) { list.add(item.getData()); } } return new StructuredSelection(list); }
From source file:fr.openpeople.rdal.model.core.diagram.navigator.RdalNavigatorLinkHelper.java
License:Open Source License
/** * @generated// w w w . j a v a 2 s . c om */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = RdalDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { RdalNavigatorItem item = new RdalNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:fr.openpeople.rdal.model.core.diagram.part.RdalDiagramEditor.java
License:Open Source License
/** * @generated/*from w ww . j a v a 2s . c om*/ */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { RdalNavigatorItem item = new RdalNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:fr.openpeople.rdal.model.core.diagram.part.RdalNewDiagramFileWizard.java
License:Open Source License
/** * @generated/*from ww w . ja va2 s . c om*/ */ public RdalNewDiagramFileWizard(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.RdalNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); myFileCreationPage.setTitle(Messages.RdalNewDiagramFileWizard_CreationPageTitle); myFileCreationPage.setDescription(NLS.bind(Messages.RdalNewDiagramFileWizard_CreationPageDescription, SpecificationEditPart.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(RdalDiagramEditorUtil.getUniqueFileName(filePath, fileName, "rdal_diagram")); //$NON-NLS-1$ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage( Messages.RdalNewDiagramFileWizard_RootSelectionPageName); diagramRootElementSelectionPage.setTitle(Messages.RdalNewDiagramFileWizard_RootSelectionPageTitle); diagramRootElementSelectionPage .setDescription(Messages.RdalNewDiagramFileWizard_RootSelectionPageDescription); diagramRootElementSelectionPage.setModelElement(diagramRoot); myEditingDomain = editingDomain; }
From source file:fr.opensagres.eclipse.jsbuild.internal.ui.navigator.TaskLinkHelper.java
License:Open Source License
@Override public IStructuredSelection findSelection(IEditorInput input) { /*//www .j av a 2s. c o m * IJavaScriptElement element = JavaScriptUI * .getEditorInputJavaElement(input); if (element == null) { IFile file * = ResourceUtil.getFile(input); if (file != null) { element = * JavaScriptCore.create(file); } } return (element != null) ? new * StructuredSelection(element) : StructuredSelection.EMPTY; */ return StructuredSelection.EMPTY; }
From source file:gov.nasa.arc.spife.core.plan.editor.timeline.TimelinePlanClipboardCutOperation.java
License:Open Source License
@Override public void displayExecute(Widget widget, IWorkbenchSite site) { ISelectionProvider selectionProvider = site.getSelectionProvider(); selectionProvider.setSelection(StructuredSelection.EMPTY); }
From source file:gov.nasa.arc.spife.ui.table.days.DaysEditor.java
License:Open Source License
@Override public void dispose() { daysComposite.dispose(); selectionProvider.setSelection(StructuredSelection.EMPTY); super.dispose(); }