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:org.eclipse.dltk.mod.ui.wizards.BuildpathsBlock.java
License:Open Source License
public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) { return new IRemoveOldBinariesQuery() { public boolean doQuery(final IPath oldOutputLocation) throws OperationCanceledException { final int[] res = new int[] { 1 }; Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh = shell != null ? shell : DLTKUIPlugin.getActiveWorkbenchShell(); String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, oldOutputLocation.toString()); MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/* w w w. j av a2 s .com*/ res[0] = dialog.open(); } }); if (res[0] == 0) { return true; } else if (res[0] == 1) { return false; } throw new OperationCanceledException(); } }; }
From source file:org.eclipse.e4.demio.views.nav.NavigatorDropAdapter.java
License:Open Source License
public String queryOverwrite(String pathString) { if (alwaysOverwrite) { return ALL; }//from w w w . j av a 2s. c om final String returnCode[] = { CANCEL }; final String msg = NLS.bind(ResourceNavigatorMessages.DropAdapter_overwriteQuery, pathString); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; getDisplay().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(getShell(), ResourceNavigatorMessages.DropAdapter_question, null, msg, MessageDialog.QUESTION, options, 0); dialog.open(); int returnVal = dialog.getReturnCode(); String[] returnCodes = { YES, ALL, NO, CANCEL }; returnCode[0] = returnVal < 0 ? CANCEL : returnCodes[returnVal]; } }); if (returnCode[0] == ALL) { alwaysOverwrite = true; } return returnCode[0]; }
From source file:org.eclipse.e4.xwt.tools.ui.designer.wizards.ExternalizeStringsWizard.java
License:Open Source License
/** * Show a dialog to ask user whether to open the created files. * //from w w w . j a v a2s .c om * @throws returnWizardPage */ private void showOpenFileDialog() throws returnWizardPage { String dialogMessage = "Do you want to open " + externalizeStringsWizardPage.getInfo().getClassName() + ".java and " + externalizeStringsWizardPage.getInfo().getPropertyName() + ".properties after finish?"; String[] dialogButtonLabels = { "Open", "Cancel" }; MessageDialog messageDialog = new MessageDialog(getShell(), "Open created files", null, dialogMessage, MessageDialog.QUESTION, dialogButtonLabels, 1); messageDialog.open(); if (messageDialog.getReturnCode() == 0) { openFlag = true; } else if (messageDialog.getReturnCode() == -1) { throw new returnWizardPage(); } else { openFlag = false; } }
From source file:org.eclipse.ecf.internal.provider.skype.ui.hyperlink.SkypeHyperlink.java
License:Open Source License
/** * @param adapters/*ww w . j av a 2s . co m*/ */ private void chooseAccountAndOpen(final IContainer[] containers) { // If there's only one choice then use it if (containers.length == 1) { // ask to the user if the talk is by IM or Call final MessageDialog dialog = new MessageDialog(null, Messages.SkypeHyperlink_DIALOG_CALLIM_TITLE, null, NLS.bind(Messages.SkypeHyperlink_DIALOG_CALLIM_MESSAGE, getURI().getAuthority()), MessageDialog.QUESTION, new String[] { Messages.SkypeHyperlink_BUTTON_CALL, Messages.SkypeHyperlink_BUTTON_IM, Messages.SkypeHyperlink_BUTTON_CANCEL }, 2); final int answer = dialog.open(); switch (answer) { case 0: final IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) containers[0] .getAdapter(IPresenceContainerAdapter.class); final ID localID = presenceContainerAdapter.getRosterManager().getRoster().getUser().getID(); final ID targetUser = new SkypeUserID(localID.getNamespace(), getURI().getAuthority()); call(containers[0], targetUser); break; case 1: openMessagesView( (IPresenceContainerAdapter) containers[0].getAdapter(IPresenceContainerAdapter.class)); break; } return; } else { final IPresenceContainerAdapter[] adapters = new IPresenceContainerAdapter[containers.length]; for (int i = 0; i < containers.length; i++) adapters[i] = (IPresenceContainerAdapter) containers[i].getAdapter(IPresenceContainerAdapter.class); final ListDialog dialog = new ListDialog(null); dialog.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return adapters; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); dialog.setInput(adapters); dialog.setAddCancelButton(true); dialog.setBlockOnOpen(true); dialog.setTitle(Messages.SkypeHyperlink_DIALOG_SELECT_ACCOUNT_TITLE); dialog.setMessage(Messages.SkypeHyperlink_DIALOG_SELECT_ACCOUNT_MESSAGE); dialog.setHeightInChars(adapters.length > 4 ? adapters.length : 4); dialog.setInitialSelections(new IPresenceContainerAdapter[] { adapters[0] }); dialog.setLabelProvider(new ILabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { final IRosterManager manager = ((IPresenceContainerAdapter) element).getRosterManager(); if (manager == null) return null; return manager.getRoster().getUser().getID().getName(); } public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } }); final int result = dialog.open(); if (result == ListDialog.OK) { final Object[] res = dialog.getResult(); if (res.length > 0) openMessagesView((IPresenceContainerAdapter) res[0]); } } }
From source file:org.eclipse.ecf.internal.provider.xmpp.ui.hyperlink.XMPPHyperlink.java
License:Open Source License
/** * @param presenceContainerAdapter// w w w . j a v a 2s . c o m */ private void openContainer(IContainer container) { final IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) container .getAdapter(IPresenceContainerAdapter.class); final IChatManager chatManager = presenceContainerAdapter.getChatManager(); final IRosterManager rosterManager = presenceContainerAdapter.getRosterManager(); if (chatManager != null && rosterManager != null) { try { // get local ID final XMPPID localID = (XMPPID) rosterManager.getRoster().getUser().getID(); final Namespace ns = container.getConnectNamespace(); // create target ID final XMPPID targetID = (isXMPPS) ? new XMPPSID(ns, getURI().getAuthority()) : new XMPPID(ns, getURI().getAuthority()); // If they are same, just tell user and return if (localID.equals(targetID)) { MessageDialog.openError(null, Messages.XMPPHyperlink_MESSAGING_ERROR_TITLE, Messages.XMPPHyperlink_MESSAGING_ERROR_MESSAGE); return; } else { final String localHost = localID.getHostname(); final String targetHost = targetID.getHostname(); // If the hosts are the same for the target and local // accounts, // it's pretty obvious that we wish to message to them if (localHost.equals(targetHost)) { openMessagesView(chatManager, localID, targetID); } else { // Otherwise, ask the user whether messaging, or // connecting is desired final MessageDialog messageDialog = new MessageDialog(null, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_TITLE, null, NLS.bind(Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_MESSAGE, new Object[] { targetHost, localHost, targetID.getName(), localID.getName() }), MessageDialog.QUESTION, new String[] { Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_SEND_MESSAGE, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CONNECT, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CANCEL }, 2); final int selected = messageDialog.open(); switch (selected) { case 0: openMessagesView(chatManager, localID, targetID); return; case 1: super.open(); return; default: return; } } } } catch (final Exception e) { MessageDialog.openError(null, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_TITLE, NLS.bind( Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_MESSAGE, e.getLocalizedMessage())); Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_LOG_STATUS_MESSAGE, e)); } } }
From source file:org.eclipse.ecf.presence.collab.ui.screencapture.ScreenCaptureShareRosterEntryContributionItem.java
License:Open Source License
protected IAction[] makeActions() { // Else check for Roster entry final IRosterEntry entry = getSelectedRosterEntry(); final IContainer c = getContainerForRosterEntry(entry); // If roster entry is selected and it has a container if (entry != null && c != null) { final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c .getAdapter(IChannelContainerAdapter.class); // If the container has channel container adapter and is online/available if (channelAdapter != null && isAvailable(entry)) { final ScreenCaptureShare tmp = ScreenCaptureShare.getScreenCaptureShare(c.getID()); // If there is an URL share associated with this container if (tmp != null) { final ScreenCaptureShare screencaptureshare = tmp; final IAction action = new Action() { public void run() { MessageDialog dialog = new MessageDialog(null, Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_TITLE, Window.getDefaultImage(), Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_MESSAGE, MessageDialog.QUESTION, new String[] { NLS.bind( Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_SEND_BUTTON_TEXT, entry.getName()), Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_CANCEL_BUTTON_TEXT }, 0);//from ww w . ja v a2 s . c om if (dialog.open() == Window.OK) { ScreenCaptureJob screenCaptureJob = new ScreenCaptureJob(Display.getCurrent(), entry.getUser().getID(), entry.getUser().getName(), new IImageSender() { public void sendImage(ID targetID, ImageData imageData) { screencaptureshare.sendImage(entry.getRoster().getUser().getID(), entry.getRoster().getUser().getName(), targetID, imageData); } }); screenCaptureJob.schedule(SCREEN_CAPTURE_DELAY); } } }; action.setText(Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MENU); action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEF_VIEW)); return new IAction[] { action }; } } } return null; }
From source file:org.eclipse.edt.ide.ui.internal.property.pages.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList removedVariables = new ArrayList(); ArrayList changedVariables = new ArrayList(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = (CPVariableElement) changedElements.get(i); if (curr.isReadOnly()) { changedElements.remove(curr); } else {/*from w w w . ja va 2 s . c o m*/ IPath path = curr.getPath(); IPath prevPath = JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = NewWizardMessages.VariableBlock_needsbuild_title; String message = NewWizardMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(), NewWizardMessages.VariableBlock_variableSettingError_titel, NewWizardMessages.VariableBlock_variableSettingError_message); return false; } catch (InterruptedException e) { return false; } if (needsBuild) { CoreUtility.getBuildJob(null).schedule(); } } return true; }
From source file:org.eclipse.edt.ide.ui.preferences.CompilerPropertyAndPreferencePage.java
License:Open Source License
protected void promptForNewCompiler(String errorCompilerId) { String message = MessageFormat.format(UINlsStrings.CompilerPreferencePage_compilerNoLongerAvailable, new Object[] { errorCompilerId }); MessageDialog dialog = new MessageDialog(getShell(), UINlsStrings.CompilerPreferencePage_compilerNoLongerAvailable_title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 2) { protected int getMinimumMessageWidth() { return convertHorizontalDLUsToPixels((int) (IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH * 1.5)); }/*from ww w. j a va 2 s . c om*/ protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false); gridData.widthHint = this.getMinimumMessageWidth(); composite.setLayoutData(gridData); return composite; } }; int res = dialog.open(); if (res == IDialogConstants.CANCEL_ID) { // cancel pressed latestStatus.setWarning(MessageFormat.format(UINlsStrings.CompilerPreferencePage_cannotDisplayCompiler, new Object[] { errorCompilerId })); statusChangeListener.statusChanged(latestStatus); } }
From source file:org.eclipse.egit.gitflow.ui.internal.dialogs.AbstractGitFlowBranchSelectionDialog.java
License:Open Source License
/** * @param parentShell//from ww w . j a v a2 s. com * @param nodes * @param title * @param message */ public AbstractGitFlowBranchSelectionDialog(Shell parentShell, List<T> nodes, String title, String message) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { OK_LABEL, CANCEL_LABEL }, 0); this.nodes = nodes; }
From source file:org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog.java
License:Open Source License
/** * @param parentShell/*from w ww . ja v a 2s .co m*/ * @param refs * @param title * @param message * @param featurePrefix * @param gfRepo */ public FeatureBranchSelectionDialog(Shell parentShell, List<Ref> refs, String title, String message, String featurePrefix, GitFlowRepository gfRepo) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { OK_LABEL, CANCEL_LABEL }, 0); this.gfRepo = gfRepo; filteredFeatures = new FilteredBranchesWidget(refs, featurePrefix, gfRepo); }