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