Package com.psddev.cms.db

Examples of com.psddev.cms.db.ToolUi$CssClassProcessor


                sct.setDisplayName(selected.getDisplayName());
                sct.setInternalName(selected.getInternalName());
            }

            for (ObjectField of : selected.getFields()) {
                ToolUi ui = of.as(ToolUi.class);

                if (!ui.isHidden()) {
                    boolean found = false;
                    for (ContentField cf : sct.getFields()) {
                        if (of.getInternalName().equals(cf.getInternalName())) {
                            found = true;
                            break;
                        }
                    }

                    if (!found) {
                        ContentField cf = new ContentField();

                        cf.setTab(ui.getTab());
                        cf.setDisplayName(of.getDisplayName());
                        cf.setInternalName(of.getInternalName());
                        sct.getFields().add(cf);
                    }
                }
View Full Code Here


        this.page = page;
        this.writer = page.getWriter();
        this.search = search;

        ObjectType selectedType = search.getSelectedType();
        ToolUi ui = selectedType == null ? null : selectedType.as(ToolUi.class);
        PaginatedResult<?> result = null;

        if (selectedType != null) {
            if (search.getSort() != null) {
                AuthenticationFilter.Static.putUserSetting(page.getRequest(), SORT_SETTING_PREFIX + selectedType.getId(), search.getSort());

            } else {
                Object sortSetting = AuthenticationFilter.Static.getUserSetting(page.getRequest(), SORT_SETTING_PREFIX + selectedType.getId());

                if (!ObjectUtils.isBlank(sortSetting)) {
                    search.setSort(sortSetting.toString());
                }
            }
        }

        if (search.getSort() == null) {
            search.setShowMissing(true);

            if (ui != null && ui.getDefaultSortField() != null) {
                search.setSort(ui.getDefaultSortField());

            } else if (!ObjectUtils.isBlank(search.getQueryString())) {
                search.setSort(Search.RELEVANT_SORT_VALUE);

            } else {
View Full Code Here

     * @param attributes Extra attributes for the HTML tag.
     */
    public void writeObjectSelect(ObjectField field, Object value, Object... attributes) throws IOException {
        ErrorUtils.errorIfNull(field, "field");

        ToolUi ui = field.as(ToolUi.class);
        String placeholder = ObjectUtils.firstNonNull(ui.getPlaceholder(), "");

        if (field.isRequired()) {
            placeholder += " (Required)";
        }

        if (isObjectSelectDropDown(field)) {
            Search dropDownSearch = new Search(field);
            dropDownSearch.setParentId(param(UUID.class, OBJECT_ID_PARAMETER));
            dropDownSearch.setParentTypeId(param(UUID.class, TYPE_ID_PARAMETER));

            List<?> items;
            if (field.getTypes().contains(ObjectType.getInstance(ObjectType.class))) {
                List<ObjectType> types = new ArrayList<ObjectType>();
                Predicate predicate = dropDownSearch.toQuery(getSite()).getPredicate();

                for (ObjectType t : Database.Static.getDefault().getEnvironment().getTypes()) {
                    if (t.is(predicate)) {
                        types.add(t);
                    }
                }
                items = new ArrayList<Object>(types);
            } else {
                items = dropDownSearch.toQuery(getSite()).selectAll();
            }

            Collections.sort(items, new ObjectFieldComparator("_label", false));

            writeStart("select",
                    "data-searchable", "true",
                    attributes);
                writeStart("option", "value", "");
                    writeHtml(placeholder);
                writeEnd();

                for (Object item : items) {
                    State itemState = State.getInstance(item);
                    writeStart("option",
                            "selected", item.equals(value) ? "selected" : null,
                            "value", itemState.getId());
                        writeObjectLabel(item);
                    writeEnd();
                }
            writeEnd();

        } else {
            State state = State.getInstance(value);
            StringBuilder typeIds = new StringBuilder();

            for (ObjectType type : field.getTypes()) {
                typeIds.append(type.getId());
                typeIds.append(',');
            }

            if (typeIds.length() > 0) {
                typeIds.setLength(typeIds.length() - 1);
            }

            writeElement("input",
                    "type", "text",
                    "class", "objectId",
                    "data-additional-query", field.getPredicate(),
                    "data-generic-argument-index", field.getGenericArgumentIndex(),
                    "data-dynamic-placeholder", ui.getPlaceholderDynamicText(),
                    "data-label", value != null ? getObjectLabel(value) : null,
                    "data-pathed", ToolUi.isOnlyPathed(field),
                    "data-preview", getPreviewThumbnailUrl(value),
                    "data-searcher-path", ui.getInputSearcherPath(),
                    "data-suggestions", ui.isEffectivelySuggestions(),
                    "data-typeIds", typeIds,
                    "data-visibility", value != null ? state.getVisibilityLabel() : null,
                    "value", value != null ? state.getId() : null,
                    "placeholder", placeholder,
                    attributes);
View Full Code Here

                        if (absMax != null) {
                            constraints.add("Absolute Maximum: " + absMax);
                        }

                        ToolUi fieldUi = field.as(ToolUi.class);
                        Object sugMin = fieldUi.getSuggestedMinimum();
                        Object sugMax = fieldUi.getSuggestedMaximum();

                        if (sugMin != null) {
                            constraints.add("Suggested Minimum: " + sugMin);
                        }
View Full Code Here

TOP

Related Classes of com.psddev.cms.db.ToolUi$CssClassProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.