PDA

View Full Version : listener



jocy
25 Jan 2010, 7:11 AM
good morning everybody,

i am new on this forum and i am francophone so please excuse me i haven't right questions and a poor english.:D

my problem is that to learn more about EXT GWT technology i decide to do a small example with a treepanel, a treestore and modeldata;

and i want to open a tab when i click on a item(modeldata) :-?of my treestore but i couldn't because modeldata doesn't have addlistener method and then i don't what else i can do.:((

thanks for your reply:s

becevka
25 Jan 2010, 7:38 AM
Normally no one can click on data - because data is just data. You can add SelectionChangeListener to your treePanel.getSelectionModel().

jocy
25 Jan 2010, 8:13 AM
i will try your proposition,

but it is possible i don't know if it is call data or store
i want to do something like the EXT main page were we can see some demo and their source code.

in the page there is to frame:
the westside is a treestore in a treepanel and the eastside is a tabpanel
When you click on an example(a store of the treepanel) in the westside the correspond tabitem is open in the tabpanel at your eastside.

i don't know if it is clear now!!!!

"is to difficult to explain his problem in a language different of yours":(B)

micgala
25 Jan 2010, 9:07 AM
It was clear since the beginning.

What becevka tried to say, is that you don't listen for "Data" clicks, because this is behind the curtains...

You always listen for component events...
In this case, treePanel.getSelectionModel()

There you can add your listener.

Regards,
Michel.

jocy
26 Jan 2010, 1:00 AM
thanks for your reply i try this::-?

tree.getSelectionModel().addSelectionChangedListener(
new SelectionChangedListener<item1>() {

public void selectionChanged(
SelectionChangedEvent<item1> se) {
addTab();
}

}
);

tree: is my treepanel
item1: is an item (modeldata type)
add(): is a method that i create for adding (sorry:D) a new tabitem in my tabpanel

so i want that after a click on "item" a tabitem is create in my tabpanel.

but there is an error i must use "se" and i don't know how???:s

becevka
26 Jan 2010, 3:29 AM
se.getSelectedItem() to get your item.

jocy
26 Jan 2010, 5:26 AM
tree.getSelectionModel().addSelectionChangedListener(
new SelectionChangedListener<item1>() {

public void selectionChanged(
SelectionChangedEvent<item1> se) {
addTab();
se.getSelectedItem();
}

}
);

there is always error over:

-addSelectionChangedListener: The method addSelectionChangedListener(SelectionChangedListener<ModelData>) in the type AbstractStoreSelectionModel<ModelData> is not applicable for the arguments (new SelectionChangedListener<item1>(){})

-SelectionChangedListener<item1>(): The type new SelectionChangedListener<item1>(){} must implement the inherited abstract method SelectionChangedListener<item1>.selectionChanged(SelectionChangedEvent<item1>)

-selectionChanged(SelectionChangedEvent<item1> se): Name clash: The method selectionChanged(SelectionChangedEvent<item1>) of type new SelectionChangedListener<item1>(){} has the same erasure as selectionChanged(SelectionChangedEvent<M>) of type SelectionChangedListener<M> but does not override it

i don't know why and what are their meaning????

micgala
26 Jan 2010, 6:01 AM
Hi.
Are you new to Java?

Instead of using <item1>

You should use <NameOfYourModelDataClass>

For example <ModelData>

Regards,
Michel.

jocy
26 Jan 2010, 6:08 AM
yes i am new in java,
ok i tried your idea and error are gone
but hadn't try if it does want i want so see you after

jocy
26 Jan 2010, 6:16 AM
coooooooool
very thanks it is working!
even if it is not working very well i will try to arrange other mistake myself for the moment if i can't
i will it post the problem

thank you.
code:
tree.getSelectionModel().addSelectionChangedListener(
new SelectionChangedListener<ModelData>() {

public void selectionChanged(
SelectionChangedEvent<ModelData> se) {

addTab();
se.getSelectedItem();

}

}
);

Arno.Nyhm
26 Jan 2010, 10:24 AM
one tip: in the gxt zip package is also the full code of the /samples/explorer (which you can see here: http://www.extjs.com/examples/explorer.html )

there you can see exactly how to open tabs from the tree :-)

jocy
28 Jan 2010, 1:31 AM
ok, thanks Arno.Nyhm for your suggestion but there isn't what you say, there is just a small picture over BorderLayout but when i open it is another one which is open.

Arno.Nyhm
28 Jan 2010, 8:19 AM
the tree you ask for is in this class:

com.extjs.gxt.samples.explorer.client.mvc.NavigationView

in this path:
samples/explorer/src/

jocy
28 Jan 2010, 9:11 AM
thanks!!!