List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:ch.elexis.actions.GlobalActions.java
License:Open Source License
protected void printPatient(final Patient patient) { PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer // driver is not handled correctly (we always get porttrait // even when the printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = Hub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try {// w w w. j a v a 2 s .c om iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) { } if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob(Messages.getString("GlobalActions.PrintLabelJobName")) == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); gc.drawString(Messages.getString("GlobalActions.PatientIDLabelText") + patient.getPatCode(), 0, 0); //$NON-NLS-1$ FontMetrics fmt = gc.getFontMetrics(); y += fmt.getHeight(); String pers = patient.getPersonalia(); gc.drawString(pers, 0, y); y += fmt.getHeight(); gc.drawString(patient.getAnschrift().getEtikette(false, false), 0, y); y += fmt.getHeight(); StringBuilder tel = new StringBuilder(); tel.append(Messages.getString("GlobalActions.PhoneHomeLabelText")).append(patient.get("Telefon1")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.getString("GlobalActions.PhoneWorkLabelText")) //$NON-NLS-1$ .append(patient.get("Telefon2")) //$NON-NLS-1$ .append(Messages.getString("GlobalActions.PhoneMobileLabelText")) //$NON-NLS-1$ .append(patient.get("Natel")); //$NON-NLS-1$ gc.drawString(tel.toString(), 0, y); gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.getString("GlobalActions.PrinterErrorTitle"), //$NON-NLS-1$ Messages.getString("GlobalActions.PrinterErrorMessage")); //$NON-NLS-1$ } } }
From source file:ch.elexis.actions.GlobalActions.java
License:Open Source License
protected void printPatientAuftragsnummer(final Patient patient) { PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer // driver is not handled correctly (we always get porttrait // even when the printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = Hub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try {/* w ww.j a va2s .c o m*/ iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) { } if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob(Messages.getString("GlobalActions.PrintLabelJobName")) == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); String pid = StringTool.addModulo10(patient.getPatCode()) + "-" //$NON-NLS-1$ + new TimeTool().toString(TimeTool.TIME_COMPACT); gc.drawString(Messages.getString("GlobalActions.OrderID") + ": " + pid, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ FontMetrics fmt = gc.getFontMetrics(); y += fmt.getHeight(); String pers = patient.getPersonalia(); gc.drawString(pers, 0, y); y += fmt.getHeight(); gc.drawString(patient.getAnschrift().getEtikette(false, false), 0, y); y += fmt.getHeight(); StringBuilder tel = new StringBuilder(); tel.append(Messages.getString("GlobalActions.PhoneHomeLabelText")).append(patient.get("Telefon1")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.getString("GlobalActions.PhoneWorkLabelText")) //$NON-NLS-1$ .append(patient.get("Telefon2")) //$NON-NLS-1$ .append(Messages.getString("GlobalActions.PhoneMobileLabelText")) //$NON-NLS-1$ .append(patient.get("Natel")); //$NON-NLS-1$ gc.drawString(tel.toString(), 0, y); gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.getString("GlobalActions.PrinterErrorTitle"), //$NON-NLS-1$ Messages.getString("GlobalActions.PrinterErrorMessage")); //$NON-NLS-1$ } } }
From source file:ch.elexis.actions.GlobalActions.java
License:Open Source License
protected void printAdr(final Kontakt k) { // 25.01.2010 patch tschaller: there was always the printer selection // dialog. With printEtikette it wasn't so I copied the hardcoded string // from there //PrinterData pd = getPrinterData(Messages.getString("GlobalActions.printersticker")); //$NON-NLS-1$ PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer driver is // not handled correctly (we always get porttrait even when the // printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = Hub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try {/*from w w w.j a v a 2s.c o m*/ iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) { } if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob("Etikette drucken") == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); FontMetrics fmt = gc.getFontMetrics(); String pers = k.getPostAnschrift(true); String[] lines = pers.split("\n"); //$NON-NLS-1$ for (String line : lines) { gc.drawString(line, 0, y); y += fmt.getHeight(); } gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.getString("GlobalActions.PrinterErrorTitle"), //$NON-NLS-1$ Messages.getString("GlobalActions.PrinterErrorMessage")); //$NON-NLS-1$ } } }
From source file:ch.elexis.agenda.preferences.AgendaImages.java
License:Open Source License
@Override protected Control createContents(final Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout(3, false)); for (String t : Termin.TerminTypes) { Image img = Plannables.getTypImage(t); Label lImg = new Label(ret, SWT.NONE); lImg.setImage(img);// w w w .ja v a 2s. co m Label lTx = new Label(ret, SWT.NONE); lTx.setText(t); Button bCh = new Button(ret, SWT.PUSH); bCh.setText(Messages.AgendaImages_change); bCh.setData(t); bCh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fdl = new FileDialog(parent.getShell(), SWT.OPEN); String dpath = PlatformHelper.getBasePath(Activator.PLUGIN_ID).replaceFirst("\\\\bin", "") //$NON-NLS-1$//$NON-NLS-2$ + File.separator + "icons"; //$NON-NLS-1$ fdl.setFilterPath(dpath); String name = fdl.open(); File src = new File(name); try { Image img = new Image(UiDesk.getDisplay(), new FileInputStream(src)); if (img != null) { // File bezeichnet ein lesbares Bild File dest = new File(dpath + File.separator + src.getName()); if (!dest.getAbsolutePath().equalsIgnoreCase(src.getAbsolutePath())) { // Ist noch nicht im richtigen Verzeichnis if (FileTool.copyFile(src, dest, FileTool.FAIL_IF_EXISTS) == false) { MessageDialog.openError(parent.getShell(), Messages.AgendaImages_cannotCopy, Messages.AgendaImages_6 + name + Messages.AgendaImages_7); return; } } String t = (String) ((Button) e.getSource()).getData(); CoreHub.userCfg.set(PreferenceConstants.AG_TYPIMAGE_PREFIX + t, "icons/" + dest.getName()); //$NON-NLS-1$ } } catch (Exception ex) { ExHandler.handle(ex); } } }); } return ret; }
From source file:ch.elexis.ApplicationWorkbenchAdvisor.java
License:Open Source License
private void handlePersistenceException() { Log.setAlertLevel(Log.ERRORS);/*from w w w . j av a2s . c om*/ Hub.log.log(Messages.ApplicationWorkbenchAdvisor_0 + PersistentObject.getConnection().lastErrorString, Log.ERRORS); MessageDialog.openError(loginshell, Messages.ApplicationWorkbenchAdvisor_1, Messages.ApplicationWorkbenchAdvisor_2 + PersistentObject.getConnection().lastErrorString); PersistentObject.disconnect(); WizardDialog wd = new WizardDialog(loginshell, new DBConnectWizard()); wd.open(); Hub.localCfg.flush(); System.exit(-1); }
From source file:ch.elexis.befunde.Messwert.java
License:Open Source License
/** * Here are configuration details read. If reading fails, the method assumes, that the table * does not exist yet an creates it.//from w ww .ja v a 2s.c o m * * * Hier werden Konfigurationseinzelheiten eingelesen. Wenn das Lesen fehlschlgt, nimmt die * Methode an, dass die Tabelle noch nicht existiert und legt sie neu an. * * @return */ @SuppressWarnings("unchecked") public static Messwert getSetup() { JdbcLink j = getConnection(); Messwert setup = new Messwert("__SETUP__"); //$NON-NLS-1$ if (!setup.exists()) { try { ByteArrayInputStream bais = new ByteArrayInputStream(create.getBytes("UTF-8")); //$NON-NLS-1$ if (j.execScript(bais, true, false) == false) { MessageDialog.openError(null, Messages.getString("Messwert.valuesError"), //$NON-NLS-1$ Messages.getString("Messwert.couldNotCreateTable")); //$NON-NLS-1$ return null; } Map names = setup.getMap(FLD_BEFUNDE); names.put("VERSION", Integer.toString(VERSION)); //$NON-NLS-1$ setup.setMap(FLD_BEFUNDE, names); new ACLContributor().initializeDefaults(CoreHub.acl); } catch (Exception ex) { ExHandler.handle(ex); } } else { // Update from earlier format if necessary Map names = setup.getMap(FLD_BEFUNDE); String v = (String) names.get("VERSION"); //$NON-NLS-1$ if (v == null || Integer.parseInt(v) < VERSION) { if (Integer.parseInt(v) < 4) { createOrModifyTable("ALTER TABLE " + TABLENAME + " ADD lastupdate BIGINT;"); //$NON-NLS-1$ //$NON-NLS-2$ } if (Integer.parseInt(v) < 3) { if (j.DBFlavor.equalsIgnoreCase("postgresql")) { //$NON-NLS-1$ j.exec("ALTER TABLE " + TABLENAME + " ALTER Name TYPE VARCHAR(80);"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (j.DBFlavor.equalsIgnoreCase("mysql")) { //$NON-NLS-1$ j.exec("ALTER TABLE " + TABLENAME + " MODIFY Name VARCHAR(80);"); //$NON-NLS-1$ //$NON-NLS-2$ } } if (Integer.parseInt(v) < 2) { // version 1 auf 2 j.exec("ALTER TABLE " + TABLENAME + " ADD deleted CHAR(1) default '0';"); //$NON-NLS-1$ //$NON-NLS-2$ } else { // version 0 auf 1 StringBuilder titles = new StringBuilder(); Map.Entry[] entryset = (Map.Entry[]) names.entrySet().toArray(new Map.Entry[0]); for (Map.Entry entry : entryset) { String param = (String) entry.getKey(); if (param.equals(HASH_NAMES) || param.equals("VERSION") //$NON-NLS-1$ || param.matches(".+_FIELDS")) { //$NON-NLS-1$ continue; } titles.append(param).append(SETUP_SEPARATOR); String vals = (String) entry.getValue(); StringBuilder flds = new StringBuilder(); for (String s : vals.split(",")) { //$NON-NLS-1$ flds.append(s).append(SETUP_CHECKSEPARATOR).append("s").append( //$NON-NLS-1$ SETUP_SEPARATOR); } if (flds.length() > SETUP_CHECKSEPARATOR.length()) { flds.setLength(flds.length() - SETUP_CHECKSEPARATOR.length()); names.put(param + _FIELDS, flds.toString()); } } if (titles.length() > SETUP_SEPARATOR.length()) { titles.setLength(titles.length() - SETUP_SEPARATOR.length()); names.put(HASH_NAMES, titles.toString()); } } names.put("VERSION", Integer.toString(VERSION)); //$NON-NLS-1$ setup.setMap(FLD_BEFUNDE, names); } } return setup; }
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//w w w . j ava2s. 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.actions.GlobalActions.java
License:Open Source License
public GlobalActions(final IWorkbenchWindow window) { if (Hub.mainActions != null) { return;/*from www . j a v a 2 s. co m*/ } logger = LoggerFactory.getLogger(this.getClass()); mainWindow = window; help = Hub.plugin.getWorkbench().getHelpSystem(); exitAction = ActionFactory.QUIT.create(window); exitAction.setText(Messages.GlobalActions_MenuExit); //$NON-NLS-1$ newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); newWindowAction.setText(Messages.GlobalActions_NewWindow); //$NON-NLS-1$ copyAction = ActionFactory.COPY.create(window); copyAction.setText(Messages.GlobalActions_Copy); //$NON-NLS-1$ cutAction = ActionFactory.CUT.create(window); cutAction.setText(Messages.GlobalActions_Cut); //$NON-NLS-1$ pasteAction = ActionFactory.PASTE.create(window); pasteAction.setText(Messages.GlobalActions_Paste); //$NON-NLS-1$ aboutAction = ActionFactory.ABOUT.create(window); aboutAction.setText(Messages.GlobalActions_MenuAbout); //$NON-NLS-1$ prefsAction = ActionFactory.PREFERENCES.create(window); prefsAction.setText(Messages.GlobalActions_Preferences); //$NON-NLS-1$ savePerspectiveAction = new Action(Messages.GlobalActions_SavePerspective) { //$NON-NLS-1$ { setId("savePerspektive"); //$NON-NLS-1$ // setActionDefinitionId(Hub.COMMAND_PREFIX+"savePerspektive"); //$NON-NLS-1$ setToolTipText(Messages.GlobalActions_SavePerspectiveToolTip); //$NON-NLS-1$ setImageDescriptor(Images.IMG_DISK.getImageDescriptor()); //$NON-NLS-1$ } @Override public void run() { IWorkbenchPage page = mainWindow.getActivePage(); if (page != null && page.getPerspective() != null) { page.savePerspectiveAs(page.getPerspective()); } } }; helpAction = new Action(Messages.GlobalActions_ac_handbook) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_BOOK.getImageDescriptor()); setToolTipText(Messages.GlobalActions_ac_openhandbook); //$NON-NLS-1$ } @Override public void run() { Desktop desktop = Desktop.getDesktop(); String url = CoreHub.globalCfg.get(UiPreferenceConstants.CFG_HANDBOOK, UiPreferenceConstants.DEFAULT_HANDBOOK); if (Desktop.isDesktopSupported()) { try { desktop.browse(new java.net.URI(url)); } catch (Exception e) { logger.warn("failed to open default browser :" + e); MessageDialog.openError(mainWindow.getShell(), Messages.GlobalActions_Error, Messages.GlobalActions_PreferencesHandbook_URL); ExHandler.handle(e); } } else { logger.warn("isDesktopSupported was false."); } } }; savePerspectiveAsAction = ActionFactory.SAVE_PERSPECTIVE.create(window); // ActionFactory.SAVE_PERSPECTIVE.create(window); resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window); resetPerspectiveAction.setImageDescriptor(Images.IMG_REFRESH.getImageDescriptor()); homeAction = new Action(Messages.GlobalActions_Home) { //$NON-NLS-1$ { setId("home"); //$NON-NLS-1$ setActionDefinitionId(Hub.COMMAND_PREFIX + "home"); //$NON-NLS-1$ setImageDescriptor(Images.IMG_HOME.getImageDescriptor()); setToolTipText(Messages.GlobalActions_HomeToolTip); //$NON-NLS-1$ help.setHelp(this, "ch.elexis.globalactions.homeAction"); //$NON-NLS-1$ } @Override public void run() { // String // perspektive=CoreHub.actUser.getInfoString("StartPerspektive"); String perspektive = CoreHub.localCfg.get(CoreHub.actUser + DEFAULTPERSPECTIVECFG, null); if (StringTool.isNothing(perspektive)) { perspektive = UiResourceConstants.PatientPerspektive_ID; } try { IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); PlatformUI.getWorkbench().showPerspective(perspektive, win); // Hub.heart.resume(true); } catch (Exception ex) { ExHandler.handle(ex); } } }; savePerspectiveAsDefaultAction = new Action(Messages.GlobalActions_saveasstartperspective) { //$NON-NLS-1$ { setId("start"); //$NON-NLS-1$ // setActionDefinitionId(Hub.COMMAND_PREFIX+"startPerspective"); } @Override public void run() { IPerspectiveDescriptor p = mainWindow.getActivePage().getPerspective(); CoreHub.localCfg.set(CoreHub.actUser + DEFAULTPERSPECTIVECFG, p.getId()); // CoreHub.actUser.setInfoElement("StartPerspektive",p.getId()); } }; loginAction = new Action(Messages.GlobalActions_Login) { //$NON-NLS-1$ { setId("login"); //$NON-NLS-1$ setActionDefinitionId(Hub.COMMAND_PREFIX + "login"); //$NON-NLS-1$ } @Override public void run() { try { IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchWindow[] wins = PlatformUI.getWorkbench().getWorkbenchWindows(); for (IWorkbenchWindow w : wins) { if (!w.equals(win)) { w.close(); } } CoreHub.logoffAnwender(); LoginDialog dlg = new LoginDialog(win.getShell()); dlg.create(); dlg.setTitle(Messages.GlobalActions_LoginDialogTitle); //$NON-NLS-1$ dlg.setMessage(Messages.GlobalActions_LoginDialogMessage); //$NON-NLS-1$ // dlg.getButton(IDialogConstants.CANCEL_ID).setText("Beenden"); dlg.getShell().setText(Messages.GlobalActions_LoginDialogShelltext); //$NON-NLS-1$ if (dlg.open() == Dialog.CANCEL) { exitAction.run(); } adaptForUser(); } catch (Exception ex) { ExHandler.handle(ex); } System.out.println("login"); //$NON-NLS-1$ } }; importAction = new Action(Messages.GlobalActions_Import) { //$NON-NLS-1$ { setId("import"); //$NON-NLS-1$ setActionDefinitionId(Hub.COMMAND_PREFIX + "import"); //$NON-NLS-1$ } @Override public void run() { // cnv.open(); Importer imp = new Importer(mainWindow.getShell(), ExtensionPointConstantsUi.FREMDDATENIMPORT); imp.create(); imp.setMessage(Messages.GlobalActions_ImportDlgMessage); //$NON-NLS-1$ imp.getShell().setText(Messages.GlobalActions_ImportDlgShelltext); //$NON-NLS-1$ imp.setTitle(Messages.GlobalActions_ImportDlgTitle); //$NON-NLS-1$ imp.open(); } }; connectWizardAction = new Action(Messages.GlobalActions_Connection) { //$NON-NLS-1$ { setId("connectWizard"); //$NON-NLS-1$ setActionDefinitionId(Hub.COMMAND_PREFIX + "connectWizard"); //$NON-NLS-1$ } @Override public void run() { WizardDialog wd = new WizardDialog(mainWindow.getShell(), new DBConnectWizard()); wd.open(); } }; changeMandantAction = new Action(Messages.GlobalActions_Mandator) { //$NON-NLS-1$ { setId("changeMandant"); //$NON-NLS-1$ // setActionDefinitionId(Hub.COMMAND_PREFIX+"changeMandant"); //$NON-NLS-1$ } @Override public void run() { ChangeMandantDialog cmd = new ChangeMandantDialog(); if (cmd.open() == org.eclipse.jface.dialogs.Dialog.OK) { Mandant n = cmd.result; if (n != null) { Hub.setMandant(n); } } } }; printKontaktEtikette = new Action(Messages.GlobalActions_PrintContactLabel) { //$NON-NLS-1$ { setToolTipText(Messages.GlobalActions_PrintContactLabelToolTip); //$NON-NLS-1$ setImageDescriptor(Images.IMG_ADRESSETIKETTE.getImageDescriptor()); } @Override public void run() { Kontakt kontakt = (Kontakt) ElexisEventDispatcher.getSelected(Kontakt.class); if (kontakt == null) { SWTHelper.showInfo("Kein Kontakt ausgewhlt", "Bitte whlen Sie vor dem Drucken einen Kontakt!"); return; } EtiketteDruckenDialog dlg = new EtiketteDruckenDialog(mainWindow.getShell(), kontakt, TT_ADDRESS_LABEL); dlg.setTitle(Messages.GlobalActions_PrintContactLabel); dlg.setMessage(Messages.GlobalActions_PrintContactLabelToolTip); if (isDirectPrint()) { dlg.setBlockOnOpen(false); dlg.open(); if (dlg.doPrint()) { dlg.close(); } else { SWTHelper.alert("Fehler beim Drucken", "Beim Drucken ist ein Fehler aufgetreten. Bitte berprfen Sie die Einstellungen."); } } else { dlg.setBlockOnOpen(true); dlg.open(); } } }; printAdresse = new Action(Messages.GlobalActions_PrintAddressLabel) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_ADRESSETIKETTE.getImageDescriptor()); setToolTipText(Messages.GlobalActions_PrintAddressLabelToolTip); //$NON-NLS-1$ } @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (actPatient == null) { SWTHelper.showInfo("Kein Patient ausgewhlt", "Bitte whlen Sie vor dem Drucken einen Patient!"); return; } EtiketteDruckenDialog dlg = new EtiketteDruckenDialog(mainWindow.getShell(), actPatient, TT_ADDRESS_LABEL); dlg.setTitle(Messages.GlobalActions_PrintAddressLabel); dlg.setMessage(Messages.GlobalActions_PrintAddressLabelToolTip); if (isDirectPrint()) { dlg.setBlockOnOpen(false); dlg.open(); if (dlg.doPrint()) { dlg.close(); } else { SWTHelper.alert("Fehler beim Drucken", "Beim Drucken ist ein Fehler aufgetreten. Bitte berprfen Sie die Einstellungen."); } } else { dlg.setBlockOnOpen(true); dlg.open(); } } }; printVersionedEtikette = new Action(Messages.GlobalActions_PrintVersionedLabel) { //$NON-NLS-1$ { setToolTipText(Messages.GlobalActions_PrintVersionedLabelToolTip); //$NON-NLS-1$ setImageDescriptor(Images.IMG_VERSIONEDETIKETTE.getImageDescriptor()); } @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (actPatient == null) { SWTHelper.showInfo("Kein Patient ausgewhlt", "Bitte whlen Sie vor dem Drucken einen Patient!"); return; } EtiketteDruckenDialog dlg = new EtiketteDruckenDialog(mainWindow.getShell(), actPatient, TT_PATIENT_LABEL_ORDER); dlg.setTitle(Messages.GlobalActions_PrintVersionedLabel); dlg.setMessage(Messages.GlobalActions_PrintVersionedLabelToolTip); if (isDirectPrint()) { dlg.setBlockOnOpen(false); dlg.open(); if (dlg.doPrint()) { dlg.close(); } else { SWTHelper.alert("Fehler beim Drucken", "Beim Drucken ist ein Fehler aufgetreten. Bitte berprfen Sie die Einstellungen."); } } else { dlg.setBlockOnOpen(true); dlg.open(); } } }; printEtikette = new Action(Messages.GlobalActions_PrintLabel) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_PATIENTETIKETTE.getImageDescriptor()); setToolTipText(Messages.GlobalActions_PrintLabelToolTip); //$NON-NLS-1$ } @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (actPatient == null) { SWTHelper.showInfo("Kein Patient ausgewhlt", "Bitte whlen Sie vor dem Drucken einen Patient!"); return; } EtiketteDruckenDialog dlg = new EtiketteDruckenDialog(mainWindow.getShell(), actPatient, TT_PATIENT_LABEL); dlg.setTitle(Messages.GlobalActions_PrintLabel); dlg.setMessage(Messages.GlobalActions_PrintLabelToolTip); if (isDirectPrint()) { dlg.setBlockOnOpen(false); dlg.open(); if (dlg.doPrint()) { dlg.close(); } else { SWTHelper.alert("Fehler beim Drucken", "Beim Drucken ist ein Fehler aufgetreten. Bitte berprfen Sie die Einstellungen."); } } else { dlg.setBlockOnOpen(true); dlg.open(); } } }; printBlatt = new Action(Messages.GlobalActions_PrintEMR) { //$NON-NLS-1$ @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); String printer = CoreHub.localCfg.get("Drucker/Einzelblatt/Name", null); //$NON-NLS-1$ String tray = CoreHub.localCfg.get("Drucker/Einzelblatt/Schacht", null); //$NON-NLS-1$ new TemplateDrucker(TT_KG_COVER_SHEET, printer, tray).doPrint(actPatient); //$NON-NLS-1$ } }; showBlatt = new Action(Messages.GlobalActions_ShowEMR) { //$NON-NLS-1$ @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); try { TemplatePrintView tpw = (TemplatePrintView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(TemplatePrintView.ID); tpw.doShow(actPatient, TT_KG_COVER_SHEET); } catch (PartInitException e) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Fehler", "Konnte View nicht ffnen"); LoggerFactory.getLogger(getClass()).error("Error showing " + TemplatePrintView.ID, e); } } }; printRoeBlatt = new Action(Messages.GlobalActions_PrintXRay) { //$NON-NLS-1$ @Override public void run() { Patient actPatient = (Patient) ElexisEventDispatcher.getSelected(Patient.class); String printer = CoreHub.localCfg.get("Drucker/A4/Name", null); //$NON-NLS-1$ String tray = CoreHub.localCfg.get("Drucker/A4/Schacht", null); //$NON-NLS-1$ new TemplateDrucker(TT_XRAY, printer, tray).doPrint(actPatient); //$NON-NLS-1$ } }; fixLayoutAction = new Action(Messages.GlobalActions_LockPerspectives, Action.AS_CHECK_BOX) { //$NON-NLS-1$ { setToolTipText(Messages.GlobalActions_LockPerspectivesToolTip); //$NON-NLS-1$ } @Override public void run() { // store the current value in the user's configuration CoreHub.userCfg.set(Preferences.USR_FIX_LAYOUT, fixLayoutAction.isChecked()); } }; makeBillAction = new Action(Messages.GlobalActions_MakeBill) { //$NON-NLS-1$ @Override public void run() { Fall actFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); Mandant mnd = ElexisEventDispatcher.getSelectedMandator(); if (actFall != null && mnd != null) { String rsId = mnd.getRechnungssteller().getId(); Konsultation[] bhdl = actFall.getBehandlungen(false); List<Konsultation> lBehdl = new ArrayList<Konsultation>(bhdl.length); for (Konsultation b : bhdl) { Rechnung rn = b.getRechnung(); if (rn == null) { if (b.getMandant().getRechnungssteller().getId().equals(rsId)) { lBehdl.add(b); } } } lBehdl = BillingUtil.getKonsultationsFromSameYear(lBehdl); Result<Rechnung> res = Rechnung.build(lBehdl); if (!res.isOK()) { ErrorDialog.openError(mainWindow.getShell(), Messages.GlobalActions_Error, Messages //$NON-NLS-1$ .GlobalActions_BillErrorMessage, ResultAdapter //$NON-NLS-1$ .getResultAsStatus(res)); // Rechnung rn=(Rechnung)res.get(); // rn.storno(true); // rn.delete(); } } // setFall(actFall,null); } }; moveBehandlungAction = new LockedAction<Konsultation>(Messages.GlobalActions_AssignCase) { @Override public Konsultation getTargetedObject() { return (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class); } @Override public void doRun(Konsultation element) { // TODO do we need to lock the fall? SelectFallDialog dlg = new SelectFallDialog(mainWindow.getShell()); if (dlg.open() == Dialog.OK) { Fall f = dlg.result; if (f != null) { element.setFall(f); ElexisEventDispatcher.fireSelectionEvent(f); } } } }; redateAction = new LockedAction<Konsultation>(Messages.GlobalActions_Redate) { @Override public Konsultation getTargetedObject() { return (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class); } @Override public void doRun(Konsultation element) { DateSelectorDialog dlg = new DateSelectorDialog(mainWindow.getShell()); if (dlg.open() == Dialog.OK) { TimeTool date = dlg.getSelectedDate(); element.setDatum(date.toString(TimeTool.DATE_GER), false); // notify listeners about change ElexisEventDispatcher.getInstance() .fire(new ElexisEvent(element, Konsultation.class, ElexisEvent.EVENT_UPDATE)); ElexisEventDispatcher.fireSelectionEvent(element); } } }; delFallAction = new LockedRestrictedAction<Fall>(AccessControlDefaults.DELETE_CASE, Messages.GlobalActions_DeleteCase) { @Override public void doRun(Fall element) { if ((element.delete(false) == false)) { SWTHelper.alert(Messages.GlobalActions_CouldntDeleteCaseMessage, Messages.GlobalActions_CouldntDeleteCaseExplanation); } ElexisEventDispatcher.reload(Fall.class); } @Override public Fall getTargetedObject() { return (Fall) ElexisEventDispatcher.getSelected(Fall.class); } }; delKonsAction = new LockedRestrictedAction<Konsultation>(AccessControlDefaults.KONS_DELETE, Messages.GlobalActions_DeleteKons) { @Override public void doRun(Konsultation element) { if (element.delete(false) == false) { SWTHelper.alert(Messages.GlobalActions_CouldntDeleteKons, //$NON-NLS-1$ Messages.GlobalActions_CouldntDeleteKonsExplanation + //$NON-NLS-1$ Messages.GlobalActions_97); //$NON-NLS-1$ } ElexisEventDispatcher.clearSelection(Konsultation.class); ElexisEventDispatcher.fireSelectionEvent(element.getFall()); } @Override public Konsultation getTargetedObject() { return (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class); } }; openFallaction = new Action(Messages.GlobalActions_EditCase) { //$NON-NLS-1$ @Override public void run() { try { Hub.plugin.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(FallDetailView.ID); // getViewSite().getPage().showView(FallDetailView.ID); } catch (Exception ex) { ExHandler.handle(ex); } } }; reopenFallAction = new LockedRestrictedAction<Fall>(AccessControlDefaults.CASE_REOPEN, Messages.GlobalActions_ReopenCase) { @Override public void doRun(Fall element) { element.setEndDatum(StringConstants.EMPTY); } @Override public Fall getTargetedObject() { return (Fall) ElexisEventDispatcher.getSelected(Fall.class); } }; neueKonsAction = new RestrictedAction(AccessControlDefaults.KONS_CREATE, Messages.GlobalActions_NewKons) { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.GlobalActions_NewKonsToolTip); //$NON-NLS-1$ } @Override public void doRun() { Konsultation.neueKons(null); IPersistentObject kons = ElexisEventDispatcher.getSelected(Konsultation.class); if (kons != null && kons.exists()) { CoreHub.getLocalLockService().acquireLock(kons); CoreHub.getLocalLockService().releaseLock(kons); } } }; neuerFallAction = new Action(Messages.GlobalActions_NewCase) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.GlobalActions_NewCaseToolTip); //$NON-NLS-1$ } @Override public void run() { Patient pat = ElexisEventDispatcher.getSelectedPatient(); if (pat != null) { NeuerFallDialog nfd = new NeuerFallDialog(mainWindow.getShell(), null); if (nfd.open() == Dialog.OK) { } } } }; planeRechnungAction = new Action(Messages.GlobalActions_plaBill) { //$NON-NLS-1$ public void run() { } }; }
From source file:ch.elexis.core.ui.actions.GlobalActions.java
License:Open Source License
protected void printPatient(final Patient patient) { PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer // driver is not handled correctly (we always get porttrait // even when the printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = CoreHub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try {/*from www . j av a 2 s. c o m*/ iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) { } if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob(Messages.GlobalActions_PrintLabelJobName) == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); gc.drawString(Messages.GlobalActions_PatientIDLabelText + patient.getPatCode(), 0, 0); //$NON-NLS-1$ FontMetrics fmt = gc.getFontMetrics(); y += fmt.getHeight(); String pers = patient.getPersonalia(); gc.drawString(pers, 0, y); y += fmt.getHeight(); gc.drawString(patient.getAnschrift().getEtikette(false, false), 0, y); y += fmt.getHeight(); StringBuilder tel = new StringBuilder(); tel.append(Messages.GlobalActions_PhoneHomeLabelText).append(patient.get("Telefon1")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneWorkLabelText).append(patient.get("Telefon2")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneMobileLabelText).append(patient.get("Natel")); //$NON-NLS-1$ //$NON-NLS-2$ gc.drawString(tel.toString(), 0, y); gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.GlobalActions_PrinterErrorTitle, Messages.GlobalActions_PrinterErrorMessage); //$NON-NLS-1$ //$NON-NLS-2$ } } }
From source file:ch.elexis.core.ui.actions.GlobalActions.java
License:Open Source License
protected void printPatientAuftragsnummer(final Patient patient) { PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer // driver is not handled correctly (we always get porttrait // even when the printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = CoreHub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try {/*from w w w . ja v a 2s .co m*/ iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) { } if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob(Messages.GlobalActions_PrintLabelJobName) == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); String pid = StringTool.addModulo10(patient.getPatCode()) + "-" //$NON-NLS-1$ + new TimeTool().toString(TimeTool.TIME_COMPACT); gc.drawString(Messages.GlobalActions_OrderID + ": " + pid, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$ FontMetrics fmt = gc.getFontMetrics(); y += fmt.getHeight(); String pers = patient.getPersonalia(); gc.drawString(pers, 0, y); y += fmt.getHeight(); gc.drawString(patient.getAnschrift().getEtikette(false, false), 0, y); y += fmt.getHeight(); StringBuilder tel = new StringBuilder(); tel.append(Messages.GlobalActions_PhoneHomeLabelText).append(patient.get("Telefon1")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneWorkLabelText).append(patient.get("Telefon2")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneMobileLabelText).append(patient.get("Natel")); //$NON-NLS-1$ //$NON-NLS-2$ gc.drawString(tel.toString(), 0, y); gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.GlobalActions_PrinterErrorTitle, Messages.GlobalActions_PrinterErrorMessage); //$NON-NLS-1$ //$NON-NLS-2$ } } }