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

The following examples show how to use org.eclipse.jface.dialogs.IDialogConstants#CANCEL_ID . 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: NatureAddingEditorCallback.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void afterCreatePartControl(XtextEditor editor) {
	IResource resource = editor.getResource();
	if (resource != null && !toggleNature.hasNature(resource.getProject()) && resource.getProject().isAccessible()
			&& !resource.getProject().isHidden()) {
		String title = Messages.NatureAddingEditorCallback_MessageDialog_Title;
		String message = Messages.NatureAddingEditorCallback_MessageDialog_Msg0 + resource.getProject().getName()
				+ Messages.NatureAddingEditorCallback_MessageDialog_Msg1;
		boolean addNature = false;
		if (MessageDialogWithToggle.PROMPT.equals(dialogs.getUserDecision(ADD_XTEXT_NATURE))) {
			int userAnswer = dialogs.askUser(message, title, ADD_XTEXT_NATURE, editor.getEditorSite().getShell());
			if (userAnswer == IDialogConstants.YES_ID) {
				addNature = true;
			} else if (userAnswer == IDialogConstants.CANCEL_ID) {
				return;
			}
		} else if (MessageDialogWithToggle.ALWAYS.equals(dialogs.getUserDecision(ADD_XTEXT_NATURE))) {
			addNature = true;
		}
		if (addNature) {
			toggleNature.toggleNature(resource.getProject());
		}
	}
}
 
Example 2
Source File: Question.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
/** Must be called in the UI thread. */
public static int askWithCancel(String title, String message) {
	String[] labels = new String[] { IDialogConstants.YES_LABEL,
			IDialogConstants.NO_LABEL,
			IDialogConstants.CANCEL_LABEL };
	MessageDialog dialog = new MessageDialog(
			UI.shell(), title, null, message,
			MessageDialog.QUESTION_WITH_CANCEL, labels, 0);
	int result = dialog.open();
	if (result == 0)
		return IDialogConstants.YES_ID;
	if (result == 1)
		return IDialogConstants.NO_ID;
	if (result == 2)
		return IDialogConstants.CANCEL_ID;
	return IDialogConstants.CANCEL_ID;
}
 
Example 3
Source File: GotoTypeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Shell shell= JavaPlugin.getActiveWorkbenchShell();
	SelectionDialog dialog= null;
	try {
		dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
			SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
	} catch (JavaModelException e) {
		String title= getDialogTitle();
		String message= PackagesMessages.GotoType_error_message;
		ExceptionHandler.handle(e, title, message);
		return;
	}

	dialog.setTitle(getDialogTitle());
	dialog.setMessage(PackagesMessages.GotoType_dialog_message);
	if (dialog.open() == IDialogConstants.CANCEL_ID) {
		return;
	}

	Object[] types= dialog.getResult();
	if (types != null && types.length > 0) {
		gotoType((IType) types[0]);
	}
}
 
Example 4
Source File: RefactoringStarter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public boolean activate(RefactoringWizard wizard, Shell parent, String dialogTitle, int saveMode) {
	RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(saveMode);
	if (! canActivate(saveHelper, parent))
		return false;

	try {
		RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
		int result= op.run(parent, dialogTitle);
		fStatus= op.getInitialConditionCheckingStatus();
		if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
			saveHelper.triggerIncrementalBuild();
			return false;
		} else {
			return true;
		}
	} catch (InterruptedException e) {
		return false; // User action got cancelled
	}
}
 
Example 5
Source File: ImportBirtRuntimeAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Open confirm dialog
 * 
 * @param file
 * @return
 */
private int openDialog( final String file )
{
	final int[] result = {IDialogConstants.CANCEL_ID};
	shell.getDisplay( ).syncExec( new Runnable( ) {

		public void run( )
		{
			String title = BirtWTPMessages.BIRTOverwriteQuery_title;
			String msg = NLS.bind(
					BirtWTPMessages.BIRTOverwriteQuery_message, file );
			String[] options = {IDialogConstants.YES_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL};
			MessageDialog dialog = new MessageDialog( shell, title,
					null, msg, MessageDialog.QUESTION, options, 0 );
			result[0] = dialog.open( );
		}
	} );
	return result[0];
}
 
Example 6
Source File: MessageDialogWithPrompt.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
    super.buttonPressed(buttonId);

    final boolean toggleState = getToggleState();
    final IPreferenceStore prefStore = getPrefStore();
    final String prefKey = getPrefKey();
    if (buttonId != IDialogConstants.CANCEL_ID
            && prefStore != null && prefKey != null) {
        switch (buttonId) {
            case IDialogConstants.YES_ID:
            case IDialogConstants.YES_TO_ALL_ID:
            case IDialogConstants.PROCEED_ID:
            case IDialogConstants.OK_ID:
                prefStore.setValue(prefKey, toggleState);
                break;
            case IDialogConstants.NO_ID:
            case IDialogConstants.NO_TO_ALL_ID:
                break;
        }
    }
}
 
Example 7
Source File: RefactoringStarter.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * @param refactoring
 * @param wizard
 * @param parent
 * @param dialogTitle
 * @param saveMode
 *            a save mode from {@link RefactoringSaveHelper}
 * @return <code>true</code> if the refactoring was executed,
 *         <code>false</code> otherwise
 * @throws JavaScriptModelException
 */
public boolean activate(Refactoring refactoring, RefactoringWizard wizard, Shell parent, String dialogTitle,
		int saveMode) {
	RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(saveMode);
	if (!canActivate(saveHelper, parent))
		return false;

	try {
		RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
		int result = op.run(parent, dialogTitle);
		fStatus = op.getInitialConditionCheckingStatus();
		if (result == IDialogConstants.CANCEL_ID
				|| result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
			saveHelper.triggerIncrementalBuild();
			return false;
		} else {
			return true;
		}
	} catch (InterruptedException e) {
		return false; // User action got cancelled
	}
}
 
Example 8
Source File: AbstractPropertyDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected final void buttonPressed( int buttonId )
{
	switch ( buttonId )
	{
		case IDialogConstants.OK_ID :
		{
			okPressed( );
			break;
		}
		case IDialogConstants.CANCEL_ID :
		{
			cancelPressed( );
			break;
		}
		case IDialogConstants.HELP_ID :
		{
			performHelp( );
			break;
		}
		default :
		{
			super.buttonPressed( buttonId );
		}
	}
}
 
Example 9
Source File: StartupDialog.java    From offspring with MIT License 5 votes vote down vote up
@Override
protected void buttonPressed(int id) {
  if (id == IDialogConstants.CANCEL_ID) {
    if (showOKButton) { // dialog is used for startup
      boolean exit = MessageDialog.openConfirm(getShell(), "Exit Offspring?",
          "Do you want to exit Offspring?");
      if (!exit)
        return;
    }
    monitor.setCanceled(true);
  }
  super.buttonPressed(id);
}
 
Example 10
Source File: ExportWarningDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void buttonPressed(int buttonId) {
	if (buttonId == IDialogConstants.CLOSE_ID
			|| buttonId == IDialogConstants.CANCEL_ID) {
		setReturnCode(buttonId);
		close();

	} else if (buttonId == IDialogConstants.OK_ID) {
		setReturnCode(buttonId);
		close();
	}

	super.buttonPressed(buttonId);
}
 
Example 11
Source File: ImportArticleDialog.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent){
	super.createButtonsForButtonBar(parent);
	
	Button okBtn = super.getButton(IDialogConstants.OK_ID);
	if (okBtn != null) {
		okBtn.setText("Import");
	}
	
	Button closeBtn = super.getButton(IDialogConstants.CANCEL_ID);
	if (closeBtn != null) {
		closeBtn.setText("Schließen");
	}
}
 
Example 12
Source File: WebArtifactOverwriteQuery.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Open confirm dialog
 * 
 * @param file
 * @return
 */
private int openDialog( final String item )
{
	final int[] result = {
		IDialogConstants.CANCEL_ID
	};
	shell.getDisplay( ).syncExec( new Runnable( ) {

		public void run( )
		{
			String title = BirtWTPMessages.BIRTOverwriteQuery_webartifact_title;
			String msg = NLS.bind( BirtWTPMessages.BIRTOverwriteQuery_webartifact_message,
					item );
			String[] options = {
					IDialogConstants.YES_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL
			};
			MessageDialog dialog = new MessageDialog( shell,
					title,
					null,
					msg,
					MessageDialog.QUESTION,
					options,
					0 );
			result[0] = dialog.open( );
		}
	} );
	return result[0];
}
 
Example 13
Source File: WorkspaceConversionItemDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public int open() {
	int result = worksapceDialog.open();
	IFile file = null;
	if (result == IDialogConstants.OK_ID) {
		file = worksapceDialog.getSelectedFile();
		if (file != null) {
			conversionItem = new FileConversionItem(file);
		}
		return IDialogConstants.OK_ID;
	}
	return IDialogConstants.CANCEL_ID;
}
 
Example 14
Source File: ReorgQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean getResult(int[] result) throws OperationCanceledException {
	switch(result[0]){
		case IDialogConstants.YES_ID:
			return true;
		case IDialogConstants.CANCEL_ID:
			throw new OperationCanceledException();
		case IDialogConstants.NO_ID:
			return false;
		default:
			Assert.isTrue(false);
			return false;
	}
}
 
Example 15
Source File: ReorgQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Runnable createQueryRunnable(final String question, final int[] result){
	return new Runnable() {
		public void run() {
			MessageDialog dialog= new MessageDialog(
				fShell,
				fDialogTitle,
				null,
				question,
				MessageDialog.QUESTION,
				getButtonLabels(),
				0);
			dialog.open();

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

		private String[] getButtonLabels() {
			return new String[] {IDialogConstants.SKIP_LABEL, ReorgMessages.ReorgQueries_skip_all, IDialogConstants.CANCEL_LABEL};
		}
	};
}
 
Example 16
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	switch (buttonId) {
		case APPLY_BUTTON:
			applyChanges();
			break;
		case IDialogConstants.OK_ID:
			applyChanges();
			close();
			break;
		case IDialogConstants.CANCEL_ID:
			close();
			break;
		case ADD_BUTTON:
			TemplateEditionDialog dialog= new TemplateEditionDialog(getShell(), -1);
			dialog.open();
			if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
				templateNames.add(dialog.getTemplateName());
				templates.add(dialog.getTemplate());
				selectedTemplateNumber= templateNames.size() - 1;
				somethingChanged= true;
				refreshControls();
			}
			break;
		case REMOVE_BUTTON:
			if (templateNames.size() > 0) {
				templateNames.remove(selectedTemplateNumber);
				templates.remove(selectedTemplateNumber);
			}
			if (selectedTemplateNumber >= templateNames.size())
				selectedTemplateNumber= templateNames.size() - 1;
			somethingChanged= true;
			refreshControls();
			break;
		case EDIT_BUTTON:
			onEdit();
	}
}
 
Example 17
Source File: SourceActionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	switch (buttonId) {
		case IDialogConstants.OK_ID: {
			okPressed();
			break;
		}
		case IDialogConstants.CANCEL_ID: {
			cancelPressed();
			break;
		}
	}
}
 
Example 18
Source File: RenameRefactoringExecuter.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean showStatusDialog(RefactoringStatus status) {
	Dialog dialog = RefactoringUI.createRefactoringStatusDialog(status, shell, refactoring.getName(), false);
	return dialog.open() == IDialogConstants.CANCEL_ID;
}
 
Example 19
Source File: TSWizardDialog.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Return the cancel button if the id is a the cancel id.
 * 
 * @param id
 *            the button id
 * @return the button corresponding to the button id
 */
protected Button getButton(int id) {
	if (id == IDialogConstants.CANCEL_ID) {
		return cancelButton;
	}
	return super.getButton(id);
}