Friday, April 24, 2015

Re: LESS/ SASS/... style usage in GWT ?

Concerning the Theming part: I did a gwt project like @Jens explained and works well.

Details: like @Jens mention, retrieve values (often: colors, logos, etc.. and not layout like height/width) from static java files. The static java (preference bridge) class will then forward the call to a contained java (preference) class that it loads through GWT, as such that in GWT config you specify the file that it need to load -> Theming ;)... Works well, another GWT config file results in another (client) theme.

Below Some copy/paste code to make it more clear (the Css part is like Jens mentioned above). It concern a Standard theme that has a corresponding Standard.gwt.xml file. So every client/theme would have it's own gwt xml file. The Theme file you include in your app and compile it... So in Maven you can define different gwt compiler jobs for every Theme... 
Works well for white label kind of web apps..

The bridge class (I think I posted it before in the GWT forum some years ago):
----
public final class ActivateCodePreferencesBridge implements ResourcesPreferencesBridge {

private static final ActivateCodePreferences BRIDGE = GWT.create(ActivateCodePreferences.class);

private ActivateCodePreferencesBridge() {
}

private static ActivateCodePreferences getBridge() {
return BRIDGE;
}

public static String activateFontColor() {
return getBridge().activateFontColor();
}

public static String activateFontWeight() {
return getBridge().activateFontWeight();
}

public static String activateFontSize() {
return getBridge().activateFontSize();
}
}

----

An implementation of the Preference instance:
----------
public final class StandardActivationCodePreferences extends AppStandardPreferencesBase implements ActivateCodePreferences {

public String activateFontColor() {
return color006699();
}

public String activateFontWeight() {
return fontWeightBold();
}

public String activateFontSize() {
return fontSize14();
}
}

----------

And the GWT config Standard.gwt.xml:
------------
<module>
   <replace-with class="com.bla.standard.StandardActivateCodePreferences">
      <when-type-is class="com.bla.ActivateCodePreferences" />
   </replace-with>
</module>
------------

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment