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

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

Introduction

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

Prototype

public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
        int dialogImageType, int defaultIndex, String... dialogButtonLabels) 

Source Link

Document

Create a message dialog.

Usage

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformWidget.java

License:Apache License

/** 
 * @param inputLinkSchema//from  w w w.  j  a  v  a 2s  .co  m
 * @param currentCompSchema
 */
private boolean compareSchemaFields(List<GridRow> inputLinkSchema, List<GridRow> currentCompSchema) {
    for (int index = 0; index < currentCompSchema.size() - 1; index++) {
        for (GridRow gridRow : inputLinkSchema) {
            if (StringUtils.equals(gridRow.getFieldName(), currentCompSchema.get(index).getFieldName())) {
                if (!StringUtils.equals(gridRow.getDataTypeValue(),
                        currentCompSchema.get(index).getDataTypeValue())) {
                    MessageDialog dialog = new MessageDialog(new Shell(), "Warning", null,
                            "Output Schema is updated,Do you want to continue with changes?",
                            MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0);
                    int dialogResult = dialog.open();
                    if (dialogResult == 0) {
                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.ELTSchemaGridWidget.java

License:Apache License

private void propagateInternalSchema() {
    if (schemaGridRowList != null) {
        if (SchemaSyncUtility.INSTANCE.isAutoSchemaSyncAllow(getComponent().getComponentName())) {

            if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInMappingWidget(getComponent(),
                    schemaGridRowList)) {

                MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null,
                        Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM,
                        new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0);
                if (dialog.open() == 0) {
                    if (isSchemaUpdated)
                        SchemaSyncUtility.INSTANCE.pushSchemaToMapping(getComponent(), schemaGridRowList);
                    else
                        updateSchemaWithPropogatedSchema();
                }/*  w w  w . j  a  v a2s .c  o  m*/
            }
        }

    }
}

From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java

License:Apache License

/**
 * //from ww w  .j  a va 2s. c  o m
 * Message dialog to be displayed if compare_fields() method returns false. 
 * 
 */
public int Message_Dialog() {

    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Rearrange Fields", null,
            Messages.HIVE_PARTI_SEQ_ERROR, MessageDialog.ERROR,
            new String[] { "Rearrange Schema", "Rearrange Partition Fields" }, 0);
    int result = dialog.open();
    return result;
}

From source file:hydrograph.ui.propertywindow.widgets.utility.SchemaSyncUtility.java

License:Apache License

public void autoSyncSchema(Schema SchemaForInternalPropagation, Component component,
        List<AbstractWidget> widgets) {
    if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInSchemaTab(SchemaForInternalPropagation.getGridRow(),
            (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME))) {
        MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null,
                Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM,
                new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0);
        if (dialog.open() == 0) {
            getSchemaGridWidget(widgets).updateSchemaWithPropogatedSchema();
        }//from  w  w  w. j av  a2 s.  co  m
    }
}

From source file:ilg.gnuarmeclipse.packs.data.Utils.java

License:Open Source License

public static boolean copyFileWithShell(final URL sourceUrl, File destinationFile, MessageConsoleStream out,
        IProgressMonitor monitor, final Shell shell) throws IOException {

    while (true) {
        try {// w w  w  .j  a v a 2 s  .  co m
            Utils.copyFile(sourceUrl, destinationFile, out, monitor);
            return true;
        } catch (final IOException e) {

            class ErrorMessageDialog implements Runnable {

                public int retCode = 0;

                @Override
                public void run() {
                    String[] buttons = new String[] { "Retry", "Ignore", "Abort" };
                    MessageDialog dialog = new MessageDialog(shell, "Read error", null,
                            sourceUrl.toString() + "\n" + e.getMessage(), MessageDialog.ERROR, buttons, 0);
                    retCode = dialog.open();
                }
            }

            ErrorMessageDialog messageDialog = new ErrorMessageDialog();
            Display.getDefault().syncExec(messageDialog);

            if (messageDialog.retCode == 2) {
                throw e; // Abort
            } else if (messageDialog.retCode == 1) {
                return false; // Ignore
            }

            // Else try again
        }
    }

    // HandlerUtil.getActiveShell(event)
}

From source file:ilg.gnuarmeclipse.packs.ui.views.PacksView.java

License:Open Source License

private boolean checkCopyDestinationFolders(TreeSelection selection, String[] param) {

    IPath m_destFolderPath = new Path(param[0]);

    boolean isNonEmpty = false;
    for (Object sel : selection.toList()) {

        PackNode exampleNode = (PackNode) sel;

        Leaf outlineExampleNode = exampleNode.getOutline().findChild(Type.EXAMPLE);

        String exampleRelativeFolder = outlineExampleNode.getProperty(Node.FOLDER_PROPERTY);

        File destFolder = m_destFolderPath.append(exampleRelativeFolder).toFile();

        if (destFolder.isDirectory() && (destFolder.listFiles().length > 0)) {
            isNonEmpty = true;/*w  w  w. j  a va  2 s .co m*/
            break;
        }

    }

    if (isNonEmpty) {

        String msg = "One of the destination folders is not empty.";
        msg += "\nDo you agree to delete the previous content?";

        String[] buttons = new String[] { "OK", "Cancel" };
        MessageDialog dlg = new MessageDialog(fComposite.getShell(), null, null, msg, MessageDialog.ERROR,
                buttons, 0);
        if (dlg.open() == 0) {
            return true; // OK
        }

        return false;
    }
    return true;
}

From source file:ilg.gnumcueclipse.packs.data.Utils.java

License:Open Source License

/**
 * //from   w  w w .j a v  a  2s  .c  o m
 * @param sourceUrl
 * @param destinationFile
 * @param out
 * @param monitor
 * @param shell
 * @return 0 = Ok, 1 = Retry, 2 = Ignore, 3 = Ignore All, 4 = Abort
 * @throws IOException
 */
public static int copyFileWithShell(final URL sourceUrl, File destinationFile, MessageConsoleStream out,
        IProgressMonitor monitor, final Shell shell, final boolean ignoreError) throws IOException {

    while (true) {
        try {
            Utils.copyFile(sourceUrl, destinationFile, out, monitor);
            return 0;
        } catch (final IOException e) {

            if (ignoreError) {
                return 3; // Ignore All
            }

            class ErrorMessageDialog implements Runnable {

                public int retCode = 0;

                @Override
                public void run() {
                    String[] buttons = new String[] { "Retry", "Ignore", "Ignore All", "Abort" };
                    MessageDialog dialog = new MessageDialog(shell, "Read error", null,
                            sourceUrl.toString() + "\n" + e.getMessage(), MessageDialog.ERROR, buttons, 0);
                    retCode = dialog.open();
                }
            }

            ErrorMessageDialog messageDialog = new ErrorMessageDialog();
            Display.getDefault().syncExec(messageDialog);

            if (messageDialog.retCode == 3) {
                throw e; // Abort
            } else if (messageDialog.retCode == 1 || messageDialog.retCode == 2) {
                return messageDialog.retCode + 1; // Ignore & Ignore All
            }

            // Else try again
        }
    }

    // HandlerUtil.getActiveShell(event)
}

From source file:io.aos.jface.sample.spl02.JFaceSample02.java

License:Apache License

private Action createAboutAction() {
    return new Action() {
        public String getText() {
            return "Essai";
        }/*from   w w  w. j  a v  a  2s .  com*/

        public void run() {
            String[] tab = { IDialogConstants.OK_LABEL };
            MessageDialog dialog = new MessageDialog(getShell(), "Essai JFace", null,
                    "Ceci est une fentre d''information", MessageDialog.INFORMATION, tab, 0);
            dialog.open();
        }
    };
}

From source file:io.aos.jface.sample.spl02.JFaceSample02.java

License:Apache License

protected void handleShellCloseEvent() {
    String[] tab = { IDialogConstants.OK_LABEL };
    MessageDialog dialog = new MessageDialog(getShell(), "Fin de l'essai", null,
            "Nous allons quitter l'application", MessageDialog.INFORMATION, tab, 0);
    dialog.open();//from  w w  w  . j a  v a2  s. c o  m
    setReturnCode(CANCEL);
    close();
}

From source file:lslforge.LSLForgePlugin.java

License:Open Source License

private boolean determineExecutable() {
    String path = getDefault().getPreferenceStore().getString(LSLFORGE_NATIVE_PATH);
    String preferredVersion = null;
    String embeddedVersion = null;
    String installedVersion = null;
    if (path != null && !"".equals(path.trim())) { //$NON-NLS-1$
        preferredVersion = tryTask("Version", path); //$NON-NLS-1$
        if (checkVersion(preferredVersion)) {
            setExecutablePath(path);//from ww w. ja  v a  2s .  c  o  m
            return true;
        }
    }

    URL url = FileLocator.find(getDefault().getBundle(), preferredNativePath(), null);
    if (url != null) {
        try {
            path = FileLocator.toFileURL(url).getFile();
            embeddedVersion = tryTask("Version", path); //$NON-NLS-1$

            if (checkVersion(embeddedVersion)) {
                setExecutablePath(path);
                return true;
            }
        } catch (IOException e) {
            Util.error(e, "can't locate " + url); //$NON-NLS-1$
        }
    }

    url = FileLocator.find(getDefault().getBundle(), alternateNativePath(), null);
    if (url != null) {
        try {
            path = FileLocator.toFileURL(url).getFile();
            embeddedVersion = tryTask("Version", path); //$NON-NLS-1$

            if (checkVersion(embeddedVersion)) {
                setExecutablePath(path);
                return true;
            }
        } catch (IOException e) {
            Util.error(e, "can't locate " + url); //$NON-NLS-1$
        }
    }

    installedVersion = tryTask("Version", LSL_COMMAND); //$NON-NLS-1$
    if (checkVersion(installedVersion)) {
        setExecutablePath(LSL_COMMAND);
        return true;
    }

    StringBuilder versions = new StringBuilder();
    boolean versionFound = false;
    if (preferredVersion != null) {
        versions.append(preferredVersion).append(" (version of executable set in LSLForge Preferences)\n"); //$NON-NLS-1$ TODO
        versionFound = true;
    }
    if (embeddedVersion != null) {
        versions.append(embeddedVersion).append(" (version installed as part of plugin)\n"); //$NON-NLS-1$ TODO
        versionFound = true;
    }
    if (installedVersion != null) {
        versions.append(installedVersion).append(" (version found on PATH)\n"); //$NON-NLS-1$ TODO
        versionFound = true;
    }

    final StringBuilder buf = new StringBuilder();
    if (versionFound) {
        buf.append("The following versions of the LSLForge native executable were found:\n"); //$NON-NLS-1$ TODO
        buf.append(versions);
        buf.append("\nNone of these version are compatible with this plugin, which requires\n"); //$NON-NLS-1$ TODO
        buf.append("version ").append(LSLFORGE_CORE_VERSION).append(".\n"); //$NON-NLS-1$//$NON-NLS-2$ TODO
    } else {
        buf.append("The LSLForge native executable was not found!\n"); //$NON-NLS-1$ TODO
    }
    buf.append("The LSLForge native executable is available from Hackage:\n"); //$NON-NLS-1$ TODO
    buf.append("http://hackage.haskell.org/cgi-bin/hackage-scripts/package/LSLForge\n\n"); //$NON-NLS-1$ TODO
    buf.append("Please also see the Help documentation for LSLForge, under 'Installation'"); //$NON-NLS-1$ TODO
    getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            MessageDialog dlg = new MessageDialog(getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "LSLForge Native Executable Problem", //$NON-NLS-1$ TODO
                    null, buf.toString(), MessageDialog.ERROR, new String[] { "Ok" }, //$NON-NLS-1$ TODO
                    0);
            dlg.open();
        }
    });

    return false;
}