If you run the examples/fwt/demo.fan in Mac OSx and go to the Tree and Table tab, the tree does not automatically refresh with the file tree. If you click out of the window and click back in the tree updates with the file tree. Is there a fix for this?
andyTue 5 Jun 2012
Always been like that - have never been able to fix. I'd very much welcome a patch if someone figures it out.
yliuTue 5 Jun 2012
So I've been trying to flesh out the problem and I think it has to do with when cocoa wants to handle it's events. By patching TreePeer.java as so:
public void rebuild()
{
// TODO: need to figure out how to sync
Tree tree = (Tree)this.control;
// get model
TreeModel model = model();
if (model == null) return;
// define roots
tree.setItemCount(model.roots().sz());
if(Fwt.isMac() == true)
{
for(int i = 0; i<model.roots().sz(); i++)
{
Event event = new Event();
event.type = SWT.SetData;
event.item = new TreeItem(tree,SWT.NONE);
event.index = i;
handleEvent(event);
}
}
}
/examples/fwt/demo.fan now has it's data loaded when you click on the tab.. except it has it twice! I think then the fix would be to just fire the event, that causes what I wrote to happen and the problem should be fixed. I need help figuring out what Event to pass into handleEvent or how that mechanism works.
yliuTue 5 Jun 2012
JK, I think I found a patch that works... TreePeer.fan if modified in this way:
TreePeer.refreshAll:
public void refreshAll(fan.fwt.Tree self)
{
Tree c = (Tree)this.control;
TreeModel model = model();
if (model == null) return;
c.removeAll();
c.setItemCount(model.roots().sz());
c.clearAll(true);
if(Fwt.isMac() == true && model.roots().sz() > 0)
{
Event event = new Event();
event.type = SWT.SetData;
event.item = new TreeItem(c,SWT.NONE);
handleEvent(event);
}
}
TreePee.refreshNode:
public void refreshNode(fan.fwt.Tree self, Object node)
{
Tree c = (Tree)this.control;
TreeModel model = model();
if (model == null) return;
TreeItem item = item(node);
if (item == null) return;
Data data = (Data)item.getData();
data.children = null;
item.removeAll();
lazyLoadChildren(item);
item.clearAll(true);
if(Fwt.isMac() == true && model.roots().sz() > 0)
{
Event event = new Event();
event.type = SWT.SetData;
event.item = new TreeItem(c,SWT.NONE);
handleEvent(event);
}
}
TreePeer.rebuild:
public void rebuild()
{
// TODO: need to figure out how to sync
Tree tree = (Tree)this.control;
// get model
TreeModel model = model();
if (model == null) return;
// define roots
tree.setItemCount(model.roots().sz());
if(Fwt.isMac() == true && model.roots().sz() > 0)
{
Event event = new Event();
event.type = SWT.SetData;
event.item = new TreeItem(tree,SWT.NONE);
handleEvent(event);
}
}
If you could look at what I did at refreshNode, I think the fix could be handled better. So far it the demo works correctly and the programs I've been working on seem to be behaving correctly with this fix. Let me know what you think.
andyTue 5 Jun 2012
Can you email me a diff yliu (afrankvt at gmail.com)? Might be a few days till I can evaluate - but I will take a look - would really like this fix this issue.
andyTue 5 Jun 2012
Promoted to ticket #1901 and assigned to andy
andyTue 5 Jun 2012
Renamed from Mac SWT Issue? to fwt::Tree does not repaint on refreshAll on OS X
tcolarMon 11 Jun 2012
Any news on this ... I've run int this a lot, including with Flux and other projects. A fix would be very welcome.
andyTue 12 Jun 2012
Yi sent me a patch - will try to take a look this week.
andyTue 12 Jun 2012
Ticket resolved in 1.0.63
Still no clue on how to really fix this - but Yi's patch is about 1000x better than current behavior - so I pushed. Basically we add and then immediately remove a node and seems to trigger the repaint correctly.
Changeset (sorry I misspelled your last name Yi :/)
yliu Tue 5 Jun 2012
If you run the examples/fwt/demo.fan in Mac OSx and go to the Tree and Table tab, the tree does not automatically refresh with the file tree. If you click out of the window and click back in the tree updates with the file tree. Is there a fix for this?
andy Tue 5 Jun 2012
Always been like that - have never been able to fix. I'd very much welcome a patch if someone figures it out.
yliu Tue 5 Jun 2012
So I've been trying to flesh out the problem and I think it has to do with when cocoa wants to handle it's events. By patching TreePeer.java as so:
/examples/fwt/demo.fan now has it's data loaded when you click on the tab.. except it has it twice! I think then the fix would be to just fire the event, that causes what I wrote to happen and the problem should be fixed. I need help figuring out what Event to pass into handleEvent or how that mechanism works.
yliu Tue 5 Jun 2012
JK, I think I found a patch that works... TreePeer.fan if modified in this way:
TreePeer.refreshAll:
TreePee.refreshNode:
TreePeer.rebuild:
If you could look at what I did at refreshNode, I think the fix could be handled better. So far it the demo works correctly and the programs I've been working on seem to be behaving correctly with this fix. Let me know what you think.
andy Tue 5 Jun 2012
Can you email me a diff yliu (afrankvt at gmail.com)? Might be a few days till I can evaluate - but I will take a look - would really like this fix this issue.
andy Tue 5 Jun 2012
Promoted to ticket #1901 and assigned to andy
andy Tue 5 Jun 2012
Renamed from Mac SWT Issue? to fwt::Tree does not repaint on refreshAll on OS X
tcolar Mon 11 Jun 2012
Any news on this ... I've run int this a lot, including with Flux and other projects. A fix would be very welcome.
andy Tue 12 Jun 2012
Yi sent me a patch - will try to take a look this week.
andy Tue 12 Jun 2012
Ticket resolved in 1.0.63
Still no clue on how to really fix this - but Yi's patch is about 1000x better than current behavior - so I pushed. Basically we add and then immediately remove a node and seems to trigger the repaint correctly.
Changeset (sorry I misspelled your last name Yi :/)