anmolbabu has uploaded a new change for review.

Change subject: webadmin : Stop Geo-Rep session
......................................................................

webadmin : Stop Geo-Rep session

Stop Geo-Rep session

Change-Id: If62cce9a18a4e84095b7183f9cbe3b08d0b5e290
Signed-off-by: Anmol Babu <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeGeoRepView.java
6 files changed, 86 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/35276/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java
index bcf0d49..f0a6254 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java
@@ -56,6 +56,8 @@
 
     geo_replication("geo_replication", HelpTagType.UNKNOWN), //$NON-NLS-1$
 
+    geo_replication_stop_confirmation("geo_replication_stop_confirmation", 
HelpTagType.WEBADMIN, "[gluster] Volumes main tab -> Geo-Replication sub-tab -> 
'Stop' dialog"), //$NON-NLS-1$ //$NON-NLS-2$
+
     cannot_add_bricks("cannot_add_bricks", HelpTagType.WEBADMIN, "[gluster] 
Volumes main tab -> Bricks sub tab (Add Bricks context), dialog shows the 
following message: 'Could not find any host in Up status in the cluster. Please 
try again later.'"), //$NON-NLS-1$ //$NON-NLS-2$
 
     change_cd("change_cd", HelpTagType.COMMON, "VMs Tab > Change CD"), 
//$NON-NLS-1$ //$NON-NLS-2$
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
index 2875d72..5a9ceb5 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
@@ -4,9 +4,13 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.ovirt.engine.core.common.action.VdcActionType;
+import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.Linq;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
@@ -15,8 +19,11 @@
 import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs;
+import org.ovirt.engine.ui.uicompat.UIConstants;
 
 public class VolumeGeoRepListModel extends SearchableListModel{
+
+    private static final UIConstants constants = 
ConstantsManager.getInstance().getConstants();
 
     private UICommand newSessionCommand;
     private UICommand removeSessionCommand;
@@ -145,7 +152,8 @@
         getNewSessionCommand().setIsAvailable(true);
         getRemoveSessionCommand().setIsAvailable(false);
         getStartSessionCommand().setIsAvailable(false);
-        getStopSessionCommand().setIsAvailable(false);
+        GlusterGeoRepSession selectedSession = (GlusterGeoRepSession) 
getSelectedItem();
+        getStopSessionCommand().setIsExecutionAllowed(selectedSession != null 
&& selectedSession.getStatus() != GeoRepSessionStatus.NOTSTARTED);
         getSessionOptionsCommand().setIsAvailable(false);
         getViewSessionDetailsCommand().setIsAvailable(false);
     }
@@ -160,14 +168,58 @@
         } else if(command.equals(getStartSessionCommand())) {
 
         } else if(command.equals(getStopSessionCommand())) {
-
+            stopGeoRepSession();
         } else if(command.equals(getSessionOptionsCommand())) {
 
         } else if(command.equals(getViewSessionDetailsCommand())) {
 
+        } else if(command.getName().equalsIgnoreCase("onStopGeoRepSession")) 
{//$NON-NLS-1$
+            onStopGeoRepSession();
+        } else if(command.getName().equals("closeWindow")) {//$NON-NLS-1$
+            closeWindow();
         }
     }
 
+    private void closeWindow() {
+        setWindow(null);
+    }
+
+    private void onStopGeoRepSession() {
+        boolean forceStart = false;
+        forceStart = 
((GlusterVolumeGeoRepActionConfirmationModel)getWindow()).getForce().getEntity();
+        closeWindow();
+        GlusterGeoRepSession selectedSession = 
(GlusterGeoRepSession)getSelectedItem();
+        GlusterVolumeGeoRepSessionParameters sessionParamters = new 
GlusterVolumeGeoRepSessionParameters(selectedSession.getMasterVolumeId(), 
selectedSession.getId());
+        sessionParamters.setForce(forceStart);
+        Frontend.getInstance().runAction(VdcActionType.StopGeoRepSession, 
sessionParamters);
+    }
+
+    private void stopGeoRepSession() {
+        GlusterGeoRepSession selectedSession = (GlusterGeoRepSession) 
getSelectedItem();
+
+        GlusterVolumeGeoRepActionConfirmationModel cModel = new 
GlusterVolumeGeoRepActionConfirmationModel();
+        cModel.setTitle(constants.geoReplicationStopConfirmationTitle());
+        cModel.setHelpTag(HelpTag.geo_replication_stop_confirmation);
+        cModel.setHashName("geo_replication_stop_confirmation");//$NON-NLS-1$
+
+        cModel.setMessage(constants.geoReplicationStopConfirmationTitle());
+        cModel.setForceLabel(constants.geoRepliStringForceStop());
+        
cModel.getMasterVolume().setEntity(selectedSession.getMasterVolumeName());
+        
cModel.getSlaveVolume().setEntity(selectedSession.getSlaveVolumeName());
+        cModel.getSlaveHost().setEntity(selectedSession.getSlaveHostName());
+
+        UICommand okCommand = new UICommand("onStopGeoRepSession", 
this);//$NON-NLS-1$
+        okCommand.setTitle(constants.ok());
+        okCommand.setIsDefault(true);
+        cModel.getCommands().add(okCommand);
+
+        UICommand cancelCommand = new UICommand("closeWindow", 
this);//$NON-NLS-1$
+        cancelCommand.setTitle(constants.cancel());
+        cancelCommand.setIsCancel(true);
+        cModel.getCommands().add(cancelCommand);
+        setWindow(cModel);
+    }
+
     private void createNewGeoRepSession() {
 
     }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index d00098d..68bb9d5 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -287,6 +287,12 @@
     @DefaultStringValue("Geo-Replication")
     String geoReplicationTitle();
 
+    @DefaultStringValue("Stop Geo Replication")
+    String geoReplicationStopConfirmationTitle();
+
+    @DefaultStringValue("Force Stop")
+    String geoRepliStringForceStop();
+
     @DefaultStringValue("Rebalance Status")
     String volumeRebalanceStatusTitle();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
index e8303b2..48c1218 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
@@ -30,6 +30,7 @@
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.AddBrickPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.BrickAdvancedDetailsPopupPresenterWidget;
+import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickStatusPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.ReplaceBrickPopupPresenterWidget;
@@ -148,11 +149,15 @@
 
     @Provides
     @Singleton
-    public SearchableDetailModelProvider<GlusterGeoRepSession, 
VolumeListModel, VolumeGeoRepListModel> getVolumeGeoRepListProvider(EventBus 
eventBus, Provider<DefaultConfirmationPopupPresenterWidget> 
defaultConfirmPopupProvider) {
+    public SearchableDetailModelProvider<GlusterGeoRepSession, 
VolumeListModel, VolumeGeoRepListModel> getVolumeGeoRepListProvider(EventBus 
eventBus, Provider<DefaultConfirmationPopupPresenterWidget> 
defaultConfirmPopupProvider, final 
Provider<GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget> 
geoRepActionConfirmationPopupProvider) {
         return new SearchableDetailTabModelProvider<GlusterGeoRepSession, 
VolumeListModel, VolumeGeoRepListModel>(eventBus, defaultConfirmPopupProvider, 
VolumeListModel.class, VolumeGeoRepListModel.class) {
             @Override
             public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> 
getModelPopup(VolumeGeoRepListModel source, UICommand lastExecutedCommand, 
Model windowModel) {
-                return null;
+                if(lastExecutedCommand == getModel().getStopSessionCommand()) {
+                    return geoRepActionConfirmationPopupProvider.get();
+                } else {
+                    return super.getConfirmModelPopup(source, 
lastExecutedCommand);
+                }
             }
         };
     }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
index 887a75c..c4725d9 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster;
 
+import java.text.ParseException;
+
 import org.ovirt.engine.ui.common.idhandler.ElementIdHandler;
 import org.ovirt.engine.ui.common.idhandler.WithElementId;
 import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView;
@@ -16,6 +18,8 @@
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.resources.client.CssResource;
+import com.google.gwt.text.shared.AbstractRenderer;
+import com.google.gwt.text.shared.Parser;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Label;
@@ -37,7 +41,7 @@
     @UiField
     WidgetStyle style;
 
-    @UiField
+    @UiField(provided = true)
     @Path("masterVolume.entity")
     @WithElementId
     StringEntityModelLabelEditor masterVolumeEditor;
@@ -89,6 +93,17 @@
 
     private void initEditors() {
         forceEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
+        masterVolumeEditor = new StringEntityModelLabelEditor(new 
AbstractRenderer<String>() {
+            @Override
+            public String render(String object) {
+                return object == null ? constants.notAvailableLabel() : object;
+            }
+        }, new Parser<String>() {
+            @Override
+            public String parse(CharSequence text) throws ParseException {
+                return text == null ? constants.notAvailableLabel() : 
text.toString();
+            }
+        });
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeGeoRepView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeGeoRepView.java
index d6c5ab5..1930175 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeGeoRepView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeGeoRepView.java
@@ -85,7 +85,7 @@
         getTable().addActionButton(new 
WebAdminButtonDefinition<GlusterGeoRepSession>(constants.stopGeoRepSession()) {
             @Override
             protected UICommand resolveCommand() {
-                return null;
+                return getDetailModel().getStopSessionCommand();
             }
         });
 


-- 
To view, visit http://gerrit.ovirt.org/35276
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If62cce9a18a4e84095b7183f9cbe3b08d0b5e290
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: anmolbabu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to