Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Re: Customizing Traverse-keys for ColumnViewerEditor
Re: Customizing Traverse-keys for ColumnViewerEditor [message #508892] Wed, 20 January 2010 11:14 Go to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
ColumnViewerEditor comes from jface, so I've copied the question to the
jface newsgroup.

"Arne Jans" <arne.jans@itscope.de> wrote in message
news:hj4aus$rm6$1@build.eclipse.org...
> Hello,
>
> I want to enable cell-traverse during edits not only for TAB-keypresses,
but also for ARROW-keys. What is the right way to do this?
>
> I already tried to modify/subclass ColumnViewerEditor, but that doesnt
work due to API-restrictions.
>
> Please help.
>
> Arne Jans
>
>
icon14.gif  Re: Customizing Traverse-keys for ColumnViewerEditor [message #510679 is a reply to message #508892] Thu, 28 January 2010 10:31 Go to previous message
Arne Jans is currently offline Arne JansFriend
Messages: 9
Registered: December 2009
Junior Member
Hello,

I am the author of the original post. I have solved this problem with the snippet Snippet059CellNavigationIn33. Using the internal API with reflection did the trick. But as the snippet-comment says: "This snippet uses internal API by reflection so its not guaranteed to work for ever", so handle with care and better dont forget about it.

To enable InEdit-Cursorcellnavigation, I had to enhance the if-expressions in the method TableViewerEditor.processTraverseEvent as follows:

	protected void processTraverseEvent(int columnIndex, ViewerRow row,
			TraverseEvent event) {

		ViewerCell cell2edit = null;

		if ((event.detail == SWT.TRAVERSE_TAB_PREVIOUS)||
				((event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) && 
						((ColumnViewerEditorActivationStrategyWithMemory)editorActivationStrategy).getLastColumnViewerEditorActivationEvent().keyCode != SWT.F2)) {
			event.doit = false;

			if ((((event.stateMask & SWT.CTRL) == SWT.CTRL) || (event.keyCode == SWT.ARROW_UP))
					&& (feature & TABBING_VERTICAL) == TABBING_VERTICAL) {
				cell2edit = searchCellAboveBelow(row, getViewer(), columnIndex, true);
			} else if ((feature & TABBING_HORIZONTAL) == TABBING_HORIZONTAL) {
				cell2edit = searchPreviousCell(row, row.getCell(columnIndex),
						row.getCell(columnIndex), getViewer());
			}
		} else if ((event.detail == SWT.TRAVERSE_TAB_NEXT)||
				((event.detail == SWT.TRAVERSE_ARROW_NEXT) && 
						((ColumnViewerEditorActivationStrategyWithMemory)editorActivationStrategy).getLastColumnViewerEditorActivationEvent().keyCode != SWT.F2)) {
			event.doit = false;

			if ((((event.stateMask & SWT.CTRL) == SWT.CTRL)||(event.keyCode == SWT.ARROW_DOWN))
					&& (feature & TABBING_VERTICAL) == TABBING_VERTICAL) {
				cell2edit = searchCellAboveBelow(row, getViewer(), columnIndex,
						false);
			} else if ((feature & TABBING_HORIZONTAL) == TABBING_HORIZONTAL) {
				cell2edit = searchNextCell(row, row.getCell(columnIndex), row
						.getCell(columnIndex), getViewer());
			}
		}
...


If you wonder about the fragment:
Quote:
((ColumnViewerEditorActivationStrategyWithMemory)editorActiv ationStrategy).getLastColumnViewerEditorActivationEvent().ke yCode != SWT.F2))

I did this to let the user decide, if he wants InEdit-cursornavigation between cells. He can press F2 to edit a cell, and the feature is temporarily disabled, just like in MS Excel. This is so that you can navigate the cellcontent as usual to fix typos etc. I had to derive the subclass ColumnViewerEditorActivationStrategyWithMemory from ColumnViewerEditorActivationStrategy and add the method getLastColumnViewerEditorActivationEvent that simply delivers the last EditorActivationEvent that was remembered as a local field in ColumnViewerEditorActivationStrategyWithMemory.

Hope this helps somebody who has similar problems.

Regards,

Arne Jans

[Updated on: Thu, 28 January 2010 10:32]

Report message to a moderator

Previous Topic:Preserve tree selection while collapsing/expanding a tree
Next Topic:Re: Problem with ColumnViewerEditorActivationListener in a TableViewer
Goto Forum:
  


Current Time: Sat Apr 20 00:33:33 GMT 2024

Powered by FUDForum. Page generated in 0.02377 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top