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

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

Introduction

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

Prototype

public static void openError(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard error dialog.

Usage

From source file:ca.uvic.cs.tagsea.research.GetIDWithProgress.java

License:Open Source License

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    GetMethod getUidMethod = new GetMethod(uidScript);
    getUidMethod.setQueryString(new NameValuePair[] { first, last, email, job, size, buisness, anon });
    monitor.beginTask("Get User Id", 1);
    HttpClient client = new HttpClient();
    try {/*from   w w w . ja v a  2  s .  c o  m*/
        status = client.executeMethod(getUidMethod);

        resp = getData(getUidMethod.getResponseBodyAsStream());

        // release the connection to the server
        getUidMethod.releaseConnection();
    } catch (Exception e) {
        // there was a problem with the file upload so throw up
        // an error
        // dialog to inform the user and log the exception
        failed = true;
        throw new InvocationTargetException(e);
    }

    if (status != 200) {
        // there was a problem with the file upload so throw up an error
        // dialog to inform the user

        failed = true;

        // there was a problem with the file upload so throw up an error
        // dialog to inform the user
        MessageDialog.openError(null, "Error Getting User ID", "There was an error getting a user id: \n"
                + "HTTP Response Code " + status + "\n" + "Please try again later");
    } else {
        resp = resp.substring(resp.indexOf(":") + 1).trim();
        uid = Integer.parseInt(resp);
    }

    monitor.worked(1);
    monitor.done();
}

From source file:ca.uvic.cs.tagsea.research.UserIDDialog.java

License:Open Source License

@Override
protected void okPressed() {
    ProgressMonitorDialog progress = new ProgressMonitorDialog(this.getParentShell());
    GetIDWithProgress getID = new GetIDWithProgress(composite.getFirstName(), composite.getLastName(),
            composite.getEmail(), composite.isAnonymous(), composite.getJob(), composite.getCompanySize(),
            composite.getCompany());//from ww w  . j a  v a 2  s .c o m
    try {
        progress.run(false, true, getID);
    } catch (InvocationTargetException ex) {
        Exception e = (Exception) ex.getCause();
        if (e instanceof NoRouteToHostException || e instanceof UnknownHostException) {
            MessageDialog.openError(null, "Error Communicating", "There was an error getting a new user id. \n"
                    + "No network connection.  Please try again later");
        } else {
            MessageDialog.openError(null, "Error Communicating", "There was an error getting a new user id: \n"
                    + e.getClass().getCanonicalName() + e.getMessage());
            TagSEAPlugin.log("", e);
        }
        return;
    } catch (InterruptedException e) {
    }
    if (getID.success()) {
        composite.setIDText(getID.getUID());
        this.id = getID.getUID();
        finish.setEnabled(true);
        cancel.setEnabled(false);
        okay.setEnabled(false);
    } else {
        setReturnCode(ERROR);
    }
}

From source file:ca.uvic.cs.tagsea.wizards.TagExportWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    TagXMLGatherer gatherer = new TagXMLGatherer();
    try {//from   w w w.j ava2 s . co m
        getContainer().run(false, true, gatherer);
        String xmlString = gatherer.getXML();
        if (page.doSend()) {
            return send.send();
        } else {
            doSave(xmlString, page.getFileName());
        }
    } catch (InvocationTargetException e) {
        TagSEAPlugin.log("Error generating XML", e);
        MessageDialog.openError(getShell(), "Error", "Error generating XML. See log for details.");
        return false;
    } catch (InterruptedException e) {
        return false;
    } catch (IOException e) {
        TagSEAPlugin.log("Error saving file", e);
        MessageDialog.openError(getShell(), "Error", "Error saving file. See log for details.");
        return false;
    }

    return true;
}

From source file:ca.uvic.cs.tagsea.wizards.XMLTagSendWizardPage.java

License:Open Source License

boolean send() {
    int id = TagSEAPlugin.getDefault().getUserID();
    if (id < 0) {
        boolean result = MessageDialog.openQuestion(getShell(), "Cannot Send",
                "You must register TagSEA before you can upload your tags. Would you like to register now?");
        if (result) {
            id = TagSEAPlugin.getDefault().askForUserID();
        }/*from   w ww . j a v a 2s . c o  m*/
    }
    if (id < 0) {
        MessageDialog.openError(getShell(), "Operation Incomplete", "Error getting ID.");
        return false;
    }
    final int fid = TagSEAPlugin.getDefault().askForUserID();
    try {
        getContainer().run(false, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                TagNetworkSender.send(textData, monitor, fid);
            }
        });
    } catch (InvocationTargetException ex) {
        MessageDialog.openError(getShell(), "Error", ex.getLocalizedMessage());
        TagSEAPlugin.log(ex.getLocalizedMessage(), ex);
        return false;
    } catch (InterruptedException e) {
    }
    MessageDialog.openInformation(getShell(), "Complete", "Upload Complete");
    return true;
}

From source file:ca.uwaterloo.gp.fmp.presentation.FmpModelWizard.java

License:Open Source License

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->/*  w w  w.  ja  va 2  s . c o m*/
 * <!-- end-user-doc -->
 * @generated NOT
 */
public boolean performFinish() {
    try {
        // Remember the file.
        //
        final IFile modelFile = getModelFile();

        // Do the work within an operation.
        //
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    //
                    ResourceSet resourceSet = new ResourceSetImpl();

                    // Get the URI of the model file.
                    //
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString());

                    // Create a resource for this file.
                    //
                    Resource resource = resourceSet.createResource(fileURI);

                    // Add the initial model object to the contents.
                    //
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }

                    // Save the contents of the resource to the file system.
                    //
                    Map options = new HashMap();
                    options.put(XMLResource.OPTION_ENCODING, "ASCII");
                    resource.save(options);
                } catch (Exception exception) {
                    fmpEditPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };

        getContainer().run(false, false, operation);

        // Select the new file resource in the current view.
        //
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {
                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }

        // Open an editor on the new file.
        //
        try {
            page.openEditor(new FileEditorInput(modelFile),
                    workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(),
                    fmpEditPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }

        return true;
    } catch (Exception exception) {
        fmpEditPlugin.INSTANCE.log(exception);
        return false;
    }
}

From source file:carisma.modeltype.bpmn2.extension.presentation.ExtensionModelWizard.java

License:Open Source License

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->//from   www .jav a2s. com
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        //
        final IFile modelFile = getModelFile();

        // Do the work within an operation.
        //
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    //
                    ResourceSet resourceSet = new ResourceSetImpl();

                    // Get the URI of the model file.
                    //
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);

                    // Create a resource for this file.
                    //
                    Resource resource = resourceSet.createResource(fileURI);

                    // Add the initial model object to the contents.
                    //
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);

                        if (ExtensionModelWizard.this.detailsPage.sourceFile != null) {
                            ExtensionModelWizardHelper.addExtensibleObjectsToModel(rootObject,
                                    ExtensionModelWizard.this.detailsPage.sourceFile.getLocation().toFile());
                        }
                    }

                    // Save the contents of the resource to the file system.
                    //
                    Map<Object, Object> options = new HashMap<>();

                    /** Define Encoding manually */
                    //options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    options.put(XMLResource.OPTION_ENCODING, "UTF-8");

                    resource.save(options);
                } catch (Exception exception) {
                    ExtensionEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };

        getContainer().run(false, false, operation);

        // Select the new file resource in the current view.
        //
        IWorkbenchWindow workbenchWindow = this.workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }

        // Open an editor on the new file.
        //
        try {
            page.openEditor(new FileEditorInput(modelFile), this.workbench.getEditorRegistry()
                    .getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(),
                    ExtensionEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"),
                    exception.getMessage());
            return false;
        }

        return true;
    } catch (Exception exception) {
        ExtensionEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}

From source file:carisma.modeltype.bpmn2.popup.ConvertEmfAction.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)//  w w  w.  j a va 2 s.  co m
 */
@Override
public final void run(final IAction action) {
    if (this.selectedFile != null) {
        String ext = "." + this.selectedFile.getFileExtension();
        String name = this.selectedFile.getName().substring(0, this.selectedFile.getName().indexOf(ext));
        String updatedName = name;
        String path = this.selectedFile.getLocation().toString().substring(0,
                this.selectedFile.getLocation().toString().indexOf(name));
        String outputfile = "";

        if (name.length() > ConvertYaoqiangAction.SUFFIX.length()
                && name.substring(name.length() - ConvertYaoqiangAction.SUFFIX.length(), name.length())
                        .equals(ConvertYaoqiangAction.SUFFIX)) {
            updatedName = name.substring(0, name.length() - ConvertYaoqiangAction.SUFFIX.length());
        }
        if (!updatedName.contains(SUFFIX)) {
            outputfile = Utils.incrementFileNameIfNecessary(path + updatedName + SUFFIX + ".bpmn");
        } else {
            outputfile = Utils.incrementFileNameIfNecessary(path + updatedName + ".bpmn");
        }
        startEmfTransformation(path + name + ext, outputfile);
    } else {
        MessageDialog.openError(this.shell, "Carisma", "No file selected!");
    }
    // refresh resources
    try {
        IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
        IProject[] projects = workspaceRoot.getProjects();
        for (IProject projectToRefresh : projects) {
            projectToRefresh.refreshLocal(IResource.DEPTH_INFINITE, null);
        }
    } catch (CoreException e) {
        Logger.log(LogLevel.ERROR, "could not refresh resource");
    }
}

From source file:carisma.modeltype.bpmn2.popup.ConvertEmfAction.java

License:Open Source License

/**
 * /*from  w w  w . ja v a2 s  .  c  om*/
 * @param inputFile
 * @param outputFile
 */
private void startEmfTransformation(String inputFile, String outputFile) {
    File model = new File(inputFile);
    if (YaoqiangHelper.emf2yaoqiangModel(inputFile, outputFile)) {
        MessageDialog.openInformation(this.shell, "CARiSMA",
                "Successfully transformed model " + model.getName() + ".");
    } else {
        MessageDialog.openError(this.shell, "Carisma", "Error during transformation!");
    }
}

From source file:carisma.modeltype.bpmn2.popup.ConvertYaoqiangAction.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)/*from www  .  j  a  v a2 s .  c  o m*/
 */
@Override
public final void run(final IAction action) {
    if (this.selectedFile != null) {
        String ext = "." + this.selectedFile.getFileExtension();
        String name = this.selectedFile.getName().substring(0, this.selectedFile.getName().indexOf(ext));
        String updatedName = name;
        String path = this.selectedFile.getLocation().toString().substring(0,
                this.selectedFile.getLocation().toString().indexOf(name));
        String outputfile = "";

        if (name.length() > ConvertEmfAction.SUFFIX.length()
                && name.substring(name.length() - ConvertEmfAction.SUFFIX.length(), name.length())
                        .equals(ConvertEmfAction.SUFFIX)) {
            updatedName = name.substring(0, name.length() - ConvertEmfAction.SUFFIX.length());
        }
        if (!updatedName.contains(SUFFIX)) {
            outputfile = Utils.incrementFileNameIfNecessary(path + updatedName + SUFFIX + ".bpmn2");
        } else {
            outputfile = Utils.incrementFileNameIfNecessary(path + updatedName + ".bpmn2");
        }
        if (!YaoqiangHelper.isYaoqiangModel(path + name + ext)) {
            if (MessageDialog.openConfirm(this.shell, "CARiSMA",
                    "Model seems not be a Yaonqiang Model. Still start transformation?")) {
                startYaoqiangTransformation(path + name + ext, outputfile);
            }
        } else {
            startYaoqiangTransformation(path + name + ext, outputfile);
        }
    } else {
        MessageDialog.openError(this.shell, "Carisma", "No file selected!");
    }
    // refresh resources
    try {
        IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
        IProject[] projects = workspaceRoot.getProjects();
        for (IProject projectToRefresh : projects) {
            projectToRefresh.refreshLocal(IResource.DEPTH_INFINITE, null);
        }
    } catch (CoreException e) {
        Logger.log(LogLevel.ERROR, "could not refresh resource");
    }
}

From source file:carisma.modeltype.bpmn2.popup.ConvertYaoqiangAction.java

License:Open Source License

/**
 * /*  www .j av a2  s . co m*/
 * @param inputFile
 * @param outputFile
 */
private void startYaoqiangTransformation(final String inputFile, final String outputFile) {
    File model = new File(inputFile);
    if (YaoqiangHelper.yaoqiang2emfModel(inputFile, outputFile)) {
        MessageDialog.openInformation(this.shell, "CARiSMA",
                "Successfully transformed model " + model.getName() + ".");
    } else {
        MessageDialog.openError(this.shell, "Carisma", "Error during transformation!");
    }
}