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:com.amalto.workbench.actions.XSDSetAnnotaionDisplayFormatAction.java

License:Open Source License

public IStatus doAction() {
    try {/*  w w  w  .  ja v  a 2  s . c om*/
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(
                    Messages.XSDSetAnnoXX_ExceptionInfo + selection.getFirstElement().getClass().getName());
        }

        dlg = new AnnotationLanguageLabelsDialog(struc.getDisplayFormat(), new SelectionListener() {

            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                dlg.close();
            }
        }, page.getSite().getShell(), Messages.XSDSetAnnoXX_DialogTitle2);

        dlg.setBlockOnOpen(true);
        int ret = dlg.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }
        LinkedHashMap<String, String> fomats = dlg.getDescriptionsMap();
        struc.setDisplayFormat(fomats);

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(selection.getFirstElement(), 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnoXX_ErrorMsg2, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationDescriptionsAction.java

License:Open Source License

public IStatus doAction() {
    try {/*from w ww .j  ava  2s .  c o m*/

        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(
                    Messages.bind(Messages.XSDSetAnnotationXX_ExceptionInfo2, xSDCom.getClass().getName()));
        }

        AnnotationLanguageLabelsDialog dlg = new AnnotationLanguageLabelsDialog(struc.getDescriptions(),
                new AnnotationLabelDialogSelectionListener(page), page.getEditorSite().getShell(),
                Messages.XSDSetAnnotationXX_SetDescOfThisItem);
        dlg.setBlockOnOpen(true);
        dlg.open();

        if (dlg.getReturnCode() == Window.OK) {
            // remove existing annotations with labels
            struc.removeAllDescriptions();
            // add the new ones
            LinkedHashMap<String, String> descriptions = dlg.getDescriptionsMap();
            Set<String> isoCodes = descriptions.keySet();
            for (Iterator iter = isoCodes.iterator(); iter.hasNext();) {
                String isoCode = (String) iter.next();
                struc.setDescription(isoCode, descriptions.get(isoCode));
            }
        } else {
            return Status.CANCEL_STATUS;
        }

        if (struc.hasChanged()) {
            page.markDirty();
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnotationXX_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationDocumentationAction.java

License:Open Source License

public IStatus doAction() {
    try {//from   www .  j a  va2 s .  c  om

        IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent) selection.getFirstElement());
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.XSDSetXX_ExceptionInfo,
                    selection.getFirstElement().getClass().getName()));
        }

        InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDSetXX_DialogTitle,
                Messages.XSDSetXX_DialogTip, struc.getDocumentation(), new IInputValidator() {

                    public String isValid(String newText) {
                        return null;
                    };
                });

        id.setBlockOnOpen(true);
        int ret = id.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setDocumentation("".equals(id.getValue()) ? null : id.getValue());//$NON-NLS-1$

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(selection.getFirstElement(), 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetXX_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationFKFilterAction.java

License:Open Source License

@Override
public IStatus doAction() {
    try {//  w w w  .  j a  v a 2 s  . c  o m
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        String conceptName = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation) {
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
                }
            }
        } else {
            xSDCom = (XSDComponent) selection.getFirstElement();
        }
        if (xSDCom instanceof XSDElementDeclaration) {
            conceptName = xSDCom.getElement().getAttributes().getNamedItem("name").getNodeValue();//$NON-NLS-1$
        }
        if (xSDCom instanceof XSDParticle) {
        }
        XSDAnnotationsStructure struc = null;
        if (xSDCom != null) {
            struc = new XSDAnnotationsStructure(xSDCom);
        }
        if (struc == null || struc.getAnnotation() == null) {
            throw new RuntimeException(
                    Messages.bind(Messages.UnableEditAnnotationType, xSDCom.getClass().getName()));
        }

        fkd = getNewFKFilterDialog(page.getSite().getShell(), struc.getFKFilter(), page, conceptName);
        fkd.setDataModel(dataModelName);
        fkd.setLock(true);
        fkd.setBlockOnOpen(true);
        int ret = fkd.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        String fkfilter = fkd.getFilter();
        struc.setFKFilter(fkfilter);

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.ErrorFKFilter, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationForeignKeyAction.java

License:Open Source License

@Override
public IStatus doAction() {
    try {//w w w .jav  a 2s .  c  o m
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation) {
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
                }
            }
        } else {
            xSDCom = (XSDComponent) selection.getFirstElement();
        }
        XSDAnnotationsStructure struc = null;
        if (xSDCom != null) {
            struc = new XSDAnnotationsStructure(xSDCom);
        }
        if (struc == null || struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.UnableEditType, xSDCom.getClass().getName()));
        }

        sxid = getNewSimpleXpathInputDlg(struc.getForeignKey());
        sxid.setLock(true);
        sxid.setPKXpaths(XSDUtil.getAllPKXpaths(schema));
        String fksep = struc.getForeignKeyNotSep();
        if (fksep != null) {
            sxid.setFkSep(Boolean.valueOf(fksep));
        }
        sxid.setBlockOnOpen(true);
        int ret = sxid.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        String fk = "".equals(sxid.getXpath()) ? null : sxid.getXpath().replaceAll("'|\"", "");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        // keep the foreignkey in memory to improve performance
        if (Util.getForeignKeys() != null && fk != null) {
            if (struc.getForeignKey() != null) {
                Util.getForeignKeys().remove(Util.getConceptFromPath(struc.getForeignKey()));
            }
            Util.getForeignKeys().add(Util.getConceptFromPath(fk));
        }
        struc.setForeignKey(fk);
        Boolean sep = sxid.getSepFk();
        struc.setForeignKeyNotSep(sep);
        updateAnnotationStructure(struc);
        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.ErrorForeignKey, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationForeignKeyInfoAction.java

License:Open Source License

@Override
public IStatus doAction() {
    try {//from  w w  w  . ja  v a 2 s .  c o  m
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation) {
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
                }
            }
        } else {
            xSDCom = (XSDComponent) selection.getFirstElement();
        }
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(
                    Messages.bind(Messages.UnableEditAnnotationType, xSDCom.getClass().getName()));
        }

        dlg = getNewAnnotaionOrderedListsDialog(struc.getForeignKeyInfos().values());

        dlg.setLock(true);
        dlg.setRetrieveFKinfos(struc.getRetrieveFKinfos());
        dlg.setFormatFKInfo(struc.getFormatForeignKeyInfo());
        dlg.setBlockOnOpen(true);
        int ret = dlg.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setForeignKeyInfos(dlg.getXPaths());
        struc.setRetrieveFKinfos(dlg.isRetrieveFKinfos());
        struc.setFormatForeignKeyInfo(dlg.getFormatFKInfo());
        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.ErrorForeignKey, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationLabelAction.java

License:Open Source License

@Override
public IStatus doAction() {
    try {/* w  w  w .java2s  . c  o m*/
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        //
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation) {
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
                }
            }
        } else {
            xSDCom = (XSDComponent) selection.getFirstElement();
        }
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationLabelAction_ExceptioInfo,
                    xSDCom.getClass().getName()));
        }

        AnnotationLanguageLabelsDialog dlg = new AnnotationLanguageLabelsDialog(struc.getLabels(),
                new AnnotationLabelDialogSelectionListener(page), page.getEditorSite().getShell(),
                Messages.XSDSetAnnotationLabelAction_DialogTitle);
        dlg.setBlockOnOpen(true);
        dlg.open();

        if (dlg.getReturnCode() == Window.OK) {
            // remove existing annotations with labels
            struc.removeAllLabels();
            // add the new ones
            LinkedHashMap<String, String> descriptions = dlg.getDescriptionsMap();
            Set<String> isoCodes = descriptions.keySet();
            for (Iterator iter = isoCodes.iterator(); iter.hasNext();) {
                String isoCode = (String) iter.next();
                struc.setLabel(isoCode, descriptions.get(isoCode));
            }
        } else {
            return Status.CANCEL_STATUS;
        }

        if (struc.hasChanged()) {
            page.markDirty();
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnotationLabelAction_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationPrimaryKeyInfoAction.java

License:Open Source License

public IStatus doAction() {
    try {//from   ww w .j a v a  2s  .c om
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        struc.setXSDSchema(schema);

        if (struc.getAnnotation() == null) {
            throw new RuntimeException(
                    Messages.bind(Messages.XSDSetAnnotationXX_ExceptionInfo1, xSDCom.getClass().getName()));
        }

        dlg = new AnnotationOrderedListsDialog(new ArrayList(struc.getPrimaryKeyInfos().values()),
                new SelectionListener() {

                    public void widgetDefaultSelected(SelectionEvent e) {
                    }

                    public void widgetSelected(SelectionEvent e) {
                        dlg.close();
                    }
                }, page.getSite().getShell(), Messages.XSDSetAnnotationXX_DialogTitle, "xPaths", page, //$NON-NLS-1$
                AnnotationOrderedListsDialog.AnnotationPrimaKeyInfo_ActionType, null);

        dlg.setBlockOnOpen(true);
        int ret = dlg.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setAccessRole(dlg.getXPaths(), false,
                (IStructuredContentProvider) page.getTreeViewer().getContentProvider(), "X_PrimaryKeyInfo");//$NON-NLS-1$

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnotationXX_Msg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationSourceSystemAction.java

License:Open Source License

public IStatus doAction() {
    try {/*  w ww.  j av a  2s  . c  o m*/
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.ExceptionInfo, xSDCom.getClass().getName()));
        }

        InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDSetAnnoXX_DialogTitle1,
                Messages.XSDSetAnnoXX_DialogTip, struc.getSourceSystem(), new IInputValidator() {

                    public String isValid(String newText) {
                        return null;
                    };
                });

        id.setBlockOnOpen(true);
        int ret = id.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setSourceSystem("".equals(id.getValue()) ? null : id.getValue());//$NON-NLS-1$

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnoXX_ErrorMsg1, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.amalto.workbench.actions.XSDSetAnnotationTargetSystemsAction.java

License:Open Source License

public IStatus doAction() {
    try {//from w ww  .j  av  a2s .  c o  m
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation)
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        } else
            xSDCom = (XSDComponent) selection.getFirstElement();
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationTargetSystemsAction_ExceptionInfo,
                    xSDCom.getClass().getName()));
        }

        dlg = new AnnotationOrderedListsDialog(new ArrayList(struc.getTargetSystems().values()),
                new SelectionListener() {

                    public void widgetDefaultSelected(SelectionEvent e) {
                    }

                    public void widgetSelected(SelectionEvent e) {
                        dlg.close();
                    }
                }, page.getSite().getShell(), Messages.XSDSetAnnotationTargetSystemsAction_DialogTitle,
                Messages.XSDSetAnnotationTargetSystemsAction_DialogTip, page,
                AnnotationOrderedListsDialog.AnnotationTargetSystems_ActionType, dataModelName);

        dlg.setBlockOnOpen(true);
        int ret = dlg.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }

        struc.setTargetSystems(dlg.getXPaths());

        if (struc.hasChanged()) {
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
            page.markDirty();
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnotationTargetSystemsAction_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}