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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a standard error dialog.

Usage

From source file:ch.medshare.mediport.MediportOutputter.java

@Override
public Result<Rechnung> doOutput(final IRnOutputter.TYPE type, final Collection<Rechnung> rnn,
        final Properties props) {
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    final Result<Rechnung> res = new Result<Rechnung>();

    final ClientParam param = getSelectedParam();
    if (param == null) {
        return res;
    }/*  w ww  . ja v a 2  s. co  m*/

    IRnOutputter alternativeAusgabe = null;
    if (!alternativeRun) {
        if (!clientParamsOk(param)) {
            return res;
        }
        String selectedOutput = prefs.getString(MediPortAbstractPrefPage.MPC_AUSGABE);
        if (selectedOutput != null) {
            // Alternative Ausgabe
            List<IRnOutputter> lo = MediPortHelper.getRnOutputter();
            for (IRnOutputter ro : lo) {
                if (selectedOutput.equals(ro.getDescription())) {
                    alternativeAusgabe = ro;
                }
            }
        }
    }
    final boolean alternativeIsMediPort = (alternativeAusgabe instanceof MediportOutputter);

    final Collection<Rechnung> alternativeRnn = new Vector<Rechnung>();

    try {
        progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), new IRunnableWithProgress() {
            @Override
            public void run(final IProgressMonitor monitor) {
                monitor.beginTask(Messages.getString("MediportOutputter.info.exportiereRechnungen"), //$NON-NLS-1$
                        rnn.size());

                Log log = Log.get("MediPortOutputter");

                for (Rechnung rn : rnn) {
                    // getSenderEAN(rn.getMandant());

                    boolean isMediPortParticipant = partnerInfoContainsEan(getRecipientEAN(rn));
                    boolean fromDefaultOutputter = "asDefault"
                            .equals(props.getProperty(IRnOutputter.PROP_OUTPUT_METHOD));

                    // Ausgabe Varianten:
                    // Outputter | MediPort Teilnehmer | MediPort ist Alternative | Ausgabe
                    // nach
                    // Mediport | Ja | Ja | MediPort
                    // Mediport | Ja | Nein | MediPort
                    // Mediport | Nein | Ja | MediPort
                    // Mediport | Nein | Nein | Error
                    // Fall Standard | Ja | Ja | MediPort
                    // Fall Standard | Ja | Nein | MediPort
                    // Fall Standard | Nein | Ja | MediPort
                    // Fall Standard | Nein | Nein | Alternative Ausgabe
                    int outputMethod = 0;
                    if (!fromDefaultOutputter && !isMediPortParticipant && !alternativeIsMediPort)
                        outputMethod = OUTPUT_ERROR;
                    if (fromDefaultOutputter && !isMediPortParticipant && !alternativeIsMediPort)
                        outputMethod = OUTPUT_ALTERNATIVE;

                    log.log("doLicensedOutput: rn.getNr()=" + rn.getNr() + "; getRecipientEAN(rn)="
                            + getRecipientEAN(rn) + "; TarmedRequirements.getEAN(getKostentraeger(rn))="
                            + TarmedRequirements.getEAN(getKostentraeger(rn))
                            + "; partnerInfoContainsEan(getRecipientEAN(rn))="
                            + partnerInfoContainsEan(getRecipientEAN(rn)) + "; isMediPortParticipant="
                            + isMediPortParticipant + "; fromDefaultOutputter=" + fromDefaultOutputter
                            + "; alternativeRun=" + alternativeRun + "; alternativeIsMediPort="
                            + alternativeIsMediPort + "; outputMethod=" + outputMethod, Log.DEBUGMSG);

                    if (outputMethod == OUTPUT_ALTERNATIVE) {
                        log.log("MediPortOutputter.doLicensedOutput: alternativeRun=" + alternativeRun,
                                Log.DEBUGMSG);
                        alternativeRnn.add(rn);
                    }

                    if (outputMethod == OUTPUT_ERROR) {
                        log.log("MediPortOutputter.doLicensedOutput: isMediPortParticipant="
                                + isMediPortParticipant, Log.DEBUGMSG);
                        String errorMsg = Messages.getString("MediportOutputter.error.NotMediPortParticipant"); //$NON-NLS-1$
                        if (rn.getStatus() == RnStatus.OFFEN) {
                            rn.reject(REJECTCODE.INTERNAL_ERROR, errorMsg);
                        } else {
                            String title = Messages.getString("MediportOutputter.error.Rechnung"); //$NON-NLS-1$
                            title = title + " " + rn.getNr();
                            MessageDialog.openError(new Shell(), title, errorMsg);
                        }
                    }

                    if (outputMethod == OUTPUT_MEDIPORT) {
                        String billFilenamePath = param.getDir() + File.separator + rn.getNr() + ".xml"; //$NON-NLS-1$
                        log.log("doLicensedOutput: rn.getNr()=" + rn.getNr() + "; billFilenamePath="
                                + billFilenamePath, Log.DEBUGMSG);
                        if (checkTier(rn, param.getDocattr())) {
                            if (doExport(rn, billFilenamePath, type, true) == null) {
                                res.add(Result.SEVERITY.ERROR, 1,
                                        Messages.getString("MediportOutputter.error.Rechnung") //$NON-NLS-1$
                                                + rn.getNr(),
                                        rn, true);
                            }
                        } else {
                            String errorMsg = Messages.getString("MediportOutputter.error.WrongTier"); //$NON-NLS-1$
                            if (rn.getStatus() == RnStatus.OFFEN) {
                                rn.reject(REJECTCODE.INTERNAL_ERROR, errorMsg);
                            } else {
                                String title = Messages.getString("MediportOutputter.error.Rechnung"); //$NON-NLS-1$
                                title = title + " " + rn.getNr();
                                MessageDialog.openError(new Shell(), title, errorMsg);
                            }
                        }
                        log.log("MediPortOutputter.doLicensedOutput: rn.getStatus()=" + rn.getStatus(),
                                Log.DEBUGMSG);
                        if (rn.getStatus() == RnStatus.FEHLERHAFT) {
                            res.add(Result.SEVERITY.ERROR, 1,
                                    Messages.getString("MediportOutputter.error.Rechnung") //$NON-NLS-1$
                                            + rn.getNr(),
                                    rn, true);
                        }
                        monitor.worked(1);
                        if (monitor.isCanceled()) {
                            break;
                        }
                    }
                    monitor.done();
                }
            }
        }, null);

        Log log = Log.get("MediPortOutputter");
        if (alternativeAusgabe != null && alternativeRnn.size() > 0) {
            boolean abort = false;
            log.log("doLicensedOutput: alternativeAusgabe.doOutput alternativeRnn.size()="
                    + alternativeRnn.size() + "; type=" + type.toString(), Log.DEBUGMSG);
            if (alternativeAusgabe instanceof MediportOutputter) {
                ((MediportOutputter) alternativeAusgabe).setAlternative();
            } else {
                final IRnOutputter iro = alternativeAusgabe;
                SWTHelper.SimpleDialog dlg = new SWTHelper.SimpleDialog(new SWTHelper.IControlProvider() {
                    @Override
                    public Control getControl(Composite parent) {
                        parent.getShell().setText(iro.getDescription());
                        return (Control) iro.createSettingsControl(parent);

                    }

                    @Override
                    public void beforeClosing() {
                        iro.saveComposite();
                    }
                });
                if (dlg.open() != Dialog.OK) {
                    abort = true;
                }
            }
            if (!abort) {
                alternativeAusgabe.doOutput(type, alternativeRnn, props);
            }
        }
    } catch (Exception ex) {
        ExHandler.handle(ex);
        res.add(Result.SEVERITY.ERROR, 2, ex.getMessage(), null, true);
    }

    if (!res.isOK()) {
        ErrorDialog.openError(null, Messages.getString("MediportOutputter.error.Output"), //$NON-NLS-1$
                Messages.getString("MediportOutputter.error.MediPortTransmit"), //$NON-NLS-1$
                ResultAdapter.getResultAsStatus(res));
    }

    return res;
}

From source file:ch.medshare.mediport.MediportOutputter.java

private boolean clientParamsOk(ClientParam param) {
    if (param == null) {
        MessageDialog.openError(new Shell(), getDescription(),
                Messages.getString("MediportOutputter.error.msg.unknownParameter")); //$NON-NLS-1$
        return false;
    }/*  www  .  j  av a2s. c  om*/

    String message = null;

    MPCProperties props = getProperties();
    if (props != null) {
        String serverIp = props.getProperty(ConfigKeys.MEDIPORT_IP);
        if (MediportMainPrefPage.VALUE_SERVER_URL_TEST.equals(serverIp)) {
            message = Messages.getString("MediportOutputter.info.testServer"); //$NON-NLS-1$
        } else if (MediportMainPrefPage.LBL_SERVER_TEST
                .equals(prefs.getString(MediportMainPrefPage.MPC_SERVER))) {
            message = Messages.getString("MediportOutputter.info.test"); //$NON-NLS-1$
        }
    }

    if (message != null) {
        return MessageDialog.openQuestion(new Shell(), getDescription(),
                message + "\n" + Messages.getString("MediportOutputter.question.Fortfahren")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    return true;
}

From source file:ch.novcom.elexis.mednet.plugin.ui.commands.GetResult.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    ProgressMonitorDialog progress = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));

    try {/*  w  w w  . ja v a 2  s  .com*/
        progress.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

                DocumentImporterPage dip = new DocumentImporterPage();
                try {
                    dip.doImport(monitor);
                } catch (Exception e) {
                    LOGGER.error("execute() - " + "Exception calling doImport", e);//$NON-NLS-1$
                }

            }
        });

    } catch (InvocationTargetException | InterruptedException e) {
        MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler",
                "Fehler beim PDF erzeugen.\n" + e.getMessage());
    }

    return null;
}

From source file:ch.ntb.inf.deep.eclipse.ui.view.ConsoleDisplayMgr.java

License:Apache License

public void println(String msg, int msgKind) {
    if (msg == null)
        return;// w w  w .jav  a2  s  .  co  m

    /* if console-view in Java-perspective is not active, then show it and
     * then display the message in the console attached to it */
    if (!displayConsoleView()) {
        /*If an exception occurs while displaying in the console, then just diplay atleast the same in a message-box */
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", msg);
        return;
    }

    /* display message on console */
    try {
        getNewIOConsoleOutputStream(msgKind).write(msg.getBytes());
    } catch (IOException e) {
    }
}

From source file:ch.powerunit.poweruniteclipse.PowerunitlaunchConfigurationShortcut.java

License:Open Source License

@Override
protected ILaunchConfiguration createConfiguration(IType type) {
    ILaunchConfiguration config = null;/*from  www .j  a va 2s .  com*/
    ILaunchConfigurationWorkingCopy wc = null;
    try {
        ILaunchConfigurationType configType = getConfigurationType();
        wc = configType.newInstance(null,
                getLaunchManager().generateLaunchConfigurationName(type.getTypeQualifiedName('.')));
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
                type.getCompilationUnit().getJavaProject().getElementName());
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
        config = wc.doSave();
    } catch (CoreException exception) {
        MessageDialog.openError(JDIDebugUIPlugin.getActiveWorkbenchShell(),
                LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage());
    }
    return config;
}

From source file:ch.wess.ezclipse.communication.properties.internal.CommunicationPage.java

License:Open Source License

/**
 * Create the GUI./*from w  w  w .j a  v  a2  s  . c o m*/
 * 
 * @param parent
 */
@Override
protected Control createContents(final Composite parent) {
    IAdaptable element = getElement();
    project = (IProject) element.getAdapter(IProject.class);

    Composite panel = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    panel.setLayout(layout);
    Group soapGroup = new Group(panel, SWT.NULL);
    soapGroup.setText(Messages.getString("CommunicationPage.0")); //$NON-NLS-1$
    soapGroup.setBounds(25, 25, 520, 300);

    // URL label
    final Label labelUrl = new Label(soapGroup, SWT.NULL);
    labelUrl.setBounds(25, 25, 70, 20);
    labelUrl.setText("URL :"); //$NON-NLS-1$

    // URL text field
    textUrl = new Text(soapGroup, SWT.SINGLE | SWT.LEFT);
    textUrl.setBounds(125, 25, 450, 20);

    // Login label
    final Label labelLogin = new Label(soapGroup, SWT.NULL);
    labelLogin.setBounds(25, 55, 100, 20);
    labelLogin.setText(Messages.getString("CommunicationPage.1")); //$NON-NLS-1$

    // Login text field
    textLogin = new Text(soapGroup, SWT.SINGLE | SWT.LEFT);
    textLogin.setBounds(125, 55, 250, 20);

    // Password label
    final Label labelPass = new Label(soapGroup, SWT.NULL);
    labelPass.setBounds(25, 85, 100, 20);
    labelPass.setText(Messages.getString("CommunicationPage.2")); //$NON-NLS-1$

    // Password text field
    textPass = new Text(soapGroup, SWT.SINGLE | SWT.LEFT | SWT.PASSWORD);
    textPass.setBounds(125, 85, 250, 20);

    final Button buttonCheck = new Button(soapGroup, SWT.CENTER);
    buttonCheck.setBounds(25, 115, 250, 30);
    buttonCheck.setText(Messages.getString("CommunicationPage.3")); //$NON-NLS-1$
    buttonCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISoapCommunication ezComm = CommunicationActivator.getNewCommunication();
            boolean result = ezComm.testConnection(textUrl.getText(), textLogin.getText(), textPass.getText());
            if (result)
                MessageDialog.openInformation(parent.getShell(), Messages.getString("CommunicationPage.4"), //$NON-NLS-1$
                        ezComm.getErrorMessage());
            else
                MessageDialog.openError(parent.getShell(), Messages.getString("CommunicationPage.5"), ezComm //$NON-NLS-1$
                        .getErrorMessage());
        }
    });

    restoreValues();
    return panel;
}

From source file:ch.wess.ezclipse.ini.wizards.internal.NewINIWizard.java

License:Open Source License

/**
 * When the wizard is finished, the file is create with the specified
 * persistent properties.//from  ww  w.ja  va  2 s  .  c  o  m
 */
@Override
public boolean performFinish() {
    final String containerName = page.getContainerName();
    final String fileName = page.getFileName();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                doFinish(containerName, fileName, monitor);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        getContainer().run(true, false, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), Messages.getString("NewINIWizard.0"), realException //$NON-NLS-1$
                .getMessage());
        return false;
    }
    return true;
}

From source file:ch.wess.ezclipse.tpl.wizards.internal.NewTemplateWizard.java

License:Open Source License

/**
 * When the wizard is finished, the file is create with the specified
 * persistent properties.//from  ww  w .  j av  a  2s. co m
 */
@Override
public boolean performFinish() {
    final String containerName = page.getContainerName();
    final String fileName = page.getFileName();
    final String nodeId = page.getNodeId();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                doFinish(containerName, fileName, nodeId, monitor);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        getContainer().run(true, false, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), Messages.getString("NewTemplateWizard.0"), realException //$NON-NLS-1$
                .getMessage());
        return false;
    }
    return true;
}

From source file:cideplus.ui.astview.ASTView.java

License:Open Source License

protected void performFindDeclaringNode() {
    String msg = "Find Declaring Node from Key";
    String key = askForKey(msg);//from   www.  ja  va2 s.com
    if (key == null)
        return;
    ASTNode node = fRoot.findDeclaringNode(key);
    if (node != null) {
        fViewer.setSelection(new StructuredSelection(node), true);
    } else {
        MessageDialog.openError(getSite().getShell(), "Find Declaring Node from Key",
                "The declaring node for key '" + key + "' could not be found");
    }
}

From source file:classes.ExceptionUtilities.java

License:Apache License

/**
 *  Generic function which creates an error popup with a generic title and message.
*//*w w  w.j av  a 2 s  . c  o m*/
public void Error() {
    Display display = Display.getDefault();
    Shell shell = new Shell(display);

    MessageDialog.openError(shell, "ERROR",
            "There was an error while generating your SPDX Document.  Please try your request again.");
}