Package pivot.wtk

Examples of pivot.wtk.TableView$CellRenderer


        // Load the main app window
        serializer = new WTKXSerializer();
        window = (Window)serializer.readObject("pivot/tools/net/application.wtkx");
        window.open(display);

        TableView tableView = (TableView)serializer.getObjectByID("log.tableView");
        tableView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
            public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
                boolean consumed = false;

                if (button == Mouse.Button.LEFT && count == 2) {
                    consumed = true;

                    if (detailsFrame == null) {
                        final WTKXSerializer frameSerializer = new WTKXSerializer();

                        try {
                            detailsFrame = (Frame)frameSerializer.readObject
                                ("pivot/tools/net/detailsFrame.wtkx");
                        } catch (Exception ex) {
                            throw new RuntimeException(ex);
                        }
                    }

                    detailsFrame.open(window);
                }

                return consumed;
            }
        });

        PushButton submitButton = (PushButton)serializer.getObjectByID("request.submit");
        submitButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(final Button button) {
                button.setEnabled(false);

                Request httpRequest = getRequest();
                httpRequest.execute(new TaskAdapter<Response>(new TaskListener<Response>() {
                    public void taskExecuted(Task<Response> task) {
                        button.setEnabled(true);
                        Response httpResponse = task.getResult();
                        Transaction transaction = new Transaction((Request)task, httpResponse);

                        TableView tableView = (TableView)serializer.getObjectByID("log.tableView");
                        List<Transaction> tableData = (List<Transaction>)tableView.getTableData();
                        tableData.add(transaction);
                    }

                    public void executeFailed(Task<Response> task) {
                        button.setEnabled(true);
View Full Code Here


    }

    public void install(Component component) {
        super.install(component);

        TableView tableView = (TableView)component;
        tableView.getTableViewListeners().add(this);
        tableView.getTableViewColumnListeners().add(this);
        tableView.getTableViewRowListeners().add(this);
        tableView.getTableViewRowStateListeners().add(this);
        tableView.getTableViewSelectionListeners().add(this);
    }
View Full Code Here

        tableView.getTableViewRowStateListeners().add(this);
        tableView.getTableViewSelectionListeners().add(this);
    }

    public void uninstall() {
        TableView tableView = (TableView)getComponent();
        tableView.getTableViewListeners().remove(this);
        tableView.getTableViewColumnListeners().remove(this);
        tableView.getTableViewRowListeners().remove(this);
        tableView.getTableViewRowStateListeners().remove(this);
        tableView.getTableViewSelectionListeners().remove(this);

        super.uninstall();
    }
View Full Code Here

    }

    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        TableView tableView = (TableView)getComponent();
        TableView.ColumnSequence columns = tableView.getColumns();

        int n = columns.getLength();
        int gridLineStop = includeTrailingVerticalGridLine ? n : n - 1;

        for (int i = 0; i < n; i++) {
View Full Code Here

    }

    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        TableView tableView = (TableView)getComponent();

        int n = tableView.getTableData().getLength();
        preferredHeight = getRowHeight() * n;

        return preferredHeight;
    }
View Full Code Here

        // No-op
    }

    @SuppressWarnings("unchecked")
    public void paint(Graphics2D graphics) {
        TableView tableView = (TableView)getComponent();
        List<Object> tableData = (List<Object>)tableView.getTableData();
        TableView.ColumnSequence columns = tableView.getColumns();

        int width = getWidth();
        int height = getHeight();

        int rowHeight = getRowHeight();
        Sequence<Integer> columnWidths = getColumnWidths();

        // Paint the background
        graphics.setPaint(backgroundColor);
        graphics.fillRect(0, 0, width, height);

        // Paint the list contents
        int rowStart = 0;
        int rowEnd = tableData.getLength() - 1;

        // Ensure that we only paint items that are visible
        Rectangle clipBounds = graphics.getClipBounds();
        if (clipBounds != null) {
            rowStart = Math.max(rowStart, (int)Math.floor(clipBounds.y
                / (double)rowHeight));
            rowEnd = Math.min(rowEnd, (int)Math.ceil((clipBounds.y
                + clipBounds.height) / (double)rowHeight) - 1);
        }

        int rowY = rowStart * rowHeight;

        for (int rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) {
            Object rowData = tableData.get(rowIndex);
            boolean rowHighlighted = (rowIndex == highlightedIndex
                && tableView.getSelectMode() != TableView.SelectMode.NONE);
            boolean rowSelected = tableView.isRowSelected(rowIndex);
            boolean rowDisabled = tableView.isRowDisabled(rowIndex);

            Color rowBackgroundColor = null;

            if (rowSelected) {
                rowBackgroundColor = (tableView.isFocused())
                    ? this.selectionBackgroundColor : inactiveSelectionBackgroundColor;
            } else {
                if (rowHighlighted && showHighlight && !rowDisabled) {
                    rowBackgroundColor = highlightBackgroundColor;
                } else {
View Full Code Here

     * The height of one table row.
     */
    public int getRowHeight() {
        int rowHeight = 0;

        TableView tableView = (TableView)getComponent();
        TableView.ColumnSequence columns = tableView.getColumns();

        for (int i = 0, n = columns.getLength(); i < n; i++) {
            TableView.Column column = columns.get(i);
            TableView.CellRenderer cellRenderer = column.getCellRenderer();

View Full Code Here

     *
     * @return
     * The widths of all columns based on the current overall width.
     */
    public Sequence<Integer> getColumnWidths() {
        TableView tableView = (TableView)getComponent();

        return getColumnWidths(tableView.getColumns(), getWidth());
    }
View Full Code Here

    public int getRowAt(int y) {
        if (y < 0) {
            throw new IllegalArgumentException("y is negative");
        }

        TableView tableView = (TableView)getComponent();
        List<Object> tableData = (List<Object>)tableView.getTableData();

        int rowIndex = (y / getRowHeight());

        if (rowIndex >= tableData.getLength()) {
            rowIndex = -1;
View Full Code Here

        return new Bounds(columnX, 0, columnWidths.get(columnIndex), getHeight());
    }

    @SuppressWarnings("unchecked")
    public Bounds getCellBounds(int rowIndex, int columnIndex) {
        TableView tableView = (TableView)getComponent();
        List<Object> tableData = (List<Object>)tableView.getTableData();
        Sequence<Integer> columnWidths = getColumnWidths();

        if (rowIndex < 0
            || rowIndex >= tableData.getLength()) {
            throw new IndexOutOfBoundsException();
View Full Code Here

TOP

Related Classes of pivot.wtk.TableView$CellRenderer

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.