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.IdentityConstraintInputDialog.java

License:Open Source License

protected void okPressed() {
    // keyName = keyNameText.getText();
    fieldName = fieldNameCombo.getText().trim();
    keyName = keyNameText.getText().trim();
    if ((keyName == null) || ("".equals(keyName))) {//$NON-NLS-1$
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.IdentityConstraintInputDialog_KeyNameCannotbeEmpty);
        setReturnCode(-1);//from  ww  w .  ja  v  a  2s .co  m
        keyNameText.setFocus();
        // fieldNameCombo.setFocus();
        return;
    }

    if (keyName.replaceAll("\\s", "").length() != keyName.length()) {//$NON-NLS-1$//$NON-NLS-2$
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.IdentityConstraintInputDialog_KeyNameCannotContainEmpty);
        setReturnCode(-1);
        keyNameText.setFocus();
        return;
    }

    if (fieldName.replaceAll("\\s", "").length() != fieldName.length()) {//$NON-NLS-1$//$NON-NLS-2$
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.IdentityConstraintInputDialog_FieldNameCannotbeEmpty);
        setReturnCode(-1);
        fieldNameCombo.setFocus();
        return;
    }

    // if ((fieldName==null) || ("".equals(fieldName))) {
    // MessageDialog.openError(
    // this.getShell(),
    // "Error", "The Field Name cannot be empty"
    // );
    // setReturnCode(-1);
    // //keyNameText.setFocus();
    // fieldNameCombo.setFocus();
    // return;
    // }
    // String selection = (typeCombo.getText()).toUpperCase();
    // if (selection.indexOf("UNIQUE")>=0)
    // type = XSDIdentityConstraintCategory.UNIQUE_LITERAL;
    // else if (selection.indexOf("FOREIGN")>=0)
    // type = XSDIdentityConstraintCategory.KEYREF_LITERAL;
    // else
    // type = XSDIdentityConstraintCategory.KEY_LITERAL;

    type = getTypeFromUI();

    // setReturnCode(OK);
    // //no close let Action Handler handle it

    super.okPressed();
}

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

License:Open Source License

private boolean validInput() {

    if ("".equals(keyNameText.getText().trim())) {//$NON-NLS-1$
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.IdentityConstraintInputDialog_KeyNameCannotbeEmpty);
        keyNameText.setFocus();/*from   w w  w  . j  av a2 s.c  o  m*/
        return false;
    }

    if (inputValidator != null) {
        String errMsg = inputValidator.isValid(keyNameText.getText().trim(), getTypeFromUI(),
                this.keyContainer);

        if (errMsg != null) {
            MessageDialog.openError(this.getShell(), Messages._Error, errMsg);
            return false;
        }
    }

    return true;
}

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

License:Open Source License

protected void okPressed() {
    if ("".equals(minOccursText.getText()) && "".equals(maxOccursText.getText())) {//$NON-NLS-1$//$NON-NLS-2$
        minOccurs = 1;//from w  w  w  . j av  a  2  s  .c o  m
        maxOccurs = 1;
        return;
    }
    try {
        minOccurs = Integer.parseInt(minOccursText.getText());
    } catch (Exception e1) {
        MessageDialog.openError(this.getShell(), Messages._Error, Messages.NewGroupDialog_ErrorMsg);
        setReturnCode(-1);
        minOccursText.setFocus();
        return;
    }
    if (minOccurs < 0) {
        MessageDialog.openError(this.getShell(), Messages._Error, Messages.NewGroupDialog_ErrorMsg);
        setReturnCode(-1);
        minOccursText.setFocus();
        return;
    }

    if ("".equals(maxOccursText.getText())) {//$NON-NLS-1$
        maxOccurs = -1;
    } else {
        try {
            maxOccurs = Integer.parseInt(maxOccursText.getText());
        } catch (Exception e2) {
            MessageDialog.openError(this.getShell(), Messages._Error, Messages.NewGroupDialog_ErrorMsg1);
            setReturnCode(-1);
            maxOccursText.setFocus();
            return;
        }
        if ((maxOccurs < minOccurs) || (maxOccurs <= 0))
            maxOccurs = -1;
    }

    setReturnCode(OK);
    // no close let Action Handler handle it
}

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

License:Open Source License

protected Control createDialogArea(Composite parent) {

    try {/*www  .  j a v a  2 s . c om*/
        // Should not really be here but well,....
        parent.getShell().setText(Messages.PluginDetailsDialog_PluginDetails);

        Composite composite = new Composite(parent, SWT.NULL);
        GridLayout layout = new GridLayout();
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        applyDialogFont(composite);

        tabFolder = new TabFolder(composite, SWT.TOP);
        tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        tabFolder.setLayout(new GridLayout(1, true));
        ((GridData) tabFolder.getLayoutData()).heightHint = 600;
        ((GridData) tabFolder.getLayoutData()).widthHint = 600;

        TabItem descriptionTI = new TabItem(tabFolder, SWT.NULL);
        descriptionTI.setText(Messages.PluginDetailsDialog_Description);
        descriptionTI.setToolTipText(Messages.PluginDetailsDialog_DescriptionTip);

        Composite descriptionC = new Composite(tabFolder, SWT.NULL);
        descriptionC.setLayout(new GridLayout(1, true));
        descriptionC.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

        /*
         * Label descriptionLabel = new Label(descriptionC, SWT.LEFT); descriptionLabel.setLayoutData( new
         * GridData(SWT.LEFT,SWT.CENTER,false,false,1,1) ); FontData fd =
         * descriptionLabel.getFont().getFontData()[0]; fd.setStyle(SWT.BOLD); descriptionLabel.setFont(new
         * Font(Display.getDefault(),fd)); descriptionLabel.setText("Description");
         */

        Label descValue = new Label(descriptionC, SWT.WRAP);
        descValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        descValue.setText(description + "\n");//$NON-NLS-1$

        Label documentationLabel = new Label(descriptionC, SWT.LEFT);
        documentationLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
        documentationLabel.setFont(FontUtils.getBoldFont(documentationLabel.getFont()));
        documentationLabel.setText(templetName);

        Text docValue = new Text(descriptionC, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
        docValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        docValue.setBackground(documentationLabel.getBackground());
        docValue.setText(documentation);

        descriptionTI.setControl(descriptionC);

        /*
         * TabItem parametersTI = new TabItem(tabFolder,SWT.NULL); parametersTI.setText("Parameters");
         * parametersTI.setToolTipText("Display the plugin description and documentation");
         * 
         * Composite parametersC = new Composite(tabFolder,SWT.NULL); parametersC.setLayout(new GridLayout(1,true));
         * 
         * Label paramsValue = new Label(parametersC, SWT.WRAP); paramsValue.setLayoutData( new
         * GridData(SWT.FILL,SWT.CENTER,true,false,1,1) ); paramsValue.setText(parametersSchema);
         * 
         * parametersTI.setControl(parametersC);
         */

        tabFolder.setSelection(0);

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

}

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

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    try {//from   w  w w . j  av a2 s .c o m

        parent.getShell().setText(title);

        Composite composite = (Composite) super.createDialogArea(parent);
        GridLayout layout = (GridLayout) composite.getLayout();
        layout.numColumns = 2;
        ((GridData) composite.getLayoutData()).widthHint = 800;

        Label variableLabel = new Label(composite, SWT.NONE);
        variableLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
        variableLabel.setText(Messages.ProcessResultsDialog_PipelineVariables);

        variablesCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        variablesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));

        /*
         * variablesCombo.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) {} public void
         * keyReleased(KeyEvent e) { if ((e.stateMask==0) && (e.character == SWT.CR)) {
         * ProcessResultsPage.this.variablesViewer.setDocument(new Document(getText(variablesCombo.getText()))); }
         * }//keyReleased }//keyListener );
         */

        variablesViewer = new SourceViewer(composite, new VerticalRuler(10), SWT.V_SCROLL | SWT.H_SCROLL);
        variablesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
        variablesViewer.configure(new TextSourceViewerConfiguration());
        ((GridData) variablesViewer.getControl().getLayoutData()).minimumHeight = 500;

        final Button seeInBrowser = new Button(composite, SWT.PUSH);
        seeInBrowser.setText(Messages.ProcessResultsDialog_display);
        seeInBrowser.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String htmlContent = variablesViewer.getTextWidget().getText();
                IFile file = FileProvider.createdTempFile(htmlContent, Messages.ProcessResultsDialog_temphtml,
                        null);

                File htmlFile = file.getLocation().toFile();
                String SHARED_ID = "org.eclipse.ui.browser"; //$NON-NLS-1$
                try {
                    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();

                    if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL) {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR,
                                file.getLocation().toPortableString(), null, null).openURL(htmlFile.toURL());
                    } else {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, SHARED_ID, null, null)
                                .openURL(htmlFile.toURL());
                    }
                } catch (Exception e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
        });

        variablesCombo.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                String output = variablesCombo.getText();
                if (output.startsWith(TransformerMainPage.DEFAULT_DISPLAY)) {
                    output = DEFAULT_DISPLAY_TEXT;// TransformerMainPage.DEFAULT_VAR+output.substring(TransformerMainPage.DEFAULT_DISPLAY.length());
                }
                String text = variablesCombo.getText();
                if (text.equals(DEFAULT_DISPLAY_TEXT)) {
                    text = TransformerMainPage.DEFAULT_DISPLAY;
                }
                variablesViewer.setDocument(new Document(getText(text)));

                seeInBrowser.setEnabled("html".equals(text)); //$NON-NLS-1$
            }
        });

        variablesCombo.setFocus();

        refreshData();

        return composite;

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

}

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

License:Open Source License

protected void refreshData() {
    try {//  w w w  . j  a  va2s.  c  om

        Set<String> outputs = resultsMap.keySet();
        for (Object element : outputs) {
            String output = (String) element;
            if (output.startsWith(TransformerMainPage.DEFAULT_VAR)) {
                output = DEFAULT_DISPLAY_TEXT;// TransformerMainPage.DEFAULT_DISPLAY+output.substring(TransformerMainPage.DEFAULT_VAR.length());
            }
            variablesCombo.add(output);
        }
        variablesCombo.select(0);
        String text = variablesCombo.getText();
        if (text.equals(DEFAULT_DISPLAY_TEXT)) {
            text = TransformerMainPage.DEFAULT_DISPLAY;
        }
        variablesViewer.setDocument(new Document(getText(text)));

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages.ProcessResultsDialog_ErrorTitle,
                Messages.bind(Messages.ProcessResultsDialog_ErrorMsg1, e.getLocalizedMessage()));
    }
}

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

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    // Should not really be here but well,....
    parent.getShell().setText(this.title);

    Composite composite = (Composite) super.createDialogArea(parent);

    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 2;// w ww. j  a va2  s  .  co m
    // layout.verticalSpacing = 10;

    try {

        // process the decision
        String dataClusterName = "";//$NON-NLS-1$
        String dataModelName = "";//$NON-NLS-1$
        boolean doOverwrite = true;
        Matcher m = dp.matcher(decision);
        if (m.matches()) {
            dataClusterName = m.group(1);
            dataModelName = m.group(2);
            if (m.groupCount() >= 4) {
                doOverwrite = (!"false".equals(m.group(3)));//$NON-NLS-1$
            }
        }

        TMDMService port = Util.getMDMService(new URL(transformerObject.getEndpointAddress()),
                transformerObject.getUsername(), transformerObject.getPassword());

        // Grab the available Clusters
        List<WSDataClusterPK> dcpks = port.getDataClusterPKs(new WSRegexDataClusterPKs(".*")) //$NON-NLS-1$
                .getWsDataClusterPKs();

        Label dataClustersLabel = new Label(composite, SWT.NULL);
        dataClustersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        dataClustersLabel.setText(Messages.ProjectDecisionDialog_DataContainers);

        dataClustersCombo = new Combo(composite, SWT.DROP_DOWN);
        dataClustersCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        int dataClusterSelect = -1;
        if (dcpks != null) {
            int i = 0;
            for (WSDataClusterPK pk : dcpks) {
                dataClustersCombo.add(pk.getPk());
                if (pk.getPk().equals(dataClusterName)) {
                    dataClusterSelect = i;
                }
                i++;
            }
        }
        dataClustersCombo.select(dataClusterSelect);

        // Grab the available Models
        List<WSDataModelPK> dmpks = port.getDataModelPKs(new WSRegexDataModelPKs(".*")).getWsDataModelPKs();//$NON-NLS-1$

        Label dataModelsLabel = new Label(composite, SWT.NULL);
        dataModelsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        dataModelsLabel.setText(Messages.ProjectDecisionDialog_DataModels);

        dataModelsCombo = new Combo(composite, SWT.DROP_DOWN);
        dataModelsCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        int dataModelSelect = -1;
        if (dmpks != null) {
            int i = 0;
            for (WSDataModelPK pk : dmpks) {
                dataModelsCombo.add(pk.getPk());
                if (pk.getPk().equals(dataModelName)) {
                    dataModelSelect = i;
                }
                i++;
            }
        }
        dataModelsCombo.select(dataModelSelect);

        // Overwrite
        Label overwriteLabel = new Label(composite, SWT.NULL);
        overwriteLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        overwriteLabel.setText(Messages.ProjectDecisionDialog_Overwrite);

        overwriteButton = new Button(composite, SWT.CHECK);
        overwriteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        overwriteButton.setSelection(doOverwrite);

    } catch (Exception e) {
        if (!Util.handleConnectionException(this.getShell(), e, null)) {
            MessageDialog.openError(ProjectDecisionDialog.this.getShell(),
                    Messages.ProjectDecisionDialog_ErrorTitle,
                    Messages.bind(Messages.ProjectDecisionDialog_ErrorMsg, e.getMessage()));
        }
    }

    return composite;
}

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

License:Open Source License

protected Control createDialogArea(Composite parent) {

    try {//  w  ww .ja va 2 s  . c o  m
        // Should not really be here but well,....
        parent.getShell().setText(Messages.QueryParametersDialog_);

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

        map = new LinkedHashMap<Integer, Text>();

        for (int i = 0; i < parameters.length; i++) {
            Label nameLabel = new Label(composite, SWT.NULL);
            nameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
            nameLabel.setText("%" + i + " ");//$NON-NLS-1$//$NON-NLS-2$
            // name
            Text nameText = new Text(composite, SWT.BORDER);
            nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
            nameText.setText(parameters[i]);
            map.put(new Integer(i), nameText);
        }

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

}

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

License:Open Source License

private boolean validateInput() {

    if ("".equals(fieldNameCombo.getText().trim())) {//$NON-NLS-1$
        MessageDialog.openError(getShell(), Messages._Error, Messages.SelectFieldDialog_FileNameCannotbeEmpty);
        return false;
    }//ww w.  j  a  v  a  2  s  .c o  m

    if (Pattern.compile("^\\s+\\w+\\s*").matcher(fieldNameCombo.getText()).matches()//$NON-NLS-1$
            || fieldNameCombo.getText().trim().replaceAll("\\s", "").length() != fieldNameCombo.getText().trim() //$NON-NLS-1$//$NON-NLS-2$
                    .length()) {

        MessageDialog.openError(getShell(), Messages._Error,
                Messages.SelectFieldDialog_FileNameCannotContainEmpty);
        return false;
    }

    return true;
}

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

License:Open Source License

public void addSchema(java.net.URL url, boolean addEntity) {
    try {/*from   w  ww .  j  a va  2s.  c  om*/
        addContent.clear();
        entityViewer.refresh();
        typeViewer.refresh();
        XSDSchema schema = createSchema(url);
        if (addEntity) {
            addEntity(schema);
        }
        addTypes(schema);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        MessageDialog.openError(getShell(), Messages.import_schema_failed, Messages.invalid_schema);
    }
}