From 712930b49a3af7901a81b84c6a06ce2dc06baa7c Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Fri, 12 Jun 2015 19:55:17 +0900 Subject: [PATCH] camera-option: Introduced new camera option. Change-Id: I5cf03e1971f558c442b9f94058f7622a3a13e3e3 Signed-off-by: minkee.lee --- .../manager/resources/FilePathResources.java | 11 + .../ui/detail/item/CommonItemListFactory.java | 1 + .../emulator/manager/ui/detail/item/ItemName.java | 1 + .../item/property/CameraImageSubViewItem.java | 126 +++++++++++ .../item/property/CameraTypeSubViewItem.java | 245 +++++++++++++++++++++ .../ui/detail/item/property/CameraViewItem.java | 156 +++++++++++++ .../emulator/manager/vms/helper/HelperClass.java | 2 +- .../emulator/manager/vms/helper/ProcessResult.java | 1 + .../emulator/manager/vms/option/CameraOption.java | 73 ++++++ 9 files changed, 615 insertions(+), 1 deletion(-) create mode 100644 src/org/tizen/emulator/manager/ui/detail/item/property/CameraImageSubViewItem.java create mode 100644 src/org/tizen/emulator/manager/ui/detail/item/property/CameraTypeSubViewItem.java create mode 100644 src/org/tizen/emulator/manager/ui/detail/item/property/CameraViewItem.java create mode 100644 src/org/tizen/emulator/manager/vms/option/CameraOption.java diff --git a/src/org/tizen/emulator/manager/resources/FilePathResources.java b/src/org/tizen/emulator/manager/resources/FilePathResources.java index 9487ae3..d4a66c9 100644 --- a/src/org/tizen/emulator/manager/resources/FilePathResources.java +++ b/src/org/tizen/emulator/manager/resources/FilePathResources.java @@ -84,6 +84,8 @@ public class FilePathResources { private final static String vms_suffix = File.separator + "vms"; private final static String qemuImg_suffic = File.separator + "qemu-img"; + private final static String checkCam_suffix = File.separator + "check-cam" + + (EmulatorManager.isWin() ? ".exe" : "") ; private static String currentPath; private static String sdkPath = null; @@ -372,6 +374,14 @@ public class FilePathResources { return getEmulatorToolPath() + qemuImg_suffic; } + public static String getCheckCamPath() { + return getEmulatorToolPath() + checkCam_suffix; + } + + public static String getEmulatorImagePath(String platformVersion) { + return getEmulatorPath(platformVersion) + images_suffix; + } + public static String getEmulatorDataPath(String platformVersion) { return getEmulatorPath(platformVersion) + data_suffix; } @@ -410,6 +420,7 @@ public class FilePathResources { } return latestVersion; } + /* public String getArchPath(){ return arcPath; diff --git a/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java b/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java index 1c5dab9..9b329a7 100644 --- a/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java +++ b/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java @@ -75,6 +75,7 @@ public abstract class CommonItemListFactory implements IItemListFactory{ public static String ITEM_NET_IP_INFO = "netIpInfo"; public static String ITEM_NET_DNS = "netDns"; public static String ITEM_NET_MAC = "netMac"; + public static String ITEM_CAMERA = "camera"; public static ObjectFactory factory = new ObjectFactory(); diff --git a/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java b/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java index 6f7ccea..4f03b5a 100644 --- a/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java +++ b/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java @@ -42,6 +42,7 @@ public class ItemName { public static final String SENSOR = "sensor"; public static final String DEVICE = "device"; public static final String JACK = "jack"; + public static final String CAMERA = "camera"; public static final String NET_CONFIG = "netConfig"; public static final String NET_PROXY = "proxy"; diff --git a/src/org/tizen/emulator/manager/ui/detail/item/property/CameraImageSubViewItem.java b/src/org/tizen/emulator/manager/ui/detail/item/property/CameraImageSubViewItem.java new file mode 100644 index 0000000..57a611b --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/item/property/CameraImageSubViewItem.java @@ -0,0 +1,126 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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.detail.item.property; + +import java.io.File; +import java.util.Arrays; + +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.resources.FilePathResources; +import org.tizen.emulator.manager.ui.detail.item.ItemState; +import org.tizen.emulator.manager.ui.detail.item.template.FileSubViewItem; +import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem; +import org.tizen.emulator.manager.vms.VMPropertyValue; +import org.tizen.emulator.manager.vms.xml.template.Item; + +public class CameraImageSubViewItem extends FileSubViewItem { + + private final CameraViewItem cameraViewItem; + String platformVersion; + private static final String DEFAULT_FRONT_IMG = "default-image1.gif"; + private static final String DEFAULT_REAR_IMG = "default-image2.gif"; + + public CameraImageSubViewItem(LabelViewItem parentItem, Composite comp, + Item template) { + super(parentItem, comp, template); + cameraViewItem = (CameraViewItem) parentItem; + + filters.addAll(Arrays.asList("*.gif", "*.png", "*.bmp", "*.jpg", "*.jpeg", "*.*")); + } + + @Override + public boolean settingModifyItem(VMPropertyValue value) { + platformVersion = value.baseImage.getVersion(); + newValue = getModifyValue(value); + setPathLabel(); + + CameraTypeSubViewItem typeItem = cameraViewItem.getCameraTypeItem(name); + if (typeItem != null) { + if (typeItem.isVirtualSelected(value)) { + activate(); + } else { + deactivate(); + } + } + return true; + } + + public void reset(String cameraType) { + if (CameraViewItem.VALUE_VIRTUAL.equals(cameraType)) { + activate(); + } else { + deactivate(); + } + } + + public void activate() { + setEnabled(true); + if (newValue == null || newValue.isEmpty()) { + newValue = FilePathResources.getEmulatorImagePath(platformVersion) + + File.separator + + (CameraViewItem.ITEM_FRONT_IMAGE.equals(name) ? DEFAULT_FRONT_IMG + : DEFAULT_REAR_IMG); + } + setPathLabel(); + } + + public void deactivate() { + newValue = ""; + setPathLabel(); + setEnabled(false); + } + + private void setPathLabel() { + String fileName = newValue.substring( + newValue.lastIndexOf(File.separator) + 1, newValue.length()); + filePathLabel.setText(fileName); + filePathLabel.setToolTipText(newValue); + } + + @Override + public ItemState checkValue() { + + itemState.setNormal(); + CameraTypeSubViewItem cameraType = cameraViewItem.getCameraTypeItem(name); + if (cameraType.isVirtualSelected()) { + if (newValue == null || newValue.isEmpty()) { + itemState.setError("Please select image file for virtual camera."); + } else { + File f = new File(newValue); + if (!f.exists()) { + itemState.setError("Virtual camera image file is not exist."); + } + } + } + return itemState; + } + +} diff --git a/src/org/tizen/emulator/manager/ui/detail/item/property/CameraTypeSubViewItem.java b/src/org/tizen/emulator/manager/ui/detail/item/property/CameraTypeSubViewItem.java new file mode 100644 index 0000000..224869f --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/detail/item/property/CameraTypeSubViewItem.java @@ -0,0 +1,245 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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.detail.item.property; + +import java.util.List; + +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.manager.ui.detail.item.template.ComboSubViewItem; +import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem; +import org.tizen.emulator.manager.vms.VMPropertyValue; +import org.tizen.emulator.manager.vms.xml.template.Item; +import org.tizen.emulator.manager.vms.xml.template.Option; + +public class CameraTypeSubViewItem extends ComboSubViewItem { + + private final CameraViewItem cameraViewItem; + + public CameraTypeSubViewItem(LabelViewItem parentItem, Composite comp, + Item template) { + super(parentItem, comp, template); + cameraViewItem = (CameraViewItem) parentItem; + } + + @Override + public String getValue() { + return newValue; + } + + @Override + protected void parseOption(List