1
/*
2
 * Copyright (C) 2011 Openismus GmbH
3
 *
4
 * This file is part of GWT-Glom.
5
 *
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.
10
 *
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
14
 * for more details.
15
 *
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/>.
18
 */
19
20
package org.glom.web.client.ui;
21
22
import org.glom.web.client.place.ListPlace;
23
24
import com.google.gwt.core.client.GWT;
25
import com.google.gwt.event.dom.client.ClickEvent;
26
import com.google.gwt.event.dom.client.ClickHandler;
27
import com.google.gwt.uibinder.client.UiBinder;
28
import com.google.gwt.uibinder.client.UiField;
29
import com.google.gwt.user.client.ui.Anchor;
30
import com.google.gwt.user.client.ui.Composite;
31
import com.google.gwt.user.client.ui.HTMLPanel;
32
import com.google.gwt.user.client.ui.Label;
33
import com.google.gwt.user.client.ui.VerticalPanel;
34
import com.google.gwt.user.client.ui.Widget;
35
36
public class DocumentSelectionViewImpl extends Composite implements DocumentSelectionView {
37
38
	interface DocumentSelectionViewImplUiBinder extends UiBinder<Widget, DocumentSelectionViewImpl> {
39
	}
40
41
	private static DocumentSelectionViewImplUiBinder uiBinder = GWT.create(DocumentSelectionViewImplUiBinder.class);
42
	@UiField
43
	VerticalPanel documentLinks;
44
	@UiField
45
	HTMLPanel documentSelectionPanel;
46
	private Presenter presenter;
47
48
	public DocumentSelectionViewImpl() {
49
		initWidget(uiBinder.createAndBindUi(this));
50
		documentSelectionPanel.getElement().setId("documentSelectionPanel");
51
		documentLinks.addStyleName("documentLinkTable");
52
	}
53
54
	@Override
55
	public void addDocumentLink(final String documentID, final String title) {
56
		final Anchor link = new Anchor(title);
57
		link.setStyleName("documentLink");
58
		link.addClickHandler(new ClickHandler() {
59
			@Override
60
			public void onClick(final ClickEvent event) {
61
				presenter.goTo(new ListPlace(documentID, "", ""));
62
			}
63
		});
64
		documentLinks.add(link);
65
	}
66
67
	@Override
68
	public void clearHyperLinks() {
69
		documentLinks.clear();
70
	}
71
72
	/*
73
	 * (non-Javadoc)
74
	 * 
75
	 * @see org.glom.web.client.ui.DocumentSelectionView#setErrorMessage(java.lang.String)
76
	 */
77
	@Override
78
	public void setErrorMessage(final String message) {
79
		clearHyperLinks();
80
		final Label label = new Label(message);
81
		label.getElement().getStyle().setColor("Red");
82
		documentLinks.add(label);
83
	}
84
85
	@Override
86
	public void setPresenter(final Presenter presenter) {
87
		this.presenter = presenter;
88
	}
89
90
	@Override
91
	public void clear() {
92
	}
93
}