magnolia-ui-vaadin-common-widgets Version: 5.0-alpha1-rc1 Last Published: Dec 10, 2012

CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
com/vaadin/terminal/gwt/client/ui/VScrollTablePatched.java5892
info/magnolia/ui/vaadin/gwt/client/grid/VMagnoliaTreeTable.java410
                    public void execute() {
                        if (showRowHeaders) {
                            setCellWidth(0, tHead.getHeaderCell(0).getWidth());
                            calcAndSetSpanWidthOnCell(1);
                        } else {
                            calcAndSetSpanWidthOnCell(0);
                        }
                    }
                });
            }

            @Override
            protected boolean isRenderHtmlInCells() {
                return htmlContentAllowed;
            }

            @Override
            protected void addCellsFromUIDL(UIDL uidl, char[] aligns, int col,
                    int visibleColumnIndex) {
                htmlContentAllowed = uidl.getBooleanAttribute("gen_html");
                spanColumns = uidl.getBooleanAttribute("gen_span");

                final Iterator<?> cells = uidl.getChildIterator();
                if (spanColumns) {
                    int colCount = uidl.getChildCount();
                    if (cells.hasNext()) {
                        final Object cell = cells.next();
                        if (cell instanceof String) {
                            addSpannedCell(uidl, cell.toString(), aligns[0],
                                    "", htmlContentAllowed, false, null,
                                    colCount);
                        } else {
                            addSpannedCell(uidl, (Widget) cell, aligns[0], "",
                                    false, colCount);
                        }
                    }
                } else {
                    super.addCellsFromUIDL(uidl, aligns, col,
                            visibleColumnIndex);
                }
            }

            private void addSpannedCell(UIDL rowUidl, Widget w, char align,
                    String style, boolean sorted, int colCount) {
                TableCellElement td = DOM.createTD().cast();
                td.setColSpan(colCount);
                initCellWithWidget(w, align, style, sorted, td);
FileLine
info/magnolia/ui/vaadin/grid/MagnoliaTable.java53
info/magnolia/ui/vaadin/grid/MagnoliaTreeTable.java52
        addStyleName("v-magnolia-table");
        setSelectable(true);
        setMultiSelect(true);
        setDragMode(TableDragMode.NONE);
        setImmediate(true);
    }

    @Override
    public void changeVariables(Object source, Map<String, Object> variables) {
        super.changeVariables(source, variables);
        if (variables.containsKey("selectAll")) {
            boolean selectAll = (Boolean) variables.get("selectAll");
            if (selectAll) {
                Collection< ? > ids = getItemIds();
                for (final Object id : ids) {
                    select(id);
                }
            } else {
                setValue(null);
            }
        }

        if (variables.containsKey("toggleSelection")) {
            boolean selected = (Boolean) variables.get("toggleSelection");
            String key = String.valueOf(variables.get("toggledRowId"));
            final Object id = itemIdMapper.get(key);
            if (selected) {
                select(id);
            } else {
                unselect(id);
            }
        }
    }
FileLine
com/vaadin/terminal/gwt/client/ui/VScrollTablePatched.java5948
info/magnolia/ui/vaadin/gwt/client/grid/VMagnoliaTreeTable.java472
                addTreeSpacer(rowUidl);
            }

            @Override
            protected void setCellWidth(int cellIx, int width) {
                if (isSpanColumns()) {
                    if (showRowHeaders) {
                        if (cellIx == 0) {
                            super.setCellWidth(0, width);
                        } else {
                            // We need to recalculate the spanning TDs width for
                            // every cellIx in order to support column resizing.
                            calcAndSetSpanWidthOnCell(1);
                        }
                    } else {
                        // Same as above.
                        calcAndSetSpanWidthOnCell(0);
                    }
                } else {
                    super.setCellWidth(cellIx, width);
                }
            }

            private void calcAndSetSpanWidthOnCell(final int cellIx) {
                int spanWidth = 0;
                for (int ix = (showRowHeaders ? 1 : 0); ix < tHead
                        .getVisibleCellCount(); ix++) {
                    spanWidth += tHead.getHeaderCell(ix).getOffsetWidth();
                }
                Util.setWidthExcludingPaddingAndBorder((Element) getElement()
                        .getChild(cellIx), spanWidth, 13, false);
            }
        }
FileLine
info/magnolia/ui/vaadin/gwt/client/editor/GWTSelector.java526
info/magnolia/ui/vaadin/gwt/client/editor/GWTSelector.java600
            futureWidth = initW + (targetX - initX);
            futureHeight = initH + (targetY - initY);

            if (futureWidth < this.MIN_SIZE || futureHeight < this.MIN_SIZE) {
                return;
            }

            nInnerWidth = futureWidth;
            nInnerHeight = futureHeight;

            // compensation for specified aspect ratio
            if (this.aspectRatio != 0) {
                if (Math.abs(initX - targetX) > Math.abs(initY - targetY)) {
                    // cursor goes right, bottom side goes down...

                    nInnerHeight = (int) (nInnerWidth / this.aspectRatio);

                    // to prevent resizing out of the canvas on the Y axis
                    if ((this.nInnerHeight + this.nInnerY) >= this.nOuterHeight) {
                        this.nInnerHeight = this.nOuterHeight - this.nInnerY;
                        this.nInnerWidth = (int) (this.nInnerHeight * this.aspectRatio);
                        this.nInnerY = this.nOuterHeight - this.nInnerHeight;
                        targetX = this.nOuterWidth;
FileLine
com/vaadin/terminal/gwt/client/ui/VScrollTablePatched.java3159
com/vaadin/terminal/gwt/client/ui/VScrollTablePatched.java3939
        public void setFooterCell(int index, FooterCell cell) {
            if (cell.isEnabled()) {
                // we're moving the cell
                DOM.removeChild(tr, cell.getElement());
                orphan(cell);
                visibleCells.remove(cell);
            }
            if (index < visibleCells.size()) {
                // insert to right slot
                DOM.insertChild(tr, cell.getElement(), index);
                adopt(cell);
                visibleCells.add(index, cell);
            } else if (index == visibleCells.size()) {
                // simply append
                DOM.appendChild(tr, cell.getElement());
                adopt(cell);
                visibleCells.add(cell);
            } else {
                throw new RuntimeException(
                        "Header cells must be appended in order");
            }
        }

        /**
         * Remove a cell by using the columnId
         * 
         * @param colKey
         *            The columnId to remove
         */
        public void removeCell(String colKey) {