List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:com.observability.modeling.common.UI.java
License:Open Source License
/** * This method gets the server details (ip and port) where the ModelHandler RMI service * is running. It shows an input dialog where the user would enter the ip and port where * the RMI service is running. /*from w ww . jav a 2 s. c o m*/ * If the user presses Cancel, the action would be cancelled and nothing would be done. * * The user input is validated before being accepted. Currently only ipv4 addresses are accepted. * * @param messageType the type of the message to be shown in the dialog box. * The values should be used from JOptionPane class. * @param message Any additional message which needs to be appended before the default input message * * @return A String array containing ip and port. Index 0 contains ip, index 1 contains port */ public String[] getServerDetails(int messageType, String message) { String input = null; // create the input dialog box ipPortInputDialog.create(messageType, (message + Messages.Ui_MSG_INFO_ENTER_IP_PORT)); // open the input dialog box and take user input if (ipPortInputDialog.open() == org.eclipse.jface.window.Window.OK) { input = ipPortInputDialog.getIpPort(); } if (input == null || input.equals("")) { //user has pressed cancel button or has not entered anything Take confirmation from user String msg = Messages.Ui_MSG_INFO_SERVER_CANCEL; boolean option = MessageDialog.openConfirm(shell, SERVER_DETAILS_TITLE, msg); if (option) { // Do not transfer files to server return new String[0]; } else { // show the box again return getServerDetails(IMessageProvider.NONE, ""); } } else { //validate input String ipRegex = "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})"; Pattern pattern = Pattern.compile(ipRegex); Matcher matcher = pattern.matcher(input); String[] serverDetails = new String[2]; if (matcher.matches()) { serverDetails[0] = matcher.group(1); //ip serverDetails[1] = matcher.group(2); //port return serverDetails; } else { //wrong input. Get input again return getServerDetails(IMessageProvider.ERROR, Messages.Ui_MSG_ERROR_WRONG_INPUT); } } }
From source file:com.opera.widgets.ui.editor.dialog.IconDetailsPage.java
License:Open Source License
private boolean confirmReplace(String fileName) { return MessageDialog.openConfirm(getShell(), Messages.IconDetailsPage_IconExistsErrorTitle, NLS.bind(Messages.IconDetailsPage_IconExistsErrorDesc, fileName)); }
From source file:com.persistent.ui.preference.StorageAccountsPreferencePage.java
License:Open Source License
/** * Method removes selected storage account from list. */// w w w .j ava 2s.com protected void removeButtonListener() { int curSelIndex = tableViewer.getTable().getSelectionIndex(); if (curSelIndex > -1) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.accRmvTtl, Messages.accRmvMsg); if (choice) { StorageAccountRegistry.getStrgList().remove(curSelIndex); PreferenceUtilStrg.save(); tableViewer.refresh(); /* * Do not remember selection index when element is removed. * As after remove no row is selected in table * and we don't want to set combo box to element * which is next to removed element. */ selIndex = -1; } } }
From source file:com.persistent.ui.toolbar.WARunEmulator.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // Get selected WA project IProject selProject = WAEclipseHelper.getSelectedProject(); errorTitle = String.format("%s%s%s", Messages.waEmulator, " ", Messages.runEmltrErrTtl); try {/*w w w. j av a 2s . co m*/ WindowsAzureProjectManager waProjManager = WindowsAzureProjectManager .load(new File(selProject.getLocation().toOSString())); /* * always set WindowsAzureProjectManager object * as we don't update on project selection. */ Activator.getDefault().setWaProjMgr(waProjManager); List<WindowsAzureRole> roleList = waProjManager.getRoles(); if (roleList.size() > 0) { Activator.getDefault().setWaRole(roleList.get(0)); } WindowsAzureRole roleWithoutLocalJdk = performJDKCheck(roleList); if (roleWithoutLocalJdk == null) { WindowsAzureRole roleWithoutLocalServer = performServerCheck(roleList); if (roleWithoutLocalServer == null) { if (waProjManager.getPackageType().equals(WindowsAzurePackageType.CLOUD)) { waProjManager.setPackageType(WindowsAzurePackageType.LOCAL); } waProjManager.save(); final IProject selProj = selProject; Job job = new Job(Messages.runJobTtl) { @Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask(Messages.runJobTtl, IProgressMonitor.UNKNOWN); try { WindowsAzureProjectManager waProjMgr = WindowsAzureProjectManager .load(new File(selProj.getLocation().toOSString())); selProj.build(IncrementalProjectBuilder.FULL_BUILD, null); waProjMgr = WindowsAzureProjectManager .load(new File(selProj.getLocation().toOSString())); if (WAEclipseHelper.isBuildSuccessful(waProjMgr, selProj)) { waProjMgr.deployToEmulator(); } else { return Status.CANCEL_STATUS; } } catch (WindowsAzureInvalidProjectOperationException e) { errorMessage = String.format("%s %s%s%s", Messages.runEmltrErrMsg, selProj.getName(), " in ", Messages.waEmulator); Activator.getDefault().log(errorMessage, e); Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog.openError(null, errorTitle, errorMessage); } }); return Status.CANCEL_STATUS; } catch (Exception ex) { errorMessage = Messages.bldErrMsg; Activator.getDefault().log(errorMessage, ex); Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog.openError(null, Messages.bldErrTtl, errorMessage); } }); return Status.CANCEL_STATUS; } monitor.done(); return Status.OK_STATUS; } }; job.schedule(); } else { // show server message dialog boolean choice = MessageDialog.openConfirm(new Shell(), errorTitle, String.format(Messages.noLocalServerMsg, roleWithoutLocalServer.getName())); if (choice) { Activator.getDefault().setWaRole(roleWithoutLocalServer); WAEclipseHelper.openRolePropertyDialog(roleWithoutLocalServer, com.persistent.contextmenu.Messages.srvConfPgId, "Server"); } } } else { // show JDK message dialog boolean choice = MessageDialog.openConfirm(new Shell(), errorTitle, String.format(Messages.noLocalJDKMsg, roleWithoutLocalJdk.getName())); if (choice) { Activator.getDefault().setWaRole(roleWithoutLocalJdk); WAEclipseHelper.openRolePropertyDialog(roleWithoutLocalJdk, com.persistent.contextmenu.Messages.srvConfPgId, "JDK"); } } } catch (Exception e) { errorMessage = String.format("%s %s%s%s", Messages.runEmltrErrMsg, selProject.getName(), " in ", Messages.waEmulator); Activator.getDefault().log(errorMessage, e); Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog.openError(null, errorTitle, errorMessage); } }); } return null; }
From source file:com.persistent.util.JdkSrvConfig.java
License:Open Source License
/** * Customize Link listener. This will close the wizard * or property page and open the/*from w w w. jav a2s . co m*/ * componentssets.xml in default editor. */ public static void custLinkListener(String ttl, String msg, boolean isWizard, Shell shell, Object pageObj, File file) { boolean choice = MessageDialog.openConfirm(shell, ttl, msg); if (choice) { try { if (isWizard) { WAProjectWizard wiz = (WAProjectWizard) pageObj; wiz.getShell().close(); } else { shell.close(); } if (file.exists() && file.isFile()) { IFileStore store = EFS.getLocalFileSystem().getStore(file.toURI()); IWorkbenchPage benchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IDE.openEditorOnFileStore(benchPage, store); } } catch (PartInitException e) { Activator.getDefault().log(e.getMessage(), e); } } }
From source file:com.persistent.winazureroles.WARCertificates.java
License:Open Source License
@SuppressWarnings("unchecked") protected void removeBtnListener() { int selIndex = tblViewer.getTable().getSelectionIndex(); if (selIndex > -1) { try {/*from w w w . j a v a 2 s . co m*/ Entry<String, WindowsAzureCertificate> certEntry = (Entry<String, WindowsAzureCertificate>) tblViewer .getTable().getItem(selIndex).getData(); WindowsAzureCertificate delCert = certEntry.getValue(); if (delCert.isRemoteAccess() && delCert.isSSLCert()) { String temp = String.format("%s%s%s", Messages.sslTtl, " and ", com.persistent.util.Messages.cmhLblRmtAces); PluginUtil.displayErrorDialog(getShell(), Messages.certRmTtl, String.format(Messages.certComMsg, temp, temp)); } else if (delCert.isRemoteAccess()) { PluginUtil.displayErrorDialog(getShell(), Messages.certRmTtl, String.format(Messages.certComMsg, com.persistent.util.Messages.cmhLblRmtAces, com.persistent.util.Messages.cmhLblRmtAces)); } else if (delCert.isSSLCert()) { PluginUtil.displayErrorDialog(getShell(), Messages.certRmTtl, String.format(Messages.certComMsg, Messages.sslTtl, Messages.sslTtl)); } else { boolean choice = MessageDialog.openConfirm(getShell(), Messages.certRmTtl, String.format(Messages.certRmMsg, delCert.getName())); if (choice) { delCert.delete(); tblViewer.refresh(); if (tblCertificates.getItemCount() == 0) { // table is empty i.e. number of rows = 0 btnRemove.setEnabled(false); } certSelected = ""; } } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.certErrTtl, Messages.certErrMsg, e); } } }
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 v a 2s.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); } } }
From source file:com.persistent.winazureroles.WARGeneral.java
License:Open Source License
/** * Method checks if number of instances are equal to 1 * and caching is enabled as well as high availability * feature is on then ask input from user, * whether to turn off high availability feature * or he wants to edit instances.//from w ww. j a v a2 s .co m * @param val * @return boolean */ private boolean handleHighAvailabilityFeature(boolean val) { boolean isBackupSet = false; boolean okToProceed = val; try { /* * checks if number of instances are equal to 1 * and caching is enabled */ if (txtNoOfInstances.getText().trim().equalsIgnoreCase("1") && windowsAzureRole.getCacheMemoryPercent() > 0) { /* * Check high availability feature of any of the cache is on */ Map<String, WindowsAzureNamedCache> mapCache = windowsAzureRole.getNamedCaches(); for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator .hasNext();) { WindowsAzureNamedCache cache = (WindowsAzureNamedCache) iterator.next(); if (cache.getBackups()) { isBackupSet = true; } } /* * High availability feature of any of the cache is on. */ if (isBackupSet) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.highAvailTtl, Messages.highAvailMsg); /* * Set High availability feature to No. */ if (choice) { for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator .hasNext();) { WindowsAzureNamedCache cache = (WindowsAzureNamedCache) iterator.next(); if (cache.getBackups()) { cache.setBackups(false); } } okToProceed = true; waProjManager.save(); } else { /* * Stay on Role properties page. */ okToProceed = false; txtNoOfInstances.setFocus(); } } } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cachErrTtl, Messages.cachGetErMsg, e); okToProceed = false; } return okToProceed; }
From source file:com.persistent.winazureroles.WARLoadBalance.java
License:Open Source License
/** * Enable session affinity./*ww w . jav a 2 s.c o m*/ */ protected void enableSessionAff() { try { WindowsAzureEndpoint endpt = null; populateEndPointList(); endpt = WARLoadBalanceUtilMethods.findInputEndpt(waRole, endpointsList); if (endpt == null) { boolean choice = MessageDialog.openConfirm(getShell(), Messages.lbCreateEndptTtl, Messages.lbCreateEndptMsg); if (choice) { WindowsAzureEndpoint newEndpt = createEndpt(); populateEndPointList(); comboEndpt.setText(String.format(Messages.dbgEndPtStr, newEndpt.getName(), newEndpt.getPort(), newEndpt.getPrivatePort())); waRole.setSessionAffinityInputEndpoint(newEndpt); isEditableEndpointCombo(newEndpt); } else { btnSsnAffinity.setSelection(false); lblEndptToUse.setEnabled(false); comboEndpt.setEnabled(false); } } else { comboEndpt.setText(String.format(Messages.dbgEndPtStr, endpt.getName(), endpt.getPort(), endpt.getPrivatePort())); waRole.setSessionAffinityInputEndpoint(endpt); isEditableEndpointCombo(endpt); } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(this.getShell(), Messages.adRolErrTitle, Messages.adRolErrMsgBox1 + Messages.adRolErrMsgBox2, e); } }
From source file:com.platzerworld.e4.biergarten.handlers.QuitHandler.java
License:Open Source License
@Execute public void execute(IWorkbench workbench, IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) throws InvocationTargetException, InterruptedException { if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) { workbench.close();//w ww.j a va2 s. c o m } }