CellNavigationStrategy doesn't seem to work with a TreeViewer [message #331897] |
Fri, 26 September 2008 20:09  |
Eclipse User |
|
|
|
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 #331927 is a reply to message #331925] |
Mon, 29 September 2008 12:47  |
Eclipse User |
|
|
|
Hi Bruno,
If you found problems with the navigation API we are always interested
in bug reports to track them and if you file a bug report for a more
customizable CellNavigationStrategy file a bug and we can try to provide
such a thing in 3.5.
Tom
Bruno Fischel schrieb:
> 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.
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Powered by
FUDForum. Page generated in 0.06105 seconds