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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.bluexml.side.clazz.generator.alfresco.handlers.SampleHandler.java

License:Open Source License

/**
 * the command has been executed, so extract extract the needed information
 * from the application context./*w  ww.j av a  2  s  . c  o  m*/
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    MessageDialog.openInformation(window.getShell(), "alfresco Class Generator", "Hello, Eclipse world");
    return null;
}

From source file:com.bluexml.side.Requirements.modeler.RequirementsPlugin.java

License:Open Source License

/**
 * Display a dialog box with the specified level
 * // w  w  w . ja  va  2  s.  c  o  m
 * @param title title dialog box
 * @param message message displayed
 * @param level message level
 * @generated
 */
public static void displayDialog(final String title, final String message, final int level) {
    if (level == IStatus.INFO) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openInformation(getActiveWorkbenchShell(),
                        (title == null) ? "Information" : title, (message == null) ? "" : message);
            }
        });
    } else if (level == IStatus.WARNING) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openWarning(getActiveWorkbenchShell(), (title == null) ? "Warning" : title,
                        (message == null) ? "" : message);
            }
        });
    } else if (level == IStatus.ERROR) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openError(getActiveWorkbenchShell(), (title == null) ? "Error" : title,
                        (message == null) ? "" : message);
            }
        });
    }
}

From source file:com.bluexml.side.Requirements.modeler.wizards.ImportAnnotationWizard.java

License:Open Source License

public boolean performFinish() {
    annotationsImported = 0;//from  w ww  .j a v  a 2  s . com
    annotationsReaded = 0;
    annotationsExisting = 0;

    ResourceSet rs = new ResourceSetImpl();
    Resource.Factory.Registry f = rs.getResourceFactoryRegistry();
    Map<String, Object> extm = f.getExtensionToFactoryMap();
    extm.put("xmi", new XMIResourceFactoryImpl());
    extm.put("ecore", new EcoreResourceFactoryImpl());
    extm.put("requirements", new RequirementsResourceFactory());

    IWorkbenchWindow iww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ISelectionService iss = iww.getSelectionService();
    ISelection sel = iss.getSelection();
    if (sel instanceof IStructuredSelection) {
        IStructuredSelection ssel = (IStructuredSelection) sel;
        if (ssel.getFirstElement() instanceof IFile) {
            IFile model = (IFile) ssel.getFirstElement();
            Map<String, Annotation> annotations = new HashMap<String, Annotation>();
            Map<String, EObject> objects = new HashMap<String, EObject>();
            RequirementsDefinition def = null;
            RequirementsResource xmi = null;

            Map<?, ?> m = new HashMap<Object, Object>();
            try {
                URI uri = URI.createFileURI(model.getRawLocation().toString());
                Resource r = EResourceUtils.createResource(uri, rs);//rs.getResource(uri, true);
                r.load(m);
                xmi = (RequirementsResource) r;
                for (Iterator<EObject> iterator = xmi.getAllContents(); iterator.hasNext();) {
                    EObject obj = (EObject) iterator.next();
                    if (def == null)
                        if (obj instanceof RequirementsDefinition)
                            def = (RequirementsDefinition) obj;
                    if (obj instanceof Annotation) {
                        Annotation a = (Annotation) obj;
                        annotations.put(a.getId(), a);
                    }
                    if (obj instanceof BasicElement) {
                        BasicElement elt = (BasicElement) obj;
                        objects.put(elt.getId(), elt);
                    }
                }

            } catch (Exception e1) {
                MessageDialog.openError(getShell(), "Problem during reading of input model !", e1.getMessage());
                return false;
            }

            if (model.getName().endsWith(".requirements")) {

                //Connexion to database
                String host = mainPage.host.getText();
                String username = mainPage.user.getText();
                String password = mainPage.password.getText();
                String database = mainPage.database.getText();

                try {
                    String pilote = "com.mysql.jdbc.Driver";
                    Class.forName(pilote);

                    Connection connexion = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database,
                            username, password);

                    Statement instruction = connexion.createStatement();

                    ResultSet resultat = instruction.executeQuery("SELECT * FROM annotation;");
                    while (resultat.next()) {
                        annotationsReaded++;

                        String id = Integer.toString(resultat.getInt("id"));
                        String elementId = resultat.getString("elementId");
                        String author = resultat.getString("author");
                        String annotation = resultat.getString("annotation");
                        String comment = resultat.getString("comment");
                        Date date = null;
                        try {
                            date = resultat.getDate("date");
                        } catch (Exception e) {
                            //Nothing to do
                        }

                        if (!annotations.containsKey(id)) {
                            Annotation a = RequirementsFactory.eINSTANCE.createAnnotation();
                            a.setAnnotation(annotation);
                            a.setAuthor(author);
                            a.setComment(comment);
                            a.setDate(date);
                            a.setId(id);
                            a.setStatus(AnnotationStatus.NEW);

                            if (objects.containsKey(elementId)) {
                                EObject obj = objects.get(elementId);
                                if (obj instanceof AnnotableElement) {
                                    annotationsImported++;
                                    AnnotableElement a_elt = (AnnotableElement) obj;
                                    a_elt.getAnnotation().add(a);
                                }
                            }
                        } else {
                            annotationsExisting++;
                        }
                    }

                    MessageDialog.openInformation(getShell(), "Success",
                            annotationsReaded + " annotation(s) have been read and " + annotationsImported
                                    + " annotation(s) have been imported. " + annotationsExisting
                                    + " annotation(s) are already present.");
                } catch (Exception e) {
                    MessageDialog.openError(getShell(), "Problem during connexion !", e.getMessage());
                    return false;
                }
            }

            //Save the file
            if (def != null && xmi != null) {
                xmi.getContents().clear();
                xmi.getContents().add(def);
                try {
                    xmi.save(m);
                } catch (IOException e) {
                    MessageDialog.openError(getShell(), "Problem during saving !", e.getMessage());
                    return false;
                }
            }

        } else {
            MessageDialog.openError(getShell(), "Incompatible selected file",
                    "You don't have selected a file or it is not a requirements model.");
            return false;
        }
    }
    return true;
}

From source file:com.bluexml.side.Util.ecore.modeler.AbstractModelerOpenLinkedObject.java

License:Open Source License

@Override
public void run() {

    // Search the good view model
    // Get project
    IFile iFile = XMIResource2IFile((XMIResource) selectedObject.eResource());
    project = iFile.getProject();//from www  .j av  a  2s . co m

    List<EObject> views = searchEObject();

    if (views.size() == 0) {
        setMessages();
        MessageDialog.openInformation(null, message1, message2);
    } else {
        recomputeAndSelect(views);
    }
}

From source file:com.bluexml.side.Workflow.modeler.actions.popup.ShowFormAction.java

License:Open Source License

@Override
public void run() {
    // Search the good form model
    // Get project
    IFile iFile = XMIResource2IFile((XMIResource) selectedObject.eResource());
    IProject project = iFile.getProject();

    List<WorkflowFormCollection> wfl = searchFormModel(project);
    List<FormWorkflow> forms = searchForm(wfl, selectedObject);

    if (forms.size() == 0)
        MessageDialog.openInformation(null, WorkflowPlugin.Messages.getString("ShowFormAction.1"), //$NON-NLS-1$
                WorkflowPlugin.Messages.getString("ShowFormAction.2", project.getName()) //$NON-NLS-1$
        ); //$NON-NLS-1$
    else {/*w w  w  .  j  av a 2 s.  c  om*/
        recomputeAndSelect(forms, selectedObject);
    }
}

From source file:com.bmw.spdxeditor.SPDXPreferencesPage.java

License:Apache License

protected void performApply() {
    System.out.println("performApply");
    IPreferenceStore store = getPreferenceStore();
    if (creatorText.getText().equalsIgnoreCase("noassertion")) {
        store.setValue(DEFAULT_FILE_CREATOR, "NOASSERTION");
    } else if (StringUtils.isEmpty(creatorTypes.getText())) {
        MessageDialog.openError(getShell(), "Error", "Select value in dropdown box first.");
    } else if (StringUtils.isEmpty(creatorText.getText())) {
        MessageDialog.openError(getShell(), "Error", "Enter value for creator name.");
    } else {// ww w .j a  v a 2s .  c o  m
        String defaultCreator = creatorTypes.getText() + ":" + creatorText.getText();
        logger.info("Default creator set to: {}", defaultCreator);
        store.setValue(DEFAULT_FILE_CREATOR, defaultCreator);
        MessageDialog.openInformation(getShell(), "Creator set", "Default SPDX file creator has been set.");
    }
    System.out.println("storeNeedsSaving: " + store.needsSaving());
}

From source file:com.brosinski.eclipse.regex.view.actions.AboutAction.java

License:Open Source License

public void run() {
    Dictionary d = RegExPlugin.getDefault().getBundle().getHeaders();
    String version = (String) d.get(org.osgi.framework.Constants.BUNDLE_VERSION);

    String msg = "Regular Expression Tester " + version + "\n";
    msg += "(C) 2006-2012 by Stephan Brosinski <sbrosinski@gmail.com>\n\n";
    msg += "https://github.com/sbrosinski/RegexTester \n";

    MessageDialog.openInformation(view.getSite().getShell(), "About RegexTester", msg);

}

From source file:com.buglabs.dragonfly.ui.editors.DragonflyEditorContributor.java

License:Open Source License

private void createActions() {
    sampleAction = new Action() {
        public void run() {
            MessageDialog.openInformation(null, Messages.getString("DragonflyEditorContributor.0"), //$NON-NLS-1$
                    Messages.getString("DragonflyEditorContributor.1")); //$NON-NLS-1$
        }/*  w  w w .ja v a 2s  .c o  m*/
    };
    sampleAction.setText(Messages.getString("DragonflyEditorContributor.2")); //$NON-NLS-1$
    sampleAction.setToolTipText(Messages.getString("DragonflyEditorContributor.3")); //$NON-NLS-1$
    sampleAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
}

From source file:com.buglabs.dragonfly.ui.editors.ProgramEditorContributor.java

License:Open Source License

private void createActions() {
    sampleAction = new Action() {
        public void run() {
            MessageDialog.openInformation(null, Messages.getString("ProgramEditorContributor.0"), //$NON-NLS-1$
                    Messages.getString("ProgramEditorContributor.1")); //$NON-NLS-1$
        }/*from  w  w  w  . ja  v  a 2  s.c  o m*/
    };
    sampleAction.setText(Messages.getString("ProgramEditorContributor.2")); //$NON-NLS-1$
    sampleAction.setToolTipText(Messages.getString("ProgramEditorContributor.3")); //$NON-NLS-1$
    sampleAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
}

From source file:com.buglabs.dragonfly.util.UIUtils.java

License:Open Source License

/**
 * Displays information message to the user
 * // w  w  w  .j  ava2  s  .c  o  m
 * @param message
 */
public static void giveVisualInformation(final String message) {
    final Display disp = PlatformUI.getWorkbench().getDisplay();
    disp.syncExec(new Runnable() {
        public void run() {
            MessageDialog.openInformation(new Shell(disp), "Information", message);
        }
    });
}