Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » expanding subtree in emf editor(using expandToLevel(item,level))
expanding subtree in emf editor [message #734767] Sun, 09 October 2011 20:45 Go to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 155
Registered: July 2009
Senior Member
I'm adding an action to expand a subtree in the emf editor's treeViewer, and it took me a while to figure out that the TreeViewer's expandToLevel wouldn't work on the TreeItems returned by getSelection(), which I figured out when I tested isExpandable(item) in the code below.

The isExpandable(item.getData()) returns true, though, so the action below works to expand a subtree in my editor.

protected IAction expandSubtreeAction =
new Action("Expand SubTree") {
@Override
public void run() {
PfsEditor ip = (PfsEditor)activeEditorPart;
if (ip != null){
CheckboxTreeViewer vw = (CheckboxTreeViewer)ip.getViewer();
vw.getTree().setRedraw(false);
TreeItem[] treeitems = vw.getTree().getSelection();
for (TreeItem item:treeitems){
if (vw.isExpandable(item.getData())){
vw.expandToLevel(item.getData(),AbstractTreeViewer.ALL_LEVELS);
}
}
vw.getTree().setRedraw(true);
}
return;
}
};
Re: expanding subtree in emf editor [message #734834 is a reply to message #734767] Mon, 10 October 2011 06:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jay,

This doesn't really sound like an EMF question... Can't this work
without dropping down to use the underlying tree widget?


On 09/10/2011 10:45 PM, Jay Norwood wrote:
> I'm adding an action to expand a subtree in the emf editor's
> treeViewer, and it took me a while to figure out that the TreeViewer's
> expandToLevel wouldn't work on the TreeItems returned by
> getSelection(), which I figured out when I tested isExpandable(item)
> in the code below.
>
> The isExpandable(item.getData()) returns true, though, so the action
> below works to expand a subtree in my editor.
> protected IAction expandSubtreeAction =
> new Action("Expand SubTree") {
> @Override
> public void run() {
> PfsEditor ip = (PfsEditor)activeEditorPart;
> if (ip != null){
> CheckboxTreeViewer vw = (CheckboxTreeViewer)ip.getViewer();
> vw.getTree().setRedraw(false);
> TreeItem[] treeitems = vw.getTree().getSelection();
> for (TreeItem item:treeitems){
> if (vw.isExpandable(item.getData())){
> vw.expandToLevel(item.getData(),AbstractTreeViewer.ALL_LEVELS);
> }
> }
> vw.getTree().setRedraw(true);
> }
> return;
> }
> };
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Custom EMF JetTemplates: Uses wrong compiled template
Next Topic:EMF & TableViewers
Goto Forum:
  


Current Time: Fri Apr 26 02:32:47 GMT 2024

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

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

Back to the top