Search in sources :

Example 6 with IScriptable

use of com.servoy.j2db.scripting.IScriptable in project servoy-client by Servoy.

the class DisplaysAdapter method valueChanged.

/*
	 * _____________________________________________________________ JavaScriptModificationlistener
	 */
public void valueChanged(ModificationEvent e) {
    if (!adjusting) {
        try {
            adjusting = true;
            Object obj = null;
            boolean formVariable = false;
            if (dataProviderID != null) {
                if (dal.getFormScope().has(dataProviderID, dal.getFormScope())) {
                    formVariable = true;
                    obj = dal.getFormScope().get(dataProviderID);
                } else if (record != null) {
                    obj = record.getValue(dataProviderID);
                    if (obj == Scriptable.NOT_FOUND) {
                        obj = null;
                    }
                    // have to do this because for calcs in calcs. Better was to had a check for previous value.
                    fireModificationEvent(obj);
                }
            }
            // do not set value for form variable except when really changed
            if (!formVariable || dataProviderID == null || dataProviderID.equals(e.getName())) {
                setValueToDisplays(obj);
            }
        } finally {
            adjusting = false;
        }
    }
    // do fire on render on all components for record change
    for (IDisplayData displayData : displays) {
        if (displayData instanceof ISupportOnRender && displayData instanceof IScriptableProvider) {
            IScriptable so = ((IScriptableProvider) displayData).getScriptObject();
            if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
                String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
                if (e.getRecord() != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
                    ((ISupportOnRender) displayData).fireOnRender(true);
                }
            }
        }
    }
}
Also used : ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 7 with IScriptable

use of com.servoy.j2db.scripting.IScriptable in project servoy-client by Servoy.

the class DataAdapterList method setDataRendererComponentsRenderState.

public static void setDataRendererComponentsRenderState(IDataRenderer dataRenderer, IRecordInternal rec) {
    if (rec != null) {
        Object[] recordStatus = null;
        if (dataRenderer.getOnRenderComponent().getRenderEventExecutor().hasRenderCallback()) {
            recordStatus = getRecordIndexAndSelectStatus(rec);
            dataRenderer.getOnRenderComponent().getRenderEventExecutor().setRenderState(rec, ((Integer) recordStatus[0]).intValue(), ((Boolean) recordStatus[1]).booleanValue(), true);
        }
        @SuppressWarnings("rawtypes") Iterator compIte = dataRenderer.getComponentIterator();
        Object comp;
        while (compIte.hasNext()) {
            comp = compIte.next();
            if (comp instanceof IScriptableProvider) {
                IScriptable scriptable = ((IScriptableProvider) comp).getScriptObject();
                if (scriptable instanceof ISupportOnRenderCallback) {
                    RenderEventExecutor rendererEventExecutor = ((ISupportOnRenderCallback) scriptable).getRenderEventExecutor();
                    if (rendererEventExecutor != null && rendererEventExecutor.hasRenderCallback()) {
                        if (recordStatus == null)
                            recordStatus = getRecordIndexAndSelectStatus(rec);
                        rendererEventExecutor.setRenderState(rec, ((Integer) recordStatus[0]).intValue(), ((Boolean) recordStatus[1]).booleanValue(), true);
                    }
                }
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 8 with IScriptable

use of com.servoy.j2db.scripting.IScriptable in project servoy-client by Servoy.

the class PropertyCopy method copyElementProps.

public static void copyElementProps(IComponent org, IComponent copy) {
    if (org == null || copy == null)
        return;
    // if (org instanceof IDelegate && copy instanceof IDelegate)
    // {
    // org = (JComponent)((IDelegate)org).getDelegate();
    // copy = (JComponent) ((IDelegate)copy).getDelegate();
    // }
    copy.setLocation(org.getLocation());
    copy.setSize(org.getSize());
    copy.setBackground(org.getBackground());
    copy.setForeground(org.getForeground());
    copy.setToolTipText(org.getToolTipText());
    copy.setComponentVisible(org.isVisible());
    copy.setComponentEnabled(org.isEnabled());
    copy.setOpaque(org.isOpaque());
    copy.setFont(org.getFont());
    if (org instanceof ILabel && copy instanceof ILabel) {
        ((ILabel) copy).setMediaIcon(((ILabel) org).getMediaIcon());
        ((ILabel) copy).setText(((ILabel) org).getText());
    }
    if (org instanceof IFieldComponent && copy instanceof IFieldComponent) {
        ((IFieldComponent) copy).setEditable(((IFieldComponent) org).isEditable());
    }
    if (org instanceof IScriptableProvider && copy instanceof IScriptableProvider) {
        IScriptable source = ((IScriptableProvider) org).getScriptObject();
        IScriptable destination = ((IScriptableProvider) copy).getScriptObject();
        if (source instanceof IFormatScriptComponent && destination instanceof IFormatScriptComponent) {
            ((IFormatScriptComponent) destination).setComponentFormat(((IFormatScriptComponent) source).getComponentFormat());
        }
        if (source instanceof HasRuntimeReadOnly && destination instanceof HasRuntimeReadOnly) {
            ((HasRuntimeReadOnly) destination).setReadOnly(((HasRuntimeReadOnly) source).isReadOnly());
        }
        if (source instanceof HasRuntimeVisible && destination instanceof HasRuntimeVisible) {
            ((HasRuntimeVisible) destination).setVisible(((HasRuntimeVisible) source).isVisible());
        }
        if (source instanceof HasRuntimeImage && destination instanceof HasRuntimeImage) {
            String imageURL = ((HasRuntimeImage) source).getImageURL();
            if (imageURL != null) {
                // only copy if explicitly set with a url
                ((HasRuntimeImage) destination).setImageURL(imageURL);
            }
            String rolloverImageURL = ((HasRuntimeImage) source).getRolloverImageURL();
            if (rolloverImageURL != null) {
                // only copy if explicitly set with a url
                ((HasRuntimeImage) destination).setRolloverImageURL(rolloverImageURL);
            }
        }
        if (source instanceof IRuntimeTabPaneAlike && destination instanceof IRuntimeTabPaneAlike) {
            // keep active tab when printing
            ((IRuntimeTabPaneAlike) destination).setTabIndex(((IRuntimeTabPaneAlike) source).getTabIndex());
        }
    }
    if (org instanceof IProviderStylePropertyChanges && copy instanceof IProviderStylePropertyChanges) {
        ((IProviderStylePropertyChanges) copy).getStylePropertyChanges().setChanges(((IProviderStylePropertyChanges) org).getStylePropertyChanges().getChanges());
    }
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly) HasRuntimeImage(com.servoy.j2db.ui.runtime.HasRuntimeImage) HasRuntimeVisible(com.servoy.j2db.ui.runtime.HasRuntimeVisible) IRuntimeTabPaneAlike(com.servoy.j2db.ui.runtime.IRuntimeTabPaneAlike) IFormatScriptComponent(com.servoy.j2db.ui.scripting.IFormatScriptComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 9 with IScriptable

use of com.servoy.j2db.scripting.IScriptable in project servoy-client by Servoy.

the class DataRenderer method fireDataRendererOnRender.

private void fireDataRendererOnRender() {
    dataRendererOnRenderWrapper.getRenderEventExecutor().fireOnRender(hasFocus());
    @SuppressWarnings("rawtypes") Iterator compIte = getComponentIterator();
    Object comp;
    while (compIte.hasNext()) {
        comp = compIte.next();
        if (comp instanceof IScriptableProvider && !(comp instanceof IDisplayData) && !(comp instanceof IDisplayRelatedData)) {
            IScriptable scriptable = ((IScriptableProvider) comp).getScriptObject();
            if (scriptable instanceof ISupportOnRenderCallback) {
                RenderEventExecutor rendererEventExecutor = ((ISupportOnRenderCallback) scriptable).getRenderEventExecutor();
                boolean hasFocus = (comp instanceof Component) ? ((Component) comp).hasFocus() : false;
                rendererEventExecutor.fireOnRender(hasFocus);
            }
        }
    }
}
Also used : IDisplayRelatedData(com.servoy.j2db.dataprocessing.IDisplayRelatedData) Iterator(java.util.Iterator) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 10 with IScriptable

use of com.servoy.j2db.scripting.IScriptable in project servoy-client by Servoy.

the class AbstractRuntimeField method setVisible.

@Override
public void setVisible(boolean b) {
    if (isVisible() != b) {
        if (getComponent().isViewable()) {
            List<ILabel> labels = getComponent().getLabelsFor();
            if (labels != null) {
                for (int i = 0; i < labels.size(); i++) {
                    ILabel label = labels.get(i);
                    IScriptable scriptable = label.getScriptObject();
                    if (scriptable instanceof IRuntimeComponent) {
                        ((IRuntimeComponent) scriptable).setVisible(b);
                    } else {
                        label.setComponentVisible(b);
                    }
                }
            }
        }
        super.setVisible(b);
    }
}
Also used : ILabel(com.servoy.j2db.ui.ILabel) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptable(com.servoy.j2db.scripting.IScriptable)

Aggregations

IScriptable (com.servoy.j2db.scripting.IScriptable)19 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)17 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)11 IComponent (com.servoy.j2db.ui.IComponent)9 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)9 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)6 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)6 RenderEventExecutor (com.servoy.j2db.ui.RenderEventExecutor)6 Component (org.apache.wicket.Component)6 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)5 JComponent (javax.swing.JComponent)5 IDisplayRelatedData (com.servoy.j2db.dataprocessing.IDisplayRelatedData)4 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)4 BaseComponent (com.servoy.j2db.persistence.BaseComponent)4 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)4 AbstractRuntimeBaseComponent (com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent)4 Point (java.awt.Point)4 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)3 ISupportOnRender (com.servoy.j2db.ui.ISupportOnRender)3 EventObject (java.util.EventObject)3