Example usage for com.vaadin.ui ComponentContainer addComponent

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

Introduction

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

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:ro.zg.netcell.vaadin.action.user.UpdateUserHandler.java

License:Apache License

private void showSuccessMessage(final OpenGroupsApplication app, final ComponentContainer container,
        final UserAction ua, final ActionContext ac) {
    container.removeAllComponents();/*from   w  ww  .j av a2  s .  c om*/
    Label msg = new Label(getMessage("user.data.succesfully.updated"));
    Button button = new Button(getMessage("new.user.data.update"));

    button.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            ua.executeHandler(null, app, container, ac);
        }
    });

    container.addComponent(msg);
    container.addComponent(button);
}

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.  ja v a2  s. co m

    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:ru.codeinside.gses.webui.declarant.DeclarantFactory.java

License:Mozilla Public License

static Component createStartEventForm(final long procedureId, final ProcedureSelectListener listener,
        VerticalLayout layout) {/*from   www. j a  va2s  . c o  m*/
    final ProcedureProcessDefinition def = Flash.flash().getDeclarantService().selectActive(procedureId);
    if (def == null) {
        layout.getWindow().showNotification("  ");
        return null;
    }
    final String processDefinitionId = def.getProcessDefinitionId();
    String login = Flash.flash().getLogin();
    List<IdentityLink> identityLinksForProcessDefinition = Flash.flash().getProcessEngine()
            .getRepositoryService().getIdentityLinksForProcessDefinition(processDefinitionId);
    boolean ok = identityLinksForProcessDefinition.isEmpty();
    for (IdentityLink identityLink : identityLinksForProcessDefinition) {
        if (identityLink.getGroupId() != null) {
            if (Flash.flash().getAdminService().getUserItem(login).getGroups()
                    .contains(identityLink.getGroupId())) {
                ok = true;
                break;
            }
        }
        if (identityLink.getUserId() != null && identityLink.getUserId().equals(login)) {
            ok = true;
            break;
        }
    }
    if (!ok) {
        layout.getWindow().showNotification(" ? ? ");
        return null;
    }

    DataAccumulator accumulator = new DataAccumulator();
    ExecutorService executorService = Flash.flash().getExecutorService();
    final FormDescription formDescription = Functions.withEngine(new FormDescriptionBuilder(
            FormID.byProcessDefinitionId(processDefinitionId), executorService, accumulator));
    if (formDescription == null) {
        layout.getWindow().showNotification("  ");
        return null;
    }
    return new TaskForm(formDescription, new TaskForm.CloseListener() {
        @Override
        public void onFormClose(final TaskForm form) {
            final ComponentContainer container = (ComponentContainer) form.getParent();
            container.removeComponent(form);
            final HorizontalLayout layout = new HorizontalLayout();
            layout.setSizeFull();
            final Button next = new Button("C? ?...", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    listener.selectProcedure(procedureId);
                }
            });
            layout.addComponent(next);
            layout.setComponentAlignment(next, Alignment.BOTTOM_RIGHT);
            container.addComponent(layout);
        }
    }, accumulator);
}

From source file:ru.codeinside.gses.webui.form.TaskForm.java

License:Mozilla Public License

private void addLabel(ComponentContainer container, String text, String style) {
    text = StringUtils.trimToNull(text);
    if (text != null) {
        Label label = new Label(text);
        if (style != null) {
            label.setStyleName(style);/*from   w  w  w .  j  a  va2s . c  om*/
        }
        container.addComponent(label);
    }
}