Search in sources :

Example 1 with UiState

use of org.opennms.features.vaadin.jmxconfiggenerator.ui.UiState in project opennms by OpenNMS.

the class JmxConfigGeneratorUI method initNavigator.

private void initNavigator() {
    navigator = new Navigator(this, contentPanel);
    // common views
    navigator.addView(UiState.ServiceConfigurationView.name(), new ConfigView(this));
    navigator.addView(UiState.MbeansView.name(), new MBeansView(this));
    navigator.addView(UiState.ResultView.name(), new ResultView());
    // "working views" need to be simulated, they do not actually exist, but we need them for navigation
    navigator.addView(UiState.MbeansDetection.name(), new Navigator.EmptyView());
    navigator.addView(UiState.ResultConfigGeneration.name(), new Navigator.EmptyView());
    // We need to hook into the "view change" process to prevent changing to the "working views"
    // Instead we trigger a long running task and show a "please wait" window.
    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            hideProgressWindow();
            headerPanel.enter(event);
            final UiState uiState = UiState.valueOf(event.getViewName());
            if (UiState.ServiceConfigurationView == uiState) {
                UiModel newModel = new UiModel();
                if (model != null) {
                    newModel.setServiceConfig(model.getServiceConfig());
                }
                model = newModel;
            }
            if (UiState.MbeansDetection == uiState) {
                showProgressWindow(uiState.getDescription());
                enqueue(new DetectMBeansJob(getUiModel().getServiceConfig()));
                return false;
            }
            if (UiState.ResultConfigGeneration == uiState) {
                showProgressWindow(uiState.getDescription());
                enqueue(new GenerateConfigsJob(getUiModel()));
                return false;
            }
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
        }
    });
}
Also used : ConfigView(org.opennms.features.vaadin.jmxconfiggenerator.ui.ConfigView) Navigator(com.vaadin.navigator.Navigator) MBeansView(org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.MBeansView) UiModel(org.opennms.features.vaadin.jmxconfiggenerator.data.UiModel) UiState(org.opennms.features.vaadin.jmxconfiggenerator.ui.UiState) GenerateConfigsJob(org.opennms.features.vaadin.jmxconfiggenerator.jobs.GenerateConfigsJob) DetectMBeansJob(org.opennms.features.vaadin.jmxconfiggenerator.jobs.DetectMBeansJob) ResultView(org.opennms.features.vaadin.jmxconfiggenerator.ui.ResultView) ViewChangeListener(com.vaadin.navigator.ViewChangeListener)

Aggregations

Navigator (com.vaadin.navigator.Navigator)1 ViewChangeListener (com.vaadin.navigator.ViewChangeListener)1 UiModel (org.opennms.features.vaadin.jmxconfiggenerator.data.UiModel)1 DetectMBeansJob (org.opennms.features.vaadin.jmxconfiggenerator.jobs.DetectMBeansJob)1 GenerateConfigsJob (org.opennms.features.vaadin.jmxconfiggenerator.jobs.GenerateConfigsJob)1 ConfigView (org.opennms.features.vaadin.jmxconfiggenerator.ui.ConfigView)1 ResultView (org.opennms.features.vaadin.jmxconfiggenerator.ui.ResultView)1 UiState (org.opennms.features.vaadin.jmxconfiggenerator.ui.UiState)1 MBeansView (org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.MBeansView)1