Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Tree Box(Tree Box field in Scout Framework)
Tree Box [message #1014838] Tue, 26 February 2013 15:07 Go to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi all,
I want use a treebox field of Scout in my project.
I need to load the information from a database and put them into a treebox.
I want use a lookup call parametrized and in the where condition of the query I need to put two date.

Example: Where orderdate between '2013-02-26 00:00' and '2013-02-26 23:59'

someone could help me figure out how to combine treebox with lookup call parameterized.

thanks in advance for the help and explanations
Re: Tree Box [message #1014929 is a reply to message #1014838] Tue, 26 February 2013 20:55 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I have assumed that you know your parameters on the client.

Just add them in a LookupCall (execPrepareLookupCall):
http://wiki.eclipse.org/Scout/Concepts/LookupCall#Members

In my example the parameters are constants set in the client. In the reality I assume they come dynamically from elsewhere.


And use them in the corresponding SqlLookupService:

See the last example for getConfiguredSqlSelect, it used the LanguageLookupCall defined in the first page:
http://wiki.eclipse.org/Scout/Concepts/Sql_Lookup_Service#Properties

---

I can provide more information on the where-clause I added if needed:
WHERE t.from_date < :validityTO AND t.to_date > :validityFROM


---

If the date depends on the current date, I think you can write your select to use trunc(sysdate).

---

NB: Instead of writing the same twice, I haved tried a wiki-first approach. Let me know if this is not enought and I need to fill the gap with more explanations.

[Updated on: Tue, 26 February 2013 21:10]

Report message to a moderator

Re: Tree Box [message #1015017 is a reply to message #1014929] Wed, 27 February 2013 08:23 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Thank you for the suggestion and the link. Now read everything and try to understand and apply this information
Re: Tree Box [message #1015059 is a reply to message #1015017] Wed, 27 February 2013 10:30 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Ok, now I can load the root element for each node with a first lookup call, with the method loadRootNode.
Now for each root element, I have to load the child elements. I try to use the same lookup call but it didn't work as hoped because it duplicated the root elements for the number of child elements.

With this sample query I populate the root elements in tree box:
Select Root From MyTable


With I change this query in the following way:
Select Root, Child From MyTable

in the tree box, the root elements are duplicated.

For this reason, I would use a second lookup call to retrieve all child elements for each root elements.
Select Child From MyTable Where Root='****'

Is this a correct idea or not? How could I proceed?

[Updated on: Wed, 27 February 2013 10:32]

Report message to a moderator

Re: Tree Box [message #1015204 is a reply to message #1015059] Wed, 27 February 2013 17:55 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Hi,

Is your data coming from the same table?

Something like:
+-----+-------+-----------+
| id  | name  | parent_id |
+-----+-------+-----------+
| 125 | Lorem | -         |
| 548 | Ipsum | -         |
| 587 | Dolor | 125       |
| 874 | Artis | 125       |
+-----+-------+-----------+


For this tree:
+-+ Lorem
| |
| +----- Dolor
| |
| \----- Artis
|
\-- Ipsum 


You can use a select like this:
SELECT id, text, NULL, NULL, NULL, NULL, NULL, 1, parent_id, 1 
FROM my_table

Re: Tree Box [message #1015331 is a reply to message #1015204] Thu, 28 February 2013 09:25 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Jeremie,
thank you for your help, now I load the tree-box with a similar query that you have posted:
index.php/fa/13595/0/

Now my question is: what means all the various null in the query you posted?

Now I would need to set the check box of the node based on a boolean field produced by the query that populates the tree-box, is this possible? How?
  • Attachment: TreeBox.png
    (Size: 7.95KB, Downloaded 1032 times)
Re: Tree Box [message #1015374 is a reply to message #1015331] Thu, 28 February 2013 12:04 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
From the wiki page:
http://wiki.eclipse.org/Scout/Concepts/Sql_Lookup_Service#Properties :

Quote:
(..) The AbstractSqlLookupService actually allows you to return additional meta-data that controls how the returned data is presented to the users. You can for example return icon IDs, color codes, tooltip texts or font descriptions. The complete list and order of all columns supported by the AbstractSqlLookupService is as follows:

Object key
String text
String iconId
String tooltip
String background color
String foreground color
String font
Boolean enabled (0,1)
Object parentKey used in hierarchical structures to point to the parents primary key
Boolean active (0,1)


The list is also provided by the Javadoc of AbstractSqlLookupService.


A check box in a tree-field, is considered as the value of this field in your form. In other words: the LookupCall/Service is not specific and can be (re)used everywhere (SmartField, SmartColumn, TreeBox, ...).

The usual way is to set the value on the field (dirrectly or using the formdata).

I will try to provide an example.

[Updated on: Thu, 28 February 2013 12:05]

Report message to a moderator

Re: Tree Box [message #1015392 is a reply to message #1015374] Thu, 28 February 2013 13:18 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Thank you for all information.

Now I have another question. I understand how I can retrieve all checked orders, but I need to find/retrieve only the selected node. Is this possible?

for example, in the following situation (see picture below), I want retrieve the information about the selected node 1630504.
index.php/fa/13606/0/

  • Attachment: TreeBox.png
    (Size: 13.46KB, Downloaded 996 times)

[Updated on: Thu, 28 February 2013 13:19]

Report message to a moderator

Re: Tree Box [message #1015395 is a reply to message #1015392] Thu, 28 February 2013 13:27 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
We now speak from the selection (independently from checked/unchecked):

how about:
getMyTreeBoxField().getTree().getSelectedNode()


[Updated on: Thu, 28 February 2013 13:27]

Report message to a moderator

Re: Tree Box [message #1015543 is a reply to message #1015395] Fri, 01 March 2013 08:25 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi,
is it possible disable the management of the checkbox in the tree box by the user or not?
Re: Tree Box [message #1015566 is a reply to message #1015543] Fri, 01 March 2013 09:09 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
The solution I can think of is to disable the field...

Maybe I did not understood what you want to do.
Re: Tree Box [message #1015612 is a reply to message #1015566] Fri, 01 March 2013 11:31 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi,
I want, if possible, that when the user selects a node in tree box doesn't automatically check.
Re: Tree Box [message #1016063 is a reply to message #1015612] Mon, 04 March 2013 19:09 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I think you can set all your lookup rows to false. This way the used can not check or uncheck it.
Re: Tree Box [message #1021744 is a reply to message #1014838] Wed, 20 March 2013 15:59 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi,
I'm here again looking for help.

How can I run a function when the user performs a double-click on an item in the tree-box?
For the moment, I use only a keystrokes, but the final user request that the same function run also on double-click.
index.php/fa/13952/0/

Can anyone help me pointing to a possible way?

Thanks in advance for your help
  • Attachment: Immagine.png
    (Size: 6.30KB, Downloaded 1045 times)
Re: Tree Box [message #1022134 is a reply to message #1021744] Thu, 21 March 2013 10:24 Go to previous messageGo to next message
Eclipse UserFriend
Ciao Marco

There are two ways to get there:
1: add a listener to the tree in the treebox
@Order(10.0)
public class TestField extends AbstractTreeBox<Long> {

  @Override
  protected void execInitField() throws ProcessingException {
    super.execInitField();
    getTree().setCheckable(false);
    // solution 01 add a listener
    getTree().addTreeListener(new TreeAdapter() {
      @Override
      public void treeChanged(TreeEvent e) {
        if (e.getType() == TreeEvent.TYPE_NODE_ACTION) {
          System.out.println("node aciton on '" + e.getNode().getNodeId() + "'");
        }
      }
    });
  }
  .....
}


2: override the default tree in your treebox:
@Order(10.0)
public class TestField extends AbstractTreeBox<Long> {

  ....

  // solution 02 override the default tree
  public class Tree extends DefaultTreeBoxTree {

    @Override
    protected void execNodeAction(ITreeNode node) throws ProcessingException {
      System.out.println("node action");
    }
  }
}


Hope it helps...
Re: Tree Box [message #1022281 is a reply to message #1022134] Thu, 21 March 2013 15:49 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Andreas,
first of all thanks for your suggestion. I choose to follow the first way.
Re: Tree Box [message #1028729 is a reply to message #1022281] Thu, 28 March 2013 16:59 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi all,
I have a new question about tree box. I managed to capture and properly handle the double click on a node, thanks to your help.

Now I want to capture the expanded and collapse event of the node; I tried to add to my listener to handle the event expanded
public void treeExpanded(TreeEvent e)

but without success.

Can you give me a help?
I think that once managed the expanded event correctly, handle the collapse event is similar. Correct?

Thanks in advance for your help
Re: Tree Box [message #1031764 is a reply to message #1028729] Tue, 02 April 2013 06:53 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Hi Marco

You might want to have a look at this howto: http://wiki.eclipse.org/Scout/HowTo/3.8/Expanding_and_collapsing_the_outline_tree

It covers other things that might not (yet) be of interest to you, but it should cover how a tree can be expanded and collapsed from code.
Re: Tree Box [message #1082949 is a reply to message #1014838] Fri, 09 August 2013 08:46 Go to previous messageGo to next message
Ranto ANDRIANJAFY is currently offline Ranto ANDRIANJAFYFriend
Messages: 7
Registered: July 2013
Junior Member
Hi All,

I would like to know if it is possible to use more than one table with the TreeBox with LookupCall?

In my case, I have two tables:

  1. Product (idProd*, nameProd, cat_idCat)
  2. Category (idCat*, nameCat)


I create a LookupCall (TreeCategoryLookupCall) to populate the Treebox, the getConfiguredSqlSelect() for the TreeCategoryLookupService is:
@Override
protected String getConfiguredSqlSelect() {
	return "SELECT "
	+ "p.idProd, "
	+ "p.nameProd, "
	+ "NULL, "
	+ "NULL, "
	+ "NULL, "
	+ "NULL, "
	+ "NULL, "
	+ "1, "
	+ "c.nameCat, "
	+ "1 "
	+ "FROM prod p, cat c "
	+ "WHERE c.idCat = p.cat_idCat";
}


But all I have is the list of all 'prod' items.
\--prod_item1
|
\--prod_item2
|
\--prod_item3
|
\--prod_item...

I want to have a structure like:
\Cat_item1
|         \--prod_item1
|         |
|         \--prod_item2
|
\Cat_item2
         \--prod_item3
         |
         \--prod_item...
Re: Tree Box [message #1082999 is a reply to message #1082949] Fri, 09 August 2013 10:14 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Your example is a very good start.

But you also need to produce LookupRows for "\Cat_item1" and "\Cat_item2".

The LookupService will construct the hierarchy of LookupRows for you if it finds the corresponing rows.

Assuming product Product.idProd and Category.idCat are in separate ranges (e.g. they do not overlap: category ids in range [0, 999] and product ids in range [1000, 9999]), you might be able to do something like this:

(pseudo SQL, I am not sure it is valid):
SELECT
p.idProd,
p.nameProd,
NULL,
NULL,
NULL,
NULL,
NULL,
1,
p.cat_idCat, -- here you provide the id of the parent lookuprow
1
FROM prod p
UNINON
SELECT
c.idCat,
c.nameCat,
NULL,
NULL,
NULL,
NULL,
NULL,
1, -- if you want to disable the "categories lookup rows" put a 0
NULL, -- categories do not have parents.
1
FROM cat c


If the ranges overlap, you need to add something (a prefix like "_cat" -> 'cat_'||p.cat_idCat and 'cat_'||c.cat_id) in order to disambiguate the ids.

I hope it helps.

Related wiki topic: Sql Lookup Service
Re: Tree Box [message #1083581 is a reply to message #1082999] Sat, 10 August 2013 05:48 Go to previous messageGo to next message
Ranto ANDRIANJAFY is currently offline Ranto ANDRIANJAFYFriend
Messages: 7
Registered: July 2013
Junior Member
Thank you, it really helped me.
Re: Tree Box [message #1355507 is a reply to message #1083581] Wed, 14 May 2014 19:17 Go to previous messageGo to next message
Tadeo Granese is currently offline Tadeo GraneseFriend
Messages: 4
Registered: May 2014
Junior Member
HI!

How i can do to refresh programatically a TreeBox?
Re: Tree Box [message #1356620 is a reply to message #1355507] Thu, 15 May 2014 06:34 Go to previous messageGo to next message
Matthias Nick is currently offline Matthias NickFriend
Messages: 197
Registered: August 2013
Senior Member
Hi Tadeo,
did not try it, but the TreeBox has a method
loadRootNode()

which loads the root node and all children, maybe this works.

What is your use case, why do you need to refresh it?

Best regards,
Matthias
Re: Tree Box [message #1357575 is a reply to message #1356620] Thu, 15 May 2014 15:37 Go to previous message
Tadeo Granese is currently offline Tadeo GraneseFriend
Messages: 4
Registered: May 2014
Junior Member
I 've a TreeBox (i don't know why, can i use another) that's call a form, this form add/modify a item node in a TreeBox.

Its works your solution!
Thanks Smile
Previous Topic:Retrieve a file client resources
Next Topic:LinkageError in Scout
Goto Forum:
  


Current Time: Thu Mar 28 13:40:56 GMT 2024

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

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

Back to the top