Search in sources :

Example 1 with PageableController

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

the class ColumnSetAnalysisResultPage method createTableSectionPartForMapDB.

private Section createTableSectionPartForMapDB(Composite parentComp, String title, SimpleStatIndicator ssIndicator) {
    Section columnSetElementSection = this.createSection(form, parentComp, title, null);
    Composite sectionTableComp = toolkit.createComposite(columnSetElementSection);
    // MOD yyi 2010-12-07 17282:create parameter section for storing data control
    if (ssIndicator.isStoreData()) {
        columnSetElementSection.setExpanded(true);
        columnSetElementSection.setEnabled(true);
        sectionTableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        sectionTableComp.setLayout(new GridLayout());
        try {
            mapDB = MapDBUtils.getMapDB(StandardDBName.dataSection.name(), ssIndicator);
        } catch (IOError error) {
            log.warn(error.getMessage(), error);
        }
        Button filterDataBt = new Button(sectionTableComp, SWT.NONE);
        // $NON-NLS-1$
        filterDataBt.setText(DefaultMessagesImpl.getString("ColumnSetResultPage.filterData"));
        filterDataBt.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
        filterDataBt.setEnabled(containAllMatchIndicator() && mapDB != null);
        filterDataBt.addMouseListener(new MouseListener() {

            public void mouseDoubleClick(MouseEvent e) {
            // do nothing until now
            }

            public void mouseDown(MouseEvent e) {
                List<Indicator> indicatorsList = masterPage.getCurrentModelElement().getResults().getIndicators();
                SelectPatternsWizard wizard = new SelectPatternsWizard(indicatorsList);
                wizard.setFilterType(filterType);
                wizard.setOldTableInputList(ColumnSetAnalysisResultPage.this.tableFilterResult.getTableFilterResult());
                WizardDialog dialog = new WizardDialog(null, wizard);
                dialog.setPageSize(300, 400);
                wizard.setContainer(dialog);
                // $NON-NLS-1$
                wizard.setWindowTitle(DefaultMessagesImpl.getString("SelectPatternsWizard.title"));
                if (WizardDialog.OK == dialog.open()) {
                    ColumnSetAnalysisResultPage.this.tableFilterResult = new TableFilterResult(wizard.getPatternSelectPage().getTableInputList());
                    filterType = wizard.getPatternSelectPage().getFilterType();
                    columnsElementViewer.refresh();
                    redrawController();
                }
            }

            public void mouseUp(MouseEvent e) {
            // do nothing until now
            }
        });
        columnsElementViewer = new TableViewer(sectionTableComp, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
        Table table = columnsElementViewer.getTable();
        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        table.setLinesVisible(true);
        table.setHeaderVisible(true);
        TableSectionViewerProvider provider = new TableSectionViewerProvider();
        columnsElementViewer.setContentProvider(provider);
        columnSetElementSection.setClient(sectionTableComp);
        columnSetElementSection.setExpanded(false);
        int pageSize = 100;
        // // ADDED sgandon 15/03/2010 bug 11769 : setup the size of the table to avoid crash and add consistency.
        setupTableGridDataLimitedSize(table, pageSize);
        // add pagation control
        controller = new PageableController(MapDBPageConstant.NUMBER_PER_PAGE);
        if (mapDB != null) {
            redrawPagationComposite(sectionTableComp, null, true);
        }
        createColumns(controller, ssIndicator);
        // Set current page to 0 to refresh the table
        controller.reset();
        for (TableColumn column : table.getColumns()) {
            column.pack();
        }
    } else {
        columnSetElementSection.setExpanded(false);
        columnSetElementSection.setEnabled(false);
    }
    return columnSetElementSection;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Table(org.eclipse.swt.widgets.Table) AbstractPageControllerComposite(org.eclipse.nebula.widgets.pagination.AbstractPageControllerComposite) Composite(org.eclipse.swt.widgets.Composite) PageableController(org.eclipse.nebula.widgets.pagination.PageableController) SelectPatternsWizard(org.talend.dataprofiler.core.ui.wizard.patterns.SelectPatternsWizard) Section(org.eclipse.ui.forms.widgets.Section) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) IOError(java.io.IOError) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ArrayList(java.util.ArrayList) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with PageableController

use of org.eclipse.nebula.widgets.pagination.PageableController 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

PageableController (org.eclipse.nebula.widgets.pagination.PageableController)2 GridData (org.eclipse.swt.layout.GridData)2 IOError (java.io.IOError)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 AbstractPageControllerComposite (org.eclipse.nebula.widgets.pagination.AbstractPageControllerComposite)1 PageChangedAdapter (org.eclipse.nebula.widgets.pagination.PageChangedAdapter)1 PageResult (org.eclipse.nebula.widgets.pagination.collections.PageResult)1 ResultAndNavigationPageGraphicsRenderer (org.eclipse.nebula.widgets.pagination.renderers.navigation.ResultAndNavigationPageGraphicsRenderer)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseListener (org.eclipse.swt.events.MouseListener)1 Point (org.eclipse.swt.graphics.Point)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 Section (org.eclipse.ui.forms.widgets.Section)1