PDA

View Full Version : Title-Toolbar



tortexy
12 Feb 2010, 8:29 PM
I am using this small amendment for toolbar. On the left it looks like a header, but following the title it can include usual ToolBar items, as it actually being a toolbar.

Unfortunately if I change the theme, the xtb-title-text has to be changed too. Any idea how to make it - unnecessarily to be changed?




public class TitleToolbar extends ToolBar {

private TitleToolItem titleLabel = new TitleToolItem();

public TitleToolbar() {
super();
baseStyle += " x-panel-header title-toolbar";
}

public TitleToolbar(String title) {
this();
setTitle(title);
insert(titleLabel, 0);
}

@Override
public void setTitle(String title) {
titleLabel.setLabel(title);
}

}

public class TitleToolItem extends BoxComponent {

private String label;

public TitleToolItem() {

}

public TitleToolItem(String label) {
this.label = label;
}

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
if (rendered) {
el().update(Util.isEmptyString(label) ? " " : label);
}
}

@Override
protected void onRender(Element target, int index) {
setElement(DOM.createDiv(), target, index);
addStyleName("xtb-title-text");
setLabel(label);
super.onRender(target, index);
}
}

.title-toolbar {
height: 22px !important;
padding-top: 1px !important;
padding-bottom: 1px !important;
padding-left: 5px !important;
border-color:#99BBE8;
}
.title-toolbar .xtb-title-text{
color: rgb(21, 66, 139);
font-weight:bold;
font-family:tahoma, arial, verdana, sans-serif;
}

tortexy
12 Feb 2010, 8:36 PM
I use it like this:



TitleToolbar toolBar = new TitleToolbar("Szállítandó");
toolBar.add(new FillToolItem());

Button close = new Button("Lezár");
close.setIcon(icons.save());
close.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
getStoreManager2().saveItemList();
}
});
toolBar.add(close);