List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:ro.zg.netcell.vaadin.action.application.SetEntityPriorityHandler.java
License:Apache License
private void displayLabel(ActionContext actionContext, CssLayout container) { Entity entity = actionContext.getEntity(); EntityUserData userData = entity.getUserData(); String valueString = "-"; if (userData.getPriority() != null) { valueString = "#" + userData.getPriority(); }/*ww w.j av a 2s .com*/ String priorityCaption = getMessage("priority"); Label priorityLabel = new Label(priorityCaption + ":"); priorityLabel.setSizeUndefined(); priorityLabel.addStyleName("middle-left right-margin-5"); container.addComponent(priorityLabel); Label valueLabel = new Label(valueString); valueLabel.setSizeUndefined(); valueLabel.addStyleName("middle-left right-margin-5"); container.addComponent(valueLabel); }
From source file:ro.zg.netcell.vaadin.action.application.SetEntityPriorityHandler.java
License:Apache License
private void displayCombo(final ActionContext actionContext, CssLayout targetContainer, final ActionContext ac) { final OpenGroupsApplication app = actionContext.getApp(); long maxPriority = (Long) app.getAppConfigManager() .getApplicationConfigParam(ApplicationConfigParam.MAX_PRIORITY); final ComboBox select = new ComboBox(); select.setImmediate(true);/* www .ja v a 2 s.c o m*/ select.setWidth("55px"); for (int i = 1; i <= maxPriority; i++) { Priority p = Priority.getPriority(i); select.addItem(p); } final Entity entity = actionContext.getEntity(); final EntityUserData userData = entity.getUserData(); if (userData.getPriority() != null) { select.setValue(Priority.getPriority(userData.getPriority())); } final UserAction ua = actionContext.getUserAction(); select.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { // boolean actionAllowed = checkUserAllowedToExecuteAction(entity, app, ua); Priority selectedPriority = (Priority) event.getProperty().getValue(); Long priority = null; if (selectedPriority != null) { priority = selectedPriority.getPriority(); } Long currentPriority = userData.getPriority(); if (priority == null) { if (currentPriority == null) { return; } } else if (priority.equals(currentPriority)) { return; } Map<String, Object> params = ua.getActionParams(); params.put("entityId", entity.getId()); params.put("userId", app.getCurrentUserId()); params.put("priority", priority); params.put("isRecordCreated", userData.isEntityUserRecordCreated()); CommandResponse resp = executeAction(actionContext, params); if (resp != null) { app.refreshEntity(entity, ac); } else { select.setValue(userData.getPriority()); } } }); // HorizontalLayout container = new HorizontalLayout(); // container.setSpacing(true); Label priorityLabel = new Label(getMessage("priority") + ":"); priorityLabel.setSizeUndefined(); priorityLabel.addStyleName("middle-left right-margin-5"); select.addStyleName("middle-left right-margin-5"); targetContainer.addComponent(priorityLabel); targetContainer.addComponent(select); // container.setComponentAlignment(select, Alignment.TOP_LEFT); // targetContainer.addComponent(container); // targetContainer.setComponentAlignment(container, Alignment.MIDDLE_RIGHT); // targetContainer.addStyleName("stats-summary"); // targetContainer.addComponent(layout); }
From source file:ro.zg.netcell.vaadin.action.application.SetEntityStatusHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { // HorizontalLayout parentContainer = (HorizontalLayout) actionContext.getTargetContainer(); CssLayout localContainer = (CssLayout) actionContext.getTargetContainer(); // localContainer.setSpacing(true); // parentContainer.addComponent(localContainer); Entity entity = actionContext.getEntity(); if (entity.getContent() != null) { // parentContainer.setComponentAlignment(localContainer, Alignment.MIDDLE_RIGHT); displayCombo(actionContext, localContainer, actionContext); } else {//from w w w . j ava2 s.c o m displayLabel(actionContext, localContainer); } /* display most used status */ Label slash = new Label("/"); slash.setSizeUndefined(); slash.addStyleName("middle-left right-margin-5"); localContainer.addComponent(slash); String valueString = "-"; if (entity.getGeneralStatus() != null) { valueString = entity.getGeneralStatus(); } Label generalStatus = new Label(valueString); generalStatus.setSizeUndefined(); generalStatus.addStyleName("middle-left"); localContainer.addComponent(generalStatus); }
From source file:ro.zg.netcell.vaadin.action.application.SetEntityStatusHandler.java
License:Apache License
private void displayLabel(ActionContext actionContext, CssLayout container) { Entity entity = actionContext.getEntity(); EntityUserData userData = entity.getUserData(); String valueString = ": -"; if (userData.getStatus() != null) { valueString = ": " + userData.getStatus(); }//from ww w . ja v a2s. c om String statusCaption = getMessage("status"); Label statusLabel = new Label(statusCaption + valueString); statusLabel.setSizeUndefined(); statusLabel.addStyleName("middle-left right-margin-5"); // actionContext.getTargetContainer().addComponent(statusLabel); container.addComponent(statusLabel); }
From source file:ro.zg.netcell.vaadin.action.application.SetEntityStatusHandler.java
License:Apache License
private void displayCombo(final ActionContext actionContext, CssLayout targetContainer, final ActionContext ac) { CommandResponse response = executeAction(ActionsManager.GET_STATUSES, new HashMap<String, Object>()); GenericNameValueList list = (GenericNameValueList) response.getValue("result"); final ComboBox select = new ComboBox(); select.setImmediate(true);//from w w w . ja v a2 s . c o m select.setNewItemsAllowed(true); select.setWidth("110px"); for (int i = 0; i < list.size(); i++) { GenericNameValueContext row = (GenericNameValueContext) list.getValueForIndex(i); select.addItem(row.getValue("status")); } final Collection<?> items = new ArrayList<Object>(select.getItemIds()); final Entity entity = actionContext.getEntity(); final EntityUserData userData = entity.getUserData(); final UserAction ua = actionContext.getUserAction(); final OpenGroupsApplication app = actionContext.getApp(); if (userData.getStatus() != null) { select.setValue(userData.getStatus()); } select.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String value = ((String) select.getValue()); if (value != null) { value = value.trim(); if ("".equals(value)) { value = null; } if (value.length() > 0) { value = value.substring(0, 1).toUpperCase() + value.substring(1).toLowerCase(); } } String currentStatus = userData.getStatus(); if (value == null) { if (currentStatus == null) { return; } } else if (value.equals(currentStatus)) { return; } Map<String, Object> params = ua.getActionParams(); params.put("entityId", entity.getId()); params.put("userId", app.getCurrentUserId()); params.put("status", value); params.put("isRecordCreated", userData.isEntityUserRecordCreated()); CommandResponse resp = executeAction(actionContext, params); if (resp != null) { app.refreshEntity(entity, ac); } else { /* remove the selected value if not laready contained in the available statuses */ if (!items.contains(value)) { select.removeItem(value.toLowerCase()); } select.setValue(userData.getStatus()); } } }); // GridLayout layout = new GridLayout(1, 1); // layout.setSizeFull(); // HorizontalLayout container = new HorizontalLayout(); // container.setSpacing(true); Label statusLabel = new Label(getMessage("status") + ":"); statusLabel.setSizeUndefined(); statusLabel.addStyleName("middle-left right-margin-5"); select.addStyleName("middle-left right-margin-5"); targetContainer.addComponent(statusLabel); targetContainer.addComponent(select); // targetContainer.addComponent(container); // targetContainer.setComponentAlignment(container, Alignment.MIDDLE_RIGHT); // ComponentContainer parentContainer = actionContext.getTargetContainer(); // parentContainer.removeAllComponents(); // layout.addStyleName("stats-summary"); // parentContainer.addComponent(layout); }
From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java
License:Apache License
private ComponentContainer getLoginView(ActionContext actionContext) { OpenGroupsApplication app = actionContext.getApp(); Map<String, Map<String, String>> loginTypes = (Map<String, Map<String, String>>) app.getAppConfigManager() .getApplicationConfigParam(ApplicationConfigParam.LOGIN_TYPES); System.out.println("login types: " + loginTypes); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeFull();/*from w w w. j a va 2 s . c om*/ if (loginTypes == null || loginTypes.containsKey(LOCAL_LOGIN_TYPE)) { Component localView = getLocalLoginView(actionContext); hl.addComponent(localView); hl.setExpandRatio(localView, 2f); } if (loginTypes != null) { Map<String, String> openIdProviders = loginTypes.get(OPENID_LOGIN_TYPE); if (openIdProviders != null) { CssLayout openIdLayout = new CssLayout(); openIdLayout.setSizeFull(); openIdLayout.addStyleName("openid-login-pane"); VerticalLayout openIdContainer = new VerticalLayout(); openIdContainer.setSizeFull(); openIdContainer.setMargin(true); openIdLayout.addComponent(openIdContainer); // Label openIdLoginMessage = new Label(OpenGroupsResources.getMessage("openid.login.message")); // openIdLoginMessage.addStyleName("openid-title"); // openIdContainer.addComponent(openIdLoginMessage); // openIdContainer.setExpandRatio(openIdLoginMessage, 0.1f); for (Map.Entry<String, String> e : openIdProviders.entrySet()) { Component providerLink = getOpenidLoginComponent(actionContext, e); openIdContainer.addComponent(providerLink); openIdContainer.setComponentAlignment(providerLink, Alignment.MIDDLE_CENTER); openIdContainer.setExpandRatio(providerLink, 1f); } hl.addComponent(openIdLayout); hl.setComponentAlignment(openIdLayout, Alignment.MIDDLE_CENTER); hl.setExpandRatio(openIdLayout, 1f); } } return hl; }
From source file:ro.zg.opengroups.views.UserNotificationRulesListHeaderView.java
License:Apache License
private CssLayout addHeader(ListColumn lc, NotificationRulesList updateData) { Label header = new Label(lc.getDescription()); header.setSizeUndefined();/* w ww . j a va2 s. c om*/ CssLayout cell = new CssLayout(); cell.addStyleName(updateData.getHeaderCellStyle()); cell.setMargin(false, false, false, true); cell.addComponent(header); container.addComponent(cell); HorizontalLayout cl = (HorizontalLayout) container; cl.setComponentAlignment(cell, Alignment.MIDDLE_LEFT); cl.setExpandRatio(cell, 1.3f); return cell; }
From source file:ro.zg.opengroups.views.UserNotificationRuleView.java
License:Apache License
private CssLayout addToContainer(Component component) { CssLayout cell = new CssLayout(); cell.addStyleName("notification-rules-list-row-cell"); cell.setMargin(true);/* www. j a va2 s .c om*/ cell.addComponent(component); container.addComponent(cell); HorizontalLayout hl = (HorizontalLayout) container; hl.setComponentAlignment(cell, Alignment.MIDDLE_LEFT); hl.setExpandRatio(cell, 1f); return cell; }
From source file:ro.zg.open_groups.gui.components.CausalHierarchyContainer.java
License:Apache License
private void init() { /* start depth combo */ CssLayout startDepthContainer = new CssLayout(); startDepthContainer.setWidth("100%"); startDepthContainer.setHeight("22px"); startDepthContainer.addStyleName(OpenGroupsStyles.HIERARCHY_FILTERS_BAR); Label startDepthLabel = new Label(OpenGroupsResources.getMessage("hierarchy.start.depth")); startDepthLabel.setSizeUndefined();//www. j a va 2s . c o m startDepthLabel.addStyleName(OpenGroupsStyles.HORIZONTAL); startDepthSelect = new ComboBox(); startDepthSelect.setInvalidAllowed(false); startDepthSelect.setNullSelectionAllowed(false); startDepthSelect.setNewItemsAllowed(false); startDepthSelect.addStyleName(OpenGroupsStyles.HORIZONTAL); startDepthSelect.setWidth("55px"); startDepthSelect.setImmediate(true); startDepthContainer.addComponent(startDepthLabel); startDepthContainer.addComponent(startDepthSelect); // CssLayout hierarchyTitleBar = new CssLayout(); // hierarchyTitleBar.setWidth("100%"); // hierarchyTitleBar.addStyleName(OpenGroupsStyles.HIERARCHY_TITLE_BAR); // Label title = new Label("Ierarhie cauzal"); // title.addStyleName(OpenGroupsStyles.TITLE_LINK); // hierarchyTitleBar.addComponent(title); // addComponent(hierarchyTitleBar); addComponent(startDepthContainer); /* the tree */ hierarchyTree = new Tree(); hierarchyTree.addStyleName(OpenGroupsStyles.HIERARCHY_TREE); hierarchyTree.setMultiSelect(false); hierarchyTree.setImmediate(true); hierarchyTree.setNullSelectionAllowed(true); hierarchyTree.setSizeUndefined(); hierarchyTree.setContainerDataSource(new HierarchicalContainer()); hierarchyTree.addContainerProperty("depth", Integer.class, null); hierarchyTree.addListener(new CollapseListener() { @Override public void nodeCollapse(CollapseEvent event) { Object itemId = event.getItemId(); /* remove the subhierarchy */ removeSubhierarchy(itemId); } }); CssLayout treeContainer = new CssLayout(); treeContainer.addStyleName("hierarchy-tree-container"); treeContainer.setWidth("100%"); treeContainer.setHeight("93%"); treeContainer.addComponent(hierarchyTree); addComponent(treeContainer); // setExpandRatio(hierarchyTree, 1); }
From source file:ro.zg.open_groups.gui.OpenGroupsMainWindow.java
License:Apache License
private void createLayout() { /* add the uri utility */ uriUtility = new UriFragmentUtility(); uriUtility.setWidth("0px"); uriUtility.setHeight("0px"); mainContent = new CssLayout(); mainContent.addComponent(uriUtility); mainContent.setWidth("90%"); mainContent.setHeight("100%"); this.setContent(mainContent); uriUtility.addListener(app.getUriHandler()); addURIHandler(app.getUriHandler());/*from w w w.j a v a2s. co m*/ mainContent.setMargin(false); mainContent.addStyleName(OpenGroupsStyles.MAIN_PANE); header = new CssLayout(); // header.setWidth("100%"); header.addStyleName(OpenGroupsStyles.HEADER_BAR); mainContent.addComponent(header); userActionsContainer = new CssLayout(); CssLayout entityFrame = new CssLayout(); entityFrame.setHeight("100%"); // entityFrame.setWidth("100%"); uncomment this and you will have // problems entityFrame.addStyleName("entity-frame"); entityFrame.setMargin(true); entityContent = new CssLayout(); entityContent.addStyleName(OpenGroupsStyles.ENTITY_PANE); entityFrame.addComponent(entityContent); frameContent = new CssLayout(); frameContent.setWidth("100%"); frameContent.setHeight("90%"); frameContent.addStyleName(OpenGroupsStyles.FRAME_PANE); hierarchyContainer = new CausalHierarchyContainer(app); hierarchyContainer.addStyleName(OpenGroupsStyles.HIERARCHY_PANE); hierarchyContainer.setWidth("350px"); hierarchyContainer.setHeight("100%"); hierarchyContainer.construct(); frameContent.addComponent(hierarchyContainer); frameContent.addComponent(entityFrame); mainContent.addComponent(frameContent); }