Search in sources :

Example 6 with FlattenedForm

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

the class FlattenedSolution method deregisterLiveForm.

/**
 * @param form
 * @param namedInstance
 */
public void deregisterLiveForm(Form form, String namedInstance) {
    synchronized (liveForms) {
        if (form instanceof FlattenedForm) {
            for (Form f : ((FlattenedForm) form).getAllForms()) {
                deregisterLiveForm(f, namedInstance);
            }
        } else {
            flushFlattendFormCache(form);
            Set<String> instances = liveForms.get(form.getName());
            if (instances != null) {
                instances.remove(namedInstance);
                if (instances.size() == 0) {
                    liveForms.remove(form.getName());
                }
            }
        }
        // Test forms if they now are ok. (form they build on when they where changed is now destroyed)
        ChangedFormData changedFormData = changedForms.get(form.getName());
        if (changedFormData != null) {
            changedFormData.instances.remove(namedInstance);
            if (changedFormData.instances.size() == 0) {
                changedForms.remove(form.getName());
            }
        }
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Example 7 with FlattenedForm

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

the class FlattenedSolution method createFlattenedForm.

/*
	 * Create a flattened form for the form that is child of the current solution.
	 */
public FlattenedForm createFlattenedForm(Form form) {
    Form myForm;
    Solution solcopy = getSolutionCopy(false);
    if (form.getParent() == getSolution() || form.getParent() == solcopy) {
        myForm = form;
    } else {
        myForm = null;
        if (solcopy != null) {
            myForm = (Form) solcopy.getChild(form.getUUID());
        }
        if (myForm == null) {
            myForm = (Form) getSolution().getChild(form.getUUID());
        }
        if (myForm == null && modules != null) {
            for (Solution mod : modules) {
                myForm = (Form) mod.getChild(form.getUUID());
                if (myForm != null)
                    break;
            }
        }
        if (myForm == null) {
            throw new RuntimeException("Cannot find form '" + form + "' in solution '" + getSolution() + "'");
        }
    }
    try {
        return new FlattenedForm(this, myForm);
    } catch (RuntimeException ex) {
        Debug.error("Error while creating full hierarchy form (flattened form) for: " + (myForm != null ? myForm.getName() : "<form not found>"), ex);
        throw ex;
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Solution(com.servoy.j2db.persistence.Solution)

Example 8 with FlattenedForm

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

the class PersistHelper method getFlattenedPersist.

public static ISupportChilds getFlattenedPersist(FlattenedSolution flattenedSolution, Form parent, ISupportChilds persist) {
    ISupportChilds flattenedPersist = persist;
    if (flattenedPersist instanceof Form) {
        flattenedPersist = flattenedSolution.getFlattenedForm(flattenedPersist);
    }
    if (flattenedPersist instanceof LayoutContainer && !(flattenedPersist instanceof FlattenedLayoutContainer)) {
        FlattenedForm ff = flattenedSolution.getFlattenedForm(parent) instanceof FlattenedForm ? (FlattenedForm) flattenedSolution.getFlattenedForm(parent) : flattenedSolution.createFlattenedForm(parent);
        flattenedPersist = new FlattenedLayoutContainer(ff, (LayoutContainer) flattenedPersist);
    }
    return flattenedPersist;
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) FlattenedLayoutContainer(com.servoy.j2db.persistence.FlattenedLayoutContainer) LayoutContainer(com.servoy.j2db.persistence.LayoutContainer) FlattenedLayoutContainer(com.servoy.j2db.persistence.FlattenedLayoutContainer)

Example 9 with FlattenedForm

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

the class FormScope method hasInstance.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.scripting.DefaultScope#hasInstance(org.mozilla.javascript.Scriptable)
	 */
@Override
public boolean hasInstance(Scriptable instance) {
    if (instance instanceof FormScope) {
        Form instanceForm = ((FormScope) instance).getFormController().getForm();
        Form thisForm = getFormController().getForm();
        if (thisForm.equals(instanceForm))
            return true;
        if (instanceForm instanceof FlattenedForm) {
            if (thisForm instanceof FlattenedForm) {
                thisForm = ((FlattenedForm) thisForm).getForm();
            }
            return ((FlattenedForm) instanceForm).getAllForms().contains(thisForm);
        }
    }
    return false;
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Example 10 with FlattenedForm

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

the class FormLayoutGenerator method generateFormElementWrapper.

public static void generateFormElementWrapper(PrintWriter writer, FormElement fe, Form form, boolean isResponsive) {
    String designId = getDesignId(fe);
    String name = fe.getName();
    boolean selectable = fe.isFormComponentChild() ? name.indexOf('$' + FormElement.SVY_NAME_PREFIX) == -1 : true;
    if (designId != null) {
        writer.print("<div ng-style=\"layout('");
        writer.print(designId);
        writer.print("')\"");
        JSONObject ngClass = new JSONObject();
        ngClass.put("invisible_element", "<getDesignFormControllerScope().model('" + designId + "').svyVisible == false<".toString());
        // added <> tokens so that we can remove quotes around the values so that angular will evaluate at runtime
        ngClass.put("highlight_element", "<getDesignFormControllerScope().highlightElement('" + designId + "') == true<".toString());
        if (fe.isFormComponentChild()) {
            ngClass.put("formComponentChild", true);
        }
        writer.print(" ng-class='" + ngClass.toString().replaceAll("\"<", "").replaceAll("<\"", "").replaceAll("'", "\"") + "'");
        String cls = "svy-wrapper";
        Form currentForm = form;
        if (form instanceof FlattenedForm)
            currentForm = ((FlattenedForm) form).getForm();
        if (fe.getPersistIfAvailable() != null && Utils.isInheritedFormElement(fe.getPersistIfAvailable(), currentForm)) {
            cls += !currentForm.equals(fe.getPersistIfAvailable().getAncestor(IRepository.FORMS)) ? " inherited_element" : " override_element";
        }
        writer.print(" class=\"" + cls + "\" ");
    } else {
        // calculations during link-phase based on the size of the parent container
        if (fe.getPersistIfAvailable() != null && "servoycore-listformcomponent".equals(fe.getTypeName())) {
            writer.print("<div svy-ng-style=\"layout.");
        } else {
            writer.print("<div ng-style=\"layout.");
        }
        writer.print(name);
        writer.print("\" class=\"svy-wrapper\" ");
    }
    if (!isResponsive && fe.getPersistIfAvailable() instanceof BaseComponent) {
        BaseComponent bc = (BaseComponent) fe.getPersistIfAvailable();
        String style = "";
        if (!form.getUseCssPosition().booleanValue() && !CSSPositionUtils.isInAbsoluteLayoutMode(bc)) {
            int anchors = bc.getAnchors();
            if (((anchors & IAnchorConstants.EAST) > 0) && ((anchors & IAnchorConstants.WEST) > 0)) {
                style += "min-width:" + bc.getSize().width + "px;";
            }
            if (((anchors & IAnchorConstants.NORTH) > 0) && ((anchors & IAnchorConstants.SOUTH) > 0)) {
                style += "min-height:" + bc.getSize().height + "px";
            }
        }
        if (!style.isEmpty()) {
            writer.print(" style='");
            writer.print(style);
            writer.print("'");
        }
    } else if (fe.getPersistIfAvailable() == null && "servoycore-portal".equals(fe.getTypeName()) && (form.getView() == IForm.LIST_VIEW || form.getView() == IFormConstants.VIEW_TYPE_LIST_LOCKED)) {
        writer.print(" style='min-width:");
        writer.print(form.getMinWidth());
        writer.print("px'");
    }
    if (designId != null) {
        writer.print(" svy-id='");
        writer.print(designId);
        writer.print("'");
        if (!selectable) {
            writer.print(" svy-non-selectable='noname'");
        }
        writer.print(" name='");
        writer.print(name);
        writer.print("'");
        List<String>[] typeAndPropertyNames = fe.getSvyTypesAndPropertiesNames();
        if (typeAndPropertyNames[0].size() > 0) {
            writer.print(" svy-types='");
            writer.print("[" + String.join(",", typeAndPropertyNames[0]) + "]");
            writer.print("'");
        }
        String directEditPropertyName = getDirectEditProperty(fe);
        if (directEditPropertyName != null) {
            writer.print(" directEditPropertyName='");
            writer.print(directEditPropertyName);
            writer.print("'");
        }
        List<String> forbiddenComponentNames = fe.getForbiddenComponentNames();
        if (forbiddenComponentNames.size() > 0) {
            writer.print(" svy-forbidden-components='");
            writer.print("[" + String.join(",", forbiddenComponentNames) + "]");
            writer.print("'");
        }
        if (isNotSelectable(fe))
            writer.print(" svy-non-selectable");
    }
    writer.print(">");
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) BaseComponent(com.servoy.j2db.persistence.BaseComponent) JSONObject(org.json.JSONObject) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)14 Form (com.servoy.j2db.persistence.Form)10 IFormController (com.servoy.j2db.IFormController)4 Set (java.util.Set)4 Solution (com.servoy.j2db.persistence.Solution)3 IPersist (com.servoy.j2db.persistence.IPersist)2 ArrayList (java.util.ArrayList)2 IForm (com.servoy.j2db.IForm)1 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 FlattenedLayoutContainer (com.servoy.j2db.persistence.FlattenedLayoutContainer)1 ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)1 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)1 Media (com.servoy.j2db.persistence.Media)1 Part (com.servoy.j2db.persistence.Part)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 RootObjectReference (com.servoy.j2db.persistence.RootObjectReference)1 Style (com.servoy.j2db.persistence.Style)1 RemoteException (java.rmi.RemoteException)1