org.geomajas.quickstart.mobile.client.view.cellist.FeatureInfoList.java Source code

Java tutorial

Introduction

Here is the source code for org.geomajas.quickstart.mobile.client.view.cellist.FeatureInfoList.java

Source

/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2015 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
/*
 * Copyright 2010 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package org.geomajas.quickstart.mobile.client.view.cellist;

import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.googlecode.mgwt.ui.client.widget.MCheckBox;
import com.googlecode.mgwt.ui.client.widget.celllist.Cell;

/**
 * @author Dosi Bingov
 * @param <T>
 */
public abstract class FeatureInfoList<T> implements Cell<T> {

    private static Template template = GWT.create(Template.class);

    private String styleName;

    public FeatureInfoList() {
        styleName = "";
    }

    /**
     * TODO.
     *
     * @author Dosi Bingov
     */
    public interface Template extends SafeHtmlTemplates {
        @Template("<div>{0}</div>")
        SafeHtml content(String recordString);
    }

    @Override
    public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) {
        final MCheckBox mCheckBox1 = new MCheckBox();
        // mCheckBox1.setText("again");
        mCheckBox1.setImportant(true);
        safeHtmlBuilder.append(template.content(getDisplayString(model)));
    }

    public abstract String getDisplayString(T model);

    public abstract boolean isLayerVisible(T model);

    @Override
    public boolean canBeSelected(T model) {
        return false;
    }

    public void setStylename(String name) {
        if (name == null) {
            name = "";
        }
        styleName = name;
    }

}