Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] Overrriding default behaviors

>>>> I would be interested in this code too.  If you don't mind, I'd also
like to make it available anyone for download.  Of >>>> course, I would do
whatever you felt reasonable to acknowledge your work as the original
author.

I'm actually not really ready to publish this. It's not packaged,
documented, or thoroughly tested, even though it has worked fine up till
now. But then again, I release it for the ones who are interested and don't
mind the rough edges of something which is not yet in its final stages.

It's actually somewhat part of my swtmodelartist project. Swtmodelartist is
a commandline GUI builder, for which I intend to make a GUI as well. But
now, it operates as a commandline utility only. From an swtmodel file, it
generates java classes. You must need a text editor, such as notepad, to
edit the swtmodel file, but I'll start working on a GUI to create such file,
as soon as I have time.

Hope this helps.

Greetings
Erik

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is licensed under the same license as SWT.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
/**
 * This grid embeds a Text and CCombo control and triggers events on.
 *
 * @author  Erik Poupaert, February 2003, Brussels, Belgium
 */
public class ATable extends Table implements TraverseListener
{
	//===========================================================
	//CONSTANTS
	//===========================================================
	protected static int COL_SELECTOR=0;

	protected static int CONTROL_TEXT=1;
	protected static int CONTROL_COMBO=2;

	protected static String IMG_NEW_LINE="GRID_NEW_LINE.bmp";
	protected static String IMG_NORMAL="GRID_NORMAL.bmp";
	protected static String IMG_EDITING="GRID_EDITING.bmp";
	protected static String IMG_HIGHLIGHT="GRID_HIGHLIGHT.bmp";
	protected static String IMG_SELECTED="GRID_SELECTED.bmp";

	protected static String IMG_UP="GRID_UP.ico";
	protected static String IMG_DOWN="GRID_DOWN.ico";
	//===========================================================
	//VARIABLES
	//===========================================================
	TableEditor mEditor;
	protected TableColumn mTableColumnSelector;
	protected boolean mCancelComboSelection;
	protected boolean mEditing=false;
	protected int mColumn=1;
	protected int mRow=0;
	protected boolean mCanAddNew=false;
	//===========================================================
	//YOU SHOULD OVERWRITE THE FOLLOWING METHODS
	//===========================================================
	protected int getControlTypeForColumn(int pColumn) { return CONTROL_TEXT; }
	protected void fillCombo(CCombo pCombo, int pRow, int pColumn) { }
	protected boolean isSortableColumn(int pColumn) { return true; }
	protected void sortByColumn(int pColumn, boolean pDesc) { }
	protected boolean cancelInsertRow(int pRow) { return false; }
	protected boolean cancelUpdateRow(int pRow) { return false; }
	protected boolean cancelDeleteRow(int pRow) { return false; }
	protected boolean handleUpdateRow(int pRow) { return true; }
	protected boolean handleInsertRow(int pRow) { return true; }
	protected boolean handleDeleteRow(int pRow) { return true; }
	protected void setRowValues(int pRow, TableItem pItem) { }
	protected boolean allowEditCell(int pRow, int pColumn) { return true; }
	protected Image getResourceImage(String pResourceName) { return null; }
	protected void handleMessage(String pMsg) { }
	//===========================================================
	//CONSTRUCTOR
	//===========================================================
	public ATable(Composite pComposite,int pStyle)
	{
		super(pComposite,pStyle | SWT.BORDER | SWT.SINGLE |
						SWT.FULL_SELECTION);
		mTableColumnSelector=new TableColumn(this,SWT.LEFT,COL_SELECTOR);
		mTableColumnSelector.setWidth(23);
		mTableColumnSelector.setResizable(false);
		setLinesVisible(true);
		setHeaderVisible(true);
		initEventHandlers();
		initEditor();
	}
	//===========================================================
	//CHECK SUB CLASS
	//===========================================================
	protected void checkSubclass () { /*allow subclassing */}
	//===========================================================
	//INIT EDITOR
	//===========================================================
	protected void initEditor()
	{
		mEditor = new TableEditor (this);
		mEditor.horizontalAlignment = SWT.LEFT;
		mEditor.grabHorizontal = true;
	}
	//===========================================================
	//INIT EVENT HANDLERS
	//===========================================================
	protected void initEventHandlers()
	{
		addMouseListener(new MouseAdapter()
		{
			public void mouseDown(MouseEvent e)
			{
				Point p=new Point(e.x,e.y);
				int columnSelected=getColumnSelected(p);
				if (columnSelected==-1)
				{
					if(getSelectionIndex()==-1) return;
					setCell(getSelectionIndex(),0);
				}
				else
				{
					setCell(getRowSelected(p),columnSelected);
				}
			}
		});
		addSelectionListener(new SelectionAdapter()
		{
			public void widgetSelected(SelectionEvent e)
			{
				if (getSelectionIndex () == -1)
				{
					setCell(mRow,mColumn);
				}
				else
				{
					setCell(getSelectionIndex(),mColumn);
				}
			}
		});
		addKeyListener(new KeyAdapter()
		{
			public void keyPressed(KeyEvent e)
			{
				if((mColumn==0) && (e.keyCode==SWT.DEL))
				{
					if(!cancelDeleteRow(mRow))
					{
						if(handleDeleteRow(mRow)) remove(mRow);
					}
				}
			}
		});
	}
	//===========================================================
	//RESET SELECTOR IMAGE
	//===========================================================
	protected void resetSelectorImage(int pRow)
	{
		if(mCanAddNew && (pRow==lastRowIndex()))
		{
			setSelectorImage(pRow,IMG_NEW_LINE);
		}
		else
		{
			setSelectorImage(pRow,IMG_NORMAL);
		}
	}
	//===========================================================
	//SET SELECTOR IMAGE
	//===========================================================
	protected void setSelectorImage(int pRow,String pImageName)
	{
		getItem(pRow).setImage(COL_SELECTOR, getResourceImage(pImageName));
	}
	//===========================================================
	//GET EDITOR VALUE
	//===========================================================
	protected String getEditorValue()
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			return ((Text)control).getText();
		}
		else if(control instanceof CCombo)
		{
			return ((CCombo)control).getText();
		}
		else
		{
			return null;
		}
	}
	//===========================================================
	//SET EDITOR VALUE
	//===========================================================
	protected void setEditorValue(String pValue)
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			((Text)control).setText(pValue);
		}
		else if(control instanceof CCombo)
		{
			((CCombo)control).setText(pValue);
		}
	}
	//===========================================================
	//SET CELL
	//===========================================================
	protected void setCell(int pNewRow, int pNewColumn)
	{
		try
		{
			if(mEditing)
			{
				getItem(mRow).setText(mColumn,getEditorValue());
				if(mRow!=pNewRow)
				{
					if(mCanAddNew)
					{
						if(mRow==lastRowIndex())
						{
							if(!cancelInsertRow(mRow))
							{
								if(handleInsertRow(mRow))
								{
									addAddNewRow();
								}
								else
								{
									deselect(pNewRow);
									mEditor.getEditor().setFocus();
									return;
								}
							}
							else
							{
								deselect(pNewRow);
								mEditor.getEditor().setFocus();
								return;
							}
						}
						else
						{
							if(!cancelUpdateRow(mRow))
							{
								if(!handleUpdateRow(mRow))
								{
									deselect(pNewRow);
									mEditor.getEditor().setFocus();
									return;
								}
							}
							else
							{
								deselect(pNewRow);
								mEditor.getEditor().setFocus();
								return;
							}
						}
					}
					else
					{
						if(!cancelUpdateRow(mRow))
						{
							if(!handleUpdateRow(mRow))
							{
								deselect(pNewRow);
								mEditor.getEditor().setFocus();
								return;
							}
						}
						else
						{
							deselect(pNewRow);
							mEditor.getEditor().setFocus();
							return;
						}
					}
					stopEditing();
				}
			}
			Control oldEditor = mEditor.getEditor();
			if (oldEditor != null)
			{
				if(oldEditor instanceof CCombo)
				{
					setComboValue(mRow,mColumn,
						((CCombo)oldEditor).getSelectionIndex());
				}
				oldEditor.dispose();
				mEditor.setEditor(null);
			}
			resetSelectorImage(mRow);
			mRow=pNewRow;
			mColumn=pNewColumn;
			select(mRow);
			showItem(getItem(mRow));
			if(mColumn==0)
			{
				select(mRow);
				setSelectorImage(mRow,IMG_HIGHLIGHT);
			}
			else
			{
				if(allowEditCell(mRow,mColumn))
				{
					Control editorControl=getEditorControl();
					if(editorControl!=null)
					{
						mEditor.setEditor(editorControl,getItem(mRow),mColumn);
					}
					if(mEditing)
					{
						setSelectorImage(mRow,IMG_EDITING);
					}
					else
					{
						setSelectorImage(mRow,IMG_SELECTED);
					}
					deselect(mRow);
				}
				else
				{
					setSelectorImage(mRow,IMG_HIGHLIGHT);
					select(mRow);
				}
			}
		}
		catch(Exception e)
		{
			handleMessage(e.getMessage());
		}
	}
	//===========================================================
	//SET CELL
	//===========================================================
	protected void msgBox(String pMsg)
	{
		((AShell)getShell()).msgBox(pMsg);
	}
	//===========================================================
	//GET CURRENT CELL VALUE
	//===========================================================
	protected String getCurrentCellValue()
	{
		return getItem(mRow).getText(mColumn);
	}
	//===========================================================
	//SET COMBO VALUE
	//===========================================================
	protected void setComboValue(int pRow, int pColumn, int pValue)
	{
		getItem(pRow).setData((new Integer(pColumn)).toString(), new
Integer(pValue));
	}
	//===========================================================
	//GET COMBO VALUE
	//===========================================================
	protected int getComboValue(int pRow, int pColumn)
	{
		try
		{
			return ((Integer)getItem(pRow).getData(
					(new Integer(pColumn)).toString())).intValue();
		}
		catch(Exception e)
		{
			return -1;
		}
	}
	//===========================================================
	//GET EDITOR CONTROL
	//===========================================================
	protected Control getEditorControl()
	{
		int controlType=getControlTypeForColumn(mColumn);

		if(controlType==CONTROL_COMBO)
		{
			final CCombo combo=new CCombo(this,SWT.FLAT);
			fillCombo(combo,mRow,mColumn);
			combo.setText(getCurrentCellValue());
			combo.addKeyListener(new KeyAdapter()
			{
				public void keyPressed(KeyEvent e)
				{
					handleKeyPressed(e);
				}
			});
			combo.addSelectionListener(new SelectionAdapter()
			{
				public void widgetSelected(SelectionEvent e)
				{
					if(mCancelComboSelection)
					{
						e.doit=false;
						combo.setText(getCurrentCellValue());
						mCancelComboSelection=false;
					}
					else
					{
						if(!mEditing && !getCurrentCellValue().equals(getEditorValue()))
						{
							setComboValue(mRow,mColumn,combo.getSelectionIndex());
							startEditing();
						}
					}
				}
			});
			combo.addTraverseListener(this);
			combo.setFocus();
			return combo;
		}
		else if(controlType==CONTROL_TEXT)
		{
			final Text text = new Text(this, SWT.NONE);
			text.setText(getCurrentCellValue());
			text.setFocus();
			text.addKeyListener(new KeyAdapter()
			{
				public void keyPressed(KeyEvent e)
				{
					handleKeyPressed(e);
				}
			});
			text.addTraverseListener(this);
			return text;
		}
		else
		{
			return null;
		}
	}
	//===========================================================
	//START EDITING
	//===========================================================
	protected void startEditing()
	{
		mEditing=true;
		setSelectorImage(mRow,IMG_EDITING);
		raiseEvent(AppEvents.EDITROW_START);
	}
	//===========================================================
	//STOP EDITING
	//===========================================================
	protected void stopEditing()
	{
		mEditing=false;
		raiseEvent(AppEvents.EDITROW_END);
	}
	//===========================================================
	//RESTORE OLD VALUES
	//===========================================================
	protected void restoreOldValues()
	{
		setRowValues(mRow,getItem(mRow));
	}
	//===========================================================
	//KEY TRAVERSED
	//===========================================================
	public void keyTraversed(TraverseEvent e)
	{
		if(mEditor.getEditor() instanceof CCombo)
		{
			mCancelComboSelection=true;
		}
		e.doit=false;
		if(e.detail==SWT.TRAVERSE_ARROW_PREVIOUS && e.keyCode==SWT.ARROW_LEFT)
		{
			if(mRow==0 && mColumn==1) return;
			handleArrowPrevious();
		}
		else if(e.detail==SWT.TRAVERSE_ARROW_NEXT && e.keyCode==SWT.ARROW_RIGHT)
		{
			if(mRow==lastRowIndex() && mColumn==getColumnCount()-1) return;
			handleArrowNext();
		}
	}
	//===========================================================
	//HANDLE ARROW PREVIOUS
	//===========================================================
	protected void handleArrowPrevious()
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			Text text=(Text)mEditor.getEditor();
			if(text.getCaretPosition()==0)
			{
				if(setCellArrowPrevious()) moveCaretArrowPrevious();
			}
		}
		else if(control instanceof CCombo)
		{
			CCombo combo=(CCombo)mEditor.getEditor();
			int caretPosition=combo.getSelection().x;
			if(caretPosition==0)
			{
				if(setCellArrowPrevious()) moveCaretArrowPrevious();
			}
		}
	}
	//===========================================================
	//SET CELL ARROW PREVIOUS
	//===========================================================
	protected boolean setCellArrowPrevious()
	{
		if(mColumn==1)
		{
			int oldRow=mRow;
			setCell(mRow-1,lastColumnIndex());
			return (mRow!=oldRow);
		}
		else
		{
			int oldColumn=mColumn;
			setCell(mRow,mColumn-1);
			return (mColumn!=oldColumn);
		}
	}
	//===========================================================
	//MOVE CARRET ARROW PREVIOUS
	//===========================================================
	protected void moveCaretArrowPrevious()
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			Text text=(Text)mEditor.getEditor();
			text.setSelection(text.getText().length());
		}
		else if(control instanceof CCombo)
		{
			CCombo combo=(CCombo)mEditor.getEditor();
			int lastCaretPosition=combo.getText().length();
			combo.setSelection(new Point(lastCaretPosition,lastCaretPosition));
		}
	}
	//===========================================================
	//HANDLE ARROW NEXT
	//===========================================================
	protected void handleArrowNext()
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			Text text=(Text)mEditor.getEditor();
			if(text.getCaretPosition()==text.getText().length())
			{
				if(setCellArrowNext()) moveCaretArrowNext();
			}
		}
		else if(control instanceof CCombo)
		{
			CCombo combo=(CCombo)mEditor.getEditor();
			int caretPosition=combo.getSelection().x;
			if(caretPosition==combo.getText().length())
			{
				if(setCellArrowNext()) moveCaretArrowNext();
			}
		}
	}
	//===========================================================
	//SET CELL ARROW NEXT
	//===========================================================
	protected boolean setCellArrowNext()
	{
		if(mColumn==lastColumnIndex())
		{
			int oldRow=mRow;
			setCell(mRow+1,1);
			return (mRow!=oldRow);
		}
		else
		{
			int oldColumn=mColumn;
			setCell(mRow,mColumn+1);
			return (mColumn!=oldColumn);
		}
	}
	//===========================================================
	//MOVE CARE ARROW NEXT
	//===========================================================
	protected void moveCaretArrowNext()
	{
		Control control=mEditor.getEditor();
		if(control instanceof Text)
		{
			Text text=(Text)mEditor.getEditor();
			text.setSelection(0);
		}
		else if(control instanceof CCombo)
		{
			CCombo combo=(CCombo)mEditor.getEditor();
			combo.setSelection(new Point(0,0));
		}
	}
	//===========================================================
	//HANDLE KEY PRESSED
	//===========================================================
	protected void handleKeyPressed(KeyEvent e)
	{
		if(isControlKey(e.keyCode))
		{
			handleControlKey(e);
		}
		else
		{
			if(!mEditing && !getCurrentCellValue().equals(getEditorValue()))
			{
				startEditing();
			}
		}
	}
	//===========================================================
	//IS CONTROL KEY
	//===========================================================
	protected boolean isControlKey(int pKeyCode)
	{
		if(pKeyCode==SWT.ARROW_DOWN ||
			pKeyCode==SWT.ARROW_UP ||
			pKeyCode==SWT.TAB ||
			pKeyCode==10 ||
			pKeyCode==13 ||
			pKeyCode==SWT.ESC)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	//===========================================================
	//HANDLE CONTROL KEY
	//===========================================================
	protected void handleControlKey(KeyEvent e)
	{
		if(e.keyCode==SWT.ARROW_DOWN)
		{
			if(mRow==lastRowIndex()) return;
			setCell(mRow+1,mColumn);
		}
		else if(e.keyCode==SWT.ARROW_UP)
		{
			if(mRow==0) return;
			setCell(mRow-1,mColumn);
		}
		else if(e.keyCode==SWT.TAB)
		{
			if(e.stateMask==SWT.SHIFT)
			{
				if(mColumn==1)
				{
					if(mRow==0) return;
					setCell(mRow-1,lastColumnIndex());
				}
				else
				{
					setCell(mRow,mColumn-1);
				}
			}
			else
			{
				if(mColumn==lastColumnIndex())
				{
					if(mRow==lastRowIndex()) return;
					mColumn=1;
					setCell(mRow+1,1);
				}
				else
				{
					setCell(mRow,mColumn+1);
				}
			}
		}
		else if((char)e.keyCode==10 || (char)e.keyCode==13)
		{
			if(mRow<lastRowIndex())
			{
				setCell(mRow+1,1);
			}
			else
			{
				if(mCanAddNew && mRow==lastRowIndex())
				{
					setCell(mRow+1,1);
				}
			}
		}
		else if(e.keyCode==SWT.ESC)
		{
			if(mEditing)
			{
				resetSelectorImage(mRow);
				if(mCanAddNew && (mRow==lastRowIndex()))
				{
					remove(lastRowIndex());
					addAddNewRow();
				}
				else
				{
					restoreOldValues();
				}
				stopEditing();
				setCell(mRow,1);
			}
		}
	}
	//===========================================================
	//LAST ROW INDEX
	//===========================================================
	protected int lastRowIndex()
	{
		return getItemCount()-1;
	}
	//===========================================================
	//LAST COLUMN INDEX
	//===========================================================
	protected int lastColumnIndex()
	{
		return getColumnCount()-1;
	}
	//===========================================================
	//GET ROW SELECTED
	//===========================================================
	protected int getRowSelected(Point p)
	{
		TableItem item = getItem (p);
		return indexOf(item);
	}
	//===========================================================
	//GET COLUMN SELECTED
	//===========================================================
	protected int getColumnSelected(Point p)
	{
		TableItem item = getItem (p);
		 if (item == null) return -1;
		for(int col=0;col<getColumnCount();col++)
		{
			Rectangle rectangle = item.getBounds (col);
			if (rectangle.contains (p)) return col;
		}
		return -1;
	}
	//===========================================================
	//GET NEW TABLE ITEM
	//===========================================================
	protected TableItem getNewTableItem()
	{
		TableItem tableItem=new TableItem(this,SWT.NULL);
		tableItem.setImage(COL_SELECTOR,getResourceImage(IMG_NORMAL));
		return tableItem;
	}
	//===========================================================
	//ADD NEW ROW
	//===========================================================
	protected void 	addAddNewRow()
	{
		TableItem tableItem=new TableItem(this,SWT.NULL);
		tableItem.setImage(COL_SELECTOR,getResourceImage(IMG_NEW_LINE));
		mCanAddNew=true;
	}
	//===========================================================
	//REMOVE ALL
	//===========================================================
	public void removeAll()
	{
		super.removeAll();
		mCanAddNew=false;
		mEditing=false;
		mColumn=1;
		mRow=0;
		Control oldEditor = mEditor.getEditor();
		if (oldEditor != null)
		{
			oldEditor.dispose();
			mEditor.setEditor(null);
		}
	}
	//===========================================================
	//MAKE SORTABLE
	//===========================================================
	protected void makeSortable()
	{
		TableColumn columns[]=getColumns();
		for(int i=1;i<columns.length;i++)
		{
			if(isSortableColumn(i))
			{
				TableColumn column=columns[i];
				column.setData("sortorder","none");
				column.addSelectionListener(new SelectionAdapter()
				{
					public void widgetSelected(SelectionEvent e)
					{
						handleSortClick(e);
					}
				});
			}
		}
	}
	//===========================================================
	//HANDLE SORT CLICK
	//===========================================================
	protected void handleSortClick(SelectionEvent e)
	{
		//
		if(mEditing) return;
		//
		TableColumn column;
		TableColumn columns[]=getColumns();
		for(int i=1;i<columns.length;i++)
		{
			column=columns[i];
			column.setImage(null);
		}
		column=(TableColumn)e.getSource();
		int index=indexOf(column);
		String sortOrder=(String)column.getData("sortorder");
		boolean desc=false;
		if(sortOrder.equals("none"))
		{
			sortOrder="asc";
			desc=false;
			column.setImage(getResourceImage(IMG_UP));
		}
		else if(sortOrder.equals("asc"))
		{
			sortOrder="desc";
			desc=true;
			column.setImage(getResourceImage(IMG_DOWN));
		}
		else
		{
			sortOrder="asc";
			desc=false;
			column.setImage(getResourceImage(IMG_UP));
		}
		column.setData("sortorder",sortOrder);
		removeAll();
		sortByColumn(index,desc);
	}
	//===========================================================
	//ADD EDITABLE GRID LISTENER
	//===========================================================
	public void addEditableGridListener(EditableGridListener
editableGridListener)
	{
		if(editableGridListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
		AppListener typedListener=new AppListener(editableGridListener);
		addListener(AppEvents.EDITROW_START,typedListener);
		addListener(AppEvents.EDITROW_END,typedListener);
	}
	//===========================================================
	//RAISE EVENT
	//===========================================================
	protected void raiseEvent(int pEventType)
	{
		notifyListeners(pEventType,new Event());
	}
	//===========================================================
	//NZ STRING (CONVENIENCE METHOD)
	//===========================================================
	protected String nzString(String pValue)
	{
		if(pValue==null)
		{
			return "";
		}
		else
		{
			return pValue;
		}
	}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is licensed under the same license as SWT.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import org.eclipse.swt.widgets.Event;
/**
 * This the adapter for the EditableGridListener.
 *
 * @author  Erik Poupaert, February 2003, Brussels, Belgium
 */
public abstract class EditableGridAdapter implements EditableGridListener
{
	public void handleEditStart(Event event) {}
	public void handleEditEnd(Event event) {}
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is licensed under the same license as SWT.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import org.eclipse.swt.internal.SWTEventListener;
import org.eclipse.swt.widgets.*;
/**
 * This handles events raised by the EditableGrid.
 *
 * @author  Erik Poupaert, February 2003, Brussels, Belgium
 */
public interface EditableGridListener extends SWTEventListener
{
	public void handleEditStart(Event event);
	public void handleEditEnd(Event event);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is licensed under the same license as SWT.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
 * This class centralizes event numbers.
 * I'm looking for a better solution to handle this event numbering problem.
 *
 * @author  Erik Poupaert, February 2003, Brussels, Belgium
 */
public class AppEvents
{
	public final static int LBOUND=3999;
	//
	public final static int EDITROW_START=		LBOUND+1;
	public final static int EDITROW_END=			LBOUND+2;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is licensed under the same license as SWT.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.internal.SWTEventListener;
/**
 * This class centralizes all listener methods. It's modeled after
 * the TypedEventListener class in SWT.
 * I'm looking for a better solution to handle this problem.
 *
 * @author  Erik Poupaert, February 2003, Brussels, Belgium
 */
public class AppListener extends TypedListener
{

	public AppListener(SWTEventListener listener)
	{
		super(listener);
	}

	public void handleEvent(Event e)
	{
		switch (e.type)
		{
			case AppEvents.EDITROW_START:
				((EditableGridListener) eventListener).handleEditStart(e);
				break;
			case AppEvents.EDITROW_END:
				((EditableGridListener) eventListener).handleEditEnd(e);
				break;
		}
	}
}



Back to the top