Package org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel

Examples of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup


        }
    }

    private boolean updateModel(int fromColumnIndex, int toColumnIndex,
            String leftEdgeGroupName, String rightEdgeGroupName) {
        ColumnGroup fromColumnGroup = model
                .getColumnGroupByIndex(fromColumnIndex);
        ColumnGroup toColumnGroup = model.getColumnGroupByIndex(toColumnIndex);

        // If moved to the RIGHT edge of a group - remove from group
        if (rightEdgeGroupName != null) {
            return (model.isPartOfAGroup(fromColumnIndex)) ? fromColumnGroup
                    .removeColumn(fromColumnIndex) : true;
        }

        // If moved to the LEFT edge of a column group - include in the group
        if (leftEdgeGroupName != null) {
            boolean removed = true;
            if (model.isPartOfAGroup(fromColumnIndex)) {
                removed = fromColumnGroup.removeColumn(fromColumnIndex);
            }
            return removed
                    && model.insertColumnIndexes(leftEdgeGroupName,
                            fromColumnIndex);
        }

        // Move column INTO a group
        if (model.isPartOfAGroup(toColumnIndex)
                && !model.isPartOfAGroup(fromColumnIndex)) {
            String groupName = toColumnGroup.getName();
            return model.insertColumnIndexes(groupName, fromColumnIndex);
        }

        // Move column OUT of a group
        if (model.isPartOfAGroup(fromColumnIndex)
                && !model.isPartOfAGroup(toColumnIndex)) {
            return fromColumnGroup.removeColumn(fromColumnIndex);
        }

        // Move column BETWEEN groups
        if (model.isPartOfAGroup(toColumnIndex)
                && model.isPartOfAGroup(fromColumnIndex)) {
            String toGroupName = toColumnGroup.getName();
            String fromGroupName = fromColumnGroup.getName();

            if (fromGroupName.equals(toGroupName)) {
                return true;
            } else {
View Full Code Here


    private boolean updateModel(ILayer underlyingLayer, int toColumnIndex,
            List<Integer> fromColumnPositions, ColumnGroupModel model) {
        // Moving INTO a group
        if (model.isPartOfAGroup(toColumnIndex)) {
            ColumnGroup toColumnGroup = model
                    .getColumnGroupByIndex(toColumnIndex);
            String toGroupName = toColumnGroup.getName();
            if (model.isPartOfAnUnbreakableGroup(toColumnIndex)) {
                return false;
            }

            for (Integer fromColumnPosition : fromColumnPositions) {
                int fromColumnIndex = underlyingLayer
                        .getColumnIndexByPosition(fromColumnPosition.intValue());
                ColumnGroup fromColumnGroup = model
                        .getColumnGroupByIndex(fromColumnIndex);

                // If 'from' index not already present in the 'to' group
                if (fromColumnGroup != toColumnGroup) {
                    if (fromColumnGroup != null) {
                        fromColumnGroup.removeColumn(fromColumnIndex);
                    }
                    model.addColumnsIndexesToGroup(toGroupName, fromColumnIndex);
                }
            }
            return true;
        }

        // Moving OUT OF a group
        if (!model.isPartOfAGroup(toColumnIndex)) {
            for (Integer fromColumnPosition : fromColumnPositions) {
                // Remove from model - if present
                int fromColumnIndex = underlyingLayer
                        .getColumnIndexByPosition(fromColumnPosition.intValue());
                ColumnGroup fromColumnGroup = model
                        .getColumnGroupByIndex(fromColumnIndex);

                if (fromColumnGroup != null
                        && !fromColumnGroup.removeColumn(fromColumnIndex)) {
                    return false;
                }
            }
            return true;
        }
View Full Code Here

        dialog.open();

        if (!dialog.isCancelPressed()) {
            int columnIndex = contextLayer
                    .getColumnIndexByPosition(columnPosition);
            ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
            columnGroup.setName(dialog.getNewColumnLabel());
        }

        return true;
    }
View Full Code Here

        contextLayer.fireLayerEvent(new UngroupColumnsEvent(contextLayer));
    }

    private void handleRemovalFromGroup(Map<String, Integer> toColumnPositions,
            int columnIndex) {
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);

        final String columnGroupName = columnGroup.getName();
        final List<Integer> columnIndexesInGroup = columnGroup.getMembers();
        final int columnGroupSize = columnIndexesInGroup.size();
        if (!toColumnPositions.containsKey(columnGroupName)) {
            for (int colGroupIndex : columnIndexesInGroup) {
                if (ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(
                        colGroupIndex, contextLayer, selectionLayer, model)) {
                    int toPosition = selectionLayer
                            .getColumnPositionByIndex(colGroupIndex);
                    if (colGroupIndex == columnIndex) {
                        if (columnGroupSize == 1) {
                            break;
                        } else {
                            toPosition++;
                        }
                    }
                    toColumnPositions.put(columnGroupName,
                            Integer.valueOf(toPosition));
                    break;
                }
            }
        } else {
            if (columnGroupSize - 1 <= 0) {
                toColumnPositions.remove(columnGroupName);
            }
        }
        columnGroup.removeColumn(columnIndex);
    }
View Full Code Here

        int columnIndex = columnGroupExpandCollapseLayer
                .getColumnIndexByPosition(command.getColumnPosition());
        ColumnGroupModel model = columnGroupExpandCollapseLayer
                .getModel(command.getRowPosition());
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);

        // if group of columnIndex is not collapseable return without any
        // further operation ...
        if (columnGroup == null || !columnGroup.isCollapseable()) {
            return true;
        }

        List<Integer> columnIndexes = new ArrayList<Integer>(
                columnGroup.getMembers());
        columnIndexes.removeAll(columnGroup.getStaticColumnIndexes());

        boolean wasCollapsed = columnGroup.isCollapsed();

        if (wasCollapsed) {
            // we need to cleanup the column position list before we toggle
            // because the columns are hidden before the toggle and will be
            // visible afterwards
            cleanupColumnIndexes(columnIndexes);
        }

        columnGroup.toggleCollapsed();

        if (!wasCollapsed) {
            // we need to cleanup the column position list after we toggle
            // because the columns are hidden now
            cleanupColumnIndexes(columnIndexes);
View Full Code Here

        }
        columnGroup.removeColumn(columnIndex);
    }

    private void handleRemoveColumnGroupCommand(int columnIndex) {
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
        model.removeColumnGroup(columnGroup);
    }
View Full Code Here

     * @param columnPosition
     *            position of any column belonging to the group
     */
    protected int getColumnSpan(int columnPosition) {
        int columnIndex = getColumnIndexByPosition(columnPosition);
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);

        int sizeOfGroup = columnGroup.getSize();

        if (columnGroup.isCollapsed()) {
            int sizeOfStaticColumns = columnGroup.getStaticColumnIndexes()
                    .size();
            if (sizeOfStaticColumns == 0) {
                return 1;
            } else {
                sizeOfGroup = sizeOfStaticColumns;
            }
        }

        int startPositionOfGroup = getStartPositionOfGroup(columnPosition);
        int endPositionOfGroup = startPositionOfGroup + sizeOfGroup;
        List<Integer> columnIndexesInGroup = columnGroup.getMembers();

        for (int i = startPositionOfGroup; i < endPositionOfGroup; i++) {
            int index = getColumnIndexByPosition(i);
            if (!columnIndexesInGroup.contains(Integer.valueOf(index))) {
                sizeOfGroup--;
View Full Code Here

     *            of any column belonging to the group
     * @return first position of the column group
     */
    private int getStartPositionOfGroup(int columnPosition) {
        int bodyColumnIndex = getColumnIndexByPosition(columnPosition);
        ColumnGroup columnGroup = model.getColumnGroupByIndex(bodyColumnIndex);

        int leastPossibleStartPositionOfGroup = columnPosition
                - (columnGroup.getSize() - 1);
        int i = 0;
        for (i = leastPossibleStartPositionOfGroup; i < columnPosition; i++) {
            if (ColumnGroupUtils.isInTheSameGroup(getColumnIndexByPosition(i),
                    bodyColumnIndex, model)) {
                break;
View Full Code Here

        int columnIndex = getColumnIndexByPosition(columnPosition);
        if (rowPosition == 0 && model.isPartOfAGroup(columnIndex)) {
            LabelStack stack = new LabelStack(GridRegion.COLUMN_GROUP_HEADER);

            if (model.isPartOfACollapseableGroup(columnIndex)) {
                ColumnGroup group = model.getColumnGroupByIndex(columnIndex);
                if (group.isCollapsed()) {
                    stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE);
                } else {
                    stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
                }
            }
View Full Code Here

    /**
     * @see ColumnGroup#setUnbreakable(boolean)
     */
    public void setGroupUnbreakable(int columnIndex) {
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
        columnGroup.setUnbreakable(true);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup

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.