Java Code Examples for org.eclipse.jface.dialogs.IDialogConstants#YES_TO_ALL_LABEL

The following examples show how to use org.eclipse.jface.dialogs.IDialogConstants#YES_TO_ALL_LABEL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportTracePackageWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private int promptForTraceOverwrite(TracePackageTraceElement packageElement) {
    String name = packageElement.getDestinationElementPath();
    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.ImportTracePackageWizardPage_AlreadyExistsTitle,
            null,
            MessageFormat.format(Messages.ImportTracePackageWizardPage_TraceAlreadyExists, name),
            MessageDialog.QUESTION, new String[] {
                    IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.YES_LABEL },
            3) {
        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    return dialog.open();
}
 
Example 2
Source File: PromptingDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Prompt for the given resources using the specific condition. The prompt dialog will
 * have the title specified.
 */
public PromptingDialog(Shell shell, IResource[] resources, IPromptCondition condition, String title) {
	this.condition = condition;
	this.resources = resources;
	this.title = title;
	this.shell = shell;
	this.hasMultipleResources = resources.length > 1;
	if (hasMultipleResources) {
		buttons = new String[] {
			IDialogConstants.YES_LABEL, 
			IDialogConstants.YES_TO_ALL_LABEL, 
			IDialogConstants.NO_LABEL, 
			IDialogConstants.CANCEL_LABEL};
	} else {
		buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
	}			 
}
 
Example 3
Source File: Question.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
public static int askWithAll(String title, String message) {
	String[] labels = new String[] {
			IDialogConstants.YES_LABEL,
			IDialogConstants.YES_TO_ALL_LABEL,
			IDialogConstants.NO_LABEL,
			IDialogConstants.CANCEL_LABEL };
	MessageDialog dialog = new MessageDialog(
			UI.shell(), title, null, message,
			MessageDialog.QUESTION, labels, 0);
	int result = dialog.open();
	if (result == 0)
		return IDialogConstants.YES_ID;
	if (result == 1)
		return IDialogConstants.YES_TO_ALL_ID;
	if (result == 2)
		return IDialogConstants.NO_ID;
	if (result == 3)
		return IDialogConstants.NO_TO_ALL_ID;
	return IDialogConstants.CANCEL_ID;
}
 
Example 4
Source File: ImportTracePackageWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private boolean handleTracesConflict(List<TracePackageTraceElement> traceElements) {
    boolean noToAll = false;
    for (TracePackageTraceElement traceElement : traceElements) {
        if (noToAll) {
            uncheckTraceElement(traceElement);
        } else {
            int returnCode = promptForTraceOverwrite(traceElement);
            // The return code is an index to a button in the dialog but the
            // 'X' button in the window corner is not considered a button
            // therefore it returns -1 and unfortunately, there is no
            // constant for that.
            if (returnCode < 0) {
                return false;
            }

            final String[] response = new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL };
            if (response[returnCode].equals(IDialogConstants.NO_TO_ALL_LABEL)) {
                noToAll = true;
                uncheckTraceElement(traceElement);
            } else if (response[returnCode].equals(IDialogConstants.NO_LABEL)) {
                uncheckTraceElement(traceElement);
            }
        }
    }

    return true;
}
 
Example 5
Source File: WizardFolderImportPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user
 * whether the existing resource at the given path should be overwritten.
 * 
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or
 *         <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString)
{

	Path path = new Path(pathString);

	String messageString;
	// Break the message up if there is a file name and a directory
	// and there are at least 2 segments.
	if (path.getFileExtension() == null || path.segmentCount() < 2)
	{
		messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
	}

	else
	{
		messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
				path.lastSegment(), path.removeLastSegments(1).toOSString());
	}

	final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null,
			messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL }, 0);
	String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
	// run in syncExec because callback is from an operation,
	// which is probably not running in the UI thread.
	getControl().getDisplay().syncExec(new Runnable()
	{
		public void run()
		{
			dialog.open();
		}
	});
	return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}
 
Example 6
Source File: JavadocWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void setAllJavadocLocations(IJavaProject[] projects, URL newURL) {
	Shell shell= getShell();
	String[] buttonlabels= new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL };

	for (int j= 0; j < projects.length; j++) {
		IJavaProject iJavaProject= projects[j];
		String message= Messages.format(JavadocExportMessages.JavadocWizard_updatejavadoclocation_message, new String[] { BasicElementLabels.getJavaElementName(iJavaProject.getElementName()), BasicElementLabels.getPathLabel(fDestination, true) });
		MessageDialog dialog= new MessageDialog(shell, JavadocExportMessages.JavadocWizard_updatejavadocdialog_label, null, message, MessageDialog.QUESTION, buttonlabels, 1);

		switch (dialog.open()) {
			case YES :
				JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
				break;
			case YES_TO_ALL :
				for (int i= j; i < projects.length; i++) {
					iJavaProject= projects[i];
					JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
					j++;
				}
				break;
			case NO_TO_ALL :
				j= projects.length;
				break;
			case NO :
			default :
				break;
		}
	}
}
 
Example 7
Source File: OverwriteQuery.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public String queryOverwrite(final String pathString) {

    if (ALL.equals(result)) {
      return ALL;
    }
    
    final String[] options = {
            IDialogConstants.YES_LABEL,
            IDialogConstants.YES_TO_ALL_LABEL,
            IDialogConstants.NO_LABEL,
            IDialogConstants.CANCEL_LABEL 
            };
    
    // Must executed synchronously, otherwise the result is not available
    // when the return statement is executed
    Display.getDefault().syncExec(new Runnable() {
      public void run() {
        MessageDialog dialog = new MessageDialog(shell, "CAS target file already exists" , null,
                "The CAS target file already exists: \n" + pathString + 
                "\n\nPlease choose an action.", MessageDialog.QUESTION, options, 0);
        dialog.open();
        
        String codes[] = { YES, ALL, NO, CANCEL };
        result = codes[dialog.getReturnCode()];
      }
    });

    return result;
  }
 
Example 8
Source File: SVNOperation.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method prompts the user to overwrite an existing resource. It uses the
 * <code>involvesMultipleResources</code> to determine what buttons to show.
 * @param project
 * @return
 */
protected boolean promptToOverwrite(final String title, final String msg) {
	if (!confirmOverwrite) {
		return true;
	}
	final String buttons[];
	if (involvesMultipleResources()) {
		buttons = new String[] {
			IDialogConstants.YES_LABEL, 
			IDialogConstants.YES_TO_ALL_LABEL, 
			IDialogConstants.NO_LABEL, 
			IDialogConstants.CANCEL_LABEL};
	} else {
		buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
	}	
	final Shell displayShell = getShell();
	if (displayShell == null) {
		// We couldn't get a shell (perhaps due to shutdown)
		return false;
	}

	// run in syncExec because callback is from an operation,
	// which is probably not running in the UI thread.
	final int[] code = new int[] {0};
	displayShell.getDisplay().syncExec(
		new Runnable() {
			public void run() {
				MessageDialog dialog = 
					new MessageDialog(displayShell, title, null, msg, MessageDialog.QUESTION, buttons, 0);
				dialog.open();
				code[0] = dialog.getReturnCode();
			}
		});
	if (involvesMultipleResources()) {
		switch (code[0]) {
			case 0://Yes
				return true;
			case 1://Yes to all
				confirmOverwrite = false; 
				return true;
			case 2://No
				return false;
			case 3://Cancel
			default:
				throw new OperationCanceledException();
		}
	} else {
		return code[0] == 0;
	}
}
 
Example 9
Source File: ReorgQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private Runnable createQueryRunnable(final String question, final int[] result) {
	return new Runnable() {
		public void run() {
			int[] resultId= getResultIDs();

			MessageDialog dialog= new MessageDialog(
				fShell,
				fDialogTitle,
				null,
				question,
				MessageDialog.QUESTION,
				getButtonLabels(),
				0);
			dialog.open();

			if (dialog.getReturnCode() == -1) { //MessageDialog closed without choice => cancel | no
				//see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
				result[0]= fAllowCancel ? IDialogConstants.CANCEL_ID : IDialogConstants.NO_ID;
			} else {
				result[0]= resultId[dialog.getReturnCode()];
			}
		}

		private String[] getButtonLabels() {
			if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
				return new String[] {
					IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.NO_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL };
			else
				return new String[] {
					IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.NO_TO_ALL_LABEL};
		}

		private int[] getResultIDs() {
			if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
				return new int[] {
					IDialogConstants.YES_ID,
					IDialogConstants.YES_TO_ALL_ID,
					IDialogConstants.NO_ID,
					IDialogConstants.NO_TO_ALL_ID,
					IDialogConstants.CANCEL_ID};
			else
				return new int[] {
					IDialogConstants.YES_ID,
					IDialogConstants.YES_TO_ALL_ID,
					IDialogConstants.NO_ID,
					IDialogConstants.NO_TO_ALL_ID};
		}
	};
}
 
Example 10
Source File: ImportProjectWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * 
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 * 	<code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {

	Path path = new Path(pathString);

	String messageString;
	// Break the message up if there is a file name and a directory
	// and there are at least 2 segments.
	if (path.getFileExtension() == null || path.segmentCount() < 2) {
		messageString = NLS.bind(
				IDEWorkbenchMessages.WizardDataTransfer_existsQuestion,
				pathString);
	} else {
		messageString = NLS
				.bind(
						IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
						path.lastSegment(), path.removeLastSegments(1)
								.toOSString());
	}

	final MessageDialog dialog = new MessageDialog(getContainer()
			.getShell(), IDEWorkbenchMessages.Question, null,
			messageString, MessageDialog.QUESTION, new String[] {
					IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.NO_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL }, 0) {
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
	// run in syncExec because callback is from an operation,
	// which is probably not running in the UI thread.
	getControl().getDisplay().syncExec(new Runnable() {
		public void run() {
			dialog.open();
		}
	});
	return dialog.getReturnCode() < 0 ? CANCEL : response[dialog
			.getReturnCode()];
}
 
Example 11
Source File: ImportProjectWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * 
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 * 	<code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {

	Path path = new Path(pathString);

	String messageString;
	// Break the message up if there is a file name and a directory
	// and there are at least 2 segments.
	if (path.getFileExtension() == null || path.segmentCount() < 2) {
		messageString = NLS.bind(
				IDEWorkbenchMessages.WizardDataTransfer_existsQuestion,
				pathString);
	} else {
		messageString = NLS
				.bind(
						IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
						path.lastSegment(), path.removeLastSegments(1)
								.toOSString());
	}

	final MessageDialog dialog = new MessageDialog(getContainer()
			.getShell(), IDEWorkbenchMessages.Question, null,
			messageString, MessageDialog.QUESTION, new String[] {
					IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.NO_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL }, 0) {
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
	// run in syncExec because callback is from an operation,
	// which is probably not running in the UI thread.
	getControl().getDisplay().syncExec(new Runnable() {
		public void run() {
			dialog.open();
		}
	});
	return dialog.getReturnCode() < 0 ? CANCEL : response[dialog
			.getReturnCode()];
}