Search in sources :

Example 1 with ISupportTabSeq

use of com.servoy.j2db.persistence.ISupportTabSeq in project servoy-client by Servoy.

the class WebDataRendererFactory method placeElements.

protected Map placeElements(IApplication app, Form form, IScriptExecuter listener, Map emptyDataRenderers, boolean printing, ControllerUndoManager undoManager, TabSequenceHelper<Component> tabSequence) throws Exception {
    // $NON-NLS-1$
    final boolean useAJAX = Utils.getAsBoolean(app.getRuntimeProperties().get("useAJAX"));
    IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
    Map listTocomplete = new HashMap();
    Map labelForComponents = new HashMap();
    String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
    // $NON-NLS-1$
    boolean leftToRight = !"rtl".equalsIgnoreCase(orientation);
    // $NON-NLS-1$
    boolean isAnchoringEnabled = Utils.getAsBoolean(app.getRuntimeProperties().get("enableAnchors"));
    // Insets insets = new Insets(0, 0, 0, 0);
    for (IFormElement obj : Utils.iterate(form.getFormElementsSortedByFormIndex())) {
        Point l = null;
        l = (obj).getLocation();
        // unknown where to add
        if (l == null)
            continue;
        if (printing && obj instanceof ISupportPrinting) {
            if (!((ISupportPrinting) obj).getPrintable())
                continue;
        }
        Iterator it = emptyDataRenderers.values().iterator();
        while (it.hasNext()) {
            WebDataRenderer panel = (WebDataRenderer) it.next();
            // Border border = panel.getBorder();
            // if (border instanceof EmptyBorder)
            // {
            // insets = ((EmptyBorder)border).getBorderInsets();
            // }
            int start = panel.getLocation().y;
            if (l.y >= start && l.y < start + panel.getSize().height) {
                org.apache.wicket.Component comp = (org.apache.wicket.Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listener, printing);
                if (comp != null) {
                    if (obj instanceof Field) {
                        String name = ((Field) obj).getName();
                        if (name != null && !"".equals(name)) {
                            labelForComponents.put(name, comp);
                        }
                    } else if (obj instanceof GraphicalComponent && (comp instanceof WebBaseLabel || comp instanceof WebBaseSubmitLink)) {
                        String labelFor = ((GraphicalComponent) obj).getLabelFor();
                        if (labelFor != null && !"".equals(labelFor)) {
                            labelForComponents.put(comp, labelFor);
                        }
                    }
                    if ((obj instanceof ISupportTabSeq) && (tabSequence != null)) {
                        tabSequence.add(panel, (ISupportTabSeq) obj, comp);
                    }
                    org.apache.wicket.Component newComp = comp;
                    if (newComp instanceof IDisplay) {
                        panel.addDisplayComponent(obj, (IDisplay) newComp);
                    } else if (newComp instanceof WebImageBeanHolder) {
                        WebImageBeanHolder wiBeanHolder = (WebImageBeanHolder) newComp;
                        Object bean = wiBeanHolder.getDelegate();
                        if (bean instanceof IServoyAwareBean) {
                            IServoyAwareBean ourBean = (IServoyAwareBean) bean;
                            panel.addDisplayComponent(obj, ourBean);
                        }
                    }
                    ((IComponent) comp).setLocation(new Point((l.x), (l.y - start)));
                    if (form.getOnRecordEditStartMethodID() > 0 && comp instanceof IFieldComponent) {
                        if (useAJAX && comp instanceof IDisplayData && ((IDisplayData) comp).getDataProviderID() != null && !ScopesUtils.isVariableScope(((IDisplayData) comp).getDataProviderID())) {
                            StartEditOnFocusGainedEventBehavior.addNewBehaviour(comp);
                        }
                    }
                    // - beans
                    if (isAnchoringEnabled && (((obj instanceof Field) && WebAnchoringHelper.needsWrapperDivForAnchoring((Field) obj)) || (obj instanceof Bean) || ((obj instanceof GraphicalComponent) && ComponentFactory.isButton((GraphicalComponent) obj)))) {
                        panel.add(WebAnchoringHelper.getWrapperComponent(comp, obj, start, panel.getSize(), leftToRight, false));
                    } else {
                        panel.add(comp);
                    }
                }
            }
        }
    }
    Iterator it = labelForComponents.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Entry) it.next();
        Object key = entry.getKey();
        if (key instanceof WebBaseLabel || key instanceof WebBaseSubmitLink) {
            IFieldComponent component = (IFieldComponent) labelForComponents.get(entry.getValue());
            if (component != null) {
                if (key instanceof WebBaseLabel) {
                    ((WebBaseLabel) entry.getKey()).setLabelFor(component);
                } else {
                    ((WebBaseSubmitLink) entry.getKey()).setLabelFor(component);
                }
                (component).addLabelFor((ILabel) entry.getKey());
                if (!component.isVisible()) {
                    component.setComponentVisible(component.isVisible());
                }
                if (!component.isEnabled()) {
                    component.setComponentEnabled(component.isEnabled());
                }
            }
        }
    }
    it = emptyDataRenderers.values().iterator();
    while (it.hasNext()) {
        WebDataRenderer panel = (WebDataRenderer) it.next();
        panel.createDataAdapter(app, dataProviderLookup, listener, undoManager);
    }
    return listTocomplete;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) IComponent(com.servoy.j2db.ui.IComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) Bean(com.servoy.j2db.persistence.Bean) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Field(com.servoy.j2db.persistence.Field) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Entry(java.util.Map.Entry) Iterator(java.util.Iterator) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IComponent(com.servoy.j2db.ui.IComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) ISupportPrinting(com.servoy.j2db.persistence.ISupportPrinting) Component(org.apache.wicket.Component) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) Point(java.awt.Point) Point(java.awt.Point) IFormElement(com.servoy.j2db.persistence.IFormElement) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) HashMap(java.util.HashMap) Map(java.util.Map) IDataProviderLookup(com.servoy.j2db.persistence.IDataProviderLookup)

Example 2 with ISupportTabSeq

use of com.servoy.j2db.persistence.ISupportTabSeq in project servoy-client by Servoy.

the class FormLayoutGenerator method getTabSeq.

private static int getTabSeq(IFormElement o) {
    int seq = 0;
    if (o instanceof ISupportTabSeq) {
        seq = ((ISupportTabSeq) o).getTabSeq();
    }
    if (o instanceof IBasicWebComponent) {
        String componentType = FormTemplateGenerator.getComponentTypeName(o);
        WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(componentType);
        if (spec != null) {
            Collection<PropertyDescription> properties = spec.getProperties(NGTabSeqPropertyType.NG_INSTANCE);
            if (properties != null && properties.size() > 0) {
                IBasicWebComponent webComponent = (IBasicWebComponent) o;
                for (PropertyDescription tabSeqProperty : properties) {
                    seq = Utils.getAsInteger(webComponent.getProperty(tabSeqProperty.getName()));
                    break;
                }
            }
        }
    }
    return seq;
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebObjectSpecification(org.sablo.specification.WebObjectSpecification) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) IBasicWebComponent(com.servoy.j2db.persistence.IBasicWebComponent)

Example 3 with ISupportTabSeq

use of com.servoy.j2db.persistence.ISupportTabSeq in project servoy-client by Servoy.

the class DataRendererFactory method placeElements.

// returns usesSliding
private Map placeElements(Iterator<IFormElement> e1, IApplication app, Form form, IScriptExecuter listner, Map emptyDataRenderers, int width, int XCorrection, int YCorrection, boolean printing, boolean cutDataProviderNames, ControllerUndoManager undoManager, boolean isPortal, TabSequenceHelper<Component> tabSequence) throws Exception {
    IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
    Map listTocomplete = new HashMap();
    Map labelForComponents = new HashMap();
    // Insets insets = new Insets(0, 0, 0, 0);
    while (e1.hasNext()) {
        Point l = null;
        IPersist obj = e1.next();
        l = ((IFormElement) obj).getLocation();
        // unkown where to add
        if (l == null)
            continue;
        if (printing && obj instanceof ISupportPrinting) {
            if (!((ISupportPrinting) obj).getPrintable())
                continue;
        }
        Iterator it = emptyDataRenderers.values().iterator();
        while (it.hasNext()) {
            DataRenderer panel = (DataRenderer) it.next();
            int start = panel.getLocation().y;
            if (l.y >= start && l.y < start + panel.getSize().height) {
                Component comp = (Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listner, printing);
                // Test for a visible bean, then get the real component
                if (comp instanceof VisibleBean) {
                    comp = ((VisibleBean) comp).getDelegate();
                }
                if (comp != null) {
                    if (obj instanceof Field && comp instanceof JComponent) {
                        String name = ((Field) obj).getName();
                        if (name != null && !"".equals(name)) {
                            labelForComponents.put(name, comp);
                        }
                    } else if (obj instanceof GraphicalComponent && comp instanceof JLabel) {
                        String labelFor = ((GraphicalComponent) obj).getLabelFor();
                        if (labelFor != null && !"".equals(labelFor)) {
                            labelForComponents.put(comp, labelFor);
                        }
                    }
                    if (obj instanceof ISupportTabSeq && comp instanceof JComponent && (tabSequence != null)) {
                        tabSequence.add(panel, (ISupportTabSeq) obj, comp);
                    }
                    Component newComp = comp;
                    if (newComp instanceof IDisplay) {
                        // HACK:don;t no other way to do this.........
                        if (newComp instanceof IDisplayData && cutDataProviderNames) {
                            IDisplayData da = (IDisplayData) newComp;
                            String id = da.getDataProviderID();
                            if (id != null && !ScopesUtils.isVariableScope(id)) {
                                // only cut first relation (so you can have relation chain inside portal)
                                int index = id.indexOf('.');
                                // TODO:check if part before . is same as relation name (objToRender.getRelationID() )
                                if (index > 0) {
                                    id = id.substring(index + 1);
                                }
                                da.setDataProviderID(id);
                            }
                        }
                        panel.addDisplayComponent(obj, (IDisplay) newComp);
                    }
                    comp.setLocation((l.x) + XCorrection, (l.y - start) + YCorrection);
                    int index = 0;
                    if (!printing && obj instanceof ISupportAnchors) {
                        panel.add(comp, new Integer(((ISupportAnchors) obj).getAnchors()), index);
                    } else if (printing) {
                        if (obj instanceof ISupportPrintSliding && !isPortal) {
                            int slide = ((ISupportPrintSliding) obj).getPrintSliding();
                            if (slide != ISupportPrintSliding.NO_SLIDING) {
                                listTocomplete.put(comp, new Integer(slide));
                                panel.setUsingSliding(true);
                            }
                        }
                        panel.add(comp, index);
                    } else {
                        panel.add(comp, index);
                    }
                }
            }
        }
    }
    if (!printing) {
        Iterator it = labelForComponents.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Entry) it.next();
            if (entry.getKey() instanceof JLabel) {
                JComponent component = (JComponent) labelForComponents.get(entry.getValue());
                if (component != null) {
                    ((JLabel) entry.getKey()).setLabelFor(component);
                    if (component instanceof IFieldComponent) {
                        ((IFieldComponent) component).addLabelFor((ILabel) entry.getKey());
                        if (!((IFieldComponent) component).isVisible()) {
                            ((IFieldComponent) component).setComponentVisible(((IFieldComponent) component).isVisible());
                        }
                        if (!((IFieldComponent) component).isEnabled()) {
                            ((IFieldComponent) component).setComponentEnabled(((IFieldComponent) component).isEnabled());
                        }
                    }
                }
            }
        }
    }
    Iterator it = emptyDataRenderers.values().iterator();
    while (it.hasNext()) {
        DataRenderer panel = (DataRenderer) it.next();
        panel.createDataAdapter(app, dataProviderLookup, listner, undoManager);
    }
    return listTocomplete;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) Field(com.servoy.j2db.persistence.Field) Entry(java.util.Map.Entry) Iterator(java.util.Iterator) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) ISupportPrinting(com.servoy.j2db.persistence.ISupportPrinting) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) Point(java.awt.Point) ISupportPrintSliding(com.servoy.j2db.persistence.ISupportPrintSliding) Point(java.awt.Point) ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) IPersist(com.servoy.j2db.persistence.IPersist) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IDataProviderLookup(com.servoy.j2db.persistence.IDataProviderLookup)

Example 4 with ISupportTabSeq

use of com.servoy.j2db.persistence.ISupportTabSeq in project servoy-client by Servoy.

the class FormElementHelper method getControlledTabSeqReplacementFor.

/**
 * Generates a Servoy controlled tab-sequence-index. We try to avoid sending default (0 or null) tabSeq even
 * for forms that do use default tab sequence in order to avoid problems with nesting default and non-default tabSeq forms.
 *
 * @param designValue the value the persist holds for the tabSeq.
 * @param form the form containing the persist
 * @param persistIfAvailable the persist. For now, 'component' type properties might work with non-persist-linked FormElements so it could be null.
 * When those become persist based as well this will never be null.
 * @return the requested controlled tabSeq (should make tabSeq be identical to the one shown in developer).
 */
public Integer getControlledTabSeqReplacementFor(Integer designValue, PropertyDescription pd, Form flattenedForm, IPersist persistIfAvailable, // TODO more args will be needed here such as the tabSeq property name or description
FlattenedSolution flattenedSolution, // TODO more args will be needed here such as the tabSeq property name or description
boolean design) {
    // TODO this can be removed when we know we'll always have a persist here; currently don't handle this in any way as it's not supported
    if (persistIfAvailable == null || (nestedCall.get() != null && nestedCall.get().booleanValue()))
        return designValue;
    nestedCall.set(Boolean.TRUE);
    final boolean responsiveForm = flattenedForm.isResponsiveLayout();
    try {
        if (flattenedForm.isFormComponent() && persistIfAvailable instanceof AbstractBase) {
            String mainFormName = ((AbstractBase) persistIfAvailable).getRuntimeProperty(FORM_COMPONENT_FORM_NAME);
            if (mainFormName != null) {
                flattenedForm = flattenedSolution.getFlattenedForm(flattenedSolution.getForm(mainFormName));
                // just return the skip value if this is somehow invalid.
                if (flattenedForm == null)
                    return Integer.valueOf(-2);
            }
        }
        boolean formWasModifiedViaSolutionModel = flattenedSolution.hasCopy(flattenedForm);
        Map<TabSeqProperty, Integer> cachedTabSeq = null;
        if (formWasModifiedViaSolutionModel) {
            Pair<Long, Map<TabSeqProperty, Integer>> pair = flattenedForm.getRuntimeProperty(FORM_TAB_SEQUENCE);
            if (pair != null && flattenedForm.getLastModified() == pair.getLeft().longValue()) {
                cachedTabSeq = pair.getRight();
            }
        } else
            cachedTabSeq = formTabSequences.get(flattenedForm.getUUID());
        if (cachedTabSeq == null) {
            cachedTabSeq = new HashMap<TabSeqProperty, Integer>();
            SortedList<TabSeqProperty> selected = new SortedList<TabSeqProperty>(new Comparator<TabSeqProperty>() {

                public int compare(TabSeqProperty o1, TabSeqProperty o2) {
                    int seq1 = o1.getSeqValue();
                    int seq2 = o2.getSeqValue();
                    if (seq1 == ISupportTabSeq.DEFAULT && seq2 == ISupportTabSeq.DEFAULT) {
                        if (responsiveForm) {
                            if (o1.element.getParent() == o2.element.getParent()) {
                                int positionComparator = PositionComparator.comparePoint(false, o1.getLocation(), o2.getLocation());
                                if (positionComparator != 0) {
                                    return positionComparator;
                                }
                            } else {
                                List<ISupportChilds> ancestors = new ArrayList<ISupportChilds>();
                                IPersist persist = o1.element;
                                while (persist.getParent() instanceof AbstractContainer) {
                                    ancestors.add(persist.getParent());
                                    persist = persist.getParent();
                                }
                                persist = o2.element;
                                while (persist.getParent() instanceof AbstractContainer) {
                                    if (ancestors.contains(persist.getParent())) {
                                        // we found the common ancestor
                                        int index = ancestors.indexOf(persist.getParent());
                                        IPersist comparablePersist = index == 0 ? o1.element : ancestors.get(index - 1);
                                        int positionComparator = PositionComparator.comparePoint(false, ((ISupportBounds) comparablePersist).getLocation(), ((ISupportBounds) persist).getLocation());
                                        if (positionComparator != 0) {
                                            return positionComparator;
                                        }
                                    }
                                    persist = persist.getParent();
                                }
                            }
                        } else {
                            int positionComparator = PositionComparator.comparePoint(false, o1.getLocation(), o2.getLocation());
                            if (positionComparator != 0) {
                                return positionComparator;
                            }
                        }
                    }
                    return compareTabSeq(seq1, o1.element, seq2, o2.element, flattenedSolution);
                }
            });
            Map<TabSeqProperty, List<TabSeqProperty>> listFormComponentMap = new HashMap<TabSeqProperty, List<TabSeqProperty>>();
            List<TabSeqProperty> listFormComponentElements = null;
            TabSeqProperty listFormComponentTabSeq = null;
            Iterator<IFormElement> iterator = flattenedForm.getFlattenedObjects(null).iterator();
            while (iterator.hasNext()) {
                IFormElement formElement = iterator.next();
                if (FormTemplateGenerator.isWebcomponentBean(formElement)) {
                    String componentType = FormTemplateGenerator.getComponentTypeName(formElement);
                    WebObjectSpecification specification = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(componentType);
                    if (specification != null) {
                        Collection<PropertyDescription> properties = specification.getProperties(NGTabSeqPropertyType.NG_INSTANCE);
                        Collection<PropertyDescription> formComponentProperties = specification.getProperties(FormComponentPropertyType.INSTANCE);
                        boolean isListFormComponent = isListFormComponent(formComponentProperties);
                        if (properties != null && properties.size() > 0) {
                            IBasicWebComponent webComponent = (IBasicWebComponent) formElement;
                            for (PropertyDescription tabSeqProperty : properties) {
                                int tabseq = Utils.getAsInteger(webComponent.getProperty(tabSeqProperty.getName()));
                                TabSeqProperty seqProperty = new TabSeqProperty(formElement, tabSeqProperty.getName());
                                if (listFormComponentTabSeq == null && isListFormComponent) {
                                    listFormComponentTabSeq = seqProperty;
                                    listFormComponentElements = new ArrayList<TabSeqProperty>();
                                    listFormComponentMap.put(listFormComponentTabSeq, listFormComponentElements);
                                }
                                if (tabseq >= 0) {
                                    selected.add(seqProperty);
                                } else {
                                    cachedTabSeq.put(seqProperty, Integer.valueOf(-2));
                                }
                            }
                        }
                        addFormComponentProperties(formComponentProperties, formElement, flattenedSolution, cachedTabSeq, selected, listFormComponentElements, design, new HashSet<String>());
                    }
                } else if (formElement instanceof ISupportTabSeq) {
                    if (((ISupportTabSeq) formElement).getTabSeq() >= 0) {
                        selected.add(new TabSeqProperty(formElement, StaticContentSpecLoader.PROPERTY_TABSEQ.getPropertyName()));
                    } else {
                        cachedTabSeq.put(new TabSeqProperty(formElement, StaticContentSpecLoader.PROPERTY_TABSEQ.getPropertyName()), Integer.valueOf(-2));
                    }
                }
            }
            int i = 1;
            for (TabSeqProperty tabSeq : selected) {
                cachedTabSeq.put(tabSeq, Integer.valueOf(i++));
            }
            for (TabSeqProperty tabSeq : listFormComponentMap.keySet()) {
                List<TabSeqProperty> elements = listFormComponentMap.get(tabSeq);
                if (elements != null) {
                    Integer value = cachedTabSeq.get(tabSeq);
                    // all elements inside list form component have same tabindex as the list itself
                    for (TabSeqProperty tabSeqElement : elements) {
                        cachedTabSeq.put(tabSeqElement, value);
                    }
                }
            }
            if (!formWasModifiedViaSolutionModel) {
                formTabSequences.putIfAbsent(flattenedForm.getUUID(), cachedTabSeq);
            } else {
                flattenedForm.setRuntimeProperty(FORM_TAB_SEQUENCE, new Pair<>(Long.valueOf(flattenedForm.getLastModified()), cachedTabSeq));
            }
        }
        IPersist realPersist = flattenedForm.findChild(persistIfAvailable.getUUID());
        if (realPersist == null) {
            realPersist = persistIfAvailable;
        }
        Integer controlledTabSeq = cachedTabSeq.get(new TabSeqProperty(realPersist, pd.getName()));
        // if not in tabSeq, use "skip" value
        if (controlledTabSeq == null)
            controlledTabSeq = Integer.valueOf(-2);
        return controlledTabSeq;
    } finally {
        nestedCall.set(Boolean.FALSE);
    }
}
Also used : WebObjectSpecification(org.sablo.specification.WebObjectSpecification) AbstractContainer(com.servoy.j2db.persistence.AbstractContainer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) SortedList(com.servoy.j2db.util.SortedList) ISupportBounds(com.servoy.j2db.persistence.ISupportBounds) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) List(java.util.List) ArrayList(java.util.ArrayList) SortedList(com.servoy.j2db.util.SortedList) IBasicWebComponent(com.servoy.j2db.persistence.IBasicWebComponent) ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) AbstractBase(com.servoy.j2db.persistence.AbstractBase) Point(java.awt.Point) PropertyDescription(org.sablo.specification.PropertyDescription) IFormElement(com.servoy.j2db.persistence.IFormElement) IPersist(com.servoy.j2db.persistence.IPersist) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) WeakHashMap(java.util.WeakHashMap)

Example 5 with ISupportTabSeq

use of com.servoy.j2db.persistence.ISupportTabSeq in project servoy-client by Servoy.

the class TabSequenceHelper method fromAbstractToNamed.

public void fromAbstractToNamed() {
    T tableViewToInsert = null;
    int largestIndexBeforeBody = -1;
    T lastComponentBeforeBody = null;
    LinkedHashMap<T, String> componentGroupsByTabIndex = new LinkedHashMap<T, String>();
    FormController fc = runtimeContainer.getController();
    Form f = fc.getForm();
    Iterator<Part> parts = f.getParts();
    while (parts.hasNext()) {
        Part p = parts.next();
        IDataRenderer dataRenderer = fc.getDataRenderers()[p.getPartType()];
        if (dataRenderer != null) {
            // Later we will insert it in the tab sequence.
            if ((fc.getViewComponent() instanceof IProvideTabSequence) && (p.getPartType() == Part.BODY)) {
                tableViewToInsert = (T) dataRenderer;
            } else {
                SortedMap<ISupportTabSeq, T> dataRendererComponents = abstractTabSequence.get(dataRenderer);
                if (dataRendererComponents != null) {
                    for (ISupportTabSeq supportTabSeq : dataRendererComponents.keySet()) {
                        if (supportTabSeq.getTabSeq() >= 0) {
                            T next = dataRendererComponents.get(supportTabSeq);
                            String name = null;
                            if (supportTabSeq instanceof ISupportName)
                                name = ((ISupportName) supportTabSeq).getName();
                            componentGroupsByTabIndex.put(next, name);
                            if ((p.getPartType() == Part.HEADER) || (p.getPartType() == Part.TITLE_HEADER) || (p.getPartType() == Part.LEADING_GRAND_SUMMARY)) {
                                if (supportTabSeq.getTabSeq() >= largestIndexBeforeBody) {
                                    lastComponentBeforeBody = next;
                                    largestIndexBeforeBody = supportTabSeq.getTabSeq();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    componentsToNames.clear();
    if ((lastComponentBeforeBody == null) && (tableViewToInsert != null))
        componentsToNames.put(tableViewToInsert, null);
    for (T o : componentGroupsByTabIndex.keySet()) {
        componentsToNames.put(o, componentGroupsByTabIndex.get(o));
        if ((tableViewToInsert != null) && (lastComponentBeforeBody != null) && (o.equals(lastComponentBeforeBody)))
            componentsToNames.put(tableViewToInsert, null);
    }
    revertComponentsToNames();
    fromNamedToRuntime();
}
Also used : FormController(com.servoy.j2db.FormController) Form(com.servoy.j2db.persistence.Form) ISupportName(com.servoy.j2db.persistence.ISupportName) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) LinkedHashMap(java.util.LinkedHashMap) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IProvideTabSequence(com.servoy.j2db.IProvideTabSequence) Part(com.servoy.j2db.persistence.Part)

Aggregations

ISupportTabSeq (com.servoy.j2db.persistence.ISupportTabSeq)6 IBasicWebComponent (com.servoy.j2db.persistence.IBasicWebComponent)3 IFormElement (com.servoy.j2db.persistence.IFormElement)3 Point (java.awt.Point)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 PropertyDescription (org.sablo.specification.PropertyDescription)3 WebObjectSpecification (org.sablo.specification.WebObjectSpecification)3 IDisplay (com.servoy.j2db.dataprocessing.IDisplay)2 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)2 Field (com.servoy.j2db.persistence.Field)2 Form (com.servoy.j2db.persistence.Form)2 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)2 IDataProviderLookup (com.servoy.j2db.persistence.IDataProviderLookup)2 IPersist (com.servoy.j2db.persistence.IPersist)2 ISupportPrinting (com.servoy.j2db.persistence.ISupportPrinting)2 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)2 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2