All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.as.console.client.shared.subsys.infinispan.CacheContainerView Maven / Gradle / Ivy

Go to download

Bundles the core AS7 console as a GWT module. Includes minor customizations to support extensions.

There is a newer version: 0.7.0.Final
Show newest version
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @author tags. All rights reserved.
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License, v. 2.1.
 * This program is distributed in the hope that it will be useful, but WITHOUT A
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License,
 * v.2.1 along with this distribution; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301, USA.
 */

package org.jboss.as.console.client.shared.subsys.infinispan;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.shared.dispatch.DispatchAsync;
import org.jboss.as.console.client.shared.subsys.infinispan.model.CacheContainer;
import org.jboss.as.console.client.shared.viewframework.AbstractEntityView;
import org.jboss.as.console.client.shared.viewframework.Columns.NameColumn;
import org.jboss.as.console.client.shared.viewframework.EntityToDmrBridge;
import org.jboss.as.console.client.shared.viewframework.EntityToDmrBridgeImpl;
import org.jboss.as.console.client.shared.viewframework.FrameworkPresenter;
import org.jboss.as.console.client.shared.viewframework.SingleEntityView;
import org.jboss.as.console.client.widgets.forms.ApplicationMetaData;
import org.jboss.as.console.client.widgets.forms.FormMetaData;
import org.jboss.ballroom.client.widgets.forms.Form;
import org.jboss.ballroom.client.widgets.forms.FormAdapter;
import org.jboss.ballroom.client.widgets.tables.DefaultCellTable;
import org.jboss.ballroom.client.widgets.tools.ToolButton;
import org.jboss.ballroom.client.widgets.tools.ToolStrip;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;

/**
 * Main view class for Infinispan Cache Containers.
 * 
 * @author Stan Silvert
 */
public class CacheContainerView extends AbstractEntityView implements CacheContainerPresenter.MyView {

    private EntityToDmrBridge bridge;
    private DefaultCacheContainerWindow defaultCacheContainerWindow;
    
    private EmbeddedAliasesView aliasesView;
    
    @Inject
    public CacheContainerView(ApplicationMetaData propertyMetaData, DispatchAsync dispatcher) {
        super(CacheContainer.class, propertyMetaData);
        bridge = new EntityToDmrBridgeImpl(propertyMetaData, CacheContainer.class, this, dispatcher);
        defaultCacheContainerWindow = new DefaultCacheContainerWindow(propertyMetaData, dispatcher);
    }
    
    @Override
    public EntityToDmrBridge getEntityBridge() {
        return bridge;
    }

    @Override
    protected String getEntityDisplayName() {
        return Console.CONSTANTS.subsys_infinispan_cache_containers();
    }

    @Override
    protected ToolStrip createToolStrip() {
        ToolStrip toolStrip = super.createToolStrip();
        
        toolStrip.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_setDefault(),
                    new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                           defaultCacheContainerWindow.setChoices(bridge.getEntityList());
                           defaultCacheContainerWindow.show();
                        }
                    }));
        return toolStrip;
    }
    
    @Override
    protected FormAdapter makeAddEntityForm() {
        Form form = new Form(CacheContainer.class);
        form.setNumColumns(1);
        form.setFields(getFormMetaData().findAttribute("name").getFormItemForAdd());
                      // getFormMetaData().findAttribute("defaultCache").getFormItemForAdd());
        return form;
    }

    @Override
    protected DefaultCellTable makeEntityTable() {
        DefaultCellTable table = new DefaultCellTable(4);
        
        table.addColumn(new NameColumn(), NameColumn.LABEL);
        
        TextColumn defaultCacheColumn = new TextColumn() {
            @Override
            public String getValue(CacheContainer record) {
                return record.getDefaultCache();
            }
        };
        
        table.addColumn(defaultCacheColumn, Console.CONSTANTS.subsys_infinispan_default_cache());
        
        return table;
    }
    
    @Override
    protected List> provideAdditionalTabs(
            Class beanType,
            FormMetaData formMetaData,
            FrameworkPresenter presenter) {

        List> additionalTabs =
                new ArrayList>();

        this.aliasesView = new EmbeddedAliasesView(new FrameworkPresenter() {
            @Override
            public EntityToDmrBridge getEntityBridge() {
                return CacheContainerView.this.getEntityBridge();
            }
        });
        additionalTabs.add(aliasesView);

        return additionalTabs;
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy