Search in sources :

Example 1 with IStylePropertyChanges

use of com.servoy.j2db.ui.IStylePropertyChanges in project servoy-client by Servoy.

the class WebImageBeanHolder method getStylePropertyChanges.

/**
 * @see com.servoy.j2db.server.headlessclient.dataui.WebBaseButton#getStylePropertyChanges()
 */
@Override
public IStylePropertyChanges getStylePropertyChanges() {
    IStylePropertyChanges changes = super.getStylePropertyChanges();
    if (!lastChanged) {
        testChanged();
        if (!changes.isChanged() && lastChanged) {
            changes.setChanged();
        }
    } else {
        changes.setChanged();
    }
    // $NON-NLS-1$
    boolean useAnchors = Utils.getAsBoolean(application.getRuntimeProperties().get("enableAnchors"));
    if (useAnchors) {
        // $NON-NLS-1$
        if ((anchoring & (IAnchorConstants.EAST | IAnchorConstants.WEST)) != 0)
            changes.getChanges().remove("width");
        // $NON-NLS-1$
        if ((anchoring & (IAnchorConstants.NORTH | IAnchorConstants.SOUTH)) != 0)
            changes.getChanges().remove("height");
    }
    return changes;
}
Also used : IStylePropertyChanges(com.servoy.j2db.ui.IStylePropertyChanges)

Example 2 with IStylePropertyChanges

use of com.servoy.j2db.ui.IStylePropertyChanges in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method checkForValueChanges.

protected void checkForValueChanges(Object cell) {
    IStylePropertyChanges spc = ((IProviderStylePropertyChanges) cell).getStylePropertyChanges();
    if (!spc.isChanged() && !spc.isValueChanged()) {
        IModel innermostModel = ((Component) cell).getInnermostModel();
        if (innermostModel instanceof RecordItemModel) {
            Object lastRenderedValue = ((RecordItemModel) innermostModel).getLastRenderedValue((Component) cell);
            Object object = ((Component) cell).getDefaultModelObject();
            if (!Utils.equalObjects(lastRenderedValue, object)) {
                spc.setValueChanged();
            }
        } else {
            spc.setChanged();
        }
    }
}
Also used : IModel(org.apache.wicket.model.IModel) IStylePropertyChanges(com.servoy.j2db.ui.IStylePropertyChanges) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 3 with IStylePropertyChanges

use of com.servoy.j2db.ui.IStylePropertyChanges in project servoy-client by Servoy.

the class WebForm method getStylePropertyChanges.

/**
 * @see com.servoy.j2db.ui.IProviderStylePropertyChanges#getStylePropertyChanges()
 */
public IStylePropertyChanges getStylePropertyChanges() {
    if (jsChangeRecorder == null)
        jsChangeRecorder = new IStylePropertyChanges() {

            private boolean changed = false;

            public void setValueChanged() {
            }

            public void setRendered() {
                uiRecreated = false;
                changed = false;
            }

            public void setChanges(Properties changes) {
            }

            public void setChanged() {
                // plugins can call this (see WebClientUtils)
                changed = true;
            }

            public boolean isValueChanged() {
                return false;
            }

            public boolean isChanged() {
                if (changed || (enableChanged != null && enableChanged.booleanValue())) {
                    return true;
                }
                if (!uiRecreated) {
                    if (designModeBehavior != null && designModeBehavior.isEnabled(WebForm.this)) {
                        Object retValue = visitChildren(IProviderStylePropertyChanges.class, new Component.IVisitor() {

                            public Object component(Component component) {
                                IStylePropertyChanges stylePropertyChanges = ((IProviderStylePropertyChanges) component).getStylePropertyChanges();
                                if (stylePropertyChanges.isValueChanged() || stylePropertyChanges.isChanged()) {
                                    return Boolean.TRUE;
                                }
                                return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                            }
                        });
                        if (retValue instanceof Boolean && ((Boolean) retValue).booleanValue()) {
                            return true;
                        }
                    }
                    return false;
                }
                return true;
            }

            public Properties getChanges() {
                return null;
            }

            public String getJSProperty(String key) {
                return null;
            }
        };
    return jsChangeRecorder;
}
Also used : IStylePropertyChanges(com.servoy.j2db.ui.IStylePropertyChanges) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) Properties(java.util.Properties) IComponent(com.servoy.j2db.ui.IComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 4 with IStylePropertyChanges

use of com.servoy.j2db.ui.IStylePropertyChanges in project servoy-client by Servoy.

the class WebOnRenderHelper method doRender.

/**
 * Calls onRender for the renderComponent and clears its changed flag if
 * the callback did not change any properties and the value did not change
 *
 * @param renderComponent
 * @return true if properties were changed during onRender, otherwise returns false
 */
public static boolean doRender(ISupportOnRender renderComponent) {
    if (renderComponent instanceof IProviderStylePropertyChanges) {
        IStylePropertyChanges spc = ((IProviderStylePropertyChanges) renderComponent).getStylePropertyChanges();
        Properties changesBeforeOnRender = (Properties) spc.getChanges().clone();
        renderComponent.fireOnRender(false);
        Properties changesAfterOnRender = spc.getChanges();
        if (changesBeforeOnRender.equals(changesAfterOnRender)) {
            if (!spc.isValueChanged())
                spc.setRendered();
            return false;
        }
    }
    return true;
}
Also used : IStylePropertyChanges(com.servoy.j2db.ui.IStylePropertyChanges) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) Properties(java.util.Properties)

Aggregations

IStylePropertyChanges (com.servoy.j2db.ui.IStylePropertyChanges)4 BaseComponent (com.servoy.j2db.persistence.BaseComponent)2 IComponent (com.servoy.j2db.ui.IComponent)2 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 IProviderStylePropertyChanges (com.servoy.j2db.ui.IProviderStylePropertyChanges)2 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)2 Properties (java.util.Properties)2 Component (org.apache.wicket.Component)2 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)1 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)1 AbstractRuntimeBaseComponent (com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent)1 IModel (org.apache.wicket.model.IModel)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1