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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

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

License:Open Source License

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

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

License:Open Source License

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

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.MessageDialogRunnable.java

License:Open Source License

public void run() {
    MessageDialog messageDialog = new MessageDialog(Display.getDefault().getActiveShell(), dialogTitle,
            dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
    action = messageDialog.open();
}

From source file:com.salesforce.ide.core.WorkbenchShutdownListener.java

License:Open Source License

private void promptRemoveIfIsvDebugProject(IWorkbench workbench, IProject proj) {
    try {//from   w  ww  .j av  a 2 s .c om
        if (proj.hasNature(DefaultNature.NATURE_ID)) {
            ForceProject fProj = ContainerDelegate.getInstance().getServiceLocator().getProjectService()
                    .getForceProject(proj);
            if (!fProj.getSessionId().isEmpty()) {
                String message = NLS.bind(Messages.RemoveSubscriberCode_Question, fProj.getProject().getName());
                MessageDialog md = new MessageDialog(workbench.getDisplay().getActiveShell(),
                        Messages.RemoveSubscriberCode_Title, null, message, MessageDialog.WARNING,
                        new String[] { Messages.RemoveSubscriberCode_Later, Messages.RemoveSubscriberCode_Now },
                        1);

                // If user selected "Delete Now"
                if (md.open() == 1) {
                    fProj.getProject().delete(true, true, new NullProgressMonitor());
                }
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
}

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

License:Open Source License

@Override
public boolean performFinish() {
    try {/*from w w  w  .  j ava 2 s .c om*/
        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//  w  w w .  j a  v  a 2 s .c o  m
        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 ww w .  j av  a 2 s. c  o m*/
        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 w ww .ja va 2 s . c  om
    return dialog.open();
}

From source file:com.servoy.eclipse.docgenerator.ui.handler.DocumentationGenerationRequestFromUI.java

License:Open Source License

public boolean confirmResourceOverwrite(final IPath path) {
    // If the settings say to not ask for confirmation, then just say yes.
    boolean mustAsk = Activator.getDefault().getPreferenceStore()
            .getBoolean(Activator.ASK_FOR_FILE_OVERWRITE_PREFERENCE);
    if (!mustAsk) {
        return true;
    }/*from  ww w.ja  va 2s .c o  m*/

    // If the user already clicked "Confirm All" then just say yes.
    if (confirmAll) {
        return true;
    }

    // Ask the user if it's OK to overwrite.
    final boolean choice[] = new boolean[1];
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog dlg = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Confirm file overwrite",
                    null,
                    "The following file already exists and will be overwritten: '" + path.toOSString()
                            + "'. Are you sure you want the file to be overwritten?" + "\n\n"
                            + "You can disable this confirmation dialog from the plugin preferences page.",
                    MessageDialog.CONFIRM, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL,
                            IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL },
                    3);
            int result = dlg.open();
            if (result == 2) // the "Yes to All" button
            {
                confirmAll = true;
            }
            if (result == 3) // the "Cancel" button
            {
                canceled = true;
            }
            choice[0] = result == 1 || result == 2; // The "Yes" or "Yes to All" buttons were pressed.
        }
    });
    return choice[0];
}