GWT : cell tree and initial keyboard selected node - gwt

I'm using a CellTree with the KeyboardSelectionPolicy.BOUND_TO_SELECTION.
I'd like to open the tree with a given path selected.
The code opening the child path and selecting the node is working fine when KeyboardSelectionPolicy is ENABLED/DISABLED but when BOUND_TO_SELECTION I can see that the keyboard-selected-node in the tree is never updated from : cellTree.selectionModel.setSelected( ... )
So I'm wondering if setSelected can work with BOUND_TO_SELECTION and how to do it.

See http://code.google.com/p/google-web-toolkit/issues/detail?id=6310
I suppose you could find a way to call setKeyboardSelectedRow in response to SelectionChangeEvents.

Related

How to track down in which application is signal handler defined gtk/gtkmm for some button

The problem:
You wanna contribute to the some gnome/gtk/gtkmm project since you've noticed and know a way that things could be made better / you wanna fix some bug. Here are steps to get you started.
Example problem:
"Clean" button in Gnome Builder isn't doing anything to my project and since at this point I believe it is just empty function with placeholder button I wanna implement actual action.
Here are steps:
open application that you wanna modify in terminal where environment GTK_DEBUG=interactive environment variable is set. so run GTK_DEBUG=interactive gnome-builder
Gtk inspector should have opened and you should see bunch of Objects displayed. If you click on Object in inspector, that object should light up in your application
Gtk has clear hierarchy, so parent contains children, and your job is to detect in which parent is child that you want to modify
When you figure which parent you want click on arrow next to the name of that parent to reveal its children
Repeat steps 3. and 4. by applying 2. to get to the child that you want to modify
For example my path is IdePrimaryWorkspace -> GtkPopover -> GtkBox -> DzlPriorityBox -> GbpBuilduiOmniBarSection -> GtkBox -> GtkBox -> GtkButton
Double click last interactive entry (such as GtkButton
on the left, in drop-down switch to Properties view
find property that you want, mine is GtkActionable, and it's value is builder-manager.clean
open source folder in terminal of application that you are interested in (clone source of that application)
type in command tree | grep build-manager
if there are entries with that filename type in find . --name=filenameof.your.file
get file path, open that file in text editor/IDE, change stuff inside
submit patches

Locating TreeObject in large Tree

I have a large tree and I can 'select' (i.e.highlight) any node of it. But if I have a large tree with all nodes expanded the user still needs to manually scroll down or up in order to locate the highlighted element. Is there a way which not only highlights the selected element but also locates it by automatically scrolling up/down in the tree?
TreePath path = createTreePath(editorID, treeObject);
getTreeViewer().setSelection(new TreeSelection(path), true);
getTreeViewer().refresh();
getTreeViewer().jumpToSelectedElement(true); // I need something like this. I made up the name of this imaginary method.
Use
public void reveal(Object elementOrTreePath)
As its name suggests elementOrTreePath can be a tree path or just an element.

Changing node icon to "folder" when adding child in fancyTree

It seems to me that the standard behaviour in fancyTree, when adding child nodes is NOT to change the parent node to have a folder icon.
For example, see http://wwwendt.de/tech/fancytree/demo/index.html#sample-multi-ext.html and try adding a child node.
How is it possible to dynamically change the icon of the parent to a "folder" when adding a child?
I thought that I could apply renderTitle() to the parent node, but this did not do anything.
This question Dynamically change icon in fancy tree is similar, but (a) I could not get it to work, and also (b) I wanted a solution that didn't involve having to create new icons.
Folders may be empty, so this status is defined by node.folder = true (not by the fact that children are present or not).
So you could set node.folder and call node.render().
Note that setting an additional class may give the same effect, but may get lost when the tree is updated.
In jquery.fancytree.edit.js I added the following line
newNode.parent.addClass("fancytree-ico-ef");
The code snippet is as follows:
newNode.makeVisible(/*{noAnimation: true}*/).done(function(){
$(newNode[tree.statusClassPropName]).addClass("fancytree-edit-new");
self.tree.ext.edit.relatedNode = self;
newNode.parent.addClass("fancytree-ico-ef");
newNode.editStart();
});

Error thrown while trying to expand model in GXT tree grid

I am trying to expand a node(model bean) using the below command
gmisRevenueGross.setExpanded(revenueGrossBean, true);
but I get the below error
java.lang.AssertionError: null
at com.sencha.gxt.widget.core.client.treegrid.TreeGrid.setExpanded(TreeGrid.java:673)
at com.sencha.gxt.widget.core.client.treegrid.TreeGrid.setExpanded(TreeGrid.java:644)
The same code when I put inside a handler of button, I was able to expand the node. So I guess I am trying to expand before the dom is loaded. So is there a way to expand some nodes soon after adding it to store. For grid.setAutoExpand(true) works fine, but that expands all the node.
Just guessing, are you using GXT version 2? I think your problem was because you tried to expand the tree node before the tree grid was rendered. Check your code and make sure your tree grid was already rendered before expanding the tree node. Post your code so I can help you better.

Displaying forms using Tree in Qt

I'm building a Qt plugin with multiple forms. I have a main form which has a tree widget placed on the left of the form.
I want to add items to this tree, such that clicking on these items would load the corresponding form on the same form. But I want the tree widget to be active so that I can select any other form also.
I was able to display a form on the main form using the following code:
Form1 *myform;
myform=new Form1(this);
myform->show();
where Form1 is the class of the form i intend to display. However this, covers up the tree widget also. And I have to do a string comparison of the item in tree being clicked to display the appropriate form.
Can someone please help me with this as I'm very new to Qt programming.
Thanks
ixM has a good suggestion. The first step should definitely be to use layouts in your main window - separating the tree from the rest of the window - where you are going to put your form. I would suggest using a splitter, because then the user can resize the two halves. You can set the splitter as the main widget of your CentralWidget in your main window.
QSplitter splitter = new QSplitter(CentralWidget);
splitter->setOrientation(Qt::Horizontal);
splitter->setHandleWidth(3);
splitter->setChildrenCollapsible(false);
MyTree= new QTreeWidget(splitter);
splitter->addWidget(MyTree);
Then add your tree widget to the splitter, which will be on the left side.
The next step is to add a placeholder widget on the right side of your splitter. We are also going to add a layout inside that widget. This layout is very important we are going to use it later.
QWidget WidgetRightSide = new QWidget(splitter);
QVBoxLayout setupLayout= new QVBoxLayout(WidgetRightSide);
setupLayout->setSpacing(0);
setupLayout->setContentsMargins(0, 0, 0, 0);
Now, at this point, this is where my answer really differs from the previous answer. You could use a QStackedWidget. That is certainly an option. The problem with that is that you have to create and load all your forms at the beginning. That uses way more memory, and will take longer to start up. That's not so bad if you have 2-5 forms, but when we are talking about 20, 30 or more forms that's really ugly.
So what I would suggest instead, is that when the user selects something in the tree, we will remove the old form, and add the newly selected form at that point.
When the selected item in the tree changes this is now what we have to do.
First, remove all the stuff from the previously selection form.
QLayoutItem *_Item;
while ((_Item = setupLayout->takeAt(0)))
delete _Item;
Next, figure out what form to show next, and create it.
QWidget *ActiveSetupForm = NULL;
if ( I need to load form 1)
{
ActiveSetupForm = new YourNewForm( WidgetRightSide);
}
else ...
And lastly, add your new form to our layout.
if(ActiveSetupForm)
{
setupLayout->addWidget(pActiveSetupForm);
}
Just as a side note. Layouts are tricky to do by hand. I would strongly suggest that you look into using the QtDesigner when you are creating your forms. It makes life soooo much easier. If you would like to know more about it check out this link.
I don't exactly understand what you are trying to achieve but the bit of code you are showing suggests that you do not use the layouts provided by Qt.
If your goal is to be able to dynamically load a form depending on the item that was clicked in the tree, you could achieve that by having a layout (let's say QHBoxLayout) where you would insert your tree and a QStackedWidget in which you could "store" each form (by using addWidget()) and choose which one you want to display by calling setCurrentIndex().