Example usage for com.vaadin.ui VerticalSplitPanel setFirstComponent

List of usage examples for com.vaadin.ui VerticalSplitPanel setFirstComponent

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalSplitPanel setFirstComponent.

Prototype

public void setFirstComponent(Component c) 

Source Link

Document

Sets the first component of this split panel.

Usage

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

License:Open Source License

/**
 * Updates the bottom widget area with the registered widgets
 * /*from  w  ww.j av a  2s  .  c o  m*/
 * Any widget with the service property of 'location=bottom' are
 * included.
 * 
 * @param widgetManager
 */
private void updateWidgetView(WidgetManager widgetManager) {
    synchronized (m_layout) {
        m_layout.removeAllComponents();
        if (widgetManager.widgetCount() == 0) {
            m_layout.addComponent(m_treeMapSplitPanel, getBelowMenuPosition());
        } else {
            VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel();
            bottomLayoutBar.setFirstComponent(m_treeMapSplitPanel);
            // Split the screen 70% top, 30% bottom
            bottomLayoutBar.setSplitPosition(70, Sizeable.UNITS_PERCENTAGE);
            bottomLayoutBar.setSizeFull();
            bottomLayoutBar.setSecondComponent(getTabSheet(widgetManager, this));
            m_layout.addComponent(bottomLayoutBar, getBelowMenuPosition());
        }
        m_layout.requestRepaint();
    }
    if (m_contextMenu != null && m_contextMenu.getParent() == null) {
        getMainWindow().addComponent(m_contextMenu);
    }
}

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  www  .java2 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

private void updateWidgetView() {
    final VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel();
    bottomLayoutBar.setFirstComponent(m_mapWidgetComponent);

    // Split the screen 70% top, 30% bottom
    bottomLayoutBar.setSplitPosition(70, Unit.PERCENTAGE);
    bottomLayoutBar.setSizeFull();/*from w w w  .  j a  va2 s .c o  m*/
    bottomLayoutBar.setSecondComponent(getTabSheet());
    m_layout.addComponent(bottomLayoutBar);
    m_layout.markAsDirty();
}

From source file:pt.yellowduck.ramboia.RamboiaApplication.java

License:Open Source License

private void buildMainLayout() {

    VerticalSplitPanel vSplit = new VerticalSplitPanel();
    vSplit.setSplitPosition(15, Sizeable.UNITS_PERCENTAGE);
    vSplit.setSizeFull();/*  w  w w  . j  a  v  a2 s  .  co m*/

    HorizontalSplitPanel hSplit_top = new HorizontalSplitPanel();
    hSplit_top.setSizeFull();
    hSplit_top.setSplitPosition(50, Sizeable.UNITS_PERCENTAGE);
    hSplit_top.setFirstComponent(viewPlayer);
    hSplit_top.setSecondComponent(viewUpload);
    hSplit_top.setLocked(true);

    vSplit.setFirstComponent(hSplit_top);

    HorizontalSplitPanel hSplit_bottom = new HorizontalSplitPanel();
    hSplit_bottom.setSizeFull();
    hSplit_bottom.setSplitPosition(75, Sizeable.UNITS_PERCENTAGE);
    hSplit_bottom.setFirstComponent(viewLibrary);
    hSplit_bottom.setSecondComponent(viewPlaylist);
    hSplit_bottom.setLocked(true);

    vSplit.setSecondComponent(hSplit_bottom);

    mainWindow.setContent(vSplit);
}