Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Custom Step Questions & TableView Documentation

  1. #1

    Question Custom Step Questions & TableView Documentation

    Hi all,

    Is there any JavaDoc available for the TableView control? I've looked around but can't find it in the hosted JavaDoc.

    Specifically, I'm trying to restrict actions within a TableView with 3 columns so that the user can only edit one (text type) of the columns. They shouldn't be able to add or remove rows as this would be taken care of by the interface. Is there a way I could set up a TableView with these restrictions or am I simply better off using the regular SWT Table?

    Which brings me to another question about how to programatically add rows to a TableView. I see an add method which takes a single string. Is this supposed to be a comma-delimited list of the values for each column in the row?

    How can I interface with parameters/arguments/variables passed to a PDI transformation? My step will require a username and password which I don't wish to save in a non-encrypted XML file or repository. I'd like to rather force the user to supply the password at runtime but I'm not certain whether to use parameters/arguments/variables and which interface I would use to access these variables.

    Thank you!
    Mike

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Hi Mike,

    There are fortunately a lot of code examples in the Kettle source code.
    The code in 4.0 for the logging tables shows how you can make certain columns and certain lines on certain columns (cells basically) read-only or even give them a different background color.

    From TransDialog.java...

    The following lines define the columns, their description, type, combo values, read-only or not, etc.

    Code:
    		ColumnInfo[] colinf=new ColumnInfo[] {
    			new ColumnInfo(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.FieldName"), ColumnInfo.COLUMN_TYPE_TEXT, false ), //$NON-NLS-1$
    			new ColumnInfo(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.StepName"), ColumnInfo.COLUMN_TYPE_CCOMBO, transMeta.getStepNames()), //$NON-NLS-1$
    			new ColumnInfo(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.Description"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), //$NON-NLS-1$
    		};
    The listener below allows you to specify if a field on a certain row is disabled or not.
    You can attach this to a certain column:

    Code:
    		FieldDisabledListener disabledListener = new FieldDisabledListener() {
    			
    			public boolean isFieldDisabled(int rowNr) {
    				if (rowNr>=0 && rowNr<fields.size()) {
    					LogTableField field = fields.get(rowNr);
    					return !field.isSubjectAllowed();
    				} else {
    					return true;
    				}
    			}
    		};
    		
    		colinf[1].setDisabledListener(disabledListener);
    Next you create the TableView itself. Mostly you simply supply the columns:

    Code:
    	
    		wOptionFields=new TableView(transMeta, wLogOptionsComposite, 
    						      SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.CHECK, // add a check to the left... 
    						      colinf, 
    						      nrRows,  
    						      true,
    						      lsMod,
    						      props
    						      );      
    		
    		wOptionFields.setSortable(false);
    The rows (TableItem) can be made checkable too as shown below.
    Background colors can be set, etc.

    Code:
    		
    		for (int i=0;i<fields.size();i++) {
    			LogTableField field = fields.get(i);
    			TableItem item = wOptionFields.table.getItem(i);
    			item.setChecked(field.isEnabled());
    			item.setText(new String[] { "", Const.NVL(field.getFieldName(), ""), field.getSubject()==null?"":field.getSubject().toString(), Const.NVL(field.getDescription(), "") });
    			
    			// Exceptions!!!
    			//
    			if (disabledListener.isFieldDisabled(i)) {
    				item.setBackground(2, GUIResource.getInstance().getColorLightGray());
    			}
    		}
    For more information on how to create extra lines, remove them, etc, please see the SWT Table class for which the Kettle TableView is a wrapper object.

    http://www.eclipse.org/swt/snippets/

    Good luck,
    Matt

  3. #3

    Question

    Thanks Matt - fast and helpful as usual .

    Any thoughts in regards to my question regarding storage of password information and using arguments instead? I'm unfamiliar with methods to access any arguments/variables/parameters that may have been passed at the beginning of the step.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.