use of com.servoy.j2db.dataprocessing.PrototypeState in project servoy-client by Servoy.
the class CellAdapter method getStyleAttributeForRow.
private Object getStyleAttributeForRow(JTable jtable, boolean isSelected, int row, ISupportRowStyling.ATTRIBUTE rowStyleAttribute) {
Object rowStyleAttrValue = null;
IRecordInternal state = ((IFoundSetInternal) jtable.getModel()).getRecord(row);
boolean specialStateCase = (state instanceof PrototypeState || state instanceof FindState);
if (/* !(renderer instanceof JButton) && */
!specialStateCase) {
if (jtable instanceof ISupportRowStyling) {
ISupportRowStyling oddEvenStyling = (ISupportRowStyling) jtable;
IStyleSheet ss = oddEvenStyling.getRowStyleSheet();
IStyleRule style = isSelected ? oddEvenStyling.getRowSelectedStyle() : null;
if (style != null && style.getAttributeCount() == 0)
style = null;
if (style == null) {
// because index = 0 means record = 1
style = (row % 2 == 0) ? oddEvenStyling.getRowOddStyle() : oddEvenStyling.getRowEvenStyle();
}
rowStyleAttrValue = getStyleAttribute(ss, style, rowStyleAttribute);
}
}
return rowStyleAttrValue;
}
use of com.servoy.j2db.dataprocessing.PrototypeState in project servoy-client by Servoy.
the class FoundsetTypeSabloValue method updateFoundset.
/**
* Find the foundset to be used based on the design value of "foundsetSelector".\n
* It can be either:
* <ul>
* <li>a related foundset based on the component's current record (as one would access it in scripting). Example: "customers_to_orders";</li>
* <li>the component's foundset (as if in scripting you would say 'foundset') - if foundsetSelector is not specified at design time or null;</li>
* <li>a new foundset based on the given datasource (as if you would do DatabaseManager.getFoundset(datasource) in scripting). Example: "db:/example_data/customers".</li>
* </ul>
*
* @param record the record this component is attached to; can be null. (form not linked to table or no records for example)
*
* @return true if the foundset was update, false otherwise.
*/
protected void updateFoundset(IRecordInternal record) {
// this foundset is only meant to be set from Rhino scripting; do not automatically set it and do not automatically clear it once it's set from Rhino
if (foundsetSelector == null)
return;
IFoundSetInternal newFoundset = null;
if (FORM_FOUNDSET_SELECTOR.equals(foundsetSelector)) {
// it is the form's foundset then
if (record != null) {
newFoundset = record.getParentFoundSet();
}
} else if (!DataSourceUtils.isDatasourceUri(foundsetSelector)) {
// it is a relation then or a shared named foundset (set somewhere on a form in designer)
if (record != null) {
Object o = record.getValue(foundsetSelector);
if (o instanceof IFoundSetInternal) {
// it is a related foundset then if we were able to get it from current record
newFoundset = (IFoundSetInternal) o;
if (chainedRelatedFoundsetSelectionMonitor == null) {
chainedRelatedFoundsetSelectionMonitor = new ChainedRelatedFoundsetSelectionMonitor(new IRelatedFoundsetChainSelectionChangeListener() {
@Override
public void selectionChanged(IRecordInternal rootRecord, String nestedRelationNames) {
updateFoundset(rootRecord);
}
});
}
chainedRelatedFoundsetSelectionMonitor.update(newFoundset, record, foundsetSelector);
} else {
// if it is not a related foundset it must be a shared/named foundset
try {
newFoundset = (IFoundSetInternal) getFoundSetManager().getNamedFoundSet(foundsetSelector);
} catch (ServoyException e) {
Debug.error(e);
}
}
}
} else // DataSourceUtils.isDatasourceUri(foundsetSelector)
{
// that will only reinitialize constantly this FoundsetType/Table with a new foundset - on every dataprovider change.
if (foundset != null)
newFoundset = foundset;
else {
try {
// if we want to use this type on services as well we need extra code here to get the application
newFoundset = (IFoundSetInternal) getFoundSetManager().getFoundSet(foundsetSelector);
if (((JSONObject) designJSONValue).optBoolean(FoundsetPropertyType.LOAD_ALL_RECORDS_FOR_SEPARATE, false)) {
newFoundset.loadAllRecords();
}
} catch (ServoyException e) {
if (record != null && !(record instanceof PrototypeState))
Debug.error(e);
}
}
}
updateFoundset(newFoundset);
}
use of com.servoy.j2db.dataprocessing.PrototypeState in project servoy-client by Servoy.
the class NGRuntimeWindow method sendTitle.
private void sendTitle(String title) {
String titleString = "";
if (windowType == JSWindow.WINDOW) {
Solution solution = getApplication().getSolution();
String solutionTitle = solution.getTitleText();
if (solutionTitle == null) {
titleString = solution.getName();
} else if (// $NON-NLS-1$
!solutionTitle.equals("<empty>")) {
titleString = solutionTitle;
}
titleString = getApplication().getI18NMessageIfPrefixed(titleString);
if (// $NON-NLS-1$ //$NON-NLS-2$
title != null && !title.trim().equals("") && !"<empty>".equals(title) && title != null) {
String nameString = getApplication().getI18NMessageIfPrefixed(title);
IWebFormController formController = getController();
if (formController != null) {
String name2 = Text.processTags(nameString, formController.getFormUI().getDataAdapterList());
if (name2 != null)
nameString = name2;
} else {
String name2 = Text.processTags(nameString, TagResolver.createResolver(new PrototypeState(null)));
if (name2 != null)
nameString = name2;
}
if (// $NON-NLS-1$
!nameString.trim().equals("")) {
if (// $NON-NLS-1$
"".equals(titleString)) {
titleString += nameString;
} else {
// $NON-NLS-1$
titleString += " - " + nameString;
}
}
}
// $NON-NLS-1$
String appName = "Servoy NG Client";
// $NON-NLS-1$ //$NON-NLS-2$
boolean branding = Utils.getAsBoolean(getApplication().getSettings().getProperty("servoy.branding", "false"));
// $NON-NLS-1$
String appTitle = getApplication().getSettings().getProperty("servoy.branding.windowtitle");
Object runtimeAppTitle = getApplication().getClientProperty(NGCONSTANTS.WINDOW_BRANDING_TITLE);
if (runtimeAppTitle instanceof String) {
appTitle = (String) runtimeAppTitle;
}
if (branding && appTitle != null) {
appName = appTitle;
}
if (// $NON-NLS-1$
titleString.equals("")) {
titleString = appName;
} else if (// $NON-NLS-1$
!appName.trim().equals("")) {
// $NON-NLS-1$
titleString += " - " + appName;
}
} else {
titleString = getApplication().getI18NMessageIfPrefixed(title);
}
getApplication().getWebsocketSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall(// $NON-NLS-1$
"setTitle", new Object[] { this.getName(), titleString });
}
use of com.servoy.j2db.dataprocessing.PrototypeState in project servoy-client by Servoy.
the class WebFormController method refreshAllPartRenderers.
@Override
protected void refreshAllPartRenderers(IRecordInternal[] records) {
if (!isFormVisible || application.isShutDown() || rendering)
return;
// don't do anything yet when there are records but the selection is invalid
if (formModel != null && (formModel.getSize() > 0 && (formModel.getSelectedIndex() < 0 || formModel.getSelectedIndex() >= formModel.getSize())))
return;
// let the ui know that it will be touched, so that locks can be taken if needed.
boolean executeOnRecordSelect = false;
IRecordInternal[] state = records;
if (state == null) {
if (formModel != null) {
state = new IRecordInternal[] { formModel.getPrototypeState() };
} else {
state = new IRecordInternal[] { new PrototypeState(null) };
}
}
if (!(records == null && formModel != null && formModel.getRawSize() > 0) && isStateChanged(state)) {
lastState = state;
executeOnRecordSelect = true;
}
IDataAdapterList dataAdapterList = getFormUI().getDataAdapterList();
for (IRecordInternal r : state) dataAdapterList.setRecord(r, true);
if (executeOnRecordSelect) {
// do this at the end because dataRenderer.refreshRecord(state) will update selection
// for related tabs - and we should execute js code after they have been updated
executeOnRecordSelect();
}
}
Aggregations