VM Property: NFC device option is added.
authorminkee.lee <minkee.lee@samsung.com>
Tue, 17 Jun 2014 12:46:31 +0000 (21:46 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Tue, 17 Jun 2014 12:56:10 +0000 (21:56 +0900)
- For mobile, "NFC device" option is added in property UI.
  Default value is specified as "on" in standard.xml(default template file).
  If emulator-image is not "x86-standard", this option is disabled("off").

Change-Id: I822649b1762b64b587e77a67214bb54ccad8fc44
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
plugin-project/mobile-plugin/src/org/tizen/emulator/manager/mobile/ui/detail/ItemListFactory.java
plugin-project/mobile-plugin/src/org/tizen/emulator/manager/mobile/ui/detail/TNFCItem.java [new file with mode: 0644]
plugin-project/mobile-plugin/src/org/tizen/emulator/manager/mobile/vms/Launcher.java
template/standard.xml

index 0330e47..9670b5b 100644 (file)
@@ -71,6 +71,7 @@ public class ItemListFactory implements IItemListFactory {
                }
                infoList.add(new TFileShareItem());
                infoList.add(new THWSupportItem());
+               infoList.add(new TNFCItem());
        }
 
        private static void makeModifyList() {
@@ -85,6 +86,7 @@ public class ItemListFactory implements IItemListFactory {
                }
                modifyList.add(new TFileShareItem());
                modifyList.add(new THWSupportItem());
+               modifyList.add(new TNFCItem());
 
        }
 }
diff --git a/plugin-project/mobile-plugin/src/org/tizen/emulator/manager/mobile/ui/detail/TNFCItem.java b/plugin-project/mobile-plugin/src/org/tizen/emulator/manager/mobile/ui/detail/TNFCItem.java
new file mode 100644 (file)
index 0000000..401cb10
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.mobile.ui.detail;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.resources.ImageResources;
+import org.tizen.emulator.manager.resources.PatchImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.detail.item.DetailViewItem;
+import org.tizen.emulator.manager.ui.widgets.ImageButton;
+import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+
+public class TNFCItem extends DetailViewItem {
+
+       private boolean oldSupport;
+       private boolean newSupport;
+
+       public static String OPTION_NFC = "nfcDevice";
+       public static String NFC_ON = "on";
+       public static String NFC_OFF = "off";
+
+       private ImageLabel supportLabel;
+       private static int INPUTBOX_WIDTH = 175;
+
+       @Override
+       public void drawDetail() {
+               supportLabel = new ImageLabel(compList.get(0), SWT.NONE);
+               supportLabel.setEnableImage(PatchImageResources.getInputBoxOff(INPUTBOX_WIDTH));
+
+               FormData data = new FormData();
+               data.left       = new FormAttachment(0, INPUTBOX_OFFSET);
+               data.top        = new FormAttachment(0, INPUTBOX_TOP_GAP);
+               data.width      = supportLabel.getSize().x;
+               data.height = supportLabel.getSize().y;
+               supportLabel.setLayoutData(data);
+
+               comp.layout(true, true);
+       }
+
+       @Override
+       public boolean settingDetailItem(VMPropertyValue value) {
+               if (value.baseName.equals("x86-standard")) {
+                       supportLabel.setText(
+                                       value.getExtendedOptionVal(OPTION_NFC).toLowerCase().equals(NFC_ON)
+                                       ? StringResources.SUPPORTED
+                                       : StringResources.NOT_SUPPORTED);
+               } else {
+                       supportLabel.setText(StringResources.NOT_SUPPORTED);
+               }
+               return true;
+       }
+
+       @Override
+       public void init() {
+               title = "NFC Device";
+               count = 1;
+       }
+
+       @Override
+       public void settingStatus(boolean isRefresh) {
+               // TODO Auto-generated method stub
+       }
+
+       @Override
+       public void closeItem() {
+               // TODO Auto-generated method stub
+       }
+
+       @Override
+       public void setValue(VMPropertyValue value) {
+               value.setExtendedOption(OPTION_NFC,
+                               newSupport ? NFC_ON : NFC_OFF );
+       }
+
+
+       private Label stateLabel;
+       private ImageButton selectSupport;
+
+       @Override
+       public void drawModify() {
+               makeModifyWidget();
+
+               FormData data = new FormData();
+               data.left       = new FormAttachment(0, INPUTBOX_OFFSET);
+               data.top        = new FormAttachment(0, INPUTBOX_TOP_GAP);
+               data.width      = TOGGLE_BUTTON_WIDTH;
+               data.height = TOGGLE_BUTTON_HEIGHT;
+               selectSupport.setLayoutData(data);
+
+               data = new FormData();
+               data.left = new FormAttachment(selectSupport, 10);
+               data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
+               data.width = TOGGLE_BUTTON_WIDTH;
+               stateLabel.setLayoutData(data);
+       }
+
+       private void makeModifyWidget() {
+               selectSupport = new ImageButton(compList.get(0), SWT.TOGGLE);
+               selectSupport.setImages(ImageResources.TOGGLE_ON_NOMAL.getImage(),
+                               ImageResources.TOGGLE_ON_HOVER.getImage(),
+                               ImageResources.TOGGLE_ON_PUSH.getImage(),
+                               ImageResources.TOGGLE_OFF_NOMAL.getImage(),
+                               ImageResources.TOGGLE_OFF_HOVER.getImage(),
+                               ImageResources.TOGGLE_OFF_PUSH.getImage(),
+                               ImageResources.TOGGLE_OFF_PUSH.getImage()); //disable
+
+               selectSupport.addSelectionListener(new SelectionListener() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (selectSupport.isSelection()) { // NOT SUPPORT
+                                       newSupport = false;
+                                       stateLabel.setText(StringResources.NOT_SUPPORTED);
+                               } else { // SUPPORT
+                                       newSupport = true;
+                                       stateLabel.setText(StringResources.SUPPORTED);
+                               }
+                               if (!isCreateMode()) {
+                                       getListener().ChangeValue(getThis());
+                               }
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                       }
+               });
+
+               stateLabel = new Label(compList.get(0), SWT.NONE);
+               stateLabel.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+               stateLabel.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+               stateLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
+       }
+
+       @Override
+       public boolean settingModifyItem(VMPropertyValue value) {
+               if (value.baseName.equals("x86-standard")) {
+                       selectSupport.setEnabled(true);
+                       boolean nfcValue = value.getExtendedOptionVal(OPTION_NFC).toLowerCase().equals(NFC_ON)
+                                       ? true : false;
+                       newSupport = oldSupport = nfcValue;
+
+                       if (oldSupport) {
+                               selectSupport.setSelection(false);
+                               stateLabel.setText(StringResources.SUPPORTED);
+                       } else {
+                               selectSupport.setSelection(true);
+                               stateLabel.setText(StringResources.NOT_SUPPORTED);
+                       }
+               } else {
+                       newSupport = oldSupport = false;
+                       stateLabel.setText(StringResources.NOT_SUPPORTED);
+                       selectSupport.setEnabled(false);
+               }
+
+               return true;
+       }
+
+}
index 7696882..f64f527 100644 (file)
@@ -43,6 +43,7 @@ import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
 import org.tizen.emulator.manager.console.RemoteManager;
 import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.mobile.ui.detail.TNFCItem;
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.tool.CheckVirtualization;
@@ -283,8 +284,11 @@ public class Launcher implements ILauncher {
                        cmd.add("virtio-jack-pci,jacks=earjack&charger&usb");
 
                        // for nfc
-                       cmd.add("-device");
-                       cmd.add("virtio-nfc-pci");
+                       String nfcValue = property.getPropertyValue().getExtendedOptionVal(TNFCItem.OPTION_NFC);
+                       if (nfcValue.equals(TNFCItem.NFC_ON)) {
+                               cmd.add("-device");
+                               cmd.add("virtio-nfc-pci");
+                       }
 
                        cmd.add("-device");
                        cmd.add("codec-pci");
index ab87b07..75efc48 100644 (file)
@@ -24,4 +24,5 @@
         </RAM>
         <touch maxTouchPoint="10"/>
     </device>
+    <extendedOption name="nfcDevice">on</extendedOption>
 </EmulatorConfiguration>