Search in sources :

Example 1 with IProvideTabSequence

use of com.servoy.j2db.IProvideTabSequence 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

FormController (com.servoy.j2db.FormController)1 IProvideTabSequence (com.servoy.j2db.IProvideTabSequence)1 Form (com.servoy.j2db.persistence.Form)1 ISupportName (com.servoy.j2db.persistence.ISupportName)1 ISupportTabSeq (com.servoy.j2db.persistence.ISupportTabSeq)1 Part (com.servoy.j2db.persistence.Part)1 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)1 LinkedHashMap (java.util.LinkedHashMap)1