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:skillpro.vc.ui.VCStartStopHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    if (VCSynchronizeHandler.getInput() == null) {
        MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShellChecked(event),
                "Synchnorization not configured!", null, "Please configure the synchronization and try again",
                MessageDialog.ERROR, new String[] { "OK" }, 0);
        dialog.open();//  w  w  w . jav  a 2  s .c o m
        return null;
    }
    if (synchronizationJob == null) {
        synchronizationJob = new Job("Synchrnizing with VIS...") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                while (!monitor.isCanceled()) {
                    for (Pair<FactoryNode, Asset> pair : VCSynchronizeHandler.getInput()) {
                        FactoryNode firstElement = pair.getFirstElement();
                        Asset secondElement = pair.getSecondElement();

                        if (firstElement != null && secondElement != null) {
                            Vector3d position = new Vector3d();
                            do {
                                position.x += firstElement.getCurrentCoordinates().x;
                                position.y += firstElement.getCurrentCoordinates().y;
                                position.z += firstElement.getCurrentCoordinates().z;
                                firstElement = firstElement.getParent();
                            } while (firstElement != null);
                            System.out.println(position);
                            // x, y are exchanged! - undone now
                            secondElement.setWorldPositionMatrixSkillPro(
                                    new double[] { position.y, position.x, position.z });
                        }
                    }
                    try {
                        Thread.sleep(1000);
                        System.out.println("Synchronizing...");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                monitor.done();
                return org.eclipse.core.runtime.Status.OK_STATUS;
            }
        };

        synchronizationJob.setUser(false);
        synchronizationJob.schedule();

    } else {
        if (synchronizationJob.getState() == Job.RUNNING) {
            synchronizationJob.cancel();
        } else {
            synchronizationJob.schedule();
        }
    }

    return null;
}

From source file:slingshot.wizards.widgets.MyWizardNewFileCreationPage.java

License:Open Source License

/**
 * Creates a new file resource in the selected container and with the
 * selected name. Creates any missing resource containers along the path;
 * does nothing if the container resources already exist.
 * <p>//from   w  w  w  . j  a  v  a  2s.com
 * In normal usage, this method is invoked after the user has pressed Finish
 * on the wizard; the enablement of the Finish button implies that all
 * controls on on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new file once it has been successfully
 * created; subsequent invocations of this method will answer the same file
 * resource without attempting to create it again.
 * </p>
 * <p>
 * This method should be called within a workspace modify operation since it
 * creates resources.
 * </p>
 *
 * @return the created file resource, or <code>null</code> if the file was
 *         not created
 */
public IFile createNewFile() {
    if (newFile != null) {
        return newFile;
    }

    // create the new file and cache it if successful

    IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFilePath = containerPath.append(resourceGroup.getResource());

    final IFile newFileHandle = createFileHandle(newFilePath);
    final InputStream initialContents = getInitialContents();

    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            CreateFileOperation op = new CreateFileOperation(newFileHandle, linkTargetPath, initialContents,
                    IDEWorkbenchMessages.WizardNewFileCreationPage_title);
            try {
                // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
                // directly execute the operation so that the undo state is
                // not preserved.  Making this undoable resulted in too many
                // accidental file deletions.
                op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
            } catch (final ExecutionException e) {
                getContainer().getShell().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        if (e.getCause() instanceof CoreException) {
                            ErrorDialog.openError(getContainer().getShell(), // Was
                                    // Utilities.getFocusShell()
                                    IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle, null, // no special
                                    // message
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$
                            MessageDialog.openError(getContainer().getShell(),
                                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                                    NLS.bind(
                                            IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                                            e.getCause().getMessage()));
                        }
                    }
                });
            }
        }
    };
    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        // Execution Exceptions are handled above but we may still get
        // unexpected runtime errors.
        IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                        e.getTargetException().getMessage()),
                SWT.SHEET);

        return null;
    }

    newFile = newFileHandle;

    return newFile;
}

From source file:slingshot.wizards.widgets.MyWizardNewFolderMainPage.java

License:Open Source License

/**
 * Creates a new folder resource in the selected container and with the
 * selected name. Creates any missing resource containers along the path;
 * does nothing if the container resources already exist.
 * <p>/*from  w ww .j  ava  2  s .c o  m*/
 * In normal usage, this method is invoked after the user has pressed Finish
 * on the wizard; the enablement of the Finish button implies that all
 * controls on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new folder once it has been successfully
 * created; subsequent invocations of this method will answer the same
 * folder resource without attempting to create it again.
 * </p>
 * <p>
 * This method should be called within a workspace modify operation since it
 * creates resources.
 * </p>
 *
 * @return the created folder resource, or <code>null</code> if the folder
 *         was not created
 */
public IFolder createNewFolder() {
    if (newFolder != null) {
        return newFolder;
    }

    // create the new folder and cache it if successful
    final IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFolderPath = containerPath.append(resourceGroup.getResource());
    final IFolder newFolderHandle = createFolderHandle(newFolderPath);

    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            AbstractOperation op;
            op = new CreateFolderOperation(newFolderHandle, null, false, filterList,
                    IDEWorkbenchMessages.WizardNewFolderCreationPage_title);
            try {
                // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
                // directly execute the operation so that the undo state is
                // not preserved.  Making this undoable can result in accidental
                // folder (and file) deletions.
                op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
            } catch (final ExecutionException e) {
                getContainer().getShell().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        if (e.getCause() instanceof CoreException) {
                            ErrorDialog.openError(getContainer().getShell(), // Was Utilities.getFocusShell()
                                    IDEWorkbenchMessages.WizardNewFolderCreationPage_errorTitle, null, // no special message
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            IDEWorkbenchPlugin.log(getClass(), "createNewFolder()", e.getCause()); //$NON-NLS-1$
                            MessageDialog.openError(getContainer().getShell(),
                                    IDEWorkbenchMessages.WizardNewFolderCreationPage_internalErrorTitle,
                                    NLS.bind(IDEWorkbenchMessages.WizardNewFolder_internalError,
                                            e.getCause().getMessage()));
                        }
                    }
                });
            }
        }
    };

    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        // ExecutionExceptions are handled above, but unexpected runtime
        // exceptions and errors may still occur.
        IDEWorkbenchPlugin.log(getClass(), "createNewFolder()", e.getTargetException()); //$NON-NLS-1$
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                IDEWorkbenchMessages.WizardNewFolderCreationPage_internalErrorTitle,
                NLS.bind(IDEWorkbenchMessages.WizardNewFolder_internalError,
                        e.getTargetException().getMessage()),
                SWT.SHEET);
        return null;
    }

    newFolder = newFolderHandle;

    return newFolder;
}

From source file:spritey.ui.wizards.SpriteSheetWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    isOverwrite = saveAsPage.isOverwrite();

    OverwriteQuery callback = new OverwriteQuery() {
        @Override/*from  w  w w.  j  a v a 2s . c om*/
        public int queryOverwrite(String path) {
            if (isOverwrite) {
                return OverwriteQuery.ALL;
            }

            String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL };

            File file = new File(path);
            String message = NLS.bind(Messages.SAVE_AS_OVERWRITE_FILE, file.getName(), file.getParent());
            final MessageDialog dialog = new MessageDialog(getShell(), Messages.SPRITE_SHEET_WIZARD_TITLE, null,
                    message, MessageDialog.QUESTION, buttons, 0) {
                @Override
                protected int getShellStyle() {
                    return super.getShellStyle() | SWT.SHEET;
                }
            };

            // This method is called from a non-UI thread, therefore,
            // opening dialog has to be wrapped into runnable and executed
            // in the UI thread.
            getShell().getDisplay().syncExec(new Runnable() {
                @Override
                public void run() {
                    dialog.open();
                }
            });
            return dialog.getReturnCode();
        }
    };

    try {
        SaveSheetOperation op = new SaveSheetOperation(newSheetPage.getConstraints(), newSheetPage.getSheet(),
                saveAsPage.getImageFile(), saveAsPage.getMetadataFile(), callback);
        getContainer().run(true, true, op);

        Shell parent = getContainer().getShell();
        IStatus status = op.getStatus();

        if (!status.isOK()) {
            // To make dialogs consistent throughout the application,
            // display a custom error dialog with details button only when
            // there are multiple problems. Otherwise display an OS native
            // dialog.
            if (status.isMultiStatus()) {
                ErrorDialog.openError(parent, Messages.SPRITE_SHEET_WIZARD_TITLE, null, status);
            } else {
                MessageDialog.open(MessageDialog.ERROR, parent, Messages.SPRITE_SHEET_WIZARD_TITLE,
                        status.getMessage(), SWT.SHEET);
            }
        } else {
            MessageDialog.open(MessageDialog.INFORMATION, parent, Messages.SPRITE_SHEET_WIZARD_TITLE,
                    Messages.SPRITE_SHEET_WIZARD_BUILT_SUCCESSFULLY, SWT.SHEET);
        }
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        throw new InternalError("Error occurred during save operation.", e);
    }
    return false;
}

From source file:thahn.java.agui.ide.eclipse.wizard.AguiPlugin.java

public static void displayError(String title, String message) {
    MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR,
            new String[] { "Ok", "Cancel" }, 0);
    dialog.open();/*from   ww w .j a v  a 2  s.co  m*/
}

From source file:tinyos.dlrc.jobs.InvokeMakeJob.java

License:Open Source License

public void execShouldContinue() {
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            IStatus ready = target.ready();
            if (ready != null) {
                int type = -1;
                String title = null;
                String message = null;

                switch (ready.getSeverity()) {
                case IStatus.ERROR:
                    title = "Error";
                    message = "an error";
                    type = MessageDialog.ERROR;
                    break;
                case IStatus.WARNING:
                    title = "Warning";
                    message = "a warning";
                    type = MessageDialog.WARNING;
                    break;
                case IStatus.INFO:
                    title = "Info";
                    message = "a message";
                    type = MessageDialog.INFORMATION;
                    break;
                }/*from www  . j  a  va 2  s . c o m*/

                if (type >= 0) {
                    message = "There is " + message + " associated with this make-option:\n\n" + "'"
                            + ready.getMessage() + "'\n\n" + "Would you like to continue anyway?";

                    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), title, null,
                            message, type,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);

                    if (dialog.open() != 0) {
                        shouldContinue = false;
                    }
                }
            }
        }
    });
}

From source file:tinyos.dlrc.make.dialog.pages.IncludePage.java

License:Open Source License

private void performeAddDirectory() {
    DirectoryDialog dialog = getDirectoryDialog();

    TableEntry selection = getSelectedEntry();
    int count = contentProvider.getSize();

    if (selection == null && count > 0)
        selection = contentProvider.getEntry(count - 1);

    if (selection == null)
        dialog.setFilterPath(null);//from  w  w w  .j av a 2 s.c o  m
    else
        dialog.setFilterPath(selection.path);

    while (true) {
        String directory = dialog.open();
        if (directory != null) {
            File directoryFile = new File(directory);
            directory = information.getEnvironment().systemToModel(directoryFile);
            if (directory == null) {
                MessageDialog errorDialog = new MessageDialog(getControl().getShell(), "Add Directory", null,
                        "The selected directory cannot be accessed by the tinyos tool chain.",
                        MessageDialog.ERROR, new String[] { "Browse", "Cancel" }, 0);
                int result = errorDialog.open();
                if (result != 0)
                    break;
            } else {
                contentProvider.add(new TableEntry(directory));
                contentChanged();
                break;
            }
        } else {
            break;
        }
    }
}

From source file:tinyos.dlrc.make.dialog.pages.IncludePage.java

License:Open Source License

private void performeAddFile() {
    FileDialog dialog = getFileDialog();
    TableEntry selection = getSelectedEntry();
    int count = contentProvider.getSize();

    if (selection == null && count > 0)
        selection = contentProvider.getEntry(count - 1);

    if (selection == null)
        dialog.setFilterPath(null);//w ww. ja v  a 2s.  co m
    else
        dialog.setFilterPath(selection.path);

    while (true) {
        String file = dialog.open();
        if (file == null)
            break;

        file = information.getEnvironment().systemToModel(new File(file));
        if (file == null) {
            MessageDialog errorDialog = new MessageDialog(getControl().getShell(), "Add File", null,
                    "The selected file cannot be accessed by the tinyos tool chain.", MessageDialog.ERROR,
                    new String[] { "Browse", "Cancel" }, 0);
            int result = errorDialog.open();
            if (result != 0)
                break;
        } else {
            contentProvider.add(new TableEntry(file));
            contentChanged();
            break;
        }
    }
}

From source file:tinyos.dlrc.make.dialog.pages.IncludePage.java

License:Open Source License

private void performeEdit() {
    TableEntry selected = getSelectedEntry();
    if (selected != null) {
        String path = selected.path;
        File file = information.getEnvironment().modelToSystem(path);

        if (file.isFile()) {
            FileDialog dialog = getFileDialog();
            dialog.setFilterPath(file.getParent());
            dialog.setFileName(file.getName());

            while (true) {
                String selection = dialog.open();
                if (selection == null)
                    break;

                selection = information.getEnvironment().systemToModel(new File(selection));
                if (selection == null) {
                    MessageDialog errorDialog = new MessageDialog(getControl().getShell(), "Edit File", null,
                            "The selected file cannot be accessed by the tinyos tool chain.",
                            MessageDialog.ERROR, new String[] { "Browse", "Cancel" }, 0);
                    int result = errorDialog.open();
                    if (result != 0)
                        break;
                } else {
                    selected.path = selection;
                    contentProvider.refresh(selected);
                    contentChanged();//from   ww  w. j  a  v  a  2 s.com
                    break;
                }
            }
        } else {
            DirectoryDialog dialog = getDirectoryDialog();
            dialog.setFilterPath(file.getAbsolutePath());
            while (true) {
                String directory = dialog.open();
                if (directory == null)
                    break;

                directory = information.getEnvironment().systemToModel(new File(directory));
                if (directory == null) {
                    MessageDialog errorDialog = new MessageDialog(getControl().getShell(), "Add Directory",
                            null, "The selected directory cannot be accessed by the tinyos tool chain.",
                            MessageDialog.ERROR, new String[] { "Browse", "Cancel" }, 0);
                    int result = errorDialog.open();
                    if (result != 0)
                        break;
                } else {
                    selected.path = directory;
                    contentProvider.refresh(selected);
                    contentChanged();
                    break;
                }
            }
        }
    }
}

From source file:uk.ac.diamond.scisoft.arpes.calibration.wizards.GoldCalibrationPageFive.java

License:Open Source License

@Override
public boolean runProcess() throws InterruptedException {
    System.out.println("Page 5");
    try {//from  ww  w .j  a  va 2  s.  c o m
        getContainer().run(true, true, saveWithProgress);
    } catch (InvocationTargetException e) {
        logger.error(e.getMessage());
        return false;
    } catch (InterruptedException e) {
        MessageDialog dialog = new MessageDialog(getShell(), "Saving process interrupted", null, e.getMessage(),
                MessageDialog.ERROR, new String[] { "OK" }, 0);
        dialog.open();
        return false;
    }
    return true;
}