From 0768962ae9b9e7ebda659d80f69d871664835391 Mon Sep 17 00:00:00 2001 From: JiHye Han Date: Mon, 12 Aug 2013 19:35:41 +0900 Subject: [PATCH] Emulator Manager ] oci device add --- .../tizen/emulator/manager/vms/xml/OciType.java | 67 +++++++ .../org/tizen/emulator/manager/platform/OCI.java | 121 ++++++++++++ .../tizen/emulator/manager/platform/OCIList.java | 213 +++++++++++++++++++++ 3 files changed, 401 insertions(+) create mode 100644 common-project/jaxb_src/org/tizen/emulator/manager/vms/xml/OciType.java create mode 100644 common-project/src/org/tizen/emulator/manager/platform/OCI.java create mode 100644 common-project/src/org/tizen/emulator/manager/platform/OCIList.java 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 index 0000000..0371e8e --- /dev/null +++ b/common-project/jaxb_src/org/tizen/emulator/manager/vms/xml/OciType.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 +// See http://java.sun.com/xml/jaxb +// 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; + + +/** + *

Java class for ociType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ociType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+*			<element name="ociOptions" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@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 index 0000000..80cdcc4 --- /dev/null +++ b/common-project/src/org/tizen/emulator/manager/platform/OCI.java @@ -0,0 +1,121 @@ +/* + * Emulator Manager + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * JiHye Kim + * YeongKyoon Lee + * + * 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 index 0000000..4765f92 --- /dev/null +++ b/common-project/src/org/tizen/emulator/manager/platform/OCIList.java @@ -0,0 +1,213 @@ +/* + * Emulator Manager + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * JiHye Kim + * YeongKyoon Lee + * + * 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 OCIDeviceList = new ArrayList(); + private ArrayList OCISelectDeviceList = new ArrayList(); + //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 getOCISelectList() { + return OCISelectDeviceList; + } + + public ArrayList 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 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; + } +} + -- 2.7.4