Search in sources :

Example 71 with ErrorDialog

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

the class MappingDialog method getByReferenceData.

private void getByReferenceData(ObjectId transObjectId) {
    try {
        if (repository == null) {
            throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.NotConnectedToRepository.Message"));
        }
        RepositoryObject transInf = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
        String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
        String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
        wPath.setText(fullPath);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MappingDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "MappingDialog.Exception.UnableToReferenceObjectId.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 72 with ErrorDialog

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

the class MappingDialog method selectFileTrans.

private void selectFileTrans() {
    String curFile = transMeta.environmentSubstitute(wPath.getText());
    FileObject root = null;
    String parentFolder = null;
    try {
        parentFolder = KettleVFS.getFileObject(transMeta.environmentSubstitute(transMeta.getFilename())).getParent().toString();
    } catch (Exception e) {
    // Take no action
    }
    try {
        root = KettleVFS.getFileObject(curFile != null ? curFile : Const.getUserHomeDirectory());
        VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog(root.getParent(), root);
        FileObject file = vfsFileChooser.open(shell, null, Const.STRING_TRANS_FILTER_EXT, Const.getTransformationFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
        if (file == null) {
            return;
        }
        String fileName = file.getName().toString();
        if (fileName != null) {
            loadFileTrans(fileName);
            if (parentFolder != null && fileName.startsWith(parentFolder)) {
                fileName = fileName.replace(parentFolder, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}");
            }
            wPath.setText(fileName);
            specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
        }
    } catch (IOException | KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MappingDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "MappingDialog.ErrorLoadingTransformation.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) VfsFileChooserDialog(org.pentaho.vfs.ui.VfsFileChooserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 73 with ErrorDialog

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

the class IngresVectorwiseLoaderDialog method generateMappings.

/**
 * Reads in the fields from the previous steps and from the ONE next step and opens an EnterMappingDialog with this
 * information. After the user did the mapping, those information is put into the Select/Rename table.
 */
private void generateMappings() {
    // Determine the source and target fields...
    // 
    RowMetaInterface sourceFields;
    RowMetaInterface targetFields;
    try {
        sourceFields = transMeta.getPrevStepFields(stepMeta);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    // refresh data
    input.setDatabaseMeta(transMeta.findDatabase(serverConnection.getText()));
    input.setTablename(transMeta.environmentSubstitute(wTable.getText()));
    StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
    try {
        targetFields = stepMetaInterface.getRequiredFields(transMeta);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        ValueMetaInterface value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName() + EnterMappingDialog.STRING_ORIGIN_SEPARATOR + value.getOrigin() + ")";
    }
    // Create the existing mapping list...
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<SourceToTargetMapping>();
    StringBuilder missingSourceFields = new StringBuilder();
    StringBuilder missingTargetFields = new StringBuilder();
    int nrFields = wFields.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wFields.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR + "   " + source + " --> " + target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR + "   " + source + " --> " + target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.SomeFieldsNotFoundTitle"), message);
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(IngresVectorwiseLoaderDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wFields.table.removeAll();
        wFields.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wFields.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
        }
        wFields.setRowNums();
        wFields.optWidth(true);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) EnterMappingDialog(org.pentaho.di.ui.core.dialog.EnterMappingDialog) TableItem(org.eclipse.swt.widgets.TableItem) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) SourceToTargetMapping(org.pentaho.di.core.SourceToTargetMapping)

Example 74 with ErrorDialog

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

the class JoinRowsDialog method open.

public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();
    backupCondition = (Condition) condition.clone();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);
    // Connection line
    wlSortDir = new Label(shell, SWT.RIGHT);
    wlSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempDir.Label"));
    props.setLook(wlSortDir);
    fdlSortDir = new FormData();
    fdlSortDir.left = new FormAttachment(0, 0);
    fdlSortDir.right = new FormAttachment(middle, -margin);
    fdlSortDir.top = new FormAttachment(wStepname, margin);
    wlSortDir.setLayoutData(fdlSortDir);
    wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSortDir);
    wbSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Browse.Button"));
    fdbSortDir = new FormData();
    fdbSortDir.right = new FormAttachment(100, 0);
    fdbSortDir.top = new FormAttachment(wStepname, margin);
    wbSortDir.setLayoutData(fdbSortDir);
    wSortDir = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Temp.Label"));
    props.setLook(wSortDir);
    wSortDir.addModifyListener(lsMod);
    fdSortDir = new FormData();
    fdSortDir.left = new FormAttachment(middle, 0);
    fdSortDir.top = new FormAttachment(wStepname, margin);
    fdSortDir.right = new FormAttachment(wbSortDir, -margin);
    wSortDir.setLayoutData(fdSortDir);
    wbSortDir.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
            dd.setFilterPath(wSortDir.getText());
            String dir = dd.open();
            if (dir != null) {
                wSortDir.setText(dir);
            }
        }
    });
    // Whenever something changes, set the tooltip to the expanded version:
    wSortDir.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wSortDir.setToolTipText(transMeta.environmentSubstitute(wSortDir.getText()));
        }
    });
    // Table line...
    wlPrefix = new Label(shell, SWT.RIGHT);
    wlPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempFilePrefix.Label"));
    props.setLook(wlPrefix);
    fdlPrefix = new FormData();
    fdlPrefix.left = new FormAttachment(0, 0);
    fdlPrefix.right = new FormAttachment(middle, -margin);
    fdlPrefix.top = new FormAttachment(wbSortDir, margin * 2);
    wlPrefix.setLayoutData(fdlPrefix);
    wPrefix = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPrefix);
    wPrefix.addModifyListener(lsMod);
    fdPrefix = new FormData();
    fdPrefix.left = new FormAttachment(middle, 0);
    fdPrefix.top = new FormAttachment(wbSortDir, margin * 2);
    fdPrefix.right = new FormAttachment(100, 0);
    wPrefix.setLayoutData(fdPrefix);
    wPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Prefix.Label"));
    // Cache size...
    wlCache = new Label(shell, SWT.RIGHT);
    wlCache.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Cache.Label"));
    props.setLook(wlCache);
    fdlCache = new FormData();
    fdlCache.left = new FormAttachment(0, 0);
    fdlCache.right = new FormAttachment(middle, -margin);
    fdlCache.top = new FormAttachment(wPrefix, margin * 2);
    wlCache.setLayoutData(fdlCache);
    wCache = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCache);
    wCache.addModifyListener(lsMod);
    fdCache = new FormData();
    fdCache.left = new FormAttachment(middle, 0);
    fdCache.top = new FormAttachment(wPrefix, margin * 2);
    fdCache.right = new FormAttachment(100, 0);
    wCache.setLayoutData(fdCache);
    // Read date from...
    wlMainStep = new Label(shell, SWT.RIGHT);
    wlMainStep.setText(BaseMessages.getString(PKG, "JoinRowsDialog.MainStep.Label"));
    props.setLook(wlMainStep);
    fdlMainStep = new FormData();
    fdlMainStep.left = new FormAttachment(0, 0);
    fdlMainStep.right = new FormAttachment(middle, -margin);
    fdlMainStep.top = new FormAttachment(wCache, margin);
    wlMainStep.setLayoutData(fdlMainStep);
    wMainStep = new CCombo(shell, SWT.BORDER);
    props.setLook(wMainStep);
    List<StepMeta> prevSteps = transMeta.findPreviousSteps(transMeta.findStep(stepname));
    for (StepMeta stepMeta : prevSteps) {
        wMainStep.add(stepMeta.getName());
    }
    wMainStep.addModifyListener(lsMod);
    fdMainStep = new FormData();
    fdMainStep.left = new FormAttachment(middle, 0);
    fdMainStep.top = new FormAttachment(wCache, margin);
    fdMainStep.right = new FormAttachment(100, 0);
    wMainStep.setLayoutData(fdMainStep);
    // Condition widget...
    wlCondition = new Label(shell, SWT.NONE);
    wlCondition.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Condition.Label"));
    props.setLook(wlCondition);
    fdlCondition = new FormData();
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.top = new FormAttachment(wMainStep, margin);
    wlCondition.setLayoutData(fdlCondition);
    RowMetaInterface inputfields = null;
    try {
        inputfields = transMeta.getPrevStepFields(stepname);
    } catch (KettleException ke) {
        inputfields = new RowMeta();
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogMessage"), ke);
    }
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
    wCondition = new ConditionEditor(shell, SWT.BORDER, condition, inputfields);
    fdCondition = new FormData();
    fdCondition.left = new FormAttachment(0, 0);
    fdCondition.top = new FormAttachment(wlCondition, margin);
    fdCondition.right = new FormAttachment(100, 0);
    fdCondition.bottom = new FormAttachment(wOK, -2 * margin);
    wCondition.setLayoutData(fdCondition);
    wCondition.addModifyListener(lsMod);
    // Add listeners
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    wSortDir.addSelectionListener(lsDef);
    wPrefix.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) RowMeta(org.pentaho.di.core.row.RowMeta) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ConditionEditor(org.pentaho.di.ui.core.widget.ConditionEditor) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) TextVar(org.pentaho.di.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 75 with ErrorDialog

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

the class MonetDBBulkLoaderDialog method getUpdate.

/*
   * Runs when the "Get Fields" button is pressed on the Output Fields dialog tab.
   */
private void getUpdate() {
    try {
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            TableItemInsertListener listener = new TableItemInsertListener() {

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    if (v.getType() == ValueMetaInterface.TYPE_DATE) {
                        // The default is : format is OK for dates, see if this sticks later on...
                        // 
                        tableItem.setText(3, "Y");
                    } else {
                        // default is OK too...
                        tableItem.setText(3, "Y");
                    }
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)527 KettleException (org.pentaho.di.core.exception.KettleException)440 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)178 MessageBox (org.eclipse.swt.widgets.MessageBox)118 TableItem (org.eclipse.swt.widgets.TableItem)97 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)76 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)63 TransMeta (org.pentaho.di.trans.TransMeta)48 Shell (org.eclipse.swt.widgets.Shell)46 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)44 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)44 ArrayList (java.util.ArrayList)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)39 StepMeta (org.pentaho.di.trans.step.StepMeta)38 FormData (org.eclipse.swt.layout.FormData)37 FormLayout (org.eclipse.swt.layout.FormLayout)37