Search in sources :

Example 76 with ErrorDialog

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

the class LDAPOutputDialog method ok.

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;
    }
    stepname = wStepname.getText();
    try {
        getInfo(input);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LDAPOutputDialog.ErrorParsingData.DialogTitle"), BaseMessages.getString(PKG, "LDAPOutputDialog.ErrorParsingData.DialogMessage"), e);
    }
    dispose();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 77 with ErrorDialog

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

the class XMLInputSaxDialog method get.

// 
private void get() {
    try {
        XMLInputSaxMeta meta = new XMLInputSaxMeta();
        getInfo(meta);
        // OK, let's try to walk through the complete tree
        List<XMLInputSaxField> fields = new ArrayList<XMLInputSaxField>();
        // Keep the list of positions
        String[] filePaths = meta.getFilePaths(transMeta);
        if (meta.getInputPosition().length == 0) {
            // error
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.NoElements.Message"));
            mb.setText(BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.NoElements.Title"));
            mb.open();
            return;
        }
        for (int f = 0; f < filePaths.length; f++) {
            XMLInputSaxFieldRetriever fieldRetreiver = new XMLInputSaxFieldRetriever(log, filePaths[f], meta);
            fields = fieldRetreiver.getFields();
            // add the values to the grid...
            for (int i = 0; i < fields.size(); i++) {
                XMLInputSaxField iF = fields.get(i);
                TableItem item = new TableItem(wFields.table, SWT.NONE);
                item.setText(1, iF.getName());
                item.setText(2, iF.getTypeDesc());
                item.setText(11, iF.getFieldPositionsCode(meta.getInputPosition().length));
            }
            wFields.removeEmptyRows();
            wFields.setRowNums();
            wFields.optWidth(true);
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorParsingInputData.Title"), BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorParsingInputData.Message"), e);
        System.out.println(e.getMessage());
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XMLInputSaxFieldRetriever(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxFieldRetriever) XMLInputSaxMeta(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxMeta) XMLInputSaxField(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxField) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 78 with ErrorDialog

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

the class XMLInputSaxDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the XML input step
        XMLInputSaxMeta oneMeta = new XMLInputSaxMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.EnterPreviewSize.Message"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            progressDialog.open();
            if (!progressDialog.isCancelled()) {
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()));
                prd.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorDisplayingPreviewData.Title"), BaseMessages.getString(PKG, "XMLInputSaxDialog.Dialog.ErrorDisplayingPreviewData.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) XMLInputSaxMeta(org.pentaho.di.trans.steps.xmlinputsax.XMLInputSaxMeta) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog)

Example 79 with ErrorDialog

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

the class SelectObjectDialog method open.

@SuppressWarnings("deprecation")
public String open() {
    Shell parent = getParent();
    dircolor = GUIResource.getInstance().getColorDirectory();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(shellText);
    int margin = Const.MARGIN;
    ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT);
    props.setLook(treeTb);
    wfilter = new ToolItem(treeTb, SWT.SEPARATOR);
    searchText = new Text(treeTb, SWT.SEARCH | SWT.CANCEL);
    searchText.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.FilterString.ToolTip"));
    wfilter.setControl(searchText);
    wfilter.setWidth(100);
    wbRegex = new ToolItem(treeTb, SWT.CHECK);
    wbRegex.setImage(GUIResource.getInstance().getImageRegexSmall());
    wbRegex.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.UseRegex"));
    goSearch = new ToolItem(treeTb, SWT.PUSH);
    goSearch.setImage(GUIResource.getInstance().getImageSearchSmall());
    goSearch.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.Run"));
    expandAll = new ToolItem(treeTb, SWT.PUSH);
    expandAll.setImage(GUIResource.getInstance().getImageExpandAll());
    collapseAll = new ToolItem(treeTb, SWT.PUSH);
    collapseAll.setImage(GUIResource.getInstance().getImageCollapseAll());
    fdexpandAll = new FormData();
    fdexpandAll.right = new FormAttachment(100, -margin);
    fdexpandAll.top = new FormAttachment(0, margin);
    treeTb.setLayoutData(fdexpandAll);
    // From step line
    wlTree = new Label(shell, SWT.NONE);
    wlTree.setText(lineText);
    props.setLook(wlTree);
    fdlTree = new FormData();
    fdlTree.left = new FormAttachment(0, 0);
    fdlTree.top = new FormAttachment(0, margin);
    wlTree.setLayoutData(fdlTree);
    wTree = new Tree(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    wTree.setHeaderVisible(true);
    props.setLook(wTree);
    // Add some columns to it as well...
    nameColumn = new TreeColumn(wTree, SWT.LEFT);
    nameColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Name"));
    nameColumn.setWidth(350);
    nameColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            setSort(0);
        }
    });
    // No sorting on the type column just yet.
    typeColumn = new TreeColumn(wTree, SWT.LEFT);
    typeColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Type"));
    typeColumn.setWidth(100);
    typeColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            setSort(1);
        }
    });
    userColumn = new TreeColumn(wTree, SWT.LEFT);
    userColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.User"));
    userColumn.setWidth(100);
    userColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            setSort(2);
        }
    });
    changedColumn = new TreeColumn(wTree, SWT.LEFT);
    changedColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Changed"));
    changedColumn.setWidth(120);
    changedColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            setSort(3);
        }
    });
    descriptionColumn = new TreeColumn(wTree, SWT.LEFT);
    descriptionColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Description"));
    descriptionColumn.setWidth(120);
    descriptionColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            setSort(4);
        }
    });
    props.setLook(wTree);
    fdTree = new FormData();
    fdTree.left = new FormAttachment(0, 0);
    fdTree.right = new FormAttachment(100, 0);
    fdTree.top = new FormAttachment(treeTb, margin);
    fdTree.bottom = new FormAttachment(100, -30);
    wTree.setLayoutData(fdTree);
    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wOK.setEnabled(false);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null);
    // Add listeners
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wTree.addSelectionListener(lsDef);
    wTree.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
                ok();
            }
        }
    });
    wTree.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (wTree.getSelection().length > 0) {
                wOK.setEnabled(!Boolean.TRUE.equals(wTree.getSelection()[0].getData("isFolder")));
            }
        }
    });
    expandAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            expandAllItems(wTree.getItems(), true);
        }
    });
    collapseAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            expandAllItems(wTree.getItems(), false);
        }
    });
    goSearch.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateFilter();
        }
    });
    searchText.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            updateFilter();
        }
    });
    // Detect [X] or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    try {
        if (rep instanceof RepositoryExtended) {
            RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep;
            directoryTree = repositoryExtended.loadRepositoryDirectoryTree("/", "*.kjb|*.ktr", -1, BooleanUtils.isTrue(repositoryExtended.getUserInfo().isAdmin()), true, false);
        } else {
            directoryTree = this.rep.loadRepositoryDirectoryTree();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectObjectDialog.Dialog.ErrorRefreshingDirectoryTree.Title"), BaseMessages.getString(PKG, "SelectObjectDialog.Dialog.ErrorRefreshingDirectoryTree.Message"), e);
    }
    // catch()
    getData();
    wTree.setFocus();
    BaseStepDialog.setSize(shell);
    shell.open();
    while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) {
            shell.getDisplay().sleep();
        }
    }
    return objectName;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) KettleException(org.pentaho.di.core.exception.KettleException) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) ToolItem(org.eclipse.swt.widgets.ToolItem) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 80 with ErrorDialog

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

the class PartitionsController method removePartition.

public void removePartition() {
    String partitionSchemaName = "";
    try {
        Collection<UIPartition> partitions = partitionsTable.getSelectedItems();
        if (partitions != null && !partitions.isEmpty()) {
            for (Object obj : partitions) {
                if (obj != null && obj instanceof UIPartition) {
                    UIPartition partition = (UIPartition) obj;
                    PartitionSchema partitionSchema = partition.getPartitionSchema();
                    partitionSchemaName = partitionSchema.getName();
                    // Make sure the partition to delete exists in the repository
                    ObjectId partitionId = repository.getPartitionSchemaID(partitionSchema.getName());
                    if (partitionId == null) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.DoesNotExists.Message", partitionSchemaName));
                        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"));
                        mb.open();
                    } else {
                        repository.deletePartitionSchema(partitionId);
                        if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
                            mainController.getSharedObjectSyncUtil().deletePartitionSchema(partitionSchema);
                        }
                    }
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.UnexpectedError.Message") + partitionSchemaName + "]", e);
        }
    } finally {
        refreshPartitions();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) UIPartition(org.pentaho.di.ui.repository.repositoryexplorer.model.UIPartition) MessageBox(org.eclipse.swt.widgets.MessageBox)

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