2 * Copyright (C) 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.client.ui;
22 import java.util.ArrayList;
24 import org.glom.web.shared.GlomField;
25 import org.glom.web.shared.layout.LayoutGroup;
27 import com.google.gwt.user.client.ui.Composite;
28 import com.google.gwt.user.client.ui.FlowPanel;
29 import com.google.gwt.user.client.ui.InlineLabel;
32 * @author Ben Konrath <ben@bagu.org>
35 public class DetailsViewImpl extends Composite implements DetailsView {
37 @SuppressWarnings("unused")
38 private Presenter presenter;
39 private final FlowPanel mainPanel = new FlowPanel();
40 private final ArrayList<InlineLabel> dataLabels = new ArrayList<InlineLabel>();
42 public DetailsViewImpl() {
43 initWidget(mainPanel);
49 * @see org.glom.web.client.ui.DetailsView#setPresenter(org.glom.web.client.ui.DetailsView.Presenter)
52 public void setPresenter(Presenter presenter) {
53 this.presenter = presenter;
59 * @see org.glom.web.client.ui.DetailsView#addLayoutGroup(org.glom.web.shared.layout.LayoutGroup)
62 public void addLayoutGroup(LayoutGroup layoutGroup) {
63 FlowTable flowTable = new FlowTable(layoutGroup);
64 dataLabels.addAll(flowTable.getDataLabels());
65 mainPanel.add(flowTable);
71 * @see org.glom.web.client.ui.DetailsView#setData(org.glom.web.shared.GlomField[])
73 public void setData(GlomField[] glomFields) {
74 if (glomFields == null) {
78 for (int i = 0; i < dataLabels.size(); i++) {
79 InlineLabel dataLabel = dataLabels.get(i);
80 dataLabel.setText(glomFields[i] == null ? "" : glomFields[i].getText());
87 * @see org.glom.web.client.ui.DetailsView#clear()