<delete dir="build" />
<delete file="${jar.file}" />
</target>
+
+ <target name="make-properties">
+ <echo message="make properties..." />
+ <tstamp>
+ <format property="build_time" pattern="MM/dd/yyyy hh:mm aa" timezone="GMT" locale="en" />
+ </tstamp>
+ <exec executable="cat" outputproperty="version">
+ <arg value="VERSION" />
+ </exec>
+ <exec executable="git" outputproperty="build_git_commit" failifexecutionfails="false">
+ <arg value="rev-parse" />
+ <arg value="--short" />
+ <arg value="HEAD" />
+ </exec>
+ <propertyfile file="about.properties" comment="Auto-generated properties - DO NOT EDIT">
+ <entry key="version" value="${version}" />
+ <entry key="build_time" value="${build_time}" />
+ <entry key="build_git_commit" value="${build_git_commit}" />
+ </propertyfile>
+ </target>
- <target name="linux-compile" depends="clean">
+ <target name="linux-compile" depends="make-properties">
<echo message="compiling..." />
<mkdir dir="bin" />
<javac encoding="UTF-8" fork="true" srcdir="src:jaxb_src" destdir="bin" debug="on" memorymaximumsize="128m">
</javac>
</target>
- <target name="windows-compile" depends="clean">
+ <target name="windows-compile" depends="make-properties">
<echo message="compiling..." />
<mkdir dir="bin" />
<javac encoding="UTF-8" fork="true" srcdir="src:jaxb_src" destdir="bin" debug="on" memorymaximumsize="128m">
</javac>
</target>
- <target name="mac-compile" depends="clean">
+ <target name="mac-compile" depends="make-properties">
<echo message="compiling..." />
<mkdir dir="bin" />
<javac encoding="UTF-8" fork="true" srcdir="src:jaxb_src" destdir="bin" debug="on" memorymaximumsize="128m">
<fileset dir="resource/res" />
</copy>
<jar jarfile="dist/linux/${jar.file}" basedir="build" duplicate="add">
+ <fileset file="about.properties" />
<manifest>
<attribute name="Main-Class" value="${mainclass}" />
<attribute name="Class-path" value="lib/swt/gtk-linux/${swt.file}" />
<fileset dir="resource/res" />
</copy>
<jar jarfile="dist/win32/${jar.file}" basedir="build" duplicate="add">
+ <fileset file="about.properties" />
<manifest>
<attribute name="Main-Class" value="${mainclass}" />
<attribute name="Class-path" value="lib/swt/win32-win32/${swt.file}" />
<fileset dir="resource/res" />
</copy>
<jar jarfile="dist/mac/${jar.file}" basedir="build" duplicate="add">
+ <fileset file="about.properties" />
<manifest>
<attribute name="Main-Class" value="${mainclass}" />
<attribute name="Class-path" value="lib/swt/cocoa-macosx/${swt.file}" />
<delete dir="build" />
</target>
-</project>
\ No newline at end of file
+</project>
em_path="."
fi
-mode=$1
-
if [ -f $current_emulmgr ]
then
-java -jar $current_emulmgr $mode $*
+java -jar $current_emulmgr $*
else
-java -jar $em_path"/emulator-manager.jar" $mode $*
+java -jar $em_path"/emulator-manager.jar" $*
fi
+++ /dev/null
-@ECHO OFF\r
-set install_path=%localappdata%\.TizenSDK\tizensdkpath\r
-::echo %install_path%\r
-\r
-for /f "tokens=2 delims==" %%i in (%install_path%) do set tizen_path=%%i\r
-::echo %tizen_path%\r
-\r
-set em_path=%tizen_path%\Emulator\bin\r
-\r
-set mode=%1\r
-\r
-javaw -jar %em_path%\emulator-manager.jar %mode%\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-int main(int argc, char* argv[]) {\r
+int main(int argc, char* argv[]) \r
+{\r
FILE *propertyFile;\r
HKEY hKey;\r
char strPropertyFilePath[MAX];\r
DWORD ret;\r
int i;\r
DWORD fileAttr;\r
+ STARTUPINFO sti = { 0 };\r
+ PROCESS_INFORMATION pi = { 0 };\r
+\r
ret = GetCurrentDirectory(512, currentEmulmgr);\r
strcat(currentEmulmgr, EMULMGR_JAR);\r
// Get a "tizensdkpath" file path\r
strcat(strCommand, argv[i]);\r
}\r
}\r
- // execute emulator-manager\r
- WinExec(strCommand, SW_SHOWNORMAL);\r
+ \r
+ if(!CreateProcess(NULL,\r
+ strCommand,\r
+ NULL,\r
+ NULL,\r
+ FALSE,\r
+ NORMAL_PRIORITY_CLASS,\r
+ NULL,\r
+ NULL,\r
+ &sti,\r
+ &pi)\r
+ ) {\r
+ fprintf(stderr, "Unable to generate Emulator Manager process\n");\r
+ exit(1);\r
+ }\r
+\r
+ DWORD rc = WaitForSingleObject(\r
+ pi.hProcess, // process handle\r
+ INFINITE);\r
+\r
return 0;\r
}\r
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="display" type="{http://www.tizen.org/em}displayType"/>
- * <element name="storage" type="{http://www.tizen.org/em}storageType"/>
+ * <element name="storage" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="RAM" type="{http://www.tizen.org/em}ramType"/>
* <element name="touch" type="{http://www.tizen.org/em}touchType" minOccurs="0"/>
* </sequence>
@XmlElement(required = true)
protected DisplayType display;
@XmlElement(required = true)
- protected StorageType storage;
+ protected String storage;
@XmlElement(name = "RAM", required = true)
protected RamType ram;
protected TouchType touch;
*
* @return
* possible object is
- * {@link StorageType }
+ * {@link String }
*
*/
- public StorageType getStorage() {
+ public String getStorage() {
return storage;
}
*
* @param value
* allowed object is
- * {@link StorageType }
+ * {@link String }
*
*/
- public void setStorage(StorageType value) {
+ public void setStorage(String value) {
this.storage = value;
}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
}
/**
+ * Create an instance of {@link UsabilityType }
+ *
+ */
+ public UsabilityType createUsabilityType() {
+ return new UsabilityType();
+ }
+
+ /**
* Create an instance of {@link BaseInformationType }
*
*/
}
/**
- * Create an instance of {@link RamType.Size }
+ * Create an instance of {@link DiskImageFormatType }
*
*/
- public RamType.Size createRamTypeSize() {
- return new RamType.Size();
+ public DiskImageFormatType createDiskImageFormatType() {
+ return new DiskImageFormatType();
}
/**
- * Create an instance of {@link DisplayType.Resolution }
+ * Create an instance of {@link BaseInformationType.DiskImage }
*
*/
- public DisplayType.Resolution createDisplayTypeResolution() {
- return new DisplayType.Resolution();
+ public BaseInformationType.DiskImage createBaseInformationTypeDiskImage() {
+ return new BaseInformationType.DiskImage();
}
/**
- * Create an instance of {@link EmulatorConfiguration }
+ * Create an instance of {@link UsabilityType.Logging }
*
*/
- public EmulatorConfiguration createEmulatorConfiguration() {
- return new EmulatorConfiguration();
+ public UsabilityType.Logging createUsabilityTypeLogging() {
+ return new UsabilityType.Logging();
}
/**
- * Create an instance of {@link StorageType.SDCard }
+ * Create an instance of {@link RamType.Size }
*
*/
- public StorageType.SDCard createStorageTypeSDCard() {
- return new StorageType.SDCard();
+ public RamType.Size createRamTypeSize() {
+ return new RamType.Size();
}
/**
- * Create an instance of {@link UsabilityType.Logging }
+ * Create an instance of {@link EmulatorConfiguration }
*
*/
- public UsabilityType.Logging createUsabilityTypeLogging() {
- return new UsabilityType.Logging();
+ public EmulatorConfiguration createEmulatorConfiguration() {
+ return new EmulatorConfiguration();
}
/**
- * Create an instance of {@link DisplayType }
+ * Create an instance of {@link UsabilityType.FileSharing }
*
*/
- public DisplayType createDisplayType() {
- return new DisplayType();
+ public UsabilityType.FileSharing createUsabilityTypeFileSharing() {
+ return new UsabilityType.FileSharing();
}
/**
- * Create an instance of {@link UsabilityType }
+ * Create an instance of {@link DisplayType.Density }
*
*/
- public UsabilityType createUsabilityType() {
- return new UsabilityType();
+ public DisplayType.Density createDisplayTypeDensity() {
+ return new DisplayType.Density();
}
/**
}
/**
- * Create an instance of {@link BaseInformationType.DiskImage }
- *
- */
- public BaseInformationType.DiskImage createBaseInformationTypeDiskImage() {
- return new BaseInformationType.DiskImage();
- }
-
- /**
- * Create an instance of {@link StorageType }
- *
- */
- public StorageType createStorageType() {
- return new StorageType();
- }
-
- /**
- * Create an instance of {@link DiskImageFormatType }
- *
- */
- public DiskImageFormatType createDiskImageFormatType() {
- return new DiskImageFormatType();
- }
-
- /**
- * Create an instance of {@link UsabilityType.FileSharing }
+ * Create an instance of {@link DeviceType }
*
*/
- public UsabilityType.FileSharing createUsabilityTypeFileSharing() {
- return new UsabilityType.FileSharing();
+ public DeviceType createDeviceType() {
+ return new DeviceType();
}
/**
}
/**
- * Create an instance of {@link DisplayType.Density }
+ * Create an instance of {@link DisplayType.Resolution }
*
*/
- public DisplayType.Density createDisplayTypeDensity() {
- return new DisplayType.Density();
+ public DisplayType.Resolution createDisplayTypeResolution() {
+ return new DisplayType.Resolution();
}
/**
}
/**
- * Create an instance of {@link DeviceType }
+ * Create an instance of {@link DisplayType }
*
*/
- public DeviceType createDeviceType() {
- return new DeviceType();
+ public DisplayType createDisplayType() {
+ return new DisplayType();
}
}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
+++ /dev/null
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
-// 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.04.02 at 05:39:01 오후 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.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for storageType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="storageType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="SDCard">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="diskImage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "storageType", propOrder = {
- "sdCard"
-})
-public class StorageType {
-
- @XmlElement(name = "SDCard", required = true)
- protected StorageType.SDCard sdCard;
-
- /**
- * Gets the value of the sdCard property.
- *
- * @return
- * possible object is
- * {@link StorageType.SDCard }
- *
- */
- public StorageType.SDCard getSDCard() {
- return sdCard;
- }
-
- /**
- * Sets the value of the sdCard property.
- *
- * @param value
- * allowed object is
- * {@link StorageType.SDCard }
- *
- */
- public void setSDCard(StorageType.SDCard value) {
- this.sdCard = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="diskImage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "diskImage"
- })
- public static class SDCard {
-
- protected String diskImage;
-
- /**
- * Gets the value of the diskImage property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getDiskImage() {
- return diskImage;
- }
-
- /**
- * Sets the value of the diskImage property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setDiskImage(String value) {
- this.diskImage = value;
- }
-
- }
-
-}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// 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.04.02 at 05:39:01 ì\98¤Ã\9b\84 KST
+// Generated on: 2012.04.20 at 10:49:37 ì\98¤ì \84 KST
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.tizen.org/em", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
Package: emulator-manager
-Version: 1.0.33
+Version: 1.0.53
OS: linux
Build-host-os: linux
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Description: Tizen Emulator Manager
Package: emulator-manager
-Version: 1.0.33
+Version: 1.0.53
OS: windows
Build-host-os: windows
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
import java.nio.channels.FileLock;
import java.util.logging.Level;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.tool.CheckVirtualization;
import org.tizen.emulator.manager.tool.FileIO;
+import org.tizen.emulator.manager.tool.SelectWorkspace;
import org.tizen.emulator.manager.ui.MainDialog;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.vms.EmulatorVMs;
public class EmulatorManager {
public EmulatorManager(ManagerModeType mode) {
this.mode = mode;
- this.display = new Display();
+ this.display = Display.getCurrent();
}
public ManagerModeType getManagerMode() {
return mode;
}
-
public MainDialog getMainDialog() {
return mainDialog;
}
private void dispose() {
mainDialog.dispose();
}
-
+
static ManagerModeType parseArgs(String[] args) {
boolean isArgsError = false;
-
+ final String SAVE_TRUE = ",save=true";
+ final String SAVE_FALSE = ",save=false";
ManagerModeType mode = ManagerModeType.PUBLIC_MODE;
-
+ String workspacePath = null;
+ boolean isSave = true;
+
if(args.length > 0) {
for(int i = 0; i < args.length; i++) {
if(args[i].equals("--workspace") || args[i].equals("-w")) {
if(args.length == i + 1 || args[i + 1].startsWith("--")) {
isArgsError = true;
} else {
- EmulatorVMs.getInstance().setVMsBaseDirectory(args[i + 1]);
+ /* used workspace option correctly */
+ if(args[i+1].endsWith(SAVE_TRUE)) {
+ workspacePath = args[i=1].substring(0, args[i=1].length() - SAVE_TRUE.length());
+ isSave = true;
+ }
+ else if(args[i+1].endsWith(SAVE_FALSE)) {
+ workspacePath = args[i=1].substring(0, args[i=1].length() - SAVE_FALSE.length());
+ isSave = false;
+ }
+ else {
+ isArgsError = true;
+ }
}
} else if (args[i].equals("--inhouse")) {
mode = ManagerModeType.INHOUSE_MODE;
}
}
}
- else {
- EmulatorVMs.getInstance().setVMsBaseDirectory(FileIO.getInstance().getTizenVmsPath());
- }
+
+ if (!SelectWorkspace.setWorkspace(workspacePath, isSave)) {
+ exitEmulatorManager(0);
+ }
+
+ MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
if (isArgsError == true) {
- getMessageBoxInNewShell(SWT.ICON_INFORMATION, "INFO", "You did not input workspace path after\n" +
- "command line option --workspace or -w\n" +
- "Emulator Manager sets in default workspace.").open();
+ msg.openWarningDialog("Used workspace option parameter is not proper. Aborting...\n" +
+ "\nSee right examples below.\n" +
+ "[--workspace {workspace path},save=true]\n" +
+ "[-w {workspace path},save=true]\n" +
+ "[--workspace {workspace path},save=false]\n" +
+ "[-w {workspace path},save=false]\n" +
+ "\nThe workspace path must be absolute."
+ );
+ exitEmulatorManager(0);
}
-
+
return mode;
}
-
- static MessageBox getMessageBoxInNewShell(int style, String text, String message) {
- Shell shell = new Shell(Display.getCurrent());
- MessageBox msg = new MessageBox(shell, SWT.ICON_INFORMATION);
- msg.setText(text);
- msg.setMessage(message);
-
- return msg;
- }
-
- static void exitEmulatorManager(int returnValue) {
+
+ public static void exitEmulatorManager(int returnValue) {
System.exit(returnValue);
}
public static void main(String[] args) {
- ManagerModeType mode = parseArgs(args);
-
- instance = new EmulatorManager(mode);
-
- EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!\n");
-
- try {
- EmulatorVMs.getInstance().loadProperties();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
+ MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
try {
FileLock lock = new RandomAccessFile(new File(FileIO.getInstance().getBinPath()
+ File.separator + "." +System.getProperty("user.name"))+ ".lock",
"rw").getChannel().tryLock();
if (lock == null) {
- getMessageBoxInNewShell(SWT.ICON_INFORMATION, "INFO", "Can not launch Emulator Manager.\n" +
- "Another one with the same user name is running now.").open();
-
+ msg.openInfoDialog("Can not launch Emulator Manager.\n" +
+ "Another one with the same user name is running now.");
exitEmulatorManager(0);
}
} catch (Exception e) {
- getMessageBoxInNewShell(SWT.ICON_INFORMATION, "INFO",
- "Can not launch Emulator Manager.\n" +e.getMessage()).open();
-
+ msg.openInfoDialog("Can not launch Emulator Manager.\n" +e.getMessage());
exitEmulatorManager(-1);
+ }
+
+ ManagerModeType mode = parseArgs(args);
+ instance = new EmulatorManager(mode);
+
+ EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!\n");
+
+ // check hax or kvm
+ CheckVirtualization.getInstance().check();
+
+ try {
+ EmulatorVMs.getInstance().loadProperties();
+ } catch (Exception e) {
+ EMLogger.getLogger().log(Level.WARNING, e.getMessage());
}
-
+
instance.preare();
instance.DrawUI();
instance.dispose();
}
-
+
public enum ManagerModeType {
PUBLIC_MODE("public"),
INHOUSE_MODE("inhouse");
File logFolder;
Handler logFileHandler;
try {
- logFolder = new File(FileIO.getInstance().getEtcPath());
+ logFolder = new File(FileIO.getInstance().getTizenVmsArchPath());
if (!logFolder.exists()) {
logFolder.mkdirs();
}
--- /dev/null
+package org.tizen.emulator.manager.tool;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.logging.EMLogger;
+
+public class CheckVirtualization {
+ private static CheckVirtualization instance = new CheckVirtualization();
+ private static boolean isSupport = true;
+ private static String enable_command = null;
+ private static String disable_command = null;
+ private static boolean isCheck = false;
+
+ private CheckVirtualization() {
+ // singleton class
+ }
+
+ public static CheckVirtualization getInstance() {
+ return instance;
+ }
+
+ public boolean isSupportVirtualization() {
+ return isSupport;
+ }
+
+ public String getEnableCommnad() {
+ return enable_command;
+ }
+
+ public String getDisableCommnad() {
+ return disable_command;
+ }
+
+ public void check() {
+ if (!isCheck) {
+ checkVirtualization();
+ isCheck = true;
+ }
+ }
+
+ private void checkVirtualization() {
+ //CheckDialog dialog = new CheckDialog();
+ //dialog.create();
+ Work work = new Work();
+ work.setDaemon(true);
+ work.start();
+
+ //dialog.open();
+
+ try {
+ work.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ EMLogger.getLogger().log(Level.INFO, "Exception" + e.getMessage() + "\n");
+ }
+ /*
+ while(work.isAlive()) {
+ if(!Display.getCurrent().readAndDispatch())
+ Display.getCurrent().sleep();
+ }
+ */
+
+ //dialog.close();
+ }
+
+ private class Work extends Thread {
+ public void run() {
+ if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+ int exitValue = 0;
+
+ List<String> cmd = new ArrayList<String>();
+ cmd.add(FileIO.getInstance().getBinPath() + File.separator + "check-hax.exe");
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.directory(new File(FileIO.getInstance().getBinPath()));
+
+ try {
+ Process process = null;
+ process = pb.start();
+ process.waitFor();
+ exitValue = process.exitValue();
+ EMLogger.getLogger().log(Level.INFO, "Check-hax.exe's exit value : " + exitValue + "\n");
+ } catch (IOException e) {
+ EMLogger.getLogger().log(Level.INFO, "IOException" + e.getMessage() + "\n");
+ } catch (InterruptedException e) {
+ EMLogger.getLogger().log(Level.INFO, "InterruptedException" + e.getMessage() + "\n");
+ } catch (Exception e) {
+ EMLogger.getLogger().log(Level.INFO, "Exception" + e.getMessage() + "\n");
+ }
+
+ if(exitValue == 0) {
+ isSupport = true;
+ } else {
+ isSupport = false;
+ }
+ enable_command = "-enable-hax";
+ } else if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
+ if(new File("/dev/kvm").canRead()) {
+ isSupport = true;
+ } else {
+ isSupport = false;
+ }
+ enable_command = "-enable-kvm";
+ }
+ }
+ }
+}
+
+class CheckDialog {
+ private Shell dialog;
+
+ public void create() {
+ dialog = new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL);
+ dialog.setText("Info");
+ dialog.setSize(300, 100);
+ dialog.setLayout(new GridLayout(1, false));
+
+ Label label = new Label(dialog, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true));
+ label.setText("Please wait !!\nCheck whether virtualization is supported.");
+ }
+
+ public void open() {
+ dialog.open();
+ }
+
+ public void close() {
+ dialog.close();
+ }
+}
x86KernelPath = dataPath + x86_kernel_suffix;
biosPath = dataPath + bios_suffix;
+
+ vmsPath = EmulatorVMs.getInstance().getVMsBaseDirectory();
+ vmsArchPath = vmsPath + arch_suffix;
+ }
+
+ public static void setVMSPath() {
vmsPath = EmulatorVMs.getInstance().getVMsBaseDirectory();
vmsArchPath = vmsPath + arch_suffix;
//testPrintPath();
}
}
+ private FileIO() {
+ }
+
public static FileIO getInstance() {
return instance;
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.tool;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.ui.MessageDialog;
+import org.tizen.emulator.manager.ui.SelectWorkspaceDialog;
+import org.tizen.emulator.manager.vms.EmulatorVMs;
+
+public class SelectWorkspace {
+ private static Properties prop = null;
+
+ private static String oldShow = null;
+ private static String oldPath = null;
+
+ public static boolean setWorkspace(String workspacePath, boolean isSave) {
+ boolean isModify = false;
+ String workspaceConfPath = null;
+ if (isSave) {
+ workspaceConfPath = System.getProperty("user.home") + File.separator + StringResource.WORKSPACE_NAME;
+ prop = new Properties();
+ try {
+ prop.load(new FileInputStream(workspaceConfPath));
+ } catch (FileNotFoundException e) {
+ // make conf file..
+ File f = new File(workspaceConfPath);
+ try {
+ f.createNewFile();
+ BufferedWriter out = new BufferedWriter(new FileWriter(f));
+ out.write(StringResource.SHOW_SELECTION_DIAGLOG + "=false\n");
+ out.write(StringResource.RECENT_VMS_PATH + "=\n");
+ out.close();
+ prop.load(new FileInputStream(f));
+ } catch (IOException e1) {
+ prop = null;
+ }
+ } catch (IOException e) {
+ prop = null;
+ }
+
+ String show = "false";
+ if (prop != null) {
+ oldShow = prop.getProperty(StringResource.SHOW_SELECTION_DIAGLOG);
+ oldPath = prop.getProperty(StringResource.RECENT_VMS_PATH);
+
+ show = oldShow;
+ if (workspacePath == null) {
+ /* There is no workspace option. */
+ if (show != null) {
+ if (show.equals("true")) {
+ SelectWorkspaceDialog dialog = new SelectWorkspaceDialog(prop);
+ dialog.create();
+ Shell shell = dialog.open();
+ while(!shell.isDisposed()) {
+ if(!Display.getCurrent().readAndDispatch())
+ Display.getCurrent().sleep();
+ }
+
+ if (dialog.isCanceled()) {
+ return false;
+ }
+ workspacePath = dialog.getSelectedPath();
+ show = dialog.isShowDialog() ? "true" : "false";
+ } else if (show.equals("false")) {
+ workspacePath = prop.getProperty(StringResource.RECENT_VMS_PATH);
+ }
+ }
+ }
+ }
+
+ if (workspacePath != null && !workspacePath.isEmpty()) {
+ if (prop != null) {
+ if (show != oldShow) {
+ prop.setProperty(StringResource.SHOW_SELECTION_DIAGLOG, show);
+ isModify = true;
+ }
+
+ if (!workspacePath.equals(oldPath)) {
+ prop.setProperty(StringResource.RECENT_VMS_PATH, workspacePath);
+ isModify = true;
+ }
+ }
+ } else {
+ workspacePath = null;
+ }
+ }
+
+ if (workspacePath != null && !workspacePath.isEmpty()) {
+ File fi = new File(workspacePath + File.separator + "x86");
+ if(!fi.exists()) {
+ boolean result = fi.mkdirs();
+ if(!result) {
+ MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
+ msg.openWarningDialog("Can not organize workspace. Aborting...\n" +
+ "User do not have authority to use [" + workspacePath + "]");
+ EmulatorManager.exitEmulatorManager(-1);
+ }
+ }
+
+ if (isSave && isModify && prop != null) {
+ try {
+ prop.store(new FileOutputStream(workspaceConfPath),null);
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ EmulatorVMs.getInstance().setVMsBaseDirectory(workspacePath);
+ FileIO.setVMSPath();
+ }
+ return true;
+ }
+}
package org.tizen.emulator.manager.tool;
public class StringResource {
-
+ // VMsProperty View
public final static String SUPPORTED = "Supported";
public final static String NOT_SUPPORTED = "Not supported";
-
// key type
public final static String ONE_KEY = "1key";
public final static String THREE_KEYS = "3keys";
-
public final static String ONE_KEY_TYPE = "1Key Type";
public final static String THREE_KEYS_TYPE = "3Keys Type";
+ // Main Dialog
+ public static final String MAIN_TITLE = "Emulator Manager";
+ public static final String MAIN_TITLE_INHOUSE = "Emulator Manager (Inhouse)";
public static final String REFRESH = "Refresh";
public static final String LAUNCH = "Launch";
public static final String MODIFY = "Modify";
public static final String CREATE = "Create";
public static final String CANCEL = "Cancel";
public static final String CONFIRM = "Confirm";
-
+ public static final String OK = "OK";
public static final String DETAIL = "Detail";
public static final String DELETE = "Delete";
public static final String RESET = "Reset";
public static final String CLONE = "Clone";
public static final String CREATE_IMAGE = "Create Base Image";
+
+ // Select Workspace and Dialog
+ public static final String WORKSPACE_NAME = ".tizen_vms_path";
+ public static final String VMS_PATH = "[VMS_PATH]";
+ public static final String SHOW_SELECTION_DIAGLOG = "SHOW_PATH_SELECTION_DIALOG";
+ public static final String RECENT_VMS_PATH="RECENT_VMS_PATH";
+ public static final String SWD_TITLE = "Select VMS path";
+ public static final String SWD_BROWSE = "Browse...";
+ public static final String SWD_ASK_AGAIN = "Use this as the default and do not ask again";
+ public static final String SELECT_DIRECTORY = "Select a Direcory";
+
+ //ArchitectureGroup
+ public static final String GROUP_TITLE = "Emulator Architecture";
+ public static final String X86 = "X86";
+ public static final String x86 = "x86";
+ public static final String ARM = "ARM";
+
+ //About Dialog
+ public static final String ABOUT_PROP_FILENAME = "about.properties";
+ public static final String PROP_KEY_VERSION = "version";
+ public static final String PROP_KEY_BUILD_TIME = "build_time";
+ public static final String PROP_KEY_GIT_VERSION = "build_git_commit";
}
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.tizen.emulator.manager.tool.StringResource;
import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
public class ArchitectureGroup {
group = new Group(archComposite, SWT.NONE);
- group.setText("Emulator Architecture");
+ group.setText(StringResource.GROUP_TITLE);
group.setLayout(new GridLayout(2, false));
x86RadioButton = new Button(group, SWT.RADIO);
x86RadioButton.setData(Architecture.x86);
- x86RadioButton.setText("X86");
+ x86RadioButton.setText(StringResource.X86);
x86RadioButton.setSelection(true);
armRadioButton = new Button(group, SWT.RADIO);
armRadioButton.setData(Architecture.ARM);
- armRadioButton.setText("ARM");
+ armRadioButton.setText(StringResource.ARM);
armRadioButton.setSelection(false);
// TODO : not support ARM
armRadioButton.setEnabled(false);
armRadioButton.addSelectionListener(archSelectionListener);
}
-
public void setLayoutData(Object data) {
group.setLayoutData(data);
}
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
import org.tizen.emulator.manager.ui.detail.VMPropertyView;
-import org.tizen.emulator.manager.ui.vmstree.VMsTree;
import org.tizen.emulator.manager.vms.VMCreateHelper;
import org.tizen.emulator.manager.vms.VMsProperty;
import org.tizen.emulator.manager.vms.VMsWorkerException;
private String vmName = null;
- public CloneDialog(MainDialog mainDialog, VMsTree vmsTree) {
+ public CloneDialog(MainDialog mainDialog, VMsProperty prop) {
this.mainDialog = mainDialog;
- property = vmsTree.getSelectionItem();
+ property = prop;
helper = new VMCreateHelper();
}
public void open() {
dialog = new Shell(mainDialog.getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setText("Emulator Cloning");
- dialog.setSize(300, 180);
+ dialog.setSize(350, 180);
dialog.setLayout(new GridLayout(1, true));
Label info = new Label(dialog, SWT.WRAP);
- info.setText("Create new Emulator\nby copying the selected Emulator.");
+ info.setText("Clone new VM which has the same configurations\nas you selected.");
Label sep = new Label(dialog, SWT.SEPARATOR | SWT.HORIZONTAL);
sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
infoLabel = new Label(dialog, SWT.WRAP);
- infoLabel.setText("");
+ infoLabel.setText("Input new VM-name.");
infoLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
Composite buttonComposite = new Composite(dialog, SWT.NONE);
buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false));
confirmButton = new Button(buttonComposite, SWT.PUSH);
- confirmButton.setText("Confirm");
+ confirmButton.setText(StringResource.CONFIRM);
confirmButton.setImage(ResourceRegistry.getImage(ImageName.CONFIRM));
confirmButton.setEnabled(false);
cancelButton = new Button(buttonComposite, SWT.PUSH);
- cancelButton.setText("Cancel");
+ cancelButton.setText(StringResource.CANCEL);
cancelButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
addListener();
}
@Override
public void widgetSelected(SelectionEvent event) {
- MessageBox msg = new MessageBox(mainDialog.getShell(), SWT.ICON_INFORMATION);
- msg.setText("INFO");
-
+ MessageDialog msg = new MessageDialog();
+ String message = "";
try {
property.getWorker().cloneVM(vmName);
- msg.setMessage("Emulator cloning completed!");
+ message = "Emulator cloning completed!";
} catch (VMsWorkerException e) {
- msg.setMessage(e.getMessage());
+ message = e.getMessage();
}
-
- msg.open();
+
+ msg.openInfoDialog(message);
dialog.close();
mainDialog.refreshProperties();
}
private void checkImageName() {
- if (vmName.length() == VMPropertyView.MAX_NAME_LEN) {
+ if (vmName.length() > VMPropertyView.MAX_NAME_LEN) {
infoLabel.setText("Max length of name is 20.");
confirmButton.setEnabled(false);
return;
return;
}
- infoLabel.setText("");
+ if (vmName.length() == VMPropertyView.MAX_NAME_LEN) {
+ infoLabel.setText("Max length of name is 20.");
+ } else {
+ infoLabel.setText("Input new VM-name.");
+ }
if (vmName.isEmpty()) {
confirmButton.setEnabled(false);
} else {
package org.tizen.emulator.manager.ui;
+import java.io.IOException;
import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
-import org.tizen.emulator.manager.tool.FileIO;
+import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.tool.StringResource;
import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
import org.tizen.emulator.manager.ui.detail.DetailTableView;
import org.tizen.emulator.manager.ui.vmstree.VMsTree;
import org.tizen.emulator.manager.vms.EmulatorVMs;
import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.VMsWorker;
import org.tizen.emulator.manager.vms.VMsWorkerException;
public class MainDialog {
SashForm sashForm;
ArchitectureGroup archGroup;
+ // ToolItems...
+ ToolItem aboutItem;
+ ToolItem refreshItem;
+ ToolItem resetItem;
+ ToolItem deleteItem;
+ ToolItem cloneItem;
+ ToolItem createImageItem;
+// ToolItem modifyItem;
+
+
+ ToolItem x86ToggleItem;
+ ToolItem armToggleItem;
+
// LEFT VIEW
VMsTree vmsTree;
- Button refreshButton;
- Button deleteButton;
- Button resetButton;
// RIGHT VIEW
DetailTableView detailView;
Button rightButton;
MenuHandling handling;
-
+
Shell shell;
Image icon;
public MainDialog(ManagerModeType mode) {
shell = new Shell(Display.getCurrent());
-
shell.setSize(700, 500);
if (mode.equals(ManagerModeType.INHOUSE_MODE)) {
- shell.setText("Emulator Manager (Inhouse)");
+ shell.setText(StringResource.MAIN_TITLE_INHOUSE);
} else {
- shell.setText("Emulator Manager");
+ shell.setText(StringResource.MAIN_TITLE);
}
shell.setLayout(new FillLayout());
mainComposite.setLayout(getNopaddedGridLayout(1, false));
{
+ // Architecture selection group and main SashForm...
+
Composite archComposite = new Composite(mainComposite, SWT.NONE);
- archComposite.setLayout(getNopaddedGridLayout(1, false));
+ GridLayout upperLayout = new GridLayout(2, false);
+ upperLayout.marginWidth = 0;
+ archComposite.setLayout(upperLayout);
archComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ // Top ToolBar
+ ToolBar leftToolBar = new ToolBar(archComposite, SWT.NONE | SWT.RIGHT);
+ leftToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
+ aboutItem = new ToolItem(leftToolBar, SWT.PUSH);
+ ToolItem separator = new ToolItem(leftToolBar, SWT.SEPARATOR);
+ separator.setWidth(10);
+ refreshItem = new ToolItem(leftToolBar, SWT.PUSH);
+ separator = new ToolItem(leftToolBar, SWT.SEPARATOR);
+ separator.setWidth(10);
+// modifyItem = new ToolItem(leftToolBar, SWT.PUSH);
+ resetItem = new ToolItem(leftToolBar, SWT.PUSH);
+ deleteItem = new ToolItem(leftToolBar, SWT.PUSH);
+
+ cloneItem = new ToolItem(leftToolBar, SWT.PUSH);
+ createImageItem = new ToolItem(leftToolBar, SWT.PUSH);
+
+ decorateLeftSideToolItems();
+
+ ToolBar toolBar = new ToolBar(archComposite, SWT.RIGHT);
+ toolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
+ x86ToggleItem = new ToolItem(toolBar, SWT.CHECK);
+ armToggleItem = new ToolItem(toolBar, SWT.CHECK);
- archGroup = new ArchitectureGroup(this, archComposite);
- archGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ decorateRightSideToolItems();
+ // Main SashForm
sashForm = new SashForm(mainComposite, SWT.HORIZONTAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
sashForm.setLayout(new FillLayout());
vmsTree = new VMsTree(this, leftView);
vmsTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Composite buttonComposite = new Composite(leftView, SWT.NONE);
- buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
- buttonComposite.setLayout(new FillLayout());
-
- {
- Label temp = new Label(buttonComposite, SWT.NONE);
- temp.setText("TODO FIX ME");
- temp.setVisible(false);
- temp = new Label(buttonComposite, SWT.NONE);
- temp.setText("TODO FIX ME");
- temp.setVisible(false);
-
- refreshButton = new Button(buttonComposite, SWT.PUSH);
- deleteButton = new Button(buttonComposite, SWT.PUSH);
- resetButton = new Button(buttonComposite, SWT.PUSH);
-
- decorateLeftBottomButtons();
- }
}
// Right : detail table
detailView = new DetailTableView(this);
detailView.createDetailView(shell, rightView);
+ detailView.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+
Composite bottomComposite = new Composite(rightView, SWT.NONE);
GridLayout bottomLayout = getNopaddedGridLayout(2, false);
try {
detailView.getCurrentPoperty().getWorker().launchVM();
} catch (VMsWorkerException e) {
- MessageBox alert = new MessageBox(getShell(), SWT.OK);
- alert.setMessage(e.getMessage());
- alert.open();
+ new MessageDialog().openInfoDialog(e.getMessage());
}
} else if (type.equals(StringResource.CONFIRM)) {
VMsProperty pro = detailView.confirm();
if (pro != null) { // success
refreshProperties();
+ vmsTree.setSelectProperty(pro);
openDetailView(pro);
}
}
}
handling = new MenuHandling(shell, vmsTree);
-
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
}
public void open() {
}
}
-
+
public Shell getShell() {
return shell;
}
-
- public void resetVirtualMachine() {
- handling.resetVirtualMachine();
+ public void resetVM() {
+ handling.resetVirtualMachine(detailView.getCurrentPoperty());
}
- public void cloneVirtualMachine() {
- CloneDialog cloneDialog = new CloneDialog(this, vmsTree);
+ public void cloneVM() {
+ CloneDialog cloneDialog = new CloneDialog(this, detailView.getCurrentPoperty());
cloneDialog.open();
}
// TOOD : error checking
- public void deleteVirtualMachine() {
- if (handling.deleteVirtualMachine()) {
- closeDetailView();
+ public void deleteVM() {
+ if (handling.deleteVirtualMachine(detailView.getCurrentPoperty())) {
refreshProperties();
+ closeDetailView();
}
}
+ public void createBaseImage() {
+ handling.createBaseImage(detailView.getCurrentPoperty());
+ }
+
public void refreshVMsTable() {
vmsTree.refreshContents();
}
public void openDetailView(VMsProperty property) {
if (vmsTree.getSelectionContentCount() == 1) {
- deleteButton.setEnabled(true);
- resetButton.setEnabled(true);
+ setToolBarState(State.TRUE);
} else {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
}
-
+
leftButton.setText(StringResource.MODIFY);
leftButton.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
rightButton.setText(StringResource.LAUNCH);
public void closeDetailView() {
if (vmsTree.getSelectionContentCount() > 1) {
- deleteButton.setEnabled(true);
- resetButton.setEnabled(true);
+ setToolBarState(State.CLOSE_DETAIL);
} else {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
}
detailView.closeDetailView();
}
public void openModifyView(VMsProperty property) {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
leftButton.setText(StringResource.CANCEL);
leftButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
}
public void openCreateDetailView(boolean isDefault) {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
leftButton.setText(StringResource.CREATE);
leftButton.setImage(ResourceRegistry.getImage(ImageName.CREATE));
}
public void openCreateDetailView() {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
leftButton.setText(StringResource.CREATE);
leftButton.setImage(ResourceRegistry.getImage(ImageName.CREATE));
}
public void openCreateView() {
- deleteButton.setEnabled(false);
- resetButton.setEnabled(false);
+ setToolBarState(State.FALSE);
leftButton.setText(StringResource.CANCEL);
leftButton.setImage(ResourceRegistry.getImage(ImageName.CANCEL));
if(icon != null)
icon.dispose();
}
-
+enum State {
+ FALSE, TRUE, CLOSE_DETAIL;
+}
+ private void setToolBarState(State state) {
+ switch(state) {
+ case FALSE:
+ deleteItem.setEnabled(false);
+ resetItem.setEnabled(false);
+ cloneItem.setEnabled(false);
+ createImageItem.setEnabled(false);
+ break;
+ case TRUE:
+ deleteItem.setEnabled(true);
+ resetItem.setEnabled(true);
+ cloneItem.setEnabled(true);
+ createImageItem.setEnabled(true);
+ break;
+ case CLOSE_DETAIL:
+ deleteItem.setEnabled(true);
+ resetItem.setEnabled(true);
+ cloneItem.setEnabled(false);
+ createImageItem.setEnabled(false);
+ break;
+ }
+ }
private GridLayout getNopaddedGridLayout(int numColumns, boolean makeColumnEqualWidth) {
GridLayout layout = new GridLayout(numColumns, makeColumnEqualWidth);
layout.horizontalSpacing = 0;
return layout;
}
- public boolean isX86Selected() {
- return archGroup.x86RadioButton.getSelection();
+ private String getAboutDialogContents() {
+ String version = "";
+ String time = "";
+ String gitVersion = "";
+ String contens = "";
+ String workspace = EmulatorVMs.getInstance().getVMsBaseDirectory();
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(StringResource.ABOUT_PROP_FILENAME );
+ Properties properties = new Properties();
+
+ if(in != null) {
+ try {
+ properties.load(in);
+ } catch (IOException e1) {
+ EMLogger.getLogger().log(Level.SEVERE, e1.getMessage() + "\n");
+ }
+
+ version = properties.getProperty(StringResource.PROP_KEY_VERSION);
+ time = properties.getProperty(StringResource.PROP_KEY_BUILD_TIME);
+ gitVersion = properties.getProperty(StringResource.PROP_KEY_GIT_VERSION);
+ }
+
+ if(version.isEmpty() || version.contains(StringResource.PROP_KEY_VERSION)) {
+ version = "Not identified";
+ }
+ if(time.isEmpty() || time.contains(StringResource.PROP_KEY_BUILD_TIME)) {
+ time = "Not identified";
+ }
+ if(gitVersion.isEmpty() || gitVersion.contains(StringResource.PROP_KEY_GIT_VERSION)) {
+ gitVersion = "Not identified";
+ }
+ if(workspace.isEmpty()) {
+ workspace = "Not identified";
+ }
+
+ contens = "Version : TIZEN " + version + "\nBuild time : " + time + " (GMT)" +
+ "\nGit version : "+ gitVersion + "\nWorkspace path : " + workspace;
+
+ return contens;
}
- private void decorateLeftBottomButtons() {
- refreshButton.setText(StringResource.REFRESH);
- refreshButton.setToolTipText("refresh list of virtual machine");
- refreshButton.setImage(ResourceRegistry.getImage(ImageName.REFRESH));
- refreshButton.addSelectionListener(new SelectionListener() {
+ private void decorateLeftSideToolItems() {
+ aboutItem.setImage(ResourceRegistry.getImage(ImageName.ABOUT));
+ aboutItem.setToolTipText("About Emulator Manager");
+ aboutItem.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ new MessageDialog().openInfoDialog("About Emulator Manager",getAboutDialogContents());
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+
+ refreshItem.setImage(ResourceRegistry.getImage(ImageName.REFRESH));
+ refreshItem.setToolTipText("refresh list of VM");
+ refreshItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshProperties();
public void widgetDefaultSelected(SelectionEvent e) {}
});
- deleteButton.setText(StringResource.DELETE);
- deleteButton.setToolTipText("delete selected virtual machine");
- deleteButton.setImage(ResourceRegistry.getImage(ImageName.DELETE));
- deleteButton.addSelectionListener(new SelectionListener() {
+ cloneItem.setText(StringResource.CLONE);
+ cloneItem.setImage(ResourceRegistry.getImage(ImageName.CLONE));
+ cloneItem.setToolTipText("Clone from selected VM");
+ cloneItem.setEnabled(false);
+ cloneItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- deleteVirtualMachine();
+ cloneVM();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+
+// modifyItem.setText("Modify");
+// modifyItem.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
+// modifyItem.setToolTipText("Modify selected VM");
+// modifyItem.addSelectionListener(new SelectionListener() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// modifyVM(vmsTree.getSelectionItem());
+// }
+// @Override
+// public void widgetDefaultSelected(SelectionEvent e) {
+// }
+// });
+
+ resetItem.setText(StringResource.RESET);
+ resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
+ resetItem.setToolTipText("Format OS of selected VM");
+ resetItem.setEnabled(false);
+ resetItem.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ resetVM();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
- resetButton.setText(StringResource.RESET);
- resetButton.setToolTipText("format os of virtual machine");
- resetButton.setImage(ResourceRegistry.getImage(ImageName.RESET));
- resetButton.addSelectionListener(new SelectionListener() {
+ deleteItem.setText(StringResource.DELETE);
+ deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
+ deleteItem.setToolTipText("Delete selected VM");
+ deleteItem.setEnabled(false);
+ deleteItem.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+ public void widgetSelected(SelectionEvent e) {
+ deleteVM();
}
-
@Override
- public void widgetSelected(SelectionEvent arg0) {
- resetVirtualMachine();
+ public void widgetDefaultSelected(SelectionEvent e) {
}
-
});
+
+ createImageItem.setText(StringResource.CREATE_IMAGE);
+ createImageItem.setImage(ResourceRegistry.getImage(ImageName.CREATEIMAGE));
+ createImageItem.setToolTipText("Create new base image from selected VM");
+ createImageItem.setEnabled(false);
+ createImageItem.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ createBaseImage();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
}
-
- public void createBaseImage() {
- MessageBox msg = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
- msg.setText("Warning");
- msg.setMessage("This process may take about 30 to 60 seconds.\nAre you sure you want to continue?");
-
- int response = msg.open();
- if (response != SWT.OK) {
- return;
- }
-
- VMsProperty property = vmsTree.getSelectionItem();
- FileDialog fd = new FileDialog(shell, SWT.SAVE);
- fd.setText("Create 'Base Image' As");
- String[] filter = {"*."+ property.getArch().toString()};
- String[] filterName = {"Image Files(*." + property.getArch().toString() + ")"};
- fd.setFilterExtensions(filter);
- fd.setFilterNames(filterName);
- fd.setFileName("emulimg-" + property.getName());
- fd.setFilterPath(FileIO.getInstance().getTizenVmsPath());
-
- msg = new MessageBox(shell, SWT.ICON_INFORMATION);
- msg.setText("Info");
-
- String path = null;
- path = fd.open();
- if (path == null) {
- msg.setMessage("Task has canceled");
- msg.open();
- return;
- }
-
- VMsWorker worker = new VMsWorker(property);
- try {
- worker.createNewBaseImage(property, path);
- msg.setMessage("Succeeded to create 'Base Image'!\nPath: " + path);
- } catch (VMsWorkerException e) {
- msg.setMessage(e.getMessage());
- }
- msg.open();
+
+ private void decorateRightSideToolItems() {
+ x86ToggleItem.setText(StringResource.x86);
+ x86ToggleItem.setImage(ResourceRegistry.getImage(ImageName.X86));
+ x86ToggleItem.setToolTipText("x86 Architecture");
+ x86ToggleItem.setSelection(true);
+ x86ToggleItem.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ x86ToggleItem.setSelection(true);
+ refreshProperties();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ });
+
+ armToggleItem.setText(StringResource.ARM);
+ armToggleItem.setImage(ResourceRegistry.getImage(ImageName.ARM));
+ armToggleItem.setToolTipText("ARM Architecture");
+ armToggleItem.setSelection(false);
+ armToggleItem.setEnabled(false);
}
}
package org.tizen.emulator.manager.ui;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.tool.FileIO;
import org.tizen.emulator.manager.ui.vmstree.VMsTree;
import org.tizen.emulator.manager.vms.VMsProperty;
import org.tizen.emulator.manager.vms.VMsWorkerException;
this.vmsTree = vmsTree;
}
- public void resetVirtualMachine() {
- MessageBox msg = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
- msg.setText("Warning");
- msg.setMessage("This VM will be formatting.\nAre you sure you want to continue?");
-
- int response = msg.open();
-
+ public void resetVirtualMachine(VMsProperty prop) {
+ MessageDialog msg = new MessageDialog();
+ int response = msg.openSelectionDialog("This VM will be formatted.\nAre you sure you want to continue?");
+
if (response != SWT.OK)
return;
-
- msg = new MessageBox(shell, SWT.ICON_INFORMATION);
- msg.setText("INFO");
-
+
VMsProperty[] properties = vmsTree.getSelectionItems();
+ if (properties.length == 0) {
+ properties = new VMsProperty[1];
+ properties[0] = prop;
+ }
for (VMsProperty property : properties) {
if(property.getWorker().isRunningNow()) {
- msg.setMessage("[" + property.getName() + "] is running now...\n" +
- "Reset process is canceled !");
- msg.open();
-
+ msg.openInfoDialog("Canceled reset process!\n" + "[" + property.getName() + "] is running now...");
return;
}
}
try {
property.getWorker().resetVM();
} catch (VMsWorkerException e) {
- msg.setMessage(" Reset [" + property.getName() + "] failed...\n"
+ msg.openInfoDialog(" Reset [" + property.getName() + "] failed...\n"
+ e.getMessage());
- msg.open();
-
- break;
+ return;
}
}
- msg.setMessage("Reset process completed !");
- msg.open();
+ msg.openInfoDialog("Completed reset process!");
}
- public boolean deleteVirtualMachine() {
- MessageBox msg = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
- msg.setText("INFO");
- msg.setMessage("Are you sure you want to delete selected VM?");
-
-
- int response = msg.open();
+ public boolean deleteVirtualMachine(VMsProperty prop) {
+ MessageDialog msg = new MessageDialog();
+ int response = msg.openSelectionDialog("Are you sure you want to delete selected VM?");
if (response != SWT.OK)
return false;
-
- msg = new MessageBox(shell, SWT.ICON_INFORMATION);
- msg.setText("INFO");
VMsProperty[] properties = vmsTree.getSelectionItems();
+ if (properties.length == 0) {
+ properties = new VMsProperty[1];
+ properties[0] = prop;
+ }
for (VMsProperty property : properties) {
if(property.getWorker().isRunningNow()) {
- msg.setMessage("[" + property.getName() + "] is running now...\n" +
- "Delete process is canceled !");
- msg.open();
-
+ msg.openInfoDialog("Canceled delete process!\n" + "[" + property.getName() + "] is running now...");
return false;
}
}
try {
property.getWorker().deleteVM();
} catch (VMsWorkerException e) {
- msg.setMessage(" Delete [" + property.getName() + "] failed...\n"
+ msg.openInfoDialog(" Delete [" + property.getName() + "] failed...\n"
+ e.getMessage());
- msg.open();
-
return false;
}
}
-
- msg.setMessage("Delete process completed !");
- msg.open();
-
+
+ msg.openInfoDialog("Completed delete process!");
+
return true;
}
+
+ public void createBaseImage(VMsProperty prop) {
+ MessageDialog msg = new MessageDialog();
+ VMsProperty property = prop;
+ if(prop.getWorker().isRunningNow()) {
+ msg.openWarningDialog("Can not 'Create Base Image' while source VM is running.");
+ return ;
+ }
+
+ FileDialog fd = new FileDialog(shell, SWT.SAVE);
+ fd.setText("Create 'Base Image' As");
+ String[] filter = {"*."+ property.getArch().toString()};
+ String[] filterName = {"Image Files(*." + property.getArch().toString() + ")"};
+ fd.setFilterExtensions(filter);
+ fd.setFilterNames(filterName);
+ fd.setFileName("emulimg-" + property.getName());
+ fd.setFilterPath(FileIO.getInstance().getTizenVmsPath());
+
+ String path = null;
+ path = fd.open();
+ if (path == null) {
+ return;
+ }
+
+ String returnMSG = "";
+ try {
+ property.getWorker().createNewBaseImage(property, path);
+ returnMSG = "Succeeded to create 'Base Image'!\nPath: " + path;
+ } catch (VMsWorkerException e) {
+ returnMSG =e.getMessage();
+ }
+ msg.openInfoDialog(returnMSG);
+ }
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.EmulatorManager;
+
+public class MessageDialog
+{
+ private Shell shell;
+ public MessageDialog() {
+ this.shell = EmulatorManager.getInstance().getMainDialog().getShell();
+ }
+
+ public MessageDialog(Shell shell) {
+ if (shell == null) {
+ this.shell = new Shell();
+ } else {
+ this.shell = shell;
+ }
+ }
+
+ public int openInfoDialog(final String message) {
+ return openInfoDialog("Info", message);
+ }
+
+ public int openInfoDialog(final String title, final String message) {
+ return openMessageDialog(title, message, SWT.OK | SWT.MODELESS | SWT.ICON_INFORMATION);
+ }
+
+ public int openWarningDialog(final String message) {
+ return openWarningDialog("Warning", message);
+ }
+
+ public int openWarningDialog(final String title, final String message) {
+ return openMessageDialog(title, message, SWT.OK | SWT.MODELESS | SWT.ICON_WARNING);
+ }
+
+ public int openSelectionDialog(final String message) {
+ return openSelectionDialog("Warning", message);
+ }
+
+ public int openSelectionDialog(final String title, final String message) {
+ return openMessageDialog(title, message, SWT.OK | SWT.CANCEL | SWT.MODELESS | SWT.ICON_WARNING);
+ }
+
+ int msgResponse = 0;
+ public int openMessageDialog(final String title, final String message, final int style) {
+ MessageBox dialog = new MessageBox(shell, style);
+ dialog.setText(title);
+ dialog.setMessage(message);
+ msgResponse = dialog.open();
+ return msgResponse;
+ }
+}
public class ResourceRegistry {
public enum ImageName {
CANCEL("cancel"), CONFIRM("confirm"), CREATE("create"), DELETE("delete"), DETAILS("details"),
- FOLDER("folder"), MODIFY("modify"), REFRESH("refresh"), RESET("reset"), LAUNCH("launch"), CLONE("clone");
+ FOLDER("folder"), MODIFY("modify"), REFRESH("refresh"), RESET("reset"), LAUNCH("launch"), CREATEIMAGE("createimage"),
+ ABOUT("about"), CLONE("clone"), ARM("arm"), X86("x86");
String name;
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.ui;
+
+import java.util.Properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.vms.EmulatorVMs;
+
+public class SelectWorkspaceDialog {
+ private Shell dialog;
+ private String selectedPath = null;
+ private boolean showDialog = true;
+ private Properties prop = null;
+
+ private Button askButton;
+ private Button browseButton;
+ private Text pathText;
+
+ private Button cancelButton;
+ private Button okButton;
+
+ private boolean isCanceled = true;
+
+ public SelectWorkspaceDialog(Properties prop) {
+ this.prop = prop;
+ }
+
+ public void create() {
+ dialog = new Shell(Display.getCurrent(), SWT.CLOSE);
+ dialog.setText(StringResource.SWD_TITLE);
+ dialog.setSize(500, 180);
+ GridLayout layout = new GridLayout(1, false);
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginBottom = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginWidth = 0;
+ dialog.setLayout(layout);
+
+ Composite labelComposite = new Composite(dialog, SWT.NONE);
+ labelComposite.setLayout(new FillLayout());
+ labelComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ Label label = new Label(dialog, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
+ label.setText(" Emulator Manager stores your VM list in a folder.\n" +
+ " Choose a folder to use for this session");
+ label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+
+ Label sep = new Label(dialog, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+
+ Composite browseComposite = new Composite(dialog, SWT.NONE);
+ browseComposite.setLayout(new GridLayout(2, false));
+ browseComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+
+ pathText = new Text(browseComposite, SWT.BORDER);
+ if (prop == null || prop.getProperty(StringResource.RECENT_VMS_PATH).isEmpty()) {
+ selectedPath = EmulatorVMs.getInstance().getVMsBaseDirectory();
+ } else {
+ selectedPath =prop.getProperty(StringResource.RECENT_VMS_PATH);
+ }
+ pathText.setText(selectedPath);
+
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ browseButton = new Button(browseComposite, SWT.PUSH);
+ browseButton.setText(StringResource.SWD_BROWSE);
+
+ Composite bottomComposite = new Composite(dialog, SWT.NONE);
+ bottomComposite.setLayout(new GridLayout(3, false));
+ bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, true));
+
+ askButton = new Button(bottomComposite, SWT.CHECK);
+ askButton.setText(StringResource.SWD_ASK_AGAIN);
+
+ new Label(bottomComposite, SWT.NONE);
+ new Label(bottomComposite, SWT.NONE);
+
+ new Label(bottomComposite, SWT.NONE);
+
+ cancelButton = new Button(bottomComposite, SWT.PUSH);
+ cancelButton.setText(StringResource.CANCEL);
+ cancelButton.setSize(100, SWT.NONE);
+ cancelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ okButton = new Button(bottomComposite, SWT.PUSH);
+ okButton.setText(StringResource.OK);
+ okButton.setSize(100, SWT.NONE);
+ okButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ addListener();
+
+ }
+
+ private void addListener() {
+ dialog.addListener(SWT.Close, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (isCanceled) {
+ showDialog = true;
+ selectedPath = null;
+ setCanceled(true);
+ }
+ }
+
+ });
+
+ browseButton.addSelectionListener(new SelectionListener(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dd = new DirectoryDialog(dialog, SWT.OPEN);
+ dd.setText(StringResource.SELECT_DIRECTORY);
+ selectedPath = dd.open();
+ if (selectedPath != null) {
+ pathText.setText(selectedPath);
+ }
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ askButton.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ showDialog = !askButton.getSelection();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+
+ cancelButton.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isCanceled = true;
+ dialog.close();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ okButton.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isCanceled = false;
+ dialog.close();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+ }
+
+ public Shell open() {
+ dialog.open();
+ return dialog;
+ }
+
+ public String getSelectedPath() {
+ return selectedPath;
+ }
+
+ public boolean isShowDialog() {
+ return showDialog;
+ }
+
+ public boolean isCanceled() {
+ return isCanceled;
+ }
+
+ public void setCanceled(boolean isCanceled) {
+ this.isCanceled = isCanceled;
+ }
+}
\ No newline at end of file
package org.tizen.emulator.manager.ui.detail;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
public void createDetailView(Shell shell, Composite rightView) {
detailTable = new Table(rightView, SWT.BORDER);
- detailTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
detailTable.setHeaderVisible(true);
- detailTable.setLinesVisible(true);
+ detailTable.setLinesVisible(false);
detailTable.addListener(SWT.MeasureItem, new Listener() {
@Override
public void handleEvent(Event event) {
public VMsProperty confirm() {
return vmView.confirm();
}
+
+ public void setLayoutData(Object data) {
+ detailTable.setLayoutData(data);
+ }
}
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.tool.CheckVirtualization;
import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.ui.ResourceRegistry;
import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
import org.tizen.emulator.manager.vms.Creator;
enum CItem{
ImageName("Name"), ImageNameInfo(""), BaseImage("BaseImage"),
Resolution("Display Resolution"), Density("Display Density"), SkinType("Front Key Type"),
- SDType("SDCard"), SDPath("SDCard Path"), RAMSize("RAM Size"),
+ RAMSize("RAM Size"),
ShareType("File Sharing"), SharePath("File Sharing Path"), HWVirtual("HW Virtualization"),
TouchType("Max Touch Point");
enum DItem{
ImageName("Name"), BaseImage("BaseImage"),
Resolution("Display Resolution"), Density("Display Density"), SkinType("Front Key Type"),
- SDType("SDCard"), SDPath("SDCard Path"), RAMSize("RAM Size"),
+ RAMSize("RAM Size"),
ShareType("File Sharing"), SharePath("File Sharing Path"), HWVirtual("HW Virtualization"),
TouchType("Max Touch Point"), Dummy("");
widget.itemList.get(DItem.SkinType.ordinal()).setText(1, oldValue.keyType == 1
? StringResource.ONE_KEY_TYPE : StringResource.THREE_KEYS_TYPE);
- widget.itemList.get(DItem.SDType.ordinal()).setText(1, oldValue.isSDCardSupport
- ? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED);
- widget.itemList.get(DItem.SDPath.ordinal()).setText(1, oldValue.SDCardPathName);
-
widget.itemList.get(DItem.RAMSize.ordinal()).setText(1, String.valueOf(oldValue.ramSize));
widget.itemList.get(DItem.ShareType.ordinal()).setText(1,oldValue.isFileShareSupport
? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED);
widget.itemList.get(DItem.SharePath.ordinal()).setText(1, oldValue.fileSharePathName);
- widget.itemList.get(DItem.HWVirtual.ordinal()).setText(1, oldValue.isHWVirtualization && helper.isSupportVirtualization()
+ widget.itemList.get(DItem.HWVirtual.ordinal()).setText(1, oldValue.isHWVirtualization && CheckVirtualization.getInstance().isSupportVirtualization()
? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED);
if (managerMode.equals(ManagerModeType.INHOUSE_MODE)) {
// TODO : please !!!
widget.itemList.get(CItem.SkinType.ordinal()).setText(1, StringResource.ONE_KEY_TYPE);
- widget.itemList.get(CItem.SDType.ordinal()).setText(1, StringResource.NOT_SUPPORTED);
- widget.itemList.get(CItem.SDPath.ordinal()).setText(1, oldValue.SDCardPathName);
-
widget.itemList.get(CItem.RAMSize.ordinal()).setText(1, String.valueOf(oldValue.ramSize));
widget.itemList.get(CItem.ShareType.ordinal()).setText(1, StringResource.NOT_SUPPORTED);
widget.itemList.get(CItem.SharePath.ordinal()).setText(1, oldValue.fileSharePathName);
- widget.itemList.get(CItem.HWVirtual.ordinal()).setText(1, oldValue.isHWVirtualization && helper.isSupportVirtualization()
+ widget.itemList.get(CItem.HWVirtual.ordinal()).setText(1, oldValue.isHWVirtualization && CheckVirtualization.getInstance().isSupportVirtualization()
? StringResource.SUPPORTED : StringResource.NOT_SUPPORTED);
if (managerMode.equals(ManagerModeType.INHOUSE_MODE)) {
createNameArea(table);
createBaseImageArea(table);
createDisplayArea(table);
- createSDCardArea(table);
createRAMSizeArea(table);
createFileShareArea(table);
createHWVirtualArea(table);
createNameArea(table);
createBaseImageArea(table);
createDisplayArea(table);
- createSDCardArea(table);
createRAMSizeArea(table);
createFileShareArea(table);
createHWVirtualArea(table);
editor = new TableEditor(table);
editor.grabHorizontal = true;
- editor.setEditor(widget.SDCardTypeCombo, widget.itemList.get(DItem.SDType.ordinal()), 1);
editor = new TableEditor(table);
editor.grabHorizontal = true;
- editor.setEditor(widget.SDCardPathCombo, widget.itemList.get(DItem.SDPath.ordinal()), 1);
editor = new TableEditor(table);
editor.grabHorizontal = true;
editor = new TableEditor(table);
editor.grabHorizontal = true;
editor.setEditor(widget.skinTypeCombo, widget.itemList.get(CItem.SkinType.ordinal()), 1);
-
- editor = new TableEditor(table);
- editor.grabHorizontal = true;
- editor.setEditor(widget.SDCardTypeCombo, widget.itemList.get(CItem.SDType.ordinal()), 1);
-
- editor = new TableEditor(table);
- editor.grabHorizontal = true;
- editor.setEditor(widget.SDCardPathCombo, widget.itemList.get(CItem.SDPath.ordinal()), 1);
editor = new TableEditor(table);
editor.grabHorizontal = true;
}
private void checkImageName() {
- if (newValue.imageName.length() == MAX_NAME_LEN) {
+ if (newValue.imageName.length() > MAX_NAME_LEN) {
widget.nameinfoLabel.setText("Max length is 20.");
widget.confirmButton.setEnabled(false);
return;
return;
}
- widget.nameinfoLabel.setText("");
+ if (newValue.imageName.length() == MAX_NAME_LEN) {
+ widget.nameinfoLabel.setText("Max length is 20.");
+ } else {
+ widget.nameinfoLabel.setText("");
+ }
if (newValue.imageName.isEmpty()) {
widget.confirmButton.setEnabled(false);
} else {
DisplayResoultion.getInstance().findIndex(oldValue.resolution));
widget.DIPspinner = new Spinner(table, SWT.BORDER);
widget.DIPspinner.setValues(oldValue.dpi, 100, 480, 0, 1, 1);
+ widget.DIPspinner.setTextLimit(3);
if (!isCreateMode) {
widget.DIPspinner.setEnabled(false);
}
*/
}
});
-
+
// TODO
widget.skinTypeCombo.addSelectionListener(new SelectionListener() {
@Override
if (i == 0) {// 1key type
newValue.keyType = 1;
} else if (i == 1) { // 3key type
- MessageBox msg = new MessageBox(table.getShell(), SWT.ICON_WARNING);
- msg.setText("Warning");
- msg.setMessage("Check platform of emulator supports 3 keys(Call/Home/End)\n"
- +"If platform has not support 3 keys, just change emulator skin.");
- msg.open();
+ MessageDialog msg = new MessageDialog();
+ msg.openWarningDialog("Pleaes check wheter platform of Emulator supports 3 keys(Call/Home/End).\n"
+ +"If the platform does not support 3 keys, only emulator skin is changed.");
newValue.keyType = 3;
}
if (!isCreateMode) {
});
}
- private void createSDCardArea(final Table table) {
- widget.SDCardTypeCombo = helper.makeCombo(table);
- helper.addComboItem(widget.SDCardTypeCombo, SupportType.getInstance().getList());
- widget.SDCardTypeCombo.select(oldValue.isSDCardSupport == true ? 0 : 1);
-
- widget.SDCardPathCombo = helper.makeCombo(table);
- helper.addComboItem(widget.SDCardPathCombo, SDCard.getInstance().getList());
- widget.SDCardPathCombo.add(oldValue.SDCardPathName, 0);
- widget.SDCardPathCombo.add("-----------------------------------------------", 1);
- widget.SDCardPathCombo.add("--Select existing SDCard", SDCard.getInstance().size() + 2);
- widget.SDCardPathCombo.select(0);
- widget.SDCardPathCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- widget.SDCardPathCombo.setEnabled(oldValue.isSDCardSupport);
-
- createSDCardListener();
- }
-
- private void createSDCardListener() {
- widget.SDCardTypeCombo.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = widget.SDCardTypeCombo.getSelectionIndex();
- if (index == 0) { // supported
- newValue.isSDCardSupport = true;
- widget.SDCardPathCombo.setEnabled(true);
- } else if (index == 1) { // not supported
- newValue.isSDCardSupport = false;
- widget.SDCardPathCombo.setEnabled(false);
- }
-
- if (!isCreateMode) {
- checkModifyState();
- }
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- widget.SDCardPathCombo.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int i = widget.SDCardPathCombo.getSelectionIndex();
- if (i == SDCard.getInstance().size() + 2) { // Select Exist SDCard
- if (widget.SDImageFD == null) {
- widget.SDImageFD = new FileDialog(table.getShell(), SWT.OPEN);
- widget.SDImageFD.setText("Select an existing SD card");
- String[] filter = {"*.img"};
- String[] filterName = {"SD Card Image Files(*.img)"};
- widget.SDImageFD.setFilterExtensions(filter);
- widget.SDImageFD.setFilterNames(filterName);
- }
- String path = widget.SDImageFD.open();
- if(path != null) {
- newValue.SDCardPath = path;
- newValue.SDCardPathName = path.substring(path.lastIndexOf(SEFARATOR) + 1, path.length());
- }
- } else if (i != 0 && i != 1) {
- newValue.SDCardPath = widget.SDCardPathCombo.getItem(i);
- newValue.SDCardPathName = widget.SDCardPathCombo.getItem(i);
- }
-
- widget.SDCardPathCombo.remove(0);
- widget.SDCardPathCombo.add(newValue.SDCardPathName, 0);
- widget.SDCardPathCombo.select(0);
-
- if (!isCreateMode) {
- checkModifyState();
- }
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- }
-
private void createRAMSizeArea(Table table) {
widget.ramSizeCombo = helper.makeCombo(table);
helper.addComboItem(widget.ramSizeCombo, RamSize.getInstance().getList(),
private void createHWVirtualArea(final Table table) {
widget.HWVirtualCombo = helper.makeCombo(table);
helper.addComboItem(widget.HWVirtualCombo, SupportType.getInstance().getList());
- widget.HWVirtualCombo.select(oldValue.isHWVirtualization && helper.isSupportVirtualization()
+ widget.HWVirtualCombo.select(oldValue.isHWVirtualization && CheckVirtualization.getInstance().isSupportVirtualization()
? 0 : 1);
- if (!helper.isSupportVirtualization()) {
+ if (!CheckVirtualization.getInstance().isSupportVirtualization()) {
widget.HWVirtualCombo.setEnabled(false);
}
public VMsProperty confirm() {
VMsProperty p = null;
- MessageBox msg = new MessageBox(table.getShell(), SWT.ICON_INFORMATION);
- msg.setText("INFO");
+ MessageDialog msg = new MessageDialog();
+ String message = "";
try {
if (isCreateMode) {
p = Creator.create(newValue);
- msg.setMessage("Succeeded to create the VM!");
+ message= "Succeeded to create the VM!";
}
else {
property.getWorker().modifyVM(oldValue, newValue);
p = property;
- msg.setMessage("Succeeded to modify the VM!");
+ message = "Succeeded to modify the VM!";
}
} catch (VMsWorkerException e) {
- msg.setMessage(e.getMessage());
+ message = e.getMessage();
}
-
- msg.open();
+
+ msg.openInfoDialog(message);
return p;
}
public Spinner DIPspinner;
public Combo skinTypeCombo;
- public Combo SDCardTypeCombo;
- public Combo SDCardPathCombo;
- public FileDialog SDImageFD;
-
public Combo ramSizeCombo;
public Combo shareTypeCombo;
resolutionCombo.dispose();
DIPspinner.dispose();
skinTypeCombo.dispose();
- SDCardTypeCombo.dispose();
- SDCardPathCombo.dispose();
ramSizeCombo.dispose();
shareTypeCombo.dispose();
selectShareFolderButton.dispose();
import java.util.ArrayList;
-import org.tizen.emulator.manager.vms.VMCreateHelper;
+import org.tizen.emulator.manager.tool.StringResource;
class StringArrayResource
{
private SupportType()
{
- add(0, "Supported");
- add(1, "Not supported");
+ add(0, StringResource.SUPPORTED);
+ add(1, StringResource.NOT_SUPPORTED);
setDefaultIndex(1);
}
}
}
-class SkinPath extends StringArrayResource
-{
- private static SkinPath skinPath = new SkinPath();
- public static SkinPath getInstance() {
- return skinPath;
- }
-
- private SkinPath() {
- ArrayList<String> list = new VMCreateHelper().makeSkinfolderList();
- int index = 0;
- for (String s : list) {
- add(index++, s);
- }
- }
-
- public int findIndex(String r) {
- String[] strArray = getList();
- String s = null;
- // TODO:
- r = "emul_" + r;
- for (int i = 0; i < strArray.length; i++) {
- s = strArray[i];
- if (s.equals(r)) {
- return i;
- }
- }
- return getDefaultIndex();
- }
-}
-
-class SDCard extends StringArrayResource
-{
- private static SDCard capacity = new SDCard();
- public static SDCard getInstance()
- {
- return capacity;
- }
-
- private SDCard()
- {
- add(0, "sdcard_256.img (256MB)");
- add(1, "sdcard_512.img (512MB)");
- add(2, "sdcard_1024.img (1024MB)");
- add(3, "sdcard_1536.img (1536MB)");
-
- setDefaultIndex(1);
- }
-
- public int findIndex(String type) {
- String[] strArray = getList();
- String s = null;
- for (int i = 0; i < strArray.length; i++) {
- s = strArray[i];
- if (s.contains(type)) {
- return i;
- }
- }
- return getDefaultIndex();
- }
-}
-
class RamSize extends StringArrayResource
{
private static RamSize size = new RamSize();
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.ui.ResourceRegistry;
import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
import org.tizen.emulator.manager.vms.VMsProperty;
try {
property.getWorker().launchVM();
} catch (VMsWorkerException e) {
- MessageBox alert = new MessageBox(EmulatorManager.getInstance().getMainDialog().getShell(), SWT.OK);
- alert.setMessage(e.getMessage());
- alert.open();
+ new MessageDialog().openInfoDialog(e.getMessage());
}
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
}
});
+
final MenuItem modifyItem = new MenuItem(treeMenu, SWT.NONE);
modifyItem.setText(StringResource.MODIFY);
modifyItem.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
EmulatorManager.getInstance().getMainDialog().openModifyView(property);
}
});
- final MenuItem deleteItem = new MenuItem(treeMenu, SWT.NONE);
- deleteItem.setText(StringResource.DELETE);
- deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
- deleteItem.addSelectionListener(new SelectionListener() {
+
+ new MenuItem(treeMenu, SWT.SEPARATOR);
+
+ final MenuItem resetItem = new MenuItem(treeMenu, SWT.NONE);
+ resetItem.setText(StringResource.RESET);
+ resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
+ resetItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
@Override
public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().deleteVirtualMachine();
+ EmulatorManager.getInstance().getMainDialog().resetVM();
}
});
- final MenuItem resetItem = new MenuItem(treeMenu, SWT.NONE);
- resetItem.setText(StringResource.RESET);
- resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
- resetItem.addSelectionListener(new SelectionListener() {
+
+ final MenuItem deleteItem = new MenuItem(treeMenu, SWT.NONE);
+ deleteItem.setText(StringResource.DELETE);
+ deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
+ deleteItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
@Override
public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().resetVirtualMachine();
+ EmulatorManager.getInstance().getMainDialog().deleteVM();
}
-
});
new MenuItem(treeMenu, SWT.SEPARATOR);
@Override
public void widgetSelected(SelectionEvent arg0) {
- EmulatorManager.getInstance().getMainDialog().cloneVirtualMachine();
+ EmulatorManager.getInstance().getMainDialog().cloneVM();
}
});
final MenuItem createImageItem = new MenuItem(treeMenu, SWT.NONE);
createImageItem.setText(StringResource.CREATE_IMAGE);
+ createImageItem.setImage(ResourceRegistry.getImage(ImageName.CREATEIMAGE));
createImageItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
class CreateMarker implements TreeMarker {
public CreateMarker(TreeItem item) {
- item.setText("<< Create new... >> ");
+ item.setText("<< Create new... >>");
Font font = ResourceRegistry.getFont(SWT.BOLD);
if(font == null) {
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
-import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.ui.MainDialog;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.vms.EmulatorVMs;
import org.tizen.emulator.manager.vms.VMsProperty;
import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
EmulatorVMs fsImage = EmulatorVMs.getInstance();
- public VMsTree(MainDialog mainDialog, Composite parent) {
+ public VMsTree(final MainDialog mainDialog, Composite parent) {
this.mainDialog = mainDialog;
this.vmsTree = new Tree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
}
refreshContents();
- pack();
+ packAll();
+ packAll(); // FIXME: Need second pack avoid column becomes too narrow... why ???
contextMenu.prepare(vmsTree);
Menu tableMenu = contextMenu.getMenu();
if (vmsTree.getSelection()[0].getData() instanceof CreateMarker) {
if (vmsTree.getSelection()[0].getParentItem().getText().equals("Custom")) {
- VMsTree.this.mainDialog.openCreateDetailView(false);
+ mainDialog.openCreateDetailView(false);
} else {
- VMsTree.this.mainDialog.openCreateDetailView(true);
+ mainDialog.openCreateDetailView(true);
}
return;
}
if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) {
- VMsTree.this.mainDialog.closeDetailView();
+ mainDialog.closeDetailView();
return;
}
PropertyContent content = (PropertyContent)data;
- VMsTree.this.mainDialog.openDetailView(content.property);
+ mainDialog.openDetailView(content.property);
}
}
try {
property.getWorker().launchVM();
} catch (VMsWorkerException e) {
- MessageBox alert = new MessageBox(EmulatorManager.getInstance().getMainDialog().getShell(), SWT.OK);
- alert.setMessage(e.getMessage());
- alert.open();
+ new MessageDialog().openInfoDialog(e.getMessage());
}
}
});
return;
}
}
- EmulatorManager.getInstance().getMainDialog().deleteVirtualMachine();
+ mainDialog.deleteVM();
}
}
});
}
- private void pack() {
+ private void packAll() {
for(TreeColumn column : vmsTree.getColumns()) {
column.pack();
}
RowItem rowItem = null;
// FIXME !!
- // TODO: We insert "1.0" now...
+ // TODO: We insert "Tizen Larkspur" now...
TreeItem tempItem = new TreeItem(vmsTree, SWT.NONE);
- rowItem = new StandardVMsMarker("1.0", tempItem);
+ rowItem = new StandardVMsMarker("TIZEN Larkspur", tempItem);
tempItem.setData(rowItem);
Map<String, TreeItem> itemsMap = new HashMap<String, TreeItem>();
- itemsMap.put("1.0", tempItem);
+ itemsMap.put("TIZEN Larkspur", tempItem);
TreeItem createItem = new TreeItem(tempItem, SWT.NONE);
rowItem = new CreateMarker(createItem);
public void setLayoutData(Object data) {
vmsTree.setLayoutData(data);
}
-}
\ No newline at end of file
+
+ public void setSelectProperty(VMsProperty property) {
+ Object data;
+ vmsTree.deselectAll();
+ for (TreeItem item : vmsTree.getItems()) {
+ for (TreeItem i : item.getItems()) {
+ data = i.getData();
+ if (data instanceof TreeMarker) {
+ continue;
+ }
+ if (((PropertyContent)data).getProperty().getName().equals(property.getName())) {
+ vmsTree.select(i);
+ break;
+ }
+ }
+ }
+ }
+}
createFileShare();
createDisplay();
createRam();
- createSDCard();
createHWVirtualization();
}
catch(VMsCreatorException e) {
private void createRam() {}
- private void createSDCard() throws VMsCreatorException {
- if (newVM.isSDCardSupport) {
- try {
- Modifier.modifySDCard(newVM);
- } catch (VMsWorkerException e) {
- throw new VMsCreatorException(e.getMessage());
- }
- }
- }
-
private void createHWVirtualization() {}
private void settingProperty() {
if (newVM.isDefaultImage) {
ec.getBaseInformation().getDiskImage().setType("standard");
// TODO : get version
- ec.getBaseInformation().getDiskImage().setVersion("1.0");
+ ec.getBaseInformation().getDiskImage().setVersion("TIZEN Larkspur");
} else {
ec.getBaseInformation().getDiskImage().setType("custom");
}
ec.getDevice().getRAM().getSize().setUnit("MiB");
ec.getDevice().getRAM().getSize().setValue(newVM.ramSize);
- ec.getDevice().setStorage(factory.createStorageType());
- ec.getDevice().getStorage().setSDCard(factory.createStorageTypeSDCard());
- if (newVM.isSDCardSupport) {
- ec.getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
- }
-
if (EmulatorManager.getInstance().getManagerMode().equals(ManagerModeType.INHOUSE_MODE)) {
ec.getDevice().setTouch(factory.createTouchType());
ec.getDevice().getTouch().setMaxTouchPoint(newVM.maxTouchCount);
public void setVMsBaseDirectory(String baseVMsDir) {
vmsBaseDirectoryName = baseVMsDir;
-
- File fi = new File(vmsBaseDirectoryName);
- if(!fi.exists())
- fi.mkdirs();
}
public String getVMsBaseDirectory() {
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.tool.CheckVirtualization;
import org.tizen.emulator.manager.tool.FileIO;
import org.tizen.emulator.manager.tool.PortHelper;
+import org.tizen.emulator.manager.ui.MessageDialog;
import org.tizen.emulator.manager.vms.xml.TouchType;
public class Launcher {
/* check available port number */
portNo = new PortHelper().getPortNo();
if(portNo == -1) {
- MessageBox alert = new MessageBox(EmulatorManager.getInstance().getMainDialog().getShell(), SWT.OK);
- alert.setMessage("Can not execute emulator.\n All available ports are in use.");
- alert.open();
+ MessageDialog alert = new MessageDialog(EmulatorManager.getInstance().getMainDialog().getShell());
+ alert.openInfoDialog("Can not execute emulator.\n All available ports are in use.");
+
return false;
}
else
binary = "emulator-x86";
- if (property.getConfiguration().getUsability().isHwVirtualization() && VMCreateHelper.isSupport) {
- hwVirtualization = VMCreateHelper.enable_command;
+ if (property.getConfiguration().getUsability().isHwVirtualization() && CheckVirtualization.getInstance().isSupportVirtualization()) {
+ hwVirtualization = CheckVirtualization.getInstance().getEnableCommnad();
} else {
- hwVirtualization = VMCreateHelper.disable_command;
+ hwVirtualization = CheckVirtualization.getInstance().getDisableCommnad();
}
/* make cmd to run emulator */
- try {
- List<String> cmd = new ArrayList<String>();
- int width = property.getConfiguration().getDevice().getDisplay().getResolution().getWidth();
- int height = property.getConfiguration().getDevice().getDisplay().getResolution().getHeight();
- String skinPath = null;
- if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) {
- skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath();
- if (skinPath.isEmpty()) {
- skinPath = null;
- }
- }
- String fileshare = property.getConfiguration().getUsability().getFileSharing().getPath();
- String sdcard = property.getConfiguration().getDevice().getStorage().getSDCard().getDiskImage();
- int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
- int isWindows = System.getProperty("os.name").toLowerCase().indexOf("linux");
- String osVersion = System.getProperty("os.version");
- boolean isFileshare = true;
- if (fileshare == null) {
- isFileshare = false;
- }
- boolean isSDcard = true;
- if (sdcard == null) {
- isSDcard = false;
- }
- FileIO fio = new FileIO();
- cmd.add(fio.getBinPath() + File.separator + binary);
- cmd.add("--skin-args");
- cmd.add("width=" + width);
- cmd.add("height=" + height);
- if (skinPath != null) {
- cmd.add("skin.path=" + skinPath);
+ MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
+
+ List<String> cmd = new ArrayList<String>();
+ int width = property.getConfiguration().getDevice().getDisplay().getResolution().getWidth();
+ int height = property.getConfiguration().getDevice().getDisplay().getResolution().getHeight();
+ String skinPath = null;
+ if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) {
+ skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath();
+ if (skinPath.isEmpty()) {
+ skinPath = null;
}
- cmd.add("--qemu-args");
- cmd.add("-drive");
- cmd.add("file=" + EmulatorVMs.getInstance().getVMsBaseDirectory() + File.separator +property.getArch().toString() + File.separator + property.getName() + File.separator +"emulimg-" + property.getName() + ".x86,if=virtio");
- cmd.add( "-boot");
- cmd.add("c");
- cmd.add("-append");
- /* is linux and use fileshare [kernel option] */
- if(isLinux > -1 && isFileshare) {
- cmd.add("console=ttyS0 video=uvesafb:ywrap,"
+ }
+ String fileshare = property.getConfiguration().getUsability().getFileSharing().getPath();
+ int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
+ int isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows");
+ String osVersion = System.getProperty("os.version");
+ boolean isFileshare = true;
+ if (fileshare == null) {
+ isFileshare = false;
+ }
+
+ FileIO fio = FileIO.getInstance();
+ cmd.add(fio.getBinPath() + File.separator + binary);
+ cmd.add("--skin-args");
+ cmd.add("width=" + width);
+ cmd.add("height=" + height);
+ if (skinPath != null) {
+ cmd.add("skin.path=" + skinPath);
+ }
+ cmd.add("--qemu-args");
+ cmd.add("-drive");
+ cmd.add("file=" + EmulatorVMs.getInstance().getVMsBaseDirectory() + File.separator + property.getArch().toString() + File.separator + property.getName() + File.separator +"emulimg-" + property.getName() + ".x86,if=virtio");
+ cmd.add( "-boot");
+ cmd.add("c");
+ cmd.add("-append");
+ /* is linux and use fileshare [kernel option] */
+ if(isLinux > -1 && isFileshare) {
+ cmd.add("console=ttyS0 video=uvesafb:ywrap,"
+ + width
+ + "x"
+ + height
+ + "-32@60"
+ + " dpi=" + property.getConfiguration().getDevice().getDisplay().getDensity().getValue() * 10
+ + " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5 virtio-9p");
+ }
+ else {
+ cmd.add("console=ttyS0 video=uvesafb:ywrap,"
+ width
+ "x"
+ height
+ "-32@60"
+ " dpi=" + property.getConfiguration().getDevice().getDisplay().getDensity().getValue() * 10
- + " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5 virtio-9p");
- }
- else {
- cmd.add("console=ttyS0 video=uvesafb:ywrap,"
- + width
- + "x"
- + height
- + "-32@60"
- + " dpi=" + property.getConfiguration().getDevice().getDisplay().getDensity().getValue() * 10
- + " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5");
- }
- /* is linux and use fileshare [non-kernel option] */
- if(isLinux > -1 && isFileshare) {
- cmd.add("-virtfs");
- cmd.add("local,path=" + property.getConfiguration().getUsability().getFileSharing().getPath() +",security_model=none,mount_tag=fileshare");
- }
+ + " ip=10.0.2.16::10.0.2.2:255.255.255.0::eth0:none 5");
+ }
+ /* is linux and use fileshare [non-kernel option] */
+ if(isLinux > -1 && isFileshare) {
+ cmd.add("-virtfs");
+ cmd.add("local,path=" + property.getConfiguration().getUsability().getFileSharing().getPath() +",security_model=none,mount_tag=fileshare");
+ }
- if(isSDcard) {
- cmd.add("-drive");
- cmd.add("file=" + sdcard + ",if=virtio");
- }
- /* is windows XP and use fileshare */
- if(isWindows > -1 && osVersion.equals("5.1") && isFileshare) {
- /* delete if fileshare with the same name existed */
- List<String> cmd2 = new ArrayList<String>();
- cmd2.add("net");
- cmd2.add("share");
- cmd2.add("emulator-" + portNo);
- cmd2.add("/delete");
- ProcessBuilder pb2 = new ProcessBuilder(cmd2);
- pb2.start();
-
- /* start net share */
- List<String> cmd3 = new ArrayList<String>();
- cmd3.add("net");
- cmd3.add("share");
- cmd3.add("emulator-" + portNo + "=" + fileshare);
- ProcessBuilder pb3 = new ProcessBuilder(cmd3);
- pb3.start();
- }
- /* is windows 7 and use fileshare */
- else if(isWindows > -1 && osVersion.equals("6.1") && isFileshare) {
+ /* is windows XP and use fileshare */
+ if(isWindows > -1 && osVersion.equals("5.1") && isFileshare) {
/* delete if fileshare with the same name existed */
List<String> cmd2 = new ArrayList<String>();
cmd2.add("net");
cmd2.add("share");
cmd2.add("emulator-" + portNo);
cmd2.add("/delete");
+ logger.log(Level.INFO, String.format("%s\n", cmd2));
ProcessBuilder pb2 = new ProcessBuilder(cmd2);
- pb2.start();
+ try {
+ pb2.start();
+ } catch (IOException e) {
+ msg.openWarningDialog("Failed to execute fileshare command.\n" + e.getMessage());
+ }
/* start net share */
List<String> cmd3 = new ArrayList<String>();
cmd3.add("net");
cmd3.add("share");
cmd3.add("emulator-" + portNo + "=" + fileshare);
- cmd3.add("/grant:"+ System.getProperty("user.name") + ",full");
+ logger.log(Level.INFO, String.format("%s\n", cmd3));
ProcessBuilder pb3 = new ProcessBuilder(cmd3);
- pb3.start();
+ try {
+ pb3.start();
+ } catch (IOException e) {
+ msg.openWarningDialog("Failed to execute fileshare command.\n" + e.getMessage());
+ }
+ }
+ /* is windows 7 and use fileshare */
+ else if(isWindows > -1 && osVersion.equals("6.1") && isFileshare) {
+ /* delete if fileshare with the same name existed */
+ List<String> cmd2 = new ArrayList<String>();
+ cmd2.add("net");
+ cmd2.add("share");
+ cmd2.add("emulator-" + portNo);
+ cmd2.add("/delete");
+ logger.log(Level.INFO, String.format("%s\n", cmd2));
+ ProcessBuilder pb2 = new ProcessBuilder(cmd2);
+ try {
+ pb2.start();
+ } catch (IOException e) {
+ msg.openWarningDialog("Failed to execute fileshare command.\n" + e.getMessage());
}
- cmd.add("-serial");
- cmd.add("file:" + EmulatorVMs.getInstance().getVMsBaseDirectory() + File.separator + property.getArch().toString() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
- cmd.add("-m");
- cmd.add(String.valueOf(property.getConfiguration().getDevice().getRAM().getSize().getValue()));
- cmd.add("-M");
- cmd.add("maru-x86-machine");
- cmd.add("-net");
- cmd.add("nic,model=virtio");
- cmd.add("-soundhw");
- cmd.add("all");
- cmd.add("-usb");
- cmd.add("-usbdevice");
- cmd.add("maru-touchscreen");
- cmd.add("-vga");
- cmd.add("maru");
- cmd.add("-bios");
- cmd.add("bios.bin");
- cmd.add("-L");
- cmd.add(fio.getBiosPath());
- cmd.add("-kernel");
- cmd.add(fio.getKernelPath() + File.separator+ "bzImage");
- cmd.add("-net");
- cmd.add("user");
- cmd.add("-rtc");
- cmd.add("base=utc");
- /* append HW virtualization option if supports */
- if (hwVirtualization != null) {
- cmd.add(hwVirtualization);
+ /* start net share */
+ List<String> cmd3 = new ArrayList<String>();
+ cmd3.add("net");
+ cmd3.add("share");
+ cmd3.add("emulator-" + portNo + "=" + fileshare);
+ cmd3.add("/grant:"+ System.getProperty("user.name") + ",full");
+ logger.log(Level.INFO, String.format("%s\n", cmd3));
+ ProcessBuilder pb3 = new ProcessBuilder(cmd3);
+ try {
+ pb3.start();
+ } catch (IOException e) {
+ msg.openWarningDialog("Failed to execute fileshare command.\n" + e.getMessage());
}
+ }
+ cmd.add("-serial");
+ cmd.add("file:" + EmulatorVMs.getInstance().getVMsBaseDirectory() + File.separator + property.getArch().toString() + File.separator + property.getName() + File.separator + "logs" + File.separator + "emulator.klog");
+ cmd.add("-m");
+ cmd.add(String.valueOf(property.getConfiguration().getDevice().getRAM().getSize().getValue()));
+ cmd.add("-M");
+ cmd.add("maru-x86-machine");
+ cmd.add("-net");
+ cmd.add("nic,model=virtio");
+ cmd.add("-soundhw");
+ cmd.add("all");
+ cmd.add("-usb");
+ cmd.add("-usbdevice");
+ cmd.add("maru-touchscreen");
+ cmd.add("-vga");
+ cmd.add("maru");
+ cmd.add("-bios");
+ cmd.add("bios.bin");
+ cmd.add("-L");
+ cmd.add(fio.getBiosPath());
+ cmd.add("-kernel");
+ cmd.add(fio.getKernelPath() + File.separator+ "bzImage");
+ cmd.add("-net");
+ cmd.add("user");
+ cmd.add("-rtc");
+ cmd.add("base=utc");
+
+ /* append HW virtualization option if supports */
+ if (hwVirtualization != null) {
+ cmd.add(hwVirtualization);
+ }
- if (EmulatorManager.getInstance().getManagerMode().equals(ManagerModeType.INHOUSE_MODE)) {
- TouchType touchType = property.getConfiguration().getDevice().getTouch();
- if (touchType != null) {
- cmd.add("-max-touch-point");
- cmd.add("" + touchType.getMaxTouchPoint());
- }
+ if (EmulatorManager.getInstance().getManagerMode().equals(ManagerModeType.INHOUSE_MODE)) {
+ TouchType touchType = property.getConfiguration().getDevice().getTouch();
+ if (touchType != null) {
+ cmd.add("-max-touch-point");
+ cmd.add("" + touchType.getMaxTouchPoint());
}
+ }
- /* append user added options if exists */
- String advancedOptions = property.getConfiguration().getUsability().getAdvancedOptions();
- if (advancedOptions != null) {
- String[] arrOptions = advancedOptions.split(" ");
- for (String option : arrOptions) {
- cmd.add(option);
- }
+ /* append user added options if exists */
+ String advancedOptions = property.getConfiguration().getUsability().getAdvancedOptions();
+ if (advancedOptions != null) {
+ String[] arrOptions = advancedOptions.split(" ");
+ for (String option : arrOptions) {
+ cmd.add(option);
}
- logger.log(Level.INFO, String.format("Starting Emulator Command : %s\n", cmd));
- ProcessBuilder pb = new ProcessBuilder(cmd);
- pb.directory(new File(fio.getBinPath()));
-
+ }
+ logger.log(Level.INFO, String.format("Starting Emulator Command : %s\n", cmd));
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.directory(new File(fio.getBinPath()));
+
+ try {
Process process = pb.start();
final InputStream in1 = new BufferedInputStream(process.getInputStream());
}
}
}).start();
+
new Thread(new Runnable() {
@Override
public void run() {
}).start();
} catch (IOException e) {
- e.printStackTrace();
+ msg.openWarningDialog("Failed to launch [" + property.getName() + "]\n" + e.getMessage());
return false;
}
+
return true;
}
}
property.getConfiguration().getDevice().getDisplay().getDensity().setValue(newVM.dpi);
}
- if (newVM.isSDCardSupport != oldVM.isSDCardSupport) {
- if (newVM.isSDCardSupport) {
- modifySDCard(newVM);
- property.getConfiguration().getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
- } else {
- property.getConfiguration().getDevice().getStorage().getSDCard().setDiskImage(null);
- }
- } else if (newVM.isSDCardSupport && !newVM.SDCardPathName.equals(oldVM.SDCardPathName)) {
- modifySDCard(newVM);
- property.getConfiguration().getDevice().getStorage().getSDCard().setDiskImage(newVM.SDCardPath);
- }
-
if (newVM.ramSize != oldVM.ramSize) {
property.getConfiguration().getDevice().getRAM().getSize().setValue(newVM.ramSize);
}
EmulatorVMs.getInstance().storeXML(property);
}
-
- static void modifySDCard(VMPropertyValue newVM) throws VMsWorkerException {
- if (newVM.SDCardPath.endsWith("MB)")) { // New
- String sdCardName = newVM.SDCardPath.substring(0, newVM.SDCardPath.lastIndexOf(" "));
- String dataPath = FileIO.getInstance().getDataPath() + File.separator + sdCardName;
-
- File src = new File(dataPath);
- if(!src.exists()) {
- throw new VMsWorkerException("Failed to create SD card image.!\nFile does not exist :" + dataPath);
- }
-
- File dest = new File(FileIO.getInstance().getVirtualTargetPath(newVM.imageName) + File.separator + sdCardName);
- try {
- dest.createNewFile();
- newVM.SDCardPath = dest.getAbsolutePath();
- } catch (IOException e) {
- throw new VMsWorkerException("Failed to create new image path!");
- }
-
-
- FileInputStream inputStream = null;
- FileOutputStream outputStream = null;
- FileChannel fcin = null;
- FileChannel fcout = null;
- try {
- inputStream = new FileInputStream(src);
- outputStream = new FileOutputStream(dest);
-
- fcin = inputStream.getChannel();
- fcout = outputStream.getChannel();
- long size = fcin.size();
- fcin.transferTo(0, size, fcout);
- } catch (FileNotFoundException e) {
- throw new VMsWorkerException("Failed to create SD card image!\n" + e.getMessage());
- } catch (IOException e) {
- throw new VMsWorkerException("Failed to create SD card image!\n" + e.getMessage());
- }finally {
- try {
- if (fcout != null)
- fcout.close();
- if (fcin != null)
- fcin.close();
- if (outputStream != null)
- outputStream.close();
- if (inputStream != null)
- inputStream.close();
- } catch (IOException e) {
- throw new VMsWorkerException(e.getMessage());
- }
- }
- } else {
- if (newVM.SDCardPath == null || newVM.SDCardPath.isEmpty()) {
- throw new VMsWorkerException("Select the SD card image!");
- }
-
- if (newVM.SDCardPath.equals("( None )")) {
- throw new VMsWorkerException("Select the SD card image !");
- }
- }
- }
}
package org.tizen.emulator.manager.vms;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import org.tizen.emulator.manager.tool.FileIO;
import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
public class VMCreateHelper {
combo.select(defaultIndex);
}
-
- public ArrayList<String> makeSkinfolderList() {
- ArrayList<String> list = new ArrayList<String>();
- File skins = new File(FileIO.getInstance().getSkinPath());
-
- if (skins.exists()) {
- //System.out.println(skins.getAbsolutePath());
- for (File dir : skins.listFiles()) {
- if (dir.isDirectory()) {
- //System.out.println(dir.getName());
- list.add(dir.getName());
- }
- }
- }
- return list;
- }
-
- // TODO : update please !!
- public static boolean isSupport = false;
- public static String enable_command = "";
- public static String disable_command = null;
- static {
- if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
- File haxDev = new File("\\\\.\\HAX");
- try {
- if(haxDev.createNewFile())
- isSupport = true;
- } catch (IOException e) {
- isSupport = false;
- }
- }
- enable_command = "-enable-hax";
- disable_command = "-disable-hax";
-
- if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
- if(new File("/dev/kvm").exists()) {
- isSupport = true;
- }
- enable_command = "-enable-kvm";
- }
- }
-
-
-
- public boolean isSupportVirtualization() {
- return isSupport;
- }
}
public int keyType;
public String skinPath;
- public boolean isSDCardSupport;
- public String SDCardPath;
- public String SDCardPathName;
-
public int ramSize;
public boolean isFileShareSupport;
}
//
- SDCardPath = property.getConfiguration().getDevice().getStorage().getSDCard().getDiskImage();
- if (SDCardPath != null) {
- isSDCardSupport = true;
- SDCardPathName = SDCardPath.substring
- (SDCardPath.lastIndexOf(File.separator) + 1, SDCardPath.length());
- } else {
- SDCardPath = "";
- SDCardPathName = "( None )";
- }
-
fileSharePath = property.getConfiguration().getUsability().getFileSharing().getPath();
if (fileSharePath != null) {
isFileShareSupport = true;
dest.skinPath = this.skinPath;
dest.keyType = this.keyType;
- dest.isSDCardSupport = this.isSDCardSupport;
- dest.SDCardPath = this.SDCardPath;
- dest.SDCardPathName = this.SDCardPathName;
-
dest.ramSize = this.ramSize;
dest.isFileShareSupport = this.isFileShareSupport;
return false;
if(this.keyType != dest.keyType)
return false;
- if(this.isSDCardSupport != dest.isSDCardSupport) {
- return false;
- } else {
- if (!this.SDCardPath.equals(dest.SDCardPath))
- return false;
- }
if(this.ramSize != dest.ramSize)
return false;
if(this.isFileShareSupport != dest.isFileShareSupport) {
value.keyType = 1;
//
- value.isSDCardSupport = false;
- value.SDCardPath = "";
- value.SDCardPathName = "( None )";
-
value.ramSize = 512;
value.isFileShareSupport = false;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.tool.FileIO;
+import org.tizen.emulator.manager.ui.MessageDialog;
public class VMsWorker {
VMsProperty property;
-
+
public VMsWorker(VMsProperty property) {
this.property = property;
}
// check if the emulator instance with the same name is running now.
public boolean isRunningNow()
{
+ Logger logger = EMLogger.getLogger();
+ MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
int isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows");
-
try {
String line;
List<String> cmd = new ArrayList<String>();
cmd.add("/V");
cmd.add("/FI");
cmd.add("\"IMAGENAME eq java.exe\"");
+ cmd.add("/FO");
+ cmd.add("CSV");
}
ProcessBuilder pb = new ProcessBuilder(cmd);
Process p = pb.start();
BufferedReader stdOut = new BufferedReader(new InputStreamReader(p.getInputStream()));
-
if(isLinux > -1) {
while ((line = stdOut.readLine()) != null) {
- if(line.contains(FileIO.getInstance().getVirtualTargetImagePath(property.getName()))) {
- //System.out.println("exist in"+ line);
+ String imagePath = FileIO.getInstance().getVirtualTargetImagePath(property.getName());
+ if(line.contains(imagePath)) {
+ logger.log(Level.INFO, line + " contains " + imagePath + "\n");
stdOut.close();
return true;
}
}
else if(isWindows > -1) {
while ((line = stdOut.readLine()) != null) {
- if(line.contains(property.getName()+ ":261")) {
- //System.out.println("exist in"+ line);
+ String[] titleName = line.split(",");
+ // "split[split.length - 1]" is window title.
+ if(titleName[titleName.length - 1].startsWith("\"" + property.getName()+ ":261")) {
+ logger.log(Level.INFO, "contains " +titleName[titleName.length - 1] + "\n");
stdOut.close();
return true;
}
}
}
stdOut.close();
- //System.out.println("not exist anywhere");
+ logger.log(Level.INFO, "not exist anywhere\n");
return false;
- } catch (Exception err) {
- err.printStackTrace();
- return true;
+ } catch (Exception err) {
+ logger.log(Level.SEVERE, err.getMessage());
+ msg.openWarningDialog("Error occured while checking if the same VM .\n" +
+ err.getMessage());
+ return false;
}
}
}
\ No newline at end of file
<density unit="dpi">0</density>
<skinPath/>
</display>
- <storage>
- <SDCard/>
- </storage>
<RAM>
<size unit="MiB">0</size>
</RAM>
<sequence>
<element name="display" type="em:displayType" minOccurs="1"
maxOccurs="1" />
- <element name="storage" type="em:storageType" minOccurs="1"
+ <element name="storage" type="string" minOccurs="1"
maxOccurs="1" />
<element name="RAM" type="em:ramType" minOccurs="1"
maxOccurs="1" />
</sequence>
</complexType>
- <complexType name="storageType">
- <sequence>
- <element name="SDCard" minOccurs="1" maxOccurs="1">
- <complexType>
- <sequence>
- <element name="diskImage" type="string" minOccurs="0"
- maxOccurs="1" />
- </sequence>
- </complexType>
- </element>
- </sequence>
- </complexType>
<complexType name="ramType">
<sequence>