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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferenceDialog.java

License:Open Source License

private String getPluginName(final Class<? extends Plugin> clazz) {

    try {/*ww w. ja va2 s  . c om*/

        return (String) clazz.getDeclaredMethod("getHumanReadableName").invoke(null);

    } catch (final NoSuchMethodException e) {

        final String message = "The SpyGlass Plug-In " + clazz.getCanonicalName()
                + " must implement the method \"public static String getHumanReadableName()\"";
        MessageDialog.openWarning(preferenceDialog.getShell(), "Incorrect plug-in implementation", message);
        log.error("", e);

    } catch (final Exception e) {
        log.error("", e);
    }

    return "SEE_ERROR_LOG";

}

From source file:de.uniluebeck.itm.spyglass.gui.wizard.WisebedPacketReaderConfigurationWizard.java

License:Open Source License

@Override
public boolean performFinish() {

    if (!sessionManagementEndpointUrlPage.isComplete()) {
        MessageDialog.openWarning(getShell(), "Warning",
                "Please fill in the Session Management service endpoint URL.");
        return false;
    }//from ww w.j a va2  s .c  o m

    if (!selectReservationPage.isComplete()) {
        MessageDialog.openWarning(getShell(), "Warning", "Please select a reservation.");
        return false;
    }

    String localControllerEndpointUrl = tryToAutoDetectLocalControllerEndpointUrl();

    if (localControllerEndpointUrl == null) {
        localControllerEndpointUrl = tryToGetLocalControllerEndpointUrlFromUser();
    }

    if (localControllerEndpointUrl == null) {
        return false;
    }

    WisebedPacketReaderConfigurationWizard.this.config.setControllerEndpointUrl(localControllerEndpointUrl);

    ConfidentialReservationData selectedReservation = selectReservationPage.getSelectedReservation();
    final List<SecretReservationKey> secretReservationKeys = newArrayList();
    for (Data data : selectedReservation.getData()) {
        final SecretReservationKey srk = new SecretReservationKey();
        srk.setUrnPrefix(data.getUrnPrefix());
        srk.setSecretReservationKey(data.getSecretReservationKey());
        secretReservationKeys.add(srk);
    }

    final WisebedPacketReader wisebedPacketReader = new WisebedPacketReader(config.getControllerEndpointUrl(),
            config.getSmEndpointUrl(), secretReservationKeys);

    SpyglassApp.spyglass.getConfigStore().getSpyglassConfig().setPacketReader(wisebedPacketReader);
    SpyglassApp.spyglass.getConfigStore().store();

    return true;
}

From source file:de.uniluebeck.itm.spyglass.plugin.simpleglobalinformation.SimpleGlobalInformationPreferencePage.java

License:Open Source License

@Override
protected void storeToModel() {
    super.storeToModel();

    // prevent two objects from sharing the same semantic type and description
    final Vector<StatisticalInformationEvaluator> evaluators = new Vector<StatisticalInformationEvaluator>(
            stringFormatterTable);//from  w  w  w  .j  a va  2  s  . co m
    for (int i = 0; i < evaluators.size() - 1; i++) {
        final StatisticalInformationEvaluator e1 = evaluators.get(i);
        for (int j = i + 1; j < evaluators.size(); j++) {
            final StatisticalInformationEvaluator e2 = evaluators.get(j);
            if ((e1.getSemanticType() == e2.getSemanticType())
                    && e1.getDescription().equals(e2.getDescription())) {
                final String message = "Two configurations with the same semantic type and description have been found. One description was"
                        + " slightly changed to prevent errors.";
                log.warn(message);
                MessageDialog.openWarning(null, "Duplicate Elements", message);
                e2.setDescription(e2.getDescription() + ".");
            }
        }
    }

    final Set<StatisticalInformationEvaluator> tmp = new TreeSet<StatisticalInformationEvaluator>();
    for (final StatisticalInformationEvaluator statisticalInformationEvaluator : evaluators) {
        tmp.add(statisticalInformationEvaluator.clone());
    }
    config.setStatisticalInformationEvaluators(tmp);
}

From source file:de.uniluebeck.itm.spyglass.plugin.vectorsequencepainter.VectorSequencePainterPlugin.java

License:Open Source License

@Override
protected void processPacket(final SpyglassPacket p) {

    if (p instanceof Int16ListPacket) {

        final Int16ListPacket packet = (Int16ListPacket) p;
        final List<AbsolutePosition> coordinateList;

        try {/*from ww  w .  j  a va  2 s  . co m*/

            synchronized (lock) {

                if (dimension == 2) {
                    coordinateList = packet.getCoordinates2D();
                } else {
                    coordinateList = packet.getCoordinates3D();
                }

                final Sequence sequence = new Sequence(coordinateList);
                Sequence eqSeq = getEqualSequence(sequence);

                if (eqSeq == null) {
                    sequences.add(sequence);
                    newSequences.push(sequence);
                    eqSeq = sequence;
                }

                sequenceTimes.put(eqSeq, System.currentTimeMillis());

            }

        } catch (final ParseException e) {

            if (!dimensionError) {

                Display.getDefault().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        MessageDialog.openWarning(null, "Packet parsing error",
                                "Could not parse received packet as " + dimension
                                        + "D coordinate list. Please check the dimension setting of the VectorSequencePainterPlugin named "
                                        + xmlConfig.getName() + ".");
                    }
                });

                dimensionError = true;
                reset();

            }
        }

    } else {

        if (!packetTypeError) {

            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    MessageDialog.openWarning(null, "Packet type error",
                            "The received packet has the wrong type. Please check the semantic type settings of the VectorSequencePainterPlugin named "
                                    + xmlConfig.getName() + ".");
                }
            });

            packetTypeError = true;
            reset();

        }
    }

    updateLayer();

}

From source file:de.uni_koeln.spinfo.strings.plugin.views.View.java

License:Open Source License

/**
 * Export a matching result to dot/* w w w  .  ja v  a  2s . c o m*/
 * 
 * @param p
 *            The pattern
 * @param results
 *            The Collection<String> of results
 * @param label
 *            The label for the edges between pattern and matches (like
 *            "matches")
 */
public static void writeResultToDot(String p, Collection<String> results, String label) {
    StringBuilder builder = new StringBuilder("graph{\nrankdir=LR;\n0[label=\"" + p + "\" shape=box];\n"); //$NON-NLS-1$ //$NON-NLS-2$
    int i = 1;
    for (String result : results) {
        builder.append(i + "[shape=box];\n" + i + "[label=\"" + result //$NON-NLS-1$ //$NON-NLS-2$
                + "\"];\n"); //$NON-NLS-1$
        builder.append(0 + "--" + i + "[label=\"" + label + "\"];\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        i++;
    }
    builder.append("}"); //$NON-NLS-1$
    Util.saveString(drawer.OUTPUT_FOLDER + drawer.DOT_FILE, builder.toString()); //$NON-NLS-1$
    try {
        if (drawer.DOT_APP_PATH.equals("")) { //$NON-NLS-1$
            String replaceAll = (drawer.OUTPUT_FOLDER + drawer.DOT_FILE).replaceAll("\\.dot", "\\.txt");
            Util.saveString(replaceAll, builder.toString()); //$NON-NLS-1$
            System.out.println("Setting browser to: " + replaceAll);
            browser.setUrl(replaceAll); //$NON-NLS-1$
            MessageDialog.openWarning(browser.getShell(), Messages.getString("View.CAPTION_NO_DOT_PATH_SET"), //$NON-NLS-1$
                    Messages.getString("View.CAPTION_NO_DOT_PATH_SET")); //$NON-NLS-1$

        } else {
            drawer.renderImage("png");
            update();
        }
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:de.uni_koeln.spinfo.strings.plugin.views.View.java

License:Open Source License

/**
 * Construct a tree for an input, exports it as dot
 * /*from   w w  w.  jav a  2 s .co m*/
 * @param text
 *            The text to be represented by the tree
 * @param forWords
 *            flag to indicate is this tree is for words (or chars)
 * @param reverse
 *            flag to indicate if this tree should be build for a reverse
 *            version of the text
 * @throws InterruptedException
 * @throws InvocationTargetException
 */
public static void constructTree(final String text, final boolean forWords, final boolean reverse)
        throws InvocationTargetException, InterruptedException {
    // View.update();

    long start = System.currentTimeMillis();

    AlphanumericSuffixTree tree;

    if (forWords)
        tree = new WordSuffixTree(text, reverse, true, new SimpleNodeAccessor());
    else
        tree = new CharSuffixTree(text, reverse, true, new SimpleNodeAccessor());

    // CompactSuffixTree tree = new CompactSuffixTree(new SimpleSuffixTree(
    // text, !forWords, reverse), false);
    long end = System.currentTimeMillis();
    System.out.println("Construction of Tree took: " + (end - start)); //$NON-NLS-1$

    start = System.currentTimeMillis();
    String string = drawer.DOT_FILE;
    String string2 = (drawer.OUTPUT_FOLDER + drawer.DOT_FILE.replaceAll("\\.dot", "\\.txt")); //$NON-NLS-1$
    tree.exportDot(drawer.OUTPUT_FOLDER + string);
    end = System.currentTimeMillis();
    System.out.println("Export of Tree took: " + (end - start)); //$NON-NLS-1$

    start = System.currentTimeMillis();
    if (drawer.DOT_APP_PATH.equals("")) { //$NON-NLS-1$
        Util.saveString(string2, tree.toString());
        System.out.println("Setting browser to: " + string2);
        browser.setUrl(string2);
        MessageDialog.openWarning(browser.getShell(), Messages.getString("View.CAPTION_NO_DOT_PATH_SET"), //$NON-NLS-1$
                Messages.getString("View.CAPTION_NO_DOT_PATH_SET")); //$NON-NLS-1$

    } else {
        drawer.renderImage("png");
        View.update();
    }
    end = System.currentTimeMillis();
    System.out.println("Rendering of Tree took: " + (end - start)); //$NON-NLS-1$
    size = tree.getAllNodes(tree.getRoot(), new ArrayList<Node>(), false).size();

    label.setText("" + size); //$NON-NLS-1$
}

From source file:de.uni_koeln.spinfo.strings.plugin.views.View.java

License:Open Source License

/**
 * Construct a tree for an input, exports it as dot
 * //from w ww.  java  2  s.  c o m
 * @param text
 *            The text to be represented by the tree
 * @param forWords
 *            flag to indicate is this tree is for words (or chars)
 * @param reverse
 *            flag to indicate if this tree should be build for a reverse
 *            version of the text
 * @throws InterruptedException
 * @throws InvocationTargetException
 */
public static void constructDAG(final String text, final boolean forWords, final boolean reverse)
        throws InvocationTargetException, InterruptedException {
    // View.update();

    long start = System.currentTimeMillis();

    AlphanumericSuffixTree tree;

    if (forWords)
        tree = new WordSuffixTree(text, reverse, true, new SimpleNodeAccessor());
    else
        tree = new CharSuffixTree(text, reverse, true, new SimpleNodeAccessor());
    DAG dag = new DAG(tree);
    long end = System.currentTimeMillis();
    System.out.println("Construction of Tree took: " + (end - start)); //$NON-NLS-1$

    start = System.currentTimeMillis();
    String string = drawer.DOT_FILE;
    String string2 = (drawer.OUTPUT_FOLDER + drawer.DOT_FILE.replaceAll("\\.dot", "\\.txt")); //$NON-NLS-1$
    ((AlphanumericSuffixTree) dag.graph).exportDot(drawer.OUTPUT_FOLDER + string);
    end = System.currentTimeMillis();
    System.out.println("Export of Tree took: " + (end - start)); //$NON-NLS-1$

    start = System.currentTimeMillis();
    if (drawer.DOT_APP_PATH.equals("")) { //$NON-NLS-1$
        Util.saveString(string2, ((AlphanumericSuffixTree) dag.graph).toString());
        System.out.println("Setting browser to: " + string2);
        browser.setUrl(string2);
        MessageDialog.openWarning(browser.getShell(), Messages.getString("View.CAPTION_NO_DOT_PATH_SET"), //$NON-NLS-1$
                Messages.getString("View.CAPTION_NO_DOT_PATH_SET")); //$NON-NLS-1$

    } else {
        drawer.renderImage("png");
        View.update();
    }
    end = System.currentTimeMillis();
    System.out.println("Rendering of Tree took: " + (end - start)); //$NON-NLS-1$
    size = ((AlphanumericSuffixTree) dag.graph)
            .getAllNodes(((AlphanumericSuffixTree) dag.graph).getRoot(), new ArrayList<Node>(), false).size();

    label.setText("" + size); //$NON-NLS-1$
}

From source file:de.uni_koeln.ub.drc.ui.views.WordView.java

License:Open Source License

private boolean currentUserMayVote(Modification modification) {
    User user = SessionContextSingleton.getInstance().getCurrentUser();
    if (modification.author().equals(user.id())) {
        MessageDialog.openWarning(viewer.getControl().getShell(), Messages.get().CannotVoteForOwnShort,
                Messages.get().CannotVoteForOwnLong);
        return false;
    }/* www  .ja  v  a 2  s .c  o  m*/
    if (modification.voters().contains(user.id())) {
        MessageDialog.openWarning(viewer.getControl().getShell(), Messages.get().CanVoteOnlyOnceShort,
                Messages.get().CanVoteOnlyOnceLong);
        return false;
    }
    return true;
}

From source file:de.walware.ecommons.debug.ui.UnterminatedLaunchAlerter.java

License:Open Source License

@Override
public boolean preShutdown(final IWorkbench workbench, final boolean forced) {
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    final List<ILaunchConfigurationType> programTypes = new LinkedList<ILaunchConfigurationType>();
    synchronized (gMutex) {
        for (final String id : fLauchTypeIds) {
            final ILaunchConfigurationType programType = manager.getLaunchConfigurationType(id);
            if (programType != null) {
                programTypes.add(programType);
            }/*  ww w  . j a v a  2  s .co  m*/
        }
    }
    if (programTypes.isEmpty()) {
        return true;
    }

    final Set<ILaunchConfigurationType> stillRunningTypes = new HashSet<ILaunchConfigurationType>();
    int count = 0;
    final ILaunch launches[] = manager.getLaunches();
    for (final ILaunch launch : launches) {
        ILaunchConfigurationType configType;
        ILaunchConfiguration config;
        try {
            config = launch.getLaunchConfiguration();
            if (config == null) {
                continue;
            }
            configType = config.getType();
        } catch (final CoreException e) {
            continue;
        }
        if (programTypes.contains(configType) && !launch.isTerminated()) {
            count++;
            stillRunningTypes.add(configType);
        }
    }
    if (stillRunningTypes.isEmpty()) {
        return true;
    }

    final StringBuilder names = new StringBuilder(stillRunningTypes.size() * 20);
    names.append('\n');
    for (final ILaunchConfigurationType type : stillRunningTypes) {
        names.append("- "); //$NON-NLS-1$
        names.append(type.getName());
        names.append('\n');
    }
    final String message = NLS.bind(Messages.UnterminatedLaunchAlerter_WorkbenchClosing_message,
            new Object[] { count, names });
    if (forced) {
        MessageDialog.openWarning(UIAccess.getDisplay().getActiveShell(),
                Messages.UnterminatedLaunchAlerter_WorkbenchClosing_title, message);
        return true;
    } else {
        final MessageDialog dialog = new MessageDialog(UIAccess.getDisplay().getActiveShell(),
                Messages.UnterminatedLaunchAlerter_WorkbenchClosing_title, null, message, MessageDialog.WARNING,
                new String[] { Messages.UnterminatedLaunchAlerter_WorkbenchClosing_button_Continue,
                        Messages.UnterminatedLaunchAlerter_WorkbenchClosing_button_Cancel, },
                1);
        final int answer = dialog.open();
        if (answer == 1) {
            return false;
        }
        return true;
    }
}

From source file:distributed.plugin.ui.models.topologies.Matrix.java

License:Open Source License

/**
 * @see distributed.plugin.ui.models.topologies.ITopology#createTopology(int)
 *//*  w  w w  .java  2s  .  com*/
public void createTopology() {
    GraphMatrixFileInputDialog dialog = new GraphMatrixFileInputDialog(this.shell);
    dialog.open();

    if (!dialog.isCancel()) {
        this.isCancel = false;
        this.path = dialog.getFile();
        try {
            if (this.path == null) {
                throw new NullPointerException("Input file is null");
            }
            this.constructMatrix();
            this.numNode = this.matrix[0].length;
            this.createNodes();

        } catch (IOException e) {
            this.isCancel = true;
            MessageDialog.openWarning(this.shell, "Error",
                    String.format("File %s Not foud or Invalid file", this.path.getName()));

        } catch (NumberFormatException e) {
            this.isCancel = true;
            MessageDialog.openWarning(this.shell, "Error",
                    String.format("File %s must contain only integer matrix", this.path.getName()));

        } catch (NullPointerException e) {
            this.isCancel = true;
            MessageDialog.openWarning(this.shell, "Error",
                    String.format("File path not found: %s", e.toString()));

        } catch (Exception e) {
            this.isCancel = true;
            MessageDialog.openWarning(this.shell, "Error",
                    String.format("File %s contains invalid format", this.path.getName()));

        }
    }
}