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:carisma.ocl.library.presentation.LibraryModelWizard.java

License:Open Source License

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->//from   w ww. ja  v  a  2 s  .c o m
 * <!-- end-user-doc -->
 * @generated not
 */
@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);
                    }

                    // 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) {
                    OclEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };

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

        // Select the new file resource in the current view.
        //
        IWorkbenchWindow workbenchWindow = this.iWorkbench.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.iWorkbench.getEditorRegistry()
                    .getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(),
                    OclEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }

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

From source file:carisma.ui.eclipse.editors.AdfModelWizard.java

License:Open Source License

@Override
public final boolean performFinish() {
    try {/*from   w  ww .j a va  2s.  c o m*/
        this.createnewfilePage.setFileExtension("adf");
        this.createnewfilePage.createNewFile();

        // create name of Analyse Editor taking the filename whitout the extension 
        String filenameWithoutExt = this.createnewfilePage.getTargetFile().getName();
        int index = filenameWithoutExt.lastIndexOf('.');
        if (index > 0 && index <= filenameWithoutExt.length() - 2) {
            filenameWithoutExt = filenameWithoutExt.substring(0, index);
        }

        Analysis analysis = new Analysis(filenameWithoutExt, this.detailsPage.getModelType(),
                this.detailsPage.getSourceFile());
        AnalysisUtil.storeAnalysis(analysis, this.createnewfilePage.getTargetFile().getLocation().toString());

        IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
        IProject[] projects = workspaceRoot.getProjects();
        for (IProject projectToRefresh : projects) {
            projectToRefresh.refreshLocal(IResource.DEPTH_ONE, null);
        }

    } catch (CoreException e) {
        Logger.log(LogLevel.ERROR, "Could not refresh resource");
    }

    // Open an editor on the new file.
    IWorkbenchWindow workbenchWindow = this.workbench.getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();
    try {
        page.openEditor(new FileEditorInput(this.createnewfilePage.getTargetFile()),
                this.workbench.getEditorRegistry()
                        .getDefaultEditor(this.createnewfilePage.getTargetFile().getFullPath().toString())
                        .getId());
    } catch (PartInitException exception) {
        MessageDialog.openError(workbenchWindow.getShell(), "Analysis Editor", exception.getMessage());
        return false;
    }
    return true;
}

From source file:cbc.helpers.Helper.java

License:Open Source License

public void error(String error) {
    MessageDialog.openError(window.getShell(), name, "Error: " + error);
}

From source file:cc.warlock.rcp.application.WarlockApplication.java

License:Open Source License

@Override
public Object start(IApplicationContext context) throws Exception {
    @SuppressWarnings("rawtypes")
    Map args = context.getArguments();
    String arguments[] = (String[]) args.get(IApplicationContext.APPLICATION_ARGS);

    parseArguments(arguments);/*from   www.  j av  a2  s. co  m*/

    Display display = PlatformUI.createDisplay();

    Location instanceLocation = Platform.getInstanceLocation();

    if (!instanceLocation.lock()) {
        MessageDialog.openError(new Shell(display), "Warlock 2",
                "Another instance of Warlock is currently running.");
        return EXIT_OK;
    }

    advisor = new WarlockWorkbenchAdvisor();
    int ret = PlatformUI.createAndRunWorkbench(display, advisor);

    //save configuration
    WarlockPreferencesScope.getInstance().flush();

    if (ret == PlatformUI.RETURN_RESTART)
        return EXIT_RESTART;

    return EXIT_OK;
}

From source file:cc.warlock.rcp.application.WarlockUpdates.java

License:Open Source License

public static void checkForUpdates(final Shell parent) {
    try {/*w ww . j a  v a2  s .  c o  m*/
        System.out.println("Checking for updates...");

        String repository_loc = updateProperties.getProperty(UPDATE_SITE);
        System.out.println("Using repository: " + repository_loc);

        BundleContext context = FrameworkUtil.getBundle(WarlockUpdates.class).getBundleContext();
        ServiceReference<?> reference = context.getServiceReference(IProvisioningAgent.SERVICE_NAME);
        if (reference == null) {
            System.out.println("No service reference");
            return;
        }
        IProvisioningAgent agent = (IProvisioningAgent) context.getService(reference);
        ProvisioningSession session = new ProvisioningSession(agent);
        UpdateOperation operation = new UpdateOperation(session);

        // Create uri
        URI uri = null;
        try {
            uri = new URI(repository_loc);
        } catch (URISyntaxException e) {
            System.out.println("URI invalid: " + e.getMessage());
            return;
        }

        operation.getProvisioningContext().setArtifactRepositories(new URI[] { uri });
        operation.getProvisioningContext().setMetadataRepositories(new URI[] { uri });

        //Update[] updates = operation.getPossibleUpdates();
        IProgressMonitor monitor = new NullProgressMonitor();
        IStatus status = operation.resolveModal(monitor);

        // Failed to find updates (inform user and exit)
        if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
            System.out.println("No update");
            MessageDialog.openWarning(parent, "No update",
                    "No updates for the current installation have been found");
            return /*Status.CANCEL_STATUS*/;
        }

        // found updates, ask user if to install?
        if (status.isOK() && status.getSeverity() != IStatus.ERROR) {
            ProvisioningJob job = operation.getProvisioningJob(monitor);
            if (job == null) {
                System.out.println("Error with update (running in eclipse?)");
                MessageDialog.openInformation(parent, "Resolution",
                        operation.getResolutionDetails() + "\nLikely cause is from running inside Eclipse.");
            } else {
                System.out.println("Scheduling update");
                job.schedule();
            }
        } else {
            System.out.println("Error with update");
            MessageDialog.openError(parent, "Error updating", operation.getResolutionDetails());
        }
        context.ungetService(reference);
    } catch (Exception e) {
        System.out.println("Unexpected exception in updater: " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:cc.warlock.rcp.stormfront.ui.util.LoginUtil.java

License:Open Source License

public static void showAuthenticationError(int status) {
    String message = "Warlock was unable to log your account in due to the following error: ";
    message += getAuthenticationError(status);

    String title = "Login Error: ";

    switch (status) {
    case SGEConnection.ACCOUNT_REJECTED:
        title += "Account Rejected";
        break;/*w  w  w .  ja v a  2 s . c  o m*/
    case SGEConnection.INVALID_ACCOUNT:
        title += "Invalid Account";
        break;
    case SGEConnection.INVALID_PASSWORD:
        title += "Wrong Password";
        break;
    case SGEConnection.ACCOUNT_EXPIRED:
        title += "Account Expired";
        break;
    }

    if (title != null && message != null)
        MessageDialog.openError(Display.getDefault().getActiveShell(), title, message);
}

From source file:cc.warlock.rcp.stormfront.ui.util.LoginUtil.java

License:Open Source License

public static void showConnectionError(ErrorType errorType) {
    switch (errorType) {
    case ConnectionRefused: {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Connection to SGE Refused",
                "The connection to eaccess.play.net was refused. This could be caused by a server outage, or a firewall blocking access.");
    }//from  w w  w. j  a  va2  s .  c o m
        break;
    case UnknownHost: {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Error connecting to SGE",
                "There was an error connecting to SGE: The server: \"eaccess.play.net\" was returned as unknown by your DNS.");
    }
        break;
    default:
        break;
    }
}

From source file:cc.warlock.rcp.telnet.util.LoginUtil.java

License:Open Source License

public static void showConnectionError(ErrorType errorType) {
    switch (errorType) {
    case ConnectionRefused: {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Connection Refused",
                "The connection was refused. This could be caused by a server outage, or a firewall blocking access.");
    }//  ww w  . j av a2s .c  o m
        break;
    case UnknownHost: {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Unable to resolve hostname",
                "There was an error connecting: The hostname was returned as unknown by your DNS.");
    }
        break;
    default:
        break;
    }
}

From source file:ccw.editors.clojure.CompileLibAction.java

License:Open Source License

protected final void compileLoadFile() {
    IFile editorFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
    if (editorFile == null)
        return;/*from w  ww  .  j a  v  a2s .  com*/

    String lib = editor.findDeclaringNamespace();

    if (lib == null || lib.trim().equals("")) {
        String title = "Compilation impossible";
        String message = "The file " + editorFile.getName()
                + " cannot be compiled because it does not declare a namespace.";
        MessageDialog.openError(editor.getSite().getShell(), title, message);
        return;
    }

    IFolder classesFolder = editorFile.getProject().getFolder("classes");
    try {
        classesFolder.refreshLocal(IFolder.DEPTH_INFINITE, null);
        if (!classesFolder.exists()) {
            classesFolder.create(true, true, null);
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }

    EvaluateTextUtil.evaluateText(editor.getCorrespondingREPL(), compileLibCommand(lib), true);
    // TODO: send the compile via the server to synchronize with the compilation end before refreshing the project
    try {
        classesFolder.refreshLocal(IFolder.DEPTH_INFINITE, null);
    } catch (CoreException e) {
        e.printStackTrace();
    }
}

From source file:ccw.editors.clojure.EvaluateTextUtil.java

License:Open Source License

public static final void evaluateText(REPLView console, final String text, boolean repeatLastREPLEvalIfActive) {
    if (console == null || console.isDisposed()) {
        DisplayUtil.syncExec(new Runnable() {
            public void run() {
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        "Expression evaluation",
                        "Please activate a running REPL session before attempting to evaluate code.");
            }/*w  w w .j  a  va2s  .  c  o m*/
        });
    } else {
        console.evalExpression(text, false, false, repeatLastREPLEvalIfActive);
    }
}