use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method distributeExtraSpace.
private void distributeExtraSpace() {
int totalDefaultWidth = 0;
int totalWidthToStretch = 0;
int stretchedElementsCount = 0;
for (IPersist element : elementToColumnIdentifierComponent.keySet()) {
Object scriptobject = elementToColumnIdentifierComponent.get(element);
if (!((Component) scriptobject).isVisible())
continue;
if (scriptobject instanceof IScriptableProvider) {
scriptobject = ((IScriptableProvider) scriptobject).getScriptObject();
}
if (scriptobject instanceof IRuntimeComponent) {
int width = ((IRuntimeComponent) scriptobject).getWidth();
totalDefaultWidth += width;
if (element instanceof ISupportAnchors) {
int anchors = ((ISupportAnchors) element).getAnchors();
if (((anchors & IAnchorConstants.EAST) != 0) && ((anchors & IAnchorConstants.WEST) != 0)) {
totalWidthToStretch += width;
stretchedElementsCount++;
}
}
}
}
boolean shouldFillAllHorizSpace = shouldFillAllHorizontalSpace();
if (shouldFillAllHorizSpace) {
if (stretchedElementsCount > 0) {
int delta = getDisplayBodyWidthHint() - totalDefaultWidth;
distributeExtraSpace(delta, totalWidthToStretch, null, true);
setHeadersWidth();
}
}
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class SortableCellViewHeader method applyStyleChanges.
private void applyStyleChanges(Component c, final Properties changes) {
StyleAppendingModifier headerStyles = new StyleAppendingModifier(new Model<String>() {
@Override
public String getObject() {
StringBuilder headerStyle = new StringBuilder();
Iterator<Entry<Object, Object>> headerStyleIte = changes.entrySet().iterator();
Entry<Object, Object> headerStyleEntry;
while (headerStyleIte.hasNext()) {
headerStyleEntry = headerStyleIte.next();
headerStyle.append(headerStyleEntry.getKey()).append(":").append(headerStyleEntry.getValue()).append(";");
}
return headerStyle.toString();
}
}) {
@Override
public boolean isEnabled(Component c) {
Iterator<IPersist> it2 = SortableCellViewHeader.this.cellview.getAllObjects();
while (it2.hasNext()) {
IPersist element = it2.next();
if (SortableCellViewHeader.this.id.equals(ComponentFactory.getWebID(SortableCellViewHeader.this.form, element)) && SortableCellViewHeader.this.view.labelsFor.get(((ISupportName) element).getName()) != null) {
return false;
}
}
return true;
}
};
c.add(headerStyles);
}
use of com.servoy.j2db.persistence.IPersist 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();
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class SortableCellViewHeader method applyInlineStyleString.
private void applyInlineStyleString(Component c, final String inlineCSSSting) {
StyleAppendingModifier headerStyles = new StyleAppendingModifier(new Model<String>() {
@Override
public String getObject() {
return inlineCSSSting;
}
}) {
@Override
public boolean isEnabled(Component c) {
Iterator<IPersist> it2 = SortableCellViewHeader.this.cellview.getAllObjects();
while (it2.hasNext()) {
IPersist element = it2.next();
if (SortableCellViewHeader.this.id.equals(ComponentFactory.getWebID(SortableCellViewHeader.this.form, element)) && SortableCellViewHeader.this.view.labelsFor.get(((ISupportName) element).getName()) != null) {
return false;
}
}
return true;
}
};
c.add(headerStyles);
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class SortableCellViewHeaders method isReorderableOrResizable.
private boolean isReorderableOrResizable() {
if (// $NON-NLS-1$
Utils.getAsBoolean(application.getRuntimeProperties().get("useAJAX"))) {
boolean isReorderable = false;
boolean isResizable = false;
Iterator<IPersist> iter = cellview.getAllObjects();
while (iter.hasNext()) {
IPersist element = iter.next();
if (element instanceof ISupportAnchors) {
int anchors = ((ISupportAnchors) element).getAnchors();
isResizable = ((anchors & IAnchorConstants.EAST) == IAnchorConstants.EAST) && ((anchors & IAnchorConstants.WEST) == IAnchorConstants.WEST);
isResizable = isResizable && (!(cellview instanceof Portal) || ((Portal) cellview).getResizable());
if (isResizable)
return true;
isReorderable = !(((anchors & IAnchorConstants.NORTH) == IAnchorConstants.NORTH) && ((anchors & IAnchorConstants.SOUTH) == IAnchorConstants.SOUTH));
isReorderable = isReorderable && (!(cellview instanceof Portal) || ((Portal) cellview).getReorderable());
if (isReorderable)
return true;
}
}
}
return false;
}
Aggregations