PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/sigmah/src/test/java/org/sigmah/client/page/entry/editor/mock/MockSiteForm.java

http://sigma-h.googlecode.com/
Java | 91 lines | 66 code | 18 blank | 7 comment | 2 complexity | ecdd6aeec46a0f859aa98f70e772a801 MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.client.page.entry.editor.mock;
 7
 8import com.extjs.gxt.ui.client.store.ListStore;
 9import org.sigmah.client.dispatch.AsyncMonitor;
10import org.sigmah.client.page.entry.editor.AdminFieldSetPresenter;
11import org.sigmah.client.page.entry.editor.MapPresenter;
12import org.sigmah.client.page.entry.editor.SiteFormPresenter;
13import org.sigmah.shared.dto.ActivityDTO;
14import org.sigmah.shared.dto.CountryDTO;
15import org.sigmah.shared.dto.PartnerDTO;
16import org.sigmah.shared.dto.SiteDTO;
17
18import java.util.HashMap;
19import java.util.HashSet;
20import java.util.Map;
21import java.util.Set;
22
23/**
24 * @author Alex Bertram (akbertram@gmail.com)
25 */
26public class MockSiteForm implements SiteFormPresenter.View {
27
28    public MockAdminFieldSet adminFieldSet = new MockAdminFieldSet();
29    public MockMapView mapView = new MockMapView();
30    public Map<String, Object> changes = new HashMap<String, Object>();
31    public Set<String> disabledActions = new HashSet<String>();
32    public Map<String, Object> properties = new HashMap<String, Object>();
33
34    public void init(SiteFormPresenter presenter, ActivityDTO activity, ListStore<PartnerDTO> partnerStore, ListStore<SiteDTO> assessmentStore) {
35
36    }
37
38    public void setSite(SiteDTO site) {
39        properties = site.getProperties();
40    }
41
42    @Override
43    public AdminFieldSetPresenter.View createAdminFieldSetView(ActivityDTO activity) {
44        return adminFieldSet;
45    }
46
47    @Override
48    public MapPresenter.View createMapView(CountryDTO country) {
49        return mapView;
50    }
51
52    @Override
53    public boolean validate() {
54        return false;
55    }
56
57    @Override
58    public Map<String, Object> getChanges() {
59        return changes;
60    }
61
62    public Map<String, Object> getPropertyMap() {
63        return properties;
64    }
65
66    @Override
67    public AsyncMonitor getMonitor() {
68        return null;
69    }
70
71    @Override
72    public void setActionEnabled(String actionId, boolean enabled) {
73        if (enabled) {
74            disabledActions.remove(actionId);
75        } else {
76            disabledActions.add(actionId);
77        }
78    }
79
80    public boolean isEnabled(String actionId) {
81        return !disabledActions.contains(actionId);
82    }
83
84    @Override
85    public boolean isDirty() {
86        return false;
87    }
88
89    public void hide() {
90    }
91}