List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.nokia.tracebuilder.view.TraceViewDialogs.java
License:Open Source License
public int showConfirmationQuery(QueryDialogParameters parameters) { Shell shell = view.getShell();//from ww w . ja v a 2 s. c o m int ret = CANCEL; if (shell != null) { if (parameters instanceof DirectoryDialogQueryParameters) { ret = showDirectoryQuery((DirectoryDialogQueryParameters) parameters); } else if (parameters instanceof FileDialogQueryParameters) { ret = showFileQuery((FileDialogQueryParameters) parameters); } else if (parameters instanceof ExtendedQueryParameters) { ret = showExtendedQueryDialog(parameters, shell); } else { if (MessageDialog.openQuestion(shell, Messages.getString("TraceView.TraceBuilder"), //$NON-NLS-1$ TraceViewMessages.getConfirmationQueryText(parameters))) { ret = OK; } } } return ret; }
From source file:com.onpositive.richtexteditor.actions.ActionFactory.java
License:Open Source License
/** * @return insert new customize font style dialog action *//* w w w .j a va 2 s.com*/ public IAction getCustomizeFontStyleAction() { if (customizeFontStyleAction == null) { customizeFontStyleAction = new Action("", Action.AS_PUSH_BUTTON) { public void run() { FontConfigurationDialog configurationDialog; configurationDialog = new FontConfigurationDialog(viewer.getTextWidget().getShell(), (FontStyleManager) manager.getFontStyleManager()); configurationDialog.create(); int retCode = configurationDialog.open(); if (retCode == Window.OK) { FontStyleData data = configurationDialog.getData(); if (data.getDeletedStyles().size() > 0) { ArrayList<FontStyle> usedStyles = new ArrayList<FontStyle>(); for (Iterator<FontStyle> iterator = data.getDeletedStyles().iterator(); iterator .hasNext();) { FontStyle deletedStyle = (FontStyle) iterator.next(); if (manager.isStyleUsed(deletedStyle)) usedStyles.add(deletedStyle); } if (usedStyles.size() > 0) { String namesList = ""; StringBuilder b = new StringBuilder(); for (Iterator<FontStyle> iterator = usedStyles.iterator(); iterator.hasNext();) { b.append(((FontStyle) iterator.next()).getDisplayName()); b.append(','); } namesList = b.toString(); boolean res = MessageDialog.openQuestion(null, "Styles is in use", "Foolowing styles is in use: " + namesList + ". Delete them and replace with default style in text?"); if (res) { for (Iterator<FontStyle> iterator = usedStyles.iterator(); iterator.hasNext();) manager.removeStyleFromAllPartitions((FontStyle) iterator.next()); } else data.getFontStyles().addAll(usedStyles); } } ArrayList<FontStyle> changedStylesList = data .validateChangedStyles(manager.getFontStyleManager()); if (changedStylesList.size() > 0 || data.getAddedStyles().size() > 0 || data.getDeletedStyles().size() > 0) { manager.getActualTextWidget() .setFont(data.getResultFontRegistry().get(FontStyleManager.NORMAL_FONT_NAME)); ((FontStyleManager) manager.getFontStyleManager()).reinit(data.getFontStyles(), data.getResultFontRegistry(), changedStylesList); /* * combo.setItems(manager.getFontStyleManager().getFontStyleDisplayNames * ());combo.setText(manager.getFontStyleManager(). * getDefaultStyle().getDisplayName()); */ } } } }; manager.getFontStyleManager().addFontStyleChangeListener(new FontStylesChangeListener() { public void stylesChanged(ArrayList<FontStyle> changedStyles) { if (combo == null) return; combo.setItems(manager.getFontStyleManager().getFontStyleDisplayNames()); combo.setText(manager.getFontStyleManager().getDefaultStyle().getDisplayName()); } }); customizeFontStyleAction.setText("Customize Font Styles"); customizeFontStyleAction.setImageDescriptor(images.getDescriptor(CUSTOMIZE_FONT_STYLES_IMAGE)); } return customizeFontStyleAction; }
From source file:com.opera.widgets.ui.wizard.export.WidgetExportWizard.java
License:Open Source License
/** * TODO make an Operation (Eclipse's Job) *///from w w w. j a va 2 s . com @Override public boolean performFinish() { fIgnoredFiles = WidgetsActivator.getDefault().getIgnoredExportElements(); File destinationFile = new File(fExportPage.getDestinationValue()); if (destinationFile.exists()) { if (!MessageDialog.openQuestion(getContainer().getShell(), Messages.WidgetExportWizard_ConfirmReplaceTitle, NLS.bind(Messages.WidgetExportWizard_ConfirmReplaceDesc, destinationFile.getAbsolutePath()))) { return false; } } IFolder buildFolder = fExportPage.getSelectedProject().getFolder(BUILD_FOLDER_NAME); try { if (!buildFolder.exists()) { buildFolder.create(true, false, null); } IFolder tempFolder = buildFolder.getFolder(TEMP_FOLDER_NAME); if (tempFolder.exists()) { tempFolder.delete(true, null); } tempFolder.create(true, true, null); IFolder srcFolder = fExportPage.getSelectedProject().getFolder(WIDGET_SRC_FOLDER); copyValidResources(srcFolder, tempFolder); ZipMaker.zipDirectory(tempFolder.getLocation().toFile(), destinationFile); tempFolder.delete(true, null); return true; } catch (Exception e) { e.printStackTrace(); printErrorDialog(e); } return false; }
From source file:com.persistent.ui.propertypage.WARemoteAccessPropertyPage.java
License:Open Source License
/** * Method specifies action to be executed when OK button is pressed. *///from w w w. jav a2 s . c o m public boolean performOk() { if (!isPageDisplayed) { return super.performOk(); } try { loadProject(); if (remoteChkBtn.getSelection()) { waProjManager.setRemoteAccessAllRoles(true); String userName = txtUserName.getText(); String pwd = txtPassword.getText(); String cnfPwd = txtConfirmPwd.getText(); String newPath = txtPath.getText(); String expDate = txtExpiryDate.getText(); String tempPath = newPath; boolean isPathChanged = false; DateFormat formatter = new SimpleDateFormat(Messages.remAccDateFormat, Locale.getDefault()); if (userName == null || userName.equalsIgnoreCase("")) { PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccNameNull); return false; } else { waProjManager.setRemoteAccessUsername(userName); } if (!newPath.equals(waProjManager.getRemoteAccessCertificatePath()) && !newPath.isEmpty()) { isPathChanged = true; /* * check If certificate file path has changed, * If yes then prompt user * for changing the password as well, * if that is not changed. * Because we have to encrypt the new password * and then we will generate certificate * based on that. * Case 1 :- If user has changed the path * and password is old then it * will prompt for new password or re-enter the password. * If user changes the password * then it will generate certificate based * on that new password. * Case 2 :- If user set the blank password * even after displaying that * password change prompt, in that case * we will display warning messages * to user that whether he want to continue * with empty password, If yes * then we will consider that blank password * else use will have to enter * new password. */ if (pwd.equals(waProjManager.getRemoteAccessEncryptedPassword()) && !pwd.isEmpty()) { txtPassword.setText(""); txtConfirmPwd.setText(""); PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccPwdMstChng); return false; } } if (pwd.isEmpty()) { boolean choice = MessageDialog.openQuestion(getShell(), Messages.remAccErTxtTitle, Messages.remAccWarnPwd); if (!choice) { return false; } } if (expDate == null || expDate.equalsIgnoreCase("")) { PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccExpDateNull); return false; } else { boolean status = validateExpDate(expDate, formatter); if (!status) { return false; } } if (newPath == null || newPath.equalsIgnoreCase("")) { PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccPathNull); return false; } /* * Check for displaying the relative path * in case when user select the certificate file path * as workspace or of current project. * We will be showing relative path in that case on UI. */ if (tempPath.startsWith(BASE_PATH)) { tempPath = tempPath.substring(tempPath.indexOf("}") + 1, tempPath.length()); tempPath = String.format("%s%s", selProject.getLocation().toOSString(), tempPath); } File file = new File(tempPath); //if path is not correct.display error message for that. if (file.exists() && tempPath.endsWith(".cer")) { waProjManager.setRemoteAccessCertificatePath(newPath); } else { PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccInvldPath); return false; } try { if (isPathChanged) { String thumbprint = CerPfxUtil.getThumbPrint(tempPath); if (waProjManager.isRemoteAccessTryingToUseSSLCert(thumbprint)) { PluginUtil.displayErrorDialog(getShell(), Messages.remAccSyntaxErr, Messages.usedBySSL); return false; } else { waProjManager.setRemoteAccessCertificateFingerprint(thumbprint); } } } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(this.getShell(), Messages.remAccSyntaxErr, Messages.remAccErTmbPrint, e); return false; } if (cnfPwd.equals(pwd)) { try { /* * Encrypting the password * if it is not dummy & blank from xml * and isPwdChanged is true that means * user has changes the password. */ String modifiedPwd = Messages.remAccDummyPwd; if (!pwd.equals(modifiedPwd) && !pwd.isEmpty() && isPwdChanged) { String encryptedPwd = EncUtilHelper.encryptPassword(pwd, tempPath, PluginUtil.getEncPath()); waProjManager.setRemoteAccessEncryptedPassword(encryptedPwd); } else { waProjManager.setRemoteAccessEncryptedPassword(pwd); } } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.remAccSyntaxErr, Messages.remAccErPwd, e); return false; } } else { PluginUtil.displayErrorDialog(this.getShell(), Messages.remAccErTxtTitle, Messages.remAccPwdNotMatch); return false; } } else { waProjManager.setRemoteAccessAllRoles(false); } waProjManager.save(); } catch (WindowsAzureInvalidProjectOperationException e) { errorTitle = Messages.remAccSyntaxErr; errorMessage = Messages.proPageErrMsgBox1 + Messages.proPageErrMsgBox2; PluginUtil.displayErrorDialog(this.getShell(), errorTitle, errorMessage); Activator.getDefault().log(Messages.remAccErConfigErr, e); } catch (ParseException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.remAccErrTitle, Messages.remAccErDateParse, e); return false; } WAEclipseHelper.refreshWorkspace(Messages.remAccWarning, Messages.remAccWarnMsg); isFrmEncLink = false; return super.performOk(); }
From source file:com.persistent.winazureroles.LocalStorageResourceDialog.java
License:Open Source License
/** * Validates the size of VM./*w ww . j a va 2 s. c om*/ * * @param size : user entered size * @param resName : name of the resource * @return isValidSize : true if size is valid else false. */ private boolean isValidSize(String size, String resName) { boolean isValidSize = false; try { int value = Integer.parseInt(size); if (value <= 0) { PluginUtil.displayErrorDialog(getShell(), Messages.lclStgSizeErrTtl, Messages.lclStgSizeErrMsg); isValidSize = false; } else if (value > maxSize) { boolean choice = MessageDialog.openQuestion(getShell(), Messages.lclStgMxSizeTtl, String.format("%s%s%s", Messages.lclStgMxSizeMsg1, maxSize, Messages.lclStgMxSizeMsg2)); if (choice) { isValidSize = true; } else { /* * If user selects No * then keep dialog open. */ isValidSize = false; } } else { isValidSize = true; } } catch (NumberFormatException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.lclStgSizeErrTtl, Messages.lclStgSizeErrMsg, e); isValidSize = false; } return isValidSize; }
From source file:com.persistent.winazureroles.WAEndpointDialog.java
License:Open Source License
/** * Disables the debugging if debug endpoint's type is changed to 'Internal', * and if private port is modified then assigns the new debugging port * by setting the modified endpoint as a debugging endpoint. * * @param oldType : old type of the endpoint. * @return retVal : false if any error occurs. * @throws WindowsAzureInvalidProjectOperationException */// w ww .j av a 2s . c om private boolean handleChangeForDebugEndpt(WindowsAzureEndpointType oldType, String privatePort) throws WindowsAzureInvalidProjectOperationException { boolean retVal = true; if (oldType.equals(WindowsAzureEndpointType.Input) && comboType.getText().equalsIgnoreCase(WindowsAzureEndpointType.Internal.toString())) { boolean choice = MessageDialog.openQuestion(getShell(), Messages.dlgTypeTitle, String.format("%s%s%s", Messages.dlgEPDel, Messages.dlgEPChangeType, Messages.dlgEPDel2)); if (choice) { waEndpt.setEndPointType(WindowsAzureEndpointType.valueOf(comboType.getText())); windowsAzureRole.setDebuggingEndpoint(null); } else { retVal = false; } } else if (privatePort == null) { PluginUtil.displayErrorDialog(getShell(), Messages.dlgInvldPort, Messages.dbgPort); retVal = false; } else if (!waEndpt.getPrivatePort().equalsIgnoreCase(privatePort)) { boolean isSuspended = windowsAzureRole.getStartSuspended(); windowsAzureRole.setDebuggingEndpoint(null); waEndpt.setPrivatePort(privatePort); windowsAzureRole.setDebuggingEndpoint(waEndpt); windowsAzureRole.setStartSuspended(isSuspended); } return retVal; }
From source file:com.persistent.winazureroles.WARCaching.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected cache entry./*w w w .j a v a2s .c o m*/ */ protected void removeBtnListener() { try { boolean choice = MessageDialog.openQuestion(getShell(), Messages.cachRmvTtl, Messages.cachRmvMsg); if (choice) { Entry<String, WindowsAzureNamedCache> cachEntry = getSelNamedCache(); WindowsAzureNamedCache cachToDel = cachEntry.getValue(); cachToDel.delete(); tableViewer.refresh(); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cachErrTtl, Messages.cachDelErMsg, e); } }
From source file:com.persistent.winazureroles.WARComponents.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected component.//www .j a v a2 s . c om */ protected void removeBtnListener() { int selIndex = tblViewer.getTable().getSelectionIndex(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); WindowsAzureRoleComponent component = listComponents.get(selIndex); if (selIndex > -1) { try { /* First condition: Checks component is part of a JDK, * server configuration * Second condition: For not showing error message * "Disable Server JDK Configuration" * while removing server application * when server or JDK is already disabled. */ if (component.getIsPreconfigured() && (!(component.getType().equals(Messages.typeSrvApp) && windowsAzureRole.getServerName() == null))) { PluginUtil.displayErrorDialog(getShell(), Messages.jdkDsblErrTtl, Messages.jdkDsblErrMsg); } else { boolean choice = MessageDialog.openQuestion(getShell(), Messages.cmpntRmvTtl, Messages.cmpntRmvMsg); if (choice) { String cmpntPath = String.format("%s%s%s%s%s", root.getProject(waProjManager.getProjectName()).getLocation(), File.separator, windowsAzureRole.getName(), Messages.approot, component.getDeployName()); File file = new File(cmpntPath); // Check import source is equal to approot if (component.getImportPath().isEmpty() && file.exists()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.cmpntSrcRmvTtl, null, Messages.cmpntSrcRmvMsg, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); switch (dialog.open()) { case 0: //yes component.delete(); tblViewer.refresh(); fileToDel.add(file); break; case 1: //no component.delete(); tblViewer.refresh(); break; case 2: //cancel break; default: break; } } else { component.delete(); tblViewer.refresh(); fileToDel.add(file); } } } if (tblComponents.getItemCount() == 0) { // table is empty i.e. number of rows = 0 btnRemove.setEnabled(false); btnEdit.setEnabled(false); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cmpntSetErrTtl, Messages.cmpntRmvErrMsg, e); } } updateMoveButtons(); }
From source file:com.persistent.winazureroles.WARDebugging.java
License:Open Source License
/** * This method sets the status of debug option * based on the user input.If user checks the debug check box * first time then it will add a debugging end point otherwise it will * prompt the user for removal of associated end point for debugging if * user already has some debug end point associated and unchecked * the debug check box./*w w w. ja va2 s . co m*/ */ private void debugOptionStatus() { if (debugCheck.getSelection()) { makeDebugEnable(); try { windowsAzureRole.setDebuggingEndpoint(dbgSelEndpoint); windowsAzureRole.setStartSuspended(jvmCheck.getSelection()); } catch (WindowsAzureInvalidProjectOperationException e1) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.adRolErrTitle, Messages.dlgDbgErr, e1); } } else { setValid(true); if (isDebugChecked && !comboEndPoint.getText().equals("")) { String msg = String.format("%s%s", Messages.dlgDbgEdPtAscMsg, comboEndPoint.getText()); boolean choice = MessageDialog.openQuestion(getShell(), Messages.dlgDbgEndPtErrTtl, msg); if (choice) { removeDebugAssociatedEndpoint(); } else { makeAllDisable(); try { windowsAzureRole.setDebuggingEndpoint(null); } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.adRolErrTitle, Messages.dlgDbgErr, e); } } } else { removeDebugAssociatedEndpoint(); } } }
From source file:com.persistent.winazureroles.WAREndpoints.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected endpoint./*from w ww . j a va 2 s . c om*/ */ protected void removeBtnListener() { int selIndex = tblViewer.getTable().getSelectionIndex(); if (selIndex > -1) { try { WindowsAzureEndpoint debugEndpt = windowsAzureRole.getDebuggingEndpoint(); String dbgEndptName = ""; if (debugEndpt != null) { dbgEndptName = debugEndpt.getName(); } // delete the selected endpoint WindowsAzureEndpoint waEndpoint = listEndPoints.get(selIndex); /* * Check end point selected for removal * is associated with Caching then give error * and does not allow to remove. */ if (waEndpoint.isCachingEndPoint()) { PluginUtil.displayErrorDialog(getShell(), Messages.cachDsblErTtl, Messages.endPtRmvErMsg); } /* * Check end point selected for removal * is associated with Debugging. */ else if (waEndpoint.getName().equalsIgnoreCase(dbgEndptName)) { StringBuffer msg = new StringBuffer(Messages.dlgEPDel); msg.append(Messages.dlgEPDel1); msg.append(Messages.dlgEPDel2); boolean choice = MessageDialog.openQuestion(getShell(), Messages.dlgDelEndPt1, msg.toString()); if (choice) { waEndpoint.delete(); windowsAzureRole.setDebuggingEndpoint(null); } } /* * Endpoint associated with both SSL * and Session affinity */ else if (waEndpoint.isStickySessionEndpoint() && waEndpoint.isSSLEndpoint()) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.dlgDelEndPt1, Messages.bothDelMsg); if (choice) { if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) { windowsAzureRole.setSessionAffinityInputEndpoint(null); windowsAzureRole.setSslOffloading(null, null); waEndpoint.delete(); } else { windowsAzureRole.setSessionAffinityInputEndpoint(null); windowsAzureRole.setSslOffloading(null, null); } } } /* * Check end point selected for removal * is associated with Load balancing * i.e (HTTP session affinity). */ else if (waEndpoint.isStickySessionEndpoint()) { StringBuffer msg = new StringBuffer(Messages.ssnAffDelMsg); boolean choice = MessageDialog.openConfirm(getShell(), Messages.dlgDelEndPt1, msg.toString()); if (choice) { if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) { windowsAzureRole.setSessionAffinityInputEndpoint(null); waEndpoint.delete(); } else { windowsAzureRole.setSessionAffinityInputEndpoint(null); } } } /* * Endpoint associated with SSL */ else if (waEndpoint.isSSLEndpoint()) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.dlgDelEndPt1, Messages.sslDelMsg); if (choice) { if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) { windowsAzureRole.setSslOffloading(null, null); waEndpoint.delete(); } else { windowsAzureRole.setSslOffloading(null, null); } } } /* * Endpoint associated with SSL redirection. */ else if (waEndpoint.isSSLRedirectEndPoint()) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.dlgDelEndPt1, Messages.sslRedirectDelMsg); if (choice) { windowsAzureRole.deleteSslOffloadingRedirectionEndpoint(); } } /* * Normal end point. */ else { boolean choice = MessageDialog.openQuestion(getShell(), Messages.dlgDelEndPt1, Messages.dlgDelEndPt2); if (choice) { waEndpoint.delete(); } } tblViewer.refresh(); if (tblEndpoints.getItemCount() == 0) { // table is empty i.e. number of rows = 0 btnRemove.setEnabled(false); btnEdit.setEnabled(false); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(this.getShell(), Messages.adRolErrTitle, Messages.adRolErrMsgBox1 + Messages.adRolErrMsgBox2, e); } } }