List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:ch.elexis.views.RezepteView.java
License:Open Source License
private void makeActions() { newRpAction = new Action(Messages.getString("RezepteView.newPrescriptionAction")) { //$NON-NLS-1$ {/*from w w w. j ava 2 s. c o m*/ setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.getString("RezepteView.newPrescriptonTooltip")); //$NON-NLS-1$ } @Override public void run() { Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (act == null) { MessageBox mb = new MessageBox(getViewSite().getShell(), SWT.ICON_INFORMATION | SWT.OK); mb.setText(Messages.getString("RezepteView.newPrescriptionError")); //$NON-NLS-1$ mb.setMessage(Messages.getString("RezepteView.noPatientSelected")); //$NON-NLS-1$ mb.open(); return; } Fall fall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (fall == null) { Konsultation k = act.getLetzteKons(false); if (k == null) { SWTHelper.alert(Messages.getString("RezepteView.noCaseSelected"), //$NON-NLS-1$ Messages.getString("RezepteView.pleaseCreateOrChooseCase")); //$NON-NLS-1$ return; } else { fall = k.getFall(); } } new Rezept(act); tv.refresh(); } }; deleteRpAction = new Action(Messages.getString("RezepteView.deletePrescriptionActiom")) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); if (MessageDialog.openConfirm(getViewSite().getShell(), Messages.getString("RezepteView.deletePrescriptionActiom"), //$NON-NLS-1$ MessageFormat.format(Messages.getString("RezepteView.deletePrescriptionConfirm"), rp //$NON-NLS-1$ .getDate()))) { rp.delete(); tv.refresh(); } } }; removeLineAction = new Action(Messages.getString("RezepteView.deleteLineAction")) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription p = (Prescription) sel.getFirstElement(); if ((rp != null) && (p != null)) { rp.removePrescription(p); lvRpLines.refresh(); } /* * RpZeile z=(RpZeile)sel.getFirstElement(); if((rp!=null) && (z!=null)){ * rp.removeLine(z); lvRpLines.refresh(); } */ } }; addLineAction = new Action(Messages.getString("RezepteView.newLineAction")) { //$NON-NLS-1$ @Override public void run() { try { LeistungenView lv1 = (LeistungenView) getViewSite().getPage().showView(LeistungenView.ID); CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget); CTabItem[] tabItems = lv1.ctab.getItems(); for (CTabItem tab : tabItems) { ICodeElement ics = (ICodeElement) tab.getData(); if (ics instanceof Artikel) { lv1.ctab.setSelection(tab); break; } } } catch (PartInitException ex) { ExHandler.handle(ex); } } }; printAction = new Action(Messages.getString("RezepteView.printAction")) { //$NON-NLS-1$ @Override public void run() { try { RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID); Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); Brief rpBrief = actR.getBrief(); if (rpBrief == null) // not yet created - just create a new Rezept rp.createRezept(actR); else { // Brief for Rezept already exists: // ask if it should be recreated or just shown String[] dialogButtonLabels = { Messages.getString("RezepteView.RecreatePrescription"), //$NON-NLS-1$ Messages.getString("RezepteView.ShowPrescription"), //$NON-NLS-1$ Messages.getString("RezepteView.PrescriptionCancel") //$NON-NLS-1$ }; MessageDialog msg = new MessageDialog(null, Messages.getString("RezepteView.CreatePrescription"), //$NON-NLS-1$ null, Messages.getString("RezepteView.ReallyWantToRecreatePrescription"), //$NON-NLS-1$ MessageDialog.WARNING, dialogButtonLabels, 2); int result = msg.open(); switch (result) { case 0: // recreate rezept rp.createRezept(actR); break; case 1: // open rezept rp.loadRezeptFromDatabase(actR, rpBrief); break; case 2: // cancel or closebox - do nothing break; } } } catch (Exception ex) { ExHandler.handle(ex); } } }; changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY, Messages.getString("RezepteView.ChangeLink")) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.getString("RezepteView.ChangeTooltip")); //$NON-NLS-1$ } public void doRun() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription pr = (Prescription) sel.getFirstElement(); if (pr != null) { new MediDetailDialog(getViewSite().getShell(), pr).open(); lvRpLines.refresh(); } } }; addLineAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); deleteRpAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); }
From source file:com.amazonaws.eclipse.explorer.sns.CreateTopicWizard.java
License:Apache License
@Override public boolean performFinish() { String topicName = (String) page.getInputValue(TOPIC_NAME_INPUT); String displayName = (String) page.getInputValue(DISPLAY_NAME_INPUT); AmazonSNS client = AwsToolkitCore.getClientFactory().getSNSClient(); CreateTopicResult result = client.createTopic(new CreateTopicRequest(topicName)); if (displayName != null && displayName.length() > 0) { try {//from ww w . j a v a2 s .c o m client.setTopicAttributes(new SetTopicAttributesRequest().withTopicArn(result.getTopicArn()) .withAttributeName(DISPLAY_NAME_ATTRIBUTE).withAttributeValue(displayName)); } catch (AmazonClientException exception) { AwsToolkitCore.getDefault().logException("Error setting topic display name", exception); MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Warning", null, ("The topic was successfully created, but the display " + "name could not be set (" + exception.toString() + ")"), MessageDialog.WARNING, new String[] { "OK" }, 0); dialog.open(); } } ContentProviderRegistry.refreshAllContentProviders(); return true; }
From source file:com.amazonaws.eclipse.explorer.sns.SNSActionProvider.java
License:Apache License
private Dialog newConfirmationDialog(String title, String message) { return new MessageDialog(Display.getDefault().getActiveShell(), title, null, message, MessageDialog.WARNING, new String[] { "OK", "Cancel" }, 0); }
From source file:com.android.ide.eclipse.adt.AdtPlugin.java
License:Open Source License
/** * Checks the location of the SDK in the prefs is valid. * If it is not, display a warning dialog to the user and try to display * some useful link to fix the situation (setup the preferences, perform an * update, etc.)//from w w w . j a v a 2 s . c om * * @return True if the SDK location points to an SDK. * If false, the user has already been presented with a modal dialog explaining that. */ public boolean checkSdkLocationAndId() { String sdkLocation = AdtPrefs.getPrefs().getOsSdkFolder(); return checkSdkLocationAndId(sdkLocation, new CheckSdkErrorHandler() { private String mTitle = "Android SDK"; /** * Handle an error, which is the case where the check did not find any SDK. * This returns false to {@link AdtPlugin#checkSdkLocationAndId()}. */ @Override public boolean handleError(Solution solution, String message) { displayMessage(solution, message, MessageDialog.ERROR); return false; } /** * Handle an warning, which is the case where the check found an SDK * but it might need to be repaired or is missing an expected component. * * This returns true to {@link AdtPlugin#checkSdkLocationAndId()}. */ @Override public boolean handleWarning(Solution solution, String message) { displayMessage(solution, message, MessageDialog.WARNING); return true; } private void displayMessage(final Solution solution, final String message, final int dialogImageType) { final Display disp = getDisplay(); disp.asyncExec(new Runnable() { @Override public void run() { Shell shell = disp.getActiveShell(); if (shell == null) { shell = AdtPlugin.getShell(); } if (shell == null) { return; } String customLabel = null; switch (solution) { case OPEN_ANDROID_PREFS: customLabel = "Open Preferences"; break; case OPEN_P2_UPDATE: customLabel = "Check for Updates"; break; case OPEN_SDK_MANAGER: customLabel = "Open SDK Manager"; break; } String btnLabels[] = new String[customLabel == null ? 1 : 2]; btnLabels[0] = customLabel; btnLabels[btnLabels.length - 1] = IDialogConstants.CLOSE_LABEL; MessageDialog dialog = new MessageDialog(shell, // parent mTitle, null, // dialogTitleImage message, dialogImageType, btnLabels, btnLabels.length - 1); int index = dialog.open(); if (customLabel != null && index == 0) { switch (solution) { case OPEN_ANDROID_PREFS: openAndroidPrefs(); break; case OPEN_P2_UPDATE: openP2Update(); break; case OPEN_SDK_MANAGER: openSdkManager(); break; } } } }); } private void openSdkManager() { // Open the standalone external SDK Manager since we know // that ADT on Windows is bound to be locking some SDK folders. // // Also when this is invoked because SdkManagerAction.run() fails, this // test will fail and we'll fallback on using the internal one. if (SdkManagerAction.openExternalSdkManager()) { return; } // Otherwise open the regular SDK Manager bundled within ADT if (!SdkManagerAction.openAdtSdkManager()) { // We failed because the SDK location is undefined. In this case // let's open the preferences instead. openAndroidPrefs(); } } private void openP2Update() { Display disp = getDisplay(); if (disp == null) { return; } disp.asyncExec(new Runnable() { @Override public void run() { String cmdId = "org.eclipse.equinox.p2.ui.sdk.update"; //$NON-NLS-1$ IWorkbench wb = PlatformUI.getWorkbench(); if (wb == null) { return; } ICommandService cs = (ICommandService) wb.getService(ICommandService.class); IHandlerService is = (IHandlerService) wb.getService(IHandlerService.class); if (cs == null || is == null) { return; } Command cmd = cs.getCommand(cmdId); if (cmd != null && cmd.isDefined()) { try { is.executeCommand(cmdId, null/*event*/); } catch (Exception ignore) { AdtPlugin.log(ignore, "Failed to execute command %s", cmdId); } } } }); } private void openAndroidPrefs() { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getDisplay().getActiveShell(), "com.android.ide.eclipse.preferences.main", //$NON-NLS-1$ preferencePageId null, // displayedIds null); // data dialog.open(); } }); }
From source file:com.android.ide.eclipse.auidt.AdtPlugin.java
License:Open Source License
/** * Checks the location of the SDK is valid and if it is, grab the SDK API version * from the SDK.// w w w . ja v a 2 s . com * @return false if the location is not correct. */ private boolean checkSdkLocationAndId() { String sdkLocation = AdtPrefs.getPrefs().getOsSdkFolder(); if (sdkLocation == null || sdkLocation.length() == 0) { return false; } return checkSdkLocationAndId(sdkLocation, new CheckSdkErrorHandler() { private String mTitle = "Android SDK Verification"; @Override public boolean handleError(Solution solution, String message) { displayMessage(solution, message, MessageDialog.ERROR); return false; } @Override public boolean handleWarning(Solution solution, String message) { displayMessage(solution, message, MessageDialog.WARNING); return true; } private void displayMessage(final Solution solution, final String message, final int dialogImageType) { final Display disp = getDisplay(); disp.asyncExec(new Runnable() { @Override public void run() { Shell shell = disp.getActiveShell(); if (shell == null) { return; } String customLabel = null; switch (solution) { case OPEN_ANDROID_PREFS: customLabel = "Open Preferences"; break; case OPEN_P2_UPDATE: customLabel = "Check for Updates"; break; case OPEN_SDK_MANAGER: customLabel = "Open SDK Manager"; break; } String btnLabels[] = new String[customLabel == null ? 1 : 2]; btnLabels[0] = customLabel; btnLabels[btnLabels.length - 1] = IDialogConstants.CLOSE_LABEL; MessageDialog dialog = new MessageDialog(shell, // parent mTitle, null, // dialogTitleImage message, dialogImageType, btnLabels, btnLabels.length - 1); int index = dialog.open(); if (customLabel != null && index == 0) { switch (solution) { case OPEN_ANDROID_PREFS: openAndroidPrefs(); break; case OPEN_P2_UPDATE: openP2Update(); break; case OPEN_SDK_MANAGER: openSdkManager(); break; } } } }); } private void openSdkManager() { // Windows only: open the standalone external SDK Manager since we know // that ADT on Windows is bound to be locking some SDK folders. if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) { if (SdkManagerAction.openExternalSdkManager()) { return; } } // Otherwise open the regular SDK Manager bundled within ADT if (!SdkManagerAction.openAdtSdkManager()) { // We failed because the SDK location is undefined. In this case // let's open the preferences instead. openAndroidPrefs(); } } private void openP2Update() { Display disp = getDisplay(); if (disp == null) { return; } disp.asyncExec(new Runnable() { @Override public void run() { String cmdId = "org.eclipse.equinox.p2.ui.sdk.update"; //$NON-NLS-1$ IWorkbench wb = PlatformUI.getWorkbench(); if (wb == null) { return; } ICommandService cs = (ICommandService) wb.getService(ICommandService.class); IHandlerService is = (IHandlerService) wb.getService(IHandlerService.class); if (cs == null || is == null) { return; } Command cmd = cs.getCommand(cmdId); if (cmd != null && cmd.isDefined()) { try { is.executeCommand(cmdId, null/*event*/); } catch (Exception ignore) { AdtPlugin.log(ignore, "Failed to execute command %s", cmdId); } } } }); } private void openAndroidPrefs() { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getDisplay().getActiveShell(), "com.android.ide.eclipse.preferences.main", //$NON-NLS-1$ preferencePageId null, // displayedIds null); // data dialog.open(); } }); }
From source file:com.android.ide.eclipse.traceview.editors.TraceviewEditor.java
License:Apache License
@Override public void doSaveAs() { Shell shell = getSite().getShell();/* w ww .j av a 2 s. c o m*/ final IEditorInput input = getEditorInput(); final IEditorInput newInput; if (input instanceof FileEditorInput) { // the file is part of the current workspace FileEditorInput fileEditorInput = (FileEditorInput) input; SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = fileEditorInput.getFile(); if (original != null) { dialog.setOriginalFile(original); } dialog.create(); if (original != null && !original.isAccessible()) { String message = String.format("The original file ''%s'' has been deleted or is not accessible.", original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { return; } IPath filePath = dialog.getResult(); if (filePath == null) { return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); if (copy(shell, fileEditorInput.getURI(), file.getLocationURI()) == null) { return; } try { file.refreshLocal(IFile.DEPTH_ZERO, null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } newInput = new FileEditorInput(file); setInput(newInput); setPartName(newInput.getName()); } else if (input instanceof FileStoreEditorInput) { // the file is not part of the current workspace FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) input; FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(fileStoreEditorInput.getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null, String.format("%s already exists.\nDo you want to replace it?", path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { return; } } IFileStore destFileStore = copy(shell, fileStoreEditorInput.getURI(), localFile.toURI()); if (destFileStore != null) { IFile file = getWorkspaceFile(destFileStore); if (file != null) { newInput = new FileEditorInput(file); } else { newInput = new FileStoreEditorInput(destFileStore); } setInput(newInput); setPartName(newInput.getName()); } } }
From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *///from www . j av a 2 s.c o m public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$ /* continue */ case 1: return new Boolean(true); case 3: WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$ return new Boolean(true); default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, new String[] { ((String) source).substring(5) })); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, new String[] { ((String) source).substring(10) })); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } } IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return new Boolean(true); } } String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, new String[] { (String) source }); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return new Boolean(true); case IDialogConstants.NO_ID: return new Boolean(false); default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.syncing.ui.actions.SyncActionEventHandler.java
License:Open Source License
private void showError(final String message, final Exception e) { fContinue = false;//w w w .j a va2 s . c om UIUtils.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog md = new MessageDialog(UIUtils.getActiveShell(), CoreStrings.ERROR + " " + fTaskTitle, //$NON-NLS-1$ null, message, MessageDialog.WARNING, new String[] { CoreStrings.CONTINUE, CoreStrings.CANCEL }, 1); fContinue = (md.open() == 0); } }); }
From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//* ww w.j a va2s.c o m*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = UIUtils.getActiveShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ return Boolean.TRUE; case 1: return Boolean.TRUE; case 3: WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER); return Boolean.TRUE; default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format( Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5))); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, ((String) source).substring(10))); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } } IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, (String) source); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return Boolean.TRUE; case IDialogConstants.NO_ID: return Boolean.FALSE; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * The constructor./*from w ww . j av a 2 s . c om*/ */ public UISeeCodePlugin() { super(); plugin = this; try { resourceBundle = ResourceBundle.getBundle("com.arc.cdt.debug.seecode.ui.SeeCode"); } catch (MissingResourceException x) { resourceBundle = null; } // // Create the object that intercepts "create-display" // // events from the core plugin so as to create // // the Custom seecode displays. // new DisplayCreatorDelegate(); // The core plugin doesn't "see" us to avoid // circular dependencies. But it needs to // instantiate the CustomDisplayCallback class // that is defined in this package. // We use a callback to do that: SeeCodePlugin.getDefault().setCustomDisplayCallbackCreator(new ICustomDisplayCallbackCreator() { @Override public ICustomDisplayCallback create(ICDITarget target) { return new CustomDisplayCallback(target); } }); SeeCodePlugin.getDefault().setLicenseExpirationChecker(new ILicenseExpirationChecker() { @Override public void checkLicenseExpiration(int days) { UISeeCodePlugin.this.checkLicensingAlert(days); } }); SeeCodePlugin.getDefault().setLicensingFailure(new ILicenseFailure() { @Override public void reportLicenseFailure(final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "A valid license for " + UISeeCodePlugin.getTheDebuggerName() + " was not found.\n\n" + msg; IStatus status = makeErrorStatus(fullMsg); ErrorDialog.openError(shell, UISeeCodePlugin.getDebuggerName() + " Licensing Failure", null, status); } }); } }); SeeCodePlugin.getDefault().setStatusWriter(new IStatusWriter() { @Override public void setStatus(final String msg) { // We need to get to the status line manager, but we can only get // access to from a viewsite. Unfortunately, we have // no direct reference to such. Therefore, look for // the debug view whose ID is "org.eclipse.debug.ui.DebugView" PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart viewPart = page.findView(IDebugUIConstants.ID_DEBUG_VIEW); if (viewPart != null) { IStatusLineManager statusLine = viewPart.getViewSite().getActionBars() .getStatusLineManager(); statusLine.setMessage(msg); } } } } }); } }); SeeCodePlugin.getDefault().setTermSimInstantiator(new TermSimInstantiator()); SeeCodePlugin.getDefault().setDisplayError(new IDisplayMessage() { @Override public void displayError(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showError(title, msg); } }); } @Override public void displayNote(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showNote(title, msg); } }); } }); SeeCodePlugin.getDefault().setEngineVersionStrategyCallback(new IEngineResolver() { @Override public boolean useToolSetEngine(final int bundledEngineId, final int toolsetEngineId, final String toolsetPath) { switch (SeeCodePlugin.getDefault().getPreferences().getInt( ISeeCodeConstants.PREF_ENGINE_VERSION_MANAGEMENT, ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET)) { case ISeeCodeConstants.ENGINE_VERSION_PROMPT: if (bundledEngineId != toolsetEngineId) { final boolean results[] = new boolean[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { results[0] = new PromptForEngineSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), bundledEngineId, toolsetEngineId, toolsetPath).open(); } }); return results[0]; } return false; case ISeeCodeConstants.ENGINE_VERSION_USE_BUNDLED: return false; case ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET: return true; case ISeeCodeConstants.ENGINE_VERSION_USE_LATEST: return toolsetEngineId > bundledEngineId; } return false; // shouldn't get here } }); /* SeeCodePlugin.getDefault().setProgramLoadTimeoutCallback(new IDiagnoseProgramLoadTimeout(){ public void diagnoseTimeout (final String exeName, final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run () { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine timed out while loading\n\"" + exeName + "\".\n" + "The current timeout for loading a program is " + timeout + " milliseconds.\n" + "If you have a slow target connection, or if you are doing a long-running\n"+ "blast operation, you may need to increase the timeout value. Go to the\n" + "preference page: \"Windows->Preferences->C/C++->Debugger->MetaWare Debugger\".\n"; IStatus status = SeeCodePlugin.makeErrorStatus(fullMsg); ErrorDialog.openError(shell, "Program load timeout failure", null, status); } }); }});*/ SeeCodePlugin.getDefault().setLoadTimeoutCallback(new ITimeoutCallback() { private int _newTimeout = 0; @Override public int getNewTimeout(final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine is attempting to load a program and it has not\n" + "completed after \"" + (timeout + 500) / 1000 + "\" seconds (as specified in the " + "MetaWare Debugger\npreferences page).\n\n" + "If you are loading over a slow connnection, or if you are doing a blast\n" + "operation, the engine may need more time.\n\n" + "What do you want the IDE to do?\n"; MessageDialog dialog = new MessageDialog(shell, "Engine Timeout Alert", null, // accept fullMsg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { Composite container = new Group(parent, 0); container.setLayout(new GridLayout(4, false)); GridData gd = new GridData(); gd.horizontalSpan = 1; gd.grabExcessHorizontalSpace = false; final Button b1 = new Button(container, SWT.RADIO); b1.setLayoutData(gd); b1.setText("Wait no longer;"); // Label on button appears to be limited in size; add additional // as a label Label label1 = new Label(container, SWT.LEFT); label1.setText("abort if load is not yet complete."); GridData gd1 = new GridData(); gd1.horizontalSpan = 3; gd1.grabExcessHorizontalSpace = true; label1.setLayoutData(gd1); gd = new GridData(); gd.horizontalSpan = 4; gd.grabExcessHorizontalSpace = true; final Button b2 = new Button(container, SWT.RADIO); b2.setLayoutData(gd); b2.setText("Continue waiting indefinitely."); final Button b3 = new Button(container, SWT.RADIO); b3.setText("Wait for an additional number of seconds"); b3.setLayoutData(gd); final Label label = new Label(container, SWT.LEFT); label.setText(" Number of additional seconds to wait: "); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); final Text field = new Text(container, SWT.SINGLE); field.setText("" + (timeout + 500) / 1000); gd = new GridData(); gd.horizontalSpan = 2; gd.grabExcessHorizontalSpace = true; gd.minimumWidth = 80; field.setLayoutData(gd); SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { if (e.widget == b1) { _newTimeout = 0; field.setEnabled(false); label.setEnabled(false); } else if (e.widget == b2) { _newTimeout = -1; field.setEnabled(false); label.setEnabled(false); } else { field.setEnabled(true); label.setEnabled(true); try { _newTimeout = Integer.parseInt(field.getText()) * 1000; } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } } }; b1.addSelectionListener(listener); b2.addSelectionListener(listener); b3.addSelectionListener(listener); field.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { try { if (b3.getSelection()) { _newTimeout = Integer.parseInt(field.getText()) * 1000; if (_newTimeout < 0) { field.setText("0"); _newTimeout = 0; } } } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } }); return container; } }; if (dialog.open() != Window.OK) { _newTimeout = 0; // terminate immediately. } } }); return _newTimeout; } }); /* * Set the Run wrapper for all engine callbacks so that they are in the UI thread. */ SeeCodePlugin.getDefault().setCallbackRunner(new IRunner() { @Override public void invoke(Runnable run, boolean async) throws Throwable { Display display = PlatformUI.getWorkbench().getDisplay(); try { // Run asynchronously to avoid deadlock of UI thread is // waiting for the engine to return. // display is null or disposed after workbench has shutdown, // but the engine may still be sending stuff... if (display != null && !display.isDisposed()) { if (async) { display.asyncExec(run); } else display.syncExec(run); } } catch (SWTException e) { if (e.throwable != null) { // If the display is disposed of after the above // check, but before the "run" is invoked, then // we can get an exception. Ignore such cases. if (display != null && !display.isDisposed()) throw e.throwable; } throw e; } } }); }