how to do mouse binding in hierarchical table - eclipse-plugin

i want to register action on Mouse down for hierarchical table, even if i register it doesn't seems to be working it always taking the SelectCellAction on mouse down. i created Hierarchical table referring Hierarchicaltreelayerexpale from nattable examples.
the mouse binding i used
uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.NONE),
new action(selectionLayer));
could any please tell me y it is not working.

The HierarchicalTreeLayerExample you are referring to does not have a row header. Therefore a mouse binding for the row header will not have any effect.
Instead you need to use a CellLabelMouseEventMatcher for the HierarchicalTreeLayer.LEVEL_HEADER_CELL like this:
uiBindingRegistry.registerFirstMouseDownBinding(
new CellLabelMouseEventMatcher(
GridRegion.BODY,
MouseEventMatcher.LEFT_BUTTON,
HierarchicalTreeLayer.LEVEL_HEADER_CELL),
new NoOpMouseAction());
Note that the selection handling is configured in the SelectionLayer and the SelectCellAction is registered on mouse down. So registering on single click will also not work, as the selection is triggered before.

Related

Condition in Event Structure Labview

Hi Guys,
I have in my labview project the needs to use the same prev/next buttons with different tab controls, so I tried to put the value change of those buttons in an event structure but I would to put in AND condition the availability of the current tab.
Any Idea??
Thank you very much.
Guido
You have to consider using Dynamic Registering for Events: http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/dynamic_register_event/
You should create Dynamic event register and when tab control state is enabled/visible you will generate user event.
For example please refer to NI Example Finder and open "User Event Generation.vi"
Hope this helps!
If you use property nodes for the tab controls, you can use the equality primitive to confirm whether the currently active tab is the one your event should handle. By adding more checks or processing, you can eliminate false positives.
Example
Apologies for the bad wiring, the snippet tool mutated the block diagram.

Parent form and child User Control communication in WinForms

I have my form with a menu bar and space underneath to display my controls. One of the buttons in my menu bar is suppose to be a print button that prints a graph that's currently in a User Control I display in the form. If the graph was on the form in the print button's eventhandler I could just simply call
graph.printing.print(true)
which isn't going to work in my case since the graph is in the control and not the form.
How do I communicate with a User Control from the containing form and access or pass its variables when needed? I also have a status bar on the bottom of the form which would also need to get updated from the User Control, but I'll be able to deal with that if I got help with just this one part. Please bear in mind, I also have another User Control I'm going to add to the form which will also contain a graph which will need the same treatment as the other graph on the first control when the print button is pressed. I plan on swapping these two out so I have one form displaying one control at a time.
I got this idea from this answer: https://stackoverflow.com/a/18191630/2567273 but after further research I can't find anyone asking about the actual communication process between a form and the control it contains.
I think this answer is close to what I'm looking for, but I think it's leading me down the path to using panels instead of User Controls.
After typing this I noticed the closest answer to my question may be this, but that question has the child raising events and the parent responding while I have the parent raising the event and the parent has to get information from the child.
One way to think about this is Roles. Presumably you built this UserControl to handle the management of the data related to the graphs. As such you can think of them in the Role of a Graphs Specialist . Once you do that, printing them is actually just one more thing it should perhaps do.
The form on the other hand, is not special just because it happens to get receive the command from the user to print. Its role in this might simply to be to know which usercontrol to contact and which method to invoke:
Sub PrintGraphMenuClick....
Select Case something ' determinant as to which UC to contact
Case operation.Foo
ucFoo.PrintGraph
Case operation.Bar
ucBar.PrintGraph
Other menu options like Clear, NewGraph, Save and whatever else there is somewhat the same way. The Form's Role here may be to receive the command from the user and pass it along to the right control, invoking the correct right method and passing the correct parameters - that is not a trivial task.
Of course, rather than a MainMenu, the usercontols could alternatively implement a ContextMenu and even receive those commands directly.
Very often offloading an operation to something else results in so many properties, filenames, streams etc having to be moved from here to there that it becomes burdensome. In this case it is not like the MainForm has some special ability regarding printers that the UserControl cannot handle.
There is only one right solution:
1) Add an event to your user control.
2) Raise the event when the particular "thing" happens in the user control.
3) Attach a handler to the event in Form code.
4) Add code to update the bottom bar in the event handler.

Domain object "Changed" event fires multiple times?

I have a custom window to display various objects from the input tree. Once an object is checked on the input tree and displayed in the window, I subscribe to the object's "Changed" event. I am absolutely sure that I did not subscribe to the event more than once. The problem I'm seeing is when I make changes to the object, such as color, the event fires 3 times.
pseudocode:
- Draw a borehole in a custom window<br />
- borehole.Changed += borehole_Changed<br />
- Change the color of the borehole<br />
- See event fire 3 times (I just added debug prints)
Edit:
I have noticed that just opening the settings and clicking "ok" without changing anything causes the 3 events to be fired. So now I assume it actually has nothing to do with changing the color.
I have also tried checking the DomainObjectChangeEventArgs PropertyNames property, but that is always empty.
It looks like the Changed event is being phased out in favor of ColorInfo.ColorChanged, ImageInfo.ImageChanged, etc. In fact, the Changed event is not fired anymore as of 2011 for color changes. Turns out that there were other things underlying that caused the event to fire.
Anyways, to make a long story short, don't use the Changed event.
I can't confirm this behavior, I only get one event - can you please tell us which version you are using? And - are you changing the color via code or via the settings page?
In my case I got a single callback in both cases.
Thanks
I am getting one event also. I am using 2011.1 and the ColorChanged event from the ColorInfo for the Borehole.
In other cases I do see multiple events, but these happen when the data changed triggers changes to other Borehole related data. For example, changing the KB will cause lots of underlying calculations and result in multiple event triggers.

Silverlight DataGrid selection and drag-drop

I am currently implementing drag and drop using the DataGrid provided in the Silverlight SDK and I want the user to be, easily, able to drag multiple items to another list.
The grid's selection gets updated on the MouseDown event so the only way the user have to drag multiple items is to press Shift while begining the drag operation. This is not really obvious and, for me, the natural way whould have been to just click the selected block of rows and drag them. To do so, the selection needs to be updated on the MouseUp event.
I've tried to derive from the DataGrid to inject my custom DataGridRows but the DataGrid doesn't expose a way to replace the type of rows it creates.
Anyone have a solution or ideas for this?
Thank you,
Jacques.
Yes, it's unfortunate that the selection is updated on mousedown. You will need to perform some work in the mousedown event to work around this. This codeproject article should help:
http://www.codeproject.com/Tips/338594/Drag-drop-multiple-selected-rows-of-datagridview-w

Connecting two DialogBoxes in GWT

In my GWT project, I'm trying to get it so two DialogBoxes can pass information between each other. One of them holds a MapWidget, and when a button is pressed in the other DialogBox, the position information is received from that other DialogBox's MapWidget. Does anyone have any tips for how I should coordinate between having two different DialogBoxes show up? Should I wrap the code for the two in a Composite? Furthermore, is there an example anywhere of dealing with two DialogBoxes at once in GWT? For example, if I click outside of the two boxes, both should be dismissed. I'm wondering if there's a way to keep both of them in focus at once, so I can switch between the two without causing either to disappear.
Sharing Data Between Dialog Boxes
In my opinion, the "correct" way to do this would be to implement some sort of MVP structure in the application so that a presenter manages the view (DialogBoxes, among other things) and knows how to pass simple data to the view for it to display (the presenter would handle the MapWidget data, the view would take care of displaying it on the DOM).
However, if you're looking for a quicker/more simpler approach, you have a couple of options (which you choose really depends on the application structure):
Create a Composite, as you mentioned, that knows how to pass the necessary data back and forth. By having the Composite manage the data object and tell the two DialogBoxes how to display it, you are actually approaching an MVP architecture within your Composite.
Subclass DialogBox into a class that contains a HandlerManager (sometimes used as an "Event Bus") that fires events when the button is pressed. You can create events that are designed to pass data back and forth between the two DialogBoxes (even make them type-safe with type parameters). See this StackOverflow question for details on using a HandlerManager. The MVP article, linked above, also has some good information on using an event bus.
Model-View-Presenter is a tried-and-true method of structuring an application that results in more testable code, better project structure, and can help guide you when making decisions like this. I strongly recommend checking it out if you haven't already.
Sharing Auto-Hide Functionality
GWT's PopupPanel (on which DialogBox is based) offers a method addAutoHidePartner(Element) which is describe thusly:
Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.
So, you can create two auto-hiding DialogBoxes that only close when you click outside both of them (e.g., they do not close when you click within either of the boxes) with the following code:
// Create the dialog boxes
DialogBox dbox1 = new DialogBox(true, false);
DialogBox dbox2 = new DialogBox(true, false);
// Set some visual options
dbox1.setPopupPosition(10, 10);
dbox2.setPopupPosition(200, 10);
dbox1.setAnimationEnabled(true);
dbox2.setAnimationEnabled(false);
// Set the dialog boxes' caption and content
dbox1.setHTML("Dialog Box 1");
dbox2.setHTML("Dialog Box 2");
dbox1.setWidget(new HTML("This is the first dialog box."));
dbox2.setWidget(new HTML("This is the second dialog box."));
// Making dobx2 a partner of dbox1 means clicking
// in dbox2 won't cause dbox1 to close
dbox1.addAutoHidePartner(dbox2.getElement());
// Similarly, setting dbox1 as a partner of dbox2 means
// clicking in dbox1 won't cause dbox2 to close
dbox2.addAutoHidePartner(dbox1.getElement());
// Show the dialog boxes
dbox1.show();
dbox2.show();
You can interact with either of the dialog boxes without the other closing. Omit the appropriate call to setAutoHidePartner if you only want a one-way partnership.