List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION_WITH_CANCEL
int QUESTION_WITH_CANCEL
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION_WITH_CANCEL.
Click Source Link
From source file:org.apache.sling.ide.eclipse.ui.internal.ServersActionModeFiddlerActionDelegate.java
License:Apache License
private void initToolbarContributedActions() { cleanAction = new Action("Clean Publish...", IAction.AS_PUSH_BUTTON) { public void run() { if (server == null) { MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected"); return; }//from w ww . j a v a 2 s.com int selection = 2; if (!doNotAskAgain) { MessageDialog dialog = new MessageDialog(view.getSite().getShell(), Messages.defaultDialogTitle, null, Messages.dialogPublishClean, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Cancel", "OK (do not ask again)", "OK" }, 1) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); setShellStyle(getShellStyle() | SWT.SHEET); } }; selection = dialog.open(); } if (selection != 0) { if (selection == 1) { doNotAskAgain = true; } IAdaptable info = new IAdaptable() { public Object getAdapter(Class adapter) { if (Shell.class.equals(adapter)) return view.getSite().getShell(); if (String.class.equals(adapter)) return "user"; return null; } }; server.publish(IServer.PUBLISH_CLEAN, modules, info, null); } } }; cleanAction.setText("Clean Publish..."); cleanAction.setToolTipText("Clean and Publish..."); ImageDescriptor cleanAndPublishImageDesc = new DecorationOverlayIcon( ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH).createImage(), ImageDescriptor.createFromFile(SharedImages.class, "refresh.gif"), IDecoration.BOTTOM_RIGHT); cleanAction.setImageDescriptor(cleanAndPublishImageDesc); cleanAction.setId("org.apache.sling.ide.eclipse.ui.actions.CleanPublishAction"); publishAction = new Action("Publish", IAction.AS_PUSH_BUTTON) { public void run() { if (server == null) { MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected"); return; } IAdaptable info = new IAdaptable() { public Object getAdapter(Class adapter) { if (Shell.class.equals(adapter)) return view.getSite().getShell(); if (String.class.equals(adapter)) return "user"; return null; } }; server.publish(IServer.PUBLISH_INCREMENTAL, modules, info, null); } }; publishAction.setText("Publish"); publishAction.setToolTipText("Publish"); publishAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH)); publishAction.setId("org.apache.sling.ide.eclipse.ui.actions.PublishAction"); cleanAction.setEnabled(false); publishAction.setEnabled(false); cleanActionContributionItem = new ActionContributionItem(cleanAction); publishActionContributionItem = new ActionContributionItem(publishAction); appendedToolbarActionContributionItems.add(publishActionContributionItem); appendedToolbarActionContributionItems.add(cleanActionContributionItem); }
From source file:org.eclipse.birt.report.designer.internal.lib.editors.LibraryFileChangeResolve.java
License:Open Source License
public boolean reload(ModuleHandle owner) { if (owner.needsSave()) { MessageDialog md = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("MultiPageReportEditor.ConfirmVersion.Dialog.Title"), //$NON-NLS-1$ null, Messages.getString("MultiPageReportEditor.ConfirmVersion.Dialog.SaveAndReloadMessage"), //$NON-NLS-1$ MessageDialog.QUESTION_WITH_CANCEL, new String[] { Messages.getString("MultiPageReportEditor.SaveButton"), //$NON-NLS-1$ //Messages.getString( "MultiPageReportEditor.DiscardButton" ), //$NON-NLS-1$ Messages.getString("MultiPageReportEditor.CancelButton") //$NON-NLS-1$ }, 0);//from w w w .ja v a 2 s . c om switch (md.open()) { case 0: try { owner.save(); } catch (IOException e) { logger.log(Level.SEVERE, e.getMessage(), e); } UIUtil.reloadModuleHandleLibraries(owner); return true; // case 1 : // UIUtil.reloadModuleHandleLibraries( owner ); // return true; default: return false; } } else if (MessageDialog.openConfirm(UIUtil.getDefaultShell(), Messages.getString("MultiPageReportEditor.ConfirmVersion.Dialog.Title"), //$NON-NLS-1$ Messages.getString("MultiPageReportEditor.ConfirmVersion.Dialog.ReloadMessage"))) //$NON-NLS-1$ { UIUtil.reloadModuleHandleLibraries(owner); return true; } return false; }
From source file:org.eclipse.birt.report.designer.internal.ui.views.actions.RefreshModuleHandleAction.java
License:Open Source License
public void run() { IEditorPart editor = UIUtil.getActiveEditor(true); if (editor != null && editor.isDirty()) { MessageDialog md = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("RefreshModuleHandleAction.MessageBox.Title"), //$NON-NLS-1$ null, Messages.getString("RefreshModuleHandleAction.MessageBox.Text"), //$NON-NLS-1$ MessageDialog.QUESTION_WITH_CANCEL, new String[] { Messages.getString("RefreshModuleHandleAction.MessageBox.SaveButton"), //$NON-NLS-1$ //Messages.getString( "RefreshModuleHandleAction.MessageBox.DiscardButton" ), //$NON-NLS-1$ Messages.getString("RefreshModuleHandleAction.MessageBox.CancelButton") //$NON-NLS-1$ }, 0);//from w w w . ja v a 2 s .co m switch (md.open()) { case 0: try { editor.doSave(null); CommandUtils.executeCommand("org.eclipse.birt.report.designer.ui.command.refreshLibraryCommand", //$NON-NLS-1$ null); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } break; // case 1 : // try // { // CommandUtils.executeCommand( "org.eclipse.birt.report.designer.ui.command.refreshLibraryCommand", null ); //$NON-NLS-1$ // } // catch ( Exception e ) // { // logger.log( Level.SEVERE, e.getMessage( ), e ); // } // break; default: } } else { try { CommandUtils.executeCommand("org.eclipse.birt.report.designer.ui.command.refreshLibraryCommand", //$NON-NLS-1$ null); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } } }
From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java
License:Open Source License
private static String[] getButtonLabels(final int kind) { String[] dialogButtonLabels;// www . j av a 2s . co m switch (kind) { case MessageDialog.ERROR: case MessageDialog.INFORMATION: case MessageDialog.WARNING: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL }; break; } case MessageDialog.CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } case MessageDialog.QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL }; break; } case MessageDialog.QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); } } return dialogButtonLabels; }
From source file:org.eclipse.ice.client.widgets.EntryComposite.java
License:Open Source License
/** * This method creates a Local/Remote file browser button for * an Entry with the Executable AllowedValueType. * //from www.j a v a2 s . co m */ private void createExecutableBrowser() { boolean redraw = buttons.isEmpty(); if (redraw) { // Create a new button, set the text Button browseButton = new Button(this, SWT.PUSH); browseButton.setText("Browse..."); // RemoteFileWidget widg = new RemoteFileWidget(this, SWT.NONE, // SWT.NONE, "TITLE", "/"); // Add an event listener that displays a Directory Dialog prompt browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Create a variable for the Executable Value String entryValue = null; // Create a MessageDialog to get whether the user // wants to use a remote or local executable. MessageDialog dialog = new MessageDialog(getShell(), "Local or Remote Application", null, "Please specify whether your executable is local or remote.", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Local", "Remote" }, 0); // Launch the dialot and get the result int result = dialog.open(); // If the user selected Remote if (result == 1) { // Create a new Remote browser and set its type to File_Browser RemoteResourceBrowser browser = new RemoteResourceBrowser(getShell(), SWT.NONE); browser.setTitle("Select a remote executable."); browser.setType(RemoteResourceBrowser.FILE_BROWSER); // Open and make sure they didn't select Cancel if (browser.open() != Window.OK) { return; } // Get the selected Resource IFileStore fs = browser.getResource(); // Set the value as the remote URI string entryValue = fs.toURI().toString(); } else { // If Local, just open up a file browser FileDialog fileDialog = new FileDialog(getShell()); fileDialog.setText("Select an executable to import into ICE"); String filePath = fileDialog.open(); if (filePath != null) { // Import the files File importedFile = new File(filePath); entryValue = importedFile.toURI().toString(); } } // If we got a valid entryValue, then let's set it. if (entryValue != null && !entryValue.isEmpty()) { // Create a new content provider with the new file // in the allowed values list IEntryContentProvider prov = new BasicEntryContentProvider(); ArrayList<String> valueList = entry.getAllowedValues(); if (!valueList.contains(entryValue)) { valueList.add(entryValue); } prov.setAllowedValueType(AllowedValueType.Executable); // Finish setting the allowed values and default // value prov.setAllowedValues(valueList); // Set the new provider entry.setContentProvider(prov); // If it is executable just add its absolute path setEntryValue(entryValue); } // Notify any listeners of the selection event notifyListeners(SWT.Selection, new Event()); return; } }); // Add the browse button buttons.add(browseButton); } }
From source file:org.eclipse.ice.client.widgets.ExecutableEntryComposite.java
License:Open Source License
/** * This method creates a Local/Remote file browser button for an Entry with * the Executable AllowedValueType./*ww w . j a v a 2 s . c om*/ * */ private void createExecutableBrowser() { boolean redraw = buttons.isEmpty(); if (redraw) { // Create a new button, set the text Button browseButton = new Button(this, SWT.PUSH); browseButton.setText("Browse..."); // RemoteFileWidget widg = new RemoteFileWidget(this, SWT.NONE, // SWT.NONE, "TITLE", "/"); // Add an event listener that displays a Directory Dialog prompt browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Create a variable for the Executable Value String entryValue = null; URI entryURI = null; // Create a MessageDialog to get whether the user // wants to use a remote or local executable. MessageDialog dialog = new MessageDialog(getShell(), "Local or Remote Application", null, "Please specify whether your executable is local or remote.", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Local", "Remote" }, 0); // Launch the dialot and get the result int result = dialog.open(); // If the user selected Remote if (result == 1) { // Create a new Remote browser and set its type to // File_Browser RemoteResourceBrowser browser = new RemoteResourceBrowser(getShell(), SWT.NONE); browser.setTitle("Select a remote executable."); browser.setType(RemoteResourceBrowser.FILE_BROWSER); // Open and make sure they didn't select Cancel if (browser.open() != Window.OK) { return; } // Get the selected Resource IFileStore fs = browser.getResource(); URI uri = fs.toURI(); // Get the hostname String hostName = browser.getConnection().getService(IRemoteConnectionHostService.class) .getHostname(); // Set up the entry value entryURI = URI.create(uri.getScheme() + "://" + hostName + uri.getPath()); entryValue = fs.getName();//uri.getScheme() + "://" + hostName + uri.getPath(); } else { // If Local, just open up a file browser FileDialog fileDialog = new FileDialog(getShell()); fileDialog.setText("Select an executable to import into ICE"); String filePath = fileDialog.open(); if (filePath != null) { // Import the files File importedFile = new File(filePath); entryURI = importedFile.toURI(); entryValue = new File(entryURI).getName(); } } // If we got a valid entryValue, then let's set it. if (entryURI != null) { // entryValue = new File(entryURI).getName(); // Create a new content provider with the new file // in the allowed values list List<String> valueList = entry.getAllowedValues(); if (!valueList.contains(entryValue)) { valueList.add(entryValue); } // Finish setting the allowed values and default // value entry.setAllowedValues(valueList); entry.setDescription("The full path of this application is " + entryURI.toString()); // If it is executable just add its absolute path //setEntryValue(entryValue); ((ExecutableEntry) entry).setValue(entryValue, entryURI.toString()); } // Notify any listeners of the selection event notifyListeners(SWT.Selection, new Event()); return; } }); // Add the browse button buttons.add(browseButton); } }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers.ReportElementHandler.java
License:Open Source License
/** * Method execute./*from ww w . j a v a2 s .c o m*/ * * @param event * ExecutionEvent * @return Object * @see org.eclipse.core.commands.IHandler#execute(ExecutionEvent) */ public Object execute(final ExecutionEvent event) { final List<IR4EUIModelElement> selectedElements = UIUtils.getCommandUIElements(); final Job job = new Job(COMMAND_MESSAGE) { public String familyName = R4EUIConstants.R4E_UI_JOB_FAMILY; @Override public boolean belongsTo(Object family) { return familyName.equals(family); } @Override public IStatus run(IProgressMonitor monitor) { R4EUIModelController.setJobInProgress(true); monitor.beginTask(COMMAND_MESSAGE, IProgressMonitor.UNKNOWN); if (!selectedElements.isEmpty()) { String groupFile = null; //Build list of reviews to generate reports for final ArrayList<File> listSelectedReviews = new ArrayList<File>(); final ArrayList<String> listUnknownReviews = new ArrayList<String>(); for (IR4EUIModelElement element : selectedElements) { if (element instanceof R4EUIReviewBasic) { R4EUIReviewBasic extentElement = (R4EUIReviewBasic) element; if (null == groupFile) { groupFile = ((R4EUIReviewGroup) extentElement.getParent()).getGroupFile(); R4EUIPlugin.Ftracer.traceInfo("Info: " + "Group file: " + groupFile); //$NON-NLS-1$//$NON-NLS-2$ } R4EUIPlugin.Ftracer.traceInfo("Review name element " //$NON-NLS-1$ + extentElement.getReview().getName()); listSelectedReviews.add(new File(extentElement.getReview().getName())); } else if (element instanceof R4EUIReview) { listUnknownReviews.add(((R4EUIReview) element).getReviewName()); } } if (R4EUIPlugin.isUserReportAvailable()) { final int[] result = new int[1]; //We need this to be able to pass the result value outside. This is safe as we are using SyncExec result[0] = GENERATE_REPORT_CONTINUE_INDEX; if (listUnknownReviews.size() > 0) { //If some selected reviews are not compatible, ask user to confirm final StringBuffer buffer = new StringBuffer(); int numReviewErrorsAppened = 0; for (String unresolvedReview : listUnknownReviews) { if (numReviewErrorsAppened < 5) { buffer.append(unresolvedReview + R4EUIConstants.LINE_FEED); } else if (MAX_REVIEW_ERRORS == numReviewErrorsAppened) { buffer.append("..."); } ++numReviewErrorsAppened; } Display.getDefault().syncExec(new Runnable() { public void run() { final MessageDialog dialog = new MessageDialog(null, GENERATE_REPORT_DIALOG_TITLE, null, GENERATE_REPORT_DIALOG_MESSAGE + "Unresolved Reviews: " + R4EUIConstants.LINE_FEED + buffer.toString(), MessageDialog.QUESTION_WITH_CANCEL, GENERATE_REPORT_DIALOG_BUTTONS, 0); result[0] = dialog.open(); } }); } if (result[0] == GENERATE_REPORT_CONTINUE_INDEX) { final org.eclipse.mylyn.reviews.r4e.report.impl.IR4EReport reportGen = org.eclipse.mylyn.reviews.r4e.report.impl.R4EReportFactory .getInstance(); reportGen.setReviewListSelection( listSelectedReviews.toArray(new File[listSelectedReviews.size()])); reportGen.handleReportGeneration(groupFile, monitor); R4EUIPlugin.Ftracer.traceInfo("Report element AVAILABLE");//$NON-NLS-1$ } } else { R4EUIPlugin.Ftracer.traceWarning("Report element Not available" //$NON-NLS-1$ ); } } monitor.done(); R4EUIModelController.setJobInProgress(false); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); return null; }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIPostponedAnomaly.java
License:Open Source License
/** * Method displayCompatibilityWarningDialog. * //from w w w. ja va2 s . c o m * @return boolean */ public int displayCompatibilityWarningDialog(String aDataVersion, String aApplVersionl) { R4EUIPlugin.Ftracer.traceWarning(COMPATIBILITY_WARNING_MESSAGE); final MessageDialog dialog = new MessageDialog(null, COMPATIBILITY_WARNING_DIALOG_TITLE, null, COMPATIBILITY_WARNING_MESSAGE + R4EUIConstants.LINE_FEED + "Element meta-data Version: " + aDataVersion + R4EUIConstants.LINE_FEED + "Application meta-data Version: " + aApplVersionl, MessageDialog.QUESTION_WITH_CANCEL, COMPATIBILITY_WARNING_DIALOG_BUTTONS, 0); return dialog.open(); }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils.java
License:Open Source License
/** * Method displayCompatibilityWarningDialog. * // w ww .j av a 2 s.co m * @param aDataVersion * String * @param aApplVersionl * String * @return int */ public static int displayCompatibilityWarningDialog(final String aDataVersion, final String aApplVersionl) { R4EUIPlugin.Ftracer.traceWarning(COMPATIBILITY_WARNING_MESSAGE); final int[] result = new int[1]; //We need this to be able to pass the result value outside. This is safe as we are using SyncExec Display.getDefault().syncExec(new Runnable() { public void run() { final MessageDialog dialog = new MessageDialog(null, COMPATIBILITY_WARNING_DIALOG_TITLE, null, COMPATIBILITY_WARNING_MESSAGE + R4EUIConstants.LINE_FEED + "Element meta-data Version: " + aDataVersion + R4EUIConstants.LINE_FEED + "Application meta-data Version: " + aApplVersionl, MessageDialog.QUESTION_WITH_CANCEL, COMPATIBILITY_WARNING_DIALOG_BUTTONS, 0); result[0] = dialog.open(); } }); return result[0]; }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils.java
License:Open Source License
/** * Method displayMeetingDataMismatchDialog. * // w w w . j a v a 2 s . c o m * @param aLocalData * IMeetingData * @param aRemoteData * IMeetingData * @return int */ public static int displayMeetingDataMismatchDialog(final IMeetingData aLocalData, final IMeetingData aRemoteData) { R4EUIPlugin.Ftracer.traceWarning(MEETING_DATA_MISMATCH_MESSAGE); final int[] result = new int[1]; //We need this to be able to pass the result value outside. This is safe as we are using SyncExec Display.getDefault().syncExec(new Runnable() { public void run() { final SimpleDateFormat dueDateFormat = new SimpleDateFormat( R4EUIConstants.SIMPLE_DATE_FORMAT_MINUTES); String localStartTime = dueDateFormat.format(new Date(aLocalData.getStartTime())); String remoteStartTime = ""; String remoteLocation = ""; String remoteDuration = ""; if (null != aRemoteData) { remoteStartTime = dueDateFormat.format(new Date(aRemoteData.getStartTime())); remoteLocation = aRemoteData.getLocation(); remoteDuration = aRemoteData.getDuration().toString(); } final MessageDialog dialog = new MessageDialog(null, MEETING_DATA_MISMATCH_DIALOG_TITLE, null, MEETING_DATA_MISMATCH_MESSAGE + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED + "Local Data:" + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Start time = " + localStartTime + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Duration = " + aLocalData.getDuration() + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Location = " + aLocalData.getLocation() + R4EUIConstants.LINE_FEED + "Remote Data:" + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Start time = " + remoteStartTime + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Duration = " + remoteDuration + R4EUIConstants.LINE_FEED + R4EUIConstants.TAB_FEED + "Location = " + remoteLocation, MessageDialog.QUESTION_WITH_CANCEL, MEETING_DATA_MISMATCH_DIALOG_BUTTONS, 0); result[0] = dialog.open(); } }); return result[0]; }