Emulator Manager ] oci device add
authorJiHye Han <jihye926.han>
Mon, 12 Aug 2013 10:35:41 +0000 (19:35 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Thu, 22 Aug 2013 02:08:07 +0000 (11:08 +0900)
common-project/jaxb_src/org/tizen/emulator/manager/vms/xml/OciType.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/platform/OCI.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/platform/OCIList.java [new file with mode: 0644]

diff --git a/common-project/jaxb_src/org/tizen/emulator/manager/vms/xml/OciType.java b/common-project/jaxb_src/org/tizen/emulator/manager/vms/xml/OciType.java
new file mode 100644 (file)
index 0000000..0371e8e
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2012.07.17 at 07:23:49 PM KST 
+//
+
+
+package org.tizen.emulator.manager.vms.xml;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ociType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="ociType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+*                      &lt;element name="ociOptions" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ociType", propOrder = {
+    "ociOptions"
+})
+public class OciType {
+
+       protected String ociOptions;
+
+    /**
+     * Gets the value of the ociOptions property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getOCIOptions() {
+       return ociOptions;
+    }
+
+    /**
+     * Sets the value of the ociOptions property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setOCIOptions(String value) {
+        this.ociOptions = value;
+    }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/platform/OCI.java b/common-project/src/org/tizen/emulator/manager/platform/OCI.java
new file mode 100644 (file)
index 0000000..80cdcc4
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.platform;
+
+import java.io.IOException;
+
+
+public class OCI {
+//     private int vendorid;
+       private int deviceid;
+       private int listid;
+       private String name;
+
+       public OCI(int i) throws IOException {
+               loadProperty(i);
+       }
+
+       private void loadProperty(int i) throws IOException {
+       //      this.vendorid = 1;
+               //this.deviceid = 1;
+               //this.name = "USB Storage";
+                       this.listid = i;
+                       this.deviceid = i+1;
+                       this.name = "USB Storage" + i;
+
+               // load OCI device list
+               /*
+               this.path = path.getCanonicalPath();
+               File f = new File(path + File.separator + StringResources.SKIN_INFO_FILENAME);
+               FileInputStream inputStream = null;
+               try {
+                       if (f.exists()) {
+                               inputStream = new FileInputStream(f);
+                               Properties prop = new Properties();
+                               prop.load(inputStream);
+                               device_name = prop.getProperty(StringResources.SKIN_NAME);
+                       } else {
+                               throw new IOException(StringResources.SKIN_INFO_FILENAME + " file does not exist.");
+                       }
+               } finally {
+                       // clear
+                       if (inputStream != null) {
+                               try {
+                                       inputStream.close();
+                               } catch (IOException e) {
+                                       EMLogger.getLogger().log(Level.WARNING, e.getMessage());
+                               }
+                       }
+               }
+               */
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public int getDeviceid() {
+               return deviceid;
+       }
+
+       public void setDeviceid(int id) {
+               this.deviceid = id;
+       }
+
+       public int getListid() {
+               return listid;
+       }
+
+       public void setListid(int id) {
+               this.listid = id;
+       }
+
+       @ Override
+       public String toString() {
+               return name;
+       }
+
+       @ Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof OCI)) {
+                       return false;
+               }
+
+               if (((OCI)obj).getName().equals(name)) {
+                       return true;
+               }
+
+               return false;
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/platform/OCIList.java b/common-project/src/org/tizen/emulator/manager/platform/OCIList.java
new file mode 100644 (file)
index 0000000..4765f92
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.platform;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.StringResources;
+
+
+public class OCIList {
+
+       private ArrayList<OCI> OCIDeviceList = new ArrayList<OCI>();
+       private ArrayList<OCI> OCISelectDeviceList = new ArrayList<OCI>();
+       //private Skins defaultSkin = null;
+
+       private static OCIList instance = null;
+       static {
+               instance = new OCIList();
+       }
+
+       public static OCIList getInstance() {
+               return instance;
+       }
+
+       private OCIList() {
+
+               /*try {
+                       for (Platform platform : EmulatorManager.getPlatformList()) {
+                                makeOCIList(new File(FilePathResources.getPlatformsPath() + File.separator + platform.getName() + FilePathResources.getDefaultSkinPath()));
+                       }
+                       makeOCIList(new File(FilePathResources.getSkinPath()));
+
+                       //defaultSkin = skinsList.get(0);
+               } catch (IOException e) {
+                       EMLogger.getLogger().warning(e.getMessage());
+               }
+
+               try {
+                       makeOCIList();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       EMLogger.getLogger().warning(e.getMessage());
+               }
+       }
+
+       private void makeOCIList() throws IOException {
+               /*System.out.println("oci dir : " + dir.getPath());
+               if (dir.exists()) {
+                       for (File OCI : dir.listFiles(new FileFilter() {
+                               public boolean accept(File pathname) {
+                                       System.out.println("pathname : " + pathname.getName());
+                                       if (!pathname.isDirectory()) {
+                                               return false;
+                                       }
+                                       return true;
+                               }
+                       })) {
+                               OCI s = null;
+                               try {
+                                       s = new OCI();
+                               } catch(IOException e) {
+                                       EMLogger.getLogger().warning("Failed adding Skin.."
+                                                       + StringResources.NEW_LINE + "Skin Path: " + OCI.getAbsolutePath()
+                                                       + StringResources.NEW_LINE + "Error: " + e.getMessage());
+                                       continue;
+                               }
+                               OCIList.add(s);
+                       }
+
+               } else {
+                       throw new IOException("This Skin path does not exist (" + dir.getPath() + ")");
+               }*/
+               for (int i = 0; i < 10; i++) {
+                               OCI s = null;
+                       try {
+                               s = new OCI(i);
+                       } catch(IOException e) {
+                               EMLogger.getLogger().warning("Failed adding OCI Device.."
+                                               + StringResources.NEW_LINE + "Error: " + e.getMessage());
+
+                       }
+                       OCIDeviceList.add(s);
+               }
+       }
+
+       public ArrayList<OCI> getOCISelectList() {
+               return OCISelectDeviceList;
+       }
+
+       public ArrayList<OCI> getOCIList() {
+               return OCIDeviceList;
+       }
+
+       public String setOCISelectList(String ociOptions) {
+               if (ociOptions == null)
+                       return ociOptions;
+               StringTokenizer s = new StringTokenizer(ociOptions);
+               String devicename;
+               OCI device;
+               while (s.hasMoreTokens()) {
+                       devicename = s.nextToken("|");
+                       device = findOCIDeviceName(devicename);
+                       OCISelectDeviceList.add(device);
+               }
+               return ociOptions;
+       }
+
+       public boolean find(String name, String ociOptions) {
+               if (ociOptions.matches(".*"+name+".*"))
+                       return true;
+               return false;
+       }
+
+       public OCI findOCIUsePath(String path) {
+               if (OCIDeviceList != null) {
+                       /*
+                       for (OCI OCI : OCIDeviceList) {
+                       }
+                       */
+               }
+               return null;
+       }
+
+       public OCI findOCIDeviceName(String name) {
+               if (OCIDeviceList != null) {
+                       for (OCI OCI : OCIDeviceList) {
+                               if (OCI.getName().equals(name)) {
+                                       return OCI;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public boolean findOCISelectDiviceName(String name) {
+               if (OCISelectDeviceList != null) {
+                       for (OCI OCI : OCISelectDeviceList) {
+
+                               if (OCI.getName().equals(name)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       public ArrayList<OCI> findOCIList() {
+                       if (OCIDeviceList != null) {
+                               for (OCI OCI : OCIDeviceList) {
+                                       // selected OCI divece add
+                                       System.out.println("OCI  " + OCI.getName());
+
+                               }
+                       }
+                       return OCISelectDeviceList;
+               }
+
+       public String addOciDeviceSelectName() {
+               String addOciDeviceName = "";
+
+               if (OCISelectDeviceList != null) {
+                       for (OCI OCI : OCISelectDeviceList) {
+                               addOciDeviceName += (OCI.getName() + " | ") ;
+                       }
+               }
+               return addOciDeviceName;
+       }
+
+       public String deleteOciDeviceSelectName(String name) {
+               String deleteOciDeviceName = "";
+
+               if (OCISelectDeviceList != null) {
+                       for (OCI OCI : OCISelectDeviceList) {
+                               if (OCI.getName().equals(name)) {
+                                       OCISelectDeviceList.remove(OCI);
+                               }
+
+                       }
+               }
+               return deleteOciDeviceName;
+       }
+}
+