Search in sources :

Example 1 with ISupportCachedLocationAndSize

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);
}
Also used : JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize)

Example 2 with ISupportCachedLocationAndSize

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);
    }
}
Also used : ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(java.awt.Component) IFormatScriptComponent(com.servoy.j2db.ui.scripting.IFormatScriptComponent) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) TableColumn(javax.swing.table.TableColumn) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize)

Example 3 with ISupportCachedLocationAndSize

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);
        }
    }
}
Also used : IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Dimension(java.awt.Dimension) Point(java.awt.Point) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize) Point(java.awt.Point)

Example 4 with ISupportCachedLocationAndSize

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;
}
Also used : JComponent(javax.swing.JComponent) Point(java.awt.Point) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize)

Example 5 with ISupportCachedLocationAndSize

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);
}
Also used : Dimension(java.awt.Dimension) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize)

Aggregations

ISupportCachedLocationAndSize (com.servoy.j2db.ui.ISupportCachedLocationAndSize)5 Dimension (java.awt.Dimension)3 Point (java.awt.Point)3 JComponent (javax.swing.JComponent)3 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)2 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)1 IFormatScriptComponent (com.servoy.j2db.ui.scripting.IFormatScriptComponent)1 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1 TableColumn (javax.swing.table.TableColumn)1 JTextComponent (javax.swing.text.JTextComponent)1