Lotus Expeditor Toolkit, Version 6.2
Operating systems: Linux on x86, Windows


Implementing inline editing

You can create cells that are editable by users by implementing the ICellModifier and CellEditor classes in the TableViewer.

The ICellModifier interface indicates whether a cell can be changed, and if it can be, enables users to provide a value for the cell. The interface has the following methods:
  • public boolean canModify(Object arg0, String arg1) -- arg0 is the data of the row which contains the cell, arg1 is the column ID of parent column of the cell. The returned value tells table if value of this cell can be modified.
  • public Object getValue(Object arg0, String arg1) -- arg0 and arg1 has same meaning as above method. This method returns the value of specified cell.
  • public void modify(Object arg0, String arg1, Object arg2) -- arg0 is the table item which contains the cell, and arg1 is the column id of parent column of the cell, arg2 is the value to be changed to.
The CellEditor class is a JFace class that you must implement to keep the table JFace-compatible.
To implement inline editing, perform the following steps:
  1. Implement the ICellModifier interface for the table viewer.
  2. Call the setCellModifier method.
  3. Use the setCellEditor() method to add an inline editor to the cell.
  4. To disable an inline editor, pass a null parameter to the setCellEditor() method.
_viewer.setCellModifier(new ICellModifier(){
		public boolean canModify(Object arg0, String arg1) {
			return true;
		}
		public Object getValue(Object arg0, String arg1) {
			if(arg0 instanceof Mail){
				if(arg1.equalsIgnoreCase("ID_SUBJECT")){
					return ((Mail)arg0).getSubject();
				}
			}
			return null;
		}

		public void modify(Object arg0, String arg1, Object arg2) {
			System.out.println("Please modify it");
		}
	});

	CellEditor[] editors=new CellEditor[tableColCount];
	for(int k=0;k<editors.length;k++){
		editors[k]=null;
	}
	//disable the cell editor
	editors[1]=new TextCellEditor(_viewer.getTable().getBody());

	if(isEnableEditor)
		_viewer.setCellEditors(editors);
	else
		_viewer.setCellEditors(null);


Library | Support | Home | Education | Terms of use |

Last updated: October 21, 2008
© Copyright IBM Corporation 2006, 2008. All Rights Reserved.
This information center is built on Eclipse™ (http://www.eclipse.org)