Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CellNavigationStrategy doesn't seem to work with a TreeViewer
CellNavigationStrategy doesn't seem to work with a TreeViewer [message #331897] Sat, 27 September 2008 00:09 Go to next message
Eclipse UserFriend
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 #331909 is a reply to message #331897] Sun, 28 September 2008 15:36 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please send a complete snippet I can use to run?

Tom

Bruno Fischel schrieb:
> 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
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
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 messageGo to next message
Eclipse UserFriend
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.
Re: CellNavigationStrategy doesn't seem to work with a TreeViewer [message #331927 is a reply to message #331925] Mon, 29 September 2008 16:47 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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
------------------------------------------------------------ --------
Previous Topic:Re: Updating to 3.4.1
Next Topic:Problem updating Ganymede SR1 Modeling version on XP
Goto Forum:
  


Current Time: Thu Jul 18 01:06:48 GMT 2024

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

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

Back to the top