option: add suspend support option (experimental)
authorMinkee Lee <minkee.lee@samsung.com>
Tue, 2 Feb 2016 04:21:35 +0000 (13:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 11 Feb 2016 06:45:27 +0000 (15:45 +0900)
Change-Id: I4a07007647d531250149f2fd17c10194f17d147c
Signed-off-by: Minkee Lee <minkee.lee@samsung.com>
src/org/tizen/emulator/manager/ui/renewal/item/CommonItemListFactory.java
src/org/tizen/emulator/manager/ui/renewal/item/CommonOptionFactory.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/OnOffItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SuspendSupportItem.java [new file with mode: 0644]

index 8465842..6e45977 100644 (file)
@@ -70,6 +70,7 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItemForWin;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetworkItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.OCIDeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.SuspendSupportItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerCountryItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerSystemItem;
@@ -280,6 +281,9 @@ public class CommonItemListFactory implements IItemListFactory{
                        itemList.add(new ViewerTypeItem(name, item.getTitle(),
                                        VMTemplateUtil.getOptionList(item.getOptions()),
                                        VMTemplateUtil.getCreateDefault(item.getOptions())));
+
+               } else if (name.equals(ItemName.SUSPEND_SUPPORT)) {
+                       itemList.add(new SuspendSupportItem(item.getTitle()));
                }
 
        }
index f0b8b00..d893c1d 100644 (file)
@@ -110,7 +110,7 @@ public class CommonOptionFactory implements IOptionFactory {
                } else if (name.equals(ItemName.RAM_SIZE)) {
                        optionList.add(Option.getInstance(RamSizeOption.class));;
 
-               } else if (name.equals(ItemName.SUSPEND_SUPPORT)) { // TODO
+               } else if (name.equals(ItemName.SUSPEND_SUPPORT)) {
                        optionList.add(Option.getInstance(SuspendSupportOption.class));
 
                } else if (name.equals(ItemName.FILE_SHARE)) {
index 5804d73..45e169e 100644 (file)
@@ -165,6 +165,10 @@ public abstract class OnOffItem extends ModifyDialogItem {
 
        public void setOnOff(boolean isOn) {
                this.isOn = isOn;
+               setOnOff();
+       }
+
+       public void setOnOff() {
                button.setSelection(isOn);
                labelText = getLabelText(isOn);
                textCanvas.redraw();
index c1d3d18..7eb08a5 100644 (file)
@@ -690,6 +690,18 @@ public class PropertyValue {
                }
        }
 
+       public boolean isSuspendSupport() {
+               if (isVMValue()) {
+                       return vmValue.isSupportSuspend;
+               }
+               return false;
+       }
+
+       public void setSuspendSupport(boolean isSupport) {
+               if (isVMValue()) {
+                       vmValue.isSupportSuspend = isSupport;
+               }
+       }
 
 
 //     public
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SuspendSupportItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/SuspendSupportItem.java
new file mode 100644 (file)
index 0000000..c02729b
--- /dev/null
@@ -0,0 +1,114 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * Jihye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.ui.Messages;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.ItemState;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.OnOffItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+
+public class SuspendSupportItem extends OnOffItem {
+
+       public SuspendSupportItem(String title) {
+               super(ItemName.SUSPEND_SUPPORT, title);
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new ModifyItem(this);
+               item.init(parent);
+               item.setItemHeight(ModifyItem.ITEM_HEIGHT);
+               item.setItemTitle(createItemTitle(item));
+               item.create();
+
+               makeBody();
+
+       }
+
+       private void makeBody() {
+               if (getItemListComp().isDetailMode()) {
+                       createDetailItem(getLabelText(isOn));
+                       return;
+               }
+
+               // create on off item
+               createOnOff();
+
+               // set value
+               if (getItemListComp().isCreateMode()) {
+                       isOn = false; // default
+               }
+               setOnOff();
+
+       }
+
+       @Override
+       public void setInitialValue() {
+               isOn = propertyValue.isSuspendSupport();
+
+       }
+
+       @Override
+       public void setValue() {
+               propertyValue.setSuspendSupport(isOn);
+       }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new SuspendSupportItem(getTitle());
+       }
+
+       @Override
+       public void changeItem(ModifyDialogItem srcDialogItem) {
+               if (getItemListComp().isCreateMode()) {
+                       setOnOff(false);
+               }
+       }
+
+       @Override
+       protected void buttonChanged() {
+               setValue();
+       }
+
+       @Override
+       public boolean isValid() {
+               String msg = isOn
+                               ? Messages.getString("SuspendSupportViewItem.SuspendWarning.0")
+                               : "";
+
+               changeItemState(msg.isEmpty() ? ItemState.NORMAL : ItemState.WARNING
+                               ,getContentRight() ,msg);
+               return true;
+       }
+}