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

The following examples show how to use org.eclipse.jface.dialogs.IDialogConstants#CANCEL_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: ExitDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static MessageDialogWithToggle openExitDialog(final Shell parentShell) {
    MessageDialogWithToggle dialog = null;
    if (deleteTenantOnExit()) {
        dialog = new ExitDialog(parentShell, IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, null, null, WARNING, new String[] {
                IDialogConstants.OK_LABEL,
                IDialogConstants.CANCEL_LABEL },
                0, IDEWorkbenchMessages.PromptOnExitDialog_choice, false);
        dialog.open();
    } else {
        dialog = MessageDialogWithToggle
                .openOkCancelConfirm(parentShell,
                        IDEWorkbenchMessages.PromptOnExitDialog_shellTitle,
                        exitMessage(),
                        IDEWorkbenchMessages.PromptOnExitDialog_choice,
                        false, null, null);
    }
    return dialog;
}
 
Example 2
Source File: DocumentPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private int openOutlineDialog(final IStructuredSelection selection) {
    final StringBuilder sb = new StringBuilder();
    for (final Object selectionElement : selection.toList()) {
        if (selectionElement instanceof Document) {
            sb.append(((Document) selectionElement).getName() + "\n");
        }
    }
    if (sb.length() > 0) {
        sb.delete(sb.length() - 1, sb.length());
    }
    final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    final java.util.List<Object> selectionList = ((IStructuredSelection) documentListViewer.getSelection()).toList();
    final OutlineDialog dialog = new OutlineDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            removalConfirmationDialogTitle, Display
                    .getCurrent().getSystemImage(SWT.ICON_WARNING),
            NLS.bind(Messages.areYouSureMessage, sb.toString()), MessageDialog.CONFIRM, buttonList,
            1, selectionList);
    return dialog.open();
}
 
Example 3
Source File: NativeBinaryDestinationPage.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public String queryOverwrite(String pathString) {

	final MessageDialog dialog = new MessageDialog(getShell(), 
			"Overwrite Files?", 
			null, 
			 pathString+ " already exists. Would you like to overwrite it?",
			 MessageDialog.QUESTION,
			 new String[] { IDialogConstants.YES_LABEL,
                        IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                        0);
	String[] response = new String[] { YES,  NO, CANCEL };
       //most likely to be called from non-ui thread
	getControl().getDisplay().syncExec(new Runnable() {
           public void run() {
               dialog.open();
           }
       });
       return dialog.getReturnCode() < 0 ? CANCEL : response[dialog
               .getReturnCode()];
}
 
Example 4
Source File: ErrorsWarningsPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean performOk() {
  updateWorkingCopyFromCombos();

  if (!GdtProblemSeverities.getInstance().equals(problemSeveritiesWorkingCopy)) {
    MessageDialog dialog = new MessageDialog(getShell(), "Errors/Warnings Settings Changed", null,
        "The GWT Error/Warning settings have changed.  A full rebuild "
            + "of all GWT projects is required for changes to " + "take effect.  Do the full build now?",
        MessageDialog.QUESTION,
        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); // Cancel
                                                                                                                   // is
                                                                                                                   // default
    int result = dialog.open();

    if (result == 2) { // Cancel
      return false;
    } else {
      updateWorkspaceSeveritySettingsFromWorkingCopy();

      if (result == 0) { // Yes
        BuilderUtilities.scheduleRebuildAll(GWTNature.NATURE_ID);
      }
    }
  }
  return true;
}
 
Example 5
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 6
Source File: BinaryPathPreferencePage.java    From cppcheclipse with Apache License 2.0 6 votes vote down vote up
private boolean askBeforeLeave() {
	String[] buttonLabels = { Messages.BinaryPathPreferencePage_ButtonSave,
			Messages.BinaryPathPreferencePage_ButtonDiscard,
			IDialogConstants.CANCEL_LABEL };
	MessageDialog messageDialog = new MessageDialog(getShell(),
			Messages.BinaryPathPreferencePage_AskBeforeLeaveTitle, null,
			Messages.BinaryPathPreferencePage_AskBeforeLeaveMessage,
			MessageDialog.QUESTION, buttonLabels, 0);
	int clickedButtonIndex = messageDialog.open();
	boolean okToLeave = false;
	switch (clickedButtonIndex) {
	case 0: // Save
		binaryPath.store();
		// we need to save all values here
		okToLeave = true;
		break;
	case 1: // Discard
		binaryPath.load();
		okToLeave = true;
	}
	if (okToLeave) {
		hasBinaryPathChanged = false;
	}
	return okToLeave;
}
 
Example 7
Source File: MessageDialogScrollable.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * @param kind
 * @return
 */
private static String[] getButtonLabels(int kind) {
	String[] dialogButtonLabels;
	switch (kind) {
	case ERROR: // fall through to WARNING
	case INFORMATION: // fall through to WARNING
	case WARNING: {
		dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
		break;
	}
	case CONFIRM: {
		dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
		break;
	}
	case QUESTION: {
		dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
		break;
	}
	case QUESTION_WITH_CANCEL: {
		dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
				IDialogConstants.CANCEL_LABEL };
		break;
	}
	default: {
		throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
	}
	}
	return dialogButtonLabels;
}
 
Example 8
Source File: N4JSBuilderPreferencePage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock.
 */
@Override
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	boolean needsBuild = !getPreferenceChanges().isEmpty() | projectSpecificChanged;
	boolean doBuild = false;
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > rebuildCount) {
			needsBuild = false;
			rebuildCount = count;
		}
	}
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(project == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1],
					MessageDialog.QUESTION,
					new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
							IDialogConstants.CANCEL_LABEL },
					2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false;
			}
		}
	}
	if (container != null) {
		if (doBuild) {
			incrementRebuildCount();
			container.registerUpdateJob(getBuildJob(getProject()));
		}
	} else {
		if (doBuild) {
			getBuildJob(getProject()).schedule();
		}
	}
	return true;
}
 
Example 9
Source File: MessageDialogWithPrompt.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected static String[] getButtonLabelsFor(int kind) {
    String[] dialogButtonLabels;
    switch (kind) {
        case ERROR:
        case INFORMATION:
        case WARNING: {
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
            break;
        }
        case CONFIRM: {
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL,
                    IDialogConstants.CANCEL_LABEL };
            break;
        }
        case QUESTION: {
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
                    IDialogConstants.NO_LABEL };
            break;
        }
        case QUESTION_WITH_CANCEL: {
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
                    IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL };
            break;
        }
        default: {
            throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
        }
    }
    return dialogButtonLabels;
}
 
Example 10
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Ask the user to confirm the overwrite of the file if the file has been
 * modified since last commit
 */
private boolean confirmOverwrite() {
   IFile file = (IFile) resource;
   if(file != null && file.exists()) {
     ISVNLocalFile svnFile = SVNWorkspaceRoot.getSVNFileFor(file);
     try {
       if(svnFile.isDirty()) {
         String title = Policy.bind("HistoryView.overwriteTitle"); //$NON-NLS-1$
         String msg = Policy.bind("HistoryView.overwriteMsg"); //$NON-NLS-1$
         final MessageDialog dialog = new MessageDialog(getSite().getShell(), title, null, msg,
             MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
         final int[] result = new int[ 1];
         getSite().getShell().getDisplay().syncExec(new Runnable() {
           public void run() {
             result[ 0] = dialog.open();
           }
         });
         if(result[ 0] != 0) {
           // cancel
           return false;
         }
       }
     } catch(SVNException e) {
       SVNUIPlugin.log(e.getStatus());
     }
   }
   return true;
 }
 
Example 11
Source File: StandardDeployCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
protected boolean checkJspConfiguration(Shell shell, IProject project) throws CoreException {
  // If we have JSPs, ensure the project is configured with a JDK: required by staging
  // which precompiles the JSPs.  We could try to find a compatible JDK, but there's
  // a possibility that we select an inappropriate one and introduce problems.
  if (!WebProjectUtil.hasJsps(project)) {
    return true;
  }

  IJavaProject javaProject = JavaCore.create(project);
  IVMInstall vmInstall = JavaRuntime.getVMInstall(javaProject);
  if (JreDetector.isDevelopmentKit(vmInstall)) {
    return true;
  }

  String title = Messages.getString("vm.is.jre.title");
  String message =
      Messages.getString(
          "vm.is.jre.proceed",
          project.getName(),
          describeVm(vmInstall),
          vmInstall.getInstallLocation());
  String[] buttonLabels =
      new String[] {Messages.getString("deploy.button"), IDialogConstants.CANCEL_LABEL};
  MessageDialog dialog =
      new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, 0, buttonLabels);
  return dialog.open() == 0;
}
 
Example 12
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	boolean needsBuild = buildPreferenceEvaluator.isAffectingBuild(getPreferenceChanges());
	boolean doBuild = false;
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > rebuildCount) {
			needsBuild = false;
			rebuildCount = count;
		}
	}
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(project == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(shell, strings[0], null, strings[1], MessageDialog.QUESTION,
					new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
							IDialogConstants.CANCEL_LABEL }, 2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false;
			}
		}
	}
	savePreferences();
	if (container != null) {
		if (doBuild) {
			incrementRebuildCount();
			container.registerUpdateJob(getBuildJob(getProject()));
		}
	} else {
		if (doBuild) {
			getBuildJob(getProject()).schedule();
		}
	}
	captureOriginalSettings(keys);
	return true;
}
 
Example 13
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 4 votes vote down vote up
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	IScopeContext currContext = fLookupOrder[0];

	List<Key> changedOptions = new ArrayList<Key>();
	boolean needsBuild = getChanges(currContext, changedOptions);
	if (changedOptions.isEmpty()) {
		return true;
	}
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > fRebuildCount) {
			needsBuild = false; // build already requested
			fRebuildCount = count;
		}
	}

	boolean doBuild = false;
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(fProject == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(
					getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] {
							IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
					2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false; // cancel pressed
			}
		}
	}
	if (container != null) {
		// no need to apply the changes to the original store: will be done
		// by the page container
		if (doBuild) { // post build
			incrementRebuildCount();
			// container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
		}
	} else {
		// apply changes right away
		try {
			fManager.applyChanges();
		} catch (BackingStoreException e) {
			// JavaScriptPlugin.log(e);
			return false;
		}
		if (doBuild) {
			// CoreUtility.getBuildJob(fProject).schedule();
		}

	}
	return true;
}
 
Example 14
Source File: GwtPreferencePage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
  noDefaultAndApplyButton();

  sdkSet = GWTPreferences.getSdks();

  return new SdkTable<GwtSdk>(parent, SWT.NONE, sdkSet, null, this) {
    @Override
    protected IStatus doAddSdk() {
      AddSdkDialog<GwtSdk> addGwtSdkDialog = new AddGwtSdkDialog(getShell(), sdkSet, GWTPlugin.PLUGIN_ID,
          "Add GWT SDK", GwtSdk.getFactory());
      if (addGwtSdkDialog.open() == Window.OK) {
        GwtSdk newSdk = addGwtSdkDialog.getSdk();
        if (newSdk != null) {
          sdkSet.add(newSdk);
        }

        return Status.OK_STATUS;
      }

      return Status.CANCEL_STATUS;
    }

    @Override
    protected IStatus doDownloadSdk() {
      MessageDialog dialog = new MessageDialog(GWTPlugin.getActiveWorkbenchShell(), "GWT Eclipse Plugin", null,
          "Would you like to open the GWT download page in your "
              + "web browser?\n\nFrom there, you can " + "download the latest GWT SDK and extract it to the"
              + " location of your choice. Add it to Eclipse" + " with the \"Add...\" button.",
          MessageDialog.QUESTION, new String[] {"Open Browser", IDialogConstants.CANCEL_LABEL}, 0);

      if (dialog.open() == Window.OK) {
        if (BrowserUtilities.launchBrowserAndHandleExceptions(GWTPlugin.SDK_DOWNLOAD_URL) == null) {
          return Status.CANCEL_STATUS;
        }
      } else {
        return Status.CANCEL_STATUS;
      }
      return Status.OK_STATUS;
    }
  };
}
 
Example 15
Source File: PublishLibraryWizard.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private boolean publishiLibrary( )
{
	// copy to library folder

	if ( !( new File( filePath ).exists( ) ) )
	{
		ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishLibraryAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishLibraryAction.wizard.message.SourceFileNotExist" ) ); //$NON-NLS-1$
		return true;
	}

	File targetFolder = new File( folderName );
	if ( targetFolder.exists( ) && ( !targetFolder.isDirectory( ) ) )
	{
		ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishLibraryAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishLibraryAction.wizard.notvalidfolder" ) ); //$NON-NLS-1$
		//$NON-NLS-1$
		return true;
	}
	boolean folderExists = targetFolder.exists( );
	if ( !folderExists )
	{
		folderExists = targetFolder.mkdirs( );
	}
	if( !folderExists )
	{
		ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishLibraryAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishLibraryAction.wizard.msgDirErr" ) ); //$NON-NLS-1$
		return false;
	}
	File targetFile = new File( targetFolder, fileName );
	if ( new File( filePath ).compareTo( targetFile ) == 0 )
	{
		ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishLibraryAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishLibraryAction.wizard.message" ) ); //$NON-NLS-1$
		return false;
	}

	int overwrite = Window.OK;
	try
	{
		if ( targetFile.exists( ) )
		{
			String[] buttons = new String[]{
					IDialogConstants.YES_LABEL,
					IDialogConstants.NO_LABEL,
					IDialogConstants.CANCEL_LABEL
			};
			String question = Messages.getFormattedString( "SaveAsDialog.overwriteQuestion", //$NON-NLS-1$
					new Object[]{
						targetFile.getAbsolutePath( )
					} );
			MessageDialog d = new MessageDialog( UIUtil.getDefaultShell( ),
					Messages.getString( "SaveAsDialog.Question" ), //$NON-NLS-1$
					null,
					question,
					MessageDialog.QUESTION,
					buttons,
					0 );
			overwrite = d.open( );
		}
		if ( overwrite == Window.OK
				&& ( targetFile.exists( ) || ( !targetFile.exists( ) && targetFile.createNewFile( ) ) ) )
		{
			copyFile( filePath, targetFile );

			IReportResourceSynchronizer synchronizer = ReportPlugin.getDefault( )
					.getResourceSynchronizerService( );

			if ( synchronizer != null )
			{
				synchronizer.notifyResourceChanged( new ReportResourceChangeEvent( this,
						Path.fromOSString( targetFile.getAbsolutePath( ) ),
						IReportResourceChangeEvent.NewResource ) );
			}
		}
	}
	catch ( IOException e )
	{
		ExceptionHandler.handle( e );
	}

	return overwrite != 1;
}
 
Example 16
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 17
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 18
Source File: WizardSaveAsPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IPath getResult( )
{

	IPath path = support.getFileLocationFullPath( )
			.append( support.getFileName( ) );

	// If the user does not supply a file extension and if the save
	// as dialog was provided a default file name append the extension
	// of the default filename to the new name
	if ( ReportPlugin.getDefault( )
			.isReportDesignFile( support.getInitialFileName( ) )
			&& !ReportPlugin.getDefault( )
					.isReportDesignFile( path.toOSString( ) ) )
	{
		String[] parts = support.getInitialFileName( ).split( "\\." ); //$NON-NLS-1$
		path = path.addFileExtension( parts[parts.length - 1] );
	}
	else if ( support.getInitialFileName( )
			.endsWith( IReportEditorContants.TEMPLATE_FILE_EXTENTION )
			&& !path.toOSString( )
					.endsWith( IReportEditorContants.TEMPLATE_FILE_EXTENTION ) )
	{
		path = path.addFileExtension( "rpttemplate" ); //$NON-NLS-1$
	}
	// If the path already exists then confirm overwrite.
	File file = path.toFile( );
	if ( file.exists( ) )
	{
		String[] buttons = new String[]{
				IDialogConstants.YES_LABEL,
				IDialogConstants.NO_LABEL,
				IDialogConstants.CANCEL_LABEL
		};

		String question = Messages.getFormattedString( "SaveAsDialog.overwriteQuestion", //$NON-NLS-1$
				new Object[]{
					path.toOSString( )
				} );
		MessageDialog d = new MessageDialog( getShell( ),
				Messages.getString( "SaveAsDialog.Question" ), //$NON-NLS-1$
				null,
				question,
				MessageDialog.QUESTION,
				buttons,
				0 );
		int overwrite = d.open( );
		switch ( overwrite )
		{
			case 0 : // Yes
				break;
			case 1 : // No
				return null;
			case 2 : // Cancel
			default :
				return Path.EMPTY;
		}
	}

	return path;
}
 
Example 19
Source File: EObjectSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Constructor.
 * 
 * @param parentShell
 *            the parent {@link Shell}
 * @param adapterFactory
 *            the {@link AdapterFactory}
 * @param title
 *            the title of the dialog
 * @param message
 *            the message of the dialog
 * @param queryEnvironment
 *            the {@link IReadOnlyQueryEnvironment}
 * @param resourceSet
 *            the {@link ResourceSet} for model
 * @param acceptedEClasses
 *            the {@link Set} of accepted {@link EClass}
 */
public EObjectSelectionDialog(Shell parentShell, AdapterFactory adapterFactory, String title, String message,
        IReadOnlyQueryEnvironment queryEnvironment, ResourceSet resourceSet, Set<EClass> acceptedEClasses) {
    super(parentShell, title, null, message, MessageDialog.QUESTION,
            new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    this.resourceSet = resourceSet;
    this.adapterFactory = adapterFactory;
    this.queryEnvironment = queryEnvironment;
    this.acceptedEClasses = acceptedEClasses;
}
 
Example 20
Source File: SelectRegistredTemplateDialog.java    From M2Doc with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Consturctor.
 * 
 * @param parentShell
 *            the parent {@link Shell}
 */
public SelectRegistredTemplateDialog(Shell parentShell) {
    super(parentShell, "Select registered template.", null,
            "Select a template in the following registered templates.", MessageDialog.QUESTION,
            new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
}