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.dialogs.SelectImportedModulesDialog.java

License:Open Source License

protected boolean resolveSchemaList(List<String> schemaList) throws XtentisException {
    TMDMService port = getPort();/*from ww w. jav a  2  s .  c  o  m*/
    if (port == null) {
        MessageDialog.openError(getShell(), Messages._Error, Messages.ServerNotNull);
        return false;
    }
    List<WSDataModelPK> xdmPKs = port.getDataModelPKs(new WSRegexDataModelPKs("")).getWsDataModelPKs();//$NON-NLS-1$
    if (xdmPKs != null) {
        for (WSDataModelPK xdmPK : xdmPKs) {
            String name = xdmPK.getPk();
            if (!name.startsWith("XMLSCHEMA")) {//$NON-NLS-1$
                schemaList.add(name);
            }
        }
    }

    return true;
}

From source file:com.amalto.workbench.dialogs.TextViewDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    try {//from w  w  w  .j a va2  s  .co m
        // Should not really be here but well,....
        parent.getShell().setText(Messages.TextViewDialog_TextView);

        Composite composite = (Composite) super.createDialogArea(parent);
        GridLayout layout = (GridLayout) composite.getLayout();
        layout.numColumns = 1;

        textViewer = new TextViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        textViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        ((GridData) textViewer.getControl().getLayoutData()).heightHint = 250;
        ((GridData) textViewer.getControl().getLayoutData()).widthHint = 250;
        textViewer.setEditable(false);
        Document doc = new Document(text);
        textViewer.setDocument(doc);

        return composite;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.TextViewDialog_ErrorMsg + e.getLocalizedMessage());
        return null;
    }

}

From source file:com.amalto.workbench.editors.actions.DeleteItemsAction.java

License:Open Source License

@Override
public void run() {
    try {/*w ww. ja  v a 2 s.  c om*/
        super.run();

        // retrieve the list of items
        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
        List<WSRoutingOrderV2> lineItems = selection.toList();

        if (lineItems.size() == 0) {
            return;
        }

        if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmDeletion,
                Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg2, lineItems.size()))) {
            return;
        }

        // Instantiate the Monitor with actual deletes
        DeleteItemsWithProgress diwp = new DeleteItemsWithProgress(
                (TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems,
                this.shell);
        // run
        new ProgressMonitorDialog(this.shell).run(false, // fork
                true, // cancelable
                diwp);
        // refresh the search
        routingEngineV2BrowserMainPage.doSearch();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error,
                Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg3, e.getLocalizedMessage()));
    }
}

From source file:com.amalto.workbench.editors.actions.EditItemAction.java

License:Open Source License

@Override
public void run() {
    try {//from  ww w  . j  a v a 2  s  . co  m
        super.run();

        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());

        if (selection.isEmpty()) {
            return;
        }

        WSRoutingOrderV2 routingOrder = (WSRoutingOrderV2) selection.getFirstElement();

        StringWriter sw = new StringWriter();
        Marshaller.marshal(routingOrder, sw);

        final DOMViewDialog d = new DOMViewDialog(shell, Util.parse(sw.toString()));
        d.addListener(new Listener() {

            public void handleEvent(Event event) {
                d.close();
            }// handleEvent
        });

        d.setBlockOnOpen(true);
        d.open();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error, Messages.bind(
                Messages.RoutingEngineV2BrowserMainPage_ErrorToViewRoutingOrder, e.getLocalizedMessage()));
    }
}

From source file:com.amalto.workbench.editors.actions.ExecuteRoutingOrdersAction.java

License:Open Source License

@Override
public void run() {
    try {//from   ww  w .ja  v a  2  s  .co m
        super.run();

        // retrieve the list of items
        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
        List<WSRoutingOrderV2> lineItems = selection.toList();

        if (lineItems.size() == 0) {
            return;
        }

        if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmTitle,
                Messages.RoutingEngineV2BrowserMainPage_ConfirmContent
                        + (synchronously ? Messages.RoutingEngineV2BrowserMainPage_Text2
                                : Messages.RoutingEngineV2BrowserMainPage_Text3)
                        + Messages.RoutingEngineV2BrowserMainPage_ConfirmContentA + lineItems.size()
                        + Messages.RoutingEngineV2BrowserMainPage_B)) {
            return;
        }

        // Instantiate the Monitor with actual deletes
        ExecuteRoutingOrdersWithProgress diwp = new ExecuteRoutingOrdersWithProgress(
                (TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems,
                this.shell);
        // run
        new ProgressMonitorDialog(this.shell).run(false, // fork
                true, // cancelable
                diwp);
        // refresh the search
        routingEngineV2BrowserMainPage.doSearch();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error,
                Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg4, e.getLocalizedMessage()));
    }
}

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

License:Open Source License

@Override
protected void commit() {
    try {/*  w  w  w .ja  v  a2  s  .co m*/
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_18,
                Messages.bind(Messages.DataClusterBrowserMainPage_19, e.getLocalizedMessage()));
    }
}

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

License:Open Source License

protected void hookDoubleClick() {
    resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            resultsViewer.setSelection(event.getSelection());
            try {
                editItem();//from w  ww. j  a va  2s .  com
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Messages._Error,
                        Messages.bind(Messages.DataClusterBrowserMainPage_10, e.getClass().getName(),
                                e.getLocalizedMessage()));
            }
        }
    });
}

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

License:Open Source License

protected LineItem[] getResults(boolean showResultInfo) {

    Cursor waitCursor = null;//from w w  w  . jav a2  s. c  o  m

    try {

        waitCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
        getSite().getShell().setCursor(waitCursor);

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

        long from = -1;
        long to = -1;

        Pattern pattern = Pattern.compile("^\\d{4}\\d{2}\\d{2} \\d{2}:\\d{2}:\\d{2}$");//$NON-NLS-1$

        if (!"".equals(fromText.getText())) {//$NON-NLS-1$

            String dateTimeText = fromText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning,
                        Messages.DataClusterBrowserMainPage_21);
                return new LineItem[0];
            }

            try {
                Date d = sdf.parse(fromText.getText());
                from = d.getTime();
            } catch (ParseException pe) {
            }
        }

        if (!"".equals(toText.getText())) { //$NON-NLS-1$
            String dateTimeText = toText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning,
                        Messages.DataClusterBrowserMainPage_23);
                return new LineItem[0];
            }

            try {
                Date d = sdf.parse(toText.getText());
                to = d.getTime();
            } catch (ParseException pe) {
            }
        }

        String concept = conceptCombo.getText();
        if ("*".equals(concept) | "".equals(concept)) { //$NON-NLS-1$ //$NON-NLS-2$
            concept = null;
        }
        if (concept != null) {
            concept = concept.replaceAll("\\[.*\\]", "").trim();//$NON-NLS-1$//$NON-NLS-2$
        }
        String keys = keyText.getText();
        if ("*".equals(keys) | "".equals(keys)) { //$NON-NLS-1$ //$NON-NLS-2$
            keys = null;
        }

        boolean useFTSearch = isMaster ? checkFTSearchButton.getSelection() : false;
        String search = searchText.getText();
        if ("*".equals(search) | "".equals(search)) { //$NON-NLS-1$ //$NON-NLS-2$
            search = null;
        }

        int start = pageToolBar.getStart();
        int limit = pageToolBar.getLimit();
        // see 0015909
        String clusterName = URLEncoder.encode(getXObject().toString(), "utf-8");//$NON-NLS-1$
        WSDataClusterPK clusterPk = new WSDataClusterPK(clusterName + getPkAddition());

        // @temp yguo, get item with taskid or get taskid by specify wsitempk.
        List<WSItemPKsByCriteriaResponseResults> results = service.getItemPKsByFullCriteria(
                new WSGetItemPKsByFullCriteria(useFTSearch, new WSGetItemPKsByCriteria(concept, search, from,
                        null, keys, limit, start, to, clusterPk)))
                .getResults();

        if (showResultInfo && (results.size() == 1)) {
            MessageDialog.openInformation(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_24,
                    Messages.DataClusterBrowserMainPage_25);
            return new LineItem[0];
        }
        if (results.size() == 1) {
            return new LineItem[0];
        }
        int totalSize = 0;
        List<LineItem> ress = new ArrayList<LineItem>();
        for (int i = 0; i < results.size(); i++) {
            WSItemPKsByCriteriaResponseResults result = results.get(i);
            if (i == 0) {
                totalSize = Integer.parseInt(Util.parse(result.getWsItemPK().getConceptName())
                        .getDocumentElement().getTextContent());

                continue;
            }

            ress.add(new LineItem(result.getDate(), result.getWsItemPK().getConceptName(),
                    result.getWsItemPK().getIds().toArray(new String[0]), result.getTaskId()));
        }
        pageToolBar.setTotalsize(totalSize);
        pageToolBar.refreshUI();
        return ress.toArray(new LineItem[ress.size()]);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) { //$NON-NLS-1$
            MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_26,
                    Messages.DataClusterBrowserMainPage_27);
        } else if (!Util.handleConnectionException(this.getSite().getShell(), e,
                Messages.DataClusterBrowserMainPage_28)) {
            MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_28,
                    e.getLocalizedMessage());
        }

        return null;
    } finally {
        try {
            this.getSite().getShell().setCursor(null);
            waitCursor.dispose();
        } catch (Exception e) {
        }
    }
}

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

License:Open Source License

protected boolean refreshData() {
    try {//w  ww. jav  a 2 s  .c  o  m
        if (conceptCombo.isDisposed()) {
            return false;
        }
        if (getXObject().getEndpointAddress() == null) {
            return false;
        }
        TMDMService service = Util.getMDMService(getXObject());

        WSDataCluster cluster = null;
        if (getXObject().getWsObject() == null) { // then fetch from server
            cluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) getXObject().getWsKey()));
            getXObject().setWsObject(cluster);
        } else { // it has been opened by an editor - use the object there
            // added for TMDM-3064
            // the following may throw ServerException to identify the data continer not exist on the server
            cluster = service.getDataCluster(new WSGetDataCluster(new WSDataClusterPK(getXObject().getName())));
            // if you could go to next line, that means the data container is on the server specified
            cluster = (WSDataCluster) getXObject().getWsObject();

        }

        // add by myli; fix the bug:0013077: if the data is too much, just get the entities from the model instead
        // of from the container.

        String clusterName = URLEncoder.encode(cluster.getName(), "utf-8");//$NON-NLS-1$

        //            WSString countStr = port.count(new WSCount(new WSDataClusterPK(cluster.getName()), "*", null, 100)); //$NON-NLS-1$
        // long count = Long.parseLong(countStr.getValue());

        WSStringArray conceptsInDataCluster = service
                .getConceptsInDataCluster(new WSGetConceptsInDataCluster(new WSDataClusterPK(clusterName)));
        if (conceptsInDataCluster != null) {
            List<String> concepts = conceptsInDataCluster.getStrings();
            conceptCombo.removeAll();
            conceptCombo.add("*");//$NON-NLS-1$
            for (String concept : concepts) {
                conceptCombo.add(concept);
            }
        } else {
            boolean selected = doSelectDataModelForEntityRecords(clusterName);
            if (!selected) {
                return false;
            }
        }

        conceptCombo.select(0);
        searchText.setFocus();
    } catch (ServerException e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(getSite().getShell(), Messages._Error,
                Messages.DataClusterBrowser_dataContainerError);
        return false;
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(getSite().getShell(), e, null)) {
            MessageDialog.openError(getSite().getShell(), Messages._Error,
                    Messages.DataClusterBrowser_connectionError);
        }
        return false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.DataClusterBrowser_error, e.getLocalizedMessage()));
        return false;
    }

    return true;
}

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

License:Open Source License

private void showInTextWidget(LineItem lineItem) {
    if (lineItem == null) {
        textViewer.setText(""); //$NON-NLS-1$
        recordContent = ""; //$NON-NLS-1$
        return;/*from   www . j ava2s  .  c o  m*/
    }

    try {
        final TMDMService service = Util.getMDMService(model);
        final WSItem wsItem = service.getItem(new WSGetItem(new WSItemPK(lineItem.getConcept().trim(),
                Arrays.asList(lineItem.getIds()), (WSDataClusterPK) model.getWsKey())));
        recordContent = Util.formatXsdSource(wsItem.getContent());
        textViewer.setText(recordContent);
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(getShell(), Messages._Error,
                Messages.bind(Messages.DataClusterBrowserMainPage_36, e.getLocalizedMessage()));
    }
}