Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Tree selection
Tree selection [message #85925] Mon, 05 May 2008 05:54 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

I have noticed a minor tree selection problem here.

Firstly, here's my snippet to reproduce :

...
public void createPartControl(Composite parent)
{
treeViewer = new TreeViewer(parent,SWT.VIRTUAL);
treeViewer.setUseHashlookup(true);

java.util.List<Map<String,Object>> list = new Vector<Map<String,
Object>>(1);

Map<String,Object> parentNode = new HashMap<String, Object>(3);
parentNode.put("id", "parentNode");
parentNode.put("caption", "Parent");

Map<String,Object> childNode = new HashMap<String, Object>(3);
childNode.put("id", "childNode");
childNode.put("caption", "Child");

Map<String,String> grandChildNode = new HashMap<String, String>(2);
grandChildNode.put("id", "grandChildNode");
grandChildNode.put("caption", "GrandChild");

parentNode.put("descendant", childNode);
childNode.put("descendant", grandChildNode);

list.add(parentNode);

treeViewer.setContentProvider(getTreeContentProvider());
treeViewer.setLabelProvider(getTreeLabelProvider());

((Tree)treeViewer.getControl()).setItemCount(list.size());
treeViewer.setInput(list);
}

private IContentProvider getTreeContentProvider()
{
return new ILazyTreeContentProvider()
{
private TreeViewer treeViewer = null;

public Object getParent(Object element){return null;}
public void dispose(){}

@Override
public void inputChanged(Viewer viewer, Object oldInput, Object
newInput)
{
treeViewer = newInput != null ? (TreeViewer)viewer : null;
}

@Override
@SuppressWarnings("unchecked")
public void updateChildCount(Object element, int currentChildCount)
{
if (!(element instanceof List)) return;
if (((List)element).size() == currentChildCount) return;
treeViewer.setChildCount(element,((List)element).size());
}

@Override
@SuppressWarnings("unchecked")
public void updateElement(Object parent, int index)
{
if (parent instanceof List)
{
List list = (List)parent;

Map map = (Map)list.get(index);
treeViewer.replace(parent, index, map);
treeViewer.setChildCount(map,1);
}
else
{
Map map = (Map)parent;
Map descendant = (Map)map.get("descendant");

if (descendant != null)
{
treeViewer.replace(parent, index, descendant);
treeViewer.setChildCount(descendant,
descendant.get("descendant") == null ? 0 : 1);
}
}
}
};
}

@SuppressWarnings("unchecked")
private IBaseLabelProvider getTreeLabelProvider()
{
return new LabelProvider()
{
@Override
public String getText(Object element)
{
return (String)((Map)element).get("caption");
}
};
}
...

Steps to reproduce :

1. Open the view.
2. Click on the + sign of 'Parent' node, the parent node is expanded &
selected.
3. Click on the + sign of 'Child' node, the child node is expanded &
selected, but the selection on parent node persists.
4. Click on the GrandChild node and the selection on Parent & Child node
persists.

I thought selection on parent node should be removed when we select the
child node unless user select & hold the CTRL at the same time.

Should I file a bug ?

Regards,

Setya
Re: Tree selection [message #86028 is a reply to message #85925] Mon, 05 May 2008 16:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

did you try to run your snippet in RCP environment? Does it behave as
expected there? If so, it's possibly a bug in RAP. If not we'll have to
digg a little bit deeper and see whether there's something wrong in your
code or if it's even a bug in the original RCP code.


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Montag, 5. Mai 2008 07:54
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Tree selection
Betreff: Tree selection


Hi all,

I have noticed a minor tree selection problem here.

Firstly, here's my snippet to reproduce :

...
public void createPartControl(Composite parent) {
treeViewer = new TreeViewer(parent,SWT.VIRTUAL);
treeViewer.setUseHashlookup(true);

java.util.List<Map<String,Object>> list = new Vector<Map<String,
Object>>(1);

Map<String,Object> parentNode = new HashMap<String, Object>(3);
parentNode.put("id", "parentNode");
parentNode.put("caption", "Parent");

Map<String,Object> childNode = new HashMap<String, Object>(3);
childNode.put("id", "childNode");
childNode.put("caption", "Child");

Map<String,String> grandChildNode = new HashMap<String, String>(2);
grandChildNode.put("id", "grandChildNode");
grandChildNode.put("caption", "GrandChild");

parentNode.put("descendant", childNode);
childNode.put("descendant", grandChildNode);

list.add(parentNode);

treeViewer.setContentProvider(getTreeContentProvider());
treeViewer.setLabelProvider(getTreeLabelProvider());

((Tree)treeViewer.getControl()).setItemCount(list.size());
treeViewer.setInput(list);
}

private IContentProvider getTreeContentProvider() {
return new ILazyTreeContentProvider()
{
private TreeViewer treeViewer = null;

public Object getParent(Object element){return null;}
public void dispose(){}

@Override
public void inputChanged(Viewer viewer, Object oldInput, Object
newInput)
{
treeViewer = newInput != null ? (TreeViewer)viewer : null;
}

@Override
@SuppressWarnings("unchecked")
public void updateChildCount(Object element, int currentChildCount)
{
if (!(element instanceof List)) return;
if (((List)element).size() == currentChildCount) return;
treeViewer.setChildCount(element,((List)element).size());
}

@Override
@SuppressWarnings("unchecked")
public void updateElement(Object parent, int index)
{
if (parent instanceof List)
{
List list = (List)parent;

Map map = (Map)list.get(index);
treeViewer.replace(parent, index, map);
treeViewer.setChildCount(map,1);
}
else
{
Map map = (Map)parent;
Map descendant = (Map)map.get("descendant");

if (descendant != null)
{
treeViewer.replace(parent, index, descendant);
treeViewer.setChildCount(descendant,
descendant.get("descendant") == null ? 0 : 1);
}
}
}
};
}

@SuppressWarnings("unchecked")
private IBaseLabelProvider getTreeLabelProvider() {
return new LabelProvider()
{
@Override
public String getText(Object element)
{
return (String)((Map)element).get("caption");
}
};
}
...

Steps to reproduce :

1. Open the view.
2. Click on the + sign of 'Parent' node, the parent node is expanded &
selected.
3. Click on the + sign of 'Child' node, the child node is expanded &
selected, but the selection on parent node persists.
4. Click on the GrandChild node and the selection on Parent & Child node
persists.

I thought selection on parent node should be removed when we select the
child node unless user select & hold the CTRL at the same time.

Should I file a bug ?

Regards,

Setya
Re: Tree selection [message #86042 is a reply to message #86028] Mon, 05 May 2008 18:06 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
Hi,

I have a rather strange question..
I have a folder in my workspace, which contains some images. What I need
is a File-Array for these images.
Inside my RCP, the following Snippet does what I want:
URL url = FileLocator.toFileURL(bundle.getEntry("images"));
File f = new File(url.getFile());
File[] list = f.listFiles();

This doesnt work in RAP, I expect the problem to be the File located
absolute within the Filesystem, rather as a relative path, which may be
not allowed??
Can someone give me a snippet of how this works, I spent nearly half day
to this and now itŽs enough:-)
I know how it works for a single File, but not for this use case with a
directory containing files. For sure this is easy to solve, but I really
donŽt get the 3-lines at the moment.

Thanks for your help!
Re: Tree selection [message #86057 is a reply to message #86042] Mon, 05 May 2008 18:07 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
sorry, wrong thread:(
Re: Tree selection [message #86688 is a reply to message #86028] Fri, 09 May 2008 11:49 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Frank,

> did you try to run your snippet in RCP environment?

I've tried it in the following snippet :

public static void main(String[] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout (new FillLayout());

TreeViewer treeViewer = new TreeViewer(shell,SWT.VIRTUAL);
treeViewer.setUseHashlookup(true);

java.util.List<Map<String,Object>> list = new Vector<Map<String,
Object>>(1);

Map<String,Object> parentNode = new HashMap<String, Object>(3);
parentNode.put("id", "parentNode");
parentNode.put("caption", "Parent");

Map<String,Object> childNode = new HashMap<String, Object>(3);
childNode.put("id", "childNode");
childNode.put("caption", "Child");

Map<String,String> grandChildNode = new HashMap<String, String>(2);
grandChildNode.put("id", "grandChildNode");
grandChildNode.put("caption", "GrandChild");

parentNode.put("descendant", childNode);
childNode.put("descendant", grandChildNode);

list.add(parentNode);

treeViewer.setContentProvider(getTreeContentProvider());
treeViewer.setLabelProvider(getTreeLabelProvider());

((Tree)treeViewer.getControl()).setItemCount(list.size());
treeViewer.setInput(list);

shell.setSize(400, 300);
shell.open();

while (!shell.isDisposed ())
{
if (!display.readAndDispatch ()) display.sleep ();
}

display.dispose ();
}

private static IContentProvider getTreeContentProvider()
{
return new ILazyTreeContentProvider()
{
private TreeViewer treeViewer = null;

public Object getParent(Object element){return null;}
public void dispose(){}

public void inputChanged(Viewer viewer, Object oldInput, Object
newInput)
{
treeViewer = newInput != null ? (TreeViewer)viewer : null;
}

@SuppressWarnings("unchecked")
public void updateChildCount(Object element, int currentChildCount)
{
if (!(element instanceof List)) return;
if (((List)element).size() == currentChildCount) return;

treeViewer.setChildCount(element,((List)element).size());
}

@SuppressWarnings("unchecked")
public void updateElement(Object parent, int index)
{
if (parent instanceof List)
{
List list = (List)parent;

Map map = (Map)list.get(index);
treeViewer.replace(parent, index, map);
treeViewer.setChildCount(map,1);
}
else
{
Map map = (Map)parent;
Map descendant = (Map)map.get("descendant");

if (descendant != null)
{
treeViewer.replace(parent, index, descendant);
treeViewer.setChildCount(descendant,
descendant.get("descendant") == null ? 0 : 1);
}
}
}
};
}

@SuppressWarnings("unchecked")
private static IBaseLabelProvider getTreeLabelProvider()
{
return new LabelProvider()
{
@Override
public String getText(Object element)
{
return (String)((Map)element).get("caption");
}
};
}


And it seems nothing is wrong in the SWT version.

Best Regards,

Setya
Re: Tree selection [message #86854 is a reply to message #86688] Mon, 12 May 2008 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

so this is probably a bug in RWT. Please file a bug for tracing it.


Thanks
Frank

-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Freitag, 9. Mai 2008 13:49
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Tree selection
Betreff: Re: Tree selection


Frank,

> did you try to run your snippet in RCP environment?

I've tried it in the following snippet :

public static void main(String[] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout (new FillLayout());

TreeViewer treeViewer = new TreeViewer(shell,SWT.VIRTUAL);
treeViewer.setUseHashlookup(true);

java.util.List<Map<String,Object>> list = new Vector<Map<String,
Object>>(1);

Map<String,Object> parentNode = new HashMap<String, Object>(3);
parentNode.put("id", "parentNode");
parentNode.put("caption", "Parent");

Map<String,Object> childNode = new HashMap<String, Object>(3);
childNode.put("id", "childNode");
childNode.put("caption", "Child");

Map<String,String> grandChildNode = new HashMap<String, String>(2);
grandChildNode.put("id", "grandChildNode");
grandChildNode.put("caption", "GrandChild");

parentNode.put("descendant", childNode);
childNode.put("descendant", grandChildNode);

list.add(parentNode);

treeViewer.setContentProvider(getTreeContentProvider());
treeViewer.setLabelProvider(getTreeLabelProvider());

((Tree)treeViewer.getControl()).setItemCount(list.size());
treeViewer.setInput(list);

shell.setSize(400, 300);
shell.open();

while (!shell.isDisposed ())
{
if (!display.readAndDispatch ()) display.sleep ();
}

display.dispose ();
}

private static IContentProvider getTreeContentProvider()
{
return new ILazyTreeContentProvider()
{
private TreeViewer treeViewer = null;

public Object getParent(Object element){return null;}
public void dispose(){}

public void inputChanged(Viewer viewer, Object oldInput, Object
newInput)
{
treeViewer = newInput != null ? (TreeViewer)viewer : null;
}

@SuppressWarnings("unchecked")
public void updateChildCount(Object element, int
currentChildCount)
{
if (!(element instanceof List)) return;
if (((List)element).size() == currentChildCount) return;

treeViewer.setChildCount(element,((List)element).size());
}

@SuppressWarnings("unchecked")
public void updateElement(Object parent, int index)
{
if (parent instanceof List)
{
List list = (List)parent;

Map map = (Map)list.get(index);
treeViewer.replace(parent, index, map);
treeViewer.setChildCount(map,1);
}
else
{
Map map = (Map)parent;
Map descendant = (Map)map.get("descendant");

if (descendant != null)
{
treeViewer.replace(parent, index, descendant);
treeViewer.setChildCount(descendant,
descendant.get("descendant") == null ? 0 : 1);
}
}
}
};
}

@SuppressWarnings("unchecked")
private static IBaseLabelProvider getTreeLabelProvider()
{
return new LabelProvider()
{
@Override
public String getText(Object element)
{
return (String)((Map)element).get("caption");
}
};
}


And it seems nothing is wrong in the SWT version.

Best Regards,

Setya
Re: Tree selection [message #86928 is a reply to message #86854] Tue, 13 May 2008 04:53 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

> so this is probably a bug in RWT. Please file a bug for tracing it.

Done. Bug ID #231523.

Regards,

Setya
Previous Topic:branding / default html body background image
Next Topic:Switching theme
Goto Forum:
  


Current Time: Sat Apr 27 00:10:29 GMT 2024

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

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

Back to the top