List of usage examples for com.vaadin.ui CssLayout addStyleName
@Override public void addStyleName(String style)
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityWithHeaderActions.java
License:Apache License
private void addCausesFragment(ActionContext actionContext) { CssLayout container = (CssLayout) actionContext.getTargetContainer(); Entity entity = actionContext.getEntity(); ComboBox causesCombo = getCausesCombo(entity); if (causesCombo == null) { return;/*from w w w.j a va 2 s.c o m*/ } CssLayout causesContainer = new CssLayout(); // causesContainer.setWidth("100%"); causesContainer.addStyleName(OpenGroupsStyles.HEADER_BAR); container.addComponent(causesContainer); Button showCauseButton = getShowCauseButton(actionContext, causesCombo); updateCausesFragment(actionContext, showCauseButton); showCauseButton.addStyleName("middle-right left-margin-10"); causesContainer.addComponent(showCauseButton); // causesCombo.setWidth("90%"); causesCombo.addStyleName("middle-left"); causesContainer.addComponent(causesCombo); }
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 ww .ja va2 s.c o m 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.netcell.vaadin.action.UserActionListHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { ComponentContainer displayArea = actionContext.getTargetContainer(); displayArea.removeAllComponents();/*from www. j a v a 2 s .c om*/ UserActionList ual = (UserActionList) actionContext.getUserAction(); final OpenGroupsApplication app = actionContext.getApp(); final Entity entity = actionContext.getEntity(); final TabSheet actionsTabSheet = new TabSheet(); actionsTabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL); // actionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); actionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTIONS_TABSHEET); // final CssLayout contentArea = new CssLayout(); // contentArea.setWidth("100%"); // contentArea.setStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // displayArea.addComponent(contentArea); /* add listener */ actionsTabSheet.addListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { TabSheet tabSheet = event.getTabSheet(); AbstractComponentContainer selectedTabContent = (AbstractComponentContainer) tabSheet .getSelectedTab(); UserAction ua = (UserAction) selectedTabContent.getData(); if (entity != null) { Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue(); /* * if a desired action exists, it will be set afterwards, otherwise allow the first action from the * list to be selected by default */ if (desiredActionsQueue.size() != 0) { String nextAction = desiredActionsQueue.peek(); if (nextAction.equals(ua.getActionName())) { /* remove action from the queue */ desiredActionsQueue.remove(); } else { /* * if this action does not match with the next desired action, do nothing */ return; } } else { entity.getState().resetPageInfo(); } } if (ua instanceof UserActionList) { // selectedTabContent.removeStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setWidth("100%"); // contentArea.setMargin(false); // selectedTabContent.setMargin(false); ua.executeHandler(entity, app, selectedTabContent, false, actionContext); } else { // selectedTabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setWidth("99.5%"); // contentArea.setMargin(true); // selectedTabContent.setMargin(true); // selectedTabContent.setWidth("100%"); if (entity != null) { entity.getState().setCurrentTabAction(ua); entity.getState().setCurrentTabActionContainer(selectedTabContent); entity.getState().setCurrentActionsPath(ua.getFullActionPath()); // entity.getState().getDesiredActionTabsQueue().clear(); // entity.getState().resetPageInfoForCurrentAction(); actionContext.getWindow().setFragmentToEntity(entity); } ua.executeHandler(entity, app, selectedTabContent, false, actionContext); } } }); /* add the tabsheet to the target component */ // List<String> currentUserTypes = getCurrentUserTypes(entity, app); Map<String, ComponentContainer> actionPathContainers = new HashMap<String, ComponentContainer>(); List<UserAction> actionsList = new ArrayList<UserAction>(ual.getActions().values()); for (UserAction cua : actionsList) { /* display only the actions that the user is allowed to see */ // if (!cua.allowRead(currentUserTypes)) { if (!cua.isVisible(actionContext)) { continue; } CssLayout tabContent = new CssLayout(); if (cua instanceof UserActionList) { // tabContent.setMargin(false); // contentArea.setMargin(false); // tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // tabContent.setWidth("100%"); } else { // tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); tabContent.setMargin(true); // contentArea.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setMargin(true); } tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); actionPathContainers.put(cua.getActionName(), tabContent); tabContent.setData(cua); actionsTabSheet.addTab(tabContent, cua.getDisplayName(), null); } displayArea.addComponent(actionsTabSheet); if (entity != null) { Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue(); if (desiredActionsQueue.size() != 0) { // System.out.println("desired actions: " + // entity.getState().getDesiredActionsPath()); // System.out.println("full url: "+app.getFullUrl()); /* select the tab specified by the next desired action */ actionsTabSheet.setSelectedTab(actionPathContainers.get(desiredActionsQueue.peek())); } } }
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 w w .j av a2s. 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);/*from w ww . j a v a 2 s .co m*/ 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();//from ww w . ja v a2s . c om 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 ww .ja v a2 s. c om*/ 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); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el evento en el vertical layout derecho del splitpanel. * * @param e Recoge el evento que se quiere mostrar. */// w w w. j ava 2 s .com private void mostrarEvento(Evento e) { removeAllComponents(); //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Evento " + e.getNombre()); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO POR SI SE QUIERE EDITAR EL EVENTO TextField nombre = new TextField("Nombre"); nombre.setValue(e.getNombre()); nombre.setRequired(true); ComboBox divisa = new ComboBox("Divisa"); divisa.setNullSelectionAllowed(false); divisa.setRequired(true); divisa.addItem(""); divisa.addItem("$"); HorizontalLayout layouth = new HorizontalLayout(); HorizontalLayout layouth2 = new HorizontalLayout(); layouth.setSpacing(true); layouth2.setSpacing(true); final Button actualizar = new Button("Actualizar Evento"); final Button eliminar = new Button("Eliminar Evento"); final Button addPago = new Button("Aadir Pago"); final Button addParticipante = new Button("Aadir Participante"); layouth.addComponents(actualizar, eliminar); layouth2.addComponents(addPago, addParticipante); final Button hacerCuentas = new Button("Hacer las cuentas"); //BOTN PARA ACTUALIZAR EL EVENTO actualizar.addClickListener(clickEvent -> { try { nombre.validate(); divisa.validate(); if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) { EventoDAO.update(e.getId(), nombre.getValue(), divisa.getValue().toString()); Notification n = new Notification("Evento actualizado", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); mostrarEventos(); } else { Notification n = new Notification("Ya existe un evento con ese nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //BOTN PARA QUE SALGA UNA VENTANA EMERGENTE PARA AADIR UN GASTO AL EVENTO addPago.addClickListener(clickEvent -> { mostrarFormularioAddGasto(e); }); //BOTN PARA ELIMINAR EL EVENTO eliminar.addClickListener(clickEvent -> { EventoDAO.delete(e.getId()); removeAllComponents(); mostrarEventos(); }); //BOTN PARA AADIR PARTICIPANTES addParticipante.addClickListener(clickEvent -> { mostrarFormularioAddParticipante(e); }); //BOTN PARA HACER LAS CUENTAS hacerCuentas.addClickListener(clickEvent -> { removeAllComponents(); VerticalLayout vl = new VerticalLayout(); Table tablaResumenPlusvalia = getTablaResumenPlusvalia(e); HorizontalLayout hl1 = new HorizontalLayout(tablaResumenPlusvalia); hl1.setMargin(true); hl1.setSpacing(true); vl.addComponent(hl1); for (Participante p : ParticipanteDAO.readAllFromEvento(e.getId())) { HorizontalLayout hl = new HorizontalLayout(getTablaResumenGastosPorPersona(e, p)); hl.setMargin(true); hl.setSpacing(true); vl.addComponent(hl); } setSplitPosition(100, Sizeable.UNITS_PERCENTAGE); setFirstComponent(vl); }); //TABLA CON TODOS LOS GASTOS DEL EVENTO Table tablaGastos = getTablaGastos(e); //TABLA CON TODOS LOS PARTICIPANTES DEL EVENTO Table tablaParticipantes = getTablaParticipantes(e); //AADIMOS LOS COMPONENTES FormLayout form = new FormLayout(nombre, divisa, layouth, layouth2, hacerCuentas); VerticalLayout vl = new VerticalLayout(l, form, tablaGastos, tablaParticipantes); vl.setMargin(true); setFirstComponent(vl); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra un gasto para poder actualizarlo o eliminarlo. * * @param e Recoge el evento al que pertenece el gasto. */// w ww. ja va 2 s. c o m private void mostrarGasto(Gasto g, Evento e) { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Gasto " + g.getNombre()); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO POR SI SE QUIERE EDITAR EL GASTO TextField nombre = new TextField("Titulo"); nombre.setValue(g.getNombre()); nombre.setRequired(true); TextField precio = new TextField("Precio"); precio.setValue(g.getPrecio().toString()); precio.setRequired(true); final Button actualizar = new Button("Actualizar Gasto"); final Button eliminar = new Button("Eliminar Gasto"); //BOTN PARA ACTUALIZAR EL GASTO actualizar.addClickListener(clickEvent -> { try { nombre.validate(); precio.validate(); GastoDAO.update(g.getId(), nombre.getValue(), Double.valueOf(precio.getValue()), g.getIdEvento(), g.getIdPagador(), g.getDeudores()); Notification n = new Notification("Gasto actualizado", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); setSecondComponent(null); mostrarEvento(e); } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //BOTN PARA ELIMINAR EL GASTO eliminar.addClickListener(clickEvent -> { GastoDAO.delete(g.getId()); removeAllComponents(); mostrarEvento(e); }); //AADIMOS LOS COMPONENTES FormLayout form = new FormLayout(nombre, precio, actualizar, eliminar); VerticalLayout vl = new VerticalLayout(l, form); vl.setMargin(true); setSecondComponent(vl); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario de aadir un nuevo evento. *//* ww w .j a v a 2s . c o m*/ private void mostrarFormularioAddEvento() { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Evento"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); ComboBox divisa = new ComboBox("Divisa"); divisa.setRequired(true); divisa.addItem(""); divisa.addItem("$"); final Button add = new Button("Crear evento"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); FormLayout form = new FormLayout(nombre, divisa, add); //BOTN PARA AADIR EVENTO add.addClickListener(clickEvent -> { try { nombre.validate(); divisa.validate(); if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) { EventoDAO.create(nombre.getValue(), divisa.getValue().toString(), usuario); mostrarEventos(); } else { Notification n = new Notification("Ya existe un evento con ese nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //AADIMOS COMPONENTES form.setMargin(true); setSecondComponent(form); }