public AttributePanelItem(AAttribute<?> attribute) {
this.attribute = attribute;
this.heightProperty().set(25);
HBox root = new HBox();
this.getChildren().add(root);
pnlName = new Panel();
pnlName.widthProperty().bind(new AExpression<Integer>() {
{
bind(clientWidthProperty());
}
@Override
public Integer calculate() {
return (clientWidthProperty().get() - 10) / 2;
}
});
pnlName.heightProperty().bind(heightProperty());
root.getChildren().add(pnlName);
// TODO make styleable
Label lblName = new Label();
lblName.textProperty().set(attribute.getName());
lblName.widthProperty().bind(pnlName.clientWidthProperty());
lblName.maxWidthProperty().bind(pnlName.clientWidthProperty());
lblName.translateYProperty().bind(new AlignMiddleExp(pnlName, lblName));
lblName.textOverflowProperty().set(ETextOverflow.ELLIPSIS);
pnlName.getChildren().add(lblName);
root.addEmptyCell(10);
pnlValue = new Panel();
pnlValue.widthProperty().bind(pnlName.widthProperty());
pnlValue.heightProperty().bind(heightProperty());
if (!attribute.isReadonly()) {
pnlValue.cursorProperty().set(ECursor.POINTER);
pnlValue.onClickEvent().addListener(new IEventListener<ClickEventArgs>() {
@Override
public void onFired(ClickEventArgs args) {
showEditor();
}
});
}
root.getChildren().add(pnlValue);
showValue();
}