From d73c1379564d83ab14c8c77b0c691120316f0d1a Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Sat, 13 Feb 2016 13:32:54 +0900 Subject: [PATCH] CLI: add 'list-platform' command - remove 'list-image' command Change-Id: I03bbd8f76ae08dab0ef1475346d11f8829f4bf22 Signed-off-by: jihye424.kim --- resource/strings/climessages.properties | 16 ++++---- .../tizen/emulator/manager/EmulatorManager.java | 23 +---------- src/org/tizen/emulator/manager/console/Action.java | 8 ++-- .../tizen/emulator/manager/console/ActionList.java | 47 +++++++++++++++++----- .../emulator/manager/console/ConsoleProcessor.java | 30 +++++--------- 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/resource/strings/climessages.properties b/resource/strings/climessages.properties index 40529ba..0ce4a35 100644 --- a/resource/strings/climessages.properties +++ b/resource/strings/climessages.properties @@ -22,6 +22,8 @@ Action.Name=Name of new VM. Action.NameMod=Name of VM. Action.PlatformHelp.0=Select Platform of base disk image. Action.PlatformHelp.1=\t\t(Available disk image can be found using 'list-image' command) +Action.ProfileHelp.0=Select profile +Action.DetailPlatformHelp.0=Display more information of platform Action.RAMSizenDescription.0=RAM size. ( Action.RAMSizenDescription.1=) Action.RemoteHelp.0=User account of remote. @@ -61,8 +63,8 @@ ActionList.ExportAs.1=create-image -n test [options] ActionList.IPOpion=IP address of remote. ActionList.Launch.0=Start emulator using selected VM. ActionList.Launch.1=launch -n test [options] -ActionList.ListImage.0=Display list of existing base disk image -ActionList.ListImage.1=list-image +ActionList.ListImage.0=Display list of existing platforms +ActionList.ListImage.1=list-platform [options] ActionList.ListVM.0=Display list of existing 'Virtual Machine' ActionList.ListVM.1=list-vm [options] ActionList.Modfiy.0=Modify configuration of selected 'Virtual Machine'. @@ -85,8 +87,8 @@ ActionList.RemoteExportAs.0=Create remote base disk image using VM's child image ActionList.RemoteExportAs.1=remote-create-image -n test -e IP -u account [options] ActionList.RemoteLaunch.0=Start remote emulator using selected VM. ActionList.RemoteLaunch.1=remote-launch -n test -e IP -u account [options] -ActionList.RemoteListImage.0=Display list of existing remote base disk image -ActionList.RemoteListImage.1=remote-list-image -e IP -u account [options] +ActionList.RemoteListImage.0=Display list of existing remote platforms +ActionList.RemoteListImage.1=remote-platform-image -e IP -u account [options] ActionList.RemoteListVM.0=Display list of existing 'Remote Virtual Machine' ActionList.RemoteListVM.1=remote-list-VM -e IP -u account [options] ActionList.RemoteModify.0=Modify configuration of selected 'Remote Virtual Machine'. @@ -175,9 +177,9 @@ ConsoleProcessor.DeleteError.1=\ - Please check and remove VM directory complete ConsoleProcessor.DeleteError.2=\ - path : ConsoleProcessor.DupulicateNameError.0=Error: The target name ( ConsoleProcessor.DupulicateNameError.1=) already exists\! -ConsoleProcessor.ImageList.0=Available Base Image: -ConsoleProcessor.ImageList.1=Base Image is empty. -ConsoleProcessor.LaunchConfigInfo.0=Print launch config file : +ConsoleProcessor.ImageList.0=Available Platforms: +ConsoleProcessor.ImageList.1=Platform list is empty. +ConsoleProcessor.LaunchConfigInfo.0=Print launch configure file : ConsoleProcessor.LaunchError.0=Error: Can not execute this VM. ConsoleProcessor.NotExistPathError.0=Error: This directory does not exist. (Path : ConsoleProcessor.NotExistVMError.0=Error: The name ( diff --git a/src/org/tizen/emulator/manager/EmulatorManager.java b/src/org/tizen/emulator/manager/EmulatorManager.java index 2e7e512..49c5e84 100755 --- a/src/org/tizen/emulator/manager/EmulatorManager.java +++ b/src/org/tizen/emulator/manager/EmulatorManager.java @@ -48,7 +48,6 @@ import org.tizen.emulator.manager.job.CheckWebcam; import org.tizen.emulator.manager.job.Overseer; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.Preparer; -import org.tizen.emulator.manager.platform.backup.ProfileList; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.tool.About; @@ -300,29 +299,9 @@ public class EmulatorManager { checkConsoleMode(args); if (isConsoleMode) { + Preparer.execute(); // initialize VMKeeper EmulatorManager.setVMKeeper(new DisposableVMKeeper()); - EMLogger.getInstance().initLogger(); - ProfileList.initialize(); - /* - try { - FileLock lock = randomAccessFile.getChannel().tryLock(); - if (lock == null) { - EMLogger.getLogger().log(Level.WARNING, "Can not launch Emulator Manager." - + StringResources.NEW_LINE - + "Another one with the same user name is running now." - + StringResources.NEW_LINE); - System.out.println("Can not launch Emulator Manager." - + StringResources.NEW_LINE - + "Another Emulator Manager is running now."); - exitEmulatorManager(1); - } - } catch (IOException e) { - EMLogger.getLogger().log(Level.WARNING, "Can not launch Emulator Manager." - + StringResources.NEW_LINE +e.getMessage() + StringResources.NEW_LINE); - exitEmulatorManager(1); - } - */ processor = new CommandLineParser(); processor.parseArgs(args); diff --git a/src/org/tizen/emulator/manager/console/Action.java b/src/org/tizen/emulator/manager/console/Action.java index a4625b5..616735c 100644 --- a/src/org/tizen/emulator/manager/console/Action.java +++ b/src/org/tizen/emulator/manager/console/Action.java @@ -242,7 +242,7 @@ class Actions { // actions public final static String AC_GLOBAL = "global"; //$NON-NLS-1$ public final static String AC_LIST_VM = "list-vm"; //$NON-NLS-1$ - public final static String AC_LIST_IMAGE = "list-image"; //$NON-NLS-1$ + public final static String AC_LIST_PLATFORM = "list-platform"; //$NON-NLS-1$ public final static String AC_CREATE = "create"; //$NON-NLS-1$ public final static String AC_DETAIL = "detail"; //$NON-NLS-1$ public final static String AC_DELETE = "delete"; //$NON-NLS-1$ @@ -261,7 +261,7 @@ class Actions { public final static String AC_REMOTE_MODIFY = "remote-modify"; //$NON-NLS-1$ public final static String AC_REMOTE_CLONE = "remote-clone"; //$NON-NLS-1$ public final static String AC_REMOTE_RESET = "remote-reset"; //$NON-NLS-1$ - public final static String AC_REMOTE_LIST_IMAGE = "remote-list-image"; //$NON-NLS-1$ + public final static String AC_REMOTE_LIST_PLATFORM = "remote-list-platform"; //$NON-NLS-1$ public final static String AC_REMOTE_CREATE_IMAGE = "remote-create-image"; //$NON-NLS-1$ public final static String AC_REMOTE_DETAIL = "remote-detail"; //$NON-NLS-1$ public final static String AC_REMOTE_WORKSPACE = "remote-workspace"; //$NON-NLS-1$ @@ -284,6 +284,7 @@ class Actions { public final static String OP_TEST = "test"; //$NON-NLS-1$ public final static String OP_COUNT = "count"; //$NON-NLS-1$ public final static String OP_COMPRESS = "compress"; + public final static String OP_PROFILE = "profile"; public final static String OP_RESOLUTION = "resolution"; //$NON-NLS-1$ public final static String OP_DPI = "dpi"; //$NON-NLS-1$ @@ -323,6 +324,8 @@ class Actions { public final static String DESC_PLATFORM = Messages.getString("Action.PlatformHelp.0") //$NON-NLS-1$ + StringResources.NEW_LINE + Messages.getString("Action.PlatformHelp.1"); //$NON-NLS-1$ + public final static String DESC_PROFILE = Messages.getString("Action.ProfileHelp.0"); + public final static String DESC_DETAIL_PLATFORM = Messages.getString("Action.DetailPlatformHelp.0"); public final static String DESC_RESOLUTION = resolutionDescription(); public final static String DESC_DPI = Messages.getString("Action.DPIHelp"); //$NON-NLS-1$ public final static String DESC_SKIN = Messages.getString("Action.SkinHelp"); //$NON-NLS-1$ @@ -336,7 +339,6 @@ class Actions { public final static String DEFAULT_BASE = Messages.getString("Action.DefaultBaseImage"); //$NON-NLS-1$ public final static String DEFAULT_SKIN = Messages.getString("Action.DefaultSkin"); //$NON-NLS-1$ - public static String resolutionDescription() { String resolution = ""; //$NON-NLS-1$ for (RESOLUTION r : RESOLUTION.values()) { diff --git a/src/org/tizen/emulator/manager/console/ActionList.java b/src/org/tizen/emulator/manager/console/ActionList.java index f33bcae..7cc785c 100644 --- a/src/org/tizen/emulator/manager/console/ActionList.java +++ b/src/org/tizen/emulator/manager/console/ActionList.java @@ -57,7 +57,7 @@ public class ActionList { globalAction = new Global(); addAction(new ListVM()); - addAction(new ListImage()); + addAction(new ListPlatform()); addAction(new Detail()); addAction(new Launch()); addAction(new Create()); @@ -68,7 +68,7 @@ public class ActionList { addAction(new CreateBaseImage()); addAction(new RemoteListVM()); - addAction(new RemoteListImage()); + addAction(new RemoteListPlatform()); addAction(new RemoteDetail()); addAction(new RemoteLaunch()); addAction(new RemoteCreate()); @@ -247,28 +247,55 @@ class RemoteListVM extends Action { } } -class ListImage extends Action { - public ListImage() { - this.action = Actions.AC_LIST_IMAGE; +class ListPlatform extends Action { + public ListPlatform() { + this.action = Actions.AC_LIST_PLATFORM; this.description = Messages.getString("ActionList.ListImage.0"); //$NON-NLS-1$ this.usage = Messages.getString("ActionList.ListImage.1"); //$NON-NLS-1$ + + commandList.add(new Command("p", Actions.OP_PROFILE, //$NON-NLS-1$ + Actions.DESC_PROFILE, "", false, true)); //$NON-NLS-1$ + commandList.add(new Command("d", Actions.OP_DETAIL, //$NON-NLS-1$ + Actions.DESC_DETAIL_PLATFORM, "", false, false)); //$NON-NLS-1$ } @Override public boolean process() { + String profile = null; boolean isDetail = false; + for (Command c : commandList) { + if (c.isInCommandLine()) { + switch (c.getShortName().charAt(0)) { + case 'd' : // detail + isDetail = true; + break; + case 'p' : // profile + profile = c.getCurrentValue(); + break; + } + } + } ConsoleProcessor processor = new ConsoleProcessor(); - for (String s : processor.getInfoOfImageList(isDetail)) { // TODO + List list = processor.getInfoOfImageList(profile, isDetail); + + // list is empty -> error??? + if (list.isEmpty()) { + System.out.println(Messages.getString("ConsoleProcessor.ImageList.1")); //$NON-NLS-1$ + return false; + } + + for (String s : list) { System.out.println(s); } + return true; } } -class RemoteListImage extends Action { - public RemoteListImage() { - this.action = Actions.AC_REMOTE_LIST_IMAGE; +class RemoteListPlatform extends Action { + public RemoteListPlatform() { + this.action = Actions.AC_REMOTE_LIST_PLATFORM; this.description = Messages.getString("ActionList.RemoteListImage.0"); //$NON-NLS-1$ this.usage = Messages.getString("ActionList.RemoteListImage.1"); //$NON-NLS-1$ @@ -288,7 +315,7 @@ class RemoteListImage extends Action { remoteManager.storeRemoteInfo(commandList); remoteManager.sshCmd(cmd); - cmd.add("list-image"); //$NON-NLS-1$ + cmd.add(Actions.AC_LIST_PLATFORM); return remoteManager.runRemoteCmd(cmd); } diff --git a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java index b5bdc6c..cf47742 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java +++ b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java @@ -37,9 +37,7 @@ import java.util.logging.Level; import org.tizen.emulator.manager.EmulatorManager; import org.tizen.emulator.manager.logging.EMLogger; -import org.tizen.emulator.manager.platform.backup.BaseImage; -import org.tizen.emulator.manager.platform.backup.Profile; -import org.tizen.emulator.manager.platform.backup.ProfileList; +import org.tizen.emulator.manager.platform.Platform; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.tool.About; @@ -137,32 +135,24 @@ public class ConsoleProcessor { return getProperties().size(); } - public ArrayList getInfoOfImageList(boolean isDetail) { + public ArrayList getInfoOfImageList(String profile, boolean isDetail) { + // TODO: isDetail ?? + ArrayList list = new ArrayList(); - list.add(Messages.getString("ConsoleProcessor.ImageList.0") + StringResources.NEW_LINE); //$NON-NLS-1$ - for (Profile profile : ProfileList.getProfileList()) { - for (BaseImage image : profile.getImageList()) { - list.add(image.toString()); + for (Platform platform : Platform.getPlatformList()) { + if (profile == null) { + list.add(platform.getName()); + } else if (platform.getProfile().getName().equals(profile)) { + list.add(platform.getName()); } } - if (list.size() == 1) { - list.remove(0); - list.add(Messages.getString("ConsoleProcessor.ImageList.1")); //$NON-NLS-1$ - } - return list; } public int getCountOfImageList() { - //ArrayList list = new ArrayList(); - int count = 0; - for (Profile profile : ProfileList.getProfileList()) { - count += profile.getImageList().size(); - } - - return count; + return Platform.getPlatformList().size(); } public boolean launchEmulator(String name, String path, boolean isTest) { -- 2.7.4