Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#ERROR

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#ERROR . These examples are extracted from open source projects. 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 Project: hop   File: GetFieldsSampleDataDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void handleOk( final int samples ) {
  if ( samples >= 0 ) {
    String message = parentDialog.loadFields( parentDialog.getPopulatedMeta(), samples, reloadAllFields );
    if ( wCheckbox != null && wCheckbox.getSelection() ) {
      if ( StringUtils.isNotBlank( message ) ) {
        final EnterTextDialog etd =
          new EnterTextDialog( parentDialog.getShell(),
            BaseMessages.getString( PKG, "GetFieldsSampleDataDialog.ScanResults.DialogTitle" ),
            BaseMessages.getString( PKG, "GetFieldsSampleDataDialog.ScanResults.DialogMessage" ), message, true );
        etd.setReadOnly();
        etd.setModal();
        etd.open();
      } else {
        final Dialog errorDlg = new SimpleMessageDialog( parentDialog.getShell(),
          BaseMessages.getString( PKG, "System.Dialog.Error.Title" ),
          BaseMessages.getString( PKG, "GetFieldsSampleDataDialog.ScanResults.Error.Message" ), MessageDialog.ERROR );
        errorDlg.open();
      }
    }
  }
}
 
Example 2
Source Project: hop   File: ActionPipelineDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void ok() {
    if (Utils.isEmpty(wName.getText())) {
        final Dialog dialog = new SimpleMessageDialog(shell,
                BaseMessages.getString(PKG, "System.TransformActionNameMissing.Title"),
                BaseMessages.getString(PKG, "System.ActionNameMissing.Msg"), MessageDialog.ERROR);
        dialog.open();
        return;
    }
    action.setName(wName.getText());

    try {
        getInfo(action);
    } catch (HopException e) {
        // suppress exceptions at this time - we will let the runtime report on any errors
    }
    action.setChanged();
    dispose();
}
 
Example 3
protected void openErrorDialog(final Display display, final String javaVersion) {
    final Shell shell = new Shell(display);
    try {
        final Version version = Version.parseVersion(ProductVersion.CURRENT_VERSION);
        final String uriWithProductVersion = ONLINE_DOC_REQUIREMENTS + version.getMajor() + "."
                + version.getMinor();
        final URI uri = new URI(uriWithProductVersion);
        final MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell,
                Messages.incompatibleJavaVersionTitle, null, String.format(
                        Messages.incompatibleJavaVersionMessage,
                        org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion,
                        "Java 1.8 and Java 11."),
                MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL },
                0,
                uri);
        messageDialog.open();
    } catch (final URISyntaxException e) {
        BonitaStudioLog.error(e);
    } finally {
        shell.dispose();
    }
}
 
Example 4
protected void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    final Dialog dialog = new SimpleMessageDialog( shell,
      BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ),
      BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ), MessageDialog.ERROR );
    dialog.open();
    return;
  }
  // Check if all parameters have names. If so, continue on.
  if ( parameterTableHelper.checkParams( shell ) ) {
    return;
  }

  jobEntry.setName( wName.getText() );

  try {
    getInfo( jobEntry );
  } catch ( KettleException e ) {
    // suppress exceptions at this time - we will let the runtime report on any errors
  }
  jobEntry.setChanged();
  dispose();
}
 
Example 5
protected void handleOk( final int samples ) {
  if ( samples >= 0 ) {
    String message = parentDialog.loadFields( parentDialog.getPopulatedMeta(), samples, reloadAllFields );
    if ( wCheckbox != null && wCheckbox.getSelection() ) {
      if ( StringUtils.isNotBlank( message ) ) {
        final EnterTextDialog etd =
          new EnterTextDialog( parentDialog.getShell(),
            BaseMessages.getString( PKG, "System.GetFields.ScanResults.DialogTitle" ),
            BaseMessages.getString( PKG, "System.GetFields.ScanResults.DialogMessage" ), message, true );
        etd.setReadOnly();
        etd.setModal();
        etd.open();
      } else {
        final Dialog errorDlg = new SimpleMessageDialog( parentDialog.getShell(),
          BaseMessages.getString( PKG, "System.Dialog.Error.Title" ),
          BaseMessages.getString( PKG, "System.GetFields.ScanResults.Error.Message" ), MessageDialog.ERROR );
        errorDlg.open();
      }
    }
  }
}
 
Example 6
Source Project: hop   File: PartitionSchemaDialog.java    License: 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 7
Source Project: hop   File: DatabaseDialog.java    License: 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 8
/**
 * Find a browser to open url
 */
private void findBrowser() {
  MessageDialog md = new MessageDialog(SWTUtilities.getShell(), "No browsers found", null, null, MessageDialog.ERROR,
      new String[] { "Ok" }, 0) {

    @Override
    protected Control createMessageArea(Composite parent) {
      super.createMessageArea(parent);
      Link link = new Link(parent, SWT.NONE);

      link.setText("There are no browsers defined, please add one (Right-click on URL -> "
          + "Open with -> Add a Browser, or <a href=\"#\">Window -> Preferences -> General -> Web Browser</a>).");
      link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          PreferenceDialog dialog = PreferencesUtil
              .createPreferenceDialogOn(Display.getCurrent().getActiveShell(),
                  "org.eclipse.ui.browser.preferencePage", new String[] { "org.eclipse.ui.browser.preferencePage" },
                  null);

          if (dialog != null) {
            dialog.open();
          }
        }
      });
      return parent;
    }
  };
  md.open();
}
 
Example 9
Source Project: msf4j   File: MSF4JProjectImporter.java    License: Apache License 2.0 5 votes vote down vote up
public void importMSF4JProject(MSF4JProjectModel msf4jProjectModel, String projectName, File pomFile,
		IProgressMonitor monitor) throws CoreException {
	String operationText;
	Set<MavenProjectInfo> projectSet = null;
	if (pomFile.exists()) {

		IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
		MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
		LocalProjectScanner scanner = new LocalProjectScanner(
				ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), //
				projectName, false, mavenModelManager);
		operationText = "Scanning maven project.";
		monitor.subTask(operationText);
		try {
			scanner.run(new SubProgressMonitor(monitor, 15));
			projectSet = configurationManager.collectProjects(scanner.getProjects());
			for (MavenProjectInfo projectInfo : projectSet) {
				if (projectInfo != null) {
					saveMavenParentInfo(projectInfo);
				}
			}
			ProjectImportConfiguration configuration = new ProjectImportConfiguration();
			operationText = "importing maven project.";
			monitor.subTask(operationText);
			if (projectSet != null && !projectSet.isEmpty()) {
				List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectSet,
						configuration, new SubProgressMonitor(monitor, 60));
			}
		} catch (InterruptedException | IOException | XmlPullParserException e) {
			Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
			MessageDialog errorDialog = new MessageDialog(shell, ERROR_TAG, null,
					"Unable to import the project, Error occurred while importing the generated project.",
					MessageDialog.ERROR, new String[] { OK_BUTTON }, 0);
			errorDialog.open();
		}

	} else {
	}
}
 
Example 10
/**
 * Log the status and inform the user about a misbehaving extension.
 *
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
	JavaPlugin.log(status);
       String title= JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
       CompletionProposalCategory category= descriptor.getCategory();
       IContributor culprit= descriptor.getContributor();
       Set<String> affectedPlugins= getAffectedContributors(category, culprit);

	final String avoidHint;
	final String culpritName= culprit == null ? null : culprit.getName();
	if (affectedPlugins.isEmpty())
		avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()});
	else
		avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});

	String message= status.getMessage();
       // inlined from MessageDialog.openError
       MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
       	@Override
		protected Control createCustomArea(Composite parent) {
       		Link link= new Link(parent, SWT.NONE);
       		link.setText(avoidHint);
       		link.addSelectionListener(new SelectionAdapter() {
       			@Override
				public void widgetSelected(SelectionEvent e) {
       				PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
       			}
       		});
       		GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
       		gridData.widthHint= this.getMinimumMessageWidth();
			link.setLayoutData(gridData);
       		return link;
       	}
       };
       dialog.open();
}
 
Example 11
Source Project: saros   File: DialogUtils.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Opens a MessageDialog of the type {@link MessageDialog#ERROR} and dispatches a call to
 * forceActive (which gives a visual hint on the taskbar that the application wants focus).
 *
 * @param shell the parent shell
 * @param dialogTitle the dialog title, or <code>null</code> if none
 * @param dialogMessage the dialog message
 * @return
 */
public static int openErrorMessageDialog(Shell shell, String dialogTitle, String dialogMessage) {
  MessageDialog md =
      new MessageDialog(
          shell,
          dialogTitle,
          null,
          dialogMessage,
          MessageDialog.ERROR,
          new String[] {IDialogConstants.OK_LABEL},
          0);
  return openWindow(md);
}
 
Example 12
Source Project: goclipse   File: SWTUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static int statusLevelToMessageDialogKing(StatusLevel statusLevel) {
	switch (statusLevel) {
	case ERROR: return MessageDialog.ERROR;
	case WARNING: return MessageDialog.WARNING;
	case INFO: return MessageDialog.INFORMATION;
	case OK: return MessageDialog.OK;
	}
	throw assertFail();
}
 
Example 13
private static int dialogImageType(MultiStatus status) {
    switch (status.getSeverity()) {
        case IStatus.ERROR:
            return MessageDialog.ERROR;
        case IStatus.WARNING:
            return MessageDialog.WARNING;
        case IStatus.INFO:
        default:
            return MessageDialog.INFORMATION;
    }
}
 
Example 14
public void ok() {
  getInfo();

  if ( !partitionSchema.getName().equals( originalSchema.getName() ) ) {
    if ( DialogUtils.objectWithTheSameNameExists( partitionSchema, existingSchemas ) ) {
      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.setNumberOfPartitionsPerSlave( wNumber.getText() );
  originalSchema.setChanged();

  ok = true;

  dispose();
}
 
Example 15
public void ok() {
  getInfo();

  if ( !slaveServer.getName().equals( originalServer.getName() ) ) {
    if ( DialogUtils.objectWithTheSameNameExists( slaveServer, existingServers ) ) {
      String title = BaseMessages.getString( PKG, "SlaveServerDialog.SlaveServerNameExists.Title" );
      String message =
          BaseMessages.getString( PKG, "SlaveServerDialog.SlaveServerNameExists", slaveServer.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;
    }
  }

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

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

  originalServer.setMaster( slaveServer.isMaster() );

  originalServer.setSslMode( slaveServer.isSslMode() );

  originalServer.setChanged();

  ok = true;

  dispose();
}
 
Example 16
Source Project: pentaho-kettle   File: DatabaseDialog.java    License: 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 17
Source Project: hop   File: HopServerDialog.java    License: 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 18
public void run( )
{
	Object selection = getSelection( );
	if ( selection instanceof StructuredSelection )
	{
		selection = ( (StructuredSelection) selection ).getFirstElement( );
	}
	if ( selection instanceof OdaDataSourceHandle )
	{
		try
		{
			DesignSessionRequest designSessionRequest = DTPUtil.getInstance( )
					.createDesignSessionRequest( (OdaDataSourceHandle) selection );
			
			if ( designSessionRequest.getDataSourceDesign( )
					.hasLinkToProfile( ) )
			{
				MessageDialog errorDialog = new MessageDialog( UIUtil.getDefaultShell( ),
						Messages.getString( "datasource.exprotToCP.title" ),
						null,
						Messages.getFormattedString( "datasource.exportToCP.error.alreadyExported",
								new Object[]{
									( (OdaDataSourceHandle) selection ).getName( )
								} ),
						MessageDialog.ERROR,
						new String[]{
							BUTTON_OK
						},
						0 );

				errorDialog.open( );
				return;
			}
			ExportDataSourceDialog dialog = new ExportDataSourceDialog( PlatformUI.getWorkbench( )
					.getDisplay( )
					.getActiveShell( ),
					Messages.getString( "datasource.exprotToCP.title" ),
					(DataSourceHandle) selection );
			
			if ( dialog.open( ) == Dialog.OK )
			{
				OdaDesignSession session = DataSourceDesignSession.convertDesignToLinkedProfile( designSessionRequest,
						dialog.getProfileName( ),
						dialog.isExternalToCP( ),
						dialog.doesCreateProfileStore( ),
						PlatformUI.getWorkbench( )
								.getDisplay( )
								.getActiveShell( ) );
				DTPUtil.getInstance( )
						.updateDataSourceHandle( session.getResponse( ),
								session.getRequestDataSourceDesign( ),
								(OdaDataSourceHandle) selection );
			}
		}
		catch ( Exception ex )
		{
			ExceptionHandler.handle( ex );
		}
	}
}
 
Example 19
Source Project: Pydev   File: PyDialogHelpers.java    License: 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 20
public void ok() {
  getInfo();

  if ( !clusterSchema.getName().equals( originalSchema.getName() ) ) {
    if ( DialogUtils.objectWithTheSameNameExists( clusterSchema, existingSchemas ) ) {
      String title = BaseMessages.getString( PKG, "ClusterSchemaDialog.ClusterSchemaNameExists.Title" );
      String message =
          BaseMessages.getString( PKG, "ClusterSchemaDialog.ClusterSchemaNameExists", clusterSchema.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( clusterSchema.getName() );
  originalSchema.setBasePort( clusterSchema.getBasePort() );
  originalSchema.setSocketsBufferSize( clusterSchema.getSocketsBufferSize() );
  originalSchema.setSocketsFlushInterval( clusterSchema.getSocketsFlushInterval() );
  originalSchema.setSocketsCompressed( clusterSchema.isSocketsCompressed() );
  originalSchema.setDynamic( clusterSchema.isDynamic() );
  originalSchema.setSlaveServers( clusterSchema.getSlaveServers() );
  originalSchema.setChanged();

  ok = true;

  // Debug: dynamic lis names/urls of slaves on the console
  //
  /*
   * if (originalSchema.isDynamic()) { // Find a master that is available // List<SlaveServer> dynamicSlaves = null;
   * for (SlaveServer slave : originalSchema.getSlaveServers()) { if (slave.isMaster() && dynamicSlaves==null) { try {
   * List<SlaveServerDetection> detections = slave.getSlaveServerDetections(); dynamicSlaves = new
   * ArrayList<SlaveServer>(); for (SlaveServerDetection detection : detections) { if (detection.isActive()) {
   * dynamicSlaves.add(detection.getSlaveServer());
   * logBasic("Found dynamic slave : "+detection.getSlaveServer().getName
   * ()+" --> "+detection.getSlaveServer().getServerAndPort()); } } } catch (Exception e) {
   * logError("Unable to contact master : "+slave.getName()+" --> "+slave.getServerAndPort(), e); } } } }
   */

  dispose();
}