List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:ac.soton.fmusim.components.presentation.ComponentsEditor.java
License:Open Source License
/** * Shows a dialog that asks if conflicting changes should be discarded. * <!-- begin-user-doc -->/* ww w .ja v a2 s . c o m*/ * <!-- end-user-doc --> * @generated */ protected boolean handleDirtyConflict() { return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), getString("_WARN_FileConflict")); }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
/** * Notifies that the OK button of this page's container has been pressed. * /* w w w .j a v a2 s.com*/ * @return false to abort the container's OK processing and true to allow * the OK to happen * * @author Joerg Sigle * @author Gerry Weirich * @author Andreas Brker * @author Markus Krger * * Adopted for Elexis by Joerg Sigle 02/2012, adding comments and monitoring output, * and reproducing the functionality of changes made by Gerry Weirich in 06/2007 * for his NOAText plugin 1.4.1 to a file obtained from an older version of the ag.ion noa library. * * Changes required because of different preference store layout in Elexis: * There are corresponding changes in: * LocalOfficeApplicationsPreferencesPage.java * PREFS_PREVENT_TERMINATION * initPreferenceValues() * performOk() * NOAUIPlugin.java * PREFERENCE_OFFICE_HOME * PREFERENCE_PREVENT_TERMINATION * internalStartApplication(). */ public boolean performOk() { System.out.println("LocalOfficeApplicationPreferencesPage: performOK() begin - Adopted to Elexis by GW/JS"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): allocating preferenceStore = new SettingsPreferenceStore(Hub.localCfg)"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): instead of using = NOAUIPlugin.getDefault().getPreferenceStore()"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): Transferring settings from configuration dialog into internal storage..."); IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); preferenceStore.setValue(PREFS_PREVENT_TERMINATION, buttonPreventTermination.getSelection()); //When we read the two timeout settings, use try/catch so that data that can't be interpreted as integer numbers doesn't cause any harm. //The trim() is needed before parseInt(), otherwise an leading space will cause failure. //See corresponding code in initPreferenceValues() and performOk(). System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): ToDo: refactor to move repeatedly used constants into single places or even out of the code."); Integer timeoutBootstrapConnect = timeoutBootstrapConnectDefault; //Start by establishing a valid default setting try { timeoutBootstrapConnect = Integer.parseInt(textTimeoutBootstrapConnect.getText().trim()); //20130310js timeout made configurable for the loop found in bootstrap*.jar that would originally stop a connection attempt after 500 tries } catch (Throwable throwable) { //do not consume } if (timeoutBootstrapConnect < timeoutBootstrapConnectMin) { timeoutBootstrapConnect = timeoutBootstrapConnectMin; } ; if (timeoutBootstrapConnect > timeoutBootstrapConnectMax) { timeoutBootstrapConnect = timeoutBootstrapConnectMax; } ; preferenceStore.setValue(PREFS_TIMEOUT_BOOTSTRAP_CONNECT, timeoutBootstrapConnect.toString()); //I also write back the possibly clamped value into the dialog immediately, cause this method might have been called by Apply rather than by OK: textTimeoutBootstrapConnect.setText(timeoutBootstrapConnect.toString()); Integer timeoutThreadedWatchdog = timeoutThreadedWatchdogDefault; //Start by establishing a valid default setting try { timeoutThreadedWatchdog = Integer.parseInt(textTimeoutThreadedWatchdog.getText().trim()); //20130310js timeout made configurable for the threaded watchdog timer added in 1.4.x by js } catch (Throwable throwable) { //do not consume } if (timeoutThreadedWatchdog < timeoutThreadedWatchdogMin) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMin; } ; if (timeoutThreadedWatchdog > timeoutThreadedWatchdogMax) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMax; } ; preferenceStore.setValue(PREFS_TIMEOUT_THREADED_WATCHDOG, timeoutThreadedWatchdog.toString()); //I also write back the possibly clamped value into the dialog immediately, cause this method might have been called by Apply rather than by OK: textTimeoutThreadedWatchdog.setText(timeoutThreadedWatchdog.toString()); ///20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 begin for (int i = 0; i < PREFERENCE_cotf_elements.length; i++) { for (int j = 0; j < PREFERENCE_cotf_parameters.length; j++) { //Specifically, textCotfOption[0][0] and [0][2] will NOT have been created for theconstant1 element. Therefore, don't try to set anything to its content! if (textCotfOption[i][j] != null) { //Intermediate string variable: //check whether it's a valid integer. // if yes: clamp it to the range [1..nNOAText_jslPREF_cotf_element_digits_max] // If no: re-use what's already in the preferenceStore. Should that not be an integer either, then remove the content alltogether. //FIXME: Sadly, any auto produced changes are only visible when the dialog is re-opened the next time. //FIXME: The same checking and limiting mechanism could be used upon the initialization of the dialog content after it is created. String s = textCotfOption[i][j].getText().trim(); if (!PREFERENCE_cotf_elements[i].contains("constant") && (PREFERENCE_cotf_parameters[j].contains("num_digits"))) { try { Integer v1 = Integer.parseInt(s); Integer v2 = v1; if (v1 > nNOAText_jslPREF_cotf_element_digits_max) { v2 = nNOAText_jslPREF_cotf_element_digits_max; } else { if (v1 < 1) { v2 = 1; } if (v2 != v1) { s = v2.toString().trim(); } } } catch (Throwable throwable) { s = getCotfOption(i, j); try { Integer v3 = Integer.parseInt(s); } catch (Throwable throwable2) { s = ""; } } } System.out.println("LocalOfficeApplicationPreferencesPage: performOk(): About to setValue(" + PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[j] + ", textCotfOption[" + i + "][" + j + "].toString().trim() ); which is <" + s + ">"); preferenceStore.setValue(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[j], s); } } } //IPreferenceStore preferenceStore = NOAUIPlugin.getDefault().getPreferenceStore(); //preferenceStore.setValue(NOAUIPlugin.PREFERENCE_PREVENT_TERMINATION, // buttonPreventTermination.getSelection()); String oldPath = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); preferenceStore.setValue(PreferenceConstants.P_OOBASEDIR, textHome.getText()); //String oldPath = preferenceStore.getString(NOAUIPlugin.PREFERENCE_OFFICE_HOME); //preferenceStore.setValue(NOAUIPlugin.PREFERENCE_OFFICE_HOME, textHome.getText()); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): Please note: There is a reference to NOAUIPlugin.getDefault()..."); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): still left in this code; I (js) don't know whether this might be null and hence not work."); super.performOk(); if (oldPath.length() != 0 || !oldPath.equals(textHome.getText())) { if (EditorCorePlugin.getDefault().getManagedLocalOfficeApplication().isActive()) { if (MessageDialog.openQuestion(getShell(), Messages.LocalOfficeApplicationPreferencesPage_dialog_restart_workbench_title, Messages.LocalOfficeApplicationPreferencesPage_dialog_restart_workbench_message)) NOAUIPlugin.getDefault().getWorkbench().restart(); } } System.out.println("LocalOfficeApplicationPreferencesPage: performOk() return true"); return true; }
From source file:ag.ion.noa4e.ui.NOAUIPlugin.java
License:Open Source License
/** * Starts local office application.// ww w . j a v a 2 s .c om * * @param shell shell to be used * @param officeApplication office application to be started * * @return information whether the office application was started or not - only * if the status severity is <code>IStatus.OK</code> the application was started * * @author Joerg Sigle * @date 24.06.2012 * @date 20.02.2012 * * @author Andreas Brker * @date 28.06.2006 */ public static IStatus startLocalOfficeApplication(Shell shell, IOfficeApplication officeApplication) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(Shell, officeApplication) begin"); while (true) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): while (true) trying to start..."); IStatus status = internalStartApplication(shell, officeApplication); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): returned from trying to start."); if (status == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status=" + status.toString()); if (status.getSeverity() == IStatus.ERROR) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): WARNING: status.getSeverity()==IStatus.ERROR"); if (MessageDialog.openQuestion(shell, Messages.NOAUIPlugin_dialog_change_preferences_title, Messages.NOAUIPlugin_dialog_change_preferences_message)) { PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell, LocalOfficeApplicationPreferencesPage.PAGE_ID, null, null); if (preferenceDialog.open() == Window.CANCEL) return Status.CANCEL_STATUS; else continue; } } else System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: !status.getSeverity()==IStatus.ERROR"); try { //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: internalStartApplication(2): getting officeHome (WARNING: probably from the wrong source)..."); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): getting officeHome..."); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): Using js mod adopted for Elexis, reproducing prior GW adoptions, P_OOBASEDIR via ...(Hub.localCfg)"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //String officeHome = getDefault().getPreferenceStore().getString(PREFERENCE_OFFICE_HOME); //Newly inserted lines: IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHome = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); if (officeHome == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): WARNING: officeHome==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): officeHome=" + officeHome); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying to get preventTermination setting..."); //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: WARNING: THIS PROBABLY REFERENCES THE WRONG PREFERENCE STORE. SEE LocalPreferences...GWeirich/JS mods"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //boolean preventTermination = getDefault().getPreferenceStore().getBoolean(PREFERENCE_PREVENT_TERMINATION); //Newly inserted lines: //Already declared further above: IPreferenceStore preferenceStore = new SettingsPreferenceStore(Hub.localCfg); boolean preventTermination = preferenceStore.getBoolean(PREFS_PREVENT_TERMINATION); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): got preventTermination setting=" + preventTermination); if (preventTermination) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying officeApplication.getDesktopService().activateTerminationPrevention()..."); officeApplication.getDesktopService().activateTerminationPrevention(); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: officeApplication.getDesktopService().activateTerminationPrevention()"); } } catch (OfficeApplicationException officeApplicationException) { //no prevention System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): FAILED: preventTermination could NOT be set."); } System.out.println("NOAUIPlugin: startLocalOfficeApplication(2) end, returning status"); return status; } }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
/** * Shows a dialog that asks if conflicting changes should be discarded. *///from w w w .ja v a2 s . com private boolean handleDirtyConflict() { return MessageDialog.openQuestion(getSite().getShell(), "File Conflict", "There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?"); }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
/** * @return <true> if build configuration is valid, <false> otherwise *//*from ww w . j a va2 s . co m*/ private boolean validateAndShowErrors() { MultiStatus status = new MultiStatus(JavaFXUIPlugin.PLUGIN_ID, IStatus.OK, null, null); // dirty if (isDirty()) { boolean option = MessageDialog.openQuestion(getSite().getShell(), "Save FX Build Configuration", getEditorInput().getName() + " must be saved before generating ant build.xml file.\nSave changes now?"); if (option) { doSave(new NullProgressMonitor()); } else { return false; } } // height if (getTask().getDeploy().getHeight() != null && getTask().getDeploy().getHeight().length() > 0) { try { Integer.parseInt(getTask().getDeploy().getHeight()); } catch (Exception e) { status.add(new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "Height must be an integer value")); } } // width if (getTask().getDeploy().getWidth() != null && getTask().getDeploy().getWidth().length() > 0) { try { Integer.parseInt(getTask().getDeploy().getWidth()); } catch (Exception e) { status.add(new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "Width must be an integer value")); } } // Show the collected errors if (!status.isOK()) { StringBuffer errors = new StringBuffer(); for (IStatus err : status.getChildren()) { errors.append(err.getMessage()).append("\n"); } MessageDialog.openWarning(getSite().getShell(), "Invalid FX Build configuration", errors.toString()); } return status.isOK(); }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.handler.AbstractBuildHandler.java
License:Open Source License
private ILaunchConfiguration getLaunchConfig(File buildFile, BuildConfiguration cfgData, IFile buildCfgFile) throws CoreException { ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = mgr//from w w w .j a va2 s .c o m .getLaunchConfigurationType("org.eclipse.ant.AntLaunchConfigurationType"); if (type != null) { String name = (String) cfgData.builderName; if (name == null) { name = "JFX Build - " + cfgData.projectName; } File fBuildFile = new File(cfgData.buildDirectory + "/build.xml"); for (ILaunchConfiguration cfg : mgr.getLaunchConfigurations(type)) { if (cfg.getName().equals(name)) { String s = cfg.getAttribute(IExternalToolConstants.ATTR_LOCATION, IExternalToolConstants.EMPTY_STRING); if (!s.equals("") && new File(s).equals(fBuildFile)) { return cfg; } else { cfg.delete(); } } } ILaunchConfigurationWorkingCopy cfg = type.newInstance(null, name); cfg.setAttribute(IExternalToolConstants.ATTR_LOCATION, buildFile.getAbsolutePath()); cfg.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, buildFile.getParentFile().getAbsolutePath()); cfg.setAttribute("org.eclipse.debug.core.ATTR_REFRESH_SCOPE", "${project}"); cfg.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, false); cfg.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE", "org.eclipse.ant.internal.launching.remote.InternalAntRunner"); cfg.setAttribute("process_factory_id", "org.eclipse.ant.ui.remoteAntProcessFactory"); IVMInstall install = null; for (IClasspathEntry e : project.getRawClasspath()) { String start = e.getPath().segment(0); if (start.startsWith("org.eclipse.jdt.launching.JRE_CONTAINER")) { install = JavaRuntime.getVMInstall(e.getPath()); cfg.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, e.getPath().toString()); } } if (!isJDK(install)) { if (MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Not a JDK", "The project is attached to a JRE only so ant would be started with a JRE which does not have a compiler. Would you like to proceed and select a JDK?")) { JDKSelectionDialog d = new JDKSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); if (d.open() == Window.OK) { cfg.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(d.install).toString()); } } else { return null; } } cfg.doSave(); return cfg; } return null; }
From source file:at.bestsolution.efxclipse.tooling.ui.wizards.AbstractNewJDTElementWizard.java
License:Open Source License
@Override public boolean performFinish() { O clazz = getDomainClass();//from w w w .jav a2s .co m String content = getGenerator().generateContent(clazz).toString(); if (clazz.getFragmentRoot() == null) { return false; } IFile file = createFile(); if (file != null) { try { if (!file.exists()) { file.create(new ByteArrayInputStream(content.getBytes()), true, null); } else { if (MessageDialog.openQuestion(getShell(), "File exists", "The file " + file.getName() + " already exists. Would you like to proceed?")) { file.setContents(new ByteArrayInputStream(content.getBytes()), IFile.FORCE | IFile.KEEP_HISTORY, null); } else { return false; } } IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return true; }
From source file:at.medevit.ch.artikelstamm.elexis.common.importer.ArtikelstammImporter.java
License:Open Source License
/** * // www. j a v a 2 s. c o m * @param monitor * @param input * @param version * the version to set. If <code>null</code> the current version will be simply * increased by one * @return */ public static IStatus performImport(IProgressMonitor monitor, InputStream input, @Nullable Integer newVersion) { LocalLock lock = new LocalLock("ArtikelstammImporter"); if (!lock.tryLock()) { UiDesk.syncExec(new Runnable() { @Override public void run() { if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(), "", "Der Importer ist durch einen anderen Benutzer gestartet.\nDie Artikelstammeintrge werden bereits importiert.\n\n" + "Startzeit: " + new TimeTool(lock.getLockCurrentMillis()).toString(TimeTool.LARGE_GER) + "\nGestartet durch: " + lock.getLockMessage() + "\n\nWollen Sie den Importer trotzdem nochmal starten ?")) { lock.unlock(); lock.tryLock(); userCanceled = false; } else { userCanceled = true; } } }); } if (userCanceled) { userCanceled = false; return Status.OK_STATUS; } try { SubMonitor subMonitor = SubMonitor.convert(monitor, 100); subMonitor.setTaskName("Einlesen der Aktualisierungsdaten"); ARTIKELSTAMM importStamm = null; try { importStamm = ArtikelstammHelper.unmarshallInputStream(input); } catch (JAXBException | SAXException je) { String msg = "Fehler beim Einlesen der Import-Datei"; Status status = new ElexisStatus(IStatus.ERROR, PluginConstants.PLUGIN_ID, ElexisStatus.CODE_NOFEEDBACK, msg, je); StatusManager.getManager().handle(status, StatusManager.SHOW); log.error(msg, je); lock.unlock(); return Status.CANCEL_STATUS; } subMonitor.worked(10); if (newVersion == null) { int month = importStamm.getBUILDDATETIME().getMonth(); int year = importStamm.getBUILDDATETIME().getYear(); newVersion = Integer.valueOf("" + (year - 2000) + month); log.info("[PI] No newVersion provided. Setting to [{}].", newVersion); } try { DATASOURCEType datasourceType = ArtikelstammItem.getDatasourceType(); String message = "Trying to import dataset sourced [" + importStamm.getDATASOURCE().value() + "] while existent database is sourced [" + datasourceType.value() + "]. Please contact support. Exiting."; if (importStamm.getDATASOURCE() != datasourceType) { log.error(message); lock.unlock(); return new Status(Status.ERROR, PluginConstants.PLUGIN_ID, message); } } catch (IllegalArgumentException iae) { ArtikelstammItem.setDataSourceType(importStamm.getDATASOURCE()); } int currentVersion = ArtikelstammItem.getCurrentVersion(); log.info("[PI] Aktualisiere v" + currentVersion + " auf v" + newVersion); subMonitor.setTaskName("Lese Produkte und Limitationen..."); populateProducsAndLimitationsMap(importStamm); subMonitor.worked(5); subMonitor.setTaskName("Setze alle Elemente auf inaktiv..."); inactivateNonBlackboxedItems(); subMonitor.worked(5); long startTime = System.currentTimeMillis(); subMonitor.setTaskName("Importiere Artikelstamm " + importStamm.getCREATIONDATETIME().getMonth() + "/" + importStamm.getCREATIONDATETIME().getYear()); updateOrAddItems(newVersion, importStamm, subMonitor.split(50)); updateOrAddProducts(newVersion, importStamm, subMonitor.split(20)); // update the version number for type importStammType subMonitor.setTaskName("Setze neue Versionsnummer"); ArtikelstammItem.setCurrentVersion(newVersion); ArtikelstammItem .setImportSetCreationDate(importStamm.getCREATIONDATETIME().toGregorianCalendar().getTime()); subMonitor.worked(5); long endTime = System.currentTimeMillis(); ElexisEventDispatcher.reload(ArtikelstammItem.class); log.info("[PI] Artikelstamm import took " + ((endTime - startTime) / 1000) + "sec. Will rebuild ATCCodeCache"); ATCCodeCache.rebuildCache(subMonitor.split(5)); log.info("[PI] Artikelstamm finished rebuilding ATCCodeCache"); } finally { lock.unlock(); } return Status.OK_STATUS; }
From source file:at.rc.tacos.client.Application.java
License:Open Source License
/** * Start the application and create the main workbench * /* ww w. j a v a 2 s . c o m*/ * @param context * the context used to init the application * @return the exit code of the application */ public Object start(IApplicationContext context) { // the net source NetSource source = NetSource.getInstance(); ServerInfo primaryServer = source.getServerInfoById(IServerInfo.PRIMARY_SERVER); ServerInfo failoverServer = source.getServerInfoById(IServerInfo.FAILOVER_SERVER); // FIXME This is just a test for svn merge // startup the workbench Display display = PlatformUI.createDisplay(); // connect to the server if (source.openConnection(primaryServer) == null) { display.beep(); // show an error message if (!MessageDialog.openQuestion(display.getActiveShell(), "Verbindungsfehler", "Verbindung zum primren Server nicht mglich.\n" + "Soll eine Verbindung zum Backup Server hergestellt werden?")) { return IApplication.EXIT_OK; } else { // get the network status if (source.openConnection(failoverServer) == null) { display.beep(); // show an error message MessageDialog.openError(display.getActiveShell(), "Verbindungsfehler", "Verbindung zum primren und zum Backup Server nicht mglich.\n" + "Applikation wird beendet"); return IApplication.EXIT_OK; } } } // startup the network NetWrapper.getDefault().init(); Activator.getDefault().init(); // try to load workbench try { ApplicationWorkbenchAdvisor adv = new ApplicationWorkbenchAdvisor(); // create the workbench int returnCode = PlatformUI.createAndRunWorkbench(display, adv); if (returnCode == PlatformUI.RETURN_RESTART) return IApplication.EXIT_RESTART; return IApplication.EXIT_OK; } finally { display.dispose(); } }
From source file:at.rc.tacos.client.controller.CancelTransportAction.java
License:Open Source License
@Override public void run() { // the selection ISelection selection = viewer.getSelection(); // get the selected transport Transport transport = (Transport) ((IStructuredSelection) selection).getFirstElement(); // check if the object is currently locked String resultLockMessage = LockManager.sendLock(Transport.ID, transport.getTransportId()); // check the result of the lock if (resultLockMessage != null) { boolean forceEdit = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Information: Eintrag wird bearbeitet", "Der Transport den Sie stornieren mchten wird bereits von " + resultLockMessage + " bearbeitet.\n" + "Ein gleichzeitiges Bearbeiten kann zu unerwarteten Fehlern fhren!\n\n" + "Es wird dringend empfohlen, den Eintrag erst nach Freigabe durch " + resultLockMessage + " zu stornieren!\n\n" + "Mchten Sie den Eintrag trotzdem sofort stornieren?"); if (!forceEdit) return; // log the override of the lock String username = SessionManager.getInstance().getLoginInformation().getUsername(); Activator.getDefault().log("Der Eintrag " + transport + " wird trotz Sperrung durch " + resultLockMessage + " von " + username + " bearbeitet", Status.WARNING); }// w ww . j av a 2s . c o m // confirm the cancel InputDialog dlg = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Transport Stornierung", "Bitte geben Sie Informationen zur Stornierung ein", null, null); if (dlg.open() == Window.OK) { transport.setNotes(transport.getNotes() + " Stornoinformation: " + dlg.getValue()); transport.setProgramStatus(PROGRAM_STATUS_JOURNAL); transport.setTransportNumber(Transport.TRANSPORT_CANCLED); NetWrapper.getDefault().sendUpdateMessage(Transport.ID, transport); } // remove the lock from the object LockManager.removeLock(Transport.ID, transport.getTransportId()); }