Search in sources :

Example 6 with IDisplayData

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;
                    }
                });
            }
        }
    }
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) ITagResolver(com.servoy.base.util.ITagResolver) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) IDataProvider(com.servoy.j2db.persistence.IDataProvider) AggregateVariable(com.servoy.j2db.persistence.AggregateVariable) IDisplayTagText(com.servoy.j2db.ui.IDisplayTagText) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Example 7 with IDisplayData

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);
    }
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException) Iterator(java.util.Iterator) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) JComponent(javax.swing.JComponent) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with IDisplayData

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;
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) CellEditorListener(javax.swing.event.CellEditorListener)

Example 9 with IDisplayData

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);
            }
        }
    }
}
Also used : IDisplayRelatedData(com.servoy.j2db.dataprocessing.IDisplayRelatedData) Iterator(java.util.Iterator) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 10 with IDisplayData

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;
}
Also used : FormController(com.servoy.j2db.FormController) HashMap(java.util.HashMap) DataAdapterList(com.servoy.j2db.dataprocessing.DataAdapterList) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) IPersist(com.servoy.j2db.persistence.IPersist) ScriptVariable(com.servoy.j2db.persistence.ScriptVariable) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)24 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)8 IDisplay (com.servoy.j2db.dataprocessing.IDisplay)7 HashMap (java.util.HashMap)7 JComponent (javax.swing.JComponent)7 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)6 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)6 Point (java.awt.Point)6 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)5 IPersist (com.servoy.j2db.persistence.IPersist)5 IScriptable (com.servoy.j2db.scripting.IScriptable)5 IComponent (com.servoy.j2db.ui.IComponent)5 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)5 Component (java.awt.Component)5 EventObject (java.util.EventObject)5 Iterator (java.util.Iterator)5 Component (org.apache.wicket.Component)5 FindState (com.servoy.j2db.dataprocessing.FindState)4 IDisplayRelatedData (com.servoy.j2db.dataprocessing.IDisplayRelatedData)4 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)4