List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:ch.elexis.core.ui.views.AUF2.java
License:Open Source License
private ch.elexis.data.AUF getSelectedAUF() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if ((sel == null) || (sel.isEmpty())) { return null; }/*from ww w . j a va 2s . c om*/ return (AUF) sel.getFirstElement(); }
From source file:ch.elexis.core.ui.views.BestellView.java
License:Open Source License
private void makeActions() { removeAction = new Action(Messages.BestellView_RemoveArticle) { //$NON-NLS-1$ @Override// w w w . jav a2 s .c o m public void run() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if ((sel != null) && (!sel.isEmpty())) { if (actBestellung != null) { @SuppressWarnings("unchecked") List<BestellungEntry> selections = sel.toList(); for (BestellungEntry entry : selections) { actBestellung.removeEntry(entry); } tv.refresh(); } } } }; dailyWizardAction = new Action(Messages.BestellView_AutomaticDailyOrder) { { setToolTipText(Messages.BestellView_CreateAutomaticDailyOrder); setImageDescriptor(Images.IMG_WIZ_DAY.getImageDescriptor()); } @Override public void run() { if (actBestellung == null) { setBestellung(new Bestellung(Messages.BestellView_AutomaticDaily, CoreHub.actUser)); //$NON-NLS-1$ } DailyOrderDialog doDlg = new DailyOrderDialog(UiDesk.getTopShell(), actBestellung); doDlg.open(); tv.refresh(true); } }; wizardAction = new Action(Messages.BestellView_AutomaticOrder) { //$NON-NLS-1$ { setToolTipText(Messages.BestellView_CreateAutomaticOrder); //$NON-NLS-1$ setImageDescriptor(Images.IMG_WIZARD.getImageDescriptor()); } @Override public void run() { if (actBestellung == null) { setBestellung(new Bestellung(Messages.BestellView_Automatic, CoreHub.actUser)); } int trigger = CoreHub.globalCfg.get(ch.elexis.core.constants.Preferences.INVENTORY_ORDER_TRIGGER, ch.elexis.core.constants.Preferences.INVENTORY_ORDER_TRIGGER_DEFAULT); boolean isInventoryBelow = trigger == ch.elexis.core.constants.Preferences.INVENTORY_ORDER_TRIGGER_BELOW; Query<StockEntry> qbe = new Query<StockEntry>(StockEntry.class, null, null, StockEntry.TABLENAME, new String[] { StockEntry.FLD_CURRENT, StockEntry.FLD_MAX }); qbe.add(StockEntry.FLD_CURRENT, isInventoryBelow ? Query.LESS : Query.LESS_OR_EQUAL, StockEntry.FLD_MIN); List<StockEntry> stockEntries = qbe.execute(); for (StockEntry se : stockEntries) { CoreHub.getOrderService().addRefillForStockEntryToOrder(se, actBestellung); } tv.refresh(true); } }; newAction = new Action(Messages.BestellView_CreateNewOrder) { //$NON-NLS-1$ @Override public void run() { NeueBestellungDialog nbDlg = new NeueBestellungDialog(getViewSite().getShell(), Messages.BestellView_CreateNewOrder, Messages.BestellView_EnterOrderTitle); if (nbDlg.open() == Dialog.OK) { setBestellung(new Bestellung(nbDlg.getTitle(), CoreHub.actUser)); } else { return; } tv.refresh(); } }; printAction = new Action(Messages.BestellView_PrintOrder) { //$NON-NLS-1$ @Override public void run() { if (actBestellung != null) { Kontakt receiver = null; List<BestellungEntry> best = prepareOrderList(receiver); try { BestellBlatt bb = (BestellBlatt) getViewSite().getPage().showView(BestellBlatt.ID); bb.createOrder(receiver, best); tv.refresh(); Bestellung.markAsOrdered(best); } catch (PartInitException e) { ExHandler.handle(e); } } } }; sendAction = new Action(Messages.BestellView_SendOrder) { @Override public void run() { if (actBestellung == null) return; // organise items in supplier and non-supplier lists List<BestellungEntry> orderableItems = new ArrayList<BestellungEntry>(); List<BestellungEntry> noSupplierItems = new ArrayList<BestellungEntry>(); for (BestellungEntry item : actBestellung.getEntries()) { Kontakt supplier = item.getProvider(); if (supplier != null && supplier.exists()) { orderableItems.add(item); } else { noSupplierItems.add(item); } } boolean runOrder = true; if (!noSupplierItems.isEmpty()) { StringBuilder sb = new StringBuilder(); for (BestellungEntry noSupItem : noSupplierItems) { sb.append(noSupItem.getArticle().getLabel()); sb.append("\n"); } runOrder = SWTHelper.askYesNo(Messages.BestellView_NoSupplierArticle, MessageFormat.format(Messages.BestellView_NoSupplierArticleMsg, sb.toString())); } if (runOrder) { List<IConfigurationElement> list = Extensions .getExtensions(ExtensionPointConstantsUi.TRANSPORTER); for (IConfigurationElement ic : list) { String handler = ic.getAttribute("type"); if (handler != null && handler.contains(Bestellung.class.getName())) { try { IDataSender sender = (IDataSender) ic .createExecutableExtension(ExtensionPointConstantsUi.TRANSPORTER_EXPC); sender.store(actBestellung); sender.finalizeExport(); SWTHelper.showInfo(Messages.BestellView_OrderSentCaption, Messages.BestellView_OrderSentBody); tv.refresh(); Bestellung.markAsOrdered(orderableItems); } catch (CoreException ex) { ExHandler.handle(ex); } catch (XChangeException xx) { SWTHelper.showError(Messages.BestellView_OrderNotPossible, Messages.BestellView_NoAutomaticOrderAvailable + xx.getLocalizedMessage()); } } } } } }; loadAction = new Action(Messages.BestellView_OpenOrder) { @Override public void run() { SelectBestellungDialog dlg = new SelectBestellungDialog(getViewSite().getShell()); dlg.setMessage(Messages.BestellView_SelectOrder); //$NON-NLS-1$ dlg.setTitle(Messages.BestellView_ReadOrder); //$NON-NLS-1$ if (dlg.open() == Dialog.OK) { if (dlg.getResult().length > 0) { Bestellung res = (Bestellung) dlg.getResult()[0]; setBestellung(res); } } } }; printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); printAction.setToolTipText(Messages.BestellView_PrintOrder); newAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); newAction.setToolTipText(Messages.BestellView_CreateNewOrder); sendAction.setImageDescriptor(Images.IMG_NETWORK.getImageDescriptor()); sendAction.setToolTipText(Messages.BestellView_transmitOrder); loadAction.setImageDescriptor(Images.IMG_IMPORT.getImageDescriptor()); loadAction.setToolTipText(Messages.BestellView_loadEarlierOrder); exportClipboardAction = new Action(Messages.BestellView_copyToClipboard) { { setToolTipText(Messages.BestellView_copyToClipBioardForGalexis); } @Override public void run() { if (actBestellung != null) { Kontakt receiver = null; List<BestellungEntry> best = prepareOrderList(receiver); StringBuffer export = new StringBuffer(); for (BestellungEntry item : best) { String pharmaCode = item.getArticle().getPharmaCode(); int num = item.getCount(); String name = item.getArticle().getName(); String line = pharmaCode + ", " + num + ", " + name; //$NON-NLS-1$ //$NON-NLS-2$ export.append(line); export.append(System.getProperty("line.separator")); //$NON-NLS-1$ } String clipboardText = export.toString(); Clipboard clipboard = new Clipboard(UiDesk.getDisplay()); TextTransfer textTransfer = TextTransfer.getInstance(); Transfer[] transfers = new Transfer[] { textTransfer }; Object[] data = new Object[] { clipboardText }; clipboard.setContents(data, transfers); clipboard.dispose(); } } }; checkInAction = new Action(Messages.BestellView_CheckInCaption) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_TICK.getImageDescriptor()); setToolTipText(Messages.BestellView_CheckInBody); //$NON-NLS-1$ } @Override public void run() { if (actBestellung != null && actBestellung.exists()) { OrderImportDialog dialog = new OrderImportDialog(getSite().getShell(), actBestellung); dialog.open(); } else { SWTHelper.alert(Messages.BestellView_NoOrder, //$NON-NLS-1$ Messages.BestellView_NoOrderLoaded); //$NON-NLS-1$ } } }; }
From source file:ch.elexis.core.ui.views.rechnung.BillingProposalView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.VIRTUAL); viewer.getTable().setHeaderVisible(true); viewer.setContentProvider(new BillingInformationContentProvider(viewer)); comparator = new BillingProposalViewerComparator(); viewer.setComparator(comparator);/*from w ww . ja va 2s . c o m*/ TableViewerColumn patNameColumn = new TableViewerColumn(viewer, SWT.NONE); patNameColumn.getColumn().setWidth(175); patNameColumn.getColumn().setText("Patient"); patNameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getPatientName(); } else { return super.getText(element); } } }); patNameColumn.getColumn().addSelectionListener(getSelectionAdapter(0)); TableViewerColumn patNrColumn = new TableViewerColumn(viewer, SWT.NONE); patNrColumn.getColumn().setWidth(50); patNrColumn.getColumn().setText("PatNr"); patNrColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return Integer.toString(((BillingInformation) element).getPatientNr()); } else { return super.getText(element); } } }); patNrColumn.getColumn().addSelectionListener(getSelectionAdapter(1)); TableViewerColumn dateColumn = new TableViewerColumn(viewer, SWT.NONE); dateColumn.getColumn().setWidth(75); dateColumn.getColumn().setText("Datum"); dateColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getDate() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy")); } else { return super.getText(element); } } }); dateColumn.getColumn().addSelectionListener(getSelectionAdapter(2)); TableViewerColumn accountingSystemColumn = new TableViewerColumn(viewer, SWT.NONE); accountingSystemColumn.getColumn().setWidth(75); accountingSystemColumn.getColumn().setText("Fall"); accountingSystemColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getAccountingSystem(); } else { return super.getText(element); } } }); TableViewerColumn insurerColumn = new TableViewerColumn(viewer, SWT.NONE); insurerColumn.getColumn().setWidth(175); insurerColumn.getColumn().setText("Versicherer"); insurerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getInsurer(); } else { return super.getText(element); } } }); TableViewerColumn totalColumn = new TableViewerColumn(viewer, SWT.NONE); totalColumn.getColumn().setWidth(75); totalColumn.getColumn().setText("Total"); totalColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getTotal(); } else { return super.getText(element); } } }); TableViewerColumn checkResultColumn = new TableViewerColumn(viewer, SWT.NONE); checkResultColumn.getColumn().setWidth(200); checkResultColumn.getColumn().setText("Prfergebnis"); checkResultColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getCheckResultMessage(); } else { return super.getText(element); } } @Override public Color getBackground(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).isOk() ? lightGreen : lightRed; } else { return super.getForeground(element); } } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null && !selection.isEmpty()) { if (selection.getFirstElement() instanceof BillingInformation) { Konsultation kons = ((BillingInformation) selection.getFirstElement()).getKonsultation(); ElexisEventDispatcher.fireSelectionEvent(kons); } } } }); viewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.F5) { refresh(); } } }); MenuManager menuManager = new MenuManager(); Menu menu = menuManager.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuManager, viewer); getSite().setSelectionProvider(viewer); }
From source file:ch.elexis.core.ui.views.rechnung.KonsZumVerrechnenView.java
License:Open Source License
private void makeActions() { billAction = new Action(Messages.KonsZumVerrechnenView_createInvoices) { //$NON-NLS-1$ {//from w w w. java 2 s.c om setImageDescriptor(Images.IMG_BILL.getImageDescriptor()); //$NON-NLS-1$ setToolTipText(Messages.KonsZumVerrechnenView_createInvoices); //$NON-NLS-1$ } @SuppressWarnings("unchecked") @Override public void run() { if (((StructuredSelection) tvSel.getSelection()).size() > 0) { if (!SWTHelper.askYesNo(Messages.KonsZumVerrechnenView_RealleCreateBillsCaption, //$NON-NLS-1$ Messages.KonsZumVerrechnenView_ReallyCreateBillsBody)) { //$NON-NLS-1$ return; } } // Handler.execute(getViewSite(), "bill.create", tSelection); ErstelleRnnCommand.ExecuteWithParams(getViewSite(), tSelection); /* * IHandlerService handlerService = (IHandlerService) * getViewSite().getService(IHandlerService.class); ICommandService cmdService = * (ICommandService) getViewSite().getService(ICommandService.class); try { * Command command = cmdService.getCommand("bill.create"); Parameterization px = * new Parameterization(command.getParameter * ("ch.elexis.RechnungErstellen.parameter" ), new * TreeToStringConverter().convertToString(tSelection)); ParameterizedCommand * parmCommand = new ParameterizedCommand(command, new Parameterization[] { px * }); * * handlerService.executeCommand(parmCommand, null); * * } catch (Exception ex) { throw new RuntimeException("add.command not found"); * } */ tvSel.refresh(); } }; clearAction = new Action(Messages.KonsZumVerrechnenView_clearSelection) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_REMOVEITEM.getImageDescriptor()); //$NON-NLS-1$ setToolTipText(Messages.KonsZumVerrechnenView_deleteList); //$NON-NLS-1$ } @Override public void run() { tSelection.clear(); tvSel.refresh(); } }; refreshAction = new Action(Messages.KonsZumVerrechnenView_reloadAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_REFRESH.getImageDescriptor()); setToolTipText(Messages.KonsZumVerrechnenView_reloadToolTip); //$NON-NLS-1$ } @Override public void run() { tAll.clear(); cv.notify(CommonViewer.Message.update); tvSel.refresh(true); } }; wizardAction = new Action(Messages.KonsZumVerrechnenView_autoAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_WIZARD.getImageDescriptor()); setToolTipText(Messages.KonsZumVerrechnenView_autoToolTip); //$NON-NLS-1$ } @Override public void run() { KonsZumVerrechnenWizardDialog kzvd = new KonsZumVerrechnenWizardDialog(getViewSite().getShell()); if (kzvd.open() == Dialog.OK) { IProgressService progressService = PlatformUI.getWorkbench().getProgressService(); try { progressService.runInUI(progressService, new Rechnungslauf(self, kzvd.bMarked, kzvd.ttFirstBefore, kzvd.ttLastBefore, kzvd.mAmount, kzvd.bQuartal, kzvd.bSkip, kzvd.ttFrom, kzvd.ttTo, kzvd.accountSys), null); } catch (Throwable ex) { ExHandler.handle(ex); } tvSel.refresh(); cv.notify(CommonViewer.Message.update); } } }; printAction = new Action(Messages.KonsZumVerrechnenView_printSelection) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); setToolTipText(Messages.KonsZumVerrechnenView_printToolTip); //$NON-NLS-1$ } @Override public void run() { new SelectionPrintDialog(getViewSite().getShell()).open(); } }; removeAction = new Action(Messages.KonsZumVerrechnenView_removeFromSelection) { //$NON-NLS-1$ @SuppressWarnings("unchecked") @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tvSel.getSelection(); if (!sel.isEmpty()) { for (Object o : sel.toList()) { if (o instanceof Tree) { Tree t = (Tree) o; if (t.contents instanceof Patient) { selectPatient((Patient) t.contents, tSelection, tAll); } else if (t.contents instanceof Fall) { selectFall((Fall) t.contents, tSelection, tAll); } else if (t.contents instanceof Konsultation) { selectBehandlung((Konsultation) t.contents, tSelection, tAll); } } } tvSel.refresh(); cv.notify(CommonViewer.Message.update); } } }; // expand action for tvSel expandSelAction = new Action(Messages.KonsZumVerrechnenView_expand) { //$NON-NLS-1$ @SuppressWarnings("unchecked") @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tvSel.getSelection(); if (!sel.isEmpty()) { for (Object o : sel.toList()) { if (o instanceof Tree) { Tree t = (Tree) o; tvSel.expandToLevel(t, TreeViewer.ALL_LEVELS); } } } } }; // expandAll action for tvSel expandSelAllAction = new Action(Messages.KonsZumVerrechnenView_expandAll) { //$NON-NLS-1$ @Override public void run() { tvSel.expandAll(); } }; selectByDateAction = new Action(Messages.KonsZumVerrechnenView_selectByDateAction) { //$NON-NLS-1$ TimeTool fromDate; TimeTool toDate; { setImageDescriptor(Images.IMG_WIZARD.getImageDescriptor()); setToolTipText(Messages.KonsZumVerrechnenView_selectByDateActionToolTip); //$NON-NLS-1$ } @Override public void run() { // select date SelectDateDialog dialog = new SelectDateDialog(getViewSite().getShell()); if (dialog.open() == TitleAreaDialog.OK) { fromDate = dialog.getFromDate(); toDate = dialog.getToDate(); IProgressService progressService = PlatformUI.getWorkbench().getProgressService(); try { progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { doSelectByDate(monitor, fromDate, toDate); } }, null); } catch (Throwable ex) { ExHandler.handle(ex); } tvSel.refresh(); cv.notify(CommonViewer.Message.update); } } }; detailAction = new RestrictedAction(AccessControlDefaults.LSTG_VERRECHNEN, Messages.KonsZumVerrechnenView_billingDetails) { //$NON-NLS-1$ @SuppressWarnings("unchecked") @Override public void doRun() { Object[] sel = cv.getSelection(); if ((sel != null) && (sel.length > 0)) { new VerrDetailDialog(getViewSite().getShell(), (Tree) sel[0]).open(); } } }; }
From source file:ch.elexis.icpc.views.ChapterDisplay.java
License:Open Source License
public ChapterDisplay(Composite parent, final String chapter) { super(parent, SWT.NONE); this.chapter = chapter; setLayout(new GridLayout(2, false)); fLeft = tk.createScrolledForm(this); fLeft.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); fLeft.setText(chapter);/* w ww. j a va2 s . c o m*/ Composite cLeft = fLeft.getBody(); cLeft.setLayout(new GridLayout()); cLeft.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); final Composite cRight = tk.createComposite(this); cRight.setLayout(new GridLayout()); cRight.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ec = new ExpandableComposite[IcpcCode.components.length]; for (int i = 0; i < ec.length; i++) { String c = IcpcCode.components[i]; ec[i] = tk.createExpandableComposite(cLeft, ExpandableComposite.TWISTIE); ec[i].setText(c); UserSettings.setExpandedState(ec[i], UC2_HEADING + c.substring(0, 1)); Composite inlay = new Composite(ec[i], SWT.NONE); inlay.setLayout(new FillLayout()); CommonViewer cv = new CommonViewer(); ViewerConfigurer vc = new ViewerConfigurer(new ComponentContentProvider(c), new DefaultLabelProvider(), new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_TABLE, SWT.SINGLE, cv)); ec[i].setData(cv); cv.create(vc, inlay, SWT.NONE, this); cv.addDoubleClickListener(new CommonViewer.DoubleClickListener() { public void doubleClicked(PersistentObject obj, CommonViewer cv) { ICodeSelectorTarget target = CodeSelectorHandler.getInstance().getCodeSelectorTarget(); if (target != null) { target.codeSelected(obj); } } }); cv.getViewerWidget().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if (!sel.isEmpty()) { IcpcCode code = (IcpcCode) sel.getFirstElement(); tCrit.setText(code.get("criteria")); tIncl.setText(code.get("inclusion")); tExcl.setText(code.get("exclusion")); tNote.setText(code.get("note")); cRight.layout(); } } }); ec[i].addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanging(final ExpansionEvent e) { ExpandableComposite src = (ExpandableComposite) e.getSource(); if (e.getState() == true) { CommonViewer cv = (CommonViewer) src.getData(); cv.notify(CommonViewer.Message.update); } UserSettings.saveExpandedState(UC2_HEADING + src.getText().substring(0, 1), e.getState()); } public void expansionStateChanged(ExpansionEvent e) { fLeft.reflow(true); } }); ec[i].setClient(inlay); } Section sCrit = tk.createSection(cRight, Section.EXPANDED); sCrit.setText("Kriterien"); tCrit = tk.createText(sCrit, "\n", SWT.BORDER | SWT.MULTI); sCrit.setClient(tCrit); Section sIncl = tk.createSection(cRight, Section.EXPANDED); sIncl.setText("Einschliesslich"); tIncl = tk.createText(sIncl, "\n", SWT.BORDER | SWT.MULTI); sIncl.setClient(tIncl); Section sExcl = tk.createSection(cRight, Section.EXPANDED); sExcl.setText("Ausser"); tExcl = tk.createText(sExcl, "", SWT.BORDER | SWT.MULTI); Section sNote = tk.createSection(cRight, Section.EXPANDED); tNote = tk.createText(cRight, "\n", SWT.BORDER | SWT.MULTI); sNote.setText("Anmerkung"); }
From source file:ch.elexis.impfplan.view.AddVaccinationDialog.java
License:Open Source License
@Override protected void okPressed() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel.isEmpty()) { MessageDialog.openError(getShell(), Messages.AddVaccinationDialog_enterVaccinationTitle, Messages.AddVaccinationDialog_enterVaccinationTextError + "."); return;/* w ww . j a va2 s . c o m*/ } result = (VaccinationType) sel.getFirstElement(); date = new TimeTool(di.getDate()); bUnexact = bCa.getSelection(); super.okPressed(); }
From source file:ch.elexis.impfplan.view.ImpfplanPreferences.java
License:Open Source License
private void edit() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { VaccinationType t = (VaccinationType) sel.getFirstElement(); if (new EditVaccinationDialog(getShell(), t).open() == Dialog.OK) { tv.refresh(true);/*from w w w . j a va 2s. co m*/ } } }
From source file:ch.elexis.impfplan.view.ImpfplanPreferences.java
License:Open Source License
private void makeActions() { removeAction = new Action(Messages.ImpfplanPreferences_removeVaccination) { {/*from w ww .j ava 2 s .com*/ setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); setToolTipText(Messages.ImpfplanPreferences_removeVaccWarning); } @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { VaccinationType t = (VaccinationType) sel.getFirstElement(); if (t.delete()) { tv.remove(sel.getFirstElement()); } } } }; }
From source file:ch.elexis.impfplan.view.ImpfplanView.java
License:Open Source License
private void makeActions() { addVacination = new Action(Messages.ImpfplanView_vaccinateActionTitle) { {// www. j a v a2 s.c o m setToolTipText(Messages.ImpfplanView_vaccinateActionTooltip); setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); } @Override public void run() { AddVaccinationDialog dlg = new AddVaccinationDialog(getViewSite().getShell()); if (dlg.open() == Dialog.OK) { new Vaccination(dlg.result, ElexisEventDispatcher.getSelectedPatient(), new TimeTool(dlg.date), dlg.bUnexact); tvVaccsDone.refresh(); tvVaccsRecommended.refresh(); } } }; printVaccinations = new Action(Messages.ImpfplanView_printActionTitle) { { setToolTipText(Messages.ImpfplanView_printActionTooltip); setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); } @Override public void run() { ImpfplanPrinter ipr = new ImpfplanPrinter(getSite().getShell()); ipr.open(); } }; removeVaccination = new Action(Messages.ImpfplanView_removeActionTitle) { { setToolTipText(Messages.ImpfplanView_removeActionTooltip); setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); } @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tvVaccsDone.getSelection(); if (!sel.isEmpty()) { Vaccination v = (Vaccination) sel.getFirstElement(); if (v.delete()) { tvVaccsDone.remove(v); } } } }; }
From source file:ch.elexis.preferences.inputs.ACLPreferenceTree.java
License:Open Source License
public ACLPreferenceTree(Composite parent, ACE... acl) { super(parent, SWT.NONE); acls = new Tree<ACE>(null, null); for (ACE s : acl) { Tree<ACE> mine = acls.find(s, true); if (mine == null) { Tree<ACE> parentTree = findParent(s); if (parentTree != null) { new Tree<ACE>(parentTree, s); } else { Hub.log.log("Could not find parent ACE " + s.getName(), Log.ERRORS); }// w w w. j ava 2 s .c o m } } setLayout(new GridLayout()); setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); tv = new TreeViewer(this); tv.setContentProvider(new ITreeContentProvider() { public Object[] getChildren(Object parentElement) { Tree tree = (Tree) parentElement; return tree.getChildren().toArray(); } public Object getParent(Object element) { return ((Tree) element).getParent(); } public boolean hasChildren(Object element) { Tree tree = (Tree) element; return tree.hasChildren(); } public Object[] getElements(Object inputElement) { return acls.getChildren().toArray(); } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return (String) ((Tree<ACE>) element).contents.getLocalizedName(); } }); tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); Composite cBottom = new Composite(this, SWT.NONE); cBottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cBottom.setLayout(new GridLayout(2, true)); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLES_DEFAULT); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLE_USERS); lbGroups = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lbGroups.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lUsers = Hub.getUserList(); for (Anwender an : lUsers) { lbUsers.add(an.getLabel()); } List<String> lGroups = Hub.acl.getGroups(); for (String s : lGroups) { lbGroups.add(s); } tv.addSelectionChangedListener(new ISelectionChangedListener() { /** * if the user selects an ACL from the TreeViewer, we want to select users and groups * that are granted this acl in the lbGroups and lbUsers ListBoxes */ public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); lbGroups.deselectAll(); lbUsers.deselectAll(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; List<String> grps = Hub.acl.groupsForGrant(right); List<Anwender> users = Hub.acl.usersForGrant(right); for (String g : grps) { int idx = StringTool.getIndex(lbGroups.getItems(), g); if (idx != -1) { lbGroups.select(idx); } } for (Anwender an : users) { int idx = StringTool.getIndex(lbUsers.getItems(), an.getLabel()); if (idx != -1) { lbUsers.select(idx); } } } } }); lbGroups.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; String[] gsel = lbGroups.getSelection(); for (String g : lbGroups.getItems()) { Hub.acl.revoke(g, right); } for (String g : gsel) { Hub.acl.grant(g, right); } } } }); lbUsers.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; int[] uSel = lbUsers.getSelectionIndices(); for (Anwender an : lUsers) { Hub.acl.revoke(an, right); } for (int i : uSel) { Hub.acl.grant(lUsers.get(i), right); } } } }); tv.setSorter(new ViewerSorter() { @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { Tree<ACE> t1 = (Tree<ACE>) e1; Tree<ACE> t2 = (Tree<ACE>) e2; return t1.contents.getLocalizedName().compareToIgnoreCase(t2.contents.getLocalizedName()); } }); tv.setInput(this); }