Example usage for com.vaadin.ui AbsoluteLayout addComponent

List of usage examples for com.vaadin.ui AbsoluteLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui AbsoluteLayout addComponent.

Prototype

private void addComponent(Component c, ComponentPosition position) throws IllegalArgumentException 

Source Link

Document

Adds the component using the given position.

Usage

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

/**
 * Gets a {@link TabSheet} view for all widgets in this manager.
 * //from ww w  . j a  v  a  2  s . co  m
 * @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) {
        }

        // Icon can be null
        tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon());

        // If the component supports the HasExtraComponents interface, then add the extra 
        // 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) {
                            // Bizarrely enough, getSelectedTab() returns the contained
                            // Component, not the Tab itself.
                            //
                            // 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;
}

From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java

License:Open Source License

@SuppressWarnings("serial")
@Override/* w ww.  j  ava2  s . c  om*/
public void init() {
    setTheme("topo_default");

    m_rootLayout = new AbsoluteLayout();
    m_rootLayout.setSizeFull();

    m_window = new Window("OpenNMS Topology");
    m_window.setContent(m_rootLayout);
    setMainWindow(m_window);

    m_uriFragUtil = new UriFragmentUtility();
    m_window.addComponent(m_uriFragUtil);
    m_uriFragUtil.addListener(this);

    m_layout = new AbsoluteLayout();
    m_layout.setSizeFull();
    m_rootLayout.addComponent(m_layout);

    if (m_showHeader) {
        HEADER_HEIGHT = 100;
        Panel header = new Panel("header");
        header.setCaption(null);
        header.setSizeUndefined();
        header.addStyleName("onmsheader");
        m_rootLayout.addComponent(header, "top: 0px; left: 0px; right:0px;");

        try {
            CustomLayout customLayout = new CustomLayout(getHeaderLayout());
            header.setContent(customLayout);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        HEADER_HEIGHT = 0;
    }

    Refresher refresher = new Refresher();
    refresher.setRefreshInterval(5000);
    getMainWindow().addComponent(refresher);

    m_graphContainer.setLayoutAlgorithm(new FRLayoutAlgorithm());

    final Property scale = m_graphContainer.getScaleProperty();

    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, m_selectionManager,
            this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);

    final Slider slider = new Slider(0, 1);

    slider.setPropertyDataSource(scale);
    slider.setResolution(1);
    slider.setHeight("300px");
    slider.setOrientation(Slider.ORIENTATION_VERTICAL);

    slider.setImmediate(true);

    final Button zoomInBtn = new Button();
    zoomInBtn.setIcon(new ThemeResource("images/plus.png"));
    zoomInBtn.setDescription("Expand Semantic Zoom Level");
    zoomInBtn.setStyleName("semantic-zoom-button");
    zoomInBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) m_graphContainer.getSemanticZoomLevel();
            szl++;
            m_graphContainer.setSemanticZoomLevel(szl);
            setSemanticZoomLevel(szl);
            saveHistory();
        }
    });

    Button zoomOutBtn = new Button();
    zoomOutBtn.setIcon(new ThemeResource("images/minus.png"));
    zoomOutBtn.setDescription("Collapse Semantic Zoom Level");
    zoomOutBtn.setStyleName("semantic-zoom-button");
    zoomOutBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) m_graphContainer.getSemanticZoomLevel();
            if (szl > 0) {
                szl--;
                m_graphContainer.setSemanticZoomLevel(szl);
                setSemanticZoomLevel(szl);
                saveHistory();
            }

        }
    });

    final Button panBtn = new Button();
    panBtn.setIcon(new ThemeResource("images/cursor_drag_arrow.png"));
    panBtn.setDescription("Pan Tool");
    panBtn.setStyleName("toolbar-button down");

    final Button selectBtn = new Button();
    selectBtn.setIcon(new ThemeResource("images/selection.png"));
    selectBtn.setDescription("Selection Tool");
    selectBtn.setStyleName("toolbar-button");
    selectBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            selectBtn.setStyleName("toolbar-button down");
            panBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("select");
        }
    });

    panBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            panBtn.setStyleName("toolbar-button down");
            selectBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("pan");
        }
    });

    VerticalLayout toolbar = new VerticalLayout();
    toolbar.setWidth("31px");
    toolbar.addComponent(panBtn);
    toolbar.addComponent(selectBtn);

    HorizontalLayout semanticLayout = new HorizontalLayout();
    semanticLayout.addComponent(zoomInBtn);
    semanticLayout.addComponent(m_zoomLevelLabel);
    semanticLayout.addComponent(zoomOutBtn);
    semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER);

    AbsoluteLayout mapLayout = new AbsoluteLayout();

    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(slider, "top: 5px; left: 20px; z-index:1000;");
    mapLayout.addComponent(toolbar, "top: 324px; left: 12px;");
    mapLayout.addComponent(semanticLayout, "top: 380px; left: 2px;");
    mapLayout.setSizeFull();

    m_treeMapSplitPanel = new HorizontalSplitPanel();
    m_treeMapSplitPanel.setFirstComponent(createWestLayout());
    m_treeMapSplitPanel.setSecondComponent(mapLayout);
    m_treeMapSplitPanel.setSplitPosition(222, Sizeable.UNITS_PIXELS);
    m_treeMapSplitPanel.setSizeFull();

    m_commandManager.addCommandUpdateListener(this);

    menuBarUpdated(m_commandManager);
    if (m_widgetManager.widgetCount() != 0) {
        updateWidgetView(m_widgetManager);
    } else {
        m_layout.addComponent(m_treeMapSplitPanel, getBelowMenuPosition());
    }

    if (m_treeWidgetManager.widgetCount() != 0) {
        updateAccordionView(m_treeWidgetManager);
    }
}

From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java

License:Open Source License

/**
 * Creates the west area layout including the
 * accordion and tree views.//from   ww w  . j  a va  2s .com
 * 
 * @return
 */
@SuppressWarnings("serial")
private Layout createWestLayout() {
    m_tree = createTree();

    final TextField filterField = new TextField("Filter");
    filterField.setTextChangeTimeout(200);

    final Button filterBtn = new Button("Filter");
    filterBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            GCFilterableContainer container = m_tree.getContainerDataSource();
            container.removeAllContainerFilters();

            String filterString = (String) filterField.getValue();
            if (!filterString.equals("") && filterBtn.getCaption().toLowerCase().equals("filter")) {
                container.addContainerFilter(LABEL_PROPERTY, (String) filterField.getValue(), true, false);
                filterBtn.setCaption("Clear");
            } else {
                filterField.setValue("");
                filterBtn.setCaption("Filter");
            }

        }
    });

    HorizontalLayout filterArea = new HorizontalLayout();
    filterArea.addComponent(filterField);
    filterArea.addComponent(filterBtn);
    filterArea.setComponentAlignment(filterBtn, Alignment.BOTTOM_CENTER);

    m_treeAccordion = new Accordion();
    m_treeAccordion.addTab(m_tree, m_tree.getTitle());
    m_treeAccordion.setWidth("100%");
    m_treeAccordion.setHeight("100%");

    AbsoluteLayout absLayout = new AbsoluteLayout();
    absLayout.setWidth("100%");
    absLayout.setHeight("100%");
    absLayout.addComponent(filterArea, "top: 25px; left: 15px;");
    absLayout.addComponent(m_treeAccordion, "top: 75px; left: 15px; right: 15px; bottom:25px;");

    return absLayout;
}

From source file:org.opennms.features.vaadin.app.TopologyWidgetTestApplication.java

License:Open Source License

@Override
public void init() {
    //This timer is a hack at the moment to disable and enable menuItems
    m_timer.scheduleAtFixedRate(new TimerTask() {

        @Override/*from w w  w. ja v  a 2 s. c o  m*/
        public void run() {
            List<MenuItem> items = m_menuBar.getItems();
            for (MenuItem item : items) {
                if (item.getText().equals("Device")) {
                    List<MenuItem> children = item.getChildren();
                    for (MenuItem child : children) {
                        if (m_graphContainer.getSelectedVertexIds().size() > 0) {
                            if (!child.isEnabled()) {
                                child.setEnabled(true);
                            }
                        } else {
                            if (child.isEnabled()) {
                                child.setEnabled(false);
                            }

                        }
                    }

                }
            }
        }
    }, 1000, 1000);

    m_commandManager.addCommand(new Command("Redo Layout") {
        ;

        @Override
        public void doCommand(Object target) {
            m_graphContainer.redoLayout();
        }

        @Override
        public boolean appliesToTarget(Object target) {
            //Applies to background as a whole
            return target == null;
        }
    }, true);

    m_commandManager.addCommand(new Command("Open") {

        @Override
        public void doCommand(Object target) {
            m_graphContainer.load("graph.xml");
        }

    }, false, "File");

    m_commandManager.addCommand(new Command("Save") {

        @Override
        public void doCommand(Object target) {
            m_graphContainer.save("graph.xml");
        }

    }, false, "File");

    m_commandManager.addCommand(new Command("Add Vertex") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId);
        }

        @Override
        public void doCommand(Object vertexId) {
            if (vertexId == null) {
                addRandomVertex();
            } else {
                connectNewVertexTo(vertexId.toString(), SERVER_ICON);
            }
            m_graphContainer.redoLayout();
        }

    }, true, "File");

    m_commandManager.addCommand(new Command("Lock") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            if (m_graphContainer.getVertexContainer().containsId(itemId)) {
                Item v = m_graphContainer.getVertexContainer().getItem(itemId);
                return !(Boolean) v.getItemProperty("locked").getValue();
            }
            return false;
        }

        @Override
        public void doCommand(Object vertexId) {
            Item v = m_graphContainer.getVertexContainer().getItem(vertexId);
            v.getItemProperty("locked").setValue(true);
        }

    }, true);

    m_commandManager.addCommand(new Command("Unlock") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            if (m_graphContainer.getVertexContainer().containsId(itemId)) {
                Item v = m_graphContainer.getVertexContainer().getItem(itemId);
                return (Boolean) v.getItemProperty("locked").getValue();
            }
            return false;
        }

        @Override
        public void doCommand(Object vertexId) {
            Item v = m_graphContainer.getVertexContainer().getItem(vertexId);
            v.getItemProperty("locked").setValue(false);
        }

    }, true);
    m_commandManager.addCommand(new Command("Add Switch Vertex") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId);
        }

        @Override
        public void doCommand(Object vertexId) {
            if (vertexId == null) {
                addRandomVertex();
            } else {
                connectNewVertexTo(vertexId.toString(), SWITCH_ICON);
            }
            m_graphContainer.redoLayout();
        }

    }, true);

    m_commandManager.addCommand(new Command("Remove Vertex") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId);
        }

        @Override
        public void doCommand(Object vertexId) {
            if (vertexId == null) {
                System.err.println("need to handle selection!!!");
            } else {
                m_graphContainer.removeVertex(vertexId.toString());
                m_graphContainer.redoLayout();
            }
        }

    }, true, "File");

    m_commandManager.addCommand(new Command("Connect") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return m_graphContainer.getSelectedVertexIds().size() == 2;
        }

        @Override
        public void doCommand(Object unused) {
            List<Object> endPoints = new ArrayList<Object>(m_graphContainer.getSelectedVertexIds());

            m_graphContainer.connectVertices(m_graphContainer.getNextEdgeId(), (String) endPoints.get(0),
                    (String) endPoints.get(1));
        }

    }, true, "File");
    m_commandManager.addCommand(new Command("Create Group") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return m_graphContainer.getSelectedVertexIds().size() > 0;
        }

        @Override
        public void doCommand(Object vertexId) {
            String groupId = m_graphContainer.getNextGroupId();
            m_graphContainer.addGroup(groupId, GROUP_ICON);
            m_graphContainer.getVertexContainer().setParent(groupId, ROOT_GROUP_ID);

            for (Object itemId : m_graphContainer.getSelectedVertexIds()) {
                m_graphContainer.getVertexContainer().setParent(itemId, groupId);
            }
        }

    }, true, "Edit");

    m_commandManager.addCommand(new Command("Manual Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new ManualLayoutAlgorithm());
        }

    }, false, "Edit|Layout");

    m_commandManager.addCommand(new Command("Balloon Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new BalloonLayoutAlgorithm(CENTER_VERTEX_ID));
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("Circle Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new CircleLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("DAG Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new DAGLayoutAlgorithm(CENTER_VERTEX_ID));
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("Radial Tree Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new RadialTreeLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");
    m_commandManager.addCommand(new Command("Tree Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new TreeLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("Simple Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new SimpleLayoutAlgorithm());
        }

    }, false, "Edit|Layout");

    m_commandManager.addCommand(new Command("Spring Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new SpringLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("KK Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new KKLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("ISOM Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new ISOMLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("FR Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new FRLayoutAlgorithm());
        }

    }, false, "Edit|Layout|JUNG");

    m_commandManager.addCommand(new Command("Other Layout") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            m_graphContainer.setLayoutAlgorithm(new AlternativeLayoutAlgorithm());
        }

    }, false, "Edit|Layout");

    m_commandManager.addCommand(new Command("Reset") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {

            resetView();
        }

    }, false, null);

    m_commandManager.addCommand(new Command("History") {

        @Override
        public boolean appliesToTarget(Object target) {
            return true;
        }

        @Override
        public void doCommand(Object target) {
            showHistoryList(m_commandManager.getHistoryList());
        }

    }, false, null);

    m_commandManager.addCommand(new Command("Show Map") {

        @Override
        public void doCommand(Object target) {
            getMainWindow().showNotification("This has not been implemented yet");

        }

    }, false, "View");

    m_commandManager.addCommand(new Command("Get Info") {

        @Override
        public boolean appliesToTarget(Object itemId) {
            return itemId == null || m_graphContainer.getEdgeContainer().containsId(itemId);
        }

        @Override
        public void doCommand(Object target) {
            getMainWindow().showNotification("This has not been implemented yet");
        }

    }, true, "Device");

    AbsoluteLayout layout = new AbsoluteLayout();
    layout.setSizeFull();

    m_window = new Window("Topology Widget Test");
    m_window.setContent(layout);
    setMainWindow(m_window);

    m_graphContainer.addGroup(ROOT_GROUP_ID, GROUP_ICON);
    m_graphContainer.addVertex(CENTER_VERTEX_ID, 50, 50, SERVER_ICON);
    m_graphContainer.getVertexContainer().setParent(CENTER_VERTEX_ID, ROOT_GROUP_ID);
    m_graphContainer.setLayoutAlgorithm(new KKLayoutAlgorithm());

    m_topologyComponent = new TopologyComponent(m_graphContainer);
    m_commandManager.addActionHandlers(m_topologyComponent);
    m_topologyComponent.setSizeFull();

    final Property scale = m_graphContainer.getProperty("scale");
    final Slider slider = new Slider(1, 4);
    slider.setResolution(2);
    slider.setHeight("300px");
    slider.setOrientation(Slider.ORIENTATION_VERTICAL);

    slider.addListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            scale.setValue((Double) slider.getValue());
        }
    });

    slider.setImmediate(true);

    m_tree = createTree();
    Label semanticZoomLabel = new Label();
    final Property zoomLevel = m_graphContainer.getProperty("semanticZoomLevel");
    semanticZoomLabel.setPropertyDataSource(zoomLevel);

    Button zoomInBtn = new Button("Zoom In");
    zoomInBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) zoomLevel.getValue();
            szl++;
            zoomLevel.setValue(szl);
            m_graphContainer.redoLayout();
        }
    });

    Button zoomOutBtn = new Button("Zoom Out");
    zoomOutBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) zoomLevel.getValue();
            szl--;
            zoomLevel.setValue(szl);
            m_graphContainer.redoLayout();
        }
    });

    VerticalLayout vLayout = new VerticalLayout();
    vLayout.setWidth("100%");
    vLayout.setHeight("100%");
    vLayout.addComponent(m_tree);

    AbsoluteLayout mapLayout = new AbsoluteLayout();

    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(slider, "top: 20px; left: 20px; z-index:1000;");
    mapLayout.addComponent(semanticZoomLabel, "bottom: 10px; right: 10px; z-index: 2000;");
    mapLayout.setSizeFull();

    HorizontalSplitPanel treeMapSplitPanel = new HorizontalSplitPanel();
    treeMapSplitPanel.setFirstComponent(vLayout);
    treeMapSplitPanel.setSecondComponent(mapLayout);
    treeMapSplitPanel.setSplitPosition(100, Sizeable.UNITS_PIXELS);
    treeMapSplitPanel.setSizeFull();

    VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel();
    bottomLayoutBar.setFirstComponent(treeMapSplitPanel);

    VerticalLayout zoomLayout = new VerticalLayout();
    zoomLayout.addComponent(zoomInBtn);
    zoomLayout.addComponent(zoomOutBtn);

    bottomLayoutBar.setSecondComponent(zoomLayout);
    bottomLayoutBar.setSplitPosition(80, Sizeable.UNITS_PERCENTAGE);
    bottomLayoutBar.setSizeFull();

    m_menuBar = m_commandManager.getMenuBar();
    m_menuBar.setWidth("100%");
    layout.addComponent(m_menuBar, "top: 0px; left: 0px; right:0px;");
    layout.addComponent(bottomLayoutBar, "top: 23px; left: 0px; right:0px; bottom:0px;");

}

From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java

License:Open Source License

/**
 * Gets a {@link TabSheet} view for all widgets in this manager.
 * //from w ww . j a  v  a  2  s  . c o m
 * @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);

        // If the component supports the HasExtraComponents interface, then add the extra 
        // 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) {
                            // Bizarrely enough, getSelectedTab() returns the contained
                            // Component, not the Tab itself.
                            //
                            // 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;
}

From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.peptidescontainer.popupcomponents.PeptideSequenceContainer.java

private void initPeptidesStackedBarComponentsLayout(
        LinkedHashSet<StackedBarPeptideComponent> stackedBarComponents,
        AbsoluteLayout peptidesComponentsContainer, boolean flip) {
    int top = 0;//w ww  . j  a  v a2  s  . c  o m
    List<StackedBarPeptideComponent> initLevel = new ArrayList<StackedBarPeptideComponent>(
            stackedBarComponents);
    List<StackedBarPeptideComponent> updatedLevel = new ArrayList<StackedBarPeptideComponent>(
            stackedBarComponents);
    List<StackedBarPeptideComponent> nextLevel = new ArrayList<StackedBarPeptideComponent>();

    boolean existedPeptides = false;
    boolean intersect = true;
    while (intersect) {
        intersect = false;
        for (int x = 0; x < initLevel.size() && initLevel.size() > 1; x++) {
            StackedBarPeptideComponent pepBarComp = (StackedBarPeptideComponent) initLevel.get(x);
            for (int y = 0; y < initLevel.size(); y++) {
                if (y <= x) {
                    continue;
                }
                StackedBarPeptideComponent pepBarComp2 = (StackedBarPeptideComponent) initLevel.get(y);
                boolean check;
                if (pepBarComp.getX0() > pepBarComp2.getX0()) {
                    check = checkIntersect(pepBarComp2, pepBarComp);
                } else {
                    check = checkIntersect(pepBarComp, pepBarComp2);
                }
                if (check) {
                    intersect = true;
                    if (pepBarComp.getWidthArea() > pepBarComp2.getWidthArea()) {
                        updatedLevel.remove(y);
                        pepBarComp2.setLevel(pepBarComp2.getLevel() + 1);
                        nextLevel.add(pepBarComp2);
                    } else if (pepBarComp.getWidthArea() == pepBarComp2.getWidthArea()) {
                        if (!pepBarComp2.isSignificant()) {
                            updatedLevel.remove(y);
                            pepBarComp2.setLevel(pepBarComp2.getLevel() + 1);
                            nextLevel.add(pepBarComp2);
                        } else {
                            updatedLevel.remove(x);
                            pepBarComp.setLevel(pepBarComp.getLevel() + 1);
                            nextLevel.add(pepBarComp);

                        }

                    } else {
                        updatedLevel.remove(x);
                        pepBarComp.setLevel(pepBarComp.getLevel() + 1);
                        nextLevel.add(pepBarComp);
                    }
                    initLevel.clear();
                    initLevel.addAll(updatedLevel);

                    break;
                }

            }
            if (intersect) {
                break;
            }

        }

        if (!intersect) {
            for (StackedBarPeptideComponent pepBarComp : updatedLevel) {
                peptidesComponentsContainer.addComponent(pepBarComp,
                        "left: " + (pepBarComp.getX0() - 20) + "px; top: " + (top + 10) + "px;");
                existedPeptides = true;
                if (pepBarComp.isPtmAvailable()) {
                    if (flip) {
                        peptidesComponentsContainer.addComponent(pepBarComp.getPtmLayout(),
                                "left: " + (pepBarComp.getX0() - 20 + (pepBarComp.getWidth() / 2) - 5)
                                        + "px; top: " + (top + 21) + "px;");
                    } else {
                        peptidesComponentsContainer.addComponent(pepBarComp.getPtmLayout(),
                                "left: " + (pepBarComp.getX0() - 20 + (pepBarComp.getWidth() / 2) - 5)
                                        + "px; top: " + (top - 4) + "px;");
                    }
                    pepBarComp.getPtmLayout().setVisible(true);
                    ptmsLayoutMap.add(pepBarComp.getPtmLayout());
                }

            }
            updatedLevel.clear();
            updatedLevel.addAll(initLevel);
            initLevel.clear();

        }
        if (!intersect && !nextLevel.isEmpty()) {

            initLevel.clear();
            updatedLevel.clear();
            initLevel.addAll(nextLevel);
            updatedLevel.addAll(nextLevel);
            nextLevel.clear();
            intersect = true;
            top = top + 20;
        }

    }
    if (stackedPeptides.isEmpty()) {
        stackedPeptides.addAll(stackedBarComponents);
    }
    if (existedPeptides) {
        top = top + 40;
        peptidesComponentsContainer.setHeight(Math.max(40, top) + "px");
    } else {
        peptidesComponentsContainer.setHeight("0px");
    }

}

From source file:songstock.web.SongStockUI.java

License:Open Source License

/**
 * Initializes the SongStock UI elements.
 * @param request /*from ww  w. j a v a 2  s.  com*/
 */
@Override
protected void init(VaadinRequest request) {

    // Set the browser window title
    getPage().setTitle("SongStock");

    final AbsoluteLayout layout = new AbsoluteLayout();
    layout.setSizeFull();

    // Menu Panel
    MenuPanel menuPanel = new MenuPanel();
    menuPanel.setImmediate(true);
    layout.addComponent(menuPanel, "top:0.0px;left:0.0px;");
    Registry.register(MENU_PANEL, menuPanel);

    // Content Panel
    ContentPanel contentPanel = new ContentPanel();
    contentPanel.setImmediate(true);
    layout.addComponent(contentPanel, "top:23.0px;left:0.0px;");
    Registry.register(CONTENT_PANEL, contentPanel);

    setContent(layout);

    Registry.register(UI, this);

    // Set the application menus

    // USERS SUBSYSTEM:

    // Login Module
    menuPanel.addMenu("Login", BasicLoginFormController.getInstance().getLoginCommand(), true);
    BasicLoginFormController.getInstance().showLoginForm();

    // Register Module
    menuPanel.addMenu("Register", RegisterFormController.getInstance().getRegisterCommand(), true);

    // Multiple Addresses (UI contribution to RegisterForm)
    RegisterFormController.getInstance().addContributor(AddressesController.getInstance());

    // CATALOG SUBSYSTEM:

    // Browsing Module
    menuPanel.addMenu("Browse Catalog", BrowsingController.getInstance().getBrowsingCommand(), true);

    // Basic Search Module
    menuPanel.addMenu("Basic Search", SearchController.getInstance().getBasicSearchCommand(), true);

    // PAYMENTS SUBSYSTEM:

    // Payments Core Module (Process contribution)
    ShoppingCartController.getInstance().addContributor(PAYMENT_STAGE, PaymentViewController.getInstance());

    // Payment Methods (UI contributions)
    PaymentViewController.getInstance().addContributor(CreditCardFormController.getInstance());

    // Additional Charges (Content contributions)
    PaymentViewController.getInstance().addContributor(TaxController.getInstance());

    // SALES SUBSYSTEM:

    // Shopping Cart Module
    menuPanel.addMenu("Shopping Cart", ShoppingCartController.getInstance().getShoppingCartCommand(), false);
    // UI contributions
    BrowsingController.getInstance().addContributor(ShoppingCartController.getInstance());
    SearchController.getInstance().addContributor(ShoppingCartController.getInstance());

    // Download Module (Process contribution)
    ShoppingCartController.getInstance().addContributor(DOWNLOAD_STAGE, DownloadController.getInstance());

    // Purchase History Module
    menuPanel.addMenu("Purchase History", PurchaseHistoryController.getInstance().getPurchaseHistoryCommand(),
            false);
    // Process contributions

    ShoppingCartController.getInstance().addContributor(PURCHASE_STAGE,
            PurchaseHistoryController.getInstance());
}