Search in sources :

Example 1 with PageResult

use of org.eclipse.nebula.widgets.pagination.collections.PageResult in project tdq-studio-se by Talend.

the class ColumnSetAnalysisResultPage method redrawPagationComposite.

/**
 * DOC zshen Comment method "redrawPagationComposite".
 *
 * @param parent
 */
private void redrawPagationComposite(Composite parent, List<Map<Integer, RegexpMatchingIndicator>> patternList, boolean withPageNumberButton) {
    final IPageLoader<PageResult<Object[]>> pageLoader = new MapDBPageLoader<Object>(mapDB, new PatternsDataValidation(patternList, filterType), mapDB.size());
    controller.removePageChangedListener(createLoadPageAndReplaceItemsListener);
    controller.removePageChangedListener(resultAndPageButtonsDecorator);
    controller.setCurrentPage(-1);
    createLoadPageAndReplaceItemsListener = PageLoaderStrategyHelper.createLoadPageAndReplaceItemsListener(controller, columnsElementViewer, pageLoader, PageResultContentProvider.getInstance(), null);
    controller.addPageChangedListener(createLoadPageAndReplaceItemsListener);
    if (buttonComposite != null) {
        buttonComposite.dispose();
    }
    buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    buttonComposite.setLayout(new GridLayout());
    if (withPageNumberButton) {
        resultAndPageButtonsDecorator = new ResultAndNavigationPageGraphicsRenderer(buttonComposite, SWT.NONE, controller);
    } else {
        resultAndPageButtonsDecorator = new ColumnSetNavigationPageGraphicsRenderer(buttonComposite, SWT.NONE, controller);
    }
    GridData gridData = new GridData(GridData.FILL_BOTH);
    resultAndPageButtonsDecorator.setLayoutData(gridData);
    controller.reset();
    parent.layout();
}
Also used : ColumnSetNavigationPageGraphicsRenderer(org.talend.dataprofiler.core.ui.editor.analysis.renderer.ColumnSetNavigationPageGraphicsRenderer) GridLayout(org.eclipse.swt.layout.GridLayout) ResultAndNavigationPageGraphicsRenderer(org.eclipse.nebula.widgets.pagination.renderers.navigation.ResultAndNavigationPageGraphicsRenderer) AbstractPageControllerComposite(org.eclipse.nebula.widgets.pagination.AbstractPageControllerComposite) Composite(org.eclipse.swt.widgets.Composite) MapDBPageLoader(org.talend.dataprofiler.common.ui.pagination.pageloder.MapDBPageLoader) GridData(org.eclipse.swt.layout.GridData) PageResult(org.eclipse.nebula.widgets.pagination.collections.PageResult) PatternsDataValidation(org.talend.dataprofiler.core.ui.editor.pattern.PatternsDataValidation)

Example 2 with PageResult

use of org.eclipse.nebula.widgets.pagination.collections.PageResult in project tdq-studio-se by Talend.

the class DrillDownResultEditor method initTableViewerForMapDB.

/**
 * DOC talend Comment method "initTableViewerForMapDB".
 *
 * @param parent
 * @param table
 * @param ddEditorInput
 */
@SuppressWarnings("unchecked")
private void initTableViewerForMapDB(final Composite parent, final Table table, DrillDownEditorInput ddEditorInput) {
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    tableView.setLabelProvider(new DrillDownResultLabelProvider());
    tableView.setContentProvider(new DrillDownResultContentProvider());
    // set page size
    final PageableController controller = new PageableController(MapDBPageConstant.NUMBER_PER_PAGE);
    Object dataSetForMapDB = ddEditorInput.getDataSetForMapDB(controller.getPageSize());
    if (dataSetForMapDB == null) {
        log.error(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownError"), new RuntimeException(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownErrorMessage")));
    } else {
        table.setData(dataSetForMapDB);
    }
    // for columnSet analysis here only have one db file need to support drill down and data section
    Analysis analysis = ddEditorInput.getAnalysis();
    AnalysisType analysisType = analysis.getParameters().getAnalysisType();
    IPageLoader<PageResult<Object[]>> pageLoader = null;
    AbstractDB<Object> mapDB = ddEditorInput.getMapDB();
    Indicator generateMapDBIndicator = ddEditorInput.getGenerateMapDBIndicator();
    MapDBManager.getInstance().addDBRef(MapDBUtils.getMapDBFile(generateMapDBIndicator));
    Long itemsSize = ddEditorInput.getItemSize(mapDB);
    if (AnalysisType.COLUMN_SET == analysisType) {
        pageLoader = new MapDBPageLoader<Object>(mapDB, IDataValidationFactory.INSTANCE.createValidation(ddEditorInput.getCurrIndicator()), itemsSize);
    } else {
        // ~
        ColumnFilter filter = ddEditorInput.getColumnFilter();
        pageLoader = new MapDBPageLoader<Object>(mapDB, null, itemsSize, filter);
    }
    controller.addPageChangedListener(PageLoaderStrategyHelper.createLoadPageAndReplaceItemsListener(controller, tableView, pageLoader, PageResultContentProvider.getInstance(), null));
    controller.addPageChangedListener(new PageChangedAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.nebula.widgets.pagination.PageChangedAdapter#pageIndexChanged(int, int,
             * org.eclipse.nebula.widgets.pagination.PageableController)
             */
        @Override
        public void pageIndexChanged(int oldPageIndex, int newPageIndex, PageableController controller) {
            Object data = table.getData();
            if (data != null && SqlExplorerUtils.getDefault().isInstanceofTalendDataSet(data)) {
                long totalSize = controller.getTotalElements();
                long pageSize = controller.getPageSize();
                long pageIndex = controller.getPageOffset();
                long fromIndex = pageIndex;
                long toIndex = pageIndex + pageSize;
                if (toIndex > totalSize) {
                    toIndex = totalSize;
                }
                SqlExplorerUtils.getDefault().resetTalendDataSetIndex(data, fromIndex, toIndex);
                parent.layout();
            }
        }
    });
    // Create navigation page links
    ResultAndNavigationPageGraphicsRenderer resultAndNavigationPageGraphicsRenderer = new ResultAndNavigationPageGraphicsRenderer(parent, SWT.NONE, controller);
    resultAndNavigationPageGraphicsRenderer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    createColumns(tableView, controller, ((DrillDownEditorInput) this.getEditorInput()));
    // Set current page to 0 to refresh the table
    controller.setCurrentPage(0);
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) ResultAndNavigationPageGraphicsRenderer(org.eclipse.nebula.widgets.pagination.renderers.navigation.ResultAndNavigationPageGraphicsRenderer) PageableController(org.eclipse.nebula.widgets.pagination.PageableController) ColumnFilter(org.talend.cwm.indicator.ColumnFilter) PageResult(org.eclipse.nebula.widgets.pagination.collections.PageResult) Indicator(org.talend.dataquality.indicators.Indicator) Point(org.eclipse.swt.graphics.Point) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) PageChangedAdapter(org.eclipse.nebula.widgets.pagination.PageChangedAdapter)

Aggregations

PageResult (org.eclipse.nebula.widgets.pagination.collections.PageResult)2 ResultAndNavigationPageGraphicsRenderer (org.eclipse.nebula.widgets.pagination.renderers.navigation.ResultAndNavigationPageGraphicsRenderer)2 GridData (org.eclipse.swt.layout.GridData)2 AbstractPageControllerComposite (org.eclipse.nebula.widgets.pagination.AbstractPageControllerComposite)1 PageChangedAdapter (org.eclipse.nebula.widgets.pagination.PageChangedAdapter)1 PageableController (org.eclipse.nebula.widgets.pagination.PageableController)1 Point (org.eclipse.swt.graphics.Point)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ColumnFilter (org.talend.cwm.indicator.ColumnFilter)1 MapDBPageLoader (org.talend.dataprofiler.common.ui.pagination.pageloder.MapDBPageLoader)1 ColumnSetNavigationPageGraphicsRenderer (org.talend.dataprofiler.core.ui.editor.analysis.renderer.ColumnSetNavigationPageGraphicsRenderer)1 PatternsDataValidation (org.talend.dataprofiler.core.ui.editor.pattern.PatternsDataValidation)1 Analysis (org.talend.dataquality.analysis.Analysis)1 AnalysisType (org.talend.dataquality.analysis.AnalysisType)1 Indicator (org.talend.dataquality.indicators.Indicator)1