Example usage for com.vaadin.ui ComponentContainer removeAllComponents

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

Introduction

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

Prototype

public void removeAllComponents();

Source Link

Document

Removes all components from this container.

Usage

From source file:ro.zg.netcell.vaadin.action.ActionsManager.java

License:Apache License

private void showProgressIndicator(ComponentContainer container) {
    if (container == null) {
        return;/*from   www.ja  v a  2  s  . co  m*/
    }
    container.removeAllComponents();
    GridLayout lc = new GridLayout(1, 1);
    lc.setSizeFull();
    ProgressIndicator pi = new ProgressIndicator();
    pi.setIndeterminate(true);
    lc.addComponent(pi, 0, 0);
    lc.setComponentAlignment(pi, Alignment.TOP_CENTER);
    container.addComponent(lc);
}

From source file:ro.zg.netcell.vaadin.action.application.BaseListHandler.java

License:Apache License

protected void displayList(ActionContext ac, OpenGroupsApplication app, ComponentContainer targetContainer,
        EntityList list) {//ww  w. j av a  2 s  . c  om
    ComponentContainer displayArea = targetContainer;
    // Table displayArea = targetContainer;
    displayArea.removeAllComponents();
    // displayArea.removeAllItems();
    for (Entity currentEntity : list.getItemsList()) {
        // VerticalLayout entityContainer = new VerticalLayout();
        CssLayout entityContainer = new CssLayout();
        //       entityContainer.setWidth("100%");
        // entityContainer.setMargin(true);
        entityContainer.addStyleName(OpenGroupsStyles.LIST_ITEM);
        currentEntity.setEntityContainer(entityContainer);
        displayArea.addComponent(entityContainer);
        // displayArea.addItem(new Object[] {entityContainer}, null);
        getActionsManager().executeAction(ActionsManager.OPEN_SELECTED_ENTITY, currentEntity, app,
                entityContainer, false, ac);

    }
}

From source file:ro.zg.netcell.vaadin.action.application.CreateEntityHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    ComponentContainer targetContainer = actionContext.getTargetContainer();
    Entity entity = actionContext.getEntity();
    targetContainer.removeAllComponents();
    UserAction ua = actionContext.getUserAction();
    //   List<String> currentUserTypes = getCurrentUserTypes(entity, actionContext.getApp());

    //   if (!currentUserTypes.contains(ua.getUserType())) {
    if (!actionContext.isActionAllowed()) {
        /* current user is not allowed to execute this action */
        displayLoginRequired("create." + ua.getTargetEntityComplexType().toLowerCase() + ".login.required",
                targetContainer);// w  ww. j a  v  a 2  s  .  c om
        return;
    }

    ExtendedForm form = getForm(entity, actionContext.getUserAction(), actionContext.getApp(), targetContainer,
            actionContext);
    targetContainer.addComponent(form);

}

From source file:ro.zg.netcell.vaadin.action.application.CreateEntityHandler.java

License:Apache License

private void displaySuccessfulMessage(final Entity entity, final UserAction ua, final OpenGroupsApplication app,
        final ComponentContainer targetComponent, final long entityId, final ActionContext ac) {
    /* store current target component */
    // final ComponentContainer targetComponent = app.getTargetComponent();
    String entityTypeLowerCase = ua.getTargetEntityType().toLowerCase();
    String createdSuccessfullyMessage = app.getMessage(entityTypeLowerCase + ".created.successfully");
    String createNewMessage = app.getMessage("create.new." + entityTypeLowerCase);
    String openCreatedMessage = app.getMessage("open.created." + entityTypeLowerCase);

    VerticalLayout container = new VerticalLayout();
    container.setSizeFull();/* w  w  w  .  j av  a 2s  .  c o  m*/

    Label success = new Label(createdSuccessfullyMessage);
    container.addComponent(success);

    HorizontalLayout linksContainer = new HorizontalLayout();
    linksContainer.setSpacing(true);
    Button openCreated = new Button(openCreatedMessage);
    linksContainer.addComponent(openCreated);
    openCreated.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> subtypesList = app.getAppConfigManager()
                    .getSubtypesForComplexType(ua.getTargetEntityComplexType());
            if (subtypesList != null) {
                Entity entity = new Entity(entityId);
                //          getActionsManager().executeAction(ActionsManager.REFRESH_SELECTED_ENTITY, entity, app, null, false,ac);
                //          getActionsManager().executeAction(ActionsManager.OPEN_ENTITY_IN_TAB, entity, app, null, false,ac);
                app.openInActiveWindow(entity);
            }
            /* if no subtypes open the parent entity */
            else {
                Entity parentEntity = ac.getMainEntity();
                parentEntity.getState().setEntityTypeVisible(true);
                String complexEntityType = ua.getTargetEntityComplexType();
                parentEntity.getState().setDesiredActionsPath(
                        complexEntityType + Defaults.getDefaultActionForEntityType(complexEntityType));
                //          app.getTemporaryTab(parentEntity).setRefreshOn(true);
                //          getActionsManager().executeAction(ActionsManager.OPEN_ENTITY_IN_TAB, parentEntity, app, null, false,ac);
                app.openInActiveWindow(parentEntity);
            }
        }
    });

    Button createNew = new Button(createNewMessage);
    linksContainer.addComponent(createNew);
    createNew.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            /* recall the handle method on this handler */
            // app.setTargetComponent(targetComponent);
            ua.executeHandler(entity, app, targetComponent, ac);
        }
    });

    container.addComponent(linksContainer);

    targetComponent.removeAllComponents();
    targetComponent.addComponent(container);

    /* refresh hierarchy tree */
    ActionsManager.getInstance().executeAction(ActionsManager.REFRESH_CAUSAL_HIERARCHY, ac);
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

@Override
public void handle(final ActionContext actionContext) throws Exception {

    final UserAction ua = actionContext.getUserAction();
    final OpenGroupsApplication app = actionContext.getApp();

    ComponentContainer targetContainer = actionContext.getTargetContainer();
    targetContainer.removeAllComponents();
    targetContainer.addStyleName(OpenGroupsStyles.LIST_ACTIONS_CONTAINER);

    final Entity entity = actionContext.getEntity();
    /* reset filters */
    entity.resetFilters();/*from w  ww . j a  v  a2s .co m*/

    // Panel listContainer = new Panel();
    // ((VerticalLayout)listContainer.getContent()).setMargin(false);

    CssLayout refreshButtonContainer = new CssLayout();
    // refreshButtonContainer.setSizeFull();
    //   refreshButtonContainer.setWidth("100%");
    refreshButtonContainer.addStyleName(OpenGroupsStyles.LIST_REFRESH_BAR);

    // final VerticalLayout listContainer = new VerticalLayout();

    final CssLayout listAndPageControlsContainer = new CssLayout();
    //   final VerticalLayout listAndPageControlsContainer = new VerticalLayout();

    listAndPageControlsContainer.addStyleName("list-container");
    // listAndPageControlsContainer.setSizeFull();
    //   listAndPageControlsContainer.setWidth("100%");

    Button refreshButton = new Button();
    refreshButton.setDescription(getMessage("refresh.list"));
    refreshButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.REFRESH, OpenGroupsIconsSet.MEDIUM));
    refreshButton.addStyleName(BaseTheme.BUTTON_LINK + " middle-right");
    refreshButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            refreshList(entity, ua, app, listAndPageControlsContainer, actionContext);
        }
    });

    targetContainer.addComponent(refreshButtonContainer);
    Component searchFilter = getSearchFilter(entity, ua, app, actionContext);
    searchFilter.addStyleName("middle-left");
    refreshButtonContainer.addComponent(searchFilter);
    refreshButtonContainer.addComponent(refreshButton);

    ComponentContainer filtersContainer = initFilters(entity, ua, app, actionContext);
    targetContainer.addComponent(filtersContainer);

    targetContainer.addComponent(listAndPageControlsContainer);
    int itemsCount = refreshList(entity, ua, app, listAndPageControlsContainer, actionContext);
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

private int refreshList(Entity entity, UserAction ua, OpenGroupsApplication app, ComponentContainer displayArea,
        ActionContext ac) {/*ww  w  .j av a 2  s  .  c o m*/
    displayArea.removeAllComponents();
    ac.getWindow().setFragmentToEntity(entity);

    EntityList list = app.getModel().getChildrenListForEntity(entity, ua, app.getCurrentUserId());
    int listSize = list.getItemsList().size();
    if (listSize == 0) {
        displayNoItemsMessage(ua.getTargetEntityComplexType(), displayArea);
    } else {
        // final Table listContainer = new Table();
        // listContainer.setSizeFull();
        // listContainer.setPageLength(0);
        // listContainer.addStyleName("components-inside");
        // listContainer.addStyleName("list-table");
        // listContainer.addContainerProperty("", CssLayout.class, null);
        // displayArea.addComponent(listContainer);

        displayList(ac, app, displayArea, list);

        /* add page controls */
        CssLayout pageControlsContainer = new CssLayout();
        pageControlsContainer.addStyleName("middle-right top-margin-5");
        //       pageControlsContainer.setSpacing(true);
        refreshPageControls(entity, ua, app, pageControlsContainer, ac);
        displayArea.addComponent(pageControlsContainer);

    }

    /* set current target component as lastUsedContainer on selected entity */
    entity.getState().setLastUsedContainer(displayArea);

    return listSize;

}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

private void displayNoItemsMessage(String entityType, ComponentContainer container) {
    String message = OpenGroupsResources.getMessage("no.items." + entityType.toLowerCase());
    Label l = new Label(message);
    container.removeAllComponents();
    container.addComponent(l);//from   ww w  .  ja v  a2  s .c  o  m
}

From source file:ro.zg.netcell.vaadin.action.application.OpenEntityWithActionsHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {

    Entity entity = actionContext.getEntity();
    OpenGroupsApplication app = actionContext.getApp();

    ComponentContainer targetContainer = actionContext.getTargetContainer();
    targetContainer.removeAllComponents();
    //   targetContainer.setSizeFull();
    /* show the component */
    CssLayout entityContainer = new CssLayout();
    //   entityContainer.setSizeFull();
    //   entityContainer.setWidth("100%");
    //   entityContainer.addStyleName("right-margin-20");
    entityContainer.addStyleName("entity-with-header-actions");
    targetContainer.addComponent(entityContainer);
    getActionsManager().executeAction(ActionsManager.OPEN_SELECTED_ENTITY_WITH_HEADER_ACTIONS, entity, app,
            entityContainer, false, actionContext);
    if (app.hasErrors()) {
        return;// www  . j a v  a  2 s  . co  m
    }

    /* add the container for the actions to the window */
    CssLayout actionsContainer = new CssLayout();
    //   HorizontalLayout actionsContainer = new HorizontalLayout();
    //   VerticalLayout actionsContainer = new VerticalLayout();
    //   actionsContainer.setSizeFull();
    actionsContainer.addStyleName(OpenGroupsStyles.USER_ACTIONS_TAB);
    //   actionsContainer.setWidth("100%");
    //   actionsContainer.addStyleName("right-margin-20");
    targetContainer.addComponent(actionsContainer);
    displayActionsForSelectedEntity(entity, app, actionsContainer, actionContext);
}

From source file:ro.zg.netcell.vaadin.action.application.OpenEntityWithUpstreamHierarchy.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    OpenGroupsApplication app = actionContext.getApp();
    Entity selectedEntity = actionContext.getEntity();
    UserAction ua = actionContext.getUserAction();

    Map<String, Object> params = ua.getActionParams();
    params.putAll(selectedEntity.getFilterValues());
    params.put("pageNumber", 1);
    /* we need to bring all the hierarchy and display it on the same page */
    params.put("itemsOnPage", 5000);
    params.put("entityId", selectedEntity.getId());
    params.put("withContent", true);
    params.put("userId", app.getCurrentUserId());

    ComponentContainer container = actionContext.getTargetContainer();
    container.removeAllComponents();
    container.setSizeFull();//  www. j av a 2  s  .  c om
    //   VerticalLayout hierarchyContainer = new VerticalLayout();
    CssLayout hierarchyContainer = new CssLayout();
    hierarchyContainer.setSizeFull();
    container.addComponent(hierarchyContainer);

    displayHierarchyList(selectedEntity, ua, app, hierarchyContainer, params);
    //   VerticalLayout entityContainer = new VerticalLayout();
    CssLayout entityContainer = new CssLayout();
    container.addComponent(entityContainer);

    getActionsManager().executeAction(ActionsManager.OPEN_ENTITY_WITH_ACTIONS, selectedEntity, app,
            entityContainer, false, actionContext);
}

From source file:ro.zg.netcell.vaadin.action.application.OpenHierarchyForEntityHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    OpenGroupsApplication app = actionContext.getApp();
    Entity selectedEntity = actionContext.getEntity();
    UserAction ua = actionContext.getUserAction();

    //   Map<String, Object> params = ua.getActionParams();
    //   params.putAll(selectedEntity.getFilterValues());
    //   params.put("pageNumber", 1);
    //   /* we need bring all the hierarchy and display it on the same page */
    //   params.put("itemsOnPage", 5000);
    //   params.put("entityId", selectedEntity.getId());
    //   params.put("withContent", true);
    //   params.put("userId", app.getCurrentUserId());

    EntityList entityList = app.getModel().getHierarchyList(selectedEntity, ua, app.getCurrentUserId());
    //   //from   w  w w  .  j a  va 2s  .com
    ComponentContainer container = actionContext.getTargetContainer();
    container.removeAllComponents();

    //   displayHierarchyList(selectedEntity,ua, app, container,params);
    displayList(actionContext, app, container, entityList);

}