Search in sources :

Example 1 with AbsoluteLayout

use of com.vaadin.ui.AbsoluteLayout 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 AbsoluteLayout

use of com.vaadin.ui.AbsoluteLayout in project opennms by OpenNMS.

the class TopologyUI method getTabSheet.

/**
     * Gets a {@link TabSheet} view for all widgets in this manager.
     *
     * @return TabSheet
     */
private Component getTabSheet(WidgetManager manager, WidgetContext widgetContext) {
    // Use an absolute layout for the bottom panel
    AbsoluteLayout bottomLayout = new AbsoluteLayout();
    bottomLayout.setSizeFull();
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    for (IViewContribution viewContrib : manager.getWidgets()) {
        // Create a new view instance
        final Component view = viewContrib.getView(m_applicationContext, widgetContext);
        try {
            m_graphContainer.getSelectionManager().addSelectionListener((SelectionListener) view);
        } catch (ClassCastException e) {
        }
        try {
            ((SelectionNotifier) view).addSelectionListener(m_graphContainer.getSelectionManager());
        } catch (ClassCastException e) {
        }
        try {
            m_graphContainer.addChangeListener((GraphContainer.ChangeListener) view);
        } catch (ClassCastException e) {
        }
        // Icon can be null
        tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon());
        // components to the tab bar
        try {
            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 (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() {

                    private static final long serialVersionUID = 6370347645872323830L;

                    @Override
                    public void selectedTabChange(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) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) GraphContainer(org.opennms.features.topology.api.GraphContainer) SelectionNotifier(org.opennms.features.topology.api.SelectionNotifier) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) TabSheet(com.vaadin.ui.TabSheet) IViewContribution(org.opennms.features.topology.api.IViewContribution) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) Component(com.vaadin.ui.Component)

Example 3 with AbsoluteLayout

use of com.vaadin.ui.AbsoluteLayout in project opennms by OpenNMS.

the class TopologyUI method createMapLayout.

private Component createMapLayout() {
    // Topology (Map) Component
    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);
    // Search Box
    m_searchBox = new SearchBox(m_serviceManager, new DefaultOperationContext(this, m_graphContainer, OperationContext.DisplayLocation.SEARCH));
    // Info Panel
    m_infoPanel = new InfoPanel(m_searchBox);
    // Breadcrumb
    m_breadcrumbComponent = new BreadcrumbComponent();
    // Layout hint
    m_layoutHintComponent = new LayoutHintComponent(m_layoutManager, m_graphContainer);
    // Toolbar
    m_toolbarPanel = new ToolbarPanel(new ToolbarPanelController() {

        @Override
        public void refreshUI() {
            new TopologyUI.DynamicUpdateRefresher().refreshUI();
        }

        @Override
        public void saveHistory() {
            TopologyUI.this.saveHistory();
        }

        @Override
        public void saveLayout() {
            m_graphContainer.saveLayout();
        }

        @Override
        public void setActiveTool(ActiveTool activeTool) {
            Objects.requireNonNull(activeTool);
            m_topologyComponent.setActiveTool(activeTool.name());
        }

        @Override
        public void showAllMap() {
            m_topologyComponent.showAllMap();
        }

        @Override
        public void centerMapOnSelection() {
            m_topologyComponent.centerMapOnSelection();
        }

        @Override
        public void toggleHighlightFocus() {
            m_topologyComponent.getState().setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus());
            m_topologyComponent.updateGraph();
        }

        @Override
        public void setSemanticZoomLevel(int semanticZoomLevel) {
            m_graphContainer.setSemanticZoomLevel(semanticZoomLevel);
            m_graphContainer.redoLayout();
        }

        public int getSemanticZoomLevel() {
            return m_graphContainer.getSemanticZoomLevel();
        }

        @Override
        public Property<Double> getScaleProperty() {
            return m_graphContainer.getScaleProperty();
        }

        @Override
        public LayoutManager getLayoutManager() {
            return m_layoutManager;
        }
    });
    // Map Layout (we need to wrap it in an absolute layout otherwise it shows up twice on the topology map)
    AbsoluteLayout mapLayout = new AbsoluteLayout();
    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(m_breadcrumbComponent, "top:10px; left: 50px");
    mapLayout.addComponent(m_layoutHintComponent, "bottom: 10px; left:20px");
    mapLayout.setSizeFull();
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName("map-layout");
    layout.addComponent(m_infoPanel);
    layout.addComponent(mapLayout);
    layout.addComponent(m_toolbarPanel);
    layout.setExpandRatio(mapLayout, 1);
    layout.setSizeFull();
    return layout;
}
Also used : LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) InfoPanel(org.opennms.features.topology.app.internal.ui.InfoPanel) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ToolbarPanelController(org.opennms.features.topology.app.internal.ui.ToolbarPanelController) ToolbarPanel(org.opennms.features.topology.app.internal.ui.ToolbarPanel)

Aggregations

AbsoluteLayout (com.vaadin.ui.AbsoluteLayout)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 Component (com.vaadin.ui.Component)2 TabSheet (com.vaadin.ui.TabSheet)2 SelectedTabChangeEvent (com.vaadin.ui.TabSheet.SelectedTabChangeEvent)2 SelectedTabChangeListener (com.vaadin.ui.TabSheet.SelectedTabChangeListener)2 HasExtraComponents (org.opennms.features.topology.api.HasExtraComponents)2 LayoutHintComponent (org.opennms.features.topology.app.internal.ui.LayoutHintComponent)2 BreadcrumbComponent (org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent)2 GraphContainer (org.opennms.features.topology.api.GraphContainer)1 IViewContribution (org.opennms.features.topology.api.IViewContribution)1 SelectionNotifier (org.opennms.features.topology.api.SelectionNotifier)1 SelectionAwareTable (org.opennms.features.topology.api.browsers.SelectionAwareTable)1 InfoPanel (org.opennms.features.topology.app.internal.ui.InfoPanel)1 SearchBox (org.opennms.features.topology.app.internal.ui.SearchBox)1 ToolbarPanel (org.opennms.features.topology.app.internal.ui.ToolbarPanel)1 ToolbarPanelController (org.opennms.features.topology.app.internal.ui.ToolbarPanelController)1