Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Component


            && title.length() > 0) {
            LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
            topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
        }

        Component content = border.getContent();
        if (content != null) {
            content.setLocation(padding.left + thickness,
                padding.top + topThickness);

            int contentWidth = Math.max(width - (padding.left + padding.right
                + (thickness * 2)), 0);
            int contentHeight = Math.max(height - (padding.top + padding.bottom
                + (topThickness + thickness)), 0);

            content.setSize(contentWidth, contentHeight);
        }
    }
View Full Code Here


                TablePane.Column tablePaneColumn = new TablePane.Column();
                tablePaneColumns.add(tablePaneColumn);

                // Determine which component to use as the editor for this column
                String columnName = tableViewColumns.get(i).getName();
                Component editorComponent = null;
                if (columnName != null) {
                    editorComponent = cellEditors.get(columnName);
                }

                // Default to a TextInput editor
                if (editorComponent == null) {
                    TextInput editorTextInput = new TextInput();
                    editorTextInput.setTextKey(columnName);
                    editorComponent = editorTextInput;
                }

                // Disable the component for read-only properties. Components
                // that are already disabled must be custom cell editor
                // components and assumed to represent read-only properties.
                if (!editorComponent.isEnabled()
                    || (beanDictionary != null
                    && beanDictionary.isReadOnly(columnName))) {
                    editorComponent.getUserData().put(READ_ONLY_KEY, true);
                }

                // Add the editor component to the table pane
                tablePaneRow.add(editorComponent);
            }
View Full Code Here

                        public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) {
                            // Clear the opening flag
                            opening = false;

                            // Focus the initial editor component
                            Component focusComponent = tablePane.getCellComponent(0, columnIndex);
                            focusComponent.requestFocus();

                            // Remove this listener
                            cardPane.getCardPaneListeners().remove(this);
                        }
                    });
View Full Code Here

                // may represent a relative width, and we need the actual width
                int columnWidth = tableView.getColumnBounds(i).width;
                tablePaneColumn.setWidth(columnWidth);

                // Disable the editor component if necessary
                Component editorComponent = tablePaneRow.get(i);
                boolean isReadOnly = (editorComponent.getUserData().get(READ_ONLY_KEY) != null);
                editorComponent.setEnabled(!isReadOnly && columnWidth > 0);
            }
        }
View Full Code Here

                Calendar calendar = (Calendar)TerraCalendarSkin.this.getComponent();
                int cellIndex = getCellIndex(date.year, date.month, date.day, calendar.getLocale());
                int rowIndex = cellIndex / 7;
                int columnIndex = cellIndex % 7;

                Component nextButton;
                switch (keyCode) {
                    case Keyboard.KeyCode.UP: {
                        do {
                            rowIndex--;
                            if (rowIndex < 0) {
                                rowIndex = 5;
                            }

                            TablePane.Row row = calendarTablePane.getRows().get(rowIndex + 2);
                            nextButton = row.get(columnIndex);
                        } while (!nextButton.isEnabled());

                        nextButton.requestFocus();
                        break;
                    }

                    case Keyboard.KeyCode.DOWN: {
                        do {
                            rowIndex++;
                            if (rowIndex > 5) {
                                rowIndex = 0;
                            }

                            TablePane.Row row = calendarTablePane.getRows().get(rowIndex + 2);
                            nextButton = row.get(columnIndex);
                        } while (!nextButton.isEnabled());

                        nextButton.requestFocus();
                        break;
                    }

                    case Keyboard.KeyCode.LEFT: {
                        TablePane.Row row = calendarTablePane.getRows().get(rowIndex + 2);

                        do {
                            columnIndex--;
                            if (columnIndex < 0) {
                                columnIndex = 6;
                            }

                            nextButton = row.get(columnIndex);
                        } while (!nextButton.isEnabled());

                        nextButton.requestFocus();
                        break;
                    }

                    case Keyboard.KeyCode.RIGHT: {
                        TablePane.Row row = calendarTablePane.getRows().get(rowIndex + 2);

                        do {
                            columnIndex++;
                            if (columnIndex > 6) {
                                columnIndex = 0;
                            }

                            nextButton = row.get(columnIndex);
                        } while (!nextButton.isEnabled());

                        nextButton.requestFocus();
                        break;
                    }
                }

                consumed = true;
View Full Code Here

        for (int i = 0; i < rowCount; i++) {
            TablePane.Row row = rows.get(i);

            for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
                Component component = row.get(j);

                if (component != null
                    && component.isVisible()) {
                    int columnSpan = TablePane.getColumnSpan(component);

                    if (columnSpan > 1) {
                        // We might need to adjust column widths to accomodate
                        // this spanning cell. First, we find out if any of the
                        // spanned cells are default width and how much space
                        // we've allocated thus far for those cells

                        int spannedDefaultWidthCellCount = 0;
                        int spannedRelativeWeight = 0;
                        int spannedWidth = 0;

                        for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
                            if (defaultWidthColumns[j + k]) {
                                spannedDefaultWidthCellCount++;
                            }

                            spannedRelativeWeight += relativeWeights[j + k];
                            spannedWidth += columnWidths[j + k];
                        }

                        if (spannedRelativeWeight > 0
                            || spannedDefaultWidthCellCount > 0) {
                            int rowHeight = row.isRelative() ? -1 : row.getHeight();
                            int componentPreferredWidth = component.getPreferredWidth(rowHeight);

                            if (componentPreferredWidth > spannedWidth) {
                                // The component's preferred width is larger
                                // than the width we've allocated thus far, so
                                // an adjustment is necessary
View Full Code Here

        for (int i = 0; i < rowCount; i++) {
            TablePane.Row row = rows.get(i);

            for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
                Component component = row.get(j);

                if (component != null
                    && component.isVisible()) {
                    int rowSpan = TablePane.getRowSpan(component);

                    if (rowSpan > 1) {
                        // We might need to adjust row heights to accomodate
                        // this spanning cell. First, we find out if any of the
                        // spanned cells are default height and how much space
                        // we've allocated thus far for those cells

                        int spannedDefaultHeightCellCount = 0;
                        int spannedRelativeWeight = 0;
                        int spannedHeight = 0;

                        for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
                            if (defaultHeightRows[i + k]) {
                                spannedDefaultHeightCellCount++;
                            }

                            spannedRelativeWeight += relativeWeights[i + k];
                            spannedHeight += rowHeights[i + k];
                        }

                        if (spannedRelativeWeight > 0
                            || spannedDefaultHeightCellCount > 0) {
                            int componentPreferredHeight =
                                component.getPreferredHeight(columnWidths[j]);

                            if (componentPreferredHeight > spannedHeight) {
                                // The component's preferred height is larger
                                // than the height we've allocated thus far, so
                                // an adjustment is necessary
View Full Code Here

        for (int i = 0; i < rowCount && baseline == -1; i++) {
            TablePane.Row row = rows.get(i);
            boolean rowVisible = false;

            for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
                Component component = row.get(j);

                if (component != null
                    && component.isVisible()) {
                    int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j);
                    int componentWidth = (columnSpan - 1) * horizontalSpacing;
                    for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
                        componentWidth += columnWidths[j + k];
                    }

                    int rowSpan = Math.min(TablePane.getRowSpan(component), rowCount  - i);
                    int componentHeight = (rowSpan - 1) * verticalSpacing;
                    for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
                        componentHeight += rowHeights[i + k];
                    }

                    baseline = component.getBaseline(Math.max(componentWidth, 0),
                        Math.max(componentHeight, 0));

                    if (baseline != -1) {
                        baseline += rowY;
                    }
View Full Code Here

        for (int i = 0; i < rowCount; i++) {
            TablePane.Row row = rows.get(i);

            int componentX = padding.left;
            for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
                Component child = row.get(j);

                if (child != null
                    && child.isVisible()) {
                    child.setLocation(componentX, componentY);

                    int columnSpan = TablePane.getColumnSpan(child);
                    columnSpan = Math.min(columnSpan, columnCount - j);
                    int childWidth = (columnSpan - 1) * horizontalSpacing;
                    for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
                        childWidth += columnWidths[j + k];
                    }

                    int rowSpan = TablePane.getRowSpan(child);
                    rowSpan = Math.min(rowSpan,rowCount  - i);
                    int childHeight = (rowSpan - 1) * verticalSpacing;
                    for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
                        childHeight += rowHeights[i + k];
                    }

                    // Set the component's size
                    child.setSize(Math.max(childWidth, 0), Math.max(childHeight, 0));
                }

                if (visibleColumns[j]) {
                    componentX += (columnWidths[j] + horizontalSpacing);
                }
View Full Code Here

        if (keyCode == Keyboard.KeyCode.TAB
            && getComponent().isFocused()) {
            Direction direction = (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) ?
                Direction.BACKWARD : Direction.FORWARD;

            Component previousFocusedComponent = Component.getFocusedComponent();
            previousFocusedComponent.transferFocus(direction);

            Component focusedComponent = Component.getFocusedComponent();

            if (previousFocusedComponent != focusedComponent) {
                // Ensure that the focused component is visible if it is in a viewport
                focusedComponent.scrollAreaToVisible(0, 0, focusedComponent.getWidth(),
                    focusedComponent.getHeight());

                consumed = true;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Component

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.