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

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

Introduction

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

Prototype

int INFORMATION

To view the source code for org.eclipse.jface.dialogs MessageDialog INFORMATION.

Click Source Link

Document

Constant for the info image, or a simple dialog with the info image and a single OK button (value 2).

Usage

From source file:cu.uci.abos.core.util.MessageDialogUtil.java

License:Open Source License

public static void openInformation(Shell parent, String title, String message, final DialogCallback callback) {
    open(MessageDialog.INFORMATION, parent, title, message, callback);
}

From source file:cu.uci.abos.core.util.MessageDialogUtil.java

License:Open Source License

private static String[] getButtonLabels(int kind) {
    String[] dialogButtonLabels;//from ww  w .j a v a  2  s  . c  om
    switch (kind) {
    case MessageDialog.ERROR:
    case MessageDialog.INFORMATION:
    case MessageDialog.WARNING: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_CLOSE };
        break;
    }
    case MessageDialog.CONFIRM: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT,
                AbosMessages.get().BUTTON_CANCEL };
        break;
    }
    case MessageDialog.QUESTION: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT,
                AbosMessages.get().BUTTON_CANCEL };
        break;
    }
    case MessageDialog.QUESTION_WITH_CANCEL: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL,
                AbosMessages.get().BUTTON_CLOSE };
        break;
    }
    default: {
        throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()");
    }
    }
    return dialogButtonLabels;
}

From source file:de.ovgu.featureide.fm.ui.GraphicsExporter.java

License:Open Source License

public static boolean exportAs(GraphicalViewerImpl viewer, File file) {
    boolean succ = false;

    if (file.getAbsolutePath().endsWith(".svg")) {
        ScalableFreeformRootEditPart part = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry()
                .get(LayerManager.ID);/*  www. j  a va 2s  .c om*/
        IFigure rootFigure = part.getFigure();
        Bundle bundleExportSVG = null;
        for (Bundle b : InternalPlatform.getDefault().getBundleContext().getBundles()) {
            if (b.getSymbolicName().equals("nl.utwente.ce.imageexport.svg")) {
                bundleExportSVG = b;
                break;
            }
        }

        // check if gef-imageexport is existing and activated!
        if (bundleExportSVG != null) {
            try {
                org.osgi.framework.BundleActivator act = ((org.osgi.framework.BundleActivator) bundleExportSVG
                        .loadClass("nl.utwente.ce.imagexport.export.svg.Activator").newInstance());
                act.start(InternalPlatform.getDefault().getBundleContext());

                Class<?> cl = bundleExportSVG.loadClass("nl.utwente.ce.imagexport.export.svg.ExportSVG");
                Method m = cl.getMethod("exportImage", String.class, String.class, IFigure.class);
                m.invoke(cl.newInstance(), "SVG", file.getAbsolutePath(), rootFigure);
                succ = true;
            } catch (Exception e) {
                FMUIPlugin.getDefault().logError(e);
            }
        } else {
            final String infoMessage = "Eclipse plugin for exporting diagram in SVG format is not existing."
                    + "\nIf you want to use this, you have to install GEF Imageexport with SVG in Eclipse from "
                    + "\nhttp://veger.github.com/eclipse-gef-imageexport";

            MessageDialog dialog = new MessageDialog(new Shell(), "SVG export failed",
                    FMUIPlugin.getImage("FeatureIconSmall.ico"), infoMessage, MessageDialog.INFORMATION,
                    new String[] { IDialogConstants.OK_LABEL }, 0);

            dialog.open();
            FMUIPlugin.getDefault().logInfo(infoMessage);
            return false;
        }
    } else {
        GEFImageWriter.writeToFile(viewer, file);
        succ = true;
    }

    GraphicsExporter.printExportMessage(file, succ);

    return succ;
}

From source file:de.ovgu.featureide.ui.statistics.core.CsvExporter.java

License:Open Source License

/**
 * Puts the description of each selected node in the first row as header and
 * it's value in the second row.//from w ww. j  a v  a  2 s .c  o m
 * 
 */
private void actualExport() {
    Job job = new Job("Export statistics into csv") {

        private StringBuilder firstBuffer;
        private StringBuilder secondBuffer;

        @Override
        protected IStatus run(IProgressMonitor monitor) {

            List<String> descs = new LinkedList<String>();
            List<String> vals = new LinkedList<String>();
            getExportData(descs, vals);
            firstBuffer = new StringBuilder();
            secondBuffer = new StringBuilder();
            prepareDataForExport(descs, vals, firstBuffer, secondBuffer);
            return actualWriting();
        }

        /**
         * @param firstBuffer
         * @param secondBuffer
         * @return
         */
        private IStatus actualWriting() {
            BufferedWriter writer = null;

            if (!returnVal.endsWith(".csv")) {
                returnVal += ".csv";
            }
            File file = new File(returnVal);
            try {
                if (!file.exists()) {
                    file.createNewFile();
                }
                writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
                writer.write(firstBuffer.toString());
                writer.newLine();
                writer.write(secondBuffer.toString());
            } catch (FileNotFoundException e) {
                giveUserFeedback(true);
                return Status.CANCEL_STATUS;
            } catch (IOException e) {
                UIPlugin.getDefault().logError(e);
            } finally {
                if (writer != null) {
                    try {
                        writer.close();
                    } catch (IOException e) {
                        UIPlugin.getDefault().logError(e);
                    }
                }
            }
            giveUserFeedback(false);
            return Status.OK_STATUS;
        }

        /**
         * 
         */
        private void giveUserFeedback(final boolean error) {
            UIJob errorJob = new UIJob(error ? "show errordialog" : "show dialog") {

                @Override
                public IStatus runInUIThread(IProgressMonitor monitor) {
                    Shell shell = Display.getDefault().getActiveShell();
                    if (error) {
                        MessageDialog dial = new MessageDialog(shell, "Error", GUIDefaults.FEATURE_SYMBOL,
                                "The file cannot be accessed!\nTry again?", MessageDialog.ERROR,
                                new String[] { "OK", "Cancel" }, 0);
                        if (dial.open() == 0) {
                            actualWriting();
                        }
                    } else {
                        // MessageDialog.openInformation(shell, ,
                        // "Data was successfully exported.");
                        new MessageDialog(shell, "Success", GUIDefaults.FEATURE_SYMBOL,
                                "Data was successfully exported", MessageDialog.INFORMATION,
                                new String[] { "OK" }, 0).open();
                    }

                    return Status.OK_STATUS;
                }
            };
            errorJob.setPriority(INTERACTIVE);
            errorJob.schedule();
        }

        /**
         * @param descs
         * @param vals
         * @param buffer
         * @param secBuf
         */
        private void prepareDataForExport(List<String> descs, List<String> vals, StringBuilder buffer,
                StringBuilder secBuf) {
            for (String desc : descs) {
                buffer.append(desc);
                buffer.append(SEPARATOR);
            }
            for (String val : vals) {
                secBuf.append(val);
                secBuf.append(SEPARATOR);
            }
        }

        /**
         * @param descs
         * @param vals
         */
        private void getExportData(List<String> descs, List<String> vals) {
            descs.add("Description: ");
            vals.add("Value: ");
            Parent last = null;
            for (Object o : visibleExpandedElements) {
                if (o instanceof Parent) {
                    Parent parent = ((Parent) o);
                    if (parent.getParent().equals(last)) {
                        int end = descs.size() - 1;
                        descs.set(end, descs.get(end) + ":");
                    }
                    descs.add(parent.getDescription());
                    vals.add(parent.getValue() != null ? parent.getValue().toString() : "");
                    last = parent;
                }
            }
        }
    };
    job.setPriority(Job.SHORT);
    job.schedule();
}

From source file:de.ovgu.featureide.ui.views.collaboration.action.DeleteAction.java

License:Open Source License

public void run() {
    MessageDialog messageDialog = new MessageDialog(null, "Delete Resources", null,
            "Are you sure you want to remove " + getDialogText(), MessageDialog.INFORMATION,
            new String[] { "OK", "Cancel" }, 0);
    if (messageDialog.open() != 0) {
        return;//  w w w  . j  a v  a2s  .  c  o  m
    }
    if (part instanceof RoleEditPart) {
        Role role = ((RoleEditPart) part).getRoleModel();
        try {
            role.getRoleFile().delete(true, null);
        } catch (CoreException e) {
            UIPlugin.getDefault().logError(e);
        }
    } else if (part instanceof ClassEditPart) {
        Class c = ((ClassEditPart) part).getClassModel();
        List<Role> roles = c.getRoles();
        for (Role role : roles) {
            //if (part != null)
            try {
                role.getRoleFile().delete(true, null);
            } catch (CoreException e) {
                UIPlugin.getDefault().logError(e);
            }
        }

    } else if (part instanceof CollaborationEditPart) {
        Collaboration coll = ((CollaborationEditPart) part).getCollaborationModel();
        for (Role role : coll.getRoles()) {
            try {
                role.getRoleFile().delete(true, null);
            } catch (CoreException e) {
                UIPlugin.getDefault().logError(e);
            }
        }
    }

}

From source file:de.quamoco.qm.properties.eval.util.Util.java

License:Apache License

public static void showInfoDialog(String title, String message) {
    showOkMessageDialog(title, message, MessageDialog.INFORMATION);
}

From source file:de.tub.tfs.henshin.editor.actions.HenshinDeleteAction.java

License:Open Source License

private boolean canDeleteEPackage(Object targetObject, EPackage ePackage) {
    Module rootModel = (Module) ((EditPart) targetObject).getParent().getParent().getModel();
    String errMsg = ModelUtil.getEPackageReferences(ePackage, rootModel);

    if (errMsg != null) {
        MessageDialog.open(MessageDialog.INFORMATION, null, "Delete Failed", "EPackage [" + ePackage.getName()
                + "] is used in:\n\n" + errMsg + "\n\nPlease delete all references first.", SWT.NONE);
        return false;
    }//from  ww w . j  av  a  2s  .  co m

    return true;
}

From source file:de.tub.tfs.henshin.editor.editparts.graph.graphical.GraphEditPart.java

License:Open Source License

@Override
protected IFigure createFigure() {
    FreeformLayer layer = new FreeformLayer();
    layer.setLayoutManager(new FreeformLayout());
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    cLayer.setAntialias(SWT.ON);/*from w w w  . java  2  s  . c om*/
    EdgeConnectionRouter edgeRouter = new EdgeConnectionRouter(layer);
    if (this.getCastedModel().getEdges().size() > 1000) {
        edgeRouter.setNextRouter(ConnectionRouter.NULL);

        MessageDialog.open(MessageDialog.INFORMATION, Display.getDefault().getActiveShell(), "Information",
                "The graph has too many edges. Therefore the edges will not be drawn around nodes.", SWT.SHEET);

    }
    cLayer.setConnectionRouter(edgeRouter);

    return layer;
}

From source file:de.tub.tfs.henshin.tggeditor.editparts.graphical.GraphEditPart.java

License:Open Source License

@Override
protected IFigure createFigure() {
    FreeformLayer layer = new FreeformLayer() {

        @Override/*from w  w w  .  j av a 2s .c  o  m*/
        protected void paintClientArea(Graphics graphics) {
            super.paintClientArea(graphics);
            Rectangle rect = getCorrectedBounds(this.getBounds(), this.getChildren(),
                    new HashSet<Class<? extends Figure>>(Arrays.asList(RectangleFigure.class)));

            if (tripleGraph.getDividerSC_X() == 0) {
                tripleGraph.setDividerSC_X(rect.width / 2 - rect.width / 8);
                tripleGraph.setDividerMaxY(rect.height - rect.y);
                tripleGraph.setDividerCT_X(rect.width / 2 + rect.width / 8);
                tripleGraph.setDividerMaxY(rect.height - rect.y);
            } else if (height != rect.height) {
                height = rect.height;
                if (rect.height + 20 - rect.y != tripleGraph.getDividerMaxY())
                    tripleGraph.setDividerMaxY(rect.height + 20 - rect.y);
            } else if (tripleGraph.getDividerMaxY() + rect.y > rect.height + 20) {
                if (rect.height + 20 - rect.y != tripleGraph.getDividerMaxY())
                    tripleGraph.setDividerMaxY(rect.height - 20 - rect.y);
            } else {
                if (rect.height + 20 - rect.y != tripleGraph.getDividerMaxY())
                    tripleGraph.setDividerMaxY(rect.height + 20 - rect.y);
            }
            if (rect.y != tripleGraph.getDividerYOffset())
                tripleGraph.setDividerYOffset(rect.y);
        }

        @Override
        public void paint(Graphics graphics) {
            graphics.pushState();
            String text = nameLabel.getText();
            graphics.setForegroundColor(TGGEditorConstants.FG_STANDARD_COLOR);
            TextLayout textLayout = new TextLayout(null);
            textLayout.setText(text);
            textLayout.setFont(TGGEditorConstants.TEXT_TITLE_FONT);
            graphics.drawTextLayout(textLayout, 5, 5);
            textLayout.dispose();

            graphics.popState();
            super.paint(graphics);

        }
    };
    layer.setLayoutManager(new TGGLayoutManager());
    nameLabel = new Label();
    nameLabel.setFont(TGGEditorConstants.TEXT_TITLE_FONT_SMALL);
    nameLabel.setForegroundColor(TGGEditorConstants.FG_STANDARD_COLOR);
    setFigureNameLabel();

    //layer.add(nameLabel, new Rectangle(10,10,-1,-1));

    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);

    cLayer.setAntialias(SWT.ON);
    EdgeConnectionRouter edgeRouter = new EdgeConnectionRouter(layer);
    if (this.getCastedModel().getEdges().size() > 1000) {
        edgeRouter.setNextRouter(ConnectionRouter.NULL);
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                MessageDialog.open(MessageDialog.INFORMATION, Display.getDefault().getActiveShell(),
                        "Information",
                        "The graph has too many edges. Therefore the edges will not be drawn around nodes.",
                        SWT.SHEET);
            }
        });

    }
    cLayer.setConnectionRouter(edgeRouter);
    return layer;
}

From source file:edu.harvard.i2b2.eclipse.plugins.querytool.ui.utils.UIUtils.java

License:Open Source License

public static void popupMessage(final String title, final String message) {
    Display.getCurrent().syncExec(new Runnable() {
        public void run() {
            MessageDialog.open(MessageDialog.INFORMATION,
                    QueryToolViewAccessor.getInstance().getQueryToolView().getWorkbenchShell(), title, message,
                    SWT.NONE);/*from   w w w.  j ava  2  s .  com*/
        }
    });
}