Package org.zkoss.zul

Examples of org.zkoss.zul.Textbox


            labelPosition.setValue(_(PositionInWorkReportEnum.LINE.toString()));
        }
    }

    private void appendTextboBoxNameDescriptionField(final Row row) {
        Textbox boxName = new Textbox();
        boxName.setHflex("1");
        boxName.setParent(row);
        boxName
                .setConstraint(validateIfExistTheSameFieldName((DescriptionField) row
                        .getValue()));

        Util.bind(boxName, new Util.Getter<String>() {
            @Override
View Full Code Here


    }

    private void showInvalidDescriptionFieldName(DescriptionField field) {
        // Find which row contains the description field inside grid
        Row row = findRowByValue(listDescriptionFields.getRows(), field);
            Textbox fieldName = (Textbox) row.getFirstChild();
        throw new WrongValueException(fieldName,
                _("The field name must be unique and not empty"));
    }
View Full Code Here

    }

    public void addElement(Component cmp) {
        viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
        Textbox name = (Textbox) cmp.getFellow("newOrderElementName");
        Intbox hours = (Intbox) cmp.getFellow("newOrderElementHours");

        if (StringUtils.isEmpty(name.getValue())) {
            throw new WrongValueException(name, _("cannot be empty"));
        }

        if (hours.getValue() == null) {
            hours.setValue(0);
        }

        Textbox nameTextbox = null;

        // Parse hours
        try {
            if (tree.getSelectedCount() == 1) {
                T node = getSelectedNode();

                T newNode = getModel().addElementAt(node, name.getValue(),
                        hours.getValue());
                getRenderer().refreshHoursValueForThisNodeAndParents(newNode);
                getRenderer().refreshBudgetValueForThisNodeAndParents(newNode);

                // Moved here in order to have items already renderer in order
                // to select the proper element to focus
                reloadTreeUIAfterChanges();

                if (node.isLeaf() && !node.isEmptyLeaf()) {
                    // Then a new container will be created
                    nameTextbox = getRenderer().getNameTextbox(node);
                } else {
                    // select the parent row to add new children ASAP
                    tree.setSelectedItem(getRenderer().getTreeitemForNode(
                            newNode.getParent().getThis()));
                }
            } else {
                getModel().addElement(name.getValue(), hours.getValue());

                // This is needed in both parts of the if, but it's repeated in
                // order to simplify the code
                reloadTreeUIAfterChanges();
            }
        } catch (IllegalStateException e) {
            LOG.warn("exception ocurred adding element", e);
            messagesForUser.showMessage(Level.ERROR, e.getMessage());
        }

        name.setValue("");
        hours.setValue(0);

        if (nameTextbox != null) {
            nameTextbox.focus();
        } else {
            name.focus();
        }
    }
View Full Code Here

            appendDeleteButton(row);
        }

        private void appendConceptInLines(Row row) {
            final ExpenseSheetLine expenseSheetLine = (ExpenseSheetLine) row.getValue();
            final Textbox txtConcept = new Textbox();
            txtConcept.setWidth("160px");
            Util.bind(txtConcept, new Util.Getter<String>() {

                @Override
                public String get() {
                    if (expenseSheetLine != null) {
View Full Code Here

            row.appendChild(bandboxSearch);
        }

        private void appendCode(final Row row) {
            final ExpenseSheetLine line = (ExpenseSheetLine) row.getValue();
            final Textbox code = new Textbox();
            code.setWidth("170px");
            code.setDisabled(getExpenseSheet().isCodeAutogenerated());
            code.applyProperties();

             if (line.getCode() != null) {
                 code.setValue(line.getCode());
             }

            code.addEventListener("onChange", new EventListener() {
                @Override
                public void onEvent(Event event) {
                    final ExpenseSheetLine line = (ExpenseSheetLine) row.getValue();
                    line.setCode(code.getValue());
                }
            });
            code.setConstraint(checkConstraintLineCodes(line));
            row.appendChild(code);
        }
View Full Code Here

     * Append a textbox @{link code} to row
     * @param row
     */
    private void appendTextboxCode(final Row row) {
        final HourCost hourCost = ((HourCost) row.getValue());
        final Textbox txtCode = new Textbox();
        txtCode.setWidth("200px");
        if (hourCost != null) {
            CostCategory costCategory = hourCost.getCategory();
            txtCode.setDisabled(costCategory.isCodeAutogenerated());
            Util.bind(txtCode, new Util.Getter<String>() {
                @Override
                public String get() {
                    return hourCost.getCode();
                }
            }, new Util.Setter<String>() {

                @Override
                public void set(String value) {
                    hourCost.setCode(value);
                }
            });

            if (!hourCost.getCategory().isCodeAutogenerated()) {
                txtCode.setConstraint("no empty:"
                        + _("cannot be empty"));
            } else {
                txtCode.setConstraint("");
            }
        }
        row.appendChild(txtCode);
    }
View Full Code Here

     */
    private Component findInMaterialCategoryTree(MaterialCategory materialCategory) {
        final Treechildren children = categoriesTree.getTreechildren();
        for(Treeitem each: (Collection<Treeitem>) children.getItems()) {
            final MaterialCategory _materialCategory = (MaterialCategory) each.getValue();
            final Textbox textbox = getMaterialCategoryTextbox(each);
            // Clear previous errors
            textbox.clearErrorMessage();
            if (_materialCategory.equals(materialCategory)) {
                return textbox;
            }
        }
        return null;
View Full Code Here

        Listbox listbox = (Listbox) window.getFellow("exceptionsList");
        if (listbox != null) {
            for (int i = 0; i < listbox.getItemCount(); i++) {
                Listitem item = (Listitem) listbox.getItems().get(i);
                if (item.getChildren().size() == 5) {
                    Textbox code = (Textbox) ((Listcell) item.getChildren()
                            .get(3)).getFirstChild();
                    if (code != null && !code.isDisabled()
                            && code.getValue().isEmpty()) {
                        throw new WrongValueException(code,
                                _("It cannot be empty"));
                    }
                }
            }
View Full Code Here

            if (snapshotOfOpenedNodes != null) {
                snapshotOfOpenedNodes.openIfRequired(item);
            }

            Treecell cellForName = new Treecell();
            Textbox textboxName= new Textbox();
            textboxName.setWidth("400px");
            cellForName.appendChild(Util.bind(textboxName,
                    new Util.Getter<String>() {

                        @Override
                        public String get() {
                            return criterionForThisRow.getName();
                        }
                    }, new Util.Setter<String>() {

                        @Override
                        public void set(String value) {
                            criterionForThisRow.setName(value);
                        }
                    }));
            String message = _("cannot be empty");
            textboxName
                    .setConstraint("no empty:"+message);

            Treecell cellForActive = new Treecell();
            cellForActive.setStyle("center");
            Checkbox checkboxActive = new Checkbox();
            cellForActive.appendChild(Util.bind(checkboxActive,
                    new Util.Getter<Boolean>() {

                        @Override
                        public Boolean get() {
                            return criterionForThisRow.isActive();
                        }
                    }, new Util.Setter<Boolean>() {

                        @Override
                        public void set(Boolean value) {
                            criterionForThisRow.setActive(value);
                        }
                    }));

            checkboxActive.addEventListener(Events.ON_CHECK,new EventListener() {
                @Override
                        public void onEvent(Event event) {
                    getModel().updateEnabledCriterions(criterionForThisRow.isActive(),criterionForThisRow);
                    reloadTree();
                }
            });

            Treerow tr = null;
            /*
             * Since only one treerow is allowed, if treerow is not null, append
             * treecells to it. If treerow is null, contruct a new treerow and
             * attach it to item.
             */
            if (item.getTreerow() == null) {
                tr = new Treerow();
                tr.setParent(item);
            } else {
                tr = item.getTreerow();
                tr.getChildren().clear();
            }
            // Attach treecells to treerow
            tr.setDraggable("true");
            tr.setDroppable("true");

            // Treecell with the cost category of the Criterion
            Treecell cellForCostCategory = new Treecell();
            criterionForThisRow.getCriterion().getCostCategory();
            cellForCostCategory.appendChild(appendAutocompleteType(item));

            // Treecell with the code of the Criterion
            Treecell cellForCode = new Treecell();
            cellForCode.setStyle("center");
            Textbox codeLabel = new Textbox();
            codeLabel.setDisabled(codeEditionDisabled);
            cellForCode.appendChild(Util.bind(codeLabel,
                    new Util.Getter<String>() {

                @Override
                public String get() {
View Full Code Here

            }
            return false;
        }

        if (workReportLine.getEffort() == null) {
            Textbox effort = getEffort(row);
            if (effort == null) {
                String message = _("cannot be empty");
                showInvalidMessage(effort, message);
            }
            if (EffortDuration.parseFromFormattedString(effort.getValue())
                    .compareTo(EffortDuration.zero()) <= 0) {
                String message = _("Effort must be greater than zero");
                showInvalidMessage(effort, message);
            }
            return false;
        }

        if (!workReportLine.isHoursCalculatedByClockConstraint()) {
            Textbox effort = getEffort(row);
            if (effort != null) {
                String message = _("effort is not properly calculated based on clock");
                showInvalidMessage(effort, message);
            }
            return false;
        }

        if (workReportLine.getTypeOfWorkHours() == null) {
            // Locate TextboxOrder
            Listbox autoTypeOfHours = getTypeOfHours(row);
            if (autoTypeOfHours != null) {
                String message = autoTypeOfHours.getItems().isEmpty() ? _("Hours types are empty. Please, create some hours types before proceeding")
                        : _("cannot be empty");
                showInvalidMessage(autoTypeOfHours, message);
            }
            return false;
        }

        if ((!getWorkReport().isCodeAutogenerated())
                && (workReportLine.getCode() == null || workReportLine
                        .getCode().isEmpty())) {
            // Locate TextboxCode
            Textbox txtCode = getCode(row);
            if (txtCode != null) {
                String message = _("cannot be empty.");
                showInvalidMessage(txtCode, message);
            }
            return false;
View Full Code Here

TOP

Related Classes of org.zkoss.zul.Textbox

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.