Search in sources :

Example 1 with StepFieldsDialog

use of org.pentaho.di.ui.core.dialog.StepFieldsDialog in project pentaho-kettle by pentaho.

the class TransGraph method inputOutputFields.

/**
 * Display the input- or outputfields for a step.
 *
 * @param stepMeta The step (it's metadata) to query
 * @param before   set to true if you want to have the fields going INTO the step, false if you want to see all the
 *                 fields that exit the step.
 */
private void inputOutputFields(StepMeta stepMeta, boolean before) {
    spoon.refreshGraph();
    transMeta.setRepository(spoon.rep);
    SearchFieldsProgressDialog op = new SearchFieldsProgressDialog(transMeta, stepMeta, before);
    boolean alreadyThrownError = false;
    try {
        final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        // Run something in the background to cancel active database queries, forecably if needed!
        Runnable run = new Runnable() {

            @Override
            public void run() {
                IProgressMonitor monitor = pmd.getProgressMonitor();
                while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
                    try {
                        Thread.sleep(250);
                    } catch (InterruptedException e) {
                    // Ignore
                    }
                }
                if (monitor.isCanceled()) {
                    try {
                        transMeta.cancelQueries();
                    } catch (Exception e) {
                    // Ignore
                    }
                }
            }
        };
        // Dump the cancel looker in the background!
        new Thread(run).start();
        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Title"), BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Message"), e);
        alreadyThrownError = true;
    } catch (InterruptedException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Title"), BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Message"), e);
        alreadyThrownError = true;
    }
    RowMetaInterface fields = op.getFields();
    if (fields != null && fields.size() > 0) {
        StepFieldsDialog sfd = new StepFieldsDialog(shell, transMeta, SWT.NONE, stepMeta.getName(), fields);
        String sn = (String) sfd.open();
        if (sn != null) {
            StepMeta esi = transMeta.findStep(sn);
            if (esi != null) {
                editStep(esi);
            }
        }
    } else {
        if (!alreadyThrownError) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
            mb.setMessage(BaseMessages.getString(PKG, "TransGraph.Dialog.CouldntFindFields.Message"));
            mb.setText(BaseMessages.getString(PKG, "TransGraph.Dialog.CouldntFindFields.Title"));
            mb.open();
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) StepFieldsDialog(org.pentaho.di.ui.core.dialog.StepFieldsDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageBox(org.eclipse.swt.widgets.MessageBox) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SearchFieldsProgressDialog(org.pentaho.di.ui.spoon.dialog.SearchFieldsProgressDialog)

Example 2 with StepFieldsDialog

use of org.pentaho.di.ui.core.dialog.StepFieldsDialog in project pentaho-kettle by pentaho.

the class XulDatabaseExplorerController method showLayout.

public void showLayout() {
    DatabaseMeta databaseMeta = model.getDatabaseMeta();
    String schemaTable = databaseMeta.getQuotedSchemaTableCombination(model.getSchema(), model.getTable());
    String theSql = databaseMeta.getSQLQueryFields(schemaTable);
    GetQueryFieldsProgressDialog theProgressDialog = new GetQueryFieldsProgressDialog(this.shell, databaseMeta, theSql);
    RowMetaInterface fields = theProgressDialog.open();
    StepFieldsDialog stepFieldsDialog = new StepFieldsDialog(shell, databaseMeta, SWT.NONE, schemaTable, fields);
    stepFieldsDialog.setShellText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.TableLayout.ShellText"));
    stepFieldsDialog.setOriginText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.TableLayout.OriginText"));
    stepFieldsDialog.setShowEditButton(false);
    stepFieldsDialog.open();
}
Also used : StepFieldsDialog(org.pentaho.di.ui.core.dialog.StepFieldsDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 StepFieldsDialog (org.pentaho.di.ui.core.dialog.StepFieldsDialog)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 KettleValueException (org.pentaho.di.core.exception.KettleValueException)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 SearchFieldsProgressDialog (org.pentaho.di.ui.spoon.dialog.SearchFieldsProgressDialog)1 XulException (org.pentaho.ui.xul.XulException)1