|
@@ -1,139 +1,139 @@ |
1 |
|
- |
package org.litesoft.datt.client.ui.views.stories; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.GWT.client.*; |
4 |
|
- |
import org.litesoft.GWT.client.view.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
6 |
|
- |
import org.litesoft.GWT.client.widgets.Button; |
7 |
|
- |
import org.litesoft.GWT.forms.client.*; |
8 |
|
- |
import org.litesoft.GWT.forms.client.components.*; |
9 |
|
- |
import org.litesoft.bo.views.*; |
10 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
11 |
|
- |
import org.litesoft.datt.client.*; |
12 |
|
- |
import org.litesoft.datt.client.boviews.*; |
13 |
|
- |
import org.litesoft.datt.client.support.*; |
14 |
|
- |
import org.litesoft.datt.client.ui.widgets.*; |
15 |
|
- |
import org.litesoft.uispecification.*; |
16 |
|
- |
|
17 |
|
- |
import com.google.gwt.event.dom.client.*; |
18 |
|
- |
import com.google.gwt.user.client.ui.*; |
19 |
|
- |
|
20 |
|
- |
public class MergeStoriesStepThree extends ScreenView implements ClickHandler, |
21 |
|
- |
TwoViewObjectInfoHelperScreenView { |
22 |
|
- |
private StoryViewDataProvider mDataProvider = StoryViewDataProvider.getInstance(); |
23 |
|
- |
|
24 |
|
- |
private UriFragmentIdParams mEncodedURLs = null; |
25 |
|
- |
|
26 |
|
- |
private Helper mFromHelper = new Helper( this, ViewDefs.STORY_MERGE_STORIES ); |
27 |
|
- |
private Helper mIntoHelper = new Helper( this, ViewDefs.STORY_MERGE_STORIES_STEP_TWO ); |
28 |
|
- |
|
29 |
|
- |
private ButtonBase mMergeButton; |
30 |
|
- |
|
31 |
|
- |
@Override |
32 |
|
- |
public UriFragmentIdParams createRefreshParams() { |
33 |
|
- |
return mEncodedURLs; |
34 |
|
- |
} |
35 |
|
- |
|
36 |
|
- |
public MergeStoriesStepThree( String pSection, ViewDef pViewDef, TwoStoryURLs pTwoStoryURLs ) { |
37 |
|
- |
super( title( pSection, pViewDef ) ); |
38 |
|
- |
|
39 |
|
- |
if ( pTwoStoryURLs != null ) { |
40 |
|
- |
mEncodedURLs = MergeStoriesStepThreeFactory.encodeParams( pTwoStoryURLs ); |
41 |
|
- |
mFromHelper.initialize( pTwoStoryURLs.getStory0(), mIntoHelper ); |
42 |
|
- |
mIntoHelper.initialize( pTwoStoryURLs.getStory1(), mFromHelper ); |
43 |
|
- |
} |
44 |
|
- |
|
45 |
|
- |
addStandardTitleBar(); |
46 |
|
- |
|
47 |
|
- |
addLeft( BackButton.factory( "Change From" ).add( mFromHelper.createShowScreenCommand() ).create() ); |
48 |
|
- |
|
49 |
|
- |
addLeft( BackButton.factory( "Change Into" ).add( mIntoHelper.createShowScreenCommand() ).create() ); |
50 |
|
- |
|
51 |
|
- |
add( createSectionTitle( "Story to merge From" ) ); |
52 |
|
- |
|
53 |
|
- |
add( mFromHelper.createInfoPanel() ); |
54 |
|
- |
|
55 |
|
- |
add( createSectionTitle( "Story to merge Into" ) ); |
56 |
|
- |
|
57 |
|
- |
add( mIntoHelper.createInfoPanel() ); |
58 |
|
- |
|
59 |
|
- |
add( new SizeableSpacer().stretchable() ); |
60 |
|
- |
} |
61 |
|
- |
|
62 |
|
- |
@Override |
63 |
|
- |
public void aboutToShow() { |
64 |
|
- |
super.aboutToShow(); |
65 |
|
- |
if ( mFromHelper.requestViewObject() ) { |
66 |
|
- |
mIntoHelper.requestViewObject(); |
67 |
|
- |
} |
68 |
|
- |
} |
69 |
|
- |
|
70 |
|
- |
@Override |
71 |
|
- |
public Widget getBottomBar() { |
72 |
|
- |
RightHorizontalPanel zActionPanel = new RightHorizontalPanel(); |
73 |
|
- |
zActionPanel.add( mMergeButton = Button.named( "Merge" ).green().text().add( this ).disabled().create() ); |
74 |
|
- |
return zActionPanel; |
75 |
|
- |
} |
76 |
|
- |
|
77 |
|
- |
@Override |
78 |
|
- |
public void formsReady() { |
79 |
|
- |
String zNoMatch = "No match"; |
80 |
|
- |
for ( String zName : mFromHelper.getNamedComponentNames() ) { |
81 |
|
- |
IFormComponent z0Component = mFromHelper.getNamedComponent( zName ); |
82 |
|
- |
IFormComponent z1Component = mIntoHelper.getNamedComponent( zName ); |
83 |
|
- |
if ( (z0Component != null) && (z1Component != null) ) { |
84 |
|
- |
if ( !Objects.areNonArraysEqual( z0Component.getCurrentValue(), // |
85 |
|
- |
z1Component.getCurrentValue() ) ) { |
86 |
|
- |
z0Component.setError( zNoMatch ); |
87 |
|
- |
z1Component.setError( zNoMatch ); |
88 |
|
- |
} |
89 |
|
- |
} |
90 |
|
- |
} |
91 |
|
- |
mMergeButton.setEnabled( true ); |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
@Override |
95 |
|
- |
public void onClick( ClickEvent event ) // Merge Button |
96 |
|
- |
{ |
97 |
|
- |
StoryView zMergeFromStoryView = mFromHelper.getFormBinder().getObject(); |
98 |
|
- |
StoryView zMergeIntoSiteStoryView = mIntoHelper.getFormBinder().getObject(); |
99 |
|
- |
|
100 |
|
- |
mDataProvider.mergeStory( zMergeFromStoryView, zMergeIntoSiteStoryView, new SimpleDataProviderCallBack() { |
101 |
|
- |
@Override |
102 |
|
- |
public void error( String pError ) { |
103 |
|
- |
if ( Strings.isNotNullOrEmpty( pError ) ) { |
104 |
|
- |
// Server Failure |
105 |
|
- |
AlertManager.alert( this.getClass().getName(), "Merge Story", pError ); |
106 |
|
- |
} else { |
107 |
|
- |
// Server Success |
108 |
|
- |
backToHome( "Story's Merged" ); |
109 |
|
- |
} |
110 |
|
- |
} |
111 |
|
- |
} ); |
112 |
|
- |
} |
113 |
|
- |
|
114 |
|
- |
private static class Helper extends TwoViewObjectInfoHelper<StoryView> implements StoryFindable { |
115 |
|
- |
public Helper( MergeStoriesStepThree pScreenView, ViewDef pViewDef ) { |
116 |
|
- |
super( pScreenView, pViewDef ); |
117 |
|
- |
} |
118 |
|
- |
|
119 |
|
- |
@Override |
120 |
|
- |
protected FormBinder<StoryView> createFormBinder( FormEngine pFE ) { |
121 |
|
- |
return new FormBinder<StoryView>( pFE, StoryViewMetaData.getInstance() ); |
122 |
|
- |
} |
123 |
|
- |
|
124 |
|
- |
@Override |
125 |
|
- |
public Widget createInfoPanel() { |
126 |
|
- |
return new StoryInfoPanel( getFormBinder() ); |
127 |
|
- |
} |
128 |
|
- |
|
129 |
|
- |
@Override |
130 |
|
- |
public boolean requestViewObject() { |
131 |
|
- |
return StoryScreenViewHelper.requestRequiredStory( this, getViewObjectURL(), null ); |
132 |
|
- |
} |
133 |
|
- |
|
134 |
|
- |
@Override |
135 |
|
- |
public void foundStory( StoryView pStoryView, Integer pRequestID ) { |
136 |
|
- |
setExistingObject( pStoryView, FormEngine.Mode.ViewRegular ); |
137 |
|
- |
} |
138 |
|
- |
} |
139 |
|
- |
} |
|
1 |
+ |
package org.litesoft.datt.client.ui.views.stories; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.GWT.client.*; |
|
4 |
+ |
import org.litesoft.GWT.client.view.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
6 |
+ |
import org.litesoft.GWT.client.widgets.Button; |
|
7 |
+ |
import org.litesoft.GWT.forms.client.*; |
|
8 |
+ |
import org.litesoft.GWT.forms.client.components.*; |
|
9 |
+ |
import org.litesoft.bo.views.*; |
|
10 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
11 |
+ |
import org.litesoft.datt.client.*; |
|
12 |
+ |
import org.litesoft.datt.client.boviews.*; |
|
13 |
+ |
import org.litesoft.datt.client.support.*; |
|
14 |
+ |
import org.litesoft.datt.client.ui.widgets.*; |
|
15 |
+ |
import org.litesoft.uispecification.*; |
|
16 |
+ |
|
|
17 |
+ |
import com.google.gwt.event.dom.client.*; |
|
18 |
+ |
import com.google.gwt.user.client.ui.*; |
|
19 |
+ |
|
|
20 |
+ |
public class MergeStoriesStepThree extends ScreenView implements ClickHandler, |
|
21 |
+ |
TwoViewObjectInfoHelperScreenView { |
|
22 |
+ |
private StoryViewDataProvider mDataProvider = StoryViewDataProvider.getInstance(); |
|
23 |
+ |
|
|
24 |
+ |
private UriFragmentIdParams mEncodedURLs = null; |
|
25 |
+ |
|
|
26 |
+ |
private Helper mFromHelper = new Helper( this, ViewDefs.STORY_MERGE_STORIES ); |
|
27 |
+ |
private Helper mIntoHelper = new Helper( this, ViewDefs.STORY_MERGE_STORIES_STEP_TWO ); |
|
28 |
+ |
|
|
29 |
+ |
private ButtonBase mMergeButton; |
|
30 |
+ |
|
|
31 |
+ |
@Override |
|
32 |
+ |
public UriFragmentIdParams createRefreshParams() { |
|
33 |
+ |
return mEncodedURLs; |
|
34 |
+ |
} |
|
35 |
+ |
|
|
36 |
+ |
public MergeStoriesStepThree( String pSection, ViewDef pViewDef, TwoStoryURLs pTwoStoryURLs ) { |
|
37 |
+ |
super( title( pSection, pViewDef ) ); |
|
38 |
+ |
|
|
39 |
+ |
if ( pTwoStoryURLs != null ) { |
|
40 |
+ |
mEncodedURLs = MergeStoriesStepThreeFactory.encodeParams( pTwoStoryURLs ); |
|
41 |
+ |
mFromHelper.initialize( pTwoStoryURLs.getStory0(), mIntoHelper ); |
|
42 |
+ |
mIntoHelper.initialize( pTwoStoryURLs.getStory1(), mFromHelper ); |
|
43 |
+ |
} |
|
44 |
+ |
|
|
45 |
+ |
addStandardTitleBar(); |
|
46 |
+ |
|
|
47 |
+ |
addLeft( BackButton.factory( "Change From" ).add( mFromHelper.createShowScreenCommand() ).create() ); |
|
48 |
+ |
|
|
49 |
+ |
addLeft( BackButton.factory( "Change Into" ).add( mIntoHelper.createShowScreenCommand() ).create() ); |
|
50 |
+ |
|
|
51 |
+ |
add( createSectionTitle( "Story to merge From" ) ); |
|
52 |
+ |
|
|
53 |
+ |
add( mFromHelper.createInfoPanel() ); |
|
54 |
+ |
|
|
55 |
+ |
add( createSectionTitle( "Story to merge Into" ) ); |
|
56 |
+ |
|
|
57 |
+ |
add( mIntoHelper.createInfoPanel() ); |
|
58 |
+ |
|
|
59 |
+ |
add( new SizeableSpacer().stretchable() ); |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
@Override |
|
63 |
+ |
public void aboutToShow() { |
|
64 |
+ |
super.aboutToShow(); |
|
65 |
+ |
if ( mFromHelper.requestViewObject() ) { |
|
66 |
+ |
mIntoHelper.requestViewObject(); |
|
67 |
+ |
} |
|
68 |
+ |
} |
|
69 |
+ |
|
|
70 |
+ |
@Override |
|
71 |
+ |
public Widget getBottomBar() { |
|
72 |
+ |
RightHorizontalPanel zActionPanel = new RightHorizontalPanel(); |
|
73 |
+ |
zActionPanel.add( mMergeButton = Button.named( "Merge" ).green().text().add( this ).disabled().create() ); |
|
74 |
+ |
return zActionPanel; |
|
75 |
+ |
} |
|
76 |
+ |
|
|
77 |
+ |
@Override |
|
78 |
+ |
public void formsReady() { |
|
79 |
+ |
String zNoMatch = "No match"; |
|
80 |
+ |
for ( String zName : mFromHelper.getNamedComponentNames() ) { |
|
81 |
+ |
IFormComponent z0Component = mFromHelper.getNamedComponent( zName ); |
|
82 |
+ |
IFormComponent z1Component = mIntoHelper.getNamedComponent( zName ); |
|
83 |
+ |
if ( (z0Component != null) && (z1Component != null) ) { |
|
84 |
+ |
if ( !Currently.areEqual( z0Component.getCurrentValue(), // |
|
85 |
+ |
z1Component.getCurrentValue() ) ) { |
|
86 |
+ |
z0Component.setError( zNoMatch ); |
|
87 |
+ |
z1Component.setError( zNoMatch ); |
|
88 |
+ |
} |
|
89 |
+ |
} |
|
90 |
+ |
} |
|
91 |
+ |
mMergeButton.setEnabled( true ); |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
@Override |
|
95 |
+ |
public void onClick( ClickEvent event ) // Merge Button |
|
96 |
+ |
{ |
|
97 |
+ |
StoryView zMergeFromStoryView = mFromHelper.getFormBinder().getObject(); |
|
98 |
+ |
StoryView zMergeIntoSiteStoryView = mIntoHelper.getFormBinder().getObject(); |
|
99 |
+ |
|
|
100 |
+ |
mDataProvider.mergeStory( zMergeFromStoryView, zMergeIntoSiteStoryView, new SimpleDataProviderCallBack() { |
|
101 |
+ |
@Override |
|
102 |
+ |
public void error( String pError ) { |
|
103 |
+ |
if ( Currently.isNotNullOrEmpty( pError ) ) { |
|
104 |
+ |
// Server Failure |
|
105 |
+ |
AlertManager.alert( this.getClass().getName(), "Merge Story", pError ); |
|
106 |
+ |
} else { |
|
107 |
+ |
// Server Success |
|
108 |
+ |
backToHome( "Story's Merged" ); |
|
109 |
+ |
} |
|
110 |
+ |
} |
|
111 |
+ |
} ); |
|
112 |
+ |
} |
|
113 |
+ |
|
|
114 |
+ |
private static class Helper extends TwoViewObjectInfoHelper<StoryView> implements StoryFindable { |
|
115 |
+ |
public Helper( MergeStoriesStepThree pScreenView, ViewDef pViewDef ) { |
|
116 |
+ |
super( pScreenView, pViewDef ); |
|
117 |
+ |
} |
|
118 |
+ |
|
|
119 |
+ |
@Override |
|
120 |
+ |
protected FormBinder<StoryView> createFormBinder( FormEngine pFE ) { |
|
121 |
+ |
return new FormBinder<StoryView>( pFE, StoryViewMetaData.getInstance() ); |
|
122 |
+ |
} |
|
123 |
+ |
|
|
124 |
+ |
@Override |
|
125 |
+ |
public Widget createInfoPanel() { |
|
126 |
+ |
return new StoryInfoPanel( getFormBinder() ); |
|
127 |
+ |
} |
|
128 |
+ |
|
|
129 |
+ |
@Override |
|
130 |
+ |
public boolean requestViewObject() { |
|
131 |
+ |
return StoryScreenViewHelper.requestRequiredStory( this, getViewObjectURL(), null ); |
|
132 |
+ |
} |
|
133 |
+ |
|
|
134 |
+ |
@Override |
|
135 |
+ |
public void foundStory( StoryView pStoryView, Integer pRequestID ) { |
|
136 |
+ |
setExistingObject( pStoryView, FormEngine.Mode.ViewRegular ); |
|
137 |
+ |
} |
|
138 |
+ |
} |
|
139 |
+ |
} |