Example usage for com.google.gwt.user.cellview.client ColumnSortList get

List of usage examples for com.google.gwt.user.cellview.client ColumnSortList get

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client ColumnSortList get.

Prototype

public ColumnSortInfo get(int index) 

Source Link

Document

Get the ColumnSortInfo at the specified index.

Usage

From source file:com.agnie.useradmin.contextmgr.client.presenter.shared.ui.CTXUsersCellTable.java

License:Open Source License

public Sort getSortColumn() {
    ColumnSortList sortList = table.getColumnSortList();
    if (sortList != null && sortList.size() > 0) {
        ColumnSortInfo col = sortList.get(0);

        return new Sort(col.getColumn().getDataStoreName(),
                (col.isAscending() ? SortOrder.ASC : SortOrder.DESC));
    }/*from   www.j a v a2 s.  com*/
    return null;
}

From source file:com.agnie.useradmin.main.client.presenter.sahered.ui.RolesCellTable.java

License:Open Source License

public Sort getSortColumn() {
    ColumnSortList sortList = table.getColumnSortList();
    if (sortList != null && sortList.size() > 0) {
        ColumnSortInfo col = sortList.get(0);
        return new Sort(col.getColumn().getDataStoreName(),
                (col.isAscending() ? SortOrder.ASC : SortOrder.DESC));
    }//from  w  w  w.jav  a  2  s .c  om
    return null;
}

From source file:com.bearsoft.gwt.ui.widgets.grid.builders.ThemedHeaderOrFooterBuilder.java

@Override
protected boolean buildHeaderOrFooterImpl() {
    AbstractCellTable<T> table = getTable();
    boolean isFooter = isBuildingFooter();

    int columnCount = table.getColumnCount();
    if (columnCount > 0) {
        // Early exit if there aren't any headers or footers in the columns
        // to render.
        boolean hasHeadersOrFooters = false;
        for (int i = 0; i < columnCount; i++) {
            if (getHeader(i) != null) {
                hasHeadersOrFooters = true;
                break;
            }/*from  ww w .j  a v  a 2  s.  co  m*/
        }
        if (hasHeadersOrFooters) {
            List<HeaderNode<T>> headersForest;
            if (headerNodes == null) {
                headersForest = new ArrayList<>();
                for (int curColumn = 0; curColumn < columnCount; curColumn++) {
                    Header<?> headerOrFooter = getHeader(curColumn);
                    HeaderNode<T> hn = new HeaderNode<T>();
                    hn.setHeader((Header<String>) headerOrFooter);
                    headersForest.add(hn);
                }
            } else {
                headersForest = headerNodes;
            }
            // Get information about the sorted columns.
            ColumnSortList sortList;
            if (sortListHolder != null) {
                sortList = sortListHolder.getSortList();
            } else {
                sortList = table.getColumnSortList();
            }
            Map<Column<T, ?>, ColumnSortList.ColumnSortInfo> sortedColumns = new HashMap<>();
            if (sortList != null) {
                for (int i = 0; i < sortList.size(); i++) {
                    ColumnSortList.ColumnSortInfo sInfo = sortList.get(i);
                    sortedColumns.put((Column<T, ?>) sInfo.getColumn(), sInfo);
                }
            }
            buildNodes(headersForest, sortedColumns);
            return true;
        } else {
            // No headers to render;
            return false;
        }
    } else {
        // Nothing to render;
        return false;
    }
}

From source file:com.databasepreservation.visualization.client.common.lists.AsyncTableCell.java

protected Sorter createSorter(ColumnSortList columnSortList,
        Map<Column<T, ?>, List<String>> columnSortingKeyMap) {
    Sorter sorter = new Sorter();
    for (int i = 0; i < columnSortList.size(); i++) {
        ColumnSortInfo columnSortInfo = columnSortList.get(i);

        List<String> sortParameterKeys = columnSortingKeyMap.get(columnSortInfo.getColumn());

        if (sortParameterKeys != null) {
            for (String sortParameterKey : sortParameterKeys) {
                sorter.add(new SortParameter(sortParameterKey, !columnSortInfo.isAscending()));
            }//from   w  ww.jav  a 2s  .  co  m
        } else {
            logger.warn("Selecting a sorter that is not mapped");
        }
    }
    return sorter;
}

From source file:com.eucalyptus.webui.client.view.SearchResultTable.java

License:Open Source License

public void load() {
    AsyncDataProvider<SearchResultRow> dataProvider = new AsyncDataProvider<SearchResultRow>() {
        @Override/* ww w  . j  a v  a2  s.c o m*/
        protected void onRangeChanged(HasData<SearchResultRow> display) {
            SearchRange sr = new SearchRange(-1);
            Range range = display.getVisibleRange();
            if (range != null) {
                sr.setStart(range.getStart());
                sr.setLength(range.getLength());
            }
            ColumnSortList sortList = cellTable.getColumnSortList();
            if (sortList != null && sortList.size() > 0) {
                ColumnSortInfo sort = sortList.get(0);
                if (sort != null) {
                    sr.setSortField(tableColIdx
                            .get(cellTable.getColumnIndex((Column<SearchResultRow, ?>) sort.getColumn())));
                    sr.setAscending(sort.isAscending());
                }
            }
            changeHandler.handleRangeChange(sr);
        }
    };
    dataProvider.addDataDisplay(cellTable);

    AsyncHandler sortHandler = new AsyncHandler(cellTable);
    cellTable.addColumnSortHandler(sortHandler);
}

From source file:com.gafactory.core.client.ui.grids.BaseListGrid.java

License:Open Source License

@Override
public void onColumnSort(ColumnSortEvent event) {
    loader.clearSortInfo();/*  w w w.j a v  a2  s .  c om*/
    ColumnSortList sorting = event.getColumnSortList();
    for (int i = 0; i < sorting.size(); i++) {
        ColumnSortList.ColumnSortInfo columnSortInfo = sorting.get(i);
        String field = columnSortInfo.getColumn().getDataStoreName();

        Preconditions.checkNotNull(field);

        SortInfoBean sortInfoBean = new SortInfoBean(field,
                columnSortInfo.isAscending() ? SortDir.ASC : SortDir.DESC);
        loader.addSortInfo(sortInfoBean);

    }

    if (secondSortingField != null) {
        loader.addSortInfo(new SortInfoBean(secondSortingField, SortDir.ASC));
    }

    loader.load();
}

From source file:com.gafactory.core.shared.loader.FilterPagingLoader.java

License:Open Source License

private List<SortInfoBean> toSortingBeanList(ColumnSortList sorting) {

    List<SortInfoBean> list = Lists.newArrayList();
    for (int i = 0; i < sorting.size(); i++) {
        ColumnSortList.ColumnSortInfo columnSortInfo = sorting.get(i);
        String field = columnSortInfo.getColumn().getDataStoreName();

        Preconditions.checkNotNull(field);

        SortInfoBean sortInfoBean = new SortInfoBean(field,
                columnSortInfo.isAscending() ? SortDir.ASC : SortDir.DESC);
        list.add(sortInfoBean);//from   w w w.  j  a  v  a 2s.co m
    }

    return list;
}

From source file:com.google.gwt.sample.dynatable.client.ui.CellTableMain.java

private void updateSort() {
    ColumnSortList csl = calendarCellTable.getColumnSortList();
    for (int i = 0; i < csl.size(); i++) {
        ColumnSortInfo info = csl.get(i);
        String fieldName = info.getColumn().getDataStoreName();
        if (fieldName != null && fieldName.length() > 0) {
            if (info.isAscending()) {
                sort = new OfySortParameter(info.getColumn().getDataStoreName());
            } else {
                sort = new OfySortParameter(info.getColumn().getDataStoreName(), OfySortType.descending);
            }/*from   www. j av a2s. c  o m*/
        }
    }
}

From source file:fr.mncc.gwttoolbox.datagrid.client.Grid.java

License:Open Source License

/**
 * Return the column to be sorted.// www  .  ja  va  2s. c  o m
 * 
 * @return column to be sorted
 */
protected ColumnSortList.ColumnSortInfo getSortOrder() {
    ColumnSortList sortList = getColumnSortList();
    return sortList == null ? null : sortList.get(0);
}

From source file:org.apache.luke.client.LukeInspector.java

License:Apache License

public void onModuleLoad() {
    final RootPanel rootPanel = RootPanel.get();

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("New panel");
    cptnpnlNewPanel.setCaptionHTML("Luke version 5.0");
    rootPanel.add(cptnpnlNewPanel, 10, 10);
    cptnpnlNewPanel.setSize("959px", "652px");

    TabPanel tabPanel = new TabPanel();
    cptnpnlNewPanel.setContentWidget(tabPanel);
    tabPanel.setSize("5cm", "636px");

    //LuceneIndexLoader.loadIndex(pName, this);

    SplitLayoutPanel splitLayoutPanel = new SplitLayoutPanel();
    tabPanel.add(splitLayoutPanel, "Index overview", false);
    tabPanel.setVisible(true);/*from   ww  w .  j av  a 2  s  .c  o  m*/
    splitLayoutPanel.setSize("652px", "590px");

    SplitLayoutPanel splitLayoutPanel_1 = new SplitLayoutPanel();
    splitLayoutPanel.addNorth(splitLayoutPanel_1, 288.0);

    Label lblIndexStatistics = new Label("Index statistics");
    lblIndexStatistics.setDirectionEstimator(true);
    lblIndexStatistics.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    splitLayoutPanel_1.addNorth(lblIndexStatistics, 26.0);

    VerticalPanel verticalPanel = new VerticalPanel();
    splitLayoutPanel_1.addWest(verticalPanel, 125.0);

    Label lblTest = new Label("Index name:");
    verticalPanel.add(lblTest);
    lblTest.setWidth("109px");

    Label lblTest_1 = new Label("# fields:");
    verticalPanel.add(lblTest_1);

    Label lblNumber = new Label("# documents:");
    verticalPanel.add(lblNumber);
    lblNumber.setWidth("101px");

    Label lblTerms = new Label("# terms:");
    verticalPanel.add(lblTerms);

    Label lblHasDeletions = new Label("Has deletions?");
    verticalPanel.add(lblHasDeletions);

    Label lblNewLabel = new Label("Optimised?");
    verticalPanel.add(lblNewLabel);

    Label lblIndexVersion = new Label("Index version:");
    verticalPanel.add(lblIndexVersion);

    SplitLayoutPanel splitLayoutPanel_2 = new SplitLayoutPanel();
    splitLayoutPanel.addWest(splitLayoutPanel_2, 240.0);

    // Create name column.
    TextColumn<Field> nameColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field field) {
            return field.getName();
        }
    };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create termCount column.
    TextColumn<Field> termCountColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getTermCount();
        }
    };

    // Create decoder column.
    TextColumn<Field> decoderColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getDecoder();
        }
    };

    final CellTable<Field> cellTable = new CellTable<Field>();

    cellTable.addColumn(nameColumn, "Name");
    cellTable.addColumn(termCountColumn, "Term count");
    cellTable.addColumn(decoderColumn, "Decoder");

    cellTable.setRowCount(FieldsDummyData.Fields.size(), true);
    // Set the range to display. In this case, our visible range is smaller than
    // the data set.
    cellTable.setVisibleRange(0, 3);

    // Create a data provider.
    AsyncDataProvider<Field> dataProvider = new AsyncDataProvider<Field>() {
        @Override
        protected void onRangeChanged(HasData<Field> display) {
            final Range range = display.getVisibleRange();

            // Get the ColumnSortInfo from the table.
            final ColumnSortList sortList = cellTable.getColumnSortList();

            // This timer is here to illustrate the asynchronous nature of this data
            // provider. In practice, you would use an asynchronous RPC call to
            // request data in the specified range.
            new Timer() {
                @Override
                public void run() {
                    int start = range.getStart();
                    int end = start + range.getLength();
                    // This sorting code is here so the example works. In practice, you
                    // would sort on the server.
                    Collections.sort(FieldsDummyData.Fields, new Comparator<Field>() {
                        public int compare(Field o1, Field o2) {
                            if (o1 == o2) {
                                return 0;
                            }

                            // Compare the name columns.
                            int diff = -1;
                            if (o1 != null) {
                                diff = (o2 != null) ? o1.getName().compareTo(o2.getName()) : 1;
                            }
                            return sortList.get(0).isAscending() ? diff : -diff;
                        }
                    });
                    List<Field> dataInRange = FieldsDummyData.Fields.subList(start, end);

                    // Push the data back into the list.
                    cellTable.setRowData(start, dataInRange);
                }
            }.schedule(2000);
        }
    };

    // Connect the list to the data provider.
    dataProvider.addDataDisplay(cellTable);

    // Add a ColumnSortEvent.AsyncHandler to connect sorting to the
    // AsyncDataPRrovider.
    AsyncHandler columnSortHandler = new AsyncHandler(cellTable);
    cellTable.addColumnSortHandler(columnSortHandler);

    // We know that the data is sorted alphabetically by default.
    cellTable.getColumnSortList().push(nameColumn);

    splitLayoutPanel_2.add(cellTable);

    SplitLayoutPanel splitLayoutPanel_3 = new SplitLayoutPanel();
    splitLayoutPanel.addEast(splitLayoutPanel_3, 215.0);

    StackPanel stackPanel = new StackPanel();
    rootPanel.add(stackPanel, 714, 184);
    stackPanel.setSize("259px", "239px");

    FlowPanel flowPanel = new FlowPanel();
    stackPanel.add(flowPanel, "Open index", false);
    flowPanel.setSize("100%", "100%");

    TextBox textBox = new TextBox();
    flowPanel.add(textBox);

    Button btnNewButton = new Button("...");
    btnNewButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            DirectoryLister directoryLister = new DirectoryLister();
            directoryLister.setPopupPosition(rootPanel.getAbsoluteLeft() + rootPanel.getOffsetWidth() / 2,
                    rootPanel.getAbsoluteTop() + rootPanel.getOffsetHeight() / 2);
            directoryLister.show();

        }
    });
    flowPanel.add(btnNewButton);

    // exception handling
    // credits: http://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/examples/showcase/client/ShowCaseEntryPoint.java?repo=showcase
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void onUncaughtException(Throwable e) {
            Window.alert("uncaught: " + e.getMessage());
            String s = buildStackTrace(e, "RuntimeExceotion:\n");
            Window.alert(s);
            e.printStackTrace();

        }
    });

}