• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

set primaryStyleName and css

 
peter tong
Ranch Hand
Posts: 248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when create project, the css file already contains some predefined css class like
.gwt_VerticalSplitPanel .splitter{
......
}

but is it necessary to explicit call the

when create a VerticalSplitPanel?

I have this doubt because I found sometimes even the widget (e.g. treee, treeitem) has not explicit call setStylePrimaryName, it can still automatically refer to the corresponding css class in css file,
but some cannot (like gwt-HorizontalPanel).
 
Maneesh Godbole
Saloon Keeper
Posts: 11312
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These components call the setStyleName("styleName") when they are initialized. You do not need to make explicit calls yourself.
 
peter tong
Ranch Hand
Posts: 248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:These components call the setStyleName("styleName") when they are initialized. You do not need to make explicit calls yourself.


I found it quite confusing.
when new a gwt project, the default css file has some style class for some component but not all.
for example, TabBar has corresponding css class in css file as follow:


but some component like DockPanel has no default css class in the css file.
if I add the style class in css as follow:


and then write the following code:


I found the following result

tabBar1.getStylePrimaryName() = gwt-TabBar
dockPanel1 primaryStyleName =
dockPanel1 primaryStyleName = gwt-DockPanel


that is, if the css file default has that classname, then when create the widget, the component will automatically set their stylePrimaryName corresponding to the css file,
but if the widget has no default css style class in css file and we add it manually, then even using their naming convention "gwt-"+ WidgetName, the widget still cannot automatically set
their stylePrimaryName.

is it normal behavior of gwt?
 
steve claflin
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not all widgets use primary styles, in particular many panel types. For HorizontalPanel, there is nothing that would need to be set for its style for general use. And it wouldn't necessarily be good for Google to have set a primary style, since the same class might be used multiple times within an app for totally different purposes. BTW, the Javadocs usually list the styles used by a widget (but unfortunately, not always). But, if there is no rule in the CSS, then GWT isn't going to bother setting a primary style.

If you want a primary style for a DockPanel, you can either manually set it for each instance, as you did, or extend DockPanel with a new class that sets its own primary style with its own name.
 
peter tong
Ranch Hand
Posts: 248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

or extend DockPanel with a new class that sets its own primary style with its own name.


Possible to set primary stlye with class?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic