use of com.servoy.j2db.server.headlessclient.dataui.TemplateGenerator.BorderAndPadding in project servoy-client by Servoy.
the class SortableCellViewHeader method setWidth.
public void setWidth(int width) {
int borderWidth = 0;
Iterator<IPersist> it2 = cellview.getAllObjects();
while (it2.hasNext()) {
IPersist element = it2.next();
if (id.equals(ComponentFactory.getWebID(form, element))) {
GraphicalComponent gc = (GraphicalComponent) view.labelsFor.get(((ISupportName) element).getName());
if (gc != null) {
TextualStyle styleObj = new TextualStyle();
BorderAndPadding ins = TemplateGenerator.applyBaseComponentProperties(gc, view.fc.getForm(), styleObj, (Insets) TemplateGenerator.DEFAULT_LABEL_PADDING.clone(), null, application);
if (ins.border != null)
borderWidth = ins.border.left + ins.border.right;
}
}
}
int headerPadding = TemplateGenerator.SORTABLE_HEADER_PADDING;
// If there is no label-for, we leave place for the default border placed at the right of headers.
if (view.labelsFor.size() == 0) {
int extraWidth = TemplateGenerator.NO_LABELFOR_DEFAULT_BORDER_WIDTH;
String headerBorder = view.getHeaderBorder();
if (headerBorder != null) {
Properties properties = new Properties();
Insets borderIns = ComponentFactoryHelper.createBorderCSSProperties(headerBorder, properties);
extraWidth = borderIns.left + borderIns.right;
headerPadding = 0;
}
borderWidth += extraWidth;
}
// we have only left padding
int clientWidth = width - headerPadding - borderWidth;
// if we have grid_style for the header, then don't change the header width
this.width = (view.labelsFor.size() == 0 && view.getHeaderBorder() != null) ? width : clientWidth;
StyleAppendingModifier widthStyleModifier = new StyleAppendingModifier(new Model<String>() {
@Override
public String getObject() {
// $NON-NLS-1$//$NON-NLS-2$
return "width: " + SortableCellViewHeader.this.width + "px";
}
});
add(widthStyleModifier);
headerColumnTable.add(widthStyleModifier);
labelResolver.setWidth(clientWidth - SortableCellViewHeader.ARROW_WIDTH);
getStylePropertyChanges().setChanged();
}
Aggregations