Search in sources :

Example 6 with XulTreeRow

use of org.pentaho.ui.xul.containers.XulTreeRow in project pentaho-kettle by pentaho.

the class XulPreviewRowsController method createPreviewRows.

private void createPreviewRows() {
    GetPreviewTableProgressDialog theProgressDialog = new GetPreviewTableProgressDialog(this.shell, this.databaseMeta, this.schema, this.table, this.limit);
    List<Object[]> thePreviewData = theProgressDialog.open();
    // Adds table rows.
    Object[] theObj = null;
    XulTreeRow theRow = null;
    Object theValue = null;
    SwtTreeCell theCell = null;
    int theRowCount = 0;
    XulTree thePreviewTable = (XulTree) super.document.getElementById("table_data");
    thePreviewTable.getRootChildren().removeAll();
    Iterator<Object[]> theItr = thePreviewData.iterator();
    while (theItr.hasNext()) {
        theObj = theItr.next();
        theRow = thePreviewTable.getRootChildren().addNewRow();
        theRowCount++;
        for (int i = 0; i < theObj.length; i++) {
            theValue = theObj[i];
            theCell = new SwtTreeCell(null);
            theCell.setLabel(theValue == null ? "" : theValue.toString());
            theRow.addCell(theCell);
        }
    }
    // Adds table columns.
    SwtTreeCol theColumn = null;
    String[] theFieldNames = theProgressDialog.getRowMeta().getFieldNames();
    SwtTreeCols theColumns = new SwtTreeCols(null, thePreviewTable, null, null);
    for (int i = 0; i < theFieldNames.length; i++) {
        theColumn = new SwtTreeCol(null, null, null, null);
        theColumn.setWidth(100);
        theColumn.setLabel(theFieldNames[i]);
        theColumns.addColumn(theColumn);
    }
    thePreviewTable.setColumns(theColumns);
    thePreviewTable.update();
    setRowCount("Rows of step: " + this.table + " (" + theRowCount + " rows)");
}
Also used : XulTree(org.pentaho.ui.xul.containers.XulTree) SwtTreeCol(org.pentaho.ui.xul.swt.tags.SwtTreeCol) SwtTreeCell(org.pentaho.ui.xul.swt.tags.SwtTreeCell) XulTreeRow(org.pentaho.ui.xul.containers.XulTreeRow) SwtTreeCols(org.pentaho.ui.xul.swt.tags.SwtTreeCols)

Example 7 with XulTreeRow

use of org.pentaho.ui.xul.containers.XulTreeRow in project pentaho-kettle by pentaho.

the class BaseStepXulDialog method getFieldsFromPrevious.

/**
 * Gets unused fields from previous steps and inserts them as rows into a table view.
 *
 * @param row
 *          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) {
        // nothing to do
        return;
    }
    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, // "Warning!"
        BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), 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) {
        // Cancel clicked
        return;
    }
    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) {
            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);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) XulTreeRow(org.pentaho.ui.xul.containers.XulTreeRow) TableViewer(org.eclipse.jface.viewers.TableViewer) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 8 with XulTreeRow

use of org.pentaho.ui.xul.containers.XulTreeRow in project data-access by pentaho.

the class StageDataStep method deselectAll.

@Bindable
public void deselectAll() {
    // $NON-NLS-1$
    XulTree tree = (XulTree) document.getElementById("csvModelDataTable");
    for (XulComponent component : tree.getRootChildren().getChildNodes()) {
        XulTreeItem item = (XulTreeItem) component;
        for (XulComponent childComp : item.getChildNodes()) {
            XulTreeRow row = (XulTreeRow) childComp;
            XulTreeCell cell = row.getCell(0);
            cell.setValue(false);
        }
    }
    datasourceModel.getModelInfo().validate();
}
Also used : XulTreeItem(org.pentaho.ui.xul.containers.XulTreeItem) XulTreeCell(org.pentaho.ui.xul.components.XulTreeCell) XulTree(org.pentaho.ui.xul.containers.XulTree) XulTreeRow(org.pentaho.ui.xul.containers.XulTreeRow) XulComponent(org.pentaho.ui.xul.XulComponent) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 9 with XulTreeRow

use of org.pentaho.ui.xul.containers.XulTreeRow in project data-access by pentaho.

the class StageDataStep method selectAll.

@Bindable
public void selectAll() {
    // $NON-NLS-1$
    XulTree tree = (XulTree) document.getElementById("csvModelDataTable");
    for (XulComponent component : tree.getRootChildren().getChildNodes()) {
        XulTreeItem item = (XulTreeItem) component;
        for (XulComponent childComp : item.getChildNodes()) {
            XulTreeRow row = (XulTreeRow) childComp;
            XulTreeCell cell = row.getCell(0);
            cell.setValue(true);
        }
    }
    datasourceModel.getModelInfo().validate();
}
Also used : XulTreeItem(org.pentaho.ui.xul.containers.XulTreeItem) XulTreeCell(org.pentaho.ui.xul.components.XulTreeCell) XulTree(org.pentaho.ui.xul.containers.XulTree) XulTreeRow(org.pentaho.ui.xul.containers.XulTreeRow) XulComponent(org.pentaho.ui.xul.XulComponent) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

XulTreeRow (org.pentaho.ui.xul.containers.XulTreeRow)9 XulTree (org.pentaho.ui.xul.containers.XulTree)3 XulComponent (org.pentaho.ui.xul.XulComponent)2 XulTreeCell (org.pentaho.ui.xul.components.XulTreeCell)2 XulTreeItem (org.pentaho.ui.xul.containers.XulTreeItem)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)2 ArrayList (java.util.ArrayList)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Shell (org.eclipse.swt.widgets.Shell)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 DatabaseConnectionPoolParameter (org.pentaho.di.core.database.DatabaseConnectionPoolParameter)1 PartitionDatabaseMeta (org.pentaho.di.core.database.PartitionDatabaseMeta)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 SwtTreeCell (org.pentaho.ui.xul.swt.tags.SwtTreeCell)1 SwtTreeCol (org.pentaho.ui.xul.swt.tags.SwtTreeCol)1 SwtTreeCols (org.pentaho.ui.xul.swt.tags.SwtTreeCols)1