OLD | NEW |
1 package autotest.afe; | 1 package autotest.afe; |
2 | 2 |
| 3 import autotest.afe.CreateJobView.JobCreateListener; |
3 import autotest.afe.HostDetailView.HostDetailListener; | 4 import autotest.afe.HostDetailView.HostDetailListener; |
4 import autotest.afe.HostListView.HostListListener; | 5 import autotest.afe.HostListView.HostListListener; |
5 import autotest.afe.JobDetailView.JobDetailListener; | 6 import autotest.afe.JobDetailView.JobDetailListener; |
6 import autotest.afe.JobListView.JobSelectListener; | 7 import autotest.afe.JobListView.JobSelectListener; |
7 import autotest.afe.RecurringView.RecurringSelectListener; | 8 import autotest.afe.RecurringView.RecurringSelectListener; |
8 import autotest.afe.UserPreferencesView.UserPreferencesListener; | 9 import autotest.afe.UserPreferencesView.UserPreferencesListener; |
9 import autotest.afe.create.CreateJobViewPresenter.JobCreateListener; | |
10 import autotest.afe.create.CreateJobViewTab; | |
11 import autotest.common.CustomHistory; | 10 import autotest.common.CustomHistory; |
12 import autotest.common.JsonRpcProxy; | 11 import autotest.common.JsonRpcProxy; |
13 import autotest.common.SiteCommonClassFactory; | 12 import autotest.common.SiteCommonClassFactory; |
14 import autotest.common.StaticDataRepository; | 13 import autotest.common.StaticDataRepository; |
15 import autotest.common.ui.CustomTabPanel; | 14 import autotest.common.ui.CustomTabPanel; |
16 import autotest.common.ui.NotifyManager; | 15 import autotest.common.ui.NotifyManager; |
17 import autotest.common.ui.TabView; | 16 import autotest.common.ui.TabView; |
18 | 17 |
19 import com.google.gwt.core.client.EntryPoint; | 18 import com.google.gwt.core.client.EntryPoint; |
20 import com.google.gwt.json.client.JSONValue; | 19 import com.google.gwt.json.client.JSONValue; |
21 import com.google.gwt.user.client.ui.RootPanel; | 20 import com.google.gwt.user.client.ui.RootPanel; |
22 | 21 |
23 | 22 |
24 public class AfeClient implements EntryPoint { | 23 public class AfeClient implements EntryPoint { |
25 private JobListView jobList; | 24 private JobListView jobList; |
26 private JobDetailView jobDetail; | 25 private JobDetailView jobDetail; |
27 private RecurringView recurringView; | 26 private RecurringView recurringView; |
28 private CreateJobViewTab createJob; | 27 private CreateJobView createJob; |
29 private HostListView hostListView; | 28 private HostListView hostListView; |
30 private HostDetailView hostDetailView; | 29 private HostDetailView hostDetailView; |
31 private UserPreferencesView userPreferencesView; | 30 private UserPreferencesView userPreferencesView; |
32 | 31 |
33 public CustomTabPanel mainTabPanel = new CustomTabPanel(); | 32 public CustomTabPanel mainTabPanel = new CustomTabPanel(); |
34 | 33 |
35 /** | 34 /** |
36 * Application entry point. | 35 * Application entry point. |
37 */ | 36 */ |
38 public void onModuleLoad() { | 37 public void onModuleLoad() { |
39 JsonRpcProxy.setDefaultBaseUrl(JsonRpcProxy.AFE_BASE_URL); | 38 JsonRpcProxy.setDefaultBaseUrl(JsonRpcProxy.AFE_BASE_URL); |
40 NotifyManager.getInstance().initialize(); | 39 NotifyManager.getInstance().initialize(); |
41 | 40 |
42 // initialize static data, and don't show main UI until that's done | 41 // initialize static data, and don't show main UI until that's done |
43 StaticDataRepository.getRepository().refresh( | 42 StaticDataRepository.getRepository().refresh( |
44 new StaticDataRepository.FinishedCallback() { | 43 new StaticDataRepository.FinishedCallback() { |
45 public void onFinished() { | 44 public void onFinished() { |
46 finishLoading(); | 45 finishLoading(); |
47 } | 46 } |
48 }); | 47 }); |
49 } | 48 } |
50 | 49 |
51 private JobCreateListener jobCreateListener = new JobCreateListener() { | 50 private JobCreateListener jobCreateListener = new JobCreateListener() { |
52 public void onJobCreated(int jobId) { | 51 public void onJobCreated(int jobId) { |
53 showJob(jobId); | 52 showJob(jobId); |
54 } | 53 } |
55 }; | 54 }; |
56 | 55 |
57 protected void finishLoading() { | 56 protected void finishLoading() { |
58 SiteCommonClassFactory.globalInitialize(); | 57 SiteCommonClassFactory.globalInitialize(); |
59 | 58 |
60 jobList = new JobListView(new JobSelectListener() { | 59 jobList = new JobListView(new JobSelectListener() { |
61 public void onJobSelected(int jobId) { | 60 public void onJobSelected(int jobId) { |
62 showJob(jobId); | 61 showJob(jobId); |
63 } | 62 } |
64 }); | 63 }); |
65 jobDetail = new JobDetailView(new JobDetailListener() { | 64 jobDetail = new JobDetailView(new JobDetailListener() { |
66 public void onHostSelected(String hostname) { | 65 public void onHostSelected(String hostname) { |
67 showHost(hostname); | 66 showHost(hostname); |
68 } | 67 } |
69 | 68 |
70 public void onCloneJob(JSONValue cloneInfo) { | 69 public void onCloneJob(JSONValue cloneInfo) { |
71 createJob.ensureInitialized(); | 70 createJob.ensureInitialized(); |
72 createJob.cloneJob(cloneInfo); | 71 createJob.cloneJob(cloneInfo); |
73 mainTabPanel.selectTabView(createJob); | 72 mainTabPanel.selectTabView(createJob); |
74 } | 73 } |
75 | 74 |
76 public void onCreateRecurringJob(int jobId) { | 75 public void onCreateRecurringJob(int jobId) { |
77 recurringView.ensureInitialized(); | 76 recurringView.ensureInitialized(); |
78 recurringView.createRecurringJob(jobId); | 77 recurringView.createRecurringJob(jobId); |
79 mainTabPanel.selectTabView(recurringView); | 78 mainTabPanel.selectTabView(recurringView); |
80 } | 79 } |
81 }); | 80 }); |
82 | 81 |
83 recurringView = new RecurringView(new RecurringSelectListener() { | 82 recurringView = new RecurringView(new RecurringSelectListener() {
|
84 public void onRecurringSelected(int jobId) { | 83 public void onRecurringSelected(int jobId) { |
85 showJob(jobId); | 84 showJob(jobId); |
86 } | 85 } |
87 }); | 86 }); |
88 | 87 |
89 createJob = AfeUtils.factory.getCreateJobView(jobCreateListener); | 88 createJob = AfeUtils.factory.getCreateJobView(jobCreateListener); |
90 | 89 |
91 hostListView = new HostListView(new HostListListener() { | 90 hostListView = new HostListView(new HostListListener() { |
92 public void onHostSelected(String hostname) { | 91 public void onHostSelected(String hostname) { |
93 showHost(hostname); | 92 showHost(hostname); |
94 } | 93 } |
95 }, jobCreateListener); | 94 }, jobCreateListener); |
96 | 95 |
97 hostDetailView = new HostDetailView(new HostDetailListener() { | 96 hostDetailView = new HostDetailView(new HostDetailListener() { |
98 public void onJobSelected(int jobId) { | 97 public void onJobSelected(int jobId) { |
99 showJob(jobId); | 98 showJob(jobId); |
100 } | 99 } |
101 }, jobCreateListener); | 100 }, jobCreateListener); |
102 | 101 |
103 userPreferencesView = new UserPreferencesView(new UserPreferencesListene
r() { | 102 userPreferencesView = new UserPreferencesView(new UserPreferencesListene
r() { |
104 public void onPreferencesChanged() { | 103 public void onPreferencesChanged() { |
105 createJob.onPreferencesChanged(); | 104 createJob.onPreferencesChanged(); |
106 } | 105 } |
107 }); | 106 }); |
108 | 107 |
109 TabView[] tabViews = new TabView[] {jobList, jobDetail, recurringView, c
reateJob, | 108 TabView[] tabViews = new TabView[] {jobList, jobDetail, recurringView, c
reateJob, |
110 hostListView, hostDetailView, userPr
eferencesView}; | 109 hostListView, hostDetailView, userPr
eferencesView}; |
111 for (TabView tabView : tabViews) { | 110 for(int i = 0; i < tabViews.length; i++) { |
112 mainTabPanel.addTabView(tabView); | 111 mainTabPanel.addTabView(tabViews[i]); |
113 } | 112 } |
114 | 113 |
115 final RootPanel tabsRoot = RootPanel.get("tabs"); | 114 final RootPanel tabsRoot = RootPanel.get("tabs"); |
116 tabsRoot.add(mainTabPanel); | 115 tabsRoot.add(mainTabPanel); |
117 CustomHistory.processInitialToken(); | 116 CustomHistory.processInitialToken(); |
118 mainTabPanel.initialize(); | 117 mainTabPanel.initialize(); |
119 tabsRoot.setStyleName(""); | 118 tabsRoot.setStyleName(""); |
120 } | 119 } |
121 | 120 |
122 protected void showJob(int jobId) { | 121 protected void showJob(int jobId) { |
123 jobDetail.ensureInitialized(); | 122 jobDetail.ensureInitialized(); |
124 jobDetail.updateObjectId(Integer.toString(jobId)); | 123 jobDetail.updateObjectId(Integer.toString(jobId)); |
125 mainTabPanel.selectTabView(jobDetail); | 124 mainTabPanel.selectTabView(jobDetail); |
126 } | 125 } |
127 | 126 |
128 protected void showHost(String hostname) { | 127 protected void showHost(String hostname) { |
129 hostDetailView.ensureInitialized(); | 128 hostDetailView.ensureInitialized(); |
130 hostDetailView.updateObjectId(hostname); | 129 hostDetailView.updateObjectId(hostname); |
131 mainTabPanel.selectTabView(hostDetailView); | 130 mainTabPanel.selectTabView(hostDetailView); |
132 } | 131 } |
133 } | 132 } |
OLD | NEW |