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.di.ui.trans.step.BaseStepXulDialog.java

License:Apache License

/**
 * Gets unused fields from previous steps and inserts them as rows into a table view.
 *
 * @param row/*from  ww  w .  j a  v a 2 s .co  m*/
 *          the input fields
 * @param tableView
 *          the table view to modify
 * @param keyColumn
 *          the column in the table view to match with the names of the fields, checks for existance if >0
 * @param nameColumn
 *          the column numbers in which the name should end up in
 * @param dataTypeColumn
 *          the target column numbers in which the data type should end up in
 * @param lengthColumn
 *          the length column where the length should end up in (if >0)
 * @param precisionColumn
 *          the length column where the precision should end up in (if >0)
 * @param listener
 *          A listener that you can use to do custom modifications to the inserted table item, based on a value from
 *          the provided row
 */
public static final void getFieldsFromPrevious(RowMetaInterface row, XulTree tableView, int keyColumn,
        int[] nameColumn, int[] dataTypeColumn, int lengthColumn, int precisionColumn,
        TableItemInsertListener listener) {
    if (row == null || row.size() == 0) {
        return; // nothing to do
    }

    Table table = ((TableViewer) tableView.getManagedObject()).getTable();

    // get a list of all the non-empty keys (names)
    //
    List<String> keys = new ArrayList<String>();
    for (int i = 0; i < table.getItemCount(); i++) {
        TableItem tableItem = table.getItem(i);
        String key = tableItem.getText(keyColumn);
        if (!Utils.isEmpty(key) && keys.indexOf(key) < 0) {
            keys.add(key);
        }
    }

    int choice = 0;

    if (keys.size() > 0) {
        // Ask what we should do with the existing data in the step.
        //
        Shell shell = ((TableViewer) tableView.getManagedObject()).getTable().getShell();
        MessageDialog md = new MessageDialog(shell,
                BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), // "Warning!"
                null,
                BaseMessages.getString(
                        PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size()),
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "BaseStepDialog.AddNew"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Add"),
                        BaseMessages.getString(PKG, "BaseStepDialog.ClearAndAdd"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Cancel"), },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open();
        choice = idx & 0xFF;
    }

    if (choice == 3 || choice == 255) {
        return; // Cancel clicked
    }

    if (choice == 2) {
        tableView.getRootChildren().removeAll();
    }

    for (int i = 0; i < row.size(); i++) {
        ValueMetaInterface v = row.getValueMeta(i);

        boolean add = true;

        if (choice == 0) { // hang on, see if it's not yet in the table view

            if (keys.indexOf(v.getName()) >= 0) {
                add = false;
            }
        }

        if (add) {
            XulTreeRow tRow = tableView.getRootChildren().addNewRow();

            for (int c = 0; c < nameColumn.length; c++) {
                tRow.addCellText(nameColumn[c], Const.NVL(v.getName(), ""));
            }
            if (dataTypeColumn != null) {
                for (int c = 0; c < dataTypeColumn.length; c++) {
                    tRow.addCellText(dataTypeColumn[c], v.getTypeDesc());
                }
            }
            if (lengthColumn > 0) {
                if (v.getLength() >= 0) {
                    tRow.addCellText(lengthColumn, Integer.toString(v.getLength()));
                }
            }
            if (precisionColumn > 0) {
                if (v.getPrecision() >= 0) {
                    tRow.addCellText(precisionColumn, Integer.toString(v.getPrecision()));
                }
            }

            if (listener != null) {
                if (!listener.tableItemInserted(
                        table.getItem(tRow.getParent().getParent().getChildNodes().indexOf(tRow.getParent())),
                        v)) {
                    tRow.getParent().getParent().removeChild(tRow.getParent());
                }
            }
        }
    }
    // tableView.removeEmptyRows();
    // tableView.setRowNums();
    // tableView.optWidth(true);
}

From source file:org.pentaho.di.ui.trans.step.BaseStepXulDialog.java

License:Apache License

public static void getFieldsFromPrevious(RowMetaInterface row, XulTree tableView, List<Object> fields,
        StepTableDataObject field, TableItemInsertXulListener listener) {
    if (row == null || row.size() == 0) {
        return; // nothing to do
    }/*from   w  w w. j a  v  a2 s.  co  m*/

    // get a list of all the non-empty keys (names)
    //
    List<String> keys = new ArrayList<String>();
    for (Object entry : fields) {
        keys.add(((StepTableDataObject) entry).getName());
    }

    int choice = 0;

    if (keys.size() > 0) {
        // Ask what we should do with the existing data in the step.
        //
        Shell shell = ((TableViewer) tableView.getManagedObject()).getTable().getShell();
        MessageDialog md = new MessageDialog(shell,
                BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), // "Warning!"
                null,
                BaseMessages.getString(
                        PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size()),
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "BaseStepDialog.AddNew"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Add"),
                        BaseMessages.getString(PKG, "BaseStepDialog.ClearAndAdd"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Cancel"), },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open();
        choice = idx & 0xFF;
    }

    if (choice == 3 || choice == 255) {
        return; // Cancel clicked
    }

    if (choice == 2) {
        fields.clear();
    }

    for (int i = 0; i < row.size(); i++) {
        ValueMetaInterface v = row.getValueMeta(i);

        if (choice == 0) { // hang on, see if it's not yet in the table view

            if (keys.indexOf(v.getName()) >= 0) {
                continue;
            }
        }

        if (listener != null && !listener.tableItemInsertedFor(v)) {
            continue;
        }

        StepTableDataObject newField = field.createNew(v);
        fields.add(newField);
    }
}

From source file:org.pentaho.di.ui.trans.steps.analyticquery.AnalyticQueryDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;/*w  w w . ja  va2  s  .c  o  m*/
    }

    int sizegroup = wGroup.nrNonEmpty();
    int nrfields = wAgg.nrNonEmpty();

    input.allocate(sizegroup, nrfields);

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < sizegroup; i++) {
        TableItem item = wGroup.getNonEmpty(i);
        input.getGroupField()[i] = item.getText(1);
    }

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrfields; i++) {
        TableItem item = wAgg.getNonEmpty(i);
        input.getAggregateField()[i] = item.getText(1);
        input.getSubjectField()[i] = item.getText(2);
        input.getAggregateType()[i] = AnalyticQueryMeta.getType(item.getText(3));
        input.getValueField()[i] = Const.toInt(item.getText(4), 1);
    }

    stepname = wStepname.getText();

    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.DialogTitle"), null,
                BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.DialogMessage", Const.CR)
                        + Const.CR,
                MessageDialog.WARNING,
                new String[] {
                        BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.Option1") },
                0, BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.denormaliser.DenormaliserDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;//from   w  w w  .  j  av  a  2s. co  m
    }

    int sizegroup = wGroup.nrNonEmpty();
    int nrfields = wTarget.nrNonEmpty();

    input.setKeyField(wKeyField.getText());

    input.allocate(sizegroup, nrfields);

    for (int i = 0; i < sizegroup; i++) {
        TableItem item = wGroup.getNonEmpty(i);
        //CHECKSTYLE:Indentation:OFF
        input.getGroupField()[i] = item.getText(1);
    }

    for (int i = 0; i < nrfields; i++) {
        DenormaliserTargetField field = new DenormaliserTargetField();

        TableItem item = wTarget.getNonEmpty(i);
        field.setTargetName(item.getText(1));
        field.setFieldName(item.getText(2));
        field.setKeyValue(item.getText(3));
        field.setTargetType(item.getText(4));
        field.setTargetFormat(item.getText(5));
        field.setTargetLength(Const.toInt(item.getText(6), -1));
        field.setTargetPrecision(Const.toInt(item.getText(7), -1));
        field.setTargetCurrencySymbol(item.getText(8));
        field.setTargetDecimalSymbol(item.getText(9));
        field.setTargetGroupingSymbol(item.getText(10));
        field.setTargetNullString(item.getText(11));
        field.setTargetAggregationType(item.getText(12));

        //CHECKSTYLE:Indentation:OFF
        input.getDenormaliserTargetField()[i] = field;
    }

    stepname = wStepname.getText();

    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "DenormaliserDialog.Unpivot.DialogTitle"), null,
                BaseMessages.getString(PKG, "DenormaliserDialog.Unpivot.DialogMessage", Const.CR, Const.CR),
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "DenormaliserDialog.WarningMessage.Option.1") }, 0,
                BaseMessages.getString(PKG, "DenormaliserDialog.WarningMessage.Option.2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.enhanced.jsonoutput.JsonOutputDialog.java

License:Apache License

public final void getFieldsFromPrevious(RowMetaInterface row, TableView tableView, int keyColumn,
        int[] nameColumn, TableItemInsertListener listener) {
    if (row == null || row.size() == 0) {
        return; // nothing to do
    }/*  w  w  w. j a  va 2  s . c o  m*/

    Table table = tableView.table;

    // get a list of all the non-empty keys (names)
    //
    List<String> keys = new ArrayList<String>();
    for (int i = 0; i < table.getItemCount(); i++) {
        TableItem tableItem = table.getItem(i);
        String key = tableItem.getText(keyColumn);
        if (!Const.isEmpty(key) && keys.indexOf(key) < 0) {
            keys.add(key);
        }
    }

    int choice = 0;

    if (keys.size() > 0) {
        // Ask what we should do with the existing data in the step.
        //
        MessageDialog md = new MessageDialog(tableView.getShell(),
                BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), // "Warning!"
                null,
                BaseMessages.getString(
                        PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size()),
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "BaseStepDialog.AddNew"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Add"),
                        BaseMessages.getString(PKG, "BaseStepDialog.ClearAndAdd"),
                        BaseMessages.getString(PKG, "BaseStepDialog.Cancel"), },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open();
        choice = idx & 0xFF;
    }

    if (choice == 3 || choice == 255) {
        return; // Cancel clicked
    }

    if (choice == 2) {
        tableView.clearAll(false);
    }

    for (int i = 0; i < row.size(); i++) {
        ValueMetaInterface v = row.getValueMeta(i);

        boolean add = true;

        if (choice == 0) { // hang on, see if it's not yet in the table view

            if (keys.indexOf(v.getName()) >= 0) {
                add = false;
            }
        }

        if (add) {
            TableItem tableItem = new TableItem(table, SWT.NONE);

            for (int c = 0; c < nameColumn.length; c++) {
                tableItem.setText(nameColumn[c], Const.NVL(v.getName(), ""));
            }
            if (listener != null) {
                if (!listener.tableItemInserted(tableItem, v)) {
                    tableItem.dispose(); // remove it again
                }
            }
        }
    }
    tableView.removeEmptyRows();
    tableView.setRowNums();
    tableView.optWidth(true);
}

From source file:org.pentaho.di.ui.trans.steps.fieldschangesequence.FieldsChangeSequenceDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;/*from   w  w  w.  j  av  a  2s  .  c  o  m*/
    }
    stepname = wStepname.getText(); // return value

    input.setStart(wStart.getText());
    input.setIncrement(wIncrement.getText());
    input.setResultFieldName(wResult.getText());

    int nrfields = wFields.nrNonEmpty();
    input.allocate(nrfields);
    for (int i = 0; i < nrfields; i++) {
        TableItem ti = wFields.getNonEmpty(i);
        //CHECKSTYLE:Indentation:OFF
        input.getFieldName()[i] = ti.getText(1);
    }

    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogTitle"), null,
                BaseMessages.getString(PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogMessage", Const.CR)
                        + Const.CR,
                MessageDialog.WARNING,
                new String[] {
                        BaseMessages.getString(PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option1") },
                0, BaseMessages.getString(PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.groupby.GroupByDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;//from   w w w . j  a  v  a  2  s  . co m
    }

    int sizegroup = wGroup.nrNonEmpty();
    int nrfields = wAgg.nrNonEmpty();
    input.setPrefix(wPrefix.getText());
    input.setDirectory(wSortDir.getText());

    input.setLineNrInGroupField(wLineNrField.getText());
    input.setAlwaysGivingBackOneRow(wAlwaysAddResult.getSelection());
    input.setPassAllRows(wAllRows.getSelection());

    input.allocate(sizegroup, nrfields);

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < sizegroup; i++) {
        TableItem item = wGroup.getNonEmpty(i);
        input.getGroupField()[i] = item.getText(1);
    }

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrfields; i++) {
        TableItem item = wAgg.getNonEmpty(i);
        input.getAggregateField()[i] = item.getText(1);
        input.getSubjectField()[i] = item.getText(2);
        input.getAggregateType()[i] = GroupByMeta.getType(item.getText(3));
        input.getValueField()[i] = item.getText(4);
    }

    stepname = wStepname.getText();

    if (sizegroup > 0 && "Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "GroupByDialog.GroupByWarningDialog.DialogTitle"), null,
                BaseMessages.getString(PKG, "GroupByDialog.GroupByWarningDialog.DialogMessage", Const.CR)
                        + Const.CR,
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "GroupByDialog.GroupByWarningDialog.Option1") }, 0,
                BaseMessages.getString(PKG, "GroupByDialog.GroupByWarningDialog.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.mergejoin.MergeJoinDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;/*from ww w .  j a v a 2s .c o m*/
    }

    getMeta(input);

    // Show a warning (optional)
    //
    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "MergeJoinDialog.InputNeedSort.DialogTitle"), null,
                BaseMessages.getString(PKG, "MergeJoinDialog.InputNeedSort.DialogMessage", Const.CR) + Const.CR,
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "MergeJoinDialog.InputNeedSort.Option1") }, 0,
                BaseMessages.getString(PKG, "MergeJoinDialog.InputNeedSort.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    stepname = wStepname.getText(); // return value

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.mergerows.MergeRowsDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;/*ww w  .  j  av  a2 s.  c  o m*/
    }

    List<StreamInterface> infoStreams = input.getStepIOMeta().getInfoStreams();
    infoStreams.get(0).setStepMeta(transMeta.findStep(wReference.getText()));
    infoStreams.get(1).setStepMeta(transMeta.findStep(wCompare.getText()));
    input.setFlagField(wFlagfield.getText());

    int nrKeys = wKeys.nrNonEmpty();
    int nrValues = wValues.nrNonEmpty();

    input.allocate(nrKeys, nrValues);

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrKeys; i++) {
        TableItem item = wKeys.getNonEmpty(i);
        input.getKeyFields()[i] = item.getText(1);
    }

    //CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrValues; i++) {
        TableItem item = wValues.getNonEmpty(i);
        input.getValueFields()[i] = item.getText(1);
    }

    stepname = wStepname.getText(); // return value

    // PDI-13509 Fix
    if (nrKeys > 0 && "Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogTitle"), null,
                BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogMessage", Const.CR)
                        + Const.CR,
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option1") },
                0, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }

    dispose();
}

From source file:org.pentaho.di.ui.trans.steps.multimerge.MultiMergeJoinDialog.java

License:Apache License

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;/*from w  w  w.j a v  a  2 s . c om*/
    }
    getMeta(joinMeta);
    // Show a warning (optional)
    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle"), null,
                BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR)
                        + Const.CR,
                MessageDialog.WARNING,
                new String[] { BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option1") }, 0,
                BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option2"),
                "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }
    stepname = wStepname.getText(); // return value
    dispose();
}