Search in sources :

Example 1 with BaseDialog

use of org.apache.hop.ui.core.dialog.BaseDialog in project hop by apache.

the class IGetFieldsCapableTransformDialog method getFields.

default void getFields(final TransformMetaType meta) {
    final String[] incomingFieldNames = getFieldNames(meta);
    final List<String> newFieldNames = getNewFieldNames(incomingFieldNames);
    if (newFieldNames != null && newFieldNames.size() > 0) {
        // we have new incoming fields
        final int nrNonEmptyFields = getFieldsTable().nrNonEmpty();
        // are any fields already populated in the fields table?
        if (nrNonEmptyFields > 0) {
            final FieldSelectionDialog fieldSelectDialog = new FieldSelectionDialog(this.getShell(), newFieldNames.size()) {

                @Override
                protected void ok() {
                    super.ok();
                    openGetFieldsSampleDataDialog(reloadAllFields);
                }
            };
            fieldSelectDialog.open();
        } else {
            // no fields are populated yet, go straight to "sample data" dialog
            openGetFieldsSampleDataDialog(true);
        }
    } else {
        // we have no new fields
        final BaseDialog errorDlg = new BaseMessageDialog(getShell(), BaseMessages.getString(PKG, "GetFieldsCapableTransformDialog.NoNewFields.Title"), BaseMessages.getString(PKG, "GetFieldsCapableTransformDialog.NoNewFields.Message"));
        // GetFieldsSampleDataDialog
        if (incomingFieldNames != null && incomingFieldNames.length > 0) {
            final Map<String, Listener> buttons = new HashMap();
            buttons.put(BaseMessages.getString(PKG, "System.Button.OK"), event -> {
                errorDlg.dispose();
                openGetFieldsSampleDataDialog(true);
            });
            errorDlg.setButtons(buttons);
        }
        errorDlg.open();
    }
}
Also used : BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) Listener(org.eclipse.swt.widgets.Listener) BaseMessageDialog(org.apache.hop.ui.core.dialog.BaseMessageDialog)

Aggregations

BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)1 BaseMessageDialog (org.apache.hop.ui.core.dialog.BaseMessageDialog)1 Listener (org.eclipse.swt.widgets.Listener)1