Example usage for org.eclipse.jface.dialogs MessageDialog ERROR

List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:org.mwc.debrief.core.operations.ExportToFlatFile.java

License:Open Source License

@Override
public void executeExport(final WatchableList primaryTrack, final WatchableList[] secondaryTracks,
        final TimePeriod period) {
    // sort out the destination file name
    String filePath = null;/*  w  w w . ja  v  a2s.co  m*/
    // sort out what type of file it is
    String sensor1Type = null;
    String sensor2Type = null;

    // don't forget the sensor depths
    Double s1fwd = null;
    Double s1aft = null;
    Double s2fwd = null;
    Double s2aft = null;

    // and speed of sound
    Double speedOfSoundMS = null;

    // the protective marking on the data
    String protMarking = null;

    // the name of the mission
    String serialName = null;

    // just check that at least one of the sensors has an offset
    final TrackWrapper primary = (TrackWrapper) primaryTrack;
    final BaseLayer sensors = primary.getSensors();
    final Enumeration<Editable> sList = sensors.elements();
    boolean foundOne = false;
    int sensorCount = 0;
    while (sList.hasMoreElements()) {
        final SensorWrapper thisS = (SensorWrapper) sList.nextElement();

        // is it visible?
        if (thisS.getVisible())
            sensorCount++;

        // does it have an array offset
        if (thisS.getSensorOffset() != null)
            if (thisS.getSensorOffset().getValue() != 0)
                foundOne = true;
    }

    // right, special handling depending on run mode
    if (sensorCount == 0) {
        final Shell shell = Display.getCurrent().getActiveShell();
        final String title = "Export flat file";
        final Image image = null;
        final String message = "At least one primary sensor must be visible";
        final int imageType = MessageDialog.ERROR; // check the user knows what
                                                   // he's
                                                   // doing
        final MessageDialog dl = new MessageDialog(shell, title, image, message, imageType, null, 0);
        dl.open();
        return;

    }
    if (_fileVersion.equals(FlatFileExporter.INITIAL_VERSION)) {
        // ok, we can only have one sensor visible
        if (sensorCount > 1) {

            final Shell shell = Display.getCurrent().getActiveShell();
            final String title = "Export flat file";
            final String message = "Only one of the sensors on the primary track must be visible";
            // pop it up
            MessageDialog.openError(shell, title, message);
            return;
        }
    } else {
        // ok, we can only have two sensors visible
        if (sensorCount > 2) {
            final Shell shell = Display.getCurrent().getActiveShell();
            final String title = "Export flat file";
            final String message = "Only one or two of the sensors on the primary track must be visible";
            // pop it up
            MessageDialog.openError(shell, title, message);
            return;
        }
    }

    // and do the warning for no array offsets found

    if (!foundOne) {
        final Shell shell = Display.getCurrent().getActiveShell();
        final String title = "Export flat file";
        final Image image = null;
        final String message = "None of the sensor data has a towed array offset applied.\nDo you wish to continue?";
        final String[] labels = new String[] { "Yes", "No" };
        final int index = 1;
        final int imageType = MessageDialog.QUESTION; // check the user knows what he's
                                                      // doing
        final MessageDialog dl = new MessageDialog(shell, title, image, message, imageType, labels, index);
        final int res = dl.open();
        if (res == MessageDialog.CANCEL)
            return;
    }

    // prepare the export wizard
    final SimplePageListWizard wizard = new SimplePageListWizard();
    wizard.addWizard(new FlatFilenameWizardPage(_fileVersion, sensorCount));
    final WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.create();
    dialog.open();
    // did it work?
    if (dialog.getReturnCode() == WizardDialog.OK) {
        final FlatFilenameWizardPage exportPage = (FlatFilenameWizardPage) wizard
                .getPage(FlatFilenameWizardPage.PAGENAME);
        if (exportPage != null) {
            if (exportPage.isPageComplete()) {
                filePath = exportPage.getFileName();
                sensor1Type = exportPage.getSensor1Type();
                sensor2Type = exportPage.getSensor2Type();
                protMarking = exportPage.getProtMarking();
                serialName = exportPage.getSerialName();

                s1fwd = exportPage.getSensor1Fwd();
                s1aft = exportPage.getSensor1Aft();
                s2fwd = exportPage.getSensor2Fwd();
                s2aft = exportPage.getSensor2Aft();
                speedOfSoundMS = exportPage.getSpeedOfSound();

                final FlatFileExporter ff = new FlatFileExporter();
                final String theData = ff.export(primaryTrack, secondaryTracks, period, sensor1Type,
                        sensor2Type, s1fwd, s1aft, s2fwd, s2aft, _fileVersion, protMarking, serialName,
                        speedOfSoundMS);

                // now write the data to file
                final String HOST_NAME = primaryTrack.getName();
                final String HOST_DATE = MWC.Utilities.TextFormatting.FormatRNDateTime
                        .toMediumString(period.getStartDTG().getDate().getTime());
                final String fileName = filePath + File.separator + HOST_NAME + "_" + HOST_DATE + "."
                        + FlatFilenameWizardPage.FILE_SUFFIX;
                BufferedWriter out = null;
                try {
                    out = new BufferedWriter(new FileWriter(fileName));
                    out.write(theData);
                    CorePlugin.showMessage("Export to SAM", "Tracks successfullly exported to SAM format");
                } catch (final FileNotFoundException e) {
                    DebriefPlugin.logError(Status.ERROR, "Unable to find output file:" + fileName, e);
                } catch (final IOException e) {
                    DebriefPlugin.logError(Status.ERROR, "Whilst writing to output file:" + fileName, e);
                } finally {
                    try {
                        if (out != null)
                            out.close();
                    } catch (final IOException e) {
                        DebriefPlugin.logError(Status.ERROR, "Whilst closing output file:" + fileName, e);
                    }

                }

            } else {
                CorePlugin.showMessage("Export to SAM", "Please try again, not all fields were entered");

            }
        }

    }
}

From source file:org.netxms.ui.eclipse.tools.MessageDialogHelper.java

License:Open Source License

/**
 * Convenience method to open a standard error dialog.
 * /*from   ww  w . j  a  v  a2 s.  c om*/
 * @param parent the parent shell of the dialog, or <code>null</code> if none
 * @param title the dialog's title, or <code>null</code> if none
 * @param message the message
 */
public static void openError(Shell parent, String title, String message) {
    open(MessageDialog.ERROR, parent, title, message);
}

From source file:org.neuro4j.studio.core.diagram.wizards.customblock.CustomBlockNewWizard.java

License:Apache License

/**
 * This method is called when 'Finish' button is pressed in
 * the wizard. We will create an operation and run it
 * using wizard as execution context./* ww  w  .  j a  v a 2 s  .  c  o m*/
 */
public boolean performFinish() {
    IWorkspaceRunnable op = new IWorkspaceRunnable() {
        public void run(final IProgressMonitor monitor) throws CoreException, OperationCanceledException {

            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    try {
                        finishPage(monitor);

                    } catch (InterruptedException e) {
                        throw new OperationCanceledException(e.getMessage());

                    } catch (CoreException e) {
                        MessageDialog dialog = new MessageDialog(
                                fWorkbench.getActiveWorkbenchWindow().getShell(), "Error", null, e.getMessage(),
                                MessageDialog.ERROR, new String[] {}, 0);
                        int result = dialog.open();
                        throw new OperationCanceledException(e.getMessage());
                    }
                }
            });

        }
    };
    try {
        ISchedulingRule rule = null;
        Job job = Job.getJobManager().currentJob();
        if (job != null)
            rule = job.getRule();
        IRunnableWithProgress runnable = null;
        if (rule != null)
            runnable = new WorkbenchRunnableAdapter(op, rule, true);
        else
            runnable = new WorkbenchRunnableAdapter(op, getSchedulingRule());
        getContainer().run(true, true, runnable);
    } catch (InvocationTargetException e) {
        handleFinishException(getShell(), e);
        return false;
    } catch (InterruptedException e) {
        return false;
    }
    boolean res = true;
    if (res) {
        IResource resource = this.page.getModifiedResource();
        if (resource != null) {
            selectAndReveal(resource);
            if (this.fOpenEditorOnFinish) {
                openResource((IFile) resource);
            }
        }
    }
    return res;
}

From source file:org.neuro4j.studio.properties.sources.MapperPropertySource.java

License:Apache License

public void setPropertyValue(Object propName, Object value) {
    if (SOURCE.equals(propName)) {
        pair.setKey(value.toString());/*ww  w.j a v  a2s. c o m*/
    }
    if (TARGET.equals(propName)) {
        if (NameUtils.validateVarName(value.toString())) {
            pair.setValue(value.toString());
        } else {

            MessageDialog dialog = new MessageDialog(Neuro4jCorePlugin.getActiveWorkbenchShell(),
                    "Error message", null, "Propery value is not valid", MessageDialog.ERROR,
                    new String[] { "Ok" }, 0);
            int result = dialog.open();

            pair.setValue(pair.getValue());
            return;
        }

    }
    firePropertyChanged((String) propName, null, value);
}

From source file:org.openoffice.ide.eclipse.core.internal.model.SDK.java

License:LGPL

/**
 * {@inheritDoc}/*from  w  w w.j a  v  a2s.c o  m*/
 */
public Process runToolWithEnv(IProject pProject, IOOo pOOo, String pShellCommand, String[] pEnv,
        IProgressMonitor pMonitor) {

    Process process = null;

    try {
        if (null != pOOo) {

            // Get the environment variables and copy them. Needs Java 1.5
            String[] sysEnv = SystemHelper.getSystemEnvironement();

            String[] vars = mergeVariables(sysEnv, pEnv);

            vars = updateEnvironment(vars, pOOo);

            // Run only if the OS and ARCH are valid for the SDK
            if (null != vars) {
                File projectFile = pProject.getLocation().toFile();
                process = SystemHelper.runTool(pShellCommand, vars, projectFile);
            }
        }

    } catch (IOException e) {
        // Error while launching the process 

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();

    } catch (SecurityException e) {
        // SubProcess creation unauthorized

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();
    } catch (Exception e) {
        PluginLogger.error(e.getMessage(), null);
    }

    return process;
}

From source file:org.overture.ide.ui.editor.core.VdmEditor.java

License:Open Source License

public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    fEditorSelectionChangedListener = new EditorSelectionChangedListener();
    fEditorSelectionChangedListener.install(getSelectionProvider());

    IEditorInput input = getEditorInput();
    IDocument doc = getDocumentProvider().getDocument(input);
    if (doc instanceof VdmDocument) {
        VdmDocument vdmDoc = (VdmDocument) doc;
        try {/*from  w w  w .  ja  va  2s  .  c o  m*/
            if (vdmDoc != null && vdmDoc.getSourceUnit() != null && !vdmDoc.getSourceUnit().hasParseTree()) {
                SourceParserManager.parseFile(vdmDoc.getSourceUnit());
            }
        } catch (CoreException e) {
            VdmUIPlugin.log("Faild to do initial parse of SourceUnit in editor", e);
        } catch (IOException e) {
            VdmUIPlugin.log("Faild to do initial parse of SourceUnit in editor", e);
        }

    } else {
        if (input instanceof FileStoreEditorInput) {
            MessageDialog d = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    "Error", null, "Cannot open a vdm file outside the workspace", MessageDialog.ERROR,
                    new String[] { "Ok" }, 0);
            d.open();

        }
        // FileStoreEditorInput fs = (FileStoreEditorInput) input;
        // IFileStore fileStore = EFS.getLocalFileSystem().getStore(
        // fs.getURI());
        //
        // if (!fileStore.fetchInfo().isDirectory()
        // && fileStore.fetchInfo().exists())
        // {
        // IWorkbench wb = PlatformUI.getWorkbench();
        // IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
        //
        // IWorkbenchPage page = win.getActivePage();
        //
        // try
        // {
        //
        // page
        // .openEditor(input,
        // EditorsUI.DEFAULT_TEXT_EDITOR_ID);
        // } catch (PartInitException e)
        // {
        // /* some code */
        // fileStore.toString();
        // }
        //
        // }
        // }

    }

    // IAnnotationModel model=
    // getDocumentProvider().getAnnotationModel(getEditorInput());
    // IDocument document =
    // getDocumentProvider().getDocument(getEditorInput());

    // if(model!=null && document !=null)
    // {
    // getSourceViewer().setDocument(document, model);
    // model.connect(document);

    // }

    // try
    // {
    // doSetInput(getEditorInput());
    // } catch (CoreException e)
    // {
    //
    // e.printStackTrace();
    // }
    // fEditorSelectionChangedListener= new
    // EditorSelectionChangedListener();
    // fEditorSelectionChangedListener.install(getSelectionProvider());
    //
    // if (isSemanticHighlightingEnabled())
    // installSemanticHighlighting();
    //
    // fBreadcrumb= createBreadcrumb();
    // fIsBreadcrumbVisible= isBreadcrumbShown();
    // if (fIsBreadcrumbVisible)
    // showBreadcrumb();
    //
    // PlatformUI.getWorkbench().addWindowListener(fActivationListener);

}

From source file:org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog.java

License:Apache License

public void ok() {
    getInfo();// w w  w.  ja  v  a2s  . c  o  m

    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();
}

From source file:org.pentaho.di.ui.cluster.dialog.SlaveServerDialog.java

License:Apache License

public void ok() {
    getInfo();/* ww  w .  j  av  a 2 s. c om*/

    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();
}

From source file:org.pentaho.di.ui.core.database.dialog.DatabaseDialog.java

License:Apache License

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();//w  w  w.  j  a v a  2  s  .  co m
}

From source file:org.pentaho.di.ui.job.entries.trans.JobEntryTransDialog.java

License:Apache License

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();/*w  w  w  .j  a  v  a2  s.com*/
        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();
}