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.editors.DataClusterDialog.java

License:Open Source License

private boolean getAllDataContainers(List<TreeObject> dataContainers) {
    MDMServerDef serverDef = getSelectedMdmServerDef();

    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String serverName = serverDef.getName();
    String endpointaddress = serverDef.getUrl();

    boolean canConnect = checkConnection(endpointaddress, username, password);
    if (!canConnect) {
        MessageDialog.openError(site.getShell(), Messages.DataClusterDialog_7, Messages.DataClusterDialog_8);
        return false;
    }/*w  ww  .  j a v a2s.  co  m*/

    List<WSDataClusterPK> xdcPKs = null;
    try {
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress,
                username + ":" + (password == null ? "" : password));//$NON-NLS-1$//$NON-NLS-2$

        xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();//$NON-NLS-1$
        for (WSDataClusterPK pk : xdcPKs) {
            String name = pk.getPk();
            if (!("CACHE".equals(name))) { //$NON-NLS-1$
                WSDataCluster wsObject = null;
                boolean retriveWSObject = false;
                try {
                    if (retriveWSObject) {
                        wsObject = service.getDataCluster(new WSGetDataCluster(pk));
                    }
                    TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
                    dataContainers.add(obj);
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return false;
    }

    return true;
}

From source file:com.amalto.workbench.editors.DataClusterMainPage.java

License:Open Source License

@Override
protected void refreshData() {
    try {/*from ww w  . ja v  a  2 s  . c o  m*/
        if (this.comitting) {
            return;
        }

        this.refreshing = true;

        WSDataCluster wsObject = (WSDataCluster) (getXObject().getWsObject());

        descriptionText.setText(wsObject.getDescription() == null ? "" : wsObject.getDescription());//$NON-NLS-1$

        /*
         * if (wsObject.getWSDataClusterType().equals(WSDataClusterType.CACHE)) dataClusterTypeCombo.select(1); else
         * dataClusterTypeCombo.select(0);
         */

        /*
         * boolean doStemming = ! ("0100".equals(wsObject.getStemmer())); useStemming.setSelection(doStemming); if
         * (doStemming) { useStemming.setText("Stemming Enabled"); } else {
         * useStemming.setText("Stemming Disabled"); } stemmerGroup.setEnabled(doStemming);
         * ((Section)DataClusterMainPage.this.stemmerGroup.getParent()).setExpanded(doStemming);
         * 
         * String language = wsObject.getStemmer().substring(0,2); if ("fr".equals(language))
         * languageCombo.select(1); else languageCombo.select(0);
         * 
         * if (useStemming.getSelection()){ String vals =
         * wsObject.getStemmer().substring(2,wsObject.getStemmer().length()); int val = Integer.parseInt(vals);
         * singleRoot.setSelection((val & (1 << 0)) == (1 << 0)); partOfSpeechSingleWord.setSelection((val & (1 <<
         * 1)) == (1 << 1)); rootConsistency.setSelection((val & (1 << 2)) == (1 << 2));
         * accentedWords.setSelection((val & (1 << 3)) == (1 << 3)); compoundWords.setSelection((val & (1 << 4)) ==
         * (1 << 4)); spellingCorrection.setSelection((val & (1 << 5)) == (1 << 5));
         * phoneticCorrection.setSelection((val & (1 << 6)) == (1 << 6));
         * partOfSpeechCompoundWords.setSelection((val & (1 << 8)) == (1 << 8));
         * synonymInformation.setSelection((val & (1 << 9)) == (1 << 9)); stopWords.setSelection((val & (1 << 10))
         * == (1 << 10)); typingErrors.setSelection((val & (1 << 11)) == (1 << 11));
         * optimizeQueryResult.setSelection((val & (1 << 12)) == (1 << 12));
         * 
         * }
         */

        this.refreshing = false;

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterMainPage_ErrorRefreshingPage,
                Messages.DataClusterMainPage_ErrorRefreshingPageXX + e.getLocalizedMessage());
    }
}

From source file:com.amalto.workbench.editors.DataClusterMainPage.java

License:Open Source License

@Override
protected void commit() {
    try {/*from   ww  w .j  ava2s .  c om*/

        if (this.refreshing) {
            return;
        }

        this.comitting = true;

        WSDataCluster wsObject = (WSDataCluster) (getXObject().getWsObject());
        wsObject.setDescription(descriptionText.getText());
        /*
         * if ("Cache".equals(dataClusterTypeCombo.getText()))
         * wsObject.setWSDataClusterType(WSDataClusterType.CACHE); else
         * wsObject.setWSDataClusterType(WSDataClusterType.ITEMS);
         */
        /*
         * wsObject.setWSDataClusterType(WSDataClusterType.ITEMS);
         * 
         * wsObject.setWSSpellerRefreshPeriodInSeconds(0); if (!useStemming.getSelection())
         * wsObject.setStemmer("0100"); else { String s=languageCombo.getText(); int i=0; if
         * (singleRoot.getSelection()) i+=1; if (partOfSpeechSingleWord.getSelection()) i+=2; if
         * (rootConsistency.getSelection()) i+=4; if (accentedWords.getSelection()) i+=8; if
         * (compoundWords.getSelection()) i+=16; if (spellingCorrection.getSelection()) i+=32; if
         * (phoneticCorrection.getSelection()) i+=64; if (partOfSpeechCompoundWords.getSelection()) i+=256; if
         * (synonymInformation.getSelection()) i+=512; if (stopWords.getSelection()) i+=1024; if
         * (typingErrors.getSelection()) i+=2048; if (optimizeQueryResult.getSelection()) i+=4096; s+=""+i;
         * wsObject.setStemmer(s); }
         */

        this.comitting = false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterMainPage_ErrorCommitingPage,
                Messages.DataClusterMainPage_ErrorCommitingPageXX + e.getLocalizedMessage());
    }
}

From source file:com.amalto.workbench.editors.DataModelMainPage.java

License:Open Source License

protected void doImportSchema(final Collection<XSDSchemaContent> addtional) {
    if (null == addtional || addtional.isEmpty()) {
        return;//from   ww w . ja  v a  2  s  .c  o  m
    }
    try {
        int flag = ConflictDialog.NONE;
        boolean dialogPopup = false;
        List<XSDSchemaContent> contents = xsdSchema.getContents();
        List<XSDSchemaContent> exists = new ArrayList<XSDSchemaContent>(contents);

        for (XSDSchemaContent content : addtional) {
            XSDSchemaContent exist = getContainedSchemaContent(exists, content);
            if (null == exist) {
                Node importElement = xsdSchema.getDocument().importNode(content.getElement(), true);
                xsdSchema.getElement().appendChild(importElement);
            } else {
                if (!dialogPopup) {
                    String type = null;
                    if (exist instanceof XSDElementDeclaration) {
                        type = Messages.DataModelMainPage_entity;
                    } else if (exist instanceof XSDTypeDefinition) {
                        type = Messages.DataModelMainPage_type;
                    } else {
                        continue;
                    }
                    LabelProvider provider = getContentLabelProvider(exist);
                    String message = Messages.bind(Messages.conflict_messages, type, provider.getText(exist));
                    ConflictDialog dialog = new ConflictDialog(getSite().getShell(), message);
                    if (dialog.open() == Dialog.OK) {
                        flag = dialog.getStatus();
                        dialogPopup = dialog.applyAll;
                    } else {
                        popupImportDialog();
                        return;
                    }
                }
                if (flag == ConflictDialog.OVERWRITE) {
                    contents.remove(exist);
                    Node importElement = xsdSchema.getDocument().importNode(content.getElement(), true);
                    xsdSchema.getElement().appendChild(importElement);
                }
            }
        }

        //
        validateSchema();
        markDirtyWithoutCommit();
        setXsdSchema(xsdSchema);
        getSchemaRoleFilterFromSchemaTree().setDataModelFilter(dataModelFilter);

        // refresh types
        viewer.setInput(getSite());
        typesViewer.setInput(getSite());
        MessageDialog.openInformation(getSite().getShell(), Messages.ImportXSDSche,
                Messages.ImportingXSDSchemaCompleted);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        String detail = "";//$NON-NLS-1$
        if (ex.getMessage() != null && !ex.getMessage().equals("")) {//$NON-NLS-1$
            detail += " , " + Messages.bind(Messages.Dueto, ex.getMessage()); //$NON-NLS-1$
        }
        MessageDialog.openError(getSite().getShell(), Messages._Error,
                Messages.bind(Messages.ImportingXSDSchemaFailed, detail));
    }
}

From source file:com.amalto.workbench.editors.DataModelMainPage.java

License:Open Source License

private void createCompDropTarget() {
    DropTarget dropTarget = new DropTarget(sash, DND.DROP_MOVE | DND.DROP_LINK);
    dropTarget.setTransfer(new TreeObjectTransfer[] { TreeObjectTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override//from w  w  w  . ja v a 2s  . c o  m
        public void dragEnter(DropTargetEvent event) {
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
        }

        @Override
        public void drop(DropTargetEvent event) {
            List<String> nameList = new ArrayList<String>();
            if (dropTargetValidate(event, nameList)) {
                if (MessageDialog.openConfirm(sash.getShell(), Messages.ConfirmText,
                        Messages.DoIncludeImportSchema)) {
                    try {
                        HashMap<String, String> customTypesMap = ResourcesUtil
                                .getResourcesMapFromURI(uriPre + TreeObject.CUSTOM_TYPES_URI, xobject);
                        List<String> customTypeList = new ArrayList<String>();
                        for (String key : nameList) {
                            customTypeList.add(customTypesMap.get(key));
                        }
                        // doImportSchema();
                    } catch (SecurityException e) {
                        MessageDialog.openError(sash.getShell(), Messages._Error, e.getMessage());
                    }
                }
            }
        }
    });

}

From source file:com.amalto.workbench.editors.DataModelMainPage.java

License:Open Source License

private void createToolBar(Composite parent) {
    Composite toolBarComp = new Composite(parent, SWT.BORDER);
    GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
    gd.heightHint = 25;/*from  w  w w.j av  a2  s . c om*/
    toolBarComp.setLayoutData(gd);
    final GridLayout glToolBarBackground = new GridLayout();
    glToolBarBackground.verticalSpacing = 0;
    glToolBarBackground.marginWidth = 0;
    glToolBarBackground.marginHeight = 0;
    glToolBarBackground.horizontalSpacing = 0;
    toolBarComp.setLayout(glToolBarBackground);
    ToolBar resultToolBar = new ToolBar(toolBarComp, SWT.FLAT | SWT.HORIZONTAL);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    resultToolBar.setLayoutData(gd);
    ToolItem importToolItem = new ToolItem(resultToolBar, SWT.PUSH);
    importToolItem.setImage(ImageCache.getCreatedImage(EImage.IMPORT.getPath()));
    importToolItem.setToolTipText(Messages.ImportText);
    importToolItem.setEnabled(!isReadOnly());

    ToolItem exportToolItem = new ToolItem(resultToolBar, SWT.PUSH);
    exportToolItem.setImage(ImageCache.getCreatedImage(EImage.EXPORT.getPath()));
    exportToolItem.setToolTipText(Messages.ExportText);
    exportToolItem.setEnabled(!isReadOnly());

    ToolItem importSchemalItem = new ToolItem(resultToolBar, SWT.PUSH);
    importSchemalItem.setImage(ImageCache.getCreatedImage(EImage.CHECKIN_ACTION.getPath()));
    importSchemalItem.setToolTipText(Messages.ImportIncludeSchema);
    importSchemalItem.setEnabled(!isReadOnly());

    importToolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(getSite().getShell(), SWT.OPEN);
            fd.setFilterExtensions(new String[] { "*.xsd", "*.dtd", "*.xml" });//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            // set the default path to the workspace.
            fd.setFilterPath(Platform.getInstanceLocation().getURL().getPath().substring(1));
            fd.setText(Messages.SelectXMLDefinition);
            String filename = fd.open();
            if (filename == null) {
                return;
            }
            xsdSchema = null;
            inferXsdFromXml(filename);
        }

        private void inferXsdFromXml(String xmlFile) {
            int infer = 0;
            String xsd = "";//$NON-NLS-1$
            try {
                String inputType = xmlFile.substring(xmlFile.lastIndexOf("."));//$NON-NLS-1$
                if (inputType.equals(".xsd")) {//$NON-NLS-1$
                    xsd = Util.getXML(xmlFile);
                    xsdSchema = Util.createXsdSchema(xsd, xobject);
                    xsd = Util.nodeToString(xsdSchema.getDocument());
                } else {
                    XSDDriver d = new XSDDriver();
                    infer = d.doMain(new String[] { xmlFile, "out.xsd" });//$NON-NLS-1$
                    if (infer == 0) {
                        xsd = d.outputXSD();
                    }
                }

            } catch (Exception e) {
                log.error(e.getMessage(), e);
                infer = 2;
            } finally {
                if (infer == 0 && !xsd.equals("")) {//$NON-NLS-1$
                    WSDataModel wsObj = (WSDataModel) (xobject.getWsObject());
                    wsObj.setXsdSchema(xsd);
                    validateSchema(xsd);
                    refreshData();
                    markDirtyWithoutCommit();
                } else if (infer != 0) {
                    MessageDialog.openError(getSite().getShell(), Messages._Error, Messages.XsdSchemaInferred);
                }
            }
        }

        void validateSchema(String xsd) {
            try {
                boolean elem = false;
                XSDSchema schema = getXSDSchema(xsd);
                NodeList nodeList = schema.getDocument().getDocumentElement().getChildNodes();
                for (int idx = 0; idx < nodeList.getLength(); idx++) {
                    Node node = nodeList.item(idx);
                    if (node instanceof Element && node.getLocalName().indexOf("element") >= 0) {//$NON-NLS-1$
                        elem = true;
                        break;
                    }
                }
                if (!elem) {
                    MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.NoElementNode);
                }
            } catch (Exception e) {

                log.error(e.getMessage(), e);
            }
        }
    });

    exportToolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(getSite().getShell(), SWT.SAVE);
            fd.setFilterExtensions(new String[] { "*.xsd" });//$NON-NLS-1$
            fd.setFilterPath(Platform.getInstanceLocation().getURL().getPath().substring(1));
            fd.setText(Messages.SaveDataModuleXSDSchema);
            String filename = fd.open();
            if (filename == null) {
                return;
            }
            inferXsdFromDataModule(filename);
        }

        private void inferXsdFromDataModule(String xmlFile) {
            WSDataModel wsObject = (WSDataModel) (xobject.getWsObject());
            XSDDriver d = new XSDDriver();
            if (d.outputXSD_UTF_8(wsObject.getXsdSchema(), xmlFile) != null) {
                MessageDialog.openInformation(getSite().getShell(), Messages.ExportXSD,
                        Messages.OperationExportingXsd);
            } else {
                MessageDialog.openError(getSite().getShell(), Messages._Error, Messages.FailedExportXSD);
            }
        }
    });

    importSchemalItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            popupImportDialog();
        }

    });

}

From source file:com.amalto.workbench.editors.ItemsTrashBrowserMainPage.java

License:Open Source License

@Override
protected void createFormContent(IManagedForm managedForm) {

    try {/*from   w w w .ja v  a 2s.c o  m*/

        // sets the title
        managedForm.getForm().setText(this.getTitle());

        // get the toolkit
        FormToolkit toolkit = managedForm.getToolkit();

        // get the body
        Composite composite = managedForm.getForm().getBody();
        composite.setLayout(new GridLayout(9, false));

        /***
         * Search Text
         */
        Label descriptionLabel = toolkit.createLabel(composite, Messages.ItemsTrashBrowserMainPage_1, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        searchText = toolkit.createText(composite, "*", SWT.BORDER);//$NON-NLS-1$
        searchText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
        // searchText.addModifyListener(this);
        searchText.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent e) {
            }

            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    ItemsTrashBrowserMainPage.this.resultsViewer.setInput(getResults(true));
                    ItemsTrashBrowserMainPage.this.resultsViewer.getTable().setFocus();
                }
            }// keyReleased
        }// keyListener
        );

        // search
        Button bSearch = toolkit.createButton(composite, "", SWT.CENTER);//$NON-NLS-1$
        bSearch.setImage(ImageCache.getCreatedImage(EImage.BROWSE.getPath()));
        bSearch.setToolTipText(Messages.ItemsTrashBrowserMainPage_2);
        bSearch.setLayoutData(new GridData(SWT.NONE, SWT.CENTER, false, false, 1, 1));
        bSearch.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                ItemsTrashBrowserMainPage.this.resultsViewer.setInput(getResults(true));
            };
        });

        /***
         * Create Table
         */
        final Table table = createTable(composite);

        resultsViewer = new TableViewer(table);

        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 9, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 500;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new ClusterTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                try {
                    new DisplayDroppedItemAction(ItemsTrashBrowserMainPage.this.getSite().getShell(),
                            resultsViewer).run();
                } catch (Exception e) {
                    MessageDialog.openError(ItemsTrashBrowserMainPage.this.getSite().getShell(),
                            Messages._Error, Messages.ItemsTrashBrowserMainPage_4 + e.getClass().getName()
                                    + Messages.ItemsTrashBrowserMainPage_5 + e.getLocalizedMessage());
                }
            }
        });

        hookKeyboard();

        hookContextMenu();

        managedForm.reflow(true); // nothng will show on the form if not called

        searchText.setFocus();
        // adapt body add mouse/focus listener for child
        WidgetFactory factory = WidgetFactory.getWidgetFactory();
        factory.adapt(managedForm.getForm().getBody());
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}

From source file:com.amalto.workbench.editors.ItemsTrashBrowserMainPage.java

License:Open Source License

@Override
protected void refreshData() {
    try {/*from  w  w w  .jav a2  s.c  om*/

        searchText.setFocus();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.ItemsTrashBrowserMainPage_11,
                Messages.ItemsTrashBrowserMainPage_12 + e.getLocalizedMessage());
    }
}

From source file:com.amalto.workbench.editors.ItemsTrashBrowserMainPage.java

License:Open Source License

@Override
protected void commit() {
    try {/*from   w w  w  .  j  av a  2 s  .  co  m*/

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.ItemsTrashBrowserMainPage_13,
                Messages.ItemsTrashBrowserMainPage_14 + e.getLocalizedMessage());
    }
}

From source file:com.amalto.workbench.editors.ItemsTrashBrowserMainPage.java

License:Open Source License

protected LineItem[] getResults(boolean showResultInfo) {

    Cursor waitCursor = null;//from www.j a v  a 2 s .  com

    try {

        Display display = getEditor().getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
        waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
        this.getSite().getShell().setCursor(waitCursor);

        TMDMService service = Util.getMDMService(getXObject());

        String search = searchText.getText();

        List<WSDroppedItemPK> results = null;
        if (search != null && search.length() > 0) {
            results = service.findAllDroppedItemsPKs(new WSFindAllDroppedItemsPKs(search)).getWsDroppedItemPK();
        }

        if ((results == null) || (results.isEmpty())) {
            if (showResultInfo) {
                MessageDialog.openInformation(this.getSite().getShell(), Messages.ItemsTrashBrowserMainPage_15,
                        Messages.ItemsTrashBrowserMainPage_16);
                return new LineItem[0];
            }
        } else {
            LineItem[] res = new LineItem[results.size()];
            for (int i = 0; i < results.size(); i++) {
                WSDroppedItemPK wsDroppedItemPK = results.get(i);
                WSItemPK refWSItemPK = wsDroppedItemPK.getWsItemPK();

                // if(revison==null||revison.equals(""))revison="head";

                res[i] = new LineItem(refWSItemPK.getWsDataClusterPK().getPk(), refWSItemPK.getConceptName(),
                        refWSItemPK.getIds().toArray(new String[0]), null, wsDroppedItemPK.getPartPath());
            }
            return res;
        }

        return new LineItem[0];
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ItemsTrashBrowserMainPage_17,
                    Messages.ItemsTrashBrowserMainPage_18);
        } else {
            if (!Util.handleConnectionException(this, e, null)) {
                MessageDialog.openError(this.getSite().getShell(), Messages.ItemsTrashBrowserMainPage_19,
                        e.getLocalizedMessage());
            }
        }
        return null;
    } finally {
        try {
            this.getSite().getShell().setCursor(null);
            waitCursor.dispose();
        } catch (Exception e) {
        }
    }

}