Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332391

Summary: Marker support does not work properly when used with RAP
Product: [RT] Riena Reporter: Jürgen Becker <juergen.becker>
Component: UIAssignee: Project Inbox <riena.core-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: christian.campo, elias, nobody
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch for project org.eclipse.riena.ui.swt.rap, adds a new marker support
none
Patch for project org.eclipse.riena.ui.swt.rap, improved marker support
none
Patch v2
none
Patch for project org.eclipse.riena.ui.swt.rap, improved validation support none

Description Jürgen Becker CLA 2010-12-12 07:32:40 EST
Created attachment 185029 [details]
Patch for project org.eclipse.riena.ui.swt.rap, adds a new marker support

Both marker support types ("defaultMarkerSupport", "borderMarkerSupport") do not work properly with RAP.

I created a new marker support type ("rapMarkerSupport") which uses RAP CSS to visualize the markers. The idea is to add a CSS class to the Ridget via
setData(...). RAP currently does not support arbitrary dynamic CSS classes for widgets. The only way to set a CSS class dynamically is:
   control.setData(WidgetUtil.CUSTOM_VARIANT, "classname")

To make use of the class I added a RAP theme extension with some styles (theme1/ror-extensions.css). 
From the above example a style could look like this:
Button.classname {
	border: 2px solid red;
}

Since we have only one dynamic CSS class available, we have to encode all marker states in different classes.
For example: We have a Ridget with the "Error" and the "Mandatory" marker, but no "Output" marker. We encode (simple and rough) the states to a CSS class named "EMo". Capital letters stand for active markers, lower case for missing markers.
Button.EMo {
	border: 1px solid red;
	background-color: rgb(255, 255, 175);
}

I attached a patch for this solution. It should be used for evaluation only. Enjoy :)
Comment 1 Jürgen Becker CLA 2010-12-14 10:16:15 EST
Created attachment 185140 [details]
Patch for project org.eclipse.riena.ui.swt.rap, improved marker support

Added support for "disable" and "hidden" marker.

The "error" marker should now work for all ridgets.

For evaluation use only.
Comment 2 Elias Volanakis CLA 2010-12-17 03:12:56 EST
Hi Juergen,

I've been playing around with the patch for a bit.

The approach looks good to me (extending the theme, using widget variants). Drawback so far is that it's not very stable. The longer one plays with the marker example the less things work. I'm investigating this and will add more detail shortly.

Here are some things I've found. Let me know if I missed something.

- strange: mandatory markers do not show everywhere when applied the first time, better on 2nd time
- strange: after checking/unchecking on marker type (example mandatory), check another type (example disabled) -> no effect on most widgets
- strange: if one starts checking / unchecking stuff less and less markers work

- output markers cannot be removed from Text widgets
- output/mandatory markers missing n Combo, CompletionCombo, CCombo, ChoiceComposite (single, multi), DatePickerComposite
- output marker missing on Table
- error marker: border size not always the same, some widgets have thicker borders, seems random
- disabled marker: Numeric/Decimal text fields do not clear (likely the typed listener issue)
- disabled marker: DatePickerComposite does not change background

- combinations of markers do not work as xpected
  -- mandatory + output -> no effect
  -- after enabling mandatory + output and disabling them, other marker settings act strange

- widget background not uniform - text: gray background, list/tree table: gray/white alternate, tree: white, combo: white >> RAP theming bug?
Comment 3 Elias Volanakis CLA 2010-12-20 01:55:34 EST
Created attachment 185516 [details]
Patch v2

I've avoided most of the issues from the previous comment by using a simplified version of the previous patch. RAPMarkerSupport only changes the error marker behavior to use a custom variant (border 2px). Otherwise it relies on the default code for the other markers. From my POV this works better. 

@Juergen: Let me know if you think we can commit this.
Comment 4 Jürgen Becker CLA 2010-12-23 03:53:17 EST
@Elias

Yes, your version works much better.

Without the workaround for removing and adding the listeners in TextRidget.forceTextToControl(...) the update of the Ridget backgrounds did not happen. After I found a workaround I did not test the old MarkerSupport, which works better than the CSS hack.

I think we should apply your patch - it works much better.

Comparing the SWT Marker demo from the Playground with the RAP version, I found two differences. When I check "mandatory" the buttons "ToggelA" and "ToggleB" still have the old background, not yellow. And the List as an odd/even coloring, not completely yellow.
Comment 5 Jürgen Becker CLA 2010-12-23 10:36:29 EST
We still have a problem. The error marker which es set by the validation uses the jface ControlDecoration class. The marker is shown as a little red star on the left side oft the control. e.g. in the Playground Validation demo.

I think the code from MarkerSupport.flash() will not work properly under RAP. It uses a thread and removes the marker during a display.syncExec(...). RAP does not know about the thread and its async UI updates, so most of the time the change will not be propagated to the browser.

We have to find a new Solution for MarkerSupport.flash().

My experiments with SWTUISynchronizer as a replacement for the thread does not work 100% of the time. I will investigate further.
Comment 6 Christian Campo CLA 2010-12-23 10:45:19 EST
Not sure but I thought we use flash only in special cases. In general error marker is set and thats it. So for controldecoration its a red cross and for the border marker support (I believe the default) its a red border around a field. Flash is only used for Numeric TextField and DateTextField where a character that is input is not consumed but rejected.

Still the error exists as you describe but I believe only for those two fields which dont work very well in RAP anyway. So maybe we have to rewrite them anyway for RAP. Or do you know which ridgets are using the flash functionality ?

(In reply to comment #5)
> We still have a problem. The error marker which es set by the validation uses
> the jface ControlDecoration class. The marker is shown as a little red star on
> the left side oft the control. e.g. in the Playground Validation demo.
> 
> I think the code from MarkerSupport.flash() will not work properly under RAP.
> It uses a thread and removes the marker during a display.syncExec(...). RAP
> does not know about the thread and its async UI updates, so most of the time
> the change will not be propagated to the browser.
> 
> We have to find a new Solution for MarkerSupport.flash().
> 
> My experiments with SWTUISynchronizer as a replacement for the thread does not
> work 100% of the time. I will investigate further.
Comment 7 Jürgen Becker CLA 2010-12-27 08:23:27 EST
I think all ridgets with custom or default validation are affected. 

As far as I know MarkerSupport.flash() is currently only used for the error marker from the validation.

I found a solution to make the control decoration work. The patch, which includes Elias changes, is attached.
Comment 8 Jürgen Becker CLA 2010-12-27 08:24:00 EST
Created attachment 185834 [details]
Patch for project org.eclipse.riena.ui.swt.rap, improved validation support
Comment 9 Elias Volanakis CLA 2011-08-03 14:35:10 EDT
Ressigning to default assignee. Not working on Riena right now.
Comment 10 Elias Volanakis CLA 2011-08-03 14:35:16 EDT
Reassigning to default assignee. Not working on Riena right now.