List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:com.htmlhifive.tools.wizard.download.DownloadModule.java
License:Apache License
/** * 1???.// w w w . ja v a 2 s . c o m * * @param monitor * @param totalWork * @param file * @param uri URI * @throws CoreException */ private ZipFile download(final IProgressMonitor monitor, final int totalWork, ResultStatus logger, IFile file, final String urlStr) throws CoreException { // PI0111=INFO,[{0}]... monitor.subTask(Messages.PI0111.format(urlStr)); lastDownloadStatus = false; int ret = 0; while (ret == 0) { try { if (file != null) { // ??. IConnectMethod method = ConnectMethodFactory.getMethod(urlStr, true); method.setConnectionTimeout(PluginConstant.URL_LIBRARY_CONNECTION_TIMEOUT); method.setProxy(getProxyService()); method.getInputStream(); boolean updateResult = updateFile(monitor, 0, logger, file, method); if (updateResult) { lastDownloadStatus = true; } monitor.worked(totalWork); } else { // file?null?????ZipFile???. BufferedInputStream bufferIs = null; OutputStream os = null; try { IConnectMethod method = ConnectMethodFactory.getMethod(urlStr, true); method.setConnectionTimeout(PluginConstant.URL_LIBRARY_CONNECTION_TIMEOUT); method.setProxy(getProxyService()); if (!method.connect()) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(Messages.SE0101, urlStr, file != null ? file.toString() : ""); return null; } final int contentLength = method.getContentLength(); // final int perWork; // if (contentLength > 0) { // perWork = Math.max(1, totalWork * DEFAULT_BUFFER_SIZE / 8 / contentLength); // }else{ // perWork = totalWork; // } InputStream is = method.getInputStream(); // if (H5IOUtils.isClassResources(urlStr)) { // // url?null??????. // is = DownloadModule.class.getResourceAsStream(urlStr); // } else { // // ?URL // HttpMethod method = DownloadModule.this.connect(urlStr, // PluginResource.URL_LIBRARY_CONNECTION_TIMEOUT); // if (method == null) { // return null; // } // // // ??????. // Header header = method.getResponseHeader("Content-Length"); // if (header != null) { // contentLength = Integer.valueOf(header.getValue()); // } // if (contentLength > 0) { // perWork = Math.max(1, perWork * DEFAULT_BUFFER_SIZE / contentLength); // } // is = method.getResponseBodyAsStream(); // } if (is == null) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(Messages.SE0101, urlStr, file != null ? file.toString() : ""); return null; } bufferIs = new BufferedInputStream(is) { private int current = 0; private final int perWork = Math.max(1, totalWork * buf.length / 8 / contentLength); @Override public synchronized int read() throws IOException { int result = super.read(); current += result * 16; monitor.subTask(Messages.PI0143.format(current, contentLength, urlStr)); //monitor.worked(result * 16); monitor.worked(perWork); return result; } }; // SE0093=INFO,{0}??? logger.log(Messages.SE0093, urlStr); // ZIP. File tempFile = File.createTempFile(H5WizardPlugin.getId(), "tmp"); // VM????. tempFile.deleteOnExit(); // ??. os = FileUtils.openOutputStream(tempFile); IOUtils.copy(bufferIs, os); // byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; // int n = 0; // while (-1 != (n = is.read(buffer))) { // os.write(buffer, 0, n); // if (contentLength > 0) { // monitor.worked(perWork); // } // } if (contentLength == 0) { monitor.worked(totalWork); } // SE0094=INFO,{0}???? logger.log(Messages.SE0094, urlStr); lastDownloadStatus = true; return new ZipFile(tempFile); } finally { IOUtils.closeQuietly(bufferIs); IOUtils.closeQuietly(os); } } ret = 1; } catch (IOException e) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(e, Messages.SE0101, urlStr, file != null ? file.toString() : ""); // ?????. MessageDialog dialog = new MessageDialog(null, Messages.SE0115.format(), Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING), Messages.SE0116.format(urlStr), MessageDialog.QUESTION, new String[] { UIMessages.Dialog_RETRY, UIMessages.Dialog_IGNORE, UIMessages.Dialog_STOP }, 0); ret = dialog.open(); if (ret == 2) { // throw new OperationCanceledException( Messages.SE0101.format(urlStr, file != null ? file.toString() : "")); } } } return null; }
From source file:com.hydra.project.myplugin_nebula.xviewer.customize.ColumnFilterDataUI.java
License:Open Source License
public void promptSetFilter(XViewerColumn column) { String columnName = column.getId().replaceFirst(".*\\.", ""); ColumnFilterDialog ed = new ColumnFilterDialog(Display.getCurrent().getActiveShell(), XViewerText.get("ColumnFilterDataUI.title"), //$NON-NLS-1$ XViewerText.get("ColumnFilterDataUI.prompt", columnName), MessageDialog.QUESTION, //$NON-NLS-1$ new String[] { XViewerText.get("button.ok"), //$NON-NLS-1$ XViewerText.get("button.clear"), //$NON-NLS-1$ XViewerText.get("button.clear_all"), //$NON-NLS-1$ XViewerText.get("button.cancel") }, //$NON-NLS-1$ 0, column);//w w w .ja v a 2s . co m String str = xViewer.getCustomizeMgr().getColumnFilterData().getFilterText(column.getId()); if (str != null && !str.equals("")) { //$NON-NLS-1$ ed.setEntry(str); } int result = ed.open(); if (result == 0) { xViewer.getCustomizeMgr().setColumnFilterText(column.getId(), ed.getEntry()); xViewer.getCustomizeMgr().setColumnDateFilter(column.getId(), ed.getDateRangeType(), ed.getDate1(), ed.getDate2()); } else if (result == 1) { xViewer.getCustomizeMgr().setColumnFilterText(column.getId(), null); xViewer.getCustomizeMgr().setColumnDateFilter(column.getId(), DateRangeType.None, null, null); } else if (result == 2) { xViewer.getCustomizeMgr().clearAllColumnFilters(); } }
From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java
License:Open Source License
private void handleRenameButton() { XViewerColumn xCol = getVisibleTableSelection().iterator().next(); DialogWithEntry ed = new DialogWithEntry(Display.getCurrent().getActiveShell(), XViewerText.get("button.rename"), null, XViewerText.get("XViewerCustomizeDialog.rename.new"), //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.QUESTION, new String[] { XViewerText.get("button.ok"), //$NON-NLS-1$ XViewerText.get("XViewerCustomizeDialog.rename.default"), //$NON-NLS-1$ XViewerText.get("button.cancel") }, //$NON-NLS-1$ 0);/*w w w . j av a2s .c o m*/ int result = ed.open(); if (result == 2) { return; } if (result == 0) { xViewerToCustomize.getCustomizeMgr().customizeColumnName(xCol, ed.getEntry()); } else if (result == 1) { xViewerToCustomize.getCustomizeMgr().customizeColumnName(xCol, ""); //$NON-NLS-1$ } visibleColTable.getViewer().update(xCol, null); }
From source file:com.hydra.project.myplugin_nebula.xviewer.util.internal.dialog.ColumnFilterDialog.java
License:Open Source License
public ColumnFilterDialog(Shell shell, String dialogTitle, String dialogMessage, int question, String[] strings, int i, XViewerColumn column) { super(shell, dialogTitle, null, dialogMessage, MessageDialog.QUESTION, strings, 0); this.shell = shell; this.column = column; }
From source file:com.hydra.project.myplugin_nebula.xviewer.util.internal.dialog.DialogWithEntry.java
License:Open Source License
public DialogWithEntry(String dialogTitle, String dialogMessage) { super(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { XViewerText.get("button.ok"), XViewerText.get("button.cancel") }, 0); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:com.hydra.project.myplugin_nebula.xviewer.XPromptChange.java
License:Open Source License
public static Boolean promptChangeBoolean(String displayName, String toggleMessage, boolean currSelection) { MessageDialogWithToggle md = new MessageDialogWithToggle(Display.getCurrent().getActiveShell(), displayName, null, displayName, MessageDialog.QUESTION, new String[] { XViewerText.get("button.ok"), XViewerText.get("button.cancel") }, Window.OK, //$NON-NLS-1$ //$NON-NLS-2$ (toggleMessage != null ? toggleMessage : displayName), currSelection); int result = md.open(); if (result == Window.OK) { return md.getToggleState(); }//w w w . j ava 2 s .co m return null; }
From source file:com.ibm.xsp.extlib.designer.bluemix.action.DeployAction.java
License:Open Source License
public static void deployWithQuestion() { if (ToolbarAction.project != null) { ManifestMultiPageEditor editor = BluemixUtil.getManifestEditor(ToolbarAction.project); if (editor != null) { if (editor.isDirty()) { MessageDialog dg = new MessageDialog(null, _DEPLOY_TXT, null, "Do you want to save the Manifest before deployment?", // $NLX-DeployAction.DoyouwanttosavetheManifest-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*w w w . j a va2 s .c om*/ switch (dg.open()) { case 0: //yes editor.doSave(null); break; case 1: //no break; case 2: //cancel return; } } } // Check for a valid configuration BluemixConfig config = ConfigManager.getInstance().getConfig(ToolbarAction.project); if (config.isValid(true)) { // Check the Server configuration if (BluemixUtil.isServerConfigured()) { // All good - Deploy !!! DeployJob job = new DeployJob(config, ToolbarAction.project); job.start(); } else { // Server configuration problem BluemixUtil.displayConfigureServerDialog(); } } else { if (config.isValid(false)) { // Something is wrong with the Manifest if (ManifestUtil.doesManifestExist(config)) { // Corrupt String msg = "The Manifest for this application is invalid. Cannot deploy."; // $NLX-DeployAction.TheManifestforthisapplicationisin-1$ MessageDialog.openError(null, _DEPLOY_TXT, msg); } else { // Missing String msg = "The Manifest for this application is missing. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.TheManifestforthisapplicationismi-1$ if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) { ConfigBluemixWizard.launch(); } } } else { // App has not been configured or the bluemix.properties file is missing or corrupt String msg = "This application is not configured for deployment. Do you want to open the Configuration Wizard?"; // $NLX-DeployAction.Thisapplicationisnotconfiguredfor-1$ if (MessageDialog.openQuestion(null, _DEPLOY_TXT, msg)) { ConfigBluemixWizard.launch(); } } } } else { MessageDialog.openError(null, _DEPLOY_TXT, "No application has been selected or the selected application is not open."); // $NLX-DeployAction.Noapplicationhasbeenselectedorthe-1$ } }
From source file:com.javapathfinder.vjp.config.LaunchDialog.java
License:Open Source License
private void handleDeleteFile() { Object selection = ((TreeSelection) fileTree.getSelection()).getFirstElement(); if (!(selection instanceof IFile)) return;/*from ww w . ja va 2 s . com*/ IFile file = (IFile) selection; int option = new MessageDialog(getShell(), "Delete " + file.getName() + "?", null, "Are you sure you want to delete " + "the configuration file: " + file.getName() + "?", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1).open(); if (option != 0) return; try { file.delete(true, true, null); } catch (CoreException e) { VJP.logError("Could not delete file.", e); } updateTree(); }
From source file:com.maccasoft.ui.internal.application.WorkbenchExceptionHandler.java
License:Open Source License
private boolean openQuestion(Shell parent, String title, String message, Throwable detail, int defaultIndex) { String[] labels;// ww w. j av a 2 s. c om if (detail == null) { labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; } else { labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.SHOW_DETAILS_LABEL }; } dialog = new InternalErrorDialog(parent, title, null, message, detail, MessageDialog.QUESTION, labels, defaultIndex); if (detail != null) { dialog.setDetailButton(2); } boolean result = dialog.open() == Window.OK; dialog = null; return result; }
From source file:com.mentor.nucleus.bp.core.util.UIUtil.java
License:Open Source License
/** * //from w ww.j a v a2 s.c om * @param msg * @return true if the user responds yes and false if the user responds no */ public static boolean displayYesNoQuestion(final String msg) { displayYesNoQuestion_isYes = true; if (CoreUtil.IsRunningHeadless) { displayYesNoQuestion_isYes = UIUtil.openMessageDialog(null, "BridgePoint UML Suite", null, msg, UIUtil.BPMessageTypes.QUESTION, new String[] { "Yes", "No" }, 0); // yes is he default } else { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { org.eclipse.swt.widgets.Shell sh = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, "BridgePoint UML Suite", null, msg, MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); // yes is the default displayYesNoQuestion_isYes = (dialog.open() == 0); } }); } return displayYesNoQuestion_isYes; }