Daniel Erez has uploaded a new change for review.

Change subject: webadmin: snapshot custom preview - excluded disks warning
......................................................................

webadmin: snapshot custom preview - excluded disks warning

Snapshot custom preview dialog:
Display warning when excluding disks from the snapshot
(in order to emphasize that these disks will be removed).

Change-Id: I1fd866d6553d73233f0bb590d47c370d11ddd8f5
Bug-Url: https://bugzilla.redhat.com/1111983
Bug-Url: https://bugzilla.redhat.com/1111984
Signed-off-by: Daniel Erez <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PreviewSnapshotModel.java
4 files changed, 57 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/32272/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 9c507e5..f1c7edf 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -1793,6 +1793,9 @@
     @DefaultStringValue("Previewing memory may cause data loss when excluding 
disks!")
     String snapshotPreviewWithMemoryAndPartialDisksWarning();
 
+    @DefaultStringValue("Excluded disks will be deleted when the snapshot is 
committed.")
+    String snapshotPreviewWithExcludedDisksWarning();
+
     @DefaultStringValue("Import as Template")
     String importAsTemplate();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.java
index 1b309b8..3a5e61c 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.java
@@ -14,6 +14,7 @@
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.cellview.client.Column;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SimplePanel;
@@ -78,7 +79,7 @@
     SimplePanel snapshotInfoContainer;
 
     @UiField
-    SimplePanel warningPanel;
+    FlowPanel warningPanel;
 
     private PreviewSnapshotModel previewSnapshotModel;
     private VmSnapshotInfoPanel vmSnapshotInfoPanel;
@@ -153,7 +154,7 @@
             public void update(int index, SnapshotModel snapshotModel, Boolean 
value) {
                 previewSnapshotModel.setSnapshotModel(snapshotModel);
                 previewSnapshotModel.clearMemorySelection();
-                updateMemoryWarning();
+                updateWarnings();
                 refreshTable(previewTable);
 
                 if (snapshotModel.getVm() == null) {
@@ -177,7 +178,7 @@
             public void update(int index, SnapshotModel snapshotModel, Boolean 
value) {
                 
previewSnapshotModel.getSnapshotModel().getMemory().setEntity(value);
                 refreshTable(previewTable);
-                updateMemoryWarning();
+                updateWarnings();
             }
         }) {
             @Override
@@ -216,7 +217,7 @@
 
                     diskListModel.setSelectedItem(Boolean.TRUE.equals(value) ? 
image : null);
                     refreshTable(previewTable);
-                    updateMemoryWarning();
+                    updateWarnings();
                     updateInfoPanel();
                 }
             }) {
@@ -266,7 +267,7 @@
                         SnapshotModel selectedSnapshotModel = (SnapshotModel) 
event.getValue();
                         previewSnapshotModel.clearSelection();
                         
previewSnapshotModel.selectSnapshot(selectedSnapshotModel.getEntity().getId());
-                        updateMemoryWarning();
+                        updateWarnings();
                         refreshTable(previewTable);
                     }
                     lastClick = System.currentTimeMillis();
@@ -280,20 +281,53 @@
         table.redraw();
     }
 
-    private void updateMemoryWarning() {
-        List<DiskImage> allSnapshotsDisks = 
previewSnapshotModel.getSnapshotModel().getEntity().getDiskImages();
+    private void updateWarnings() {
         List<DiskImage> selectedDisks = 
previewSnapshotModel.getSelectedDisks();
+        List<DiskImage> disksOfSelectedSnapshot = 
previewSnapshotModel.getSnapshotModel().getEntity().getDiskImages();
+        List<DiskImage> disksOfActiveSnapshot = 
previewSnapshotModel.getActiveSnapshotModel().getEntity().getDiskImages();
 
-        boolean partialDisksSelection = 
!selectedDisks.containsAll(allSnapshotsDisks);
-        boolean isIncludeMemory = (Boolean) 
previewSnapshotModel.getSnapshotModel().getMemory().getEntity();
+        boolean isIncludeAllDisksOfSnapshot = 
selectedDisks.containsAll(disksOfSelectedSnapshot);
+        boolean isIncludeMemory = 
previewSnapshotModel.getSnapshotModel().getMemory().getEntity();
 
         SafeHtml warningImage = 
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(
                 resources.logWarningImage()).getHTML());
-        HTML warningWidget = new HTML(templates.iconWithText(
+
+        HTML partialSnapshotWarningWidget = new HTML(templates.iconWithText(
+                warningImage, 
constants.snapshotPreviewWithExcludedDisksWarning()));
+        HTML memoryWarningWidget = new HTML(templates.iconWithText(
                 warningImage, 
constants.snapshotPreviewWithMemoryAndPartialDisksWarning()));
 
-        // Show warning in case of previewing a memory snapshot and excluding 
some disks.
-        warningPanel.setWidget(isIncludeMemory && partialDisksSelection ? 
warningWidget : null);
+        warningPanel.clear();
+
+        // Show warning in case of previewing a memory snapshot and excluding 
disks of the selected snapshot.
+        if (!isIncludeAllDisksOfSnapshot && isIncludeMemory) {
+            warningPanel.add(memoryWarningWidget);
+        }
+
+        // Show warning when excluding disks.
+        if (isDisksExcluded(disksOfActiveSnapshot, selectedDisks)) {
+            warningPanel.add(partialSnapshotWarningWidget);
+        }
+    }
+
+    // Search disks by ID (i.e. for each image, determines whether any image 
from the image-group is selected)
+    private boolean isDisksExcluded(List<DiskImage> disks, List<DiskImage> 
selectedDisks) {
+        for (DiskImage disk : disks) {
+            if (!containsDisk(disk, selectedDisks)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    // Check whether the specified disk list contains a disk by its ID 
(image-group)
+    private boolean containsDisk(DiskImage snapshotDisk, List<DiskImage> 
disks) {
+        for (DiskImage disk : disks) {
+            if (disk.getId().equals(snapshotDisk.getId())) {
+                return true;
+            }
+        }
+        return false;
     }
 
     private void updateInfoPanel() {
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.ui.xml
index a71c5b7..2f6dc0a 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmSnapshotCustomPreviewPopupWidget.ui.xml
@@ -41,6 +41,8 @@
         .warningPanel {
             color: red;
             text-align: right;
+            height: 24px;
+            overflow: auto;
         }
     </ui:style>
 
@@ -50,7 +52,7 @@
                 <g:FlowPanel addStyleNames="{style.containerPanelInner}">
                     <g:HorizontalPanel width="100%">
                         <g:Label ui:field="previewTableLabel" 
addStyleNames="{style.previewTableLabel}"/>
-                        <g:SimplePanel ui:field="warningPanel" 
addStyleNames="{style.warningPanel}"/>
+                        <g:FlowPanel ui:field="warningPanel" 
addStyleNames="{style.warningPanel}"/>
                     </g:HorizontalPanel>
                     <e:EntityModelCellTable ui:field="previewTable"/>
                 </g:FlowPanel>
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PreviewSnapshotModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PreviewSnapshotModel.java
index aad9fde..93b2e71 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PreviewSnapshotModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PreviewSnapshotModel.java
@@ -25,6 +25,7 @@
     private ListModel snapshots;
     private Map<Guid, ListModel> diskSnapshotsMap;
     private Guid vmId;
+    private Guid activeSnapshotId;
 
     public PreviewSnapshotModel() {
         setSnapshots(new ListModel());
@@ -44,7 +45,6 @@
                     ArrayList<Snapshot> snapshots = response.getReturnValue();
                     previewSnapshotModel.sortSnapshots(snapshots);
 
-                    Guid activeSnapshotId = null;
                     Guid userSelectedSnapshotId = 
previewSnapshotModel.getSnapshotModel().getEntity().getId();
 
                     for (Snapshot snapshot : snapshots) {
@@ -198,6 +198,10 @@
         return null;
     }
 
+    public SnapshotModel getActiveSnapshotModel() {
+        return getSnapshotModelById(activeSnapshotId);
+    }
+
     public void selectSnapshot(Guid id) {
         SnapshotModel snapshotModel = getSnapshotModelById(id);
 


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

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

Reply via email to