Project

General

Profile

Feature #2412

Implement widget browser

Added by Hynek Cihlar over 9 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
10/05/2014
Due date:
% Done:

100%

Estimated time:
16.00 h
billable:
No
vendor_id:
GCD

13.png (165 KB) Hynek Cihlar, 10/29/2014 07:48 PM

hc_upd20141031a.zip (46 KB) Hynek Cihlar, 10/31/2014 10:51 AM

hc_upd20141103a.zip (37.6 KB) Hynek Cihlar, 11/03/2014 03:10 AM

hc_upd20141118a.zip (35.9 KB) Hynek Cihlar, 11/18/2014 06:11 PM

hc_upd20141201b.zip (9.03 KB) Hynek Cihlar, 12/04/2014 05:44 AM

hc_upd20141221a.zip (7.38 KB) Hynek Cihlar, 12/21/2014 06:31 PM

hc_upd20150217a.zip (23.1 KB) Hynek Cihlar, 02/16/2015 08:15 PM

hc_upd20150217b.zip (13.1 KB) Hynek Cihlar, 02/17/2015 04:54 AM

History

#1 Updated by Hynek Cihlar over 9 years ago

  • Estimated time set to 16.00

The Widget browser should provide runtime insight into the widget hierarchy. The idea is to have some basic functionality quick: a Swing tree view showing widget tree structure, widget types, at least basic attributes and hopefully some bounds visualization in the live window.

See the email conversation below for more details.

On 5.10.2014 14:27, Greg Shah wrote:

Hynek,

I do think this will be enhanced over time. I can imagine this also providing views into:

- the event queue
- showing a trace of the event processing
- z-order
- layout/clipping rectangles (visually showing the outlines of the associated rectangles)
- showing a trace of the drawing

Use of reflection may allow all data from both the contained config instance and the widget itself to be displayed.

For now, do whatever you can do in 2 days. We can always enhance it later. I'd like this to work for both ChUI and GUI if possible. It is OK to add features to the driver interfaces if that is necessary.

Thanks,
Greg

On 10/04/2014 05:52 PM, Hynek Cihlar wrote:

Hi Greg,

I have an idea on my mind I want to share with you.

I already spent some time on modifying the widget layouts and from this short experience I think that some kind of widget browser would be useful. Having the widget tree structure, widget attributes and maybe the position in the parent container visualised during runtime would decrease the time spent in debugger.

It could be a very simple Swing component activated with a Java property. A tree view with the widget structure, some useful attributes shown for the selected item with the widget bounds highlighted. A matter of cca two days to pull together.

Thanks,
Hynek

#2 Updated by Hynek Cihlar over 9 years ago

  • Status changed from New to WIP

#3 Updated by Hynek Cihlar over 9 years ago

The task is nearly finished. I am attaching a screenshot of the browser in action.

I got a little stuck with the highlighting part. The drawing of the highlighted area itself is not a problem but I need to figure out how to invalidate the widgets (to trigger redraw to switch the highlight off) out of the regular event loop in ThinClient. The widget gets highlighted when a widget node is selected in the widget browser and this happens independently on the standard event processing. Anyway, I will investigate further.

#4 Updated by Greg Shah over 9 years ago

This is going to be invaluable! Well done.

#5 Updated by Hynek Cihlar over 9 years ago

Attached is the finished implementation. Supported are both GUI and ChUI while highlighting was implemented only for GUI.

Note that the highlight feature works based on the physical location and dimensions reported by the widgets and thus may be inaccurate with the actual screen buffer. I noticed that some widgets do report wrong coordinates.

Please review.

#6 Updated by Hynek Cihlar over 9 years ago

  • % Done changed from 0 to 90
  • Status changed from WIP to Review

#7 Updated by Greg Shah over 9 years ago

Code Review 1031a

This is super useful and well done. Most of the feedback is really minor style stuff.

1. I had really not been planning to extend the use of AspectJ at this time. My primary concern with using AspectJ is that it hides/obscures the relationship between the WidgetBrowser and the Widget.draw() method. In code that is important for production, I would probably want to implement this directly (we could always add a base draw() implementation to AbstractWidget and make sure that all subclasses call the super.draw() properly. However, for this use case I guess it is OK. Please do modify the build.xml to ensure that WidgetBrowserAspect is excluded from AspectJ by default. Enable it only when there is a command line flag like ant -Dwidget.browser=true.

2. In WidgetBrowser, please use WindowAdapter instead of new WindowListener(). That will eliminate most of the boilerplate.

3. Some of the new GuiSimulator data members need javadoc, as do the drawHighlightWorker() and clearHighlightWorker().

4. In GuiSimulator the drawHighlightWorker() and clearHighlightWorker() both need spaces on both sides of the minus operator.

5. Several of the files use explicit imports instead of wildcards.

6. There are no changes in ProcedureManager.

7. ContainerTree.WidgetWrapper.getProperties() has some opening curly braces that should be separated onto the next line.

#8 Updated by Hynek Cihlar over 9 years ago

Good idea with the ant script. I believe I resolved all the comments. In regards to AspectJ I think we share the same view. The reasons I used the aspect for launching Widget Browser were (1) the possibility for conditional compilation, (2) make it least dependent on the actual state of widget source codes (for example if somebody forgets to call base.draw(), Widget Browser will still work).

Please review.

#9 Updated by Greg Shah over 9 years ago

Code Review 1103a

The changes look good.

Since there are no conversion changes and the runtime changes are specific to GUI, I don't think regression testing will do anything useful for us here. You can go ahead and check in + distribute the change.

#10 Updated by Hynek Cihlar over 9 years ago

Committed to bzr revision 10641.

#11 Updated by Hynek Cihlar over 9 years ago

  • % Done changed from 90 to 100

#12 Updated by Greg Shah over 9 years ago

  • Status changed from Review to Closed

#13 Updated by Constantin Asofiei over 9 years ago

Hynek, a small problem related to highlightning the container's inner widgets: the coordinates of the child widgets are relative to the container, so these need to be translated to the origin; at this time, the child widgets are highlighted incorrect. AbstractWidget.screenLocation computes the widget's location relative to parent window, in character units.

#14 Updated by Hynek Cihlar over 9 years ago

Looking in the code I think you are right. I forgot to offset the NativePoint loc in WidgetBrowserAspect.highlightWidget. I will provide a fix, thank you!

#15 Updated by Constantin Asofiei over 9 years ago

Hynek, I think we need one more property to the widget details: the object's identity hash code, retrieved either by ObjectUtils.identityToString or by System.identityHashCode. This allows me to determine easily if two widgets with the same ID are the same instance or not.

For now, I've added this line to ContainerTree$WidgetWrapper.getProperties:

result.put("id", ObjectUtils.identityToString(widget));

#16 Updated by Hynek Cihlar over 9 years ago

The attached update
  • adds the object identity property,
  • fixes widget highlight - the coordinates are now relative to the screen,
  • changes the highlight color to red - the previous cyan was too close to the default widget color scheme,
  • fixes an NPE.

Please review.

Also I found another little issue. Sometimes the highlight doesn't have any effect or draws to a different window. The reason for this is the GuiDriver.selectWindow feature. When the highlight command is sent to the driver it may have selected a different simulator than the one belonging to the window originally used to resolve the output manager. I haven't figured out how to (at least temporarily) select the correct simulator while not interfere with the widget drawing itself. The usability workaround is to move the window or perform any user action that will trigger the selection of the proper simulator.

#17 Updated by Greg Shah over 9 years ago

Code Review hc_upd20141118a.zip

The changes look good.

1. How about changing the name of the new "id" property to "hashcode"? That way, it is less likely to be confused with the widget ID.

2. I am fine living with the select window bug for now.

I think the changes are safe enough to be checked in.

#18 Updated by Hynek Cihlar over 9 years ago

Greg Shah wrote:

1. How about changing the name of the new "id" property to "hashcode"? That way, it is less likely to be confused with the widget ID.

I think the idea was not to have a hashcode property in the property table but rather an id to be able to identify the object identity. System.identityHashCode is in this case an implementation detail. However I think it will anyway return unique ids on the used JVMs.

#19 Updated by Greg Shah over 9 years ago

I understand. My concern is that the result is just a number, which could easily be confused with "the" widget ID. By specifying that it is the hashcode or some other name, it is less likely to be confused by people that don't use the tool often.

#20 Updated by Hynek Cihlar over 9 years ago

True. I will rename it to hashcode then.

#21 Updated by Hynek Cihlar over 9 years ago

Committed to bzr revision 10659.

#22 Updated by Hynek Cihlar over 9 years ago

The attached file was committed to bzr revision 10671.

It contains the following changes to Widget browser.

- Widget config fields are displayed in the widget property table.
- Fixed cast exceptions when the progress program contained an alert box (or other klind of client window widgets not inheritied from the type Window).
- Other bug fixes.

#23 Updated by Hynek Cihlar over 9 years ago

Hynek Cihlar wrote:

The attached file was committed to bzr revision 10671.

It contains the following changes to Widget browser.

- Widget config fields are displayed in the widget property table.
- Fixed cast exceptions when the progress program contained an alert box (or other kind of client window widgets not inherited from the type Window).
- Other bug fixes.

#24 Updated by Hynek Cihlar over 9 years ago

The attached updates adds a couple of new features:
  • property table now contains all widget and its associated config fields,
  • property name filter,
  • if property value is a weak reference it is dereferenced.
  • property value string formatter recognizes more well-known types.

Please review.

#25 Updated by Greg Shah over 9 years ago

Code Review hc_upd20141221a.zip

Nice improvements! Please check these in.

#26 Updated by Hynek Cihlar over 9 years ago

1221a committed to bzr revision 10686.

#27 Updated by Hynek Cihlar about 9 years ago

The attached update extends Widget browser with the possibility to copy widget properties to clipboard. This is useful for example when comparing widget object trees or for full-text searching.

Please review.

#28 Updated by Greg Shah about 9 years ago

Code Review hc_upd20150217a.zip

1. PropertyTable needs a history entry. It also needs all of its hard-tab chars converted to spaces.

2. Did you plan to include the build.xml change?

#29 Updated by Hynek Cihlar about 9 years ago

Missing history entry added and converted tabs to spaces in the whole PropertyTable.java. build.xml removed as this should not be part of the changes to commit.

Please review.

#30 Updated by Greg Shah about 9 years ago

Code Review hc_upd20150217b.zip

It looks good. Please check it in.

#31 Updated by Hynek Cihlar almost 9 years ago

I have improved Widget Browser GUI highlight. Restoring the highlighted area was causing artifacts. Also the highlighted area was frozen for draw updates. The change is committed to task branch 2412a. Please review.

#32 Updated by Greg Shah almost 9 years ago

Code Review Task Branch 2412a Revision 10887

The changes are OK.

#33 Updated by Hynek Cihlar almost 9 years ago

The task branch 2412a was committed to trunk revision 10887.

#34 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 12 to GUI Support for a Complex ADM2 App

Also available in: Atom PDF