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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:net.bpelunit.toolsupport.editors.BPELUnitEditor.java

License:Open Source License

public Definition getWsdlForFile(String wsdl) throws WSDLReadingException {

    IPath path = new Path(wsdl);
    IResource resource = null;/*from w  w  w .j  a  v  a2 s. c  o m*/

    // try to find from current dir:
    resource = this.getCurrentDirectory().findMember(wsdl);

    // try to find from project dir:
    if (this.notFound(resource)) {
        resource = this.getCurrentProject().findMember(path);
    }

    if (this.notFound(resource)) {
        resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
    }

    // all hope failed...
    if (this.notFound(resource)) {
        throw new WSDLReadingException("Cannot find WSDL file with file path " + wsdl);
    }

    IFile file = (IFile) resource;

    // TODO caching probably NOT a good idea at all.
    Definition definition = this.fWSDLDefinitions.get(file);

    if (definition == null) {
        String fileName = file.getRawLocation().toFile().toString();
        // load WSDL
        try {
            WSDLFactory factory = WSDLFactory.newInstance();
            WSDLReader reader = factory.newWSDLReader();
            // reader.setFeature(Constants.FEATURE_VERBOSE, false);

            definition = reader.readWSDL(null, fileName);
            this.fWSDLDefinitions.put(file, definition);

            WSDLParser parser = new WSDLParser(definition);
            this.fWSDLParser.put(definition, parser);

        } catch (WSDLException e) {
            throw new WSDLReadingException("Error loading WSDL file for partner", e);
        } catch (SAXException e) {
            MessageDialog dialog = new MessageDialog(this.getShell(), "Invalid Schema", null, e.getMessage(),
                    MessageDialog.ERROR, new String[] { "OK" }, 0);
            dialog.open();
            throw new WSDLReadingException("Error reading Schemata in WSDL: " + e.getMessage(), e);
        } catch (TransformerException e) {
            MessageDialog dialog = new MessageDialog(this.getShell(), "Invalid Schema", null, e.getMessage(),
                    MessageDialog.ERROR, new String[] { "OK" }, 0);
            dialog.open();
            throw new WSDLReadingException("Error reading Schemata in WSDL: " + e.getMessage(), e);
        }
    }
    return definition;

}

From source file:net.leboxondelex.daplomb.utils.Utils.java

License:Open Source License

/**
 * Opens a message dialog with a the inner i18n system.
 * @param parent//from w  w w.  ja  va 2  s  .c  om
 * @param title
 * @param message
 * @return true if the user presses the "yes" button
 */
public static boolean showQuestion(Shell parent, String title, String message) {
    MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.QUESTION,
            new String[] { "Oui", "Non" }, 0);

    return dialog.open() == 0;
}

From source file:net.leboxondelex.daplomb.utils.Utils.java

License:Open Source License

/**
 * Opens an error dialog with a the inner i18n system.
 * @param parent// w  w  w.j  av a 2 s  .  c om
 * @param title
 * @param message
 */
public static void showError(Shell parent, String title, String message) {
    MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.ERROR,
            new String[] { "OK" }, 0);

    dialog.open();
}

From source file:net.refractions.udig.catalog.internal.worldimage.InMemoryCoverageLoader.java

License:Open Source License

private void updateMemoryLevel() throws IOException {

    int heap;/*  ww  w .j a v  a2 s . c  o  m*/
    int originalHeap = UiPlugin.getMaxHeapSize();
    if (originalHeap < 700) {
        heap = 1024;
    } else if (originalHeap < 1500) {
        heap = 2048;
    } else {
        heap = originalHeap * 2;
    }

    String os = Platform.getOS();
    if (heap > 1024 && os == Platform.OS_WIN32) {
        heap = 1024;
    }

    final int finalHeap = heap;
    coverage = new SoftReference<GridCoverage>(EMPTY_COVERAGE);

    Display.getDefault().asyncExec(new Runnable() {

        public void run() {

            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            String title = InMemoryCoverageLoader_msgTitle;
            String desc = MessageFormat.format(InMemoryCoverageLoader_message, resource.getIdentifier(),
                    finalHeap);
            String[] buttons = { InMemoryCoverageLoader_restart_button, InMemoryCoverageLoader_close_button };
            MessageDialog dialog = new MessageDialog(shell, title, null, desc, QUESTION, buttons, 0) {

                @Override
                protected void buttonPressed(int buttonId) {
                    if (buttonId == 0) {
                        try {
                            UiPlugin.setMaxHeapSize(String.valueOf(finalHeap));
                            PlatformUI.getWorkbench().restart();

                        } catch (IOException e) {
                            throw (RuntimeException) new RuntimeException().initCause(e);
                        }
                    }
                    super.buttonPressed(buttonId);
                }
            };
            dialog.open();

        }
    });
}

From source file:net.refractions.udig.ui.dialogs.WizardDataTransferPage.java

License:Open Source License

/**
 * Displays a Yes/No question to the user with the specified message and returns
 * the user's response.//from   w ww  . j av  a2 s . co  m
 *
 * @param message the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
protected boolean queryYesNoQuestion(String message) {
    MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.WizardDataTransferPage_dialog_title, (Image) null, message, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    // ensure yes is the default

    return dialog.open() == 0;
}

From source file:net.resheim.eclipse.timekeeper.ui.Activator.java

License:Open Source License

/**
 * Must be called by the UI-thread//from   w w w  .j av  a2  s .  c o  m
 *
 * @param idleTimeMillis
 */
private void handleReactivation(long idleTimeMillis) {
    // We want only one dialog open.
    if (dialogIsOpen) {
        return;
    }
    synchronized (this) {
        if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) {
            // If we have an active task
            ITask task = TasksUi.getTaskActivityManager().getActiveTask();
            if (task != null && Activator.getValue(task, Activator.START) != null) {
                dialogIsOpen = true;
                String tickString = Activator.getValue(task, Activator.TICK);
                LocalDateTime started = getActiveSince();
                LocalDateTime ticked = LocalDateTime.parse(tickString);
                LocalDateTime lastTick = ticked;
                // Subtract the IDLE_INTERVAL time the computer _was_
                // idle while counting up to the threshold. During this
                // period fields were updated. Thus must be adjusted for.
                ticked = ticked.minusNanos(IDLE_INTERVAL);
                String time = DurationFormatUtils.formatDuration(lastIdleTime, "H:mm:ss", true);

                StringBuilder sb = new StringBuilder();
                if (task.getTaskKey() != null) {
                    sb.append(task.getTaskKey());
                    sb.append(": ");
                }
                sb.append(task.getSummary());
                MessageDialog md = new MessageDialog(Display.getCurrent().getActiveShell(),
                        "Disregard idle time?", null,
                        MessageFormat.format(
                                "The computer has been idle since {0}, more than {1}. The active task \"{2}\" was started on {3}. Deactivate the task and disregard the idle time?",
                                ticked.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US)), time,
                                sb.toString(),
                                started.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US))),
                        MessageDialog.QUESTION, new String[] { "No", "Yes" }, 1);
                int open = md.open();
                dialogIsOpen = false;
                if (open == 1) {
                    // Stop task, subtract initial idle time
                    TasksUi.getTaskActivityManager().deactivateTask(task);
                    reduceTime(task, ticked.toLocalDate().toString(), IDLE_INTERVAL / 1000);
                } else {
                    // Continue task, add idle time
                    LocalDateTime now = LocalDateTime.now();
                    long seconds = lastTick.until(now, ChronoUnit.MILLIS);
                    accumulateTime(task, ticked.toLocalDate().toString(), seconds);
                    Activator.setValue(task, Activator.TICK, now.toString());
                }
            }
        }
    }
}

From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java

License:Open Source License

private void setJDKCompatibilitySettings(final IJavaProject mainProject, final List<IJavaProject> nonBBProjects,
        final List<IJavaProject> projectsWithProblem) {
    _log.trace("Entered setJDKCompatibilitySettings()");
    if (projectsWithProblem.size() > 0) {
        StringBuffer projectList = new StringBuffer();
        for (IJavaProject javaProject : projectsWithProblem) {
            projectList.append(javaProject.getProject().getName() + "\n");
        }//  w ww  . j av  a  2s .  c  om
        final String projectNames = projectList.toString();
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                Shell shell = ContextManager.getActiveWorkbenchWindow().getShell();
                StringBuffer messageBuffer = new StringBuffer(
                        Messages.ClasspathChangeManager_settingJDKComplianceMsg1);
                messageBuffer.append("\n");
                messageBuffer.append(NLS.bind(Messages.ClasspathChangeManager_settingJDKComplianceMsg2,
                        mainProject.getProject().getName()));
                messageBuffer.append("\n");
                messageBuffer.append(projectNames);
                messageBuffer.append("\n");
                messageBuffer.append(Messages.ClasspathChangeManager_settingJDKComplianceMsg3);
                MessageDialog complianceDialog = new MessageDialog(shell,
                        Messages.ClasspathChangeManager_DialogTitle, null, messageBuffer.toString(),
                        MessageDialog.INFORMATION, new String[] { Messages.IConstants_OK_BUTTON_TITLE,
                                Messages.IConstants_CANCEL_BUTTON_TITLE },
                        0);

                int buttonEventCode = complianceDialog.open();

                switch (buttonEventCode) {
                case Window.OK: {
                    processNonBBProjects(nonBBProjects, projectsWithProblem, true);
                    break;
                }
                case Window.CANCEL: {
                    processNonBBProjects(nonBBProjects, projectsWithProblem, false);
                    break;
                }
                default:
                    throw new IllegalArgumentException("Unsupported dialog button event!");
                }
                complianceDialog.close();
            }
        });
    } else {
        processNonBBProjects(nonBBProjects, projectsWithProblem, false);
    }
}

From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java

License:Open Source License

private void processNonBBProjects(final List<IJavaProject> nonBBProjects,
        final List<IJavaProject> projectsWithProblem, final boolean fix) {
    for (IJavaProject javaProject : nonBBProjects) {
        if (fix && projectsWithProblem.contains(javaProject)) {
            ImportUtils.initializeProjectOptions(javaProject);
        }//from   www  .ja  v  a2s.c  om
    }
    if (fix) {
        Shell shell = ContextManager.getActiveWorkbenchWindow().getShell();
        String message = Messages.ClasspathChangeManager_rebuildProjectMsg1;
        StringBuffer projectList = new StringBuffer();
        for (IJavaProject javaProject : projectsWithProblem) {
            projectList.append(javaProject.getProject().getName() + "\n");
        }
        message += projectList.toString();
        message += Messages.ClasspathChangeManager_rebuildProjectMsg2;
        MessageDialog dialog = new MessageDialog(shell,
                Messages.ClasspathChangeManager_RebuildProjectDialogTitle, null, message,
                MessageDialog.INFORMATION,
                new String[] { Messages.IConstants_OK_BUTTON_TITLE, Messages.IConstants_CANCEL_BUTTON_TITLE },
                0);
        int buttonEventCode = dialog.open();

        switch (buttonEventCode) {
        case Window.OK: {
            buildProjects(projectsWithProblem);
            break;
        }
        case Window.CANCEL: {
            break;
        }
        default:
            throw new IllegalArgumentException("Unsupported dialog button event!");
        }
        dialog.close();
    }
}

From source file:net.rim.ejde.internal.launching.MDSCSChecker.java

License:Open Source License

private static void askUserDecision(final String title, final String message) {
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            Shell shell = new Shell();
            MessageDialog dialog = new MessageDialog(shell, title, null, // accept the default window icon
                    message, MessageDialog.WARNING,
                    new String[] { IDialogConstants.PROCEED_LABEL, IDialogConstants.STOP_LABEL }, 0); // proceed
            // is the default
            _userDecision = dialog.open();
            shell.dispose();//from   w  ww .jav a2 s .c o  m
        }
    });
}

From source file:net.rim.ejde.internal.signing.ImportCSIFilesAction.java

License:Open Source License

/**
 * Displays a warning dialog indicating that the signature tool is already running.
 *///from w w  w. j av  a 2s.  c om
private void warnSignatureToolRunning() {
    MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
            "Signature Tool is already running...", null,
            "The Signature Tool is already running.  Please exit the tool before running it again.",
            MessageDialog.WARNING, new String[] { "OK" }, 0);
    dialog.open();
}