Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 266970 - [CSS] Widget.setData keys should be qualified
Summary: [CSS] Widget.setData keys should be qualified
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 4.1   Edit
Assignee: Aghiles Abdesselam CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-03 23:11 EST by Kevin McGuire CLA
Modified: 2011-05-17 16:23 EDT (History)
0 users

See Also:


Attachments
.setData() now uses qualified names (10.93 KB, patch)
2009-03-11 14:12 EDT, Aghiles Abdesselam CLA
no flags Details | Diff
qualified updated (10.97 KB, patch)
2009-04-08 10:39 EDT, Aghiles Abdesselam CLA
john.arthorne: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin McGuire CLA 2009-03-03 23:11:23 EST
There are many cases where we use Widget.setData(keyString, value) to remember some CSS value.  See SWTElement for many examples.

These key strings are often of the form "active", "hover", etc.
They should be fully qualified to reduce conflicts since others may be using the widget's setData.  So should instead be:

"active" -> "org.eclipse.e4.ui.css.swt.active"
"hover" -> "org.eclipse.e4.ui.css.swt.hover"

Also, we should have final static fields to hold keys with these as values, eg.
in DynamicPseudoClassesSWTActiveHandler we would have

final static String WIDGET_ACTIVE_KEY = "org.eclipse.e4.ui.css.swt.activeLost"
Comment 1 Aghiles Abdesselam CLA 2009-03-11 14:12:42 EDT
Created attachment 128415 [details]
.setData() now uses qualified names
Comment 2 Kevin McGuire CLA 2009-04-07 16:09:24 EDT
You have copy/paste errors:

+	public static final String FOCUS_LOST = "org.eclipse.e4.ui.css.swt.selectors.FOCUS_KEY";


+	public static final String HOVER_LOST = "org.eclipse.e4.ui.css.swt.selectors.FOCUS_KEY";

	
+	public static final String HOVER_LISTENER = "org.eclipse.e4.ui.css.swt.selectors.FOCUS_KEY";


Identical key value repeated for all three keys.

Also this change looked odd:

-			return control.getData("mouseHover") != null;
+			return control.getData(CSSSWTConstants.HOVER_LOST) != null;

Shouldn't the constant have been called "MOUSE_HOVER" to match the existing value?  ie. did you intend on renaming it or is this an error?
Comment 3 Kevin McGuire CLA 2009-04-07 16:13:59 EDT
Also note inconsistent naming of vars vs. values e.g.

+       public static final String FOCUS_LOST =
"org.eclipse.e4.ui.css.swt.selectors.FOCUS_KEY";

This one used the word "key" in the value but not in the key, which seemed odd, but others didn't.
Comment 4 Kevin McGuire CLA 2009-04-07 16:19:42 EDT
Note that qualified key value strings should generally follow the package structure.  Specifically, you have:

   org.eclipse.e4.ui.css.swt.selectors.XXX

but that's not the package for CSSSWTConstants (ie. 'selectors'). 
Comment 5 Kevin McGuire CLA 2009-04-07 16:20:45 EDT
Please correct all these items and resubmit the patch.
Comment 6 Aghiles Abdesselam CLA 2009-04-08 10:39:40 EDT
Created attachment 131290 [details]
qualified updated
Comment 7 Kevin McGuire CLA 2009-04-08 11:07:08 EDT
I noticed the key names and values don't match for these:

	public static final String MOUSE_HOVER = "org.eclipse.e4.ui.css.swt.HOVER_LOST";
	
	public static final String MOUSE_HOVER_LOST = "org.eclipse.e4.ui.css.swt.HOVER_LISTENER";

Is this intentional, and if so why?
Comment 8 Kevin McGuire CLA 2009-04-15 15:01:26 EDT
Released to HEAD