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

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

Introduction

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

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.

Click Source Link

Document

Constant for the warning image, or a simple dialog with the warning image and a single OK button (value 4).

Usage

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.avro.output.AvroOutputDialog.java

License:Apache License

private MessageDialog getFieldsChoiceDialog(Shell shell, int existingFields, int newFields) {
    MessageDialog messageDialog = new MessageDialog(shell,
            BaseMessages.getString(PKG, "AvroOutputDialog.GetFieldsChoice.Title"), // "Warning!"
            null,/*from www  .jav a2  s. c  o m*/
            BaseMessages.getString(
                    PKG, "AvroOutputDialog.GetFieldsChoice.Message", "" + existingFields, "" + newFields),
            MessageDialog.WARNING,
            new String[] { BaseMessages.getString(PKG, "AvroOutputDialog.AddNew"),
                    BaseMessages.getString(PKG, "AvroOutputDialog.Add"),
                    BaseMessages.getString(PKG, "AvroOutputDialog.ClearAndAdd"),
                    BaseMessages.getString(PKG, "AvroOutputDialog.Cancel"), },
            0);
    MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
    return messageDialog;
}

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.orc.output.OrcOutputDialog.java

License:Apache License

private MessageDialog getFieldsChoiceDialog(Shell shell, int existingFields, int newFields) {
    MessageDialog messageDialog = new MessageDialog(shell,
            BaseMessages.getString(PKG, "OrcOutputDialog.GetFieldsChoice.Title"), // "Warning!"
            null,/*from  w  w  w .  j ava  2s . c  om*/
            BaseMessages.getString(
                    PKG, "OrcOutputDialog.GetFieldsChoice.Message", "" + existingFields, "" + newFields),
            MessageDialog.WARNING,
            new String[] { BaseMessages.getString(PKG, "OrcOutputDialog.AddNew"),
                    BaseMessages.getString(PKG, "OrcOutputDialog.Add"),
                    BaseMessages.getString(PKG, "OrcOutputDialog.ClearAndAdd"),
                    BaseMessages.getString(PKG, "OrcOutputDialog.Cancel"), },
            0);
    MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
    return messageDialog;
}

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.parquet.input.ParquetInputDialog.java

License:Apache License

static MessageDialog getFieldsChoiceDialog(Shell shell, int newFields) {
    MessageDialog messageDialog = new MessageDialog(shell,
            BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.Title"), // "Warning!"
            null, BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.Message", "" + newFields),
            MessageDialog.WARNING,
            new String[] { BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.AddNew"),
                    BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.Add"),
                    BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.ClearAndAdd"),
                    BaseMessages.getString(PKG, "ParquetInput.GetFieldsChoice.Cancel"), },
            0) {/*from w  ww .jav  a2  s  .co m*/

        public void create() {
            super.create();
            getShell().setBackground(GUIResource.getInstance().getColorWhite());
        }

        protected Control createMessageArea(Composite composite) {
            Control control = super.createMessageArea(composite);
            imageLabel.setBackground(GUIResource.getInstance().getColorWhite());
            messageLabel.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }

        protected Control createDialogArea(Composite parent) {
            Control control = super.createDialogArea(parent);
            control.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }

        protected Control createButtonBar(Composite parent) {
            Control control = super.createButtonBar(parent);
            control.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }
    };
    MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
    return messageDialog;
}

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.parquet.output.ParquetOutputDialog.java

License:Apache License

static MessageDialog getFieldsChoiceDialog(Shell shell, int existingFields, int newFields) {
    MessageDialog messageDialog = new MessageDialog(shell,
            BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.Title"), // "Warning!"
            null, BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.Message", "" + newFields),
            MessageDialog.WARNING,
            new String[] { BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.AddNew"),
                    BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.Add"),
                    BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.ClearAndAdd"),
                    BaseMessages.getString(PKG, "ParquetOutput.GetFieldsChoice.Cancel"), },
            0) {// w ww  .ja v  a 2  s. co  m

        public void create() {
            super.create();
            getShell().setBackground(GUIResource.getInstance().getColorWhite());
        }

        protected Control createMessageArea(Composite composite) {
            Control control = super.createMessageArea(composite);
            imageLabel.setBackground(GUIResource.getInstance().getColorWhite());
            messageLabel.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }

        protected Control createDialogArea(Composite parent) {
            Control control = super.createDialogArea(parent);
            control.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }

        protected Control createButtonBar(Composite parent) {
            Control control = super.createButtonBar(parent);
            control.setBackground(GUIResource.getInstance().getColorWhite());
            return control;
        }
    };
    MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
    return messageDialog;
}

From source file:org.pentaho.big.data.kettle.plugins.hbase.input.HBaseInputDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(Messages.getString("System.StepJobEntryNameMissing.Title"));
        mb.setMessage(Messages.getString("System.JobEntryNameMissing.Msg"));
        mb.open();/*from w ww  .  j  a  v a2 s  .c o m*/
        return;
    }
    NamedCluster selectedNamedCluster = namedClusterWidget.getSelectedNamedCluster();
    if (selectedNamedCluster == null) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(Messages.getString("Dialog.Error"));
        mb.setMessage(Messages.getString("HBaseInputDialog.NamedClusterNotSelected.Msg"));
        mb.open();
        return;
    } else {
        if (StringUtils.isEmpty(selectedNamedCluster.getZooKeeperHost())) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setText(Messages.getString("Dialog.Error"));
            mb.setMessage(Messages.getString("HBaseInputDialog.NamedClusterMissingValues.Msg"));
            mb.open();
            return;
        }
    }
    HBaseService hBaseService = null;
    try {
        hBaseService = getHBaseService();
    } catch (ClusterInitializationException e) {
        throw new RuntimeException(e);
    }
    HBaseValueMetaInterfaceFactory hBaseValueMetaInterfaceFactory = hBaseService
            .getHBaseValueMetaInterfaceFactory();

    stepname = m_stepnameText.getText();

    updateMetaConnectionDetails(m_currentMeta);

    m_currentMeta.setKeyStartValue(m_keyStartText.getText());
    m_currentMeta.setKeyStopValue(m_keyStopText.getText());
    m_currentMeta.setScannerCacheSize(m_scanCacheText.getText());
    m_currentMeta.setMatchAnyFilter(m_matchAnyBut.getSelection());

    int numNonEmpty = m_fieldsView.nrNonEmpty();
    if (numNonEmpty > 0) {
        ByteConversionUtil byteConversionUtil = hBaseService.getByteConversionUtil();
        List<HBaseValueMetaInterface> outputFields = new ArrayList<>();

        for (int i = 0; i < numNonEmpty; i++) {
            TableItem item = m_fieldsView.getNonEmpty(i);
            String alias = item.getText(1).trim();
            String isKey = item.getText(2).trim();
            String family = item.getText(3).trim();
            String column = item.getText(4).trim();
            String type = item.getText(5).trim();
            String format = item.getText(6).trim();

            HBaseValueMetaInterface vm = hBaseValueMetaInterfaceFactory.createHBaseValueMetaInterface(family,
                    column, alias, ValueMeta.getType(type), -1, -1);

            vm.setTableName(m_mappedTableNamesCombo.getText());
            vm.setMappingName(m_mappingNamesCombo.getText());
            vm.setKey(isKey.equalsIgnoreCase("Y"));
            String indexItems = m_indexedLookup.get(alias);
            if (indexItems != null) {
                Object[] values = byteConversionUtil.stringIndexListToObjects(indexItems);
                vm.setIndex(values);
                vm.setStorageType(ValueMetaInterface.STORAGE_TYPE_INDEXED);
            }
            vm.setConversionMask(format);

            outputFields.add(vm);
        }
        m_currentMeta.setOutputFields(outputFields);
    } else {
        m_currentMeta.setOutputFields(null); // output everything
    }

    numNonEmpty = m_filtersView.nrNonEmpty();
    if (numNonEmpty > 0) {
        ColumnFilterFactory columnFilterFactory = hBaseService.getColumnFilterFactory();
        List<ColumnFilter> filters = new ArrayList<>();

        for (int i = 0; i < m_filtersView.nrNonEmpty(); i++) {
            TableItem item = m_filtersView.getNonEmpty(i);
            String alias = item.getText(1).trim();
            String type = item.getText(2).trim();
            String operator = item.getText(3).trim();
            String comparison = item.getText(4).trim();
            String signed = item.getText(6).trim();
            String format = item.getText(5).trim();
            ColumnFilter f = columnFilterFactory.createFilter(alias);
            f.setFieldType(type);
            f.setComparisonOperator(ColumnFilter.ComparisonType.stringToOpp(operator));
            f.setConstant(comparison);
            f.setSignedComparison(signed.equalsIgnoreCase("Y"));
            f.setFormat(format);
            filters.add(f);
        }

        m_currentMeta.setColumnFilters(filters);
    } else {
        m_currentMeta.setColumnFilters(null);
    }

    if (m_storeMappingInStepMetaData.getSelection()) {
        if (Const.isEmpty(m_mappingNamesCombo.getText())) {
            List<String> problems = new ArrayList<String>();

            Mapping toSet = m_mappingEditor.getMapping(false, problems, false);
            if (problems.size() > 0) {
                StringBuffer p = new StringBuffer();
                for (String s : problems) {
                    p.append(s).append("\n");
                }
                MessageDialog md = new MessageDialog(shell,
                        BaseMessages
                                .getString(
                                        HBaseInputMeta.PKG, "HBaseInputDialog.Error.IssuesWithMapping.Title"),
                        null,
                        BaseMessages.getString(HBaseInputMeta.PKG,
                                "HBaseInputDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                        MessageDialog.WARNING,
                        new String[] {
                                BaseMessages.getString(HBaseInputMeta.PKG,
                                        "HBaseInputDialog.Error.IssuesWithMapping.ButtonOK"),
                                BaseMessages.getString(HBaseInputMeta.PKG,
                                        "HBaseInputDialog.Error.IssuesWithMapping.ButtonCancel") },
                        0);
                MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                int idx = md.open() & 0xFF;
                if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
                    return; // Cancel
                }
            }
            m_currentMeta.setMapping(toSet);
        } else {
            HBaseConnection connection = null;
            try {
                connection = getHBaseConnection();
                MappingAdmin admin = new MappingAdmin(connection);
                Mapping current = admin.getMapping(
                        transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText()),
                        transMeta.environmentSubstitute(m_mappingNamesCombo.getText()));

                m_currentMeta.setMapping(current);
                m_currentMeta.setSourceMappingName("");
            } catch (Exception e) {
                logError(Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping") + " \""
                        + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                + transMeta.environmentSubstitute(m_mappingNamesCombo.getText()) + "\""),
                        e);
                new ErrorDialog(shell, Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping"),
                        Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping") + " \""
                                + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                        + transMeta.environmentSubstitute(m_mappingNamesCombo.getText())
                                        + "\""),
                        e);
            } finally {
                if (connection != null) {
                    try {
                        connection.close();
                    } catch (Exception e) {
                        String msg = Messages
                                .getString("HBaseInputDialog.ErrorMessage.FailedClosingHBaseConnection");
                        logError(msg, e);
                        new ErrorDialog(shell, msg, msg, e);
                    }
                }
            }
        }
    } else {
        // we're going to use a mapping stored in HBase - null out any stored
        // mapping
        m_currentMeta.setMapping(null);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.big.data.kettle.plugins.hbase.mapping.MappingEditor.java

License:Apache License

private void populateTableWithTupleTemplate() {
    Table table = m_fieldsView.table;//  w w  w.  j  av a2 s  .c om

    Set<String> existingRowAliases = new HashSet<String>();
    for (int i = 0; i < table.getItemCount(); i++) {
        TableItem tableItem = table.getItem(i);
        String alias = tableItem.getText(1);
        if (!Const.isEmpty(alias)) {
            existingRowAliases.add(alias);
        }
    }

    int choice = 0;
    if (existingRowAliases.size() > 0) {
        // Ask what we should do with existing mapping data
        MessageDialog md = new MessageDialog(m_shell, Messages.getString("MappingDialog.GetFieldsChoice.Title"),
                null,
                Messages.getString("MappingDialog.GetFieldsChoice.Message", "" + existingRowAliases.size(),
                        "" + 5),
                MessageDialog.WARNING, new String[] { Messages.getString("MappingOutputDialog.ClearAndAdd"),
                        Messages.getString("MappingOutputDialog.Cancel"), },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open();
        choice = idx & 0xFF;
    }

    if (choice == 1 || choice == 255 /* 255 = escape pressed */ ) {
        return; // Cancel
    }

    m_fieldsView.clearAll();
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(1, "KEY");
    item.setText(2, "Y");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Family");
    item.setText(2, "N");
    item.setText(5, "String");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Column");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Value");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Timestamp");
    item.setText(2, "N");
    item.setText(5, "Long");

    m_fieldsView.removeEmptyRows();
    m_fieldsView.setRowNums();
    m_fieldsView.optWidth(true);
}

From source file:org.pentaho.big.data.kettle.plugins.hbase.mapping.MappingEditor.java

License:Apache License

private void populateTableWithIncomingFields() {
    if (m_incomingFieldsProducer != null) {
        RowMetaInterface incomingRowMeta = m_incomingFieldsProducer.getIncomingFields();

        Table table = m_fieldsView.table;
        if (incomingRowMeta != null) {
            Set<String> existingRowAliases = new HashSet<String>();
            for (int i = 0; i < table.getItemCount(); i++) {
                TableItem tableItem = table.getItem(i);
                String alias = tableItem.getText(1);
                if (!Const.isEmpty(alias)) {
                    existingRowAliases.add(alias);
                }/*w  w w. j a  v  a2s.  co  m*/
            }

            int choice = 0;
            if (existingRowAliases.size() > 0) {
                // Ask what we should do with existing mapping data
                MessageDialog md = new MessageDialog(m_shell,
                        Messages.getString("MappingDialog.GetFieldsChoice.Title"), null,
                        Messages.getString("MappingDialog.GetFieldsChoice.Message",
                                "" + existingRowAliases.size(), "" + incomingRowMeta.size()),
                        MessageDialog.WARNING,
                        new String[] { Messages.getString("MappingDialog.AddNew"),
                                Messages.getString("MappingOutputDialog.Add"),
                                Messages.getString("MappingOutputDialog.ClearAndAdd"),
                                Messages.getString("MappingOutputDialog.Cancel"), },
                        0);
                MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                int idx = md.open();
                choice = idx & 0xFF;
            }

            if (choice == 3 || choice == 255 /* 255 = escape pressed */ ) {
                return; // Cancel
            }

            if (choice == 2) {
                m_fieldsView.clearAll();
            }

            ByteConversionUtil byteConversionUtil = null;
            try {
                byteConversionUtil = m_configProducer.getHBaseService().getByteConversionUtil();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            for (int i = 0; i < incomingRowMeta.size(); i++) {
                ValueMetaInterface vm = incomingRowMeta.getValueMeta(i);
                boolean addIt = true;

                if (choice == 0) {
                    // only add if its not already in the table
                    if (existingRowAliases.contains(vm.getName())) {
                        addIt = false;
                    }
                }

                if (addIt) {
                    TableItem item = new TableItem(m_fieldsView.table, SWT.NONE);
                    item.setText(1, vm.getName());
                    item.setText(2, "N");

                    if (m_familyCI.getComboValues()[0].length() > 0) {
                        // use existing first column family name as the default
                        item.setText(3, m_familyCI.getComboValues()[0]);
                    } else {
                        // default
                        item.setText(3, DEFAULT_FAMILY);
                    }

                    item.setText(4, vm.getName());
                    item.setText(5, vm.getTypeDesc());
                    if (vm.getType() == ValueMetaInterface.TYPE_INTEGER) {
                        item.setText(5, "Long");
                    }
                    if (vm.getType() == ValueMetaInterface.TYPE_NUMBER) {
                        item.setText(5, "Double");
                    }
                    if (vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_INDEXED) {
                        Object[] indexValus = vm.getIndex();
                        String indexValsS = byteConversionUtil.objectIndexValuesToString(indexValus);
                        item.setText(6, indexValsS);
                    }
                }
            }

            m_fieldsView.removeEmptyRows();
            m_fieldsView.setRowNums();
            m_fieldsView.optWidth(true);
        }
    }
}

From source file:org.pentaho.big.data.kettle.plugins.hbase.output.HBaseOutputDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "System.StepJobEntryNameMissing.Title"));
        mb.setMessage(BaseMessages.getString(HBaseOutputMeta.PKG, "System.JobEntryNameMissing.Msg"));
        mb.open();//from w  w w . j  av  a 2 s.  c  o  m
        return;
    }
    if (namedClusterWidget.getSelectedNamedCluster() == null) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "Dialog.Error"));
        mb.setMessage(
                BaseMessages.getString(HBaseOutputMeta.PKG, "HBaseOutputDialog.NamedClusterNotSelected.Msg"));
        mb.open();
        return;
    } else {
        NamedCluster nc = namedClusterWidget.getSelectedNamedCluster();
        if (StringUtils.isEmpty(nc.getZooKeeperHost())) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "Dialog.Error"));
            mb.setMessage(BaseMessages.getString(HBaseOutputMeta.PKG,
                    "HBaseOutputDialog.NamedClusterMissingValues.Msg"));
            mb.open();
            return;
        }
    }

    stepname = m_stepnameText.getText();

    updateMetaConnectionDetails(m_currentMeta);

    if (m_storeMappingInStepMetaData.getSelection()) {
        if (Const.isEmpty(m_mappingNamesCombo.getText())) {
            List<String> problems = new ArrayList<String>();
            Mapping toSet = m_mappingEditor.getMapping(false, problems, false);
            if (problems.size() > 0) {
                StringBuffer p = new StringBuffer();
                for (String s : problems) {
                    p.append(s).append("\n");
                }
                MessageDialog md = new MessageDialog(shell, BaseMessages
                        .getString(HBaseOutputMeta.PKG, "HBaseOutputDialog.Error.IssuesWithMapping.Title"),
                        null,
                        BaseMessages.getString(HBaseOutputMeta.PKG,
                                "HBaseOutputDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                        MessageDialog.WARNING,
                        new String[] {
                                BaseMessages.getString(HBaseOutputMeta.PKG,
                                        "HBaseOutputDialog.Error.IssuesWithMapping.ButtonOK"),
                                BaseMessages.getString(HBaseOutputMeta.PKG,
                                        "HBaseOutputDialog.Error.IssuesWithMapping.ButtonCancel") },
                        0);
                MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                int idx = md.open() & 0xFF;
                if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
                    return; // Cancel
                }
            }
            m_currentMeta.setMapping(toSet);
        } else {
            HBaseConnection connection = null;
            try {
                connection = getHBaseConnection();
                MappingAdmin admin = new MappingAdmin(connection);
                Mapping current = null;

                current = admin.getMapping(transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText()),
                        transMeta.environmentSubstitute(m_mappingNamesCombo.getText()));

                m_currentMeta.setMapping(current);
                m_currentMeta.setTargetMappingName("");
            } catch (Exception e) {
                logError(Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping") + " \""
                        + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                + transMeta.environmentSubstitute(m_mappingNamesCombo.getText()) + "\""),
                        e);
                new ErrorDialog(shell, Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping"),
                        Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping") + " \""
                                + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                        + transMeta.environmentSubstitute(m_mappingNamesCombo.getText())
                                        + "\""),
                        e);
            } finally {
                try {
                    if (connection != null) {
                        connection.close();
                    }
                } catch (Exception e) {
                    String msg = Messages
                            .getString("HBaseInputDialog.ErrorMessage.FailedClosingHBaseConnection");
                    logError(msg, e);
                    new ErrorDialog(shell, msg, msg, e);
                }
            }
        }
    } else {
        // we're going to use a mapping stored in HBase - null out any stored
        // mapping
        m_currentMeta.setMapping(null);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.big.data.kettle.plugins.hbase.rowdecoder.HBaseRowDecoderDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        return;/*from w ww .ja v a 2 s  .c  om*/
    }

    stepname = m_stepnameText.getText();

    m_currentMeta.setIncomingKeyField(m_incomingKeyCombo.getText());
    m_currentMeta.setIncomingResultField(m_incomingResultCombo.getText());
    List<String> problems = new ArrayList<String>();
    Mapping mapping = m_mappingEditor.getMapping(false, problems, false);
    if (problems.size() > 0) {
        StringBuffer p = new StringBuffer();
        for (String s : problems) {
            p.append(s).append("\n");
        }
        MessageDialog md = new MessageDialog(shell,
                BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.Title"), null,
                BaseMessages.getString(PKG,
                        "HBaseRowDecoderDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                MessageDialog.WARNING,
                new String[] {
                        BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonOK"),
                        BaseMessages.getString(PKG,
                                "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonCancel") },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open() & 0xFF;
        if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
            return; // Cancel
        }
    }
    if (mapping != null) {
        m_currentMeta.setMapping(mapping);
    }
    NamedCluster selectedNamedCluster = m_mappingEditor.getSelectedNamedCluster();
    if (selectedNamedCluster != null) {
        m_currentMeta.setNamedCluster(selectedNamedCluster);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.big.data.plugins.common.ui.NamedClusterDialog.java

License:Apache License

public void ok() {
    result = namedCluster.getName();//  w w  w .  jav  a  2 s  .co  m
    if (StringUtils.isBlank(result)) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(PKG, "NamedClusterDialog.Error"));
        mb.setMessage(BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameMissing"));
        mb.open();
        return;
    } else if (newClusterCheck || !originalNamedCluster.getName().equals(result)) {
        // check that the name does not already exist
        try {
            NamedCluster fetched = namedClusterService.read(result, Spoon.getInstance().getMetaStore());
            if (fetched != null) {

                String title = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists.Title");
                String message = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists", result);
                String replaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.Replace");
                String doNotReplaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.DoNotReplace");
                MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING,
                        new String[] { replaceButton, doNotReplaceButton }, 0);

                // there already exists a cluster with the new name, ask the user
                if (RESULT_NO == dialog.open()) {
                    // do not exist dialog
                    return;
                }
            }
        } catch (MetaStoreException ignored) {
            // the lookup failed, the cluster does not exist, move on to dispose
        }
    }
    dispose();
}