use of com.servoy.j2db.ui.ISupportCachedLocationAndSize in project servoy-client by Servoy.
the class AbstractRuntimeBaseComponent method setComponentSize.
protected final void setComponentSize(Dimension size) {
Dimension oldSize = getComponent().getSize();
// sets the component, changes recorder is not called here
if (getComponent() instanceof ISupportCachedLocationAndSize) {
((ISupportCachedLocationAndSize) getComponent()).setCachedSize(size);
}
getComponent().setSize(size);
if (getComponent() instanceof JComponent) {
((JComponent) getComponent()).validate();
}
sizeSet = true;
propertyChanged("size", size, oldSize);
}
use of com.servoy.j2db.ui.ISupportCachedLocationAndSize in project servoy-client by Servoy.
the class CellAdapter method onEditorChanged.
private void onEditorChanged() {
try {
table.setLayoutChangingViaJavascript(true);
ArrayList<CellAdapter> cellAdaptersList = new ArrayList<CellAdapter>();
Enumeration<TableColumn> columnsEnum = table.getColumnModel().getColumns();
TableColumn column;
while (columnsEnum.hasMoreElements()) {
column = columnsEnum.nextElement();
cellAdaptersList.add((CellAdapter) column);
}
for (CellAdapter ca : cellAdaptersList) table.getColumnModel().removeColumn(ca);
Collections.sort(cellAdaptersList, new Comparator<CellAdapter>() {
public int compare(CellAdapter o1, CellAdapter o2) {
Component editor1 = o1.getEditor();
Component editor2 = o2.getEditor();
Point p1 = ((editor1 instanceof ISupportCachedLocationAndSize) ? ((ISupportCachedLocationAndSize) editor1).getCachedLocation() : editor1.getLocation());
Point p2 = ((editor2 instanceof ISupportCachedLocationAndSize) ? ((ISupportCachedLocationAndSize) editor2).getCachedLocation() : editor2.getLocation());
return PositionComparator.comparePoint(true, p1, p2);
}
});
for (CellAdapter cellAdapter : cellAdaptersList) {
cellAdapter.updateEditorX();
cellAdapter.updateEditorWidth();
cellAdapter.resetEditorSize();
table.getColumnModel().addColumn(cellAdapter);
}
} finally {
table.setLayoutChangingViaJavascript(false);
}
}
use of com.servoy.j2db.ui.ISupportCachedLocationAndSize in project servoy-client by Servoy.
the class TableView method updateComponentBounds.
protected void updateComponentBounds(Component component, Rectangle cellRect, boolean sizeChanged, boolean locationChanged) {
int height;
int y;
if (component instanceof ISupportCachedLocationAndSize) {
Dimension cachedSize = ((ISupportCachedLocationAndSize) component).getCachedSize();
height = ((cachedSize != null) ? cachedSize.height : 0);
Point cachedLocation = ((ISupportCachedLocationAndSize) component).getCachedLocation();
y = ((cachedLocation != null) ? cachedLocation.y : 0);
} else {
height = component.getHeight();
y = component.getY();
}
if (sizeChanged) {
if (component instanceof IScriptableProvider && ((IScriptableProvider) component).getScriptObject() instanceof IRuntimeComponent) {
((IRuntimeComponent) ((IScriptableProvider) component).getScriptObject()).setSize(cellRect.width, height);
} else {
component.setSize(cellRect.width, height);
}
}
if (locationChanged) {
if (component instanceof IScriptableProvider && ((IScriptableProvider) component).getScriptObject() instanceof IRuntimeComponent) {
((IRuntimeComponent) ((IScriptableProvider) component).getScriptObject()).setLocation(cellRect.x, y);
} else {
component.setLocation(cellRect.x, y);
}
}
}
use of com.servoy.j2db.ui.ISupportCachedLocationAndSize in project servoy-client by Servoy.
the class AbstractRuntimeBaseComponent method setLocation.
public void setLocation(int x, int y) {
Point newValue = new Point(x, y);
Point oldValue = new Point(getLocationX(), getLocationY());
if (!newValue.equals(oldValue)) {
getComponent().setLocation(newValue);
getChangesRecorder().setLocation(x, y);
if (getComponent() instanceof JComponent) {
((JComponent) getComponent()).validate();
}
propertyChanged("location", newValue, oldValue);
}
if (getComponent() instanceof ISupportCachedLocationAndSize) {
((ISupportCachedLocationAndSize) getComponent()).setCachedLocation(new Point(x, y));
}
locationSet = true;
}
use of com.servoy.j2db.ui.ISupportCachedLocationAndSize in project servoy-client by Servoy.
the class CellAdapter method resetEditorSize.
private void resetEditorSize() {
Dimension size;
if (editor instanceof ISupportCachedLocationAndSize) {
size = ((ISupportCachedLocationAndSize) editor).getCachedSize();
} else {
size = editor.getSize();
}
CellAdapter.this.setPreferredWidth(size != null ? size.width + table.getColumnModel().getColumnMargin() : 0);
}
Aggregations