Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#open()

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#open() . 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: BindingDialogHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private boolean canProcessFunctionTypeError( String function, String type,
		String recommended )
{
	MessageDialog dialog = new MessageDialog( UIUtil.getDefaultShell( ),
			Messages.getString( "Warning" ), //$NON-NLS-1$
			null,
			Messages.getFormattedString( "BindingDialogHelper.warning.function", //$NON-NLS-1$
					new String[]{
						recommended
					} ),
			MessageDialog.WARNING,
			new String[]{
					Messages.getString( Messages.getString( "BindingDialogHelper.warning.button.yes" ) ), Messages.getString( Messages.getString( "BindingDialogHelper.warning.button.no" ) ) //$NON-NLS-1$ //$NON-NLS-2$
			},
			0 );
	return dialog.open( ) == 0;
}
 
Example 2
Source File: Hub.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Programmende
 */
public static void postShutdown(){
	// shutdownjobs are executed after the workbench has been shut down.
	// So those jobs must not use any of the workbench's resources.
	if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) {
		Shell shell = new Shell(Display.getDefault());
		MessageDialog dlg =
			new MessageDialog(shell, Messages.Hub_title_configuration,
				Dialog.getDefaultImage(), Messages.Hub_message_configuration,
				SWT.ICON_INFORMATION, new String[] {}, 0);
		dlg.setBlockOnOpen(false);
		dlg.open();
		for (ShutdownJob job : shutdownJobs) {
			try {
				job.doit();
			} catch (Exception e) {
				log.error("Error starting job: " + e.getMessage());
			}
		}
		dlg.close();
	}
}
 
Example 3
Source File: SWTHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void run(){
	Shell shell = UiDesk.getTopShell();
	MessageDialog dialog = new MessageDialog(shell, title, null, // accept
		// the
		// default
		// window
		// icon
		message, MessageDialog.QUESTION, new String[] {
			Messages.SWTHelper_yes, Messages.SWTHelper_no, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
			Messages.SWTHelper_cancel
		}, 0);
	// ok is the default
	int result = dialog.open();
	if (result != 2) {
		ret = result == 0;
	}
}
 
Example 4
Source File: PartitionSchemaDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public void ok() {
  try {
    IHopMetadataSerializer<PartitionSchema> serializer = metadataProvider.getSerializer( PartitionSchema.class );
    getInfo();

    if ( !partitionSchema.getName().equals( originalSchema.getName() ) ) {
      if ( serializer.exists( partitionSchema.getName() ) ) {
        String title = BaseMessages.getString( PKG, "PartitionSchemaDialog.PartitionSchemaNameExists.Title" );
        String message =
          BaseMessages.getString( PKG, "PartitionSchemaDialog.PartitionSchemaNameExists", partitionSchema.getName() );
        String okButton = BaseMessages.getString( PKG, "System.Button.OK" );
        MessageDialog dialog =
          new MessageDialog( shell, title, null, message, MessageDialog.ERROR, new String[] { okButton }, 0 );

        dialog.open();
        return;
      }
    }

    originalSchema.setName( partitionSchema.getName() );
    originalSchema.setPartitionIDs( partitionSchema.getPartitionIDs() );
    originalSchema.setDynamicallyDefined( wDynamic.getSelection() );
    originalSchema.setNumberOfPartitions( wNumber.getText() );
    originalSchema.setChanged();

    result = originalSchema.getName();

    dispose();
  } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "Error getting dialog information for the partition schema", e );
  }
}
 
Example 5
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 6
Source File: DatabaseDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public static void showDatabaseExistsDialog( Shell parent, DatabaseMeta databaseMeta ) {
  String title = BaseMessages.getString( PKG, "DatabaseDialog.DatabaseNameExists.Title" );
  String message = BaseMessages.getString( PKG, "DatabaseDialog.DatabaseNameExists", databaseMeta.getName() );
  String okButton = BaseMessages.getString( PKG, "System.Button.OK" );
  MessageDialog dialog =
    new MessageDialog( parent, title, null, message, MessageDialog.ERROR, new String[] { okButton }, 0 );
  dialog.open();
}
 
Example 7
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void performDefaults() {

		// Ask the user to confirm
		final String title = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxText;
		final String message = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxMessage;
		final boolean confirmed = MessageDialog.open(MessageDialog.CONFIRM, getShell(), title, message, SWT.SHEET);

		if (confirmed) {
			long startTime = 0L;
			if (DEBUG) {
				startTime = System.currentTimeMillis();
			}

			fFilteredTree.setRedraw(false);
			BusyIndicator.showWhile(fFilteredTree.getViewer().getTree().getDisplay(), new Runnable() {
				public void run() {
					try {
						keyController.setDefaultBindings(fBindingService, lstRemove);
					} catch (NotDefinedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			});
			fFilteredTree.setRedraw(true);
			if (DEBUG) {
				final long elapsedTime = System.currentTimeMillis() - startTime;
				Tracing.printTrace(TRACING_COMPONENT, "performDefaults:model in " //$NON-NLS-1$
						+ elapsedTime + "ms"); //$NON-NLS-1$
			}
		}

		super.performDefaults();
	}
 
Example 8
Source File: PyDialogHelpers.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static int openQuestionConfigureInterpreter(AbstractInterpreterManager m) {
    IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore();
    String key = InterpreterGeneralPreferences.NOTIFY_NO_INTERPRETER + m.getInterpreterType();
    boolean val = store.getBoolean(key);

    if (val) {
        String title = m.getInterpreterUIName() + " not configured";
        String message = "It seems that the " + m.getInterpreterUIName()
                + " interpreter is not currently configured.\n\nHow do you want to proceed?";
        Shell shell = EditorUtils.getShell();

        String[] dialogButtonLabels = ArrayUtils.concatArrays(InterpreterConfigHelpers.CONFIG_NAMES_FOR_FIRST_INTERPRETER,
                new String[] { "Don't ask again" });

        dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION,
                dialogButtonLabels, 0);
        int open = dialog.open();

        //If dialog is null now, it was forcibly closed by a "disable" call of enableAskInterpreterStep.
        if (dialog != null) {
            dialog = null;
            // "Don't ask again" button is the final button in the list
            if (open == dialogButtonLabels.length - 1) {
                store.setValue(key, false);
                return INTERPRETER_CANCEL_CONFIG;
            }
            return open;
        }
    }
    return INTERPRETER_CANCEL_CONFIG;
}
 
Example 9
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 10
Source File: PyDialogHelpers.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return the index chosen or -1 if it was canceled.
 */
public static int openCriticalWithChoices(String title, String message, String[] choices) {
    Shell shell = EditorUtils.getShell();
    MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.ERROR, choices, 0);
    return dialog.open();
}
 
Example 11
Source File: KonsDetailView.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void selectionChanged(SelectionChangedEvent event){
	if (!ignoreEventSelectionChanged) {
		ISelection selection = event.getSelection();
		if (selection instanceof StructuredSelection) {
			if (!selection.isEmpty()) {
				ICoverage changeToCoverage =
					(ICoverage) ((StructuredSelection) selection).getFirstElement();
				
				ICoverage actCoverage = null;
				String fallLabel = "Current Case NOT found!!";//$NON-NLS-1$
				if (actEncounter != null) {
					actCoverage = actEncounter.getCoverage();
					fallLabel = actCoverage.getLabel();
				}
				
				if (!changeToCoverage.equals(actCoverage)) {
					if (!changeToCoverage.isOpen()) {
						SWTHelper.alert(Messages.KonsDetailView_CaseClosedCaption, // $NON-NLS-1$
							Messages.KonsDetailView_CaseClosedBody); // $NON-NLS-1$
					} else {
						MessageDialog msd = new MessageDialog(getViewSite().getShell(),
							Messages.KonsDetailView_ChangeCaseCaption, // $NON-NLS-1$
							Images.IMG_LOGO.getImage(ImageSize._75x66_TitleDialogIconSize),
							MessageFormat.format(
								Messages.KonsDetailView_ConfirmChangeConsToCase,
								new Object[] {
									fallLabel, changeToCoverage.getLabel()
								}), MessageDialog.QUESTION, new String[] {
									Messages.KonsDetailView_Yes, // $NON-NLS-1$
									Messages.KonsDetailView_No
							}, 0); // $NON-NLS-1$
						if (msd.open() == Window.OK) {
							Result<IEncounter> transferResult = EncounterServiceHolder.get().transferToCoverage(actEncounter,
								changeToCoverage, false);
							if(!transferResult.isOK()) {
								SWTHelper.alert("Error", transferResult.toString());
							}
							
						} else {
							ignoreSelectionEventOnce();
							comboViewerFall
								.setSelection(new StructuredSelection(actCoverage));
						}
					}
				}
			}
		}
	}
	ignoreEventSelectionChanged = false;
}
 
Example 12
Source File: MenuDataDialog.java    From EasyShell with Eclipse Public License 2.0 4 votes vote down vote up
private boolean validateValues() {

        String title = Activator.getResourceString("easyshell.error.title.incompletedata");

        // check type
        CommandData data = commandComboViewer.getSelection();
        if (data == null) {
            MessageDialog.openError(getShell(), title, Activator.getResourceString("easyshell.menu.editor.dialog.error.type.text"));
            return false;
        }

        boolean valid = true;

        // check name
        String text  = Activator.getResourceString("easyshell.menu.editor.dialog.error.text.name");
        if ( (namePatternText.getText() == null) || (namePatternText.getText().length() <= 0)) {
            valid = false;
        }

        // show error message
        if (!valid) {
            MessageDialog.openError(getShell(), title, text);
        } else {
            List<MenuData> menus = MenuDataStore.instance().getRefencedBy(data.getId());
            menus.remove(this.menuData);
            if (menus.size() >0) {
                title = Activator.getResourceString("easyshell.menu.editor.dialog.title.duplicate");
                String commandNames = data.getCommandAsComboName();
                String menuNames = "";
                for (MenuData menu : menus) {
                    menuNames += menu.getNameExpanded() + "\n";
                }
                String question = MessageFormat.format(Activator.getResourceString("easyshell.menu.editor.dialog.question.duplicate"),
                        commandNames, menuNames);
                MessageDialog dialog = new MessageDialog(
                        null, title, null, question,
                        MessageDialog.WARNING,
                        new String[] {"Yes", "No"},
                        1); // no is the default
                int result = dialog.open();
                if (result != 0) {
                    valid = false;
                }
            }
        }

        return valid;
    }
 
Example 13
Source File: IDEMultiPageReportEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void partActivated( IWorkbenchPart part )
{
	super.partActivated( part );
	if ( part != this )

		return;
	if ( isWorkspaceResource )
	{
		final IFile file = ( (IFileEditorInput) getEditorInput( ) ).getFile( );
		if ( !file.exists( ) )
		{

			Shell shell = getSite( ).getShell( );

			String title = DLG_SAVE_TITLE;

			String message = DLG_SAVE_CONFIRM_DELETE;

			String[] buttons = {
					DLG_SAVE_BUTTON_SAVE, DLG_SAVE_BUTTON_CLOSE
			};

			if ( closedStatus.contains( file ) )
			{
				return;
			}

			MessageDialog dialog = new MessageDialog( shell,
					title,
					null,
					message,
					MessageDialog.QUESTION,
					buttons,
					0 );

			closedStatus.add( file );

			int result = dialog.open( );

			if ( result == 0 )
			{
				doSaveAs( );
				partActivated( part );
			}
			else
			{
				closeEditor( false );
			}
			Display.getDefault( ).asyncExec( new Runnable( ) {

				public void run( )
				{
					closedStatus.remove( file );
				}
			} );
		}
	}
}
 
Example 14
Source File: GWTProjectPropertyPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public void addGWT(IProject project, GwtSdk runtime)
    throws BackingStoreException, FileNotFoundException, CoreException {
  IJavaProject javaProject = JavaCore.create(project);

  // TODO this causes some issue with dialog popup and war output folder selection
  WebAppProjectProperties.maybeSetWebAppPropertiesForDynamicWebProject(project);

  // if (sdkSelectionBlock.hasSdkChanged() &&
  // !GWTProjectsRuntime.isGWTRuntimeProject(javaProject)) {

  boolean isDefault = false;
  GwtSdk newSdk = runtime;
  GwtSdk oldSdk = runtime;

  UpdateType updateType = GWTUpdateProjectSdkCommand.computeUpdateType(oldSdk, newSdk, isDefault);

  GWTUpdateProjectSdkCommand updateProjectSdkCommand =
      new GWTUpdateProjectSdkCommand(javaProject, oldSdk, newSdk, updateType, null);

  /*
   * Update the project classpath which will trigger the <WAR>/WEB-INF/lib jars to be updated.
   */
  updateProjectSdkCommand.execute();
  // }

  GWTNature.addNatureToProject(project);

  // Need to rebuild to get GWT errors to appear
  BuilderUtilities.scheduleRebuild(project);

  // only prompt to reopen editors if the transition from disabled -> enabled
  if (!initialUseGWT && useGWT) {
    // Get the list of Java editors opened on files in this project
    IEditorReference[] openEditors = getOpenJavaEditors(project);
    if (openEditors.length > 0) {
      MessageDialog dlg = new MessageDialog(GWTPlugin.getActiveWorkbenchShell(), GWTPlugin.getName(), null,
          "GWT editing functionality, such as syntax-colored JSNI blocks, "
              + "will only be enabled after you re-open your Java editors.\n\nDo "
              + "you want to re-open your editors now?",
          MessageDialog.QUESTION, new String[] {"Re-open Java editors", "No"}, 0);
      if (dlg.open() == IDialogConstants.OK_ID) {
        reopenWithGWTJavaEditor(openEditors);
      }
    }
  }
}
 
Example 15
Source File: ProblemSeveritiesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
	if (!areSettingsEnabled()) {
		return;
	}

	if (changedKey != null) {
		if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) ||
				PREF_PB_DEPRECATION.equals(changedKey) ||
				PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) ||
				PREF_15_PB_INCOMPLETE_ENUM_SWITCH.equals(changedKey) ||
				PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey) ||
				PREF_PB_SUPPRESS_WARNINGS.equals(changedKey) ||
				PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey)) {
			updateEnableStates();
		}
		
		if (checkValue(PREF_ANNOTATION_NULL_ANALYSIS, ENABLED)
				&& (PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey)
						|| PREF_PB_NULL_REFERENCE.equals(changedKey)
						|| PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey)
						|| PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey)
						|| PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey))) {
			boolean badNullRef= lessSevere(getValue(PREF_PB_NULL_REFERENCE), getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION));
			boolean badPotNullRef= lessSevere(getValue(PREF_PB_POTENTIAL_NULL_REFERENCE), getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT));
			boolean ask= false;
			ask |= badNullRef && (PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey));
			ask |= badPotNullRef && (PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey));
			ask |= (badNullRef || badPotNullRef) && PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey);
			if (ask) {
				final Combo comboBoxNullRef= getComboBox(PREF_PB_NULL_REFERENCE);
				final Label labelNullRef= fLabels.get(comboBoxNullRef);
				int highlightNullRef= getHighlight(labelNullRef);
				final Combo comboBoxPotNullRef= getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE);
				final Label labelPotNullRef= fLabels.get(comboBoxPotNullRef);
				int highlightPotNullRef= getHighlight(labelPotNullRef);
				
				getShell().getDisplay().asyncExec(new Runnable() {
					public void run() {
						highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, HIGHLIGHT_FOCUS);
						highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, HIGHLIGHT_FOCUS);
					}
				});
				
				MessageDialog messageDialog= new MessageDialog(
						getShell(),
						PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_title,
						null,
						PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_message,
						MessageDialog.QUESTION,
						new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
						0);
				messageDialog.create();
				Shell messageShell= messageDialog.getShell();
				messageShell.setLocation(messageShell.getLocation().x, getShell().getLocation().y + 40);
				if (messageDialog.open() == 0) {
					if (badNullRef) {
						setValue(PREF_PB_NULL_REFERENCE, getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION));
						updateCombo(getComboBox(PREF_PB_NULL_REFERENCE));
					}
					if (badPotNullRef) {
						setValue(PREF_PB_POTENTIAL_NULL_REFERENCE, getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT));
						updateCombo(getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE));
					}
				}
				
				highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, highlightNullRef);
				highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, highlightPotNullRef);
			}

		} else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) {
			// merging the two options
			setValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue);
			
		} else if (INTR_DEFAULT_NULL_ANNOTATIONS.equals(changedKey)) {
			if (ENABLED.equals(newValue)) {
				setValue(PREF_NULLABLE_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[0]);
				setValue(PREF_NONNULL_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[1]);
				setValue(PREF_NONNULL_BY_DEFAULT_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[2]);
			} else {
				openNullAnnotationsConfigurationDialog();
			}
			
		} else {
			return;
		}
	} else {
		updateEnableStates();
		updateNullAnnotationsSetting();
	}
}
 
Example 16
Source File: PublishResourceWizard.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( ) ) )
	{
		ExceptionUtil.openError( Messages.getString( "PublishResourceAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishResourceAction.wizard.message.SourceFileNotExist" ) ); //$NON-NLS-1$

		return false;
	}

	File targetFile = getTargetFile( );

	if ( targetFile == null )
	{
		ExceptionUtil.openError( Messages.getString( "PublishResourceAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishResourceAction.wizard.notvalidfolder" ) ); //$NON-NLS-1$

		return false;
	}

	if ( new File( filePath ).compareTo( targetFile ) == 0 )
	{
		ExceptionUtil.openError( Messages.getString( "PublishResourceAction.wizard.errorTitle" ), //$NON-NLS-1$
				Messages.getString( "PublishResourceAction.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( ) ) ) )
		{
			doCopy( filePath, targetFile );

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

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

	return overwrite != 2;
}
 
Example 17
Source File: OpenERPObjectInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void populateFielsTable( ArrayList<FieldMapping> mappings ) {

    int choice = 0;

    if ( tableViewFields.table.getItemCount() > 0 ) {
      // Ask what we should do with the existing data in the step.
      MessageDialog md =
        new MessageDialog(
          tableViewFields.getShell(),
          BaseMessages.getString( PKGStepInterface, "BaseStepDialog.GetFieldsChoice.Title" ), // "Warning!"
          null,
          BaseMessages.getString( PKGStepInterface, "BaseStepDialog.GetFieldsChoice.Message",
            "" + tableViewFields.table.getItemCount(), "" + mappings.size() ),
          MessageDialog.WARNING,
          new String[]{
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.AddNew" ),
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.ClearAndAdd" ),
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.Cancel" ),
          },
          0 );
      MessageDialog.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
      int idx = md.open();
      choice = idx & 0xFF;
    }

    if ( choice == 2 || choice == 255 /* 255 = escape pressed */ ) {
      return; // Cancel clicked
    }

    if ( choice == 1 ) {
      tableViewFields.table.removeAll();
    }

    // Make a list of the old elements
    Hashtable<String, Object> currentMaps = new Hashtable<String, Object>();
    for ( int i = 0; i < tableViewFields.table.getItemCount(); i++ ) {
      currentMaps.put( tableViewFields.table.getItem( i ).getText( 1 ) + tableViewFields.table.getItem( i ).getText( 2 )
        + tableViewFields.table.getItem( i ).getText( 3 ), true );
    }
    sourceListMapping = mappings;
    for ( FieldMapping map : mappings ) {
      // Only add new elements
      if ( !currentMaps.containsKey( map.target_field_label + map.target_model + map.target_field ) ) {
        tableViewFields.add( map.target_field_label, map.target_model, map.target_field, map.source_model,
          map.source_field, String.valueOf( map.source_index ), String.valueOf( map.target_field_type ) );
      }
    }

    tableViewFields.setRowNums();
    tableViewFields.optWidth( true );
  }
 
Example 18
Source File: CheckConfigurationPropertiesDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 */
@Override
protected void okPressed() {
  try {
    // Check if the configuration is valid
    mCheckConfig = mConfigurationEditor.getEditedWorkingCopy();

    CheckConfigurationTester tester = new CheckConfigurationTester(mCheckConfig);
    List<ResolvableProperty> unresolvedProps = tester.getUnresolvedProperties();

    if (!unresolvedProps.isEmpty()) {

      MessageDialog dialog = new MessageDialog(getShell(),
              Messages.CheckConfigurationPropertiesDialog_titleUnresolvedProps, null,
              NLS.bind(Messages.CheckConfigurationPropertiesDialog_msgUnresolvedProps,
                      "" + unresolvedProps.size()), //$NON-NLS-1$
              MessageDialog.WARNING,
              new String[] { Messages.CheckConfigurationPropertiesDialog_btnEditProps,
                  Messages.CheckConfigurationPropertiesDialog_btnContinue,
                  Messages.CheckConfigurationPropertiesDialog_btnCancel },
              0);
      int result = dialog.open();

      if (0 == result) {
        ResolvablePropertiesDialog propsDialog = new ResolvablePropertiesDialog(getShell(),
                mCheckConfig);
        propsDialog.open();
        return;
      } else if (1 == result) {
        super.okPressed();
      } else if (2 == result) {
        return;
      }
    } else {
      super.okPressed();
    }
  } catch (CheckstylePluginException e) {
    CheckstyleLog.log(e);
    this.setErrorMessage(e.getLocalizedMessage());
  }
}
 
Example 19
Source File: HopServerDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
public void ok() {
  getInfo();

  if ( !hopServer.getName().equals( originalServer.getName() ) ) {

    // See if the name collides with an existing one...
    // TODO: provide name changes utilities
    //
    try {
      IHopMetadataSerializer<HopServer> serializer = metadataProvider.getSerializer( HopServer.class );
      if ( serializer.exists( hopServer.getName() ) ) {
        String title = BaseMessages.getString( PKG, "HopServerDialog.HopServerNameExists.Title" );
        String message =
          BaseMessages.getString( PKG, "HopServerDialog.HopServerNameExists", hopServer.getName() );
        String okButton = BaseMessages.getString( PKG, "System.Button.OK" );
        MessageDialog dialog =
          new MessageDialog( shell, title, null, message, MessageDialog.ERROR, new String[] { okButton }, 0 );

        dialog.open();
        return;
      }
    } catch ( Exception e ) {
      new ErrorDialog( shell, "Error", "Error checking for name collisions after rename", e );
    }
  }

  originalServer.setName( hopServer.getName() );
  originalServer.setHostname( hopServer.getHostname() );
  originalServer.setPort( hopServer.getPort() );
  originalServer.setWebAppName( hopServer.getWebAppName() );
  originalServer.setUsername( hopServer.getUsername() );
  originalServer.setPassword( hopServer.getPassword() );

  originalServer.setProxyHostname( hopServer.getProxyHostname() );
  originalServer.setProxyPort( hopServer.getProxyPort() );
  originalServer.setNonProxyHosts( hopServer.getNonProxyHosts() );

  originalServer.setSslMode( hopServer.isSslMode() );

  originalServer.setChanged();

  result = hopServer.getName();

  dispose();
}
 
Example 20
Source File: ImportProjectWizardPage.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Display an error dialog with the specified message.
 * 
 * @param message
 * 		the error message
 */
protected void displayErrorDialog(String message) {
	MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
			getErrorDialogTitle(), message, SWT.SHEET);
}