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:org.vclipse.connection.dialogs.IDocErrorDialog.java

License:Open Source License

/**
 * //from  w  w w .  ja  v  a2 s .c  om
 */
public IDocErrorDialog() {
    super(Display.getDefault().getActiveShell(), TITLE_MESSAGE, null, ERROR_MESSAGE, MessageDialog.ERROR,
            new String[] { "OK" }, 0);
}

From source file:org.vclipse.connection.dialogs.JCoErrorDialog.java

License:Open Source License

/**
 * //from   w w  w . j  av a  2  s .  c  om
 */
public JCoErrorDialog() {
    super(Display.getDefault().getActiveShell(), TITLE_MESSAGE, null, ERROR_MESSAGE, MessageDialog.ERROR,
            new String[] { "OK" }, 0);
}

From source file:org.vclipse.connection.dialogs.PreferencePage.java

License:Open Source License

/**
 *   Handles the connect operation/*from ww  w . ja v  a  2  s  .  c  o m*/
 */
private void handleConnectButtonPushed() {
    final IConnection oldConnection = handler.getCurrentConnection();
    final IConnection connection = (IConnection) ((IStructuredSelection) tableViewer.getSelection())
            .getFirstElement();
    try {
        IStatus status = new ConnectionStateDialog(getShell(), handler).connect(connection);
        if (status != null && IStatus.ERROR == status.getSeverity()) {
            new MessageDialog(getShell(), "Connection state", null, status.getMessage(), MessageDialog.ERROR,
                    new String[] { "OK" }, 0).open();
        } else {
            new MessageDialog(getShell(), "Connection state", null,
                    "Connected to '" + connection.getSystemName() + "'", MessageDialog.INFORMATION,
                    new String[] { "OK" }, 0).open();
            tableViewer.refresh(connection, true);
            if (oldConnection != null) {
                tableViewer.refresh(oldConnection, true);
            }
            handler.storeConnectionData();
        }
        handleTableSelection();
    } catch (Throwable exception) {
        final String errorMessage = "Connection to '" + connection.getSystemName() + "' was not successful!\n"
                + "\n\nReason:\n\t" + exception.getMessage();
        new MessageDialog(getShell(), "Connection state", null, errorMessage, MessageDialog.ERROR,
                new String[] { "OK" }, 0).open();
    }
}

From source file:org.vimplugin.editors.VimEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    this.shell = parent.getShell();

    VimPlugin plugin = VimPlugin.getDefault();

    if (!plugin.gvimAvailable()) {
        MessageDialog dialog = new MessageDialog(shell, "Vimplugin", null,
                plugin.getMessage("gvim.not.found.dialog"), MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0) {
            protected void buttonPressed(int buttonId) {
                super.buttonPressed(buttonId);
                if (buttonId == IDialogConstants.OK_ID) {
                    PreferenceDialog prefs = PreferencesUtil.createPreferenceDialogOn(shell,
                            "org.vimplugin.preferences.VimPreferences", null, null);
                    if (prefs != null) {
                        prefs.open();/*from   w  w w.  j  a v a 2 s  .  co m*/
                    }
                }
            }
        };
        dialog.open();

        if (!plugin.gvimAvailable()) {
            throw new RuntimeException(plugin.getMessage("gvim.not.found"));
        }
    }

    IPreferenceStore prefs = plugin.getPreferenceStore();
    tabbed = prefs.getBoolean(PreferenceConstants.P_TABBED);
    embedded = prefs.getBoolean(PreferenceConstants.P_EMBED);
    // disabling documentListen until there is a really good reason to have,
    // cause it is by far the buggest part of vim's netbeans interface.
    documentListen = false; //plugin.gvimNbDocumentListenSupported();
    if (embedded) {
        if (!plugin.gvimEmbedSupported()) {
            String message = plugin.getMessage("gvim.not.supported",
                    plugin.getMessage("gvim.embed.not.supported"));
            throw new RuntimeException(message);
        }
    }
    if (!plugin.gvimNbSupported()) {
        String message = plugin.getMessage("gvim.not.supported", plugin.getMessage("gvim.nb.not.enabled"));
        throw new RuntimeException(message);
    }

    //set some flags
    alreadyClosed = false;
    dirty = false;

    String projectPath = null;
    String filePath = null;
    IEditorInput input = getEditorInput();
    if (input instanceof IFileEditorInput) {
        selectedFile = ((IFileEditorInput) input).getFile();

        IProject project = selectedFile.getProject();
        IPath path = project.getRawLocation();
        if (path == null) {
            String name = project.getName();
            path = ResourcesPlugin.getWorkspace().getRoot().getRawLocation();
            path = path.append(name);
        }
        projectPath = path.toPortableString();

        filePath = selectedFile.getRawLocation().toPortableString();
        if (filePath.toLowerCase().indexOf(projectPath.toLowerCase()) != -1) {
            filePath = filePath.substring(projectPath.length() + 1);
        }
    } else {
        URI uri = ((IURIEditorInput) input).getURI();
        filePath = uri.toString().substring("file:".length());
        filePath = filePath.replaceFirst("^/([A-Za-z]:)", "$1");
    }

    if (filePath != null) {
        editorGUI = new Canvas(parent, SWT.EMBEDDED);

        //create a vim instance
        VimConnection vc = createVim(projectPath, filePath, parent);

        viewer = new VimViewer(bufferID, vc, editorGUI != null ? editorGUI : parent, SWT.EMBEDDED);
        viewer.getTextWidget().setVisible(false);
        viewer.setDocument(document);
        viewer.setEditable(isEditable());
        try {
            Field fSourceViewer = AbstractTextEditor.class.getDeclaredField("fSourceViewer");
            fSourceViewer.setAccessible(true);
            fSourceViewer.set(this, viewer);
        } catch (Exception e) {
            logger.error("Unable to access source viewer field.", e);
        }

        // open eclimd view if necessary
        boolean startEclimd = plugin.getPreferenceStore().getBoolean(PreferenceConstants.P_START_ECLIMD);
        if (startEclimd) {
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            try {
                if (page != null && page.findView(ECLIMD_VIEW_ID) == null) {
                    page.showView(ECLIMD_VIEW_ID);
                }
            } catch (PartInitException pie) {
                logger.error("Unable to open eclimd view.", pie);
            }
        }

        // on initial open, our part listener isn't firing for some reason.
        if (embedded) {
            plugin.getPartListener().partOpened(this);
            plugin.getPartListener().partBroughtToTop(this);
            plugin.getPartListener().partActivated(this);
        }
    }
}

From source file:org.wso2.developerstudio.eclipse.gmf.esb.diagram.part.EsbMultiPageEditor.java

License:Open Source License

private void printHandleDesignViewActivatedEventErrorMessageSimple(Exception e,
        DeserializeStatus deserializeStatus) {
    String topStackTrace = e.getStackTrace()[0].toString();
    String errorMsgHeader = fileName + " has some syntax errors";
    if (topStackTrace.contains("MediatorFactoryFinder.getMediator")) {
        errorMsgHeader = fileName + " has some syntax errors";
    }// w ww  .  j a v  a 2s  .co  m
    IStatus editorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());

    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Error Dialog", null,
            errorMsgHeader, MessageDialog.ERROR, new String[] { "OK", "Show Details" }, 0);
    int result = dialog.open();
    if (result == 1) {
        String source = deserializeStatus.getsource();
        DocumentBuilderFactory domParserFactory = DocumentBuilderFactory.newInstance();
        domParserFactory.setValidating(true);
        DocumentBuilder builder;
        try {
            builder = domParserFactory.newDocumentBuilder();
            builder.parse(new InputSource(new StringReader(source)));

            final OMElement element = AXIOMUtil.stringToOM(source);
            try {
                new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).run(true,
                        true, new IRunnableWithProgress() {
                            public void run(IProgressMonitor monitor)
                                    throws InvocationTargetException, InterruptedException {
                                monitor.beginTask("Generating Error Report", 100);
                                monitor.worked(IProgressMonitor.UNKNOWN);
                                validationMessage = Deserializer.getInstance().validate(element, element);
                                monitor.done();

                            }
                        });
            } catch (InvocationTargetException | InterruptedException exception) {
                log.error("Error while validating synapse syntax", exception);
            }
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Error Details",
                    validationMessage);

        } catch (IOException | ParserConfigurationException | XMLStreamException exception) {
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Error Details",
                    "Errors in XML formatting");
        } catch (SAXException exception) {
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Error Details",
                    "Errors in XML formatting: " + exception.getMessage());
        }
    }
}

From source file:org.wso2.developerstudio.msf4j.artifact.ui.wizard.MSF4JProjectCreationWizard.java

License:Open Source License

@Override
public boolean performFinish() {

    try {//from ww w.  j a v  a  2s.c  o m
        if (getModel().getSelectedOption().equals(NEW_MSF4J_PROJECT_CREATION_OPTION)) {

            // Creating new Eclipse project
            IProject project = createNewProject();
            msf4jArtifactModel.setCreatedProjectFile(project.getLocation().toOSString());
            msf4jArtifactModel.setCreatedProjectN(project.getName());
            newJavaFolder = new File(project.getLocation().toOSString());
            project.delete(true, new NullProgressMonitor());
            newJavaFolder.mkdir();
            msf4jArtifactModel.setProjectFolder(newJavaFolder);

            msf4jArtifactModel.setGeneratedCodeLocation(newJavaFolder.getAbsolutePath());
            if (msf4jArtifactModel.getMsf4jVersion() != null) {
                MSF4JArtifactConstants.setMSF4JServiceParentVersion(msf4jArtifactModel.getMsf4jVersion());
            }
            ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell());
            progressMonitorDialog.create();
            progressMonitorDialog.open();
            progressMonitorDialog.run(false, false, new CodegenJob());

        } else {
            log.error("Unsupported MSF4J project creation option" + getModel().getSelectedOption());
            MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null,
                    "Unsupported Microserices project creation option", MessageDialog.ERROR,
                    new String[] { OK_BUTTON }, 0);
            errorDialog.open();
            return false;
        }
    } catch (CoreException | InvocationTargetException | InterruptedException e) {
        log.error("Error while creating MSF4J project for given Swagger API", e);
        MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null,
                "Error while creating MSF4J project for given Swagger API", MessageDialog.ERROR,
                new String[] { OK_BUTTON }, 0);
        errorDialog.open();
        return false;
    }
    return true;
}

From source file:org.wso2.developerstudio.msf4j.artifact.util.MSF4JDependencyResolverJob.java

License:Open Source License

@Override
protected IStatus run(IProgressMonitor monitor) {
    try {/*  w  ww .  ja v  a 2s  .co m*/
        projectDependencyResolver(monitor);
        final IWorkbench workbench = PlatformUI.getWorkbench();
        new UIJob("Switching perspectives") {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                try {
                    workbench.showPerspective(PERSPECTIVE_ID, workbench.getActiveWorkbenchWindow());
                } catch (WorkbenchException e) {
                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while switching perspectives",
                            e);
                }
                return Status.OK_STATUS;
            }
        }.run(new NullProgressMonitor());

    } catch (CoreException | IOException e) {
        log.error("error in resolving project dependencies", e);
        Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
        MessageDialog errorDialog = new MessageDialog(shell, "Error", null,
                "Error while creating MSF4J project for given Swagger API", MessageDialog.ERROR,
                new String[] { OK_BUTTON }, 0);
        errorDialog.open();
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:org.wso2.developerstudio.msf4j.artifact.util.MSF4JMavenDependencyResolverJob.java

License:Open Source License

@Override
protected IStatus run(IProgressMonitor monitor) {
    String operationText = DEPENDENCY_RESOLVING_TASK;
    IStatus status = Status.OK_STATUS;//from ww w  .  j av  a 2 s . co  m
    try {
        String mavenHome = "EMBEDDED";
        monitor.beginTask(operationText, 100);
        monitor.subTask(READING_POM_TASK);
        monitor.worked(10);
        InvocationRequest request = new DefaultInvocationRequest();
        File pomFile = FileUtils.getMatchingFiles(project.getLocation().toOSString(), POM_FILE_PREFIX,
                XML_EXTENTION)[0];
        request.setPomFile(pomFile);
        request.setGoals(Collections.singletonList(MAVEN_ECLIPSE_ECLIPSE_GOAL));
        monitor.subTask(SETTING_MAVEN_INVOKER_TASK);
        monitor.worked(25);
        Invoker invoker = new DefaultInvoker();
        invoker.setMavenHome(new File(mavenHome));
        monitor.subTask(EXECUTING_MAVEN_REQUEST_TASK);
        monitor.worked(70);
        InvocationResult result = invoker.execute(request);
        if (result.getExitCode() != 0) {
            throw new MavenInvocationException("Maven Invoker was unable to execute the request");
        }
        monitor.subTask(PROJECT_REFRESH_TASK);
        monitor.worked(90);
    } catch (MavenInvocationException e) {
        log.error("Error while resolving dependencies from the project pom file", e);
        status = new Status(0, Activator.PLUGIN_ID,
                "Error occured while resolving dependencies of the file in eclipse.\n"
                        + " Please execute \"mvn eclipse:eclipse\" command in the generated project "
                        + "folder to resolve dependencies.",
                e);
    } /*
        * catch (NoSuchFieldException e) { log.error(
        * "Maven Home system variable is not set as a environment variable"
        * ); status = new Status(0, Activator.PLUGIN_ID,
        * "Maven Home system variable is not set." +
        * " Please execute \"mvn eclipse:eclipse\" command in the generated project "
        * + "folder to resolve dependencies."); }
        */

    try {
        project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (CoreException e) {
        log.error("Error while refreshing the project", e);
    } finally {
        monitor.done();
    }
    if (status != Status.OK_STATUS) {
        final String message = status.getMessage();
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
                MessageDialog errorDialog = new MessageDialog(shell, ERROR_TAG, null, message,
                        MessageDialog.ERROR, new String[] { OK_BUTTON }, 0);
                errorDialog.open();
            }
        });
    }
    return status;
}

From source file:org.wso2.developerstudio.msf4j.artifact.util.MSF4JProjectImporter.java

License:Open Source License

public void importMSF4JProject(MSF4JProjectModel msf4jProjectModel, String projectName, File pomFile,
        IProgressMonitor monitor) throws CoreException {
    String operationText;//w ww  . ja v a 2  s . com
    Set<MavenProjectInfo> projectSet = null;
    if (pomFile.exists()) {

        IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
        MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
        LocalProjectScanner scanner = new LocalProjectScanner(
                ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), //
                projectName, false, mavenModelManager);
        operationText = "Scanning maven project.";
        monitor.subTask(operationText);
        try {
            scanner.run(new SubProgressMonitor(monitor, 15));
            projectSet = configurationManager.collectProjects(scanner.getProjects());
            for (MavenProjectInfo projectInfo : projectSet) {
                if (projectInfo != null) {
                    saveMavenParentInfo(projectInfo);
                }
            }
            ProjectImportConfiguration configuration = new ProjectImportConfiguration();
            operationText = "importing maven project.";
            monitor.subTask(operationText);
            if (projectSet != null && !projectSet.isEmpty()) {
                List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectSet,
                        configuration, new SubProgressMonitor(monitor, 60));
            }
        } catch (InterruptedException | IOException | XmlPullParserException e) {
            Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
            MessageDialog errorDialog = new MessageDialog(shell, ERROR_TAG, null,
                    "Unable to import the project, Error occurred while importing the generated project.",
                    MessageDialog.ERROR, new String[] { OK_BUTTON }, 0);
            errorDialog.open();
        }

    } else {
    }
}

From source file:org.wso2.developerstudio.mss.artifact.ui.wizard.MSSProjectCreationWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*ww w .j ava  2  s.  com*/
        if (getModel().getSelectedOption().equals("new.MSS")) {
            // Creating new Eclipse project
            IProject project = createNewProject();
            mssArtifactModel.setGeneratedCodeLocation(project.getLocation().toOSString());
            mssArtifactModel.setProject(project);

            ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell());
            progressMonitorDialog.create();
            progressMonitorDialog.open();
            progressMonitorDialog.run(false, false, new CodegenJob());

            // Adding Microservices project nature to created project
            ProjectUtils.addNatureToProject(project, false, MSS_PROJECT_NATURE);
            // Sync physical location with Eclipse workspace
            project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        } else {
            log.error("Unsupported Microserices project creation option");
            MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null,
                    "Unsupported Microserices project creation option", MessageDialog.ERROR,
                    new String[] { OK_BUTTON }, 0);
            errorDialog.open();
            return false;
        }
    } catch (CoreException | InvocationTargetException | InterruptedException e) {
        log.error("Error while creating Microservices project for given Swagger API", e);
        MessageDialog errorDialog = new MessageDialog(getShell(), "Error", null,
                "Error while creating Microservices project for given Swagger API", MessageDialog.ERROR,
                new String[] { OK_BUTTON }, 0);
        errorDialog.open();
        return false;
    }
    return true;
}