List of usage examples for org.eclipse.jface.viewers StructuredViewer getSelection
@Override
public ISelection getSelection()
StructuredViewer implementation of this method returns the result as an IStructuredSelection. From source file:ch.elexis.core.ui.contacts.views.PatientMenuPopulator.java
License:Open Source License
PatientMenuPopulator(PatientenListeView plv, final StructuredViewer structuredViewer) { mine = plv;/*from w ww. j a v a 2 s . co m*/ stickerAction = new RestrictedAction(AccessControlDefaults.KONTAKT_ETIKETTE, Messages.PatientMenuPopulator_StickerAction) { // $NON-NLS-1$ { setToolTipText(Messages.PatientMenuPopulator_StickerToolTip); // $NON-NLS-1$ } @Override public void doRun() { Patient p = mine.getSelectedPatient(); AssignStickerDialog aed = new AssignStickerDialog(Hub.getActiveShell(), p); aed.open(); } }; delPatAction = new LockRequestingRestrictedAction<Patient>(AccessControlDefaults.KONTAKT_DELETE, Messages.PatientMenuPopulator_DeletePatientAction) { @Override public void doRun(Patient p) { if (MessageDialog.openConfirm(mine.getViewSite().getShell(), Messages.PatientMenuPopulator_DeletePatientConfirm, p.getLabel()) == true) { if (p.delete(false) == false) { SWTHelper.alert(Messages.PatientMenuPopulator_DeletePatientRejectCaption, Messages.PatientMenuPopulator_DeletePatientRejectBody); } else { mine.reload(); } } } @Override public Patient getTargetedObject() { StructuredSelection selection = (StructuredSelection) structuredViewer.getSelection(); if (selection != null) { return (Patient) selection.getFirstElement(); } return null; } }; exportKGAction = new Action(Messages.PatientMenuPopulator_ExportEMRAction, Action.AS_DROP_DOWN_MENU) { // $NON-NLS-1$ Menu menu = null; { setToolTipText(Messages.PatientMenuPopulator_ExportEMRToolTip); // $NON-NLS-1$ setMenuCreator(new IMenuCreator() { public void dispose() { if (menu != null) { menu.dispose(); menu = null; } } public Menu getMenu(Control parent) { menu = new Menu(parent); createMenu(); return menu; } public Menu getMenu(Menu parent) { menu = new Menu(parent); createMenu(); return menu; } }); } void createMenu() { Patient p = mine.getSelectedPatient(); if (p != null) { List<IConfigurationElement> list = Extensions .getExtensions(ExtensionPointConstantsUi.TRANSPORTER); // $NON-NLS-1$ for (final IConfigurationElement ic : list) { // TODO "Acceptable Types" is not part of // ch.elexis.Transporter // never was?! Should we remove this code? - mde String handler = ic.getAttribute("AcceptableTypes"); //$NON-NLS-1$ if (handler == null) { continue; } if (handler.contains("ch.elexis.data.Patient") //$NON-NLS-1$ || (handler.contains("ch.elexis.data.*"))) { //$NON-NLS-1$ MenuItem it = new MenuItem(menu, SWT.NONE); it.setText(ic.getAttribute("name")); //$NON-NLS-1$ it.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Patient pat = mine.getSelectedPatient(); try { IDataSender sender = (IDataSender) ic .createExecutableExtension("ExporterClass"); //$NON-NLS-1$ sender.store(pat); sender.finalizeExport(); SWTHelper.showInfo(Messages.PatientMenuPopulator_EMRExported, // $NON-NLS-1$ MessageFormat.format(Messages.PatientMenuPopulator_ExportEmrSuccess, // $NON-NLS-1$ pat.getLabel())); } catch (CoreException e1) { ExHandler.handle(e1); } catch (XChangeException xx) { SWTHelper.showError(Messages.PatientMenuPopulator_ErrorCaption, // $NON-NLS-1$ MessageFormat.format(Messages.PatientMenuPopulator_ExportEmrFailure, // $NON-NLS-1$ pat.getLabel())); } } }); } } } } }; }
From source file:ch.elexis.core.ui.util.PersistentObjectDragSource.java
License:Open Source License
public PersistentObjectDragSource(final StructuredViewer v) { dragSource = v.getControl();/*from w ww .j a va 2 s.c om*/ renderer = new ISelectionRenderer() { public List<PersistentObject> getSelection() { IStructuredSelection sel = (IStructuredSelection) v.getSelection(); return sel.toList(); } }; setup(); }
From source file:com.archimatetool.templates.dialog.TemplateManagerDialogDragDropHandler.java
License:Open Source License
/** * Register drag support that starts from the Table *///from w w w .ja v a 2s .c o m private void registerDragSupport(final StructuredViewer viewer) { viewer.addDragSupport(fDragOperations, sourceTransferTypes, new DragSourceListener() { public void dragFinished(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(null); } public void dragSetData(DragSourceEvent event) { } public void dragStart(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection()); event.doit = true; } }); }
From source file:com.foglyn.ui.FoglynAdvancedSearchPage.java
License:Open Source License
private void refreshViewer(StructuredViewer viewer) { IStructuredSelection sel = (IStructuredSelection) viewer.getSelection(); viewer.refresh();//from w w w . j av a 2 s .c o m viewer.setSelection(sel); IStructuredSelection after = (IStructuredSelection) viewer.getSelection(); if (after.isEmpty()) { viewer.setSelection(HelperConstants.NULL_VALUE_SELECTION); } }
From source file:com.google.dart.tools.search.ui.text.AbstractTextSearchViewPage.java
License:Open Source License
/** * Note: this is internal API and should not be called from clients outside of the search plug-in. * <p>// w w w . j av a 2s.co m * Removes the currently selected match. Does nothing if no match is selected. * </p> * * @noreference This method is not intended to be referenced by clients. */ public void internalRemoveSelected() { AbstractTextSearchResult result = getInput(); if (result == null) { return; } StructuredViewer viewer = getViewer(); IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); HashSet<Match> set = new HashSet<Match>(); if (viewer instanceof TreeViewer) { ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider(); collectAllMatchesBelow(result, set, cp, selection.toArray()); } else { collectAllMatches(set, selection.toArray()); } navigateNext(true); Match[] matches = new Match[set.size()]; set.toArray(matches); result.removeMatches(matches); }
From source file:com.google.dart.tools.ui.callhierarchy.CallHierarchyViewPart.java
License:Open Source License
/** * Returns the current selection.// w w w .j a va2 s .c o m * * @return selection */ protected ISelection getSelection() { StructuredViewer viewerInFocus = selectionProviderMediator.getViewerInFocus(); if (viewerInFocus != null) { return viewerInFocus.getSelection(); } return StructuredSelection.EMPTY; }
From source file:com.netxforge.netxstudio.screens.editing.util.CDOMementoUtil.java
License:Open Source License
/** * Remember a {@link StructuredViewer} {@link ISelection} * /*from ww w .j a v a 2 s .c o m*/ * @param memento * @param viewer * @param key */ public static void rememberStructuredViewerSelection(IMemento memento, StructuredViewer viewer, String key) { ISelection selection = viewer.getSelection(); rememberSelection(memento, (IStructuredSelection) selection, key); }
From source file:com.nokia.carbide.search.system.ui.text.AbstractTextSearchViewPage.java
License:Open Source License
/** * Note: this is internal API and should not be called from clients outside * of the search plug-in.//w w w.j a va2 s . c om * <p> * Removes the currently selected match. Does nothing if no match is * selected. * </p> * * @noreference This method is not intended to be referenced by clients. */ public void internalRemoveSelected() { AbstractTextSearchResult result = getInput(); if (result == null) return; StructuredViewer viewer = getViewer(); IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); HashSet set = new HashSet(); if (viewer instanceof TreeViewer) { ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider(); collectAllMatchesBelow(result, set, cp, selection.toArray()); } else { collectAllMatches(set, selection.toArray()); } navigateNext(true); Match[] matches = new Match[set.size()]; set.toArray(matches); result.removeMatches(matches); }
From source file:com.nokia.tools.vct.internal.common.secure.ui.actions.DeleteKeysAction.java
License:Open Source License
public DeleteKeysAction(StructuredViewer viewer) { this.viewer = viewer; setEnabled(!viewer.getSelection().isEmpty()); setText("Delete"); }
From source file:com.nokia.tools.vct.internal.common.secure.ui.actions.ExportKeysAction.java
License:Open Source License
public ExportKeysAction(StructuredViewer viewer) { this.viewer = viewer; setEnabled(!viewer.getSelection().isEmpty()); setText("Export Keys"); }