Example usage for com.vaadin.ui VerticalLayout setWidth

List of usage examples for com.vaadin.ui VerticalLayout setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:org.openeos.services.ui.vaadin.internal.abstractform.UIVaadinFormToolkit.java

License:Apache License

@Override
protected AbstractComponent internalBuildField(org.abstractform.core.Field field,
        Map<String, Object> extraObjects) {
    AbstractComponent ret;//  w  w  w  .  j a  va 2s . c  om
    if (BFUIButton.TYPE_UI_BUTTON.equals(field.getType())) {
        UIVaadinButtonField button = new UIVaadinButtonField(field.getName(),
                (UIButtonController) field.getExtra(BFUIButton.EXTRA_UI_BUTTON_CONTROLLER),
                (UIApplicationImpl) extraObjects.get(EXTRA_OBJECT_APPLICATION));
        ret = button;
    } else if (BFUITable.TYPE_UITABLE.equals(field.getType())) {
        final Table table = (Table) buildTableField(field, extraObjects);
        HorizontalLayout mainLayout = new HorizontalLayout();
        mainLayout.setSizeFull();
        //mainLayout.setSizeFull();
        mainLayout.setMargin(false);
        mainLayout.setSpacing(true);
        mainLayout.addComponent(table);

        VerticalLayout buttonLayout = new VerticalLayout();
        buttonLayout.setMargin(false);
        buttonLayout.setSpacing(true);
        //buttonLayout.setSizeFull();

        final UITableController controller = (UITableController) field
                .getExtra(BFUITable.EXTRA_TABLE_CONTROLLER);
        final UIApplication application = (UIApplication) extraObjects.get(EXTRA_OBJECT_APPLICATION);

        Button buttonNew = new Button("N", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onNew(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues());
            }
        });
        buttonNew.setWidth("100%");
        buttonLayout.addComponent(buttonNew);
        Button buttonEdit = new Button("E", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onEdit(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue());
            }
        });
        buttonEdit.setWidth("100%");
        buttonLayout.addComponent(buttonEdit);
        Button buttonDelete = new Button("D", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onDelete(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue());
            }
        });
        buttonDelete.setWidth("100%");
        buttonLayout.addComponent(buttonDelete);

        buttonLayout.setWidth("50px");

        mainLayout.addComponent(buttonLayout);
        mainLayout.setExpandRatio(table, 1.0f);
        ret = mainLayout;

    } else {
        ret = super.internalBuildField(field, extraObjects);
        if (field.getType().equals(Field.TYPE_NUMERIC)) {
            //TODO This normally can be many types of classes and can be with data conversion in binding tier
            ((TextField) ret).setPropertyDataSource(new ObjectProperty<BigDecimal>(null, BigDecimal.class));
        }
    }
    return ret;
}

From source file:org.openeos.usertask.ui.VaadinEntityUsertaskUI.java

License:Apache License

@Override
protected VerticalLayout createVaadinComponent(UserTask userTask,
        UIApplication<IUnoVaadinApplication> application) {

    EntityInfo info = extractEntity(userTask);

    Panel panel = createPanel("Entities");
    StringBuilder captionBuilder = new StringBuilder();
    captionBuilder.append(info.classDefinition.getSingularEntityName());
    captionBuilder.append(": ");
    captionBuilder.append(info.classDefinition.getStringRepresentation(info.entity));
    Button button = new Button(captionBuilder.toString());
    button.setStyleName(Reindeer.BUTTON_LINK);
    panel.addComponent(button);/*ww  w  . j  a  v  a2 s.co m*/
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);
    mainLayout.setWidth("100%");
    mainLayout.addComponent(panel);
    return mainLayout;
}

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

License:Open Source License

@SuppressWarnings("serial")
@Override/*from  w  w  w . j  av  a 2  s .  c o  m*/
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.netutils.internal.TracerouteWindow.java

License:Open Source License

/**
 * The TracerouteWindow method constructs a TracerouteWindow component with a size proportionate to the 
 * width and height of the main window.//from  w ww  .ja v a2  s.  c  o  m
 * @param node 
 * @param width Width of Main window
 * @param height Height of Main window
 */
public TracerouteWindow(final Node node, final String url) {

    this.tracerouteUrl = url;

    String label = "";
    String ipAddress = "";
    if (node != null) {
        label = node.getLabel();
        ipAddress = node.getIPAddress();
    }
    String caption = "";
    /*Sets up window settings*/
    if (label == null || label.equals("") || label.equalsIgnoreCase(noLabel)) {
        label = "";
    }
    if (!label.equals(""))
        caption = " - " + label;
    setCaption("Traceroute" + caption);
    setImmediate(true);
    setResizable(false);

    /*Initialize the header of the Sub-window with the name of the selected Node*/
    String nodeName = "<div style=\"text-align: center; font-size: 18pt; font-weight:bold;\">" + label
            + "</div>";
    nodeLabel = new Label(nodeName);
    nodeLabel.setContentMode(ContentMode.HTML);

    /*Creating various layouts to encapsulate all of the components*/
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    vSplit = new VerticalSplitPanel();
    topLayout = new VerticalLayout();
    bottomLayout = new VerticalLayout();
    VerticalLayout form = new VerticalLayout();
    GridLayout grid = new GridLayout(2, 2);
    grid.setWidth("420");
    grid.setHeight("62");

    /*Sets up IP Address dropdown with the Name as default*/
    ipDropdown = new NativeSelect();
    ipDropdown.addItem(ipAddress);
    ipDropdown.select(ipAddress);

    /*Creates the Numerical Output Check box and sets up the listener*/
    numericalDataCheckBox = new CheckBox("Use Numerical Node Names");
    numericalDataCheckBox.setImmediate(true);
    numericalDataCheckBox.setValue(false);

    /*Creates the form labels and text fields*/
    Label ipLabel = new Label("IP Address: ");
    Label forcedHopLabel = new Label("Forced Hop IP: ");
    forcedHopField = new TextField();
    forcedHopField.setMaxLength(15);

    /*Add all of the components to the GridLayout*/
    grid.addComponent(ipLabel);
    grid.setComponentAlignment(ipLabel, Alignment.MIDDLE_LEFT);
    grid.addComponent(ipDropdown);
    grid.setComponentAlignment(ipDropdown, Alignment.MIDDLE_LEFT);
    grid.addComponent(forcedHopLabel);
    grid.setComponentAlignment(forcedHopLabel, Alignment.MIDDLE_LEFT);
    grid.addComponent(forcedHopField);
    grid.setComponentAlignment(forcedHopField, Alignment.MIDDLE_LEFT);

    /*Creates the Ping button and sets up the listener*/
    tracerouteButton = new Button("Traceroute");
    tracerouteButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            changeBrowserURL(buildURL());
        }
    });

    /*Adds components to the form and sets the width and spacing*/
    form.addComponent(grid);
    form.addComponent(numericalDataCheckBox);
    form.addComponent(tracerouteButton);
    form.setWidth("100%");
    form.setSpacing(true);

    /*Adds components to the Top Layout and sets the width and margins*/
    topLayout.addComponent(nodeLabel);
    topLayout.setComponentAlignment(nodeLabel, Alignment.MIDDLE_CENTER);
    topLayout.addComponent(form);
    topLayout.setSizeFull();
    topLayout.setMargin(new MarginInfo(true, true, false, true));

    /*Adds components to the Bottom Layout and sets the width and margins*/
    bottomLayout.setSizeFull();
    bottomLayout.setMargin(true);
    bottomLayout.setImmediate(true);

    buildEmbeddedBrowser();

    /*Setting first and second components for the split panel and setting the panel divider position*/
    vSplit.setFirstComponent(topLayout);
    vSplit.setSecondComponent(bottomLayout);
    vSplit.setSplitPosition(splitHeight, Unit.PIXELS);
    vSplit.setLocked(true);

    /*Adds split panel to the main layout and expands the split panel to 100% of the layout space*/
    mainLayout.addComponent(vSplit);
    mainLayout.setExpandRatio(vSplit, 1);

    setContent(mainLayout);
}

From source file:org.opennms.features.topology.ssh.internal.SSHWindow.java

License:Open Source License

/**
 * The constructor for the SSH window//from w w w  . j  a  v  a2  s .  co  m
 * 
 * @param session The current SSH session
 * @param width The width of the window
 * @param height The height of the window
 */
public SSHWindow(ClientSession session, int width, int height) {
    super("SSH");
    setImmediate(true);
    setResizeLazy(false);
    setWidth("" + width + "px");
    setHeight("" + height + "px");

    VerticalLayout vPanel = new VerticalLayout();
    vPanel.setWidth("100%");
    vPanel.setHeight("100%");

    if (session != null) {
        terminal = new SSHTerminal(this, session, TERM_WIDTH, TERM_HEIGHT);
        vPanel.addComponent(terminal);
        vPanel.setComponentAlignment(terminal, Alignment.TOP_CENTER);
    } else {
        vPanel.addComponent(errorLabel);
        vPanel.setComponentAlignment(errorLabel, Alignment.MIDDLE_CENTER);
    }
    setContent(vPanel);
}

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/* w  ww  . j  a v a  2s . 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.pmatrix.ui.PmatrixApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth("-1px");
    layout.setHeight("-1px");
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    layout.setMargin(true);/*from ww  w . j av a  2  s .  c  om*/
    setContent(layout);

    //used to test that detach events are happening
    addDetachListener(new DetachListener() {
        @Override
        public void detach(DetachEvent event) {
            LOG.debug("Pmatrix UI instance detached:" + this);
        }
    });

    Component uiComponent = uiComponentFactory.getUiComponent(request);

    if (uiComponent == null) {

        StringBuilder sb = new StringBuilder(
                "Error: Cannot create the UI because the URL request parameters are not recognised<BR>\n"
                        + "you need to provide atleast '?" + UiComponentFactory.COMPONENT_REQUEST_PARAMETER
                        + "=" + UiComponentFactory.DEFAULT_COMPONENT_REQUEST_VALUE + "'<BR>\n"
                        + "Parameters passed in URL:<BR>\n");
        for (Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
            sb.append("parameter:'" + entry.getKey() + "' value:'");
            for (String s : entry.getValue()) {
                sb.append("{" + s + "}");
            }
            sb.append("'<BR>\n");
        }
        Label label = new Label();
        label.setWidth("600px");
        label.setContentMode(ContentMode.HTML);
        label.setValue(sb.toString());
        layout.addComponent(label);

    } else {
        layout.addComponent(uiComponent);

        // refresh interval to apply to the UI
        int pollInterval = uiComponentFactory.getRefreshRate();
        setPollInterval(pollInterval);

        // display poll interval in seconds
        DecimalFormat dformat = new DecimalFormat("##.##");
        Label label = new Label();
        label.setCaption("(refresh rate:" + dformat.format(pollInterval / 1000) + " seconds)");
        layout.addComponent(label);
    }

}

From source file:org.ow2.sirocco.cloudmanager.ConfirmDialog.java

License:Open Source License

private ConfirmDialog(final String caption, final String question, final String option, final String okLabel,
        final String cancelLabel, final ConfirmationDialogCallback callback) {

    super(caption);
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);//  w  w w.jav  a 2  s.c  o  m
    content.setWidth("400px");
    content.setHeight("150px");

    this.callback = callback;

    if (question != null) {
        Label label = new Label(question);
        content.addComponent(label);
    }
    if (option != null) {
        this.optionBox = new CheckBox(option);
        content.addComponent(this.optionBox);
    }

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button(okLabel, this);
    this.cancelButton = new Button(cancelLabel, this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

}

From source file:org.ow2.sirocco.cloudmanager.KeyPairImportDialog.java

License:Open Source License

public KeyPairImportDialog(final DialogCallback callback) {
    super("Import Key Pair");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();/*from   w w  w  .  j  av  a2  s.  co  m*/
    content.setMargin(true);
    content.setSpacing(true);
    content.setWidth("500px");
    content.setHeight("250px");

    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);
    form.setSpacing(true);

    this.nameField = new TextField("Name");
    this.nameField.setWidth("50%");
    this.nameField.setRequired(true);
    this.nameField.setRequiredError("Please enter a name for your key pair");
    form.addComponent(this.nameField);

    this.publicKeyField = new TextArea("Public Key");
    this.publicKeyField.setWidth("100%");
    this.publicKeyField.setRequired(true);
    this.publicKeyField.setRequiredError("Please enter a name for your key pair");
    form.addComponent(this.publicKeyField);

    content.addComponent(form);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

}

From source file:org.processbase.ui.bpm.admin.ProcessDefinitionWindow.java

License:Open Source License

public void initUI() {
    try {/*from   ww w.  ja  v a2s .co m*/
        String caption = processDefinition.getLabel() != null ? processDefinition.getLabel()
                : processDefinition.getName();
        setCaption(caption + " (v." + processDefinition.getVersion() + ")");
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);

        v1.setMargin(true, false, false, false);
        v1.setSizeFull();

        if (processDefinition.getLabel() != null) {
            Label pdLabel = new Label("<b>" + processDefinition.getLabel() + "</b>");
            pdLabel.setContentMode(Label.CONTENT_XHTML);
            v1.addComponent(pdLabel);
        }

        if (processDefinition.getDescription() != null) {
            Label pdDescription = new Label(processDefinition.getDescription());
            pdDescription.setContentMode(Label.CONTENT_XHTML);
            v1.addComponent(pdDescription);
            v1.setExpandRatio(pdDescription, 1);
        }

        tabSheet.addTab(v1, ProcessbaseApplication.getCurrent().getPbMessages().getString("tabDescription"),
                null);

        activitiesTable.setSizeFull();

        v2.setMargin(false, false, false, false);
        v2.addComponent(activitiesTable);
        v2.setSizeFull();
        tabSheet.addTab(v2, ProcessbaseApplication.getCurrent().getPbMessages().getString("tabCustomUI"), null);

        // prepare membership
        prepareTableMembership();
        addBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnAdd"), this);
        addBtn.setStyleName(Runo.BUTTON_SMALL);
        v3.setMargin(false, false, false, false);
        v3.setSpacing(true);
        v3.addComponent(addBtn);
        v3.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
        v3.addComponent(tableMembership);
        v3.setSizeFull();
        tabSheet.addTab(v3, ProcessbaseApplication.getCurrent().getPbMessages().getString("processAccess"),
                null);
        refreshTableMembership();

        tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL);
        tabSheet.setSizeFull();
        tabSheet.addListener((TabSheet.SelectedTabChangeListener) this);
        layout.addComponent(tabSheet);
        layout.setExpandRatio(tabSheet, 1);

        closeBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnClose"), this);
        applyBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSaveCustomUI"),
                this);
        saveAccessBtn = new Button(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSaveProcessAccess"), this);
        deleteAllBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDeleteAll"),
                this);
        deleteInstancesBtn = new Button(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDeleteInstances"), this);
        downloadBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDownload"),
                this);
        enableBtn = new CheckBox(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnEnable"),
                this);
        archiveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnArchive"),
                this);

        deleteAllBtn.setDescription(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("deleteProcessDefinition"));
        buttons.addButton(deleteAllBtn);
        buttons.setComponentAlignment(deleteAllBtn, Alignment.MIDDLE_RIGHT);
        deleteInstancesBtn.setDescription(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("deleteProcessInstances"));
        buttons.addButton(deleteInstancesBtn);
        buttons.setComponentAlignment(deleteInstancesBtn, Alignment.MIDDLE_RIGHT);

        Label expand = new Label("");
        buttons.addComponent(expand);
        buttons.setExpandRatio(expand, 1);

        enableBtn.setValue(processDefinition.getState().equals(ProcessState.ENABLED));
        buttons.addButton(enableBtn);
        buttons.setComponentAlignment(enableBtn, Alignment.MIDDLE_RIGHT);

        buttons.addButton(archiveBtn);
        buttons.setComponentAlignment(archiveBtn, Alignment.MIDDLE_RIGHT);

        applyBtn.setVisible(false);
        buttons.addButton(applyBtn);
        buttons.setComponentAlignment(applyBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(saveAccessBtn);
        saveAccessBtn.setVisible(false);
        buttons.setComponentAlignment(saveAccessBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(closeBtn);
        buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        layout.addComponent(buttons);
        layout.setWidth("800px");
        layout.setHeight("400px");
        setResizable(false);
        setModal(true);

        //        activitiesTable.addContainerProperty("activityUUID", String.class, null, "UUID", null, null);
        //        activitiesTable.setColumnWidth("activityUUID", 0);
        activitiesTable.addContainerProperty("activityLabel", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionActivityName"), null,
                null);
        activitiesTable.addContainerProperty("url", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tabCaptionTaskURL"), null, null);
        activitiesTable.setColumnWidth("url", 300);
        activitiesTable.setTableFieldFactory(new PbTableFieldFactory());
        activitiesTable.setEditable(true);
        activitiesTable.setImmediate(true);

        refreshTable();
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
    }
}