CellNavigationStrategy doesn't seem to work with a TreeViewer [message #331897] |
Sat, 27 September 2008 00:09 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: fischelbruno2.hotmail.com
------=_Part_3485_27567972.1222474270855
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hello,
I have a tree and I want to be able to block the user from selecting specific nodes in this tree. I found a way to do this is SWT but it is also preventing traversal of the tree.
I thought I could use the CellNavigationStrategy class(I am using Eclipse 3.4) but I am not able to achieve the focus strategy highlighted above.
I am trying to override the findSelectedCell() method to skip the 'next' cell if its element is of a specific type.
The problem is that the default implementation of this method always return null in a TreeViewer when I would expect that it returns the 'next' cell in the Tree (after or before the current selection, based the key pressed).
Maybe the CellNavigationStrategy is not intended for this usage but if so, how should I do it?
(I was not able to attach the code snippet because of some server error)
Thanks
------=_Part_3485_27567972.1222474270855
Content-Type: text/plain; charset=us-ascii; name=cellnavigationstrategy.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=cellnavigationstrategy.txt
// .....
CellNavigationStrategy naviStrat = new CellNavigationStrategy() {
public ViewerCell findSelectedCell(ColumnViewer viewer,
ViewerCell currentSelectedCell, Event event)
{
ViewerCell cell = null;
// If the next cell is a Schema, we skip it
do
{
cell = super.findSelectedCell(viewer, currentSelectedCell, event);
}
while (cell != null && cell.getElement() instanceof Schema);
return cell;
}
};
TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(treeViewer, new FocusCellOwnerDrawHighlighter(treeViewer),naviStrat);
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer)
{
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
return false;
}
};
TreeViewerEditor.create(treeViewer, focusCellManager,
actSupport,
ColumnViewerEditor.KEYBOARD_ACTIVATION);
// .....
------=_Part_3485_27567972.1222474270855
Content-Type: text/plain; charset=us-ascii; name=cellnavigationstrategy.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=cellnavigationstrategy.txt
// .....
CellNavigationStrategy naviStrat = new CellNavigationStrategy() {
public ViewerCell findSelectedCell(ColumnViewer viewer,
ViewerCell currentSelectedCell, Event event)
{
ViewerCell cell = null;
// If the next cell is a Schema, we skip it
do
{
cell = super.findSelectedCell(viewer, currentSelectedCell, event);
}
while (cell != null && cell.getElement() instanceof Schema);
return cell;
}
};
TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(treeViewer, new FocusCellOwnerDrawHighlighter(treeViewer),naviStrat);
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer)
{
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
return false;
}
};
TreeViewerEditor.create(treeViewer, focusCellManager,
actSupport,
ColumnViewerEditor.KEYBOARD_ACTIVATION);
// .....
------=_Part_3485_27567972.1222474270855--
|
|
|
|
Re: CellNavigationStrategy doesn't seem to work with a TreeViewer [message #331925 is a reply to message #331909] |
Mon, 29 September 2008 16:42 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: fischelbruno2.hotmail.com
Hello Tom,
After toying with the new JFace API I gave up and implemented a solution using a combination of SWT Listeners.
I found a few issues with the current implementation CellNavigationStrategy.findSelectedCell() always return null unless you explicitly added a TreeColumn to your tree.
Also, it would be nice to make some default CellNavigationStrategy available. For instance, the default navigation strategy for the TreeViewerFocusCellManager is not visible.
A navigation strategy which skips nodes matching a pattern would also be really helpful.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03047 seconds