|
@@ -18,8 +18,7 @@ |
18 |
18 |
|
import com.google.gwt.user.client.ui.*; |
19 |
19 |
|
|
20 |
20 |
|
public class MergeStoriesStepThree extends ScreenView implements ClickHandler, |
21 |
|
- |
TwoViewObjectInfoHelperScreenView |
22 |
|
- |
{ |
|
21 |
+ |
TwoViewObjectInfoHelperScreenView { |
23 |
22 |
|
private StoryViewDataProvider mDataProvider = StoryViewDataProvider.getInstance(); |
24 |
23 |
|
|
25 |
24 |
|
private UriFragmentIdParams mEncodedURLs = null; |
|
@@ -30,17 +29,14 @@ |
30 |
29 |
|
private ButtonBase mMergeButton; |
31 |
30 |
|
|
32 |
31 |
|
@Override |
33 |
|
- |
public UriFragmentIdParams createRefreshParams() |
34 |
|
- |
{ |
|
32 |
+ |
public UriFragmentIdParams createRefreshParams() { |
35 |
33 |
|
return mEncodedURLs; |
36 |
34 |
|
} |
37 |
35 |
|
|
38 |
|
- |
public MergeStoriesStepThree( String pSection, ViewDef pViewDef, TwoStoryURLs pTwoStoryURLs ) |
39 |
|
- |
{ |
|
36 |
+ |
public MergeStoriesStepThree( String pSection, ViewDef pViewDef, TwoStoryURLs pTwoStoryURLs ) { |
40 |
37 |
|
super( title( pSection, pViewDef ) ); |
41 |
38 |
|
|
42 |
|
- |
if ( pTwoStoryURLs != null ) |
43 |
|
- |
{ |
|
39 |
+ |
if ( pTwoStoryURLs != null ) { |
44 |
40 |
|
mEncodedURLs = MergeStoriesStepThreeFactory.encodeParams( pTwoStoryURLs ); |
45 |
41 |
|
mFromHelper.initialize( pTwoStoryURLs.getStory0(), mIntoHelper ); |
46 |
42 |
|
mIntoHelper.initialize( pTwoStoryURLs.getStory1(), mFromHelper ); |
|
@@ -64,36 +60,29 @@ |
64 |
60 |
|
} |
65 |
61 |
|
|
66 |
62 |
|
@Override |
67 |
|
- |
public void aboutToShow() |
68 |
|
- |
{ |
|
63 |
+ |
public void aboutToShow() { |
69 |
64 |
|
super.aboutToShow(); |
70 |
|
- |
if ( mFromHelper.requestViewObject() ) |
71 |
|
- |
{ |
|
65 |
+ |
if ( mFromHelper.requestViewObject() ) { |
72 |
66 |
|
mIntoHelper.requestViewObject(); |
73 |
67 |
|
} |
74 |
68 |
|
} |
75 |
69 |
|
|
76 |
70 |
|
@Override |
77 |
|
- |
public Widget getBottomBar() |
78 |
|
- |
{ |
|
71 |
+ |
public Widget getBottomBar() { |
79 |
72 |
|
RightHorizontalPanel zActionPanel = new RightHorizontalPanel(); |
80 |
73 |
|
zActionPanel.add( mMergeButton = Button.named( "Merge" ).green().text().add( this ).disabled().create() ); |
81 |
74 |
|
return zActionPanel; |
82 |
75 |
|
} |
83 |
76 |
|
|
84 |
77 |
|
@Override |
85 |
|
- |
public void formsReady() |
86 |
|
- |
{ |
|
78 |
+ |
public void formsReady() { |
87 |
79 |
|
String zNoMatch = "No match"; |
88 |
|
- |
for ( String zName : mFromHelper.getNamedComponentNames() ) |
89 |
|
- |
{ |
|
80 |
+ |
for ( String zName : mFromHelper.getNamedComponentNames() ) { |
90 |
81 |
|
IFormComponent z0Component = mFromHelper.getNamedComponent( zName ); |
91 |
82 |
|
IFormComponent z1Component = mIntoHelper.getNamedComponent( zName ); |
92 |
|
- |
if ( (z0Component != null) && (z1Component != null) ) |
93 |
|
- |
{ |
|
83 |
+ |
if ( (z0Component != null) && (z1Component != null) ) { |
94 |
84 |
|
if ( !Objects.areNonArraysEqual( z0Component.getCurrentValue(), // |
95 |
|
- |
z1Component.getCurrentValue() ) ) |
96 |
|
- |
{ |
|
85 |
+ |
z1Component.getCurrentValue() ) ) { |
97 |
86 |
|
z0Component.setError( zNoMatch ); |
98 |
87 |
|
z1Component.setError( zNoMatch ); |
99 |
88 |
|
} |
|
@@ -108,18 +97,13 @@ |
108 |
97 |
|
StoryView zMergeFromStoryView = mFromHelper.getFormBinder().getObject(); |
109 |
98 |
|
StoryView zMergeIntoSiteStoryView = mIntoHelper.getFormBinder().getObject(); |
110 |
99 |
|
|
111 |
|
- |
mDataProvider.mergeStory( zMergeFromStoryView, zMergeIntoSiteStoryView, new SimpleDataProviderCallBack() |
112 |
|
- |
{ |
|
100 |
+ |
mDataProvider.mergeStory( zMergeFromStoryView, zMergeIntoSiteStoryView, new SimpleDataProviderCallBack() { |
113 |
101 |
|
@Override |
114 |
|
- |
public void error( String pError ) |
115 |
|
- |
{ |
116 |
|
- |
if ( Strings.isNotNullOrEmpty( pError ) ) |
117 |
|
- |
{ |
|
102 |
+ |
public void error( String pError ) { |
|
103 |
+ |
if ( Strings.isNotNullOrEmpty( pError ) ) { |
118 |
104 |
|
// Server Failure |
119 |
105 |
|
AlertManager.alert( this.getClass().getName(), "Merge Story", pError ); |
120 |
|
- |
} |
121 |
|
- |
else |
122 |
|
- |
{ |
|
106 |
+ |
} else { |
123 |
107 |
|
// Server Success |
124 |
108 |
|
backToHome( "Story's Merged" ); |
125 |
109 |
|
} |
|
@@ -127,34 +111,28 @@ |
127 |
111 |
|
} ); |
128 |
112 |
|
} |
129 |
113 |
|
|
130 |
|
- |
private static class Helper extends TwoViewObjectInfoHelper<StoryView> implements StoryFindable |
131 |
|
- |
{ |
132 |
|
- |
public Helper( MergeStoriesStepThree pScreenView, ViewDef pViewDef ) |
133 |
|
- |
{ |
|
114 |
+ |
private static class Helper extends TwoViewObjectInfoHelper<StoryView> implements StoryFindable { |
|
115 |
+ |
public Helper( MergeStoriesStepThree pScreenView, ViewDef pViewDef ) { |
134 |
116 |
|
super( pScreenView, pViewDef ); |
135 |
117 |
|
} |
136 |
118 |
|
|
137 |
119 |
|
@Override |
138 |
|
- |
protected FormBinder<StoryView> createFormBinder( FormEngine pFE ) |
139 |
|
- |
{ |
|
120 |
+ |
protected FormBinder<StoryView> createFormBinder( FormEngine pFE ) { |
140 |
121 |
|
return new FormBinder<StoryView>( pFE, StoryViewMetaData.getInstance() ); |
141 |
122 |
|
} |
142 |
123 |
|
|
143 |
124 |
|
@Override |
144 |
|
- |
public Widget createInfoPanel() |
145 |
|
- |
{ |
|
125 |
+ |
public Widget createInfoPanel() { |
146 |
126 |
|
return new StoryInfoPanel( getFormBinder() ); |
147 |
127 |
|
} |
148 |
128 |
|
|
149 |
129 |
|
@Override |
150 |
|
- |
public boolean requestViewObject() |
151 |
|
- |
{ |
|
130 |
+ |
public boolean requestViewObject() { |
152 |
131 |
|
return StoryScreenViewHelper.requestRequiredStory( this, getViewObjectURL(), null ); |
153 |
132 |
|
} |
154 |
133 |
|
|
155 |
134 |
|
@Override |
156 |
|
- |
public void foundStory( StoryView pStoryView, Integer pRequestID ) |
157 |
|
- |
{ |
|
135 |
+ |
public void foundStory( StoryView pStoryView, Integer pRequestID ) { |
158 |
136 |
|
setExistingObject( pStoryView, FormEngine.Mode.ViewRegular ); |
159 |
137 |
|
} |
160 |
138 |
|
} |