Search in sources :

Example 41 with IFoundSetInternal

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

the class WebDataLookupField method dependencyChanged.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.dataprocessing.IDisplayDependencyData#dependencyChanged(com.servoy.j2db.dataprocessing.IRecordInternal)
	 */
@Override
public void dependencyChanged(IRecordInternal record) {
    this.parentState = record;
    if (list != null) {
        int index = -1;
        if (!ScopesUtils.isVariableScope(getDataProviderID()) && (getDataProviderID() != null)) {
            index = getDataProviderID().lastIndexOf('.');
        }
        if (index == -1 || parentState == null) {
            list.fill(parentState);
        } else {
            IFoundSetInternal relatedFoundSet = parentState.getRelatedFoundSet(getDataProviderID().substring(0, index));
            if (relatedFoundSet == null) {
                this.relatedRecord = parentState.getParentFoundSet().getPrototypeState();
                list.fill(relatedRecord);
            } else if (relatedFoundSet.getSize() == 0) {
                this.relatedRecord = relatedFoundSet.getPrototypeState();
                list.fill(relatedRecord);
            } else {
                IRecordInternal relRecord = relatedFoundSet.getRecord(relatedFoundSet.getSelectedIndex());
                if (relRecord != relatedRecord) {
                    this.relatedRecord = relRecord;
                    list.fill(relatedRecord);
                }
            }
        }
    }
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal)

Example 42 with IFoundSetInternal

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

the class WebDataRenderer method getParentViewBgColor.

private String getParentViewBgColor() {
    if (parentView != null) {
        String rowBGColorCalculation = parentView.getRowBGColorScript();
        IRecordInternal rec = (IRecordInternal) getDefaultModelObject();
        if (rec != null && rec.getRawData() != null) {
            IFoundSetInternal parentFoundSet = rec.getParentFoundSet();
            int recIndex = parentFoundSet.getSelectedIndex();
            boolean isSelected = recIndex == parentFoundSet.getRecordIndex(rec);
            if (rowBGColorCalculation != null) {
                Object bg_color = null;
                if (rec.getRawData().containsCalculation(rowBGColorCalculation)) {
                    // data renderer is always on the selected index.
                    bg_color = parentFoundSet.getCalculationValue(rec, rowBGColorCalculation, Utils.arrayMerge(new Object[] { new Integer(recIndex), new Boolean(isSelected), null, null, Boolean.FALSE }, Utils.parseJSExpressions(parentView.getRowBGColorArgs())), null);
                } else {
                    try {
                        FormController currentForm = dataAdapterList.getFormController();
                        bg_color = currentForm.executeFunction(rowBGColorCalculation, Utils.arrayMerge(new Object[] { new Integer(parentFoundSet.getSelectedIndex()), new Boolean(isSelected), null, null, currentForm.getName(), rec, Boolean.FALSE }, Utils.parseJSExpressions(parentView.getRowBGColorArgs())), true, null, true, null);
                    } catch (Exception ex) {
                        Debug.error(ex);
                    }
                }
                if (bg_color != null && !(bg_color.toString().trim().length() == 0) && !(bg_color instanceof Undefined)) {
                    return bg_color.toString();
                }
            }
            if (parentView instanceof ISupportRowStyling) {
                ISupportRowStyling parentViewWithRowStyling = (ISupportRowStyling) parentView;
                IStyleSheet ss = parentViewWithRowStyling.getRowStyleSheet();
                IStyleRule style = isSelected ? parentViewWithRowStyling.getRowSelectedStyle() : null;
                if (style != null && style.getAttributeCount() == 0)
                    style = null;
                if (style == null) {
                    style = (recIndex % 2 == 0) ? parentViewWithRowStyling.getRowEvenStyle() : parentViewWithRowStyling.getRowOddStyle();
                }
                if (ss != null && style != null) {
                    return PersistHelper.createColorString(ss.getBackground(style));
                }
            }
        }
    }
    return null;
}
Also used : FormController(com.servoy.j2db.FormController) Undefined(org.mozilla.javascript.Undefined) ISupportRowStyling(com.servoy.j2db.ui.ISupportRowStyling) IStyleSheet(com.servoy.j2db.util.IStyleSheet) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Point(java.awt.Point) NoSuchElementException(java.util.NoSuchElementException) IStyleRule(com.servoy.j2db.util.IStyleRule)

Example 43 with IFoundSetInternal

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

the class FoundSetIndexModel method onRender.

/**
 * @see wicket.MarkupContainer#onRender(wicket.markup.MarkupStream)
 */
@Override
protected void onRender(MarkupStream markupStream) {
    super.onRender(markupStream);
    IFoundSetInternal fs = foundSetIndexModel.getFoundSet();
    if (fs != null) {
        totalRecords = (fs.getSize() == 0 ? "" : (fs.getSize() + (fs.hadMoreRows() ? "+" : "")));
        selectedRecord = (fs.getSelectedIndex() == -1 ? "" : "" + (fs.getSelectedIndex() + 1));
    }
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal)

Example 44 with IFoundSetInternal

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

the class FoundsetTest method foundsetChangeMonitorChangeFlags.

@Test
public void foundsetChangeMonitorChangeFlags() throws ServoyException {
    IWebFormController form = (IWebFormController) client.getFormManager().showFormInCurrentContainer("test");
    Assert.assertNotNull(form);
    FoundsetTypeSabloValue rawPropertyValue = (FoundsetTypeSabloValue) form.getFormUI().getWebComponent("mycustombean").getRawPropertyValue("myfoundset");
    IFoundSetInternal foundSet = rawPropertyValue.getFoundset();
    rawPropertyValue.changeMonitor.clearChanges();
    foundSet.newRecord(0, false);
    Assert.assertEquals(FoundsetTypeChangeMonitor.SEND_FOUNDSET_SIZE | FoundsetTypeChangeMonitor.SEND_SELECTED_INDEXES, rawPropertyValue.changeMonitor.changeFlags);
    rawPropertyValue.changeMonitor.clearChanges();
    foundSet.deleteRecord(0);
    Assert.assertEquals(FoundsetTypeChangeMonitor.SEND_FOUNDSET_SIZE | FoundsetTypeChangeMonitor.SEND_SELECTED_INDEXES, rawPropertyValue.changeMonitor.changeFlags);
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) Test(org.junit.Test)

Example 45 with IFoundSetInternal

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

the class WebTabPanel method registerSelectionListeners.

private void registerSelectionListeners(IRecordInternal parentState, String relationName) {
    // $NON-NLS-1$
    String[] parts = relationName.split("\\.");
    IRecordInternal currentRecord = parentState;
    for (int i = 0; currentRecord != null && i < parts.length - 1; i++) {
        IFoundSetInternal fs = currentRecord.getRelatedFoundSet(parts[i]);
        if (fs instanceof ISwingFoundSet) {
            related.add((ISwingFoundSet) fs);
            ((ISwingFoundSet) fs).getSelectionModel().addListSelectionListener(this);
        }
        currentRecord = (fs == null) ? null : fs.getRecord(fs.getSelectedIndex());
    }
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Point(java.awt.Point) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet)

Aggregations

IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)55 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)26 Point (java.awt.Point)13 FormController (com.servoy.j2db.FormController)12 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)11 ServoyException (com.servoy.j2db.util.ServoyException)8 ArrayList (java.util.ArrayList)8 IApplication (com.servoy.j2db.IApplication)6 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)6 EventObject (java.util.EventObject)6 ITagResolver (com.servoy.base.util.ITagResolver)5 FindState (com.servoy.j2db.dataprocessing.FindState)5 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)5 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)5 RepositoryException (com.servoy.j2db.persistence.RepositoryException)5 JSONObject (org.json.JSONObject)5 FormManager (com.servoy.j2db.FormManager)4 SortColumn (com.servoy.j2db.dataprocessing.SortColumn)4 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)4 Color (java.awt.Color)4