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);
}
}
}
}
}
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);
}
}
}
}
}
}
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());
}
}
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);
}
}
}
}
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);
}
}
Aggregations