Example usage for com.vaadin.ui HorizontalSplitPanel addComponent

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

Introduction

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

Prototype


@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:org.s23m.cell.editor.semanticdomain.Editor.java

License:Mozilla Public License

@Override
public void init() {
    EditorController.getInstance().setEditor(this);
    mainWindow = new Window("Gmodel");
    //mainWindow.addComponent(pusher);
    setMainWindow(mainWindow);/*from  w ww  . ja  va 2s  .co m*/
    setTheme(THEME_NAME);

    initializeGmodelKernel();

    final HorizontalSplitPanel splitter = new HorizontalSplitPanel();
    splitter.setSplitPosition(DEFAULT_L_WIDTH, Sizeable.UNITS_PIXELS);
    mainWindow.setContent(splitter);

    containmentTreePanel = new ContainmentTreePanel(this);
    multitabPanel = new MultitabPanel(this);
    //((VerticalLayout)multitabPanel.getConsole().getParent()).addComponent(pusher);
    splitter.addComponent(containmentTreePanel);
    splitter.addComponent(multitabPanel);
}

From source file:org.sensorhub.ui.AdminUI.java

License:Mozilla Public License

@Override
protected void init(VaadinRequest request) {
    String configClass = null;//from w w w . ja  v a2 s  .  c  om
    moduleConfigLists.clear();

    // retrieve module config
    try {
        Properties initParams = request.getService().getDeploymentConfiguration().getInitParameters();
        String moduleID = initParams.getProperty(AdminUIModule.SERVLET_PARAM_MODULE_ID);
        uiConfig = (AdminUIConfig) SensorHub.getInstance().getModuleRegistry().getModuleById(moduleID)
                .getConfiguration();
    } catch (Exception e) {
        throw new RuntimeException("Cannot get UI module configuration", e);
    }

    try {
        // load default form builders
        customForms.put(HttpServerConfig.class.getCanonicalName(), HttpServerConfigForm.class);
        customForms.put(StreamStorageConfig.class.getCanonicalName(), GenericStorageConfigForm.class);
        customForms.put(CommConfig.class.getCanonicalName(), CommConfigForm.class);
        customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSServiceConfig", SOSConfigForm.class);
        customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSProviderConfig", SOSConfigForm.class);

        // load custom form builders defined in config
        for (CustomUIConfig customForm : uiConfig.customForms) {
            configClass = customForm.configClass;
            Class<?> clazz = Class.forName(customForm.uiClass);
            customForms.put(configClass, (Class<IModuleConfigForm>) clazz);
            log.debug("Loaded custom form for " + configClass);
        }
    } catch (Exception e) {
        log.error("Error while instantiating form builder for config class " + configClass, e);
    }

    try {
        // load default panel builders
        customPanels.put(SensorConfig.class.getCanonicalName(), SensorAdminPanel.class);
        customPanels.put(StorageConfig.class.getCanonicalName(), StorageAdminPanel.class);

        // load custom panel builders defined in config
        for (CustomUIConfig customPanel : uiConfig.customPanels) {
            configClass = customPanel.configClass;
            Class<?> clazz = Class.forName(customPanel.uiClass);
            customPanels.put(configClass, (Class<IModuleAdminPanel<?>>) clazz);
            log.debug("Loaded custom panel for " + configClass);
        }
    } catch (Exception e) {
        log.error("Error while instantiating panel builder for config class " + configClass, e);
    }

    // register new field converter for interger numbers
    @SuppressWarnings("serial")
    ConverterFactory converterFactory = new DefaultConverterFactory() {
        @Override
        protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter(
                Class<PRESENTATION> presentationType, Class<MODEL> modelType) {
            // Handle String <-> Integer/Short/Long
            if (presentationType == String.class
                    && (modelType == Long.class || modelType == Integer.class || modelType == Short.class)) {
                return (Converter<PRESENTATION, MODEL>) new StringToIntegerConverter() {
                    @Override
                    protected NumberFormat getFormat(Locale locale) {
                        NumberFormat format = super.getFormat(Locale.US);
                        format.setGroupingUsed(false);
                        return format;
                    }
                };
            }
            // Let default factory handle the rest
            return super.findConverter(presentationType, modelType);
        }
    };
    VaadinSession.getCurrent().setConverterFactory(converterFactory);

    // init main panels
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setMinSplitPosition(300.0f, Unit.PIXELS);
    splitPanel.setMaxSplitPosition(30.0f, Unit.PERCENTAGE);
    splitPanel.setSplitPosition(350.0f, Unit.PIXELS);
    setContent(splitPanel);

    // build left pane
    VerticalLayout leftPane = new VerticalLayout();
    leftPane.setSizeFull();

    // header image and title
    Component header = buildHeader();
    leftPane.addComponent(header);
    leftPane.setExpandRatio(header, 0);

    // toolbar
    Component toolbar = buildToolbar();
    leftPane.addComponent(toolbar);
    leftPane.setExpandRatio(toolbar, 0);

    // accordion with several sections
    Accordion stack = new Accordion();
    stack.setSizeFull();
    VerticalLayout layout;
    Tab tab;

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Sensors");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, SensorConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Storage");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, StorageConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Processing");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ProcessConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Services");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ServiceConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Clients");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ClientConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Network");
    tab.setIcon(ACC_TAB_ICON);
    buildNetworkConfig(layout);

    leftPane.addComponent(stack);
    leftPane.setExpandRatio(stack, 1);
    splitPanel.addComponent(leftPane);

    // init config area
    configArea = new VerticalLayout();
    configArea.setMargin(true);
    splitPanel.addComponent(configArea);
}

From source file:pl.altkom.ecommerce.vaadin.view.ProductListView.java

private void initLayout() {
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    addComponent(splitPanel);//from  w w  w . j  a  v a 2  s . com

    VerticalLayout leftLayout = new VerticalLayout();
    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(editorLayout);
    leftLayout.addComponent(contactList);
    HorizontalLayout bottomLeftLayout = new HorizontalLayout();
    leftLayout.addComponent(bottomLeftLayout);
    bottomLeftLayout.addComponent(searchField);
    bottomLeftLayout.addComponent(addNewContactButton);
    leftLayout.setSizeFull();
    leftLayout.setExpandRatio(contactList, 1);
    contactList.setSizeFull();
    bottomLeftLayout.setWidth("100%");
    searchField.setWidth("100%");
    bottomLeftLayout.setExpandRatio(searchField, 1);
    editorLayout.setMargin(true);
    editorLayout.setVisible(false);

}

From source file:ru.codeinside.adm.ui.TableGroup.java

License:Mozilla Public License

TableGroup(String typeGroup) {
    setSizeFull();/* w w  w  . j a v a2 s .  co m*/
    this.typeGroup = typeGroup;
    setMargin(false, false, false, true);
    table = new FilterTable();
    table.setSizeFull();
    table.setSelectable(true);
    table.setMultiSelect(false);
    table.addListener(this);
    table.setImmediate(true);
    table.addContainerProperty("", String.class, "");
    table.addContainerProperty("?", String.class, "");
    table.setFilterBarVisible(true);
    table.setFilterDecorator(new FilterDecorator_());
    Set<String> groupNames = null;
    if (typeGroup.equals(GroupTab.ORGANIZATION)) {
        groupNames = AdminServiceProvider.get().getOrgGroupNames();
    } else if (typeGroup.equals(GroupTab.EMPLOYEE)) {
        groupNames = AdminServiceProvider.get().getEmpGroupNames();
    }
    for (String groupName : groupNames) {
        List<Group> groups = AdminServiceProvider.get().findGroupByName(groupName);
        for (Group group : groups) {
            table.addItem(new Object[] { groupName, group.getTitle() }, groupName);
        }
    }

    panel.setStyleName(Reindeer.PANEL_LIGHT);
    panel.setSizeFull();

    final HorizontalSplitPanel horiz = new HorizontalSplitPanel();
    horiz.setSplitPosition(35); // percent
    horiz.setSizeFull();
    addComponent(horiz);
    horiz.addComponent(table);
    horiz.addComponent(panel);
}

From source file:ru.codeinside.adm.ui.TreeTableOrganization.java

License:Mozilla Public License

public TreeTableOrganization() {
    setSizeFull();/*from ww  w .j  a v a 2 s  .c om*/
    treetable = new TreeTable();
    treetable.setSizeFull();
    treetable.setSelectable(true);
    treetable.setMultiSelect(false);
    treetable.addListener(this);
    treetable.setImmediate(true);
    treetable.setValue(null);
    setMargin(true);
    // Add Table columns
    treetable.addContainerProperty(NAME_PROPERTY, String.class, "");

    fillTable(treetable);

    treetable.addListener(new ExpandListener() {

        private static final long serialVersionUID = 1L;

        public void nodeExpand(ExpandEvent event) {
            if (lockExpandListener) {
                return;
            }
            Object valuePropertyEvent = event.getItemId();
            Organization org = AdminServiceProvider.get().findOrganizationById((Long) valuePropertyEvent);
            Set<Organization> childs = org.getOrganizations();
            if (!(childs.isEmpty())) {
                treetable.setChildrenAllowed((Long) valuePropertyEvent, true);

                for (Organization o : childs) {
                    treetable.addItem(new Object[] { o.getName() }, o.getId());
                    treetable.setCollapsed(o.getId(), true);
                }

                for (Organization o : childs) {
                    treetable.setParent(o.getId(), (Long) valuePropertyEvent);
                }

                for (Organization o : childs) {
                    treetable.setChildrenAllowed(o.getId(), !(o.getOrganizations().isEmpty()));
                }
            }

        }
    });

    treetable.addListener(new CollapseListener() {

        private static final long serialVersionUID = 1L;

        public void nodeCollapse(CollapseEvent event) {
            if (lockExpandListener) {
                return;
            }
            Set<Object> delete = new HashSet<Object>();
            Collection<?> children = treetable.getChildren(event.getItemId());
            if (children != null) {
                for (Object child : children) {
                    removeRecursively(child, delete);
                }
            }
            for (Object o : delete) {
                treetable.setCollapsed(o, true);
                treetable.removeItem(o);
            }
        }

        private void removeRecursively(Object object, Set<Object> delete) {
            Collection<?> children = treetable.getChildren(object);
            if (children != null) {
                for (Object child : children) {
                    removeRecursively(child, delete);
                }
            }
            delete.add(object);
        }
    });

    panel.setStyleName(Reindeer.PANEL_LIGHT);
    panel.setSizeFull();
    panel.addComponent(new ButtonCreateOrganization(treetable));

    final HorizontalSplitPanel horiz = new HorizontalSplitPanel();
    horiz.setSplitPosition(25); // percent
    horiz.setSizeFull();
    addComponent(horiz);
    TextField orgFilter = new TextField();
    orgFilter.setImmediate(true);
    orgFilter.setWidth(100, UNITS_PERCENTAGE);
    orgFilter.setInputPrompt("  ");
    orgFilter.addListener(new FieldEvents.TextChangeListener() {

        List<Organization> organizations;
        List<Long> organizationIds;

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            String name = StringUtils.trimToNull(event.getText());
            if (name != null) {
                lockExpandListener = true;
                organizations = AdminServiceProvider.get().findOrganizationIdsByName(name);
                treetable.removeAllItems();
                organizationIds = new ArrayList<Long>();
                for (Organization org : organizations) {
                    for (Organization o1 : getPath(org)) {
                        if (!treetable.containsId(o1.getId())) {
                            treetable.addItem(new Object[] { o1.getName() }, o1.getId());
                            if (o1.getParent() != null) {
                                treetable.setParent(o1.getId(), o1.getParent().getId());
                            }
                            treetable.setChildrenAllowed(o1.getId(), !(o1.getOrganizations().isEmpty()));
                            treetable.setCollapsed(o1.getId(), false);
                        }
                    }
                    organizationIds.add(org.getId());
                }

                treetable.setCellStyleGenerator(new Table.CellStyleGenerator() {
                    @Override
                    public String getStyle(Object itemId, Object propertyId) {
                        if (propertyId == null) {
                            if (!organizationIds.contains(itemId)) {
                                return "gray";
                            }
                        }
                        return null;
                    }
                });

            } else {
                lockExpandListener = false;
                treetable.removeAllItems();
                fillTable(treetable);
                treetable.setCellStyleGenerator(new Table.CellStyleGenerator() {
                    @Override
                    public String getStyle(Object itemId, Object propertyId) {
                        return null;
                    }
                });
            }
        }

        private List<Organization> getPath(Organization org) {
            List<Organization> list = new LinkedList<Organization>();
            while (org != null) {
                list.add(0, org);
                org = org.getParent();
            }
            return list;
        }
    });
    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);
    vl.setSizeFull();
    vl.addComponent(orgFilter);
    vl.addComponent(treetable);
    vl.setExpandRatio(treetable, 0.9f);
    horiz.addComponent(vl);
    horiz.addComponent(panel);
}