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:eu.esdihumboldt.hale.ui.util.selector.AbstractSelector.java
License:Open Source License
/** * @see ISelectionProvider#setSelection(ISelection) */// www. java 2 s.co m @Override public void setSelection(ISelection selection) { if (!selection.isEmpty() && selection instanceof IStructuredSelection) { Object selected = ((IStructuredSelection) selection).getFirstElement(); if (selected != null) { // run against filters if (AbstractViewerSelectionDialog.acceptObject(viewer, filters, selected)) { // valid selection currentInput = selected; viewer.setInput(selected); fireSelectionChange(); return; } else { // TODO user error message? } } } currentInput = NoObject.NONE; viewer.setInput(NoObject.NONE); viewer.setSelection(StructuredSelection.EMPTY); fireSelectionChange(); }
From source file:eu.esdihumboldt.hale.ui.util.selector.AbstractSelector.java
License:Open Source License
/** * Resets the current selection, but shows the given text instead of the * default.//from w w w.j a v a2s . com * * @param text the text to show */ public void showText(String text) { currentInput = NoObject.NONE; viewer.setInput(text); viewer.setSelection(StructuredSelection.EMPTY); fireSelectionChange(); }
From source file:eu.esdihumboldt.hale.ui.views.mapping.AlignmentView.java
License:Open Source License
/** * @see eu.esdihumboldt.hale.ui.views.mapping.AbstractMappingView#createViewControl(org.eclipse.swt.widgets.Composite) *//*from w w w .java 2 s .com*/ @Override public void createViewControl(Composite parent) { Composite page = new Composite(parent, SWT.NONE); page.setLayout(GridLayoutFactory.fillDefaults().create()); // create type relation selection control sourceTargetSelector = new SourceTargetTypeSelector(page); sourceTargetSelector.getControl().setLayoutData( GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { getViewer().setInput(sourceTargetSelector.getSelectedCell()); if (deactivatedCellFilterAction != null) { deactivatedCellFilterAction.setEnabled(sourceTargetSelector.isCellSelected()); if (!sourceTargetSelector.isCellSelected()) deactivatedCellFilterAction.setChecked(true); } refreshGraph(); } }); // typeRelations = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY); // typeRelations.setContentProvider(ArrayContentProvider.getInstance()); // typeRelations.setLabelProvider(new LabelProvider() { // // @Override // public Image getImage(Object element) { // if (element instanceof Cell) { // // use function image if possible // Cell cell = (Cell) element; // String functionId = cell.getTransformationIdentifier(); // AbstractFunction<?> function = FunctionUtil.getFunction(functionId); // if (function != null) { // return functionLabels.getImage(function); // } // return null; // } // // return super.getImage(element); // } // // @Override // public String getText(Object element) { // if (element instanceof Cell) { // Cell cell = (Cell) element; // // return CellUtil.getCellDescription(cell); // } // // return super.getText(element); // } // // }); // typeRelations.addSelectionChangedListener(new ISelectionChangedListener() { // // @Override // public void selectionChanged(SelectionChangedEvent event) { // updateGraph(); // } // }); // typeRelations.getControl().setLayoutData( // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) // .create()); // create viewer Composite viewerContainer = new Composite(page, SWT.NONE); viewerContainer.setLayout(new FillLayout()); viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); super.createViewControl(viewerContainer); updateLayout(false); AlignmentService as = (AlignmentService) PlatformUI.getWorkbench().getService(AlignmentService.class); // update(); as.addListener(alignmentListener = new AlignmentServiceAdapter() { @Override public void alignmentCleared() { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { sourceTargetSelector.setSelection(StructuredSelection.EMPTY); } }); } @Override public void cellsRemoved(Iterable<Cell> cells) { if (sourceTargetSelector.isCellSelected() && Iterables.contains(cells, sourceTargetSelector.getSelectedCell())) sourceTargetSelector.setSelection(StructuredSelection.EMPTY); refreshGraph(); } @Override public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) { if (sourceTargetSelector.isCellSelected() && cells.keySet().contains(sourceTargetSelector.getSelectedCell())) sourceTargetSelector.setSelection(StructuredSelection.EMPTY); refreshGraph(); } @Override public void cellsAdded(Iterable<Cell> cells) { refreshGraph(); } @Override public void alignmentChanged() { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { sourceTargetSelector.setSelection(StructuredSelection.EMPTY); } }); } @Override public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) { refreshGraph(); } }); // initialize compatibility checkup and display CompatibilityService cs = (CompatibilityService) PlatformUI.getWorkbench() .getService(CompatibilityService.class); cs.addListener( compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() { @Override public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) { refreshGraph(); } }); // listen on SchemaSelections getSite().getWorkbenchWindow().getSelectionService() .addPostSelectionListener(selectionListener = new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (!(selection instanceof SchemaSelection)) { // only react on schema selections return; } if (part != AlignmentView.this) { updateRelation((SchemaSelection) selection); } } }); // select type cell, if it is double clicked getViewer().addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() == 1) { Object selected = selection.getFirstElement(); if (selected instanceof Cell && AlignmentUtil.isTypeCell((Cell) selected)) sourceTargetSelector.setSelection(selection); } } }); // listen on size changes getViewer().getControl().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { updateLayout(true); } }); getViewer().setInput(new DefaultCell()); }
From source file:eu.geclipse.traceview.debug.actions.AbstractEventBreakpointAction.java
License:Open Source License
public void selectionChanged(final IAction action, final ISelection selection) { if (selection instanceof StructuredSelection) { this.selection = (StructuredSelection) selection; } else {/*from w w w. ja v a2s . c o m*/ this.selection = StructuredSelection.EMPTY; } }
From source file:eu.geclipse.ui.internal.actions.FileActions.java
License:Open Source License
/** * Construct a new file action group for the specified * {@link GridModelViewPart}.//from w w w .ja v a 2s . c o m * * @param view The {@link GridModelViewPart} for which to create * this action group. */ public FileActions(final GridModelViewPart view) { this.site = view.getSite(); Shell shell = this.site.getShell(); ISelectionProvider provider = this.site.getSelectionProvider(); this.clipboard = new Clipboard(shell.getDisplay()); this.copyAction = new CopyAction(this.clipboard); this.pasteAction = new PasteAction(this.clipboard); this.deleteElementAction = new DeleteGridElementAction(shell); this.renameAction = new RenameResourceAction(shell); provider.addSelectionChangedListener(this.copyAction); provider.addSelectionChangedListener(this.pasteAction); provider.addSelectionChangedListener(this.deleteElementAction); provider.addSelectionChangedListener(this.renameAction); ISelection selection = provider.getSelection(); if ((selection == null) || !(selection instanceof IStructuredSelection)) { selection = StructuredSelection.EMPTY; } this.copyAction.selectionChanged((IStructuredSelection) selection); this.pasteAction.selectionChanged((IStructuredSelection) selection); this.deleteElementAction.selectionChanged((IStructuredSelection) selection); this.renameAction.selectionChanged((IStructuredSelection) selection); }
From source file:eu.geclipse.ui.internal.actions.OpenElementAction.java
License:Open Source License
public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { selectionChanged((IStructuredSelection) selection); } else {//from ww w . j a v a 2s .co m selectionChanged(StructuredSelection.EMPTY); } }
From source file:eu.geclipse.ui.internal.actions.SubmitJobActions.java
License:Open Source License
/** * Create a new job submission action for the specified workbench site. * //from w ww . j av a 2 s . c om * @param site The {@link IWorkbenchSite} to create this action for. */ public SubmitJobActions(final IWorkbenchSite site) { this.site = site; ISelectionProvider provider = site.getSelectionProvider(); this.submitAction = new SubmitJobAction(site); provider.addSelectionChangedListener(this.submitAction); ISelection selection = provider.getSelection(); if ((selection == null) || !(selection instanceof IStructuredSelection)) { selection = StructuredSelection.EMPTY; } this.submitAction.selectionChanged((IStructuredSelection) selection); }
From source file:eu.geclipse.ui.internal.GridElementSelectionAdapter.java
License:Open Source License
public ISelection getSelection() { return this.currentSelection == null ? StructuredSelection.EMPTY : this.currentSelection; }
From source file:eu.geclipse.ui.wizards.ConnectionWizard.java
License:Open Source License
@Override public void addPages() { if (this.initialSelection == null) { this.initialSelection = StructuredSelection.EMPTY; }/*from w w w. ja v a2s. com*/ if (this.createGlobalConnection) { this.firstPage = new ConnectionNameWizardPage(this.initialName); } else { this.firstPage = new ConnectionLocationWizardPage( Messages.getString("ConnectionWizard.location_page_name"), //$NON-NLS-1$ (IStructuredSelection) this.initialSelection); this.firstPage.setTitle(Messages.getString("ConnectionWizard.location_page_title")); //$NON-NLS-1$ this.firstPage.setDescription(Messages.getString("ConnectionWizard.location_page_description")); //$NON-NLS-1$ if (this.initialName != null) { ((ConnectionLocationWizardPage) this.firstPage).setFileName(this.initialName); } } addPage(this.firstPage); IGridContainer mountPoint = getMountPoint(); this.definitionPage = new ConnectionDefinitionWizardPage(mountPoint, this.initialURI); addPage(this.definitionPage); }
From source file:eu.geclipse.workflow.ui.navigator.WorkflowNavigatorLinkHelper.java
License:Open Source License
/** * @generated/*from w w w . j a v a2s . c om*/ */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = WorkflowDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { WorkflowNavigatorItem item = new WorkflowNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }