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:com.salesforce.ide.core.internal.utils.DialogUtils.java

License:Open Source License

public int abortOkMessage(String title, String message) {
    return abortOkMessage(title, message, MessageDialog.ERROR);
}

From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java

License:Open Source License

public int abortMessage(String title, String message) {
    // ok is the default
    MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR,
            new String[] { IDialogConstants.ABORT_LABEL }, IDialogConstants.ABORT_ID);
    return dialog.open();
}

From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java

License:Open Source License

public void presentFetchExceptionDialog(Exception ex, IProgressMonitor monitor) throws Exception {
    if (ex instanceof RetrieveException || ex instanceof ServiceException || ex instanceof FactoryException
            || ex instanceof InvocationTargetException) {
        String exceptionMessage = ForceExceptionUtils.getExceptionMessage(ex);
        exceptionMessage = ForceExceptionUtils.getStrippedExceptionMessage(exceptionMessage);
        StringBuffer strBuff = new StringBuffer(Messages.getString("General.FetchError.message"));
        strBuff.append(":\n\n").append(exceptionMessage).append("\n\n")
                .append(Messages.getString("General.AbortOrContinue.message"));
        int action = abortContinueMessage("Fetch Error", strBuff.toString(), MessageDialog.ERROR);
        if (action == FIRST_BUTTON) {
            logger.info("Abort remote component fetch and project creation");
            throw new ForceProjectException(ex, "Unable to fetch components");
        }//  w  w w .ja va 2 s. c om
    } else {
        throw ex;
    }
}

From source file:com.salesforce.ide.ui.dialogs.HyperLinkMessageDialog.java

License:Open Source License

/**
 * Convenience method to open a standard error dialog.
 * //from w w  w.j  a  va 2  s.co m
 * @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) {
    HyperLinkMessageDialog dialog = new HyperLinkMessageDialog(parent, title, null, // accept
            // the
            // default
            // window
            // icon
            message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); // ok
    // is
    // the
    // default
    dialog.open();
    return;
}

From source file:com.salesforce.ide.ui.wizards.components.wsdl.Wsdl2apexWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*  ww w  .j a v  a  2s .c  o m*/
        getContainer().run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                exec();
            }
        });
    } catch (InvocationTargetException e) {
        MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(), MessageDialog.ERROR,
                new String[] { "Ok" }, 0);
        dialog.open();
        logger.error(e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(), MessageDialog.ERROR,
                new String[] { "Ok" }, 0);
        dialog.open();
        logger.error(e.getMessage());
    } catch (Exception e) {
        MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(), MessageDialog.ERROR,
                new String[] { "Ok" }, 0);
        dialog.open();
        logger.error(e.getMessage());
    }
    return true;
}

From source file:com.salesforce.ide.ui.wizards.components.wsdl.Wsdl2apexWizard.java

License:Open Source License

public void exec() {
    Display.getDefault().syncExec(new Runnable() {
        @Override//from w w  w  . j  a  v  a  2  s. c om
        public void run() {
            ApexClassWizard a;
            try {
                String[] arguements = new String[1];
                arguements[0] = convertPage.getAsyncTrue().toString(); //checks if we want async methods
                generator.generate(arguements);

                //we have all of the generated classes now
                Iterator<String> ii = generator.getAllClasses().iterator();
                Iterator<String> jj = generator.getAllClassNames().iterator();
                allPackages = ContainerDelegate.getInstance().getServiceLocator().getProjectService()
                        .getProjectPackageListInstance();
                while (ii.hasNext() && jj.hasNext()) //this loop here purely for checking if the class name is already used
                {
                    String classBody = ii.next().trim();
                    String className = jj.next().trim();
                    a = new ApexClassWizard(true, allPackages);

                    ApexClassWizardPage ap = new ApexClassWizardPage(a);
                    ApexClassModel apexClassModel = (ApexClassModel) ap.getComponentWizardModel();

                    a.init(currentWorkBench, initialSelection);

                    Component apexComponent = apexClassModel.getComponent();
                    apexComponent.setBodyFromTemplateString(classBody);
                    apexComponent.setName(className);
                    if (!ap.getComponentController().isNameUniqueLocalCheck()) {
                        throw new IOException("There is already a class named " + className);
                    }
                }

                Iterator<String> i = generator.getAllClasses().iterator();
                Iterator<String> j = generator.getAllClassNames().iterator();

                while (i.hasNext() && j.hasNext()) //this loop for creating apex classes by programmatically using the ApexClassWizard
                {
                    String classBody = i.next();
                    String className = j.next();
                    a = new ApexClassWizard(true, allPackages);

                    ApexClassWizardPage ap = new ApexClassWizardPage(a);
                    ApexClassModel apexClassModel = (ApexClassModel) ap.getComponentWizardModel();

                    a.init(currentWorkBench, initialSelection);

                    Component apexComponent = apexClassModel.getComponent();

                    //set the body and class name of the component
                    apexComponent.setBodyFromTemplateString(classBody);
                    apexComponent.setName(className);

                    if (!i.hasNext() && !j.hasNext()) {
                        //this is the last class we are creating for this wsdl, so we want to save the packagelist to the server
                        MultiClassComponentController c = (MultiClassComponentController) ap
                                .getComponentController();
                        c.setShouldSaveToServer(true);
                    }

                    if (ap.getComponentController().isNameUniqueLocalCheck()) {
                        a.executeCreateOperation();
                    }
                }

            } catch (ForceProjectException e) {
                MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(),
                        MessageDialog.ERROR, new String[] { "Ok" }, 0);
                dialog.open();
                logger.error(e.getMessage());
            } catch (IOException e) {
                MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(),
                        MessageDialog.ERROR, new String[] { "Ok" }, 0);
                dialog.open();
                logger.error(e.getMessage());
            } catch (CalloutException e) {
                MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(),
                        MessageDialog.ERROR, new String[] { "Ok" }, 0);
                dialog.open();
                logger.error(e.getMessage());
            } catch (Exception e) {
                if (e.getMessage() != null) {
                    MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(),
                            MessageDialog.ERROR, new String[] { "Ok" }, 0);
                    dialog.open();
                }
                logger.error(e.getMessage());
            }
        }
    });
}

From source file:com.salesforce.ide.ui.wizards.components.wsdl.Wsdl2apexWizardFindPage.java

License:Open Source License

@Override
public DynamicWizardPage getNextPage() {
    DynamicWizardPage nextPage = super.getNextPage();
    //only needs to generate the next page if the wsdl file location changes
    if (shouldGenerate) {
        shouldGenerate = false;/*from w  w  w. j a va2  s.  com*/
        String[] s = new String[] { getWsdlFileLocation() };
        try {
            Wsdl2apexWizard w = (Wsdl2apexWizard) this.getWizard();
            w.getApexGenerator().parse(s);
        } catch (Exception e) {
            MessageDialog dialog = new MessageDialog(null, "Error", null, e.getMessage(), MessageDialog.ERROR,
                    new String[] { "Ok" }, 0);
            dialog.open();
            logger.error(e.getMessage());
            return null;
        }
        nextPage.onEnterPage();
        return nextPage;
    }
    return nextPage;
}

From source file:com.salesforce.ide.ui.wizards.project.ProjectOrganizationPage.java

License:Open Source License

private int createOfflineAbortRetryMessage(String title, String message) {
    // retry is the default
    MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR,
            new String[] { "Create Offline", IDialogConstants.ABORT_LABEL, IDialogConstants.RETRY_LABEL },
            IDialogConstants.RETRY_ID);//from  ww w  .j  a va2s.  c om
    return dialog.open();
}

From source file:com.sap.netweaver.porta.ide.eclipse.server.ui.dialogs.PublishProblemDialog.java

License:Open Source License

private static int getImage(DeployResultStatus status) {
    switch (status) {
    case ERROR:/*  w  w  w  . java  2 s. co m*/
        return MessageDialog.ERROR;
    case WARNING:
        return MessageDialog.WARNING;
    default:
        return MessageDialog.NONE;
    }
}

From source file:com.simplifide.core.ui.wizard.other.NewFilePage.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 ww. ja va2s. 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 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

    final IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFilePath = containerPath.append(resourceGroup.getResource());
    final IFile newFileHandle = createFileHandle(newFilePath);
    final InputStream initialContents = getInitialContents();

    createLinkTarget();

    if (linkTargetPath != null) {
        // Not compatible with 3.5
        URI resolvedPath = linkTargetPath;//newFileHandle.getPathVariableManager().resolveURI(linkTargetPath);
        try {
            if (resolvedPath.getScheme() != null && resolvedPath.getSchemeSpecificPart() != null) {
                IFileStore store = EFS.getStore(resolvedPath);
                if (!store.fetchInfo().exists()) {
                    MessageDialog dlg = new MessageDialog(getContainer().getShell(), LINK_TITLE, null,
                            NLS.bind(LINK_NOTSURE, linkTargetPath), MessageDialog.QUESTION_WITH_CANCEL,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                    IDialogConstants.CANCEL_LABEL },
                            0);
                    int result = dlg.open();
                    if (result == Window.OK) {
                        store.getParent().mkdir(0, new NullProgressMonitor());
                        OutputStream stream = store.openOutputStream(0, new NullProgressMonitor());
                        stream.close();
                    }
                    if (result == 2)
                        return null;
                }
            }
        } catch (CoreException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        } catch (IOException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        }
    }

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