--- /dev/null
+/*
+ * 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;
+ }
+
+}