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.mcgill.cs.swevo.qualyzer.wizards.ImportMemoWizard.java

License:Open Source License

/**
 * @see org.eclipse.jface.wizard.Wizard#performFinish()
 *///from   ww  w . j  a  va  2 s  . c  o  m
@Override
public boolean performFinish() {
    try {
        FileUtil.setupMemoFiles(fPage.getMemoName(), fProject.getFolderName(), fPage.getMemoFile());

        fMemo = Facade.getInstance().createMemo(fPage.getMemoName(), fPage.getDate(), fPage.getAuthor(),
                fPage.getParticipants(), fProject, fPage.getCode(), fPage.getTranscript());
    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(), Messages.getString("wizards.ImportMemoWizard.memoError"), //$NON-NLS-1$
                e.getMessage());
        return false;
    }

    return true;
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.ImportTranscriptWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {// w w  w.j a  v  a 2s.c o m
        FileUtil.setupTranscriptFiles(fPage.getTranscriptName(), fProject.getFolderName(), fPage.getAudioFile(),
                fPage.getTranscriptFile());

        fTranscript = Facade.getInstance().createTranscript(fPage.getTranscriptName(), fPage.getDate(),
                fPage.getAudioFile(), fPage.getParticipants(), fProject);
    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(),
                Messages.getString("wizards.ImportTranscriptWizard.transcriptError"), e.getMessage()); //$NON-NLS-1$
        return false;
    }

    return true;
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.NewMemoWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {//from ww  w  . j  a  v  a  2 s .  com
        FileUtil.setupMemoFiles(fPage.getMemoName(), fProject.getFolderName(), ""); //$NON-NLS-1$

        fMemo = Facade.getInstance().createMemo(fPage.getMemoName(), fPage.getDate(), fPage.getAuthor(),
                fPage.getParticipants(), fProject, fPage.getCode(), fPage.getTranscript());

    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(), Messages.getString("wizards.NewMemoWizard.memoError"), //$NON-NLS-1$
                e.getMessage());
        return false;
    }

    return fMemo != null;
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.NewProjectWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    fOne.save();//from  ww  w .j  av a 2  s.  com

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    dialog.setOpenOnRun(true);
    dialog.create();
    dialog.getShell().setText(Messages.getString("wizards.NewProjectWizard.projectCreationStatus")); //$NON-NLS-1$
    try {
        dialog.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                QualyzerActivator.getDefault().setCreatingProject(true);
                monitor.beginTask(Messages.getString("wizards.NewProjectWizard.creatingNewProject"), //$NON-NLS-1$
                        WORK);
                monitor.worked(1);
                monitor.worked(1);
                Project project = Facade.getInstance().createProject(fOne.getProjectName(),
                        fOne.getInvestigatorNickname(), fOne.getInvestigatorFullname(), fOne.getInstitution());
                monitor.worked(2);

                fProject = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getFolderName());
                monitor.worked(1);
                monitor.done();
                QualyzerActivator.getDefault().setCreatingProject(false);
            }
        });
    } catch (InvocationTargetException e) {

    } catch (InterruptedException e) {

    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(), Messages.getString("wizard.NewProjectWizard.projectError"), //$NON-NLS-1$
                e.getMessage());
        return false;
    }

    return fProject != null && fProject.exists();
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.NewTranscriptWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*from w ww .j a  v  a  2s  .c o m*/
        FileUtil.setupTranscriptFiles(fPage.getTranscriptName(), fProject.getFolderName(), fPage.getAudioFile(),
                ""); //$NON-NLS-1$

        fTranscript = Facade.getInstance().createTranscript(fPage.getTranscriptName(), fPage.getDate(),
                fPage.getAudioFile(), fPage.getParticipants(), fProject);
    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(),
                Messages.getString("wizards.NewTranscriptWizard.transcriptCreateError"), e.getMessage()); //$NON-NLS-1$
        return false;
    }

    return true;
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.ProjectImportWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    boolean toReturn = fMainPage.createProjects();
    ArrayList<IProject> toDelete = new ArrayList<IProject>();
    for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
        /*For each project that was imported:
         * Verify that it is a Qualyzer Project,
         * Recreate it's sub-folders.//  w w w .ja v a2s .  c o  m
         * If it was not then show an error message and delete it from the workspace.
         */
        PersistenceManager.getInstance().refreshManager(project);
        Project qProject = PersistenceManager.getInstance().getProject(project.getName());
        if (qProject != null) {
            try {
                FileUtil.refreshSubFolders(project);
                FileUtil.renewTimestamps(project);
            } catch (QualyzerException e) {
                MessageDialog.openError(getShell(), IMPORT_ERROR, e.getMessage());
            }
        } else {
            MessageDialog.openError(getShell(), IMPORT_ERROR,
                    Messages.getString("wizards.ProjectImportWizard.couldNotImport") + project.getName() + //$NON-NLS-1$
                            Messages.getString("wizards.ProjectImportWizard.invalidProject")); //$NON-NLS-1$
            toDelete.add(project);
        }
    }
    for (IProject wProject : toDelete) {
        try {
            wProject.delete(true, new NullProgressMonitor());
        } catch (CoreException e) {
            MessageDialog.openError(getShell(), IMPORT_ERROR,
                    Messages.getString("wizards.ProjectImportWizard.deleteFailed")); //$NON-NLS-1$
        }
    }

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    CommonNavigator view = (CommonNavigator) page.findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID);
    view.getCommonViewer().refresh();
    return toReturn;
}

From source file:ca.mcgill.sable.soot.launching.SootThread.java

License:Open Source License

public void run() {
    final String[] cmdFinal = getCmd();
    final PrintStream sootOutFinal = getSootOut();
    try {//from   www .  j ava 2s .c  om

        soot.G.reset();
        soot.G.v().out = sootOutFinal;

        InteractionController listener = getListener();
        InteractionHandler.v().setInteractionListener(listener);

        String mainClass = getMainClass();
        String mainProject = null;
        if (mainClass.contains(":")) {
            String[] split = mainClass.split(":");
            mainProject = split[0];
            mainClass = split[1];
        }
        Class<?> toRun;
        try {
            ClassLoader loader;
            if (mainProject != null) {
                IProject project = SootPlugin.getWorkspace().getRoot().getProject(mainProject);
                if (project.exists() && project.isOpen()
                        && project.hasNature("org.eclipse.jdt.core.javanature")) {
                    IJavaProject javaProject = JavaCore.create(project);
                    URL[] urls = SootClasspath.projectClassPath(javaProject);
                    loader = new URLClassLoader(urls, SootThread.class.getClassLoader());
                } else {
                    final String mc = mainClass;
                    final Shell defaultShell = getShell();
                    getDisplay().syncExec(new Runnable() {
                        public void run() {
                            MessageDialog.openError(defaultShell, "Unable to find Soot Main Project",
                                    "Project " + mc + " does not exist,"
                                            + " is no Java project or is closed. Aborting...");
                        }
                    });
                    SootPlugin.getDefault().getConsole().clearConsole();
                    return;
                }
            } else {
                loader = SootThread.class.getClassLoader();
            }

            toRun = loader.loadClass(mainClass);
        } catch (final ClassNotFoundException e) {
            final Shell defaultShell = getShell();
            final String inProject = mainProject != null ? (" in project " + mainProject) : "";
            getDisplay().syncExec(new Runnable() {
                public void run() {
                    MessageDialog.openError(defaultShell, "Unable to find class",
                            "Cannot find class" + inProject + ". Aborting...\n" + e.getLocalizedMessage());
                }
            });
            SootPlugin.getDefault().getConsole().clearConsole();
            return;
        }

        Method[] meths = toRun.getDeclaredMethods();
        Object[] args = new Object[1];
        args[0] = cmdFinal;
        for (int i = 0; i < meths.length; i++) {
            if (meths[i].getName().equals("main")) {
                Class<?>[] fields = meths[i].getParameterTypes();
                if (fields.length == 1) {
                    meths[i].invoke(toRun, args);
                }
            }
        }
        setCfgList(soot.Scene.v().getPkgList());
        getParent().setCfgList(getCfgList());

    } catch (Exception e) {
        System.out.println("Soot exception: " + e);
        e.printStackTrace(sootOutFinal);
        System.out.println(e.getCause());
    }
}

From source file:ca.mcgill.sable.soot.ui.PhaseOptionsDialog.java

License:Open Source License

/**
 * all options get saved as (alias, value) pair
 *//*from   ww  w. ja va  2s  .c  o m*/
protected void okPressed() {
    if (createNewConfig())
        super.okPressed();
    else {
        Shell defaultShell = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
        String projectName = getSootMainProjectWidget().getText().getText();
        MessageDialog.openError(defaultShell, "Unable to find Soot Main Project",
                "Project " + projectName + " does not exist," + " is no Java project or is closed.");
    }
}

From source file:ca.uvic.cs.tagsea.editing.InlineTreeItemRenamer.java

License:Open Source License

/**
 * Compares the text in the Text control with the original text
 * in the TreeItem.  If they are different, and the new name is valid
 * then the TreeItem will be updated and a Rename event will be fired.
 * If they are the same false is returned.  If the new name is not valid
 * an error dialog will popup./*  w  w w. j a v a2s.  co  m*/
 * @param item   The TreeItem (containing the original name)
 * @param text   The Text control (containing the new name)
 * @return boolean if the rename was successful
 */
protected boolean validateRename(TreeItem item, Text text) {
    boolean ok = true;
    String oldName = item.getText().trim();
    String newName = text.getText().trim();

    // nothing changed
    if (newName.equals(oldName))
        return false;

    if (validator != null) {
        String errorMsg = validator.isValid(newName);
        if (errorMsg != null) {
            // invalid name - revert back to old name
            text.setText(oldName);
            text.selectAll();
            ok = false;
            // note - this starts a new thread
            MessageDialog.openError(tree.getShell(), "Invalid Name", errorMsg);
        } else {
            ok = true;
        }
    }
    if (ok) {
        TreeItemRenameEvent event = new TreeItemRenameEvent(item, newName);
        item.setText(newName);
        fireAfterRenameEvent(event);
    }
    return ok;
}

From source file:ca.uvic.cs.tagsea.monitor.NetworkLogging.java

License:Open Source License

public synchronized boolean uploadForDate(Date d) throws IOException {
    File f = SimpleDayLog.findLogFileForDay(d);
    if (f.length() == 0)
        return true;

    PostMethod post = new PostMethod(uploadScript);
    Display disp = TagSEAMonitorPlugin.getDefault().getWorkbench().getDisplay();
    int id = getUID();
    if (id < 0) {
        //error getting the user id. Quit.
        return false;
    }// w ww  .j  a  va  2  s  .com
    Part[] parts = { new StringPart("KIND", "log"), new FilePart("MYLAR" + id, f.getName(), f) };
    post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
    HttpClient client = new HttpClient();
    int status = client.executeMethod(post);
    resp = getData(post.getResponseBodyAsStream());
    if (status != 200) {
        disp.syncExec(new Runnable() {
            public void run() {
                MessageDialog.openError(null, "Error Sending File", resp);
            }
        });
        return false;

    }
    MonitorPreferences.setLastSendDate(d);
    return true;

}