use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.
the class PartNode method getAggregatesFromRenderer.
private void getAggregatesFromRenderer(final List<AggregateVariable> aggregates, final Form f, DataRenderer a_renderer) throws RepositoryException {
Map<IPersist, IDisplay> allFields = a_renderer.getFieldComponents();
Iterator<IDisplay> it = allFields.values().iterator();
while (it.hasNext()) {
IDisplay display = it.next();
if (display instanceof IDisplayData) {
String dataProviderID = ((IDisplayData) display).getDataProviderID();
if (dataProviderID != null) {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(dataProviderID);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} else if (display instanceof IDisplayTagText) {
String tagText = ((IDisplayTagText) display).getTagText();
Text.processTags(tagText, new ITagResolver() {
public String getStringValue(String name) {
try {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(name);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} catch (Exception e) {
Debug.error(e);
}
return null;
}
});
}
}
}
}
use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.
the class DataRendererDefinition method tempAddToParent.
void tempAddToParent(final RendererParentWrapper renderParent, final boolean fillWithData, final boolean doLayout, final boolean saveComponentBounds) {
try {
Runnable r = new Runnable() {
public void run() {
try {
if (!doLayout) {
// restore the bound to match exactly to the init phase
// (and no fields are cut in half due to different html render positions)
restoreSavedComponentBounds();
}
// data is needed to see how (much) to slide
if (fillWithData) {
IRecordInternal a_state = getState();
// lookup all field needed, so the are present in the state when needed for rendering
if (a_state != null)
renderer.getDataAdapterList().setRecord(a_state, true);
}
// always needed for correct layout of text-areas/mediafields
renderParent.add(renderer);
List<Component> invisibleComponents = new ArrayList<Component>();
Component[] comps = renderer.getComponents();
for (int i = 0; i < comps.length; i++) {
int slide = ISupportPrintSliding.NO_SLIDING;
Map componentsListToBeHandeld = renderer.getComponentsUsingSliding();
if (componentsListToBeHandeld != null && componentsListToBeHandeld.containsKey(comps[i])) {
slide = ((Integer) componentsListToBeHandeld.get(comps[i])).intValue();
}
// set components invisible if empty/null and should shrink
if (((slide & ISupportPrintSliding.SHRINK_HEIGHT) == ISupportPrintSliding.SHRINK_HEIGHT) && ((slide & ISupportPrintSliding.SHRINK_WIDTH) == ISupportPrintSliding.SHRINK_WIDTH) && comps[i] instanceof IDisplayData) {
boolean visible = !(((IDisplayData) comps[i]).getValueObject() == null || ((IDisplayData) comps[i]).getValueObject().toString().trim().length() == 0);
comps[i].setVisible(visible);
if (!visible) {
comps[i].setSize(0, 0);
invisibleComponents.add(comps[i]);
}
}
}
if (doLayout) {
renderer.invalidate();
renderer.validate();
for (Component invisibleComponent : invisibleComponents) {
invisibleComponent.setPreferredSize(new Dimension(0, 0));
}
// 1) do first
renderer.doLayout();
// 2) do second time, some times the after the fist time something is changed which causes stuff to render correctly
renderer.doLayout();
if (saveComponentBounds) {
// store the prefered sizes so we don't have todo layouting again (by adding / removing)
for (Component element : comps) {
bounds.put(element, new Rectangle(element.getBounds()));
}
}
for (Component invisibleComponent : invisibleComponents) {
invisibleComponent.setPreferredSize(null);
}
} else {
// for bounds change, important for html/text-areas
Iterator it = bounds.keySet().iterator();
while (it.hasNext()) {
Component c = (Component) it.next();
// relayouts the internals of html/text-areas
c.validate();
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
};
if (application.isEventDispatchThread()) {
r.run();
} else {
application.invokeAndWait(r);
}
} catch (Exception e) {
Debug.error(e);
}
}
use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.
the class CellAdapter method stopCellEditing.
public boolean stopCellEditing() {
if (!isStopping) {
try {
isStopping = true;
// Get the current celleditor value for testing notify changed.
getCellEditorValue();
// if the notify changed failed the mustTestLastValue is set and we shouldn't allow stopping:
if (editor instanceof IDisplayData && !((IDisplayData) editor).isValueValid()) {
return false;
}
CellEditorListener l = listener;
if (l != null) {
// TODO this also triggers (or can trigger) a getCellEditorValue() call.. (so the vallue is set in the record, conversion/validation is called again)
l.editingStopped(new ChangeEvent(this));
}
return true;
} finally {
isStopping = false;
}
} else {
return true;
}
}
use of com.servoy.j2db.dataprocessing.IDisplayData 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.dataprocessing.IDisplayData in project servoy-client by Servoy.
the class DataRenderer method createDataAdapter.
void createDataAdapter(IApplication app, IDataProviderLookup dataProviderLookup, IScriptExecuter el, ControllerUndoManager undoManager) throws Exception {
// IScriptExecutor can be null for a design component
FormController formController = el == null ? null : el.getFormController();
dataAdapterList = new DataAdapterList(app, dataProviderLookup, fieldComponents, formController, null, undoManager);
// make it really fields only
HashMap<IPersist, IDisplay> f = new HashMap<IPersist, IDisplay>();
Iterator<Map.Entry<IPersist, IDisplay>> it = fieldComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<IPersist, IDisplay> element = it.next();
if (element.getValue() instanceof IDisplayData) {
String id = ((IDisplayData) element.getValue()).getDataProviderID();
if (dataProviderLookup.getDataProvider(id) instanceof ScriptVariable) {
globalFields.add(element.getValue());
}
f.put(element.getKey(), element.getValue());
}
}
fieldComponents = f;
}
Aggregations