Search in sources :

Example 6 with EventReceiver

use of org.talend.dataprofiler.core.ui.events.EventReceiver in project tdq-studio-se by Talend.

the class ColumnAnalysisResultPage method registerOtherDynamicEvent.

/**
 * refresh the composite of the chart, to show the changes on the chart.
 */
private void registerOtherDynamicEvent() {
    registerDynamicRefreshEvent = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            reLayoutChartComposite();
            return true;
        }
    };
    EventManager.getInstance().register(chartComposite, EventEnum.DQ_DYNAMIC_REFRESH_DYNAMIC_CHART, registerDynamicRefreshEvent);
    // register a event to handle switch between master and result page
    switchBetweenPageEvent = new EventReceiver() {

        int times = 0;

        @Override
        public boolean handle(Object data) {
            if (times == 0) {
                times++;
                masterPage.refreshGraphicsInSettingsPage();
            }
            return true;
        }
    };
    EventManager.getInstance().register(masterPage.getCurrentModelElement(), EventEnum.DQ_DYNAMIC_SWITCH_MASTER_RESULT_PAGE, switchBetweenPageEvent);
}
Also used : DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) DynamicBAWChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver)

Example 7 with EventReceiver

use of org.talend.dataprofiler.core.ui.events.EventReceiver in project tdq-studio-se by Talend.

the class DynamicAnalysisMasterPage method registerOtherDynamicEvent.

/**
 * refresh the composite of the chart, to show the changes on the chart.
 */
private void registerOtherDynamicEvent() {
    registerDynamicRefreshEvent = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            reLayoutChartComposite();
            return true;
        }
    };
    EventManager.getInstance().register(chartComposite, EventEnum.DQ_DYNAMIC_REFRESH_DYNAMIC_CHART, registerDynamicRefreshEvent);
    // register a event to handle switch between master and result page
    switchBetweenPageEvent = new EventReceiver() {

        int times = 0;

        @Override
        public boolean handle(Object data) {
            // only need to refresh for the first time switch, and must be during a running.
            if (times == 0) {
                times++;
                ((AnalysisEditor) currentEditor).getResultPage().refresh(((AnalysisEditor) currentEditor).getMasterPage());
            }
            return true;
        }
    };
    EventManager.getInstance().register(getCurrentModelElement(), EventEnum.DQ_DYNAMIC_SWITCH_MASTER_RESULT_PAGE, switchBetweenPageEvent);
}
Also used : DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) DynamicBAWChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver)

Example 8 with EventReceiver

use of org.talend.dataprofiler.core.ui.events.EventReceiver in project tdq-studio-se by Talend.

the class AbstractAnalysisMetadataPage method registerEvents.

/**
 * DOC msjian Comment method "registerEvents".
 */
protected void registerEvents() {
    // register: refresh the result page after running it from menu
    afterCreateConnectionReceiver = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            // check if the connection is unavailable, give a warning dialog to user without opening the columns
            // select dialog
            Connection conn = (Connection) data;
            if (ConnectionUtils.checkConnection(conn, getAnalysisHandler().getAnalysis().getName())) {
                // need to give the new connection to the dialog to show only this new one in the dialog.
                openColumnsSelectionDialog(conn);
            }
            return true;
        }
    };
    EventManager.getInstance().register(dataPreviewSection, EventEnum.DQ_SELECT_ELEMENT_AFTER_CREATE_CONNECTION, afterCreateConnectionReceiver);
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver)

Example 9 with EventReceiver

use of org.talend.dataprofiler.core.ui.events.EventReceiver in project tdq-studio-se by Talend.

the class AnalysisEditor method registerUpdateExecutionEvent.

/**
 * currently will not open the editor of the analysis when running from menu, so, if the editor is opened and not
 * the current active one, the page will not know that the result is changed. so we need to add the event/listener
 * to them to handle this. Added 20130725 TDQ-7639
 *
 * @param analysis
 */
private void registerUpdateExecutionEvent() {
    // register: check if the analysis need to be saved or if it can run before running it(from menu's RUN)
    checkBeforeRunReceiver = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            if (isDirty()) {
                ReturnCode canSave = masterPage.canSave();
                if (canSave.isOk()) {
                    // save the analysis before running
                    // MOD msjian TDQ-8225 : This save action won't invoke any remote repository action such as svn
                    // commit. TDQ-7508
                    IRepositoryFactory localRepository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
                    IRepositoryFactory oldRepository = ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider();
                    ProxyRepositoryFactory.getInstance().setRepositoryFactoryFromProvider(localRepository);
                    try {
                        doSave(null);
                    } catch (Exception e) {
                        log.error(e, e);
                    } finally {
                        ProxyRepositoryFactory.getInstance().setRepositoryFactoryFromProvider(oldRepository);
                    }
                    // TDQ-8225~
                    setDirty(false);
                } else {
                    if (canSave.getMessage() != null && !canSave.getMessage().equals(StringUtils.EMPTY)) {
                        MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
                        canSave.getMessage());
                    }
                    return false;
                }
            }
            ReturnCode canRun = canRun();
            if (!canRun.isOk()) {
                MessageDialogWithToggle.openError(null, DefaultMessagesImpl.getString("RunAnalysisAction.runAnalysis"), // $NON-NLS-1$
                canRun.getMessage());
                return false;
            }
            // TDQ-8220 change the listener every time( master page or result page)
            changeListener();
            return true;
        }
    };
    EventManager.getInstance().register(getMasterPage().getCurrentModelElement(), EventEnum.DQ_ANALYSIS_CHECK_BEFORERUN, checkBeforeRunReceiver);
    // register: refresh the result page after running it from menu
    refreshReceiver = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            // enough;TDQ-8270 resultpage is null for overview type
            if (resultPage != null && resultPage.getManagedForm() != null) {
                resultPage.refresh(getMasterPage());
            } else {
                getMasterPage().refreshGraphicsInSettingsPage();
            }
            return true;
        }
    };
    EventManager.getInstance().register(getMasterPage().getCurrentModelElement(), EventEnum.DQ_ANALYSIS_RUN_FROM_MENU, refreshReceiver);
    // register: reopen this editor after reload its depended connection
    reopenEditor = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            // TDQ-13275 remove 'Display.getDefault().asyncExec' to avoid error with Multi-thread open editors.
            WorkbenchUtils.refreshCurrentAnalysisEditor(getMasterPage().getCurrentModelElement().getName());
            return true;
        }
    };
    EventManager.getInstance().register(getMasterPage().getCurrentModelElement().getName(), EventEnum.DQ_ANALYSIS_REOPEN_EDITOR, reopenEditor);
    // all match indicator in the Indicators section.
    if (analysisType.equals(AnalysisType.COLUMN_SET)) {
        // register: refresh the dataprovider combobox when the name of the data provider is changed.
        refresh2ShowMatchIndicator = new EventReceiver() {

            @Override
            public boolean handle(Object data) {
                ((ColumnSetAnalysisDetailsPage) getMasterPage()).refreshIndicatorsSection();
                return true;
            }
        };
        EventManager.getInstance().register(getMasterPage().getCurrentModelElement(), EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, refresh2ShowMatchIndicator);
    }
    // Added TDQ8787 2014-06-16 yyin: for dynamic chart, create all charts before execute the analysis
    if (masterPage instanceof DynamicAnalysisMasterPage) {
        registerDynamicEvent = new EventReceiver() {

            @Override
            public boolean handle(Object data) {
                if (masterPage.equals(activePageInstance)) {
                    ((DynamicAnalysisMasterPage) masterPage).registerDynamicEvent();
                } else {
                    // register result page
                    if (resultPage != null) {
                        if (resultPage instanceof ColumnAnalysisResultPage) {
                            ((ColumnAnalysisResultPage) resultPage).registerDynamicEvent();
                        } else if (resultPage instanceof BusinessRuleAnalysisResultPage) {
                            ((BusinessRuleAnalysisResultPage) resultPage).registerDynamicEvent();
                        }
                    }
                }
                return true;
            }
        };
        EventManager.getInstance().register(getMasterPage().getCurrentModelElement(), EventEnum.DQ_DYNAMIC_REGISTER_DYNAMIC_CHART, registerDynamicEvent);
        unRegisterDynamicEvent = new EventReceiver() {

            @Override
            public boolean handle(Object data) {
                if (masterPage.equals(activePageInstance)) {
                    ((DynamicAnalysisMasterPage) masterPage).unRegisterDynamicEvent();
                } else {
                    // register result page
                    if (resultPage != null) {
                        if (resultPage instanceof ColumnAnalysisResultPage) {
                            ((ColumnAnalysisResultPage) resultPage).unRegisterDynamicEvent();
                        } else if (resultPage instanceof BusinessRuleAnalysisResultPage) {
                            ((BusinessRuleAnalysisResultPage) resultPage).unRegisterDynamicEvent();
                        }
                    }
                }
                return true;
            }
        };
        EventManager.getInstance().register(getMasterPage().getCurrentModelElement(), EventEnum.DQ_DYNAMIC_UNREGISTER_DYNAMIC_CHART, unRegisterDynamicEvent);
    }
}
Also used : IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ReturnCode(org.talend.utils.sugars.ReturnCode) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

EventReceiver (org.talend.dataprofiler.core.ui.events.EventReceiver)9 DynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver)3 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ISubRepositoryObject (org.talend.core.model.repository.ISubRepositoryObject)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 DynamicBAWChartEventReceiver (org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 TableCombo (org.eclipse.nebula.widgets.tablecombo.TableCombo)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 Label (org.eclipse.swt.widgets.Label)1 PartInitException (org.eclipse.ui.PartInitException)1