List of usage examples for org.eclipse.jface.dialogs MessageDialog close
@Override public boolean close()
From source file:ch.elexis.core.ui.Hub.java
License:Open Source License
/** * Programmende/* www .j a v a 2 s . c o m*/ */ public static void postShutdown() { // shutdownjobs are executed after the workbench has been shut down. // So those jobs must not use any of the workbench's resources. if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) { Shell shell = new Shell(Display.getDefault()); MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(), Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0); dlg.setBlockOnOpen(false); dlg.open(); for (ShutdownJob job : shutdownJobs) { try { job.doit(); } catch (Exception e) { log.error("Error starting job: " + e.getMessage()); } } dlg.close(); } }
From source file:ch.elexis.Hub.java
License:Open Source License
/** * Programmende//from w w w . j a v a 2s .co m */ public static void postShutdown() { // heart.stop(); // JobPool.getJobPool().dispose(); if (Hub.actUser != null) { Anwender.logoff(); } if (globalCfg != null) { // We should not flush at this point, since this might // overwrite other client's // settings // acl.flush(); // globalCfg.flush(); } // shutdownjobs are executed after the workbench has been shut down. // So those jobs must not use any of the workbench's resources. if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) { Shell shell = new Shell(Display.getDefault()); MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(), Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0); dlg.setBlockOnOpen(false); dlg.open(); for (ShutdownJob job : shutdownJobs) { try { job.doit(); } catch (Exception e) { log.log("Error starting job: " + e.getMessage(), Log.ERRORS); } } dlg.close(); } }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * Show an note box./*from w w w .jav a 2s . c om*/ * (We use JFace ErrorDialog instead of MessageBox. The latter is done outside * of Java and the WindowTester framework loses control). * @param title * @param message */ public static void showNote(String title, String message) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, // accept // the // default // window // icon message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.setBlockOnOpen(false); // we want to be able to make box expire // ok is the default dialog.open(); long expireTime = System.currentTimeMillis() + NOTE_TIME_OUT; Display display = shell.getDisplay(); try { while (dialog.getShell() != null && !dialog.getShell().isDisposed() && System.currentTimeMillis() < expireTime) { if (!display.readAndDispatch()) { display.sleep(); } } } finally { if (dialog.getShell() != null && !dialog.getShell().isDisposed()) { dialog.close(); } } }
From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java
License:Open Source License
private void setJDKCompatibilitySettings(final IJavaProject mainProject, final List<IJavaProject> nonBBProjects, final List<IJavaProject> projectsWithProblem) { _log.trace("Entered setJDKCompatibilitySettings()"); if (projectsWithProblem.size() > 0) { StringBuffer projectList = new StringBuffer(); for (IJavaProject javaProject : projectsWithProblem) { projectList.append(javaProject.getProject().getName() + "\n"); }//from ww w. ja v a2s . co m final String projectNames = projectList.toString(); Display.getDefault().syncExec(new Runnable() { public void run() { Shell shell = ContextManager.getActiveWorkbenchWindow().getShell(); StringBuffer messageBuffer = new StringBuffer( Messages.ClasspathChangeManager_settingJDKComplianceMsg1); messageBuffer.append("\n"); messageBuffer.append(NLS.bind(Messages.ClasspathChangeManager_settingJDKComplianceMsg2, mainProject.getProject().getName())); messageBuffer.append("\n"); messageBuffer.append(projectNames); messageBuffer.append("\n"); messageBuffer.append(Messages.ClasspathChangeManager_settingJDKComplianceMsg3); MessageDialog complianceDialog = new MessageDialog(shell, Messages.ClasspathChangeManager_DialogTitle, null, messageBuffer.toString(), MessageDialog.INFORMATION, new String[] { Messages.IConstants_OK_BUTTON_TITLE, Messages.IConstants_CANCEL_BUTTON_TITLE }, 0); int buttonEventCode = complianceDialog.open(); switch (buttonEventCode) { case Window.OK: { processNonBBProjects(nonBBProjects, projectsWithProblem, true); break; } case Window.CANCEL: { processNonBBProjects(nonBBProjects, projectsWithProblem, false); break; } default: throw new IllegalArgumentException("Unsupported dialog button event!"); } complianceDialog.close(); } }); } else { processNonBBProjects(nonBBProjects, projectsWithProblem, false); } }
From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java
License:Open Source License
private void processNonBBProjects(final List<IJavaProject> nonBBProjects, final List<IJavaProject> projectsWithProblem, final boolean fix) { for (IJavaProject javaProject : nonBBProjects) { if (fix && projectsWithProblem.contains(javaProject)) { ImportUtils.initializeProjectOptions(javaProject); }//from w w w . j ava 2 s . c o m } if (fix) { Shell shell = ContextManager.getActiveWorkbenchWindow().getShell(); String message = Messages.ClasspathChangeManager_rebuildProjectMsg1; StringBuffer projectList = new StringBuffer(); for (IJavaProject javaProject : projectsWithProblem) { projectList.append(javaProject.getProject().getName() + "\n"); } message += projectList.toString(); message += Messages.ClasspathChangeManager_rebuildProjectMsg2; MessageDialog dialog = new MessageDialog(shell, Messages.ClasspathChangeManager_RebuildProjectDialogTitle, null, message, MessageDialog.INFORMATION, new String[] { Messages.IConstants_OK_BUTTON_TITLE, Messages.IConstants_CANCEL_BUTTON_TITLE }, 0); int buttonEventCode = dialog.open(); switch (buttonEventCode) { case Window.OK: { buildProjects(projectsWithProblem); break; } case Window.CANCEL: { break; } default: throw new IllegalArgumentException("Unsupported dialog button event!"); } dialog.close(); } }
From source file:oic.simulator.clientcontroller.view.ResourceManagerView.java
License:Open Source License
private void searchUIOperation(boolean refresh) { final MessageDialog targetDialog; if (refresh) { targetDialog = refreshDialog;/*from w ww . j a va 2 s. c o m*/ } else { targetDialog = findDialog; } // Open the dialog in a new thread. PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() { @Override public void run() { if (isFoundResource()) { setFoundResource(false); return; } PlatformUI.getWorkbench().getDisplay().asyncExec(new Thread() { @Override public void run() { targetDialog.open(); // This method returns once the // cancel button is pressed. // Interrupt the sleep thread. if (null != sleepThreadHandle && sleepThreadHandle.isAlive()) { sleepThreadHandle.interrupt(); } // Set the status of find. setFoundResource(false); } }); // Thread for find time-out. sleepThreadHandle = new Thread() { Thread child; public void run() { try { Thread.sleep(Constants.FIND_RESOURCES_TIMEOUT * 1000); } catch (InterruptedException e) { return; } child = new Thread() { @Override public void run() { if (null != targetDialog) { targetDialog.close(); // Check if any new resources are // discovered. // Is no new resources, then display a // message box. if (!isFoundResource()) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), "No servers found", "No servers are available as of now.\n" + "Please check the servers' status and press" + "'Refresh' button to restart the search."); } else { // Resetting the status to false for // ensuring safety. setFoundResource(false); } } } }; PlatformUI.getWorkbench().getDisplay().syncExec(child); } }; sleepThreadHandle.start(); } }); }
From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java
License:Open Source License
@SuppressWarnings("deprecation") public boolean performOk() { if (isProjectPreferencePage()) { return projectPerformOK(); } else {//from w ww . java2 s . c o m IPreferenceStore store = getPreferenceStore(); Preferences ajCorePreferences = getAspectJCorePLuginPreferences(); boolean lintChanges = false; for (int i = fComboBoxes.size() - 1; i >= 0; i--) { Combo curr = (Combo) fComboBoxes.get(i); ControlData data = (ControlData) curr.getData(); String currValue = data.getValue(curr.getSelectionIndex()); String storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getString(data.getKey()) : store.getString(data.getKey()); if (!currValue.equals(storedValue)) { lintChanges = true; if (usesAspectJCorePreferences(curr)) { ajCorePreferences.setValue(data.getKey(), currValue); } else { store.setValue(data.getKey(), currValue); } } } boolean advancedOrOtherChanges = false; for (int i = fCheckBoxes.size() - 1; i >= 0; i--) { Button curr = (Button) fCheckBoxes.get(i); // has the data changed? ControlData data = (ControlData) curr.getData(); boolean currValue = curr.getSelection(); boolean storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getBoolean(data.getKey()) : store.getBoolean(data.getKey()); if (currValue != storedValue) { // check to see if we should ignore the change in the checkbox // change should be ignored if the NO_BUILD_ON_CHANGE flag exists if (curr.getData(NO_BUILD_ON_CHANGE) == null) { advancedOrOtherChanges = true; } // determine where this preference is stored if (usesAspectJCorePreferences(curr)) { ajCorePreferences.setValue(data.getKey(), currValue); } else { store.setValue(data.getKey(), currValue); } } } boolean compilerChanges = false; String value = nonStandardOptionsEditor.getStringValue(); if (!value.equals(store.getString(AspectJPreferences.COMPILER_OPTIONS))) { store.setValue(AspectJPreferences.COMPILER_OPTIONS, nonStandardOptionsEditor.getStringValue()); AJLog.log("Non Standard Compiler properties changed: " //$NON-NLS-1$ + store.getString(AspectJPreferences.COMPILER_OPTIONS)); compilerChanges = true; } AspectJUIPlugin.getDefault().savePluginPreferences(); AspectJPlugin.getDefault().savePluginPreferences(); if (lintChanges || advancedOrOtherChanges || compilerChanges) { String[] strings = getFullBuildDialogStrings(); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); if (isTesting) { dialog.setBlockOnOpen(false); } int res = dialog.open(); // simulate user input if we're testing if (isTesting) { // choices are "Yes", "No" or "Cancel" dialog.close(); if (buildNow) { res = Window.OK; } else { res = Window.CANCEL; // simulating cancel or no being pressed. } } if (res == 0) { projects = (ResourcesPlugin.getWorkspace().getRoot().getProjects()); } else if (res != 1) { return false; // cancel pressed } } // PreferencePageBuilder handles building so // don't need to do it here // if (doBuild) { // doFullBuild(); // } } return true; } }
From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java
License:Open Source License
private boolean projectPerformOK() { boolean projectSettingsChanged = updateProjectSettings(); boolean projectWorkspaceChanges = false; if (AspectJPreferences.isUsingProjectSettings(getProject()) != useProjectSettings()) { projectWorkspaceChanges = true;/*from ww w.ja v a2 s .c om*/ // don't want to overwrite existing project settings // because have just set them in the above call to // updateProjectSettings(); AspectJPreferences.setUsingProjectSettings(getProject(), useProjectSettings(), false); } AspectJUIPlugin.getDefault().savePluginPreferences(); if (projectWorkspaceChanges || (projectSettingsChanged && useProjectSettings())) { String[] strings = getProjectBuildDialogStrings(); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); // if we're testing then we don't want to block // the dialog on open otherwise we require real user input // rather than being able to simulate it if (isTesting) { dialog.setBlockOnOpen(false); } int res = dialog.open(); // simulate user input if we're testing if (isTesting) { // choices are "Yes", "No" or "Cancel" dialog.close(); if (buildNow) { res = Window.OK; } else { res = Window.CANCEL; // simulating cancel or no being pressed. } } if ((res == 0)) { // by only setting compilerSettingsUpdated to be true here, // means that // the user wont select "don't want to build" here and then // get a build // from other pages. } else if (res != 1) { return false; // cancel pressed } } } return true; }
From source file:org.eclipse.mylyn.internal.monitor.usage.CheckForUploadJob.java
License:Open Source License
synchronized void checkForStatisticsUpload() { Date currentTime = new Date(); if (shouldAskForUpload(currentTime)) { String ending = getUserPromptDelay() == 1 ? "" : "s"; //$NON-NLS-1$//$NON-NLS-2$ MessageDialog message = new MessageDialog(Display.getDefault().getActiveShell(), Messages.UiUsageMonitorPlugin_Send_Usage_Feedback, null, Messages.UiUsageMonitorPlugin_Help_Improve_Eclipse_And_Mylyn, MessageDialog.QUESTION, new String[] { Messages.UiUsageMonitorPlugin_Submit_Feedback, NLS .bind(Messages.UiUsageMonitorPlugin_Remind_Me_In_X_Days, getUserPromptDelay(), ending), Messages.UiUsageMonitorPlugin_Dont_Ask_Again, }, 0);/* w ww . j a v a2 s . c o m*/ int result = message.open(); if (result == 0) { // time must be stored right away into preferences, to prevent // other threads UiUsageMonitorPlugin.getDefault().getPreferenceStore() .setValue(MonitorPreferenceConstants.PREF_PREVIOUS_TRANSMIT_DATE, currentTime.getTime()); if (!UiUsageMonitorPlugin.getDefault().getPreferenceStore() .contains(MonitorPreferenceConstants.PREF_MONITORING_MYLYN_ECLIPSE_ORG_CONSENT_VIEWED) || !UiUsageMonitorPlugin.getDefault().getPreferenceStore().getBoolean( MonitorPreferenceConstants.PREF_MONITORING_MYLYN_ECLIPSE_ORG_CONSENT_VIEWED)) { MessageDialog consentMessage = new MessageDialog(Display.getDefault().getActiveShell(), Messages.UiUsageMonitorPlugin_Consent, null, Messages.UiUsageMonitorPlugin_All_Data_Public, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); consentMessage.open(); UiUsageMonitorPlugin.getDefault().getPreferenceStore().setValue( MonitorPreferenceConstants.PREF_MONITORING_MYLYN_ECLIPSE_ORG_CONSENT_VIEWED, true); } UsageSubmissionWizard wizard = new UsageSubmissionWizard(); wizard.init(PlatformUI.getWorkbench(), null); // Instantiates the wizard container with the wizard and // opens it WizardDialog dialog = new UsageSubmissionWizardDialog(Display.getDefault().getActiveShell(), wizard); dialog.create(); dialog.open(); /* * the UI usage report is loaded asynchronously so there's no * synchronous way to know if it failed if (wizard.failed()) { * lastTransmit.setTime(currentTime.getTime() + DELAY_ON_FAILURE - * studyParameters.getTransmitPromptPeriod()); * plugin.getPreferenceStore().setValue(MylynMonitorPreferenceConstants.PREF_PREVIOUS_TRANSMIT_DATE, * currentTime.getTime()); } */ } else { if (result == 1) { UiUsageMonitorPlugin.getDefault().userCancelSubmitFeedback(currentTime, true); } else { UiUsageMonitorPlugin.getDefault().getPreferenceStore() .setValue(MonitorPreferenceConstants.PREF_MONITORING_ENABLE_SUBMISSION, false); } } message.close(); } }
From source file:org.gw4e.eclipse.facade.DialogManager.java
License:Open Source License
/** * Display an error message in a Dialog/*from ww w. j av a 2 s . c o m*/ * * @param message */ public static void displayErrorMessage(String title, String message) { MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] { MessageUtil.getString("close") }, 0); int result = dialog.open(); dialog.close(); }