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:gov.redhawk.frontend.ui.internal.AllocateHandler.java

License:Open Source License

private void warnNoTuners(ExecutionEvent event) {
    MessageDialog warning = new MessageDialog(HandlerUtil.getActiveShell(event),
            "Warning - No Tuners Available", null,
            "The selected device has no tuners.  Dynamic tuner creation may not be supported.",
            MessageDialog.WARNING, new String[] { "OK" }, 0);
    warning.open();/*w  ww . ja  v a  2 s .c o  m*/
}

From source file:gov.redhawk.frontend.ui.internal.DeallocateAction.java

License:Open Source License

private int confirmDeallocate(TunerStatus tuner) {
    MessageDialog warning = new MessageDialog(Display.getCurrent().getActiveShell(), "Deallocation Warning",
            null,// w w w .  j av a2 s.  c o m
            "Some selected tuners have listeners.  Deallocating them will also deallocate all of their listeners.  Deallocate them anyway?",
            MessageDialog.WARNING, new String[] { "Cancel", "Yes" }, 0);
    return warning.open();
}

From source file:gov.redhawk.frontend.ui.internal.DeallocateHandler.java

License:Open Source License

private int confirmDeallocate(TunerStatus tuner, ExecutionEvent event) {
    MessageDialog warning = new MessageDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell(),
            "Deallocation Warning", null,
            "Some selected tuners have listeners.  Deallocating them will also deallocate all of their listeners.  Deallocate them anyway?",
            MessageDialog.WARNING, new String[] { "Cancel", "Yes" }, 0);
    return warning.open();
}

From source file:gov.redhawk.ide.codegen.ui.internal.command.GenerateCodeHandler.java

License:Open Source License

/**
 * Check to see if any implementation is configured using the Manual Code Generator option
 * @param parent//from   w  w w . j a  va  2  s. c o m
 * @param impls
 * @throws CoreException
 */
private boolean checkManualGeneratorImpls(Shell parent, List<Implementation> impls) throws CoreException {
    if (impls == null || impls.isEmpty()) {
        throw new OperationCanceledException();
    }
    boolean shouldGenerate = true;
    final SoftPkg softPkg = (SoftPkg) impls.get(0).eContainer();
    final WaveDevSettings waveDev = CodegenUtil.loadWaveDevSettings(softPkg);
    boolean hasManualGenerator = false;
    int manualImpls = 0;
    for (final Implementation impl : impls) {
        hasManualGenerator = isManualGenerator(impl, waveDev);
        if (hasManualGenerator) {
            manualImpls++;
        }
    }
    if (manualImpls > 0) {
        String name = softPkg.getName();
        String message = "Some implementations in " + name + " require manual code generation.\n\n"
                + "Automatic Code Generation is only available for implementations using supported code generators.";
        MessageDialog dialog = new MessageDialog(parent, "Manual Code Generation Required", null, message,
                MessageDialog.INFORMATION, new String[] { "OK" }, 0);
        dialog.open();
    }
    // If all implementations require manual code generation, then do not start the generation process
    if (manualImpls == impls.size()) {
        shouldGenerate = false;
    }
    return shouldGenerate;
}

From source file:gov.redhawk.ide.codegen.ui.internal.command.GenerateCodeHandler.java

License:Open Source License

private boolean shouldUpgrade(Shell parent, String name) throws CoreException {
    String message = name + " uses deprecated code generators.\n\n" + "Would you like to upgrade this project?";
    MessageDialog dialog = new MessageDialog(parent, "Deprecated Generator", null, message,
            MessageDialog.WARNING, new String[] { "Upgrade", "Cancel" }, 1);
    switch (dialog.open()) {
    case 0: // Upgrade
        return true;
    case 1:// Cancel
    default://  w  w  w.  j  a  va  2s . c o m
        throw new OperationCanceledException();
    }
}

From source file:gov.redhawk.ide.codegen.ui.internal.GenerateFilesDialog.java

License:Open Source License

protected boolean checkUserFile(boolean newValue, FileStatus element) {
    if (!askedUserFile) {
        if (newValue && !element.getDoItDefault()) {
            MessageDialog dialog = new MessageDialog(getShell(), "WARNING", null,
                    "The file '" + element.getFilename() + "' is a 'USER' file.\n"
                            + "This file may contain code that was written by the user.  "
                            + "\n\nCONTINUING WILL OVERWRITE THIS CODE.\n\n"
                            + "Are you sure you want to do this?",
                    MessageDialog.WARNING, new String[] { "Yes", "No" }, 1);
            if (dialog.open() == 0) {
                askedUserFile = true;//w  w w  . j a va 2 s . c o m
                return true;
            } else {
                return false;
            }
        }
        return true;
    } else {
        return true;
    }
}

From source file:gov.redhawk.ide.codegen.ui.internal.GenerateFilesDialog.java

License:Open Source License

protected boolean checkSystemFile(boolean newValue, FileStatus element) {
    if (!askedSystemFileGenerate && newValue) {
        if (!element.getDoItDefault()) {
            MessageDialog dialog = new MessageDialog(getShell(), getShell().getText(), null,
                    "The 'SYSTEM' file '" + element.getFilename()
                            + "' has been modified and may contain code that was written by the user.\n\n"
                            + "It is recommended you overwrite this file.\n\n"
                            + "Do you want to overwrite this file?",
                    MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1);
            if (dialog.open() == 0) {
                askedSystemFileGenerate = true;
                return true;
            } else {
                return false;
            }// w  w w  .  j  av  a2 s . c o m
        }
    }

    return true;
}

From source file:gov.redhawk.ide.idl.ui.wizard.ScaIDLProjectPropertiesWizardPage.java

License:Open Source License

/**
 * Scan the first idl file in the list for a module name and if it's different than the current
 * module name, ask the user if they want to update it.
 *///  www.j  a va  2  s .c o m
private void updateModuleName() {
    final File file = new File(this.idlFiles.get(0));
    Scanner input = null;

    try {
        input = new Scanner(file);
    } catch (final FileNotFoundException e) {
        // PASS
    }

    while (input != null && input.hasNext()) {
        final String line = input.nextLine();

        if (line.contains("module")) {
            final String[] splitNames = line.split("[ ]+");

            for (final String token : splitNames) {
                if (!"module".equals(token) && token.matches("[A-Z]+")
                        && !this.moduleNameText.getText().equalsIgnoreCase(token)) {
                    final MessageDialog dialog = new MessageDialog(getShell(), "Update Module Name", null,
                            "Module " + token + " was found in the imported IDL file(s).  Update?",
                            MessageDialog.QUESTION, new String[] { "No", "Yes" }, 1);
                    final int selection = dialog.open();

                    if (selection == 1) {
                        this.moduleNameText.setText(token.toLowerCase());
                    }
                }
            }

            break;
        }
    }
}

From source file:gov.redhawk.ide.pydev.PyDevConfigureStartup.java

License:Open Source License

@Override
public void earlyStartup() {
    final String app = System.getProperty("eclipse.application");
    final boolean runConfig = app == null || "org.eclipse.ui.ide.workbench".equals(app);
    if (!runConfig) {
        return;/*  ww w . j a v a2 s  .  c o m*/
    }

    // If PyDev isn't configured at all, then prompt the user
    if (PydevPlugin.getPythonInterpreterManager().isConfigured()) {
        try {
            boolean configuredCorrectly = AutoConfigPydevInterpreterUtil
                    .isPydevConfigured(new NullProgressMonitor(), null);
            if (!configuredCorrectly) {
                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        final String[] buttons = { "Ok", "Cancel" };
                        final MessageDialog dialog = new MessageDialog(
                                PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Configure PyDev",
                                null,
                                "PyDev appears to be mis-configured for REDHAWK, would you like it to be re-configured?",
                                MessageDialog.QUESTION, buttons, 0);
                        dialog.open();
                        PyDevConfigureStartup.this.result = dialog.getReturnCode();

                        if (PyDevConfigureStartup.this.result < 1) {
                            new ConfigurePythonJob(false).schedule();
                        }
                    }

                });
            }
        } catch (CoreException e) {
            RedhawkIdePyDevPlugin.getDefault().getLog().log(new Status(e.getStatus().getSeverity(),
                    RedhawkIdePyDevPlugin.PLUGIN_ID, "Failed to auto configure.", e));
        }
    } else {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                new ConfigurePythonJob(false).schedule();
            }

        });
    }
}

From source file:gov.redhawk.ide.snapshot.internal.ui.SnapshotHandler.java

License:Open Source License

/**
 * the command has been executed, so extract extract the needed information
 * from the application context.//from   w  w w  . j av  a  2 s . c o  m
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);
    ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    if (selection == null) {
        selection = HandlerUtil.getCurrentSelection(event);
    }
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;

        Object obj = ss.getFirstElement();
        ScaUsesPort port = PluginUtil.adapt(ScaUsesPort.class, obj);
        if (port != null) {
            if (port.eContainer() instanceof ResourceOperations) {
                final ResourceOperations lf = (ResourceOperations) port.eContainer();
                if (!lf.started()) {
                    MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShell(event),
                            "Start Resource", null,
                            "The ports container is not started.  Would you like to start it now?",
                            MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0);
                    if (dialog.open() == Window.OK) {
                        Job job = new Job("Starting...") {

                            @Override
                            protected IStatus run(IProgressMonitor monitor) {
                                try {
                                    lf.start();
                                } catch (StartError e) {
                                    return new Status(Status.ERROR, SnapshotActivator.PLUGIN_ID,
                                            "Failed to start resource", e);
                                }
                                return Status.OK_STATUS;
                            }

                        };
                        job.schedule();
                    }
                }
            }
            BulkIOSnapshotWizard wizard = new BulkIOSnapshotWizard();
            WizardDialog dialog = new WizardDialog(shell, wizard);
            if (dialog.open() == Window.OK) {
                CorbaDataReceiver receiver = wizard.getCorbaReceiver();
                receiver.setPort(port);
                receiver.getDataWriter().getSettings().setType(BulkIOType.getType(port.getRepid()));

                final ScaItemProviderAdapterFactory factory = new ScaItemProviderAdapterFactory();
                final StringBuilder tooltip = new StringBuilder();
                List<String> tmpList = new LinkedList<String>();
                for (EObject eObj = port; !(eObj instanceof ScaDomainManagerRegistry)
                        && eObj != null; eObj = eObj.eContainer()) {
                    Adapter adapter = factory.adapt(eObj, IItemLabelProvider.class);
                    if (adapter instanceof IItemLabelProvider) {
                        IItemLabelProvider lp = (IItemLabelProvider) adapter;
                        tmpList.add(0, lp.getText(eObj));
                    }
                }
                for (Iterator<String> i = tmpList.iterator(); i.hasNext();) {
                    tooltip.append(i.next());
                    if (i.hasNext()) {
                        tooltip.append(" -> ");
                    }
                }
                factory.dispose();

                SnapshotJob job = new SnapshotJob("Snapshot of " + tooltip, receiver);
                job.schedule();
            }
        }
    }
    return null;
}