Search in sources :

Example 1 with IRecord

use of com.servoy.j2db.dataprocessing.IRecord in project servoy-client by Servoy.

the class WebCellAdapter method valueChanged.

public void valueChanged(ModificationEvent e) {
    MainPage mp = view.findParent(MainPage.class);
    if (mp != null)
        mp.touch();
    IRecord record = e.getRecord();
    Iterator iterator = ((MarkupContainer) view.getTable()).iterator();
    while (iterator.hasNext()) {
        Object next = iterator.next();
        if (next instanceof ListItem) {
            ListItem li = (ListItem) next;
            Object modelObject = li.getModelObject();
            if (record == null || modelObject == record) {
                boolean hasOnRender = false;
                Iterator iterator2 = li.iterator();
                while (iterator2.hasNext()) {
                    ArrayList<Object> cellDisplays = new ArrayList<Object>();
                    Object cell = iterator2.next();
                    cell = CellContainer.getContentsForCell((Component) cell);
                    if (cell instanceof WebCellBasedViewListViewItem) {
                        Iterator listItemIte = ((WebCellBasedViewListViewItem) cell).iterator();
                        while (listItemIte.hasNext()) {
                            Object listItemDisplay = listItemIte.next();
                            if (listItemDisplay instanceof WrapperContainer) {
                                listItemDisplay = ((WrapperContainer) listItemDisplay).getDelegate();
                            }
                            cellDisplays.add(listItemDisplay);
                        }
                    } else {
                        cellDisplays.add(cell);
                    }
                    for (Object cellDisplay : cellDisplays) {
                        if (cellDisplay instanceof IProviderStylePropertyChanges && cellDisplay instanceof IDisplayData && ((IDisplayData) cellDisplay).getDataProviderID() == dataprovider) {
                            // only test if it is not already changed
                            view.checkForValueChanges(cellDisplay);
                            // do fire on render on all components for record change
                            if (cellDisplay instanceof ISupportOnRender && cellDisplay instanceof IScriptableProvider) {
                                IScriptable so = ((IScriptableProvider) cellDisplay).getScriptObject();
                                if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
                                    String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
                                    if (record != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
                                        ((ISupportOnRender) cellDisplay).fireOnRender(true);
                                        hasOnRender = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (record != null || (!hasOnRender && !canChangeValue(e)))
                    break;
            }
        }
    }
}
Also used : MarkupContainer(org.apache.wicket.MarkupContainer) ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) IRecord(com.servoy.j2db.dataprocessing.IRecord) ArrayList(java.util.ArrayList) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) WebCellBasedViewListViewItem(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.WebCellBasedViewListViewItem) IScriptable(com.servoy.j2db.scripting.IScriptable) WrapperContainer(com.servoy.j2db.server.headlessclient.WrapperContainer) Iterator(java.util.Iterator) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 2 with IRecord

use of com.servoy.j2db.dataprocessing.IRecord in project servoy-client by Servoy.

the class MapSerializer method convertToMap.

public static Map<String, Object> convertToMap(Object jsobj) {
    Map<String, Object> retval = new HashMap<String, Object>();
    if (jsobj == null || jsobj == Undefined.instance || jsobj instanceof IFoundSet || jsobj instanceof IRecord || !(jsobj instanceof NativeObject)) {
        return retval;
    }
    IdScriptableObject no = (IdScriptableObject) jsobj;
    Object[] noIDs = no.getIds();
    String propertyKey;
    Object propertyValue;
    for (Object element : noIDs) {
        // id can be Integer or String
        if (element instanceof Integer) {
            propertyKey = ((Integer) element).toString();
            propertyValue = no.get(((Integer) element).intValue(), no);
        } else if (element instanceof String) {
            propertyKey = (String) element;
            propertyValue = no.get((String) element, no);
        } else {
            // should not happen
            continue;
        }
        if (// allow but ignore functions nested in objects
        propertyValue instanceof Function) {
            continue;
        }
        if (propertyValue instanceof NativeObject) {
            propertyValue = convertToMap(propertyValue);
        }
        if (propertyValue instanceof Wrapper) {
            propertyValue = ((Wrapper) propertyValue).unwrap();
        }
        retval.put(propertyKey, propertyValue);
    }
    return retval;
}
Also used : NativeObject(org.mozilla.javascript.NativeObject) Function(org.mozilla.javascript.Function) Wrapper(org.mozilla.javascript.Wrapper) IFoundSet(com.servoy.j2db.dataprocessing.IFoundSet) HashMap(java.util.HashMap) IRecord(com.servoy.j2db.dataprocessing.IRecord) NativeObject(org.mozilla.javascript.NativeObject) IdScriptableObject(org.mozilla.javascript.IdScriptableObject) IdScriptableObject(org.mozilla.javascript.IdScriptableObject)

Example 3 with IRecord

use of com.servoy.j2db.dataprocessing.IRecord in project servoy-client by Servoy.

the class FoundsetDataAdapterList method resetDALToSelectedIndexQuietly.

public void resetDALToSelectedIndexQuietly() {
    // see https://support.servoy.com/browse/SVY-11537; DataproviderTypeSabloValues do listen to related data but only on the row in the foundset DAL
    IFoundSetInternal foundset;
    if (getRecord() != null)
        foundset = getRecord().getParentFoundSet();
    else
        foundset = null;
    if (foundset != null && foundset.getSize() > 0) {
        IRecord selectedRecord = foundset.getRecord(foundset.getSelectedIndex());
        setRecordQuietly(selectedRecord, true);
    } else {
        // to make sure DAL is not listening to records that are no longer in the foundset
        setRecordQuietly(null, true);
    }
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) IRecord(com.servoy.j2db.dataprocessing.IRecord)

Example 4 with IRecord

use of com.servoy.j2db.dataprocessing.IRecord in project servoy-client by Servoy.

the class AlwaysRowSelectedSelectionModel method testStopUIEditing.

private boolean testStopUIEditing() {
    for (IFormController fco : formControllers.toArray(new IFormController[formControllers.size()])) {
        if (fco.isFormVisible()) {
            EditRecordList editRecordList = fco.getApplication().getFoundSetManager().getEditRecordList();
            IRecord[] editedRecords = editRecordList.getEditedRecords(fco.getFoundSet());
            if (editedRecords.length > 0) {
                int stopEditing = editRecordList.stopEditing(false, Arrays.asList(editedRecords));
                return stopEditing == ISaveConstants.STOPPED || stopEditing == ISaveConstants.AUTO_SAVE_BLOCKED;
            }
        }
    }
    return true;
}
Also used : EditRecordList(com.servoy.j2db.dataprocessing.EditRecordList) IRecord(com.servoy.j2db.dataprocessing.IRecord) IFormController(com.servoy.j2db.IFormController)

Example 5 with IRecord

use of com.servoy.j2db.dataprocessing.IRecord in project servoy-client by Servoy.

the class CellAdapter method valueChanged.

/*
	 * @see JSModificationListener#valueChanged(ModificationEvent)
	 */
public void valueChanged(ModificationEvent e) {
    if (adjusting)
        return;
    try {
        adjusting = true;
        // ignore globals in a cell adapter, will be handled by the row manager
        if (!table.isEditing() && ScopesUtils.isVariableScope(e.getName())) {
            // test if it is a related
            if (dataProviderID != null && dataProviderID.indexOf('.') != -1) {
                TableModel parent = table.getModel();
                if (parent instanceof ISwingFoundSet) {
                    // it could be based on that global so fire a table event.
                    ((ISwingFoundSet) parent).fireTableModelEvent(0, parent.getRowCount() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE);
                }
            }
            return;
        }
        // refresh value
        IRecord s = e.getRecord();
        if (s == null) {
            TableModel tm = table.getModel();
            if (tm instanceof IFoundSetInternal) {
                IFoundSetInternal fs = (IFoundSetInternal) tm;
                int selRow = fs.getSelectedIndex();
                if (selRow != -1) {
                    s = fs.getRecord(selRow);
                }
            }
        }
        if (s != null) {
            Object obj = e.getValue();
            if (e.getName().equals(dataProviderID)) {
                // make sure the change is seen and pushed to display by jtable
                fireModificationEvent(s);
            } else {
                obj = dal.getValueObject(s, dataProviderID);
                if (obj == Scriptable.NOT_FOUND) {
                    obj = null;
                }
            }
            if (s == currentEditingState && table.getEditorComponent() == editor && editor instanceof IDisplayData) {
                convertAndSetValue(((IDisplayData) editor), obj);
            }
        }
    } finally {
        adjusting = false;
    }
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) IRecord(com.servoy.j2db.dataprocessing.IRecord) EventObject(java.util.EventObject) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) TableModel(javax.swing.table.TableModel) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet) Point(java.awt.Point)

Aggregations

IRecord (com.servoy.j2db.dataprocessing.IRecord)9 FormScope (com.servoy.j2db.scripting.FormScope)3 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)2 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)2 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)2 Component (org.apache.wicket.Component)2 IJSEvent (com.servoy.base.scripting.api.IJSEvent)1 IFormController (com.servoy.j2db.IFormController)1 ServoyBeanState (com.servoy.j2db.component.ServoyBeanState)1 EditRecordList (com.servoy.j2db.dataprocessing.EditRecordList)1 FindState (com.servoy.j2db.dataprocessing.FindState)1 IFoundSet (com.servoy.j2db.dataprocessing.IFoundSet)1 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)1 DbIdentValue (com.servoy.j2db.dataprocessing.ValueFactory.DbIdentValue)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 AbstractBase (com.servoy.j2db.persistence.AbstractBase)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 Form (com.servoy.j2db.persistence.Form)1 IPersist (com.servoy.j2db.persistence.IPersist)1 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)1