org.cloudcoder.app.client.view.ShowFullOutputButtonColumn.java Source code

Java tutorial

Introduction

Here is the source code for org.cloudcoder.app.client.view.ShowFullOutputButtonColumn.java

Source

// CloudCoder - a web-based pedagogical programming environment
// Copyright (C) 2011-2013, Jaime Spacco <jspacco@knox.edu>
// Copyright (C) 2011-2013, David H. Hovemeyer <david.hovemeyer@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.cloudcoder.app.client.view;

import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.user.cellview.client.Column;

public abstract class ShowFullOutputButtonColumn<T> extends Column<T, String> {
    public ShowFullOutputButtonColumn() {
        super(new ButtonCell());

        // Set a FieldUpdater to handle the button click
        setFieldUpdater(new FieldUpdater<T, String>() {
            @Override
            public void update(int index, T object, String value) {
                // Show the TestResultOutputDialog.
                TestResultOutputDialog dialog = new TestResultOutputDialog(getText(object));
                dialog.center();
            }
        });
    }

    protected abstract String getText(T object);

    @Override
    public String getValue(T object) {
        return "Show all";
    }
}