List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:ch.elexis.core.application.advisors.ApplicationWorkbenchAdvisor.java
License:Open Source License
@Override public void postStartup() { List<Reminder> reminderList = Reminder.findToShowOnStartup(CoreHub.actUser); if (reminderList.size() > 0) { final StringBuilder sb = new StringBuilder(); for (Reminder reminder : reminderList) { sb.append(reminder.getKontakt().getLabel() + ", Id[" + reminder.getKontakt().getPatCode() + "]:\n"); sb.append(reminder.getSubject() + "\n" + reminder.getMessage()).append("\n\n"); }//from w w w . j a v a 2s . co m // must be called inside display thread Display.getDefault().asyncExec(new Runnable() { @Override public void run() { MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ReminderView_importantRemindersOnLogin, sb.toString()); } }); } }
From source file:ch.elexis.core.application.listeners.MessageEventListener.java
License:Open Source License
@Override public void run(final ElexisEvent ev) { Display.getDefault().syncExec(new Runnable() { @Override/*from w ww . j a v a 2 s.c om*/ public void run() { MessageEvent me = (MessageEvent) ev.getGenericObject(); log.debug("MessageEvent [TITLE] " + me.title); switch (me.mt) { case ERROR: MessageDialog.openError(UiDesk.getTopShell(), me.title, me.message); break; case WARN: MessageDialog.openWarning(UiDesk.getTopShell(), me.title, me.message); break; default: MessageDialog.openInformation(UiDesk.getTopShell(), me.title, me.message); break; } } }); }
From source file:ch.elexis.core.ui.commands.BillingProposalViewCreateBillsHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { List<Konsultation> kons = getToBill(event); final List<Konsultation> toBill = BillingUtil.getKonsultationsFromSameYear(kons); if (toBill.size() > 0 && toBill.size() != kons.size()) { if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Rechnung Validierung", "Eine Rechnung kann nur Leistungen innerhalb eines Jahres beinhalten.\n\nWollen Sie mit der Erstellung der Rechnung fr das Jahr " + new TimeTool(toBill.get(0).getDatum()).get(TimeTool.YEAR) + " fortsetzen ?")) { LoggerFactory.getLogger(BillingProposalViewCreateBillsHandler.class) .warn("Invoice creation canceled by user"); return null; }/* w w w .j a v a 2 s. com*/ } ProgressMonitorDialog dialog = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event)); try { dialog.run(true, false, new IRunnableWithProgress() { private int successful = 0; private int errorneous = 0; private StringBuilder errorneousInfo = new StringBuilder(); @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Rechnungen erstellen", 3); List<Konsultation> billable = BillingUtil.filterNotBillable(toBill); monitor.worked(1); Map<Rechnungssteller, Map<Fall, List<Konsultation>>> toBillMap = BillingUtil .getGroupedBillable(billable); monitor.worked(1); // create all bills List<Result<Rechnung>> results = BillingUtil.createBills(toBillMap); // build information to show for (Result<Rechnung> result : results) { if (result.isOK()) { successful++; } else { errorneousInfo.append(result.getSeverity()).append(" -> "); List<Result<Rechnung>.msg> messages = result.getMessages(); for (int i = 0; i < messages.size(); i++) { if (i > 0) { errorneousInfo.append(" / "); } errorneousInfo.append(messages.get(i).getText()); } errorneousInfo.append("\n"); errorneous++; } } monitor.worked(1); monitor.done(); // show information Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Info", MessageFormat.format( "Es wurden {0} Rechnungen erfolgreich erstellt.\nBei {1} Rechnungen traten Fehler auf.\n{2}", successful, errorneous, errorneousInfo.toString())); } }); } }); } catch (InvocationTargetException | InterruptedException e) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler", "Fehler beim Ausfhren der Rechnungserstelltung. Details siehe Log."); LoggerFactory.getLogger(BillingProposalViewCreateBillsHandler.class).error("Error creating bills", e); return null; } return null; }
From source file:ch.elexis.core.ui.dialogs.KontaktErfassenDialog.java
License:Open Source License
private void createKontakt() { String[] ret = new String[8]; ret[0] = tName.getText();/*from w w w .ja va 2 s .com*/ ret[1] = tVorname.getText(); int idx = cbSex.getSelectionIndex(); if (idx == -1) { SWTHelper.showError(Messages.KontaktErfassenDialog_geschlechtFehlt_title, //$NON-NLS-1$ Messages.KontaktErfassenDialog_geschlechtFehlt_msg); //$NON-NLS-1$ return; } ret[2] = cbSex.getItem(idx); ret[3] = tGebDat.getText(); try { if (!StringTool.isNothing(ret[3])) { new TimeTool(ret[3], true); } ret[4] = tStrasse.getText(); ret[5] = tPlz.getText(); ret[6] = tOrt.getText(); ret[7] = tTel.getText(); if (newKontakt == null) { Query<Kontakt> qbe = new Query<Kontakt>(Kontakt.class); qbe.add("Bezeichnung1", "=", ret[0]); //$NON-NLS-1$ //$NON-NLS-2$ qbe.add("Bezeichnung2", "=", ret[1]); //$NON-NLS-1$ //$NON-NLS-2$ List<Kontakt> list = qbe.execute(); if ((list != null) && (!list.isEmpty())) { Kontakt k = list.get(0); if (bOrganisation.getSelection() && k.istOrganisation()) { if (bLabor.getSelection()) { k.set("istOrganisation", "1"); //$NON-NLS-1$ //$NON-NLS-2$ } if (MessageDialog.openConfirm(getShell(), Messages.KontaktErfassenDialog_organisationExistiert_title, //$NON-NLS-1$ Messages.KontaktErfassenDialog_organisationExistiert_msg) == false) { //$NON-NLS-1$ super.okPressed(); return; } } if (k.istPerson()) { if (bAnwender.getSelection()) { k.set("istAnwender", "1"); //$NON-NLS-1$ //$NON-NLS-2$ } if (bMandant.getSelection()) { k.set("istMandant", "1"); //$NON-NLS-1$ //$NON-NLS-2$ } if (bPatient.getSelection()) { k.set("istPatient", "1"); //$NON-NLS-1$ //$NON-NLS-2$ } if (MessageDialog.openConfirm(getShell(), Messages.KontaktErfassenDialog_personExisitiert_title, //$NON-NLS-1$ Messages.KontaktErfassenDialog_personExisitiert_msg) == false) { //$NON-NLS-1$ super.okPressed(); return; } } } /** * Neuer Kontakt erstellen. Reihenfolge der Abfrage ist Wichtig, da ein Anwender * auch ein Mandant sein kann. "Organisation", - "Labor", "Person" - "Patient" - * "Anwender" - "Mandant" */ if (bMandant.getSelection()) { newKontakt = new Mandant(ret[0], ret[1], ret[3], ret[2]); newKontakt.set("Zusatz", tZusatz.getText()); //$NON-NLS-1$ } else if (bAnwender.getSelection()) { newKontakt = new Anwender(ret[0], ret[1], ret[3], ret[2]); newKontakt.set("Zusatz", tZusatz.getText()); //$NON-NLS-1$ } else if (bPatient.getSelection()) { newKontakt = new Patient(ret[0], ret[1], ret[3], ret[2]); newKontakt.set("Zusatz", tZusatz.getText()); //$NON-NLS-1$ } else if (bPerson.getSelection()) { newKontakt = new Person(ret[0], ret[1], ret[3], ret[2]); newKontakt.set("Zusatz", tZusatz.getText()); //$NON-NLS-1$ } else if (bLabor.getSelection()) { newKontakt = new Labor(ret[0], ret[0]); newKontakt.set("Zusatz1", ret[1]); //$NON-NLS-1$ newKontakt.set("Ansprechperson", tZusatz.getText()); //$NON-NLS-1$ } else if (bOrganisation.getSelection()) { newKontakt = new Organisation(ret[0], ret[1]); newKontakt.set("Ansprechperson", tZusatz.getText()); //$NON-NLS-1$ } else { MessageDialog.openInformation(getShell(), Messages.KontaktErfassenDialog_unbekannterTyp_title, //$NON-NLS-1$ Messages.KontaktErfassenDialog_unbekannterTyp_msg); //$NON-NLS-1$ return; } } if (CoreHub.getLocalLockService().acquireLock(newKontakt).isOk()) { newKontakt.set(new String[] { "Strasse", "Plz", "Ort", "Telefon1", "Fax", "E-Mail" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ }, new String[] { ret[4], ret[5], ret[6], ret[7], tFax.getText(), tEmail.getText() }); ElexisEventDispatcher.fireSelectionEvent(newKontakt); CoreHub.getLocalLockService().releaseLock(newKontakt); } } catch (TimeFormatException e) { ExHandler.handle(e); SWTHelper.showError(Messages.KontaktErfassenDialog_falschesDatum_title, //$NON-NLS-1$ Messages.KontaktErfassenDialog_falschesDatum_msg); //$NON-NLS-1$ return; } }
From source file:ch.elexis.core.ui.laboratory.preferences.LabSettings.java
License:Open Source License
@Override protected void createFieldEditors() { addField(new BooleanFieldEditor(Preferences.LABSETTINGS_CFG_SHOW_MANDANT_ORDERS_ONLY, Messages.LabSettings_showOrdersActiveMandant, getFieldEditorParent())); addField(new RadioGroupFieldEditor(Preferences.LABSETTINGS_CFG_LABNEW_HEARTRATE, Messages.LabSettings_frequencyNewLabvalues, 3, new String[][] { { Messages.LabSettings_normal, "1" //$NON-NLS-1$ }, { Messages.LabSettings_medium, "2" //$NON-NLS-1$ }, { Messages.LabSettings_slow, "3" //$NON-NLS-1$ } }, getFieldEditorParent())); addField(new BooleanFieldEditor(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, Messages.LabSettings_useLocalLabRefValues, getFieldEditorParent())); Composite area = new Composite(getFieldEditorParent(), SWT.NONE); area.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); area.setLayout(new GridLayout(2, false)); Label lblKeepUnseen = new Label(area, SWT.NONE); lblKeepUnseen.setText(Messages.LabSettings_showNewLabvaluesDays); txtKeepUnseen = new Text(area, SWT.BORDER); txtKeepUnseen.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); txtKeepUnseen.setText(daysKeepUnseen); Button btnValidateMappings = new Button(area, SWT.PUSH); btnValidateMappings.setText(Messages.LabSettings_validateMappings); btnValidateMappings.addSelectionListener(new SelectionAdapter() { @Override//from w w w . j a v a 2 s.c o m public void widgetSelected(SelectionEvent e) { Query<LabMapping> query = new Query<LabMapping>(LabMapping.class); query.add(LabMapping.FLD_ID, Query.NOT_EQUAL, LabMapping.VERSIONID); //$NON-NLS-1$ List<LabMapping> mappings = query.execute(); int countDeleted = 0; for (LabMapping labMapping : mappings) { if (!labMapping.isMappingValid()) { countDeleted++; labMapping.delete(); } } MessageDialog.openInformation(getShell(), Messages.LabSettings_validateMappings, MessageFormat.format(Messages.LabSettings_validateMappingsResult, countDeleted)); } }); // dummy lbl new Label(area, SWT.NONE); }
From source file:ch.elexis.core.ui.preferences.ScannerPref.java
License:Open Source License
@Override protected Control createContents(Composite parent) { super.createContents(parent); GridLayout noMarginLayout = new GridLayout(3, false); noMarginLayout.marginLeft = 0;// w w w .j a va 2 s. c om Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(noMarginLayout); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lblTest = new Label(comp, SWT.NONE); lblTest.setText(Messages.ScannerPref_test); lblTest.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final Text txtTest = new Text(comp, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.WRAP); txtTest.setLayoutData(new GridData(GridData.FILL_BOTH)); txtScannerListener = new TextScannerListener(txtTest); getShell().getDisplay().addFilter(SWT.KeyDown, txtScannerListener); backupDefaultButton = getShell().getDefaultButton(); final Button hiddenBtn = new Button(parent, SWT.PUSH); hiddenBtn.setVisible(false); txtTest.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { getShell().setDefaultButton(hiddenBtn); } public void focusLost(FocusEvent e) { getShell().setDefaultButton(backupDefaultButton); } }); Button btnClear = new Button(comp, SWT.PUSH); btnClear.setText(Messages.ScannerPref_clear); btnClear.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); btnClear.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { txtTest.setText(""); //$NON-NLS-1$ txtTest.setFocus(); } }); Button btnSteuerblatt = new Button(parent, SWT.PUSH); btnSteuerblatt.setText(Messages.ScannerPref_printSheet); btnSteuerblatt.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MessageDialog.openInformation(getShell(), Messages.ScannerPref_printSettingsSheet, Messages.ScannerPref_NotImplemented); } }); return parent; }
From source file:ch.elexis.core.ui.stock.dialogs.ImportArticleDialog.java
License:Open Source License
private void doImport() { StringBuffer buf = new StringBuffer(); // check for store availability final List<String> storeIds = ArticleServiceHolder.getStoreIds(); if (storeIds.isEmpty()) { buf.append(/*from w w w . j av a 2 s . com*/ "Es ist kein Artikelservice registriert. Vergewissern Sie sich, dass zumindest ein Artikel Plugin installiert ist."); } else { // check for stock availability StructuredSelection iSelection = (StructuredSelection) comboStockType.getSelection(); if (iSelection.isEmpty()) { buf.append("Bitte whlen Sie ein Lager aus."); } else { final Stock stock = (Stock) iSelection.getFirstElement(); // check src file String path = tFilePath.getText(); if (path != null && !path.isEmpty() && path.toLowerCase().endsWith("xls")) { try (FileInputStream is = new FileInputStream(tFilePath.getText())) { ExcelWrapper xl = new ExcelWrapper(); if (xl.load(is, 0)) { xl.setFieldTypes(new Class[] { Integer.class, String.class, String.class, String.class, String.class, String.class, Integer.class, String.class, String.class }); MessageDialog dialog = new MessageDialog(getShell(), "Datenimport", null, "Wie sollen die Datenbestnde importiert werden ?", MessageDialog.QUESTION, 0, "Datenbestand 'exakt' importieren", "Datenbestand 'aufaddieren'"); int ret = dialog.open(); if (ret >= 0) { runImport(buf, storeIds, stock, xl, ret == 0); } return; } } catch (IOException e) { MessageDialog.openError(getShell(), "Import error", "Import fehlgeschlagen.\nDatei nicht importierbar: " + path); LoggerFactory.getLogger(ImportArticleDialog.class).error("cannot import file at " + path, e); } } else { buf.append("Die Quelldatei ist ungltig. Bitte berprfen Sie diese Datei.\n" + path); } } } if (buf.length() > 0) { MessageDialog.openInformation(getShell(), "Import Ergebnis", buf.toString()); } else { MessageDialog.openWarning(getShell(), "Import Ergebnis", "Import nicht mglich.\nberprfen Sie das Log-File."); } }
From source file:ch.elexis.core.ui.util.SWTHelper.java
License:Open Source License
/** * Eine Standard-Infomeldung asynchron zeigen * //from w w w. j a v a2 s . c om * @param title * Titel * @param message * Nachricht */ public static void showInfo(final String title, final String message) { UiDesk.getDisplay().syncExec(new Runnable() { public void run() { Shell shell = UiDesk.getTopShell(); MessageDialog.openInformation(shell, title, message); } }); }
From source file:ch.elexis.core.ui.views.BriefAuswahl.java
License:Open Source License
private void makeActions() { briefNeuAction = new Action(Messages.BriefAuswahlNewButtonText) { //$NON-NLS-1$ @Override//from w ww .ja v a 2 s . c om public void run() { Patient pat = ElexisEventDispatcher.getSelectedPatient(); if (pat == null) { MessageDialog.openInformation(UiDesk.getTopShell(), Messages.BriefAuswahlNoPatientSelected, Messages.BriefAuswahlNoPatientSelected); return; } Fall selectedFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (selectedFall == null) { SelectFallDialog sfd = new SelectFallDialog(UiDesk.getTopShell()); sfd.open(); if (sfd.result != null) { ElexisEventDispatcher.fireSelectionEvent(sfd.result); } else { MessageDialog.openInformation(UiDesk.getTopShell(), Messages.TextView_NoCaseSelected, //$NON-NLS-1$ Messages.TextView_SaveNotPossibleNoCaseAndKonsSelected); //$NON-NLS-1$ return; } } Konsultation selectedKonsultation = (Konsultation) ElexisEventDispatcher .getSelected(Konsultation.class); if (selectedKonsultation == null) { Konsultation k = pat.getLetzteKons(false); if (k == null) { k = ((Fall) ElexisEventDispatcher.getSelected(Fall.class)).neueKonsultation(); k.setMandant(CoreHub.actMandant); } ElexisEventDispatcher.fireSelectionEvent(k); } TextView tv = null; try { DocumentSelectDialog bs = new DocumentSelectDialog(getViewSite().getShell(), CoreHub.actMandant, DocumentSelectDialog.TYPE_CREATE_DOC_WITH_TEMPLATE); if (bs.open() == Dialog.OK) { tv = (TextView) getSite().getPage().showView(TextView.ID); // trick: just supply a dummy address for creating the doc Kontakt address = null; if (DocumentSelectDialog.getDontAskForAddresseeForThisTemplate(bs.getSelectedDocument())) address = Kontakt.load("-1"); //$NON-NLS-1$ tv.createDocument(bs.getSelectedDocument(), bs.getBetreff(), address); tv.setName(); CTabItem sel = ctab.getSelection(); if (sel != null) { CommonViewer cv = (CommonViewer) sel.getData(); cv.notify(CommonViewer.Message.update_keeplabels); } } } catch (Exception ex) { ExHandler.handle(ex); } } }; briefLadenAction = new Action(Messages.BriefAuswahlOpenButtonText) { //$NON-NLS-1$ @Override public void run() { try { CTabItem sel = ctab.getSelection(); if (sel != null) { CommonViewer cv = (CommonViewer) sel.getData(); Object[] o = cv.getSelection(); if ((o != null) && (o.length > 0)) { Brief brief = (Brief) o[0]; if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false)) { startLocalEditAction.run(); } else { TextView tv = (TextView) getViewSite().getPage().showView(TextView.ID); if (brief.getMimeType().equalsIgnoreCase("pdf")) { //$NON-NLS-1$ try { File temp = File.createTempFile("letter_", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$ temp.deleteOnExit(); FileOutputStream fos = new FileOutputStream(temp); fos.write(brief.loadBinary()); fos.close(); Program.launch(temp.getAbsolutePath()); } catch (IOException e) { SWTHelper.alert(Messages.BriefAuswahlErrorHeading, //$NON-NLS-1$ Messages.BriefAuswahlCouldNotLoadText); //$NON-NLS-1$ } } else if (tv.openDocument(brief) == false) { SWTHelper.alert(Messages.BriefAuswahlErrorHeading, //$NON-NLS-1$ Messages.BriefAuswahlCouldNotLoadText); //$NON-NLS-1$ } } } else { TextView tv = (TextView) getViewSite().getPage().showView(TextView.ID); tv.createDocument(null, null); } cv.notify(CommonViewer.Message.update); } } catch (PartInitException e) { ExHandler.handle(e); } } }; deleteAction = new LockRequestingAction<Brief>(Messages.BriefAuswahlDeleteButtonText) { //$NON-NLS-1$ @Override public void doRun(Brief brief) { if (brief != null && SWTHelper.askYesNo(Messages.BriefAuswahlDeleteConfirmHeading, //$NON-NLS-1$ Messages.BriefAuswahlDeleteConfirmText)) { brief.delete(); CTabItem sel = ctab.getSelection(); CommonViewer cv = (CommonViewer) sel.getData(); cv.notify(CommonViewer.Message.update); } } @Override public Brief getTargetedObject() { CTabItem sel = ctab.getSelection(); if ((sel != null)) { //$NON-NLS-1$ CommonViewer cv = (CommonViewer) sel.getData(); Object[] o = cv.getSelection(); if ((o != null) && (o.length > 0)) { if (o[0] instanceof Brief) { return (Brief) o[0]; } } } return null; } }; editNameAction = new LockRequestingAction<Brief>(Messages.BriefAuswahlRenameButtonText) { //$NON-NLS-1$ @Override public void doRun(Brief brief) { if (brief != null) { InputDialog id = new InputDialog(getViewSite().getShell(), Messages.BriefAuswahlNewSubjectHeading, //$NON-NLS-1$ Messages.BriefAuswahlNewSubjectText, //$NON-NLS-1$ brief.getBetreff(), null); if (id.open() == Dialog.OK) { brief.setBetreff(id.getValue()); } CTabItem sel = ctab.getSelection(); CommonViewer cv = (CommonViewer) sel.getData(); cv.notify(CommonViewer.Message.update); } } @Override public Brief getTargetedObject() { CTabItem sel = ctab.getSelection(); if (sel != null) { //$NON-NLS-1$ CommonViewer cv = (CommonViewer) sel.getData(); Object[] o = cv.getSelection(); if ((o != null) && (o.length > 0)) { if (o[0] instanceof Brief) { return (Brief) o[0]; } } } return null; } }; startLocalEditAction = new Action() { @Override public ImageDescriptor getImageDescriptor() { return Images.IMG_EDIT.getImageDescriptor(); } @Override public String getText() { return Messages.BriefAuswahl_actionlocaledittext; } @Override public void run() { Brief brief = getSelectedBrief(); if (brief != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getSite().getShell(), Messages.BriefAuswahl_errorttile, Messages.BriefAuswahl_erroreditmessage); } refreshSelectedViewer(); } } }; endLocalEditAction = new Action() { @Override public ImageDescriptor getImageDescriptor() { return Images.IMG_EDIT_DONE.getImageDescriptor(); } @Override public String getText() { return Messages.BriefAuswahl_actionlocaleditstopmessage; } @Override public void run() { Brief brief = getSelectedBrief(); if (brief != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.endLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getSite().getShell(), Messages.BriefAuswahl_errortitle, Messages.BriefAuswahl_errorlocaleditendmessage); } } refreshSelectedViewer(); } }; cancelLocalEditAction = new Action() { @Override public ImageDescriptor getImageDescriptor() { return Images.IMG_EDIT_ABORT.getImageDescriptor(); } @Override public String getText() { return Messages.BriefAuswahl_actionlocaleditabortmessage; } @Override public void run() { Brief brief = getSelectedBrief(); if (brief != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.abortLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getSite().getShell(), Messages.BriefAuswahl_errortitle, Messages.BriefAuswahl_errorlocaleditabortmessage); } } refreshSelectedViewer(); } }; /* * importAction=new Action("Importieren..."){ public void run(){ * * } }; */ briefLadenAction.setImageDescriptor(Images.IMG_DOCUMENT_TEXT.getImageDescriptor()); briefLadenAction.setToolTipText(Messages.BriefAuswahlOpenLetterForEdit); //$NON-NLS-1$ briefNeuAction.setImageDescriptor(Images.IMG_DOCUMENT_ADD.getImageDescriptor()); briefNeuAction.setToolTipText(Messages.BriefAuswahlCreateNewDocument); //$NON-NLS-1$ editNameAction.setImageDescriptor(Images.IMG_DOCUMENT_WRITE.getImageDescriptor()); editNameAction.setToolTipText(Messages.BriefAuswahlRenameDocument); //$NON-NLS-1$ deleteAction.setImageDescriptor(Images.IMG_DOCUMENT_REMOVE.getImageDescriptor()); deleteAction.setToolTipText(Messages.BriefAuswahlDeleteDocument); //$NON-NLS-1$ }
From source file:ch.elexis.core.ui.views.TextView.java
License:Open Source License
private void makeActions() { briefLadenAction = new Action(Messages.TextView_openLetter) { //$NON-NLS-1$ @Override/*from w ww . j av a 2s .c o m*/ public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); DocumentSelectDialog bs = new DocumentSelectDialog(getViewSite().getShell(), actPatient, DocumentSelectDialog.TYPE_LOAD_DOCUMENT); if (bs.open() == Dialog.OK) { openDocument(bs.getSelectedDocument()); } } }; loadSysTemplateAction = new Action(Messages.TextView_openSysTemplate) { //$NON-NLS-1$ @Override public void run() { DocumentSelectDialog bs = new DocumentSelectDialog(getViewSite().getShell(), CoreHub.actMandant, DocumentSelectDialog.TYPE_LOAD_SYSTEMPLATE); if (bs.open() == Dialog.OK) { openDocument(bs.getSelectedDocument()); } } }; loadTemplateAction = new Action(Messages.TextView_openTemplate) { //$NON-NLS-1$ @Override public void run() { DocumentSelectDialog bs = new DocumentSelectDialog(getViewSite().getShell(), CoreHub.actMandant, DocumentSelectDialog.TYPE_LOAD_TEMPLATE); if (bs.open() == Dialog.OK) { openDocument(bs.getSelectedDocument()); } } }; saveTemplateAction = new Action(Messages.TextView_saveAsTemplate) { //$NON-NLS-1$ @Override public void run() { if (actBrief != null) { txt.saveTemplate(actBrief.get(Messages.TextView_Subject)); //$NON-NLS-1$ } else { txt.saveTemplate(null); } } }; showMenuAction = new Action(Messages.TextView_showMenu, Action.AS_CHECK_BOX) { //$NON-NLS-1$ public void run() { txt.getPlugin().showMenu(isChecked()); } }; showToolbarAction = new Action(Messages.TextView_Toolbar, Action.AS_CHECK_BOX) { //$NON-NLS-1$ public void run() { txt.getPlugin().showToolbar(isChecked()); } }; importAction = new Action(Messages.TextView_importText) { //$NON-NLS-1$ @Override public void run() { try { FileDialog fdl = new FileDialog(getViewSite().getShell()); String filename = fdl.open(); if (filename != null) { File file = new File(filename); if (file.exists()) { actBrief = null; setPartName(filename); FileInputStream fis = new FileInputStream(file); txt.getPlugin().loadFromStream(fis, false); } } } catch (Throwable ex) { ExHandler.handle(ex); } } }; exportAction = new Action(Messages.TextView_exportText) { //$NON-NLS-1$ @Override public void run() { try { if (actBrief == null) { SWTHelper.alert("Fehler", //$NON-NLS-1$ "Es ist kein Dokument zum exportieren geladen"); //$NON-NLS-1$ } else { FileDialog fdl = new FileDialog(getViewSite().getShell(), SWT.SAVE); fdl.setFilterExtensions(new String[] { "*.odt", "*.xml", "*.*" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }); fdl.setFilterNames(new String[] { "OpenOffice.org Text", "XML File", "All files" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }); String filename = fdl.open(); if (filename != null) { if (FileTool.getExtension(filename).equals("")) { //$NON-NLS-1$ filename += ".odt"; //$NON-NLS-1$ } File file = new File(filename); byte[] contents = actBrief.loadBinary(); ByteArrayInputStream bais = new ByteArrayInputStream(contents); FileOutputStream fos = new FileOutputStream(file); FileTool.copyStreams(bais, fos); fos.close(); bais.close(); } } } catch (Throwable ex) { ExHandler.handle(ex); } } }; newDocAction = new Action(Messages.TextView_newDocument) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); } public void run() { Patient pat = ElexisEventDispatcher.getSelectedPatient(); if (pat != null) { Fall selectedFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (selectedFall == null) { SelectFallDialog sfd = new SelectFallDialog(UiDesk.getTopShell()); sfd.open(); if (sfd.result != null) { ElexisEventDispatcher.fireSelectionEvent(sfd.result); } else { MessageDialog.openInformation(UiDesk.getTopShell(), Messages.TextView_NoCaseSelected, //$NON-NLS-1$ Messages.TextView_SaveNotPossibleNoCaseAndKonsSelected); //$NON-NLS-1$ return; } } Konsultation selectedKonsultation = (Konsultation) ElexisEventDispatcher .getSelected(Konsultation.class); if (selectedKonsultation == null) { Konsultation k = pat.getLetzteKons(false); if (k == null) { k = ((Fall) ElexisEventDispatcher.getSelected(Fall.class)).neueKonsultation(); k.setMandant(CoreHub.actMandant); } ElexisEventDispatcher.fireSelectionEvent(k); } actBrief = null; setName(); txt.getPlugin().createEmptyDocument(); } else { MessageDialog.openInformation(UiDesk.getTopShell(), Messages.BriefAuswahlNoPatientSelected, //$NON-NLS-1$ Messages.BriefAuswahlNoPatientSelected); //$NON-NLS-1$ } } }; briefLadenAction.setImageDescriptor(Images.IMG_MAIL.getImageDescriptor()); briefLadenAction.setToolTipText("Brief zum Bearbeiten ffnen"); //$NON-NLS-1$ // briefNeuAction.setImageDescriptor(Hub.getImageDescriptor("rsc/schreiben.gif")); // briefNeuAction.setToolTipText("Einen neuen Brief erstellen"); showMenuAction.setToolTipText(Messages.TextView_showMenuBar); //$NON-NLS-1$ showMenuAction.setImageDescriptor(Images.IMG_MENUBAR.getImageDescriptor()); showMenuAction.setChecked(true); showToolbarAction.setImageDescriptor(Images.IMG_TOOLBAR.getImageDescriptor()); showToolbarAction.setToolTipText(Messages.TextView_showToolbar); //$NON-NLS-1$ showToolbarAction.setChecked(true); }