List of usage examples for com.vaadin.ui ComponentContainer addComponent
public void addComponent(Component c);
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityHandler.java
License:Apache License
private void displayFooterActions(Entity entity, OpenGroupsApplication app, ComponentContainer currentContainer, ActionContext ac) {//from w ww . j a v a2 s . c o m UserActionList entityActions = getAvailableActions(entity, ActionLocations.FOOTER); UserActionList globalActions = getGlobalActions(ActionLocations.FOOTER); Collection<UserAction> allActions = getAllFooterActions(entityActions, globalActions); // if (entityActions == null || entityActions.getActions() == null || // entityActions.getActions().size() == 0) { // return; // } if (allActions.size() == 0) { return; } CssLayout actionsContainer = new CssLayout(); boolean changeRow = true; int leftCount = 0; int rightCount = 0; CssLayout leftContainer = null; CssLayout rightContainer = null; CssLayout actionContainer = null; // for (UserAction ua : entityActions.getActions().values()) { for (UserAction ua : allActions) { if (!ua.isVisible(ac)) { continue; } // HorizontalLayout actionContainer = new HorizontalLayout(); // actionContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); CssLayout cc = new CssLayout(); boolean isLeft = false; if (isLeft = "LEFT".equals(ua.getActionPath())) { } else { if (rightCount > 0) { changeRow = true; } } if (changeRow) { /* * add the left/right containers to the previous action * container */ if (actionContainer != null) { if (leftCount > 0) { actionContainer.addComponent(leftContainer); } if (rightCount > 0) { actionContainer.addComponent(rightContainer); } } actionContainer = new CssLayout(); actionContainer.addStyleName(OpenGroupsStyles.FOOTER_ACTION_PANE); actionsContainer.addComponent(actionContainer); leftContainer = new CssLayout(); leftContainer.addStyleName("middle-left"); rightContainer = new CssLayout(); rightContainer.addStyleName("middle-right"); rightCount = 0; leftCount = 0; changeRow = false; } if (isLeft) { leftCount++; leftContainer.addComponent(cc); cc.addStyleName("middle-left"); } else { rightCount++; rightContainer.addComponent(cc); } ua.executeHandler(entity, app, cc, ac); } /* add these also for the last row */ if (actionContainer != null) { if (leftCount > 0) { actionContainer.addComponent(leftContainer); } if (rightCount > 0) { actionContainer.addComponent(rightContainer); } } currentContainer.addComponent(actionsContainer); }
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityWithHeaderActions.java
License:Apache License
@Override public void handle(ActionContext actionContext) throws Exception { OpenGroupsApplication app = actionContext.getApp(); Entity entity = actionContext.getEntity(); ComponentContainer container = actionContext.getTargetContainer(); app.getModel().populateCauses(entity); getActionsManager().executeAction(ActionsManager.REFRESH_SELECTED_ENTITY, entity, app, container, false, actionContext);/*w ww .ja va 2 s. c o m*/ if (app.hasErrors()) { return; } container.removeAllComponents(); // container.setWidth("100%"); if (app.getRootEntity().getId() != entity.getId()) { /* create header containers */ createHeaderContainers(actionContext); /* add causes combo */ addCausesFragment(actionContext); } // Panel entityContainer = new Panel(); CssLayout entityContainer = new CssLayout(); entityContainer.addStyleName("entity-container"); // entityContainer.setSizeFull(); // entityContainer.setWidth("100%"); container.addComponent(entityContainer); getActionsManager().executeAction(ActionsManager.OPEN_SELECTED_ENTITY, entity, app, entityContainer, false, actionContext); }
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityWithHeaderActions.java
License:Apache License
private void createHeaderContainers(ActionContext actionContext) { Entity entity = actionContext.getEntity(); ComponentContainer container = actionContext.getTargetContainer(); /* create a special container where the cause can be shown */ ComponentContainer cc = createHeaderContainer(); entity.addHeaderActionContainer(ActionConstants.SHOW_CAUSE, cc); container.addComponent(cc); UserActionList headerActions = getAvailableActions(entity, ActionLocations.HEADER); if (headerActions != null && headerActions.getActions() != null) { // HorizontalLayout actionsContainer = new HorizontalLayout(); for (final UserAction ha : headerActions.getActions().values()) { /* create container for this action */ ComponentContainer hac = (CssLayout) entity.getHeaderActionContainer(ha.getActionName()); if (hac == null) { hac = createHeaderContainer(); entity.addHeaderActionContainer(ha.getActionName(), hac); // System.out.println("Adding header action: " + ha.getActionName()); }/*w ww . j a va 2s . c om*/ container.addComponent(hac); } } }
From source file:ro.zg.netcell.vaadin.action.application.UpdateEntityHandler.java
License:Apache License
@Override public void handle(ActionContext actionContext) throws Exception { ComponentContainer targetContainer = actionContext.getTargetContainer(); Entity entity = actionContext.getEntity(); targetContainer.removeAllComponents(); ExtendedForm form = getForm(entity, actionContext.getUserAction(), actionContext.getApp(), targetContainer, actionContext);/*from w ww. j ava 2s . c o m*/ targetContainer.addComponent(form); }
From source file:ro.zg.netcell.vaadin.action.application.UpdateEntityHandler.java
License:Apache License
private void displaySuccessfulMessage(final Entity entity, final UserAction ua, final OpenGroupsApplication app, final ComponentContainer targetComponent, final ActionContext ac) { /* store current target component */ // final ComponentContainer targetComponent = app.getTargetComponent(); targetComponent.removeAllComponents(); String entityTypeLowerCase = ua.getTargetEntityType().toLowerCase(); String createdSuccessfullyMessage = app.getMessage(entityTypeLowerCase + ".updated.successfully"); String newUpdateMessage = app.getMessage("new.update"); HorizontalLayout container = new HorizontalLayout(); container.setSizeFull();/* w w w . ja va2 s . c om*/ container.setSpacing(true); targetComponent.addComponent(container); Label success = new Label(createdSuccessfullyMessage); container.addComponent(success); Button newUpdate = new Button(newUpdateMessage); container.addComponent(newUpdate); newUpdate.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { // Entity entity = new Entity(entityId); // app.pushSelectedEntity(entity); // app.executeAction(ActionsManager.OPEN_ENTITY_IN_WINDOW); ua.executeHandler(entity, app, targetComponent, ac); } }); }
From source file:ro.zg.netcell.vaadin.action.application.UserNotificationRulesHandler.java
License:Apache License
private void refreshNotificationsView(final ActionContext actionContext) throws Exception { final NotificationRulesList rulesList = getNotificationRulesList(actionContext); final OpenGroupsApplication app = actionContext.getApp(); ComponentContainer container = actionContext.getTargetContainer(); container.removeAllComponents();//from ww w. j a v a 2 s . c o m UserEventHandler<UserEvent> eventHandler = new UserEventHandler<UserEvent>() { @Override public void handleEvent(UserEvent event) { boolean saved = app.getModel().saveUserNotificationRules(app.getCurrentUserId(), actionContext.getEntity().getId(), rulesList); if (saved) { rulesList.markAsSaved(); } else { app.pushError(OpenGroupsExceptions.getSystemError()); } } }; UserNotificationRulesView view = getViewsManager().createView(UserNotificationRulesView.class, eventHandler); rulesList.addView(view); view.update(rulesList); container.addComponent(view.getContainer()); }
From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java
License:Apache License
private void showAlreadyVotedFragment(final ComponentContainer container, final Entity selectedEntity, final OpenGroupsApplication app, final UserAction ua, final ActionContext ac) { String entityType = selectedEntity.getSimpleType().toLowerCase(); String currentUserVote = selectedEntity.getUserData().getVote(); String messageKey = entityType + ".already.voted." + currentUserVote; HorizontalLayout hl = new HorizontalLayout(); hl.addStyleName(OpenGroupsStyles.TOP_RIGHT); hl.setSpacing(true);/*from w w w.j a va 2s . co m*/ hl.addComponent(new Label(OpenGroupsResources.getMessage(messageKey))); final VoteType opposedVote = VoteType.opposteVoteForValue(currentUserVote, entityType); Button changeVoteButton = new Button(/*OpenGroupsResources.getMessage("change.vote")*/); changeVoteButton.setCaption(opposedVote.getCaption()); changeVoteButton.setIcon(opposedVote.getIcon()); changeVoteButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { // container.removeAllComponents(); // showVotesFragment(container, selectedEntity, app, ua, ac); Map<String, Object> params = ua.getActionParams(); // params.put("entityId", selectedEntity.getId()); params.put("entityLinkId", selectedEntity.getSelectedCause().getLinkId()); params.put("userId", app.getCurrentUserId()); params.put("isRecordCreated", selectedEntity.getUserData().isEntityLinkUserRecordCreated()); params.put("vote", opposedVote.getValue()); CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params); /* refresh the entity only if the user was actually able to vote */ if (response != null) { app.refreshEntity(selectedEntity, ac); } } }); hl.addComponent(changeVoteButton); Button recallVoteButton = new Button(OpenGroupsResources.getMessage("recall.vote")); recallVoteButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.CANCEL, OpenGroupsIconsSet.SMALL)); recallVoteButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { EntityLink selectedCause = selectedEntity.getSelectedCause(); Map<String, Object> params = ua.getActionParams(); params.put("entityLinkId", selectedCause.getLinkId()); params.put("userId", app.getCurrentUserId()); params.put("isRecordCreated", true); CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params); /* refresh the entity only if the user was actually able to vote */ if (response != null) { app.refreshEntity(selectedEntity, ac); } } }); hl.addComponent(recallVoteButton); container.addComponent(hl); }
From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java
License:Apache License
private void showVotesFragment(ComponentContainer container, Entity selectedEntity, final OpenGroupsApplication app, final UserAction ua, final ActionContext ac) { String entityType = selectedEntity.getSimpleType().toLowerCase(); List<VoteType> voteTypes = VoteType.valuesList(entityType); HorizontalLayout votesContainer = new HorizontalLayout(); votesContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); votesContainer.setSpacing(true);//from ww w .j a va 2 s. c o m for (VoteType vt : voteTypes) { votesContainer.addComponent(getButtonForVoteType(vt, container, selectedEntity, app, ua, ac)); } container.addComponent(votesContainer); }
From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java
License:Apache License
private void addFooterActions(final ComponentContainer container, final OpenGroupsApplication app, final ActionContext ac) { UserActionList actionsList = ActionsManager.getInstance().getGlobalActions(ActionLocations.LOGIN_FOOTER); if (actionsList != null && actionsList.getActions() != null) { final Window window = ac.getWindow(); for (final UserAction ua : actionsList.getActions().values()) { Button link = new Button(ua.getDisplayName()); link.addStyleName(BaseTheme.BUTTON_LINK); container.addComponent(link); link.addListener(new ClickListener() { @Override/*from w ww .j a va 2s.com*/ public void buttonClick(ClickEvent event) { window.removeWindow(container.getWindow()); ua.executeHandler(null, app, null, ac); } }); } } }
From source file:ro.zg.netcell.vaadin.action.user.UpdateUserHandler.java
License:Apache License
@Override public void handle(ActionContext actionContext) throws Exception { ComponentContainer targetContainer = actionContext.getTargetContainer(); targetContainer.removeAllComponents(); Form form = getUpdateForm(actionContext.getUserAction(), actionContext.getApp(), actionContext.getTargetContainer(), actionContext); targetContainer.addComponent(form); }