Search in sources :

Example 1 with SelectionAwareTable

use of org.opennms.features.topology.api.browsers.SelectionAwareTable in project opennms by OpenNMS.

the class NodeMapsApplication method getTabSheet.

/**
     * Gets a {@link TabSheet} view for all widgets in this manager.
     * 
     * @return TabSheet
     */
private Component getTabSheet() {
    // Use an absolute layout for the bottom panel
    AbsoluteLayout bottomLayout = new AbsoluteLayout();
    bottomLayout.setSizeFull();
    final TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    for (final SelectionAwareTable view : new SelectionAwareTable[] { m_alarmTable, m_nodeTable }) {
        // Icon can be null
        tabSheet.addTab(view, (view == m_alarmTable ? "Alarms" : "Nodes"), null);
        // components to the tab bar
        try {
            final Component[] extras = ((HasExtraComponents) view).getExtraComponents();
            if (extras != null && extras.length > 0) {
                // For any extra controls, add a horizontal layout that will float
                // on top of the right side of the tab panel
                final HorizontalLayout extraControls = new HorizontalLayout();
                extraControls.setHeight(32, Unit.PIXELS);
                extraControls.setSpacing(true);
                // Add the extra controls to the layout
                for (final Component component : extras) {
                    extraControls.addComponent(component);
                    extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT);
                }
                // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls
                tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        final TabSheet source = (TabSheet) event.getSource();
                        if (source == tabSheet) {
                            // If the first tab was selected...
                            if (source.getSelectedTab() == view) {
                                extraControls.setVisible(true);
                            } else {
                                extraControls.setVisible(false);
                            }
                        }
                    }
                });
                // Place the extra controls on the absolute layout
                bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100");
            }
        } catch (ClassCastException e) {
        }
        view.setSizeFull();
    }
    // Add the tabsheet to the layout
    bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;");
    return bottomLayout;
}
Also used : HasExtraComponents(org.opennms.features.topology.api.HasExtraComponents) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) SelectionAwareTable(org.opennms.features.topology.api.browsers.SelectionAwareTable) TabSheet(com.vaadin.ui.TabSheet) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) Component(com.vaadin.ui.Component) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with SelectionAwareTable

use of org.opennms.features.topology.api.browsers.SelectionAwareTable in project opennms by OpenNMS.

the class TopologyUI method updateTabVisibility.

private void updateTabVisibility() {
    for (int i = 0; i < tabSheet.getComponentCount(); i++) {
        TabSheet.Tab tab = tabSheet.getTab(i);
        if (tab.getComponent() instanceof SelectionAwareTable) {
            ContentType contentType = ((SelectionAwareTable) tab.getComponent()).getContentType();
            boolean visible = m_graphContainer.getTopologyServiceClient().contributesTo(contentType);
            tab.setVisible(visible);
        }
    }
}
Also used : ContentType(org.opennms.features.topology.api.browsers.ContentType) SelectionAwareTable(org.opennms.features.topology.api.browsers.SelectionAwareTable) TabSheet(com.vaadin.ui.TabSheet)

Aggregations

TabSheet (com.vaadin.ui.TabSheet)2 SelectionAwareTable (org.opennms.features.topology.api.browsers.SelectionAwareTable)2 AbsoluteLayout (com.vaadin.ui.AbsoluteLayout)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 SelectedTabChangeEvent (com.vaadin.ui.TabSheet.SelectedTabChangeEvent)1 SelectedTabChangeListener (com.vaadin.ui.TabSheet.SelectedTabChangeListener)1 HasExtraComponents (org.opennms.features.topology.api.HasExtraComponents)1 ContentType (org.opennms.features.topology.api.browsers.ContentType)1