From c2c58cd2f93cc6e3419615ee94b68eed942378d6 Mon Sep 17 00:00:00 2001 From: jihye kim Date: Tue, 20 Nov 2012 20:47:17 +0900 Subject: [PATCH] [Title] emulator-manager : fix problem reported from static analysis tool. [Desc.] fix problem reported from static analysis tool and fix bug issue [Issue] N_SE-14781, N_SE-14024 --- .../tizen/emulator/manager/EmulatorManager.java | 11 +++---- .../tizen/emulator/manager/console/ActionList.java | 2 +- .../emulator/manager/console/ConsoleCreateVM.java | 9 ++---- .../emulator/manager/console/ConsoleProcessor.java | 3 +- .../tizen/emulator/manager/image/BaseImage.java | 14 ++++---- src/org/tizen/emulator/manager/image/Platform.java | 13 ++++---- src/org/tizen/emulator/manager/image/Skin.java | 6 ++-- src/org/tizen/emulator/manager/image/SkinList.java | 5 +-- src/org/tizen/emulator/manager/image/Skins.java | 7 ++-- .../tizen/emulator/manager/logging/EMLogger.java | 9 +++++- .../tizen/emulator/manager/tool/CheckSDCard.java | 24 +++++++++----- src/org/tizen/emulator/manager/tool/FilePath.java | 8 ++--- .../emulator/manager/tool/SelectWorkspace.java | 37 ++++++++++++++-------- .../emulator/manager/ui/ArchitectureGroup.java | 4 +-- src/org/tizen/emulator/manager/ui/MainDialog.java | 6 ++-- .../tizen/emulator/manager/ui/MenuHandling.java | 6 ++-- .../emulator/manager/ui/ResourceRegistry.java | 3 +- .../emulator/manager/ui/detail/TableWidget.java | 4 +-- .../emulator/manager/ui/detail/VMPropertyView.java | 4 +-- .../manager/ui/vmstree/ColumnContentHelper.java | 2 +- .../manager/ui/vmstree/ColumnSortListner.java | 17 ++++++---- .../emulator/manager/ui/vmstree/ContextMenu.java | 3 +- .../tizen/emulator/manager/ui/vmstree/VMsTree.java | 6 ++-- .../tizen/emulator/manager/vms/EmulatorVMs.java | 8 ++--- .../tizen/emulator/manager/vms/VMCreateHelper.java | 9 +++--- .../emulator/manager/vms/VMPropertyValue.java | 6 ++-- .../tizen/emulator/manager/vms/VMsProperty.java | 9 ++++-- src/org/tizen/emulator/manager/vms/VMsWorker.java | 24 +++++++------- 28 files changed, 146 insertions(+), 113 deletions(-) diff --git a/src/org/tizen/emulator/manager/EmulatorManager.java b/src/org/tizen/emulator/manager/EmulatorManager.java index 730db7a..9d5a54b 100755 --- a/src/org/tizen/emulator/manager/EmulatorManager.java +++ b/src/org/tizen/emulator/manager/EmulatorManager.java @@ -31,6 +31,7 @@ package org.tizen.emulator.manager; import java.io.File; +import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.FileLock; import java.util.ArrayList; @@ -203,7 +204,7 @@ public class EmulatorManager { "Another one with the same user name is running now.\n"); exitEmulatorManager(-1); } - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().log(Level.WARNING, "Can not launch Emulator Manager.\n" +e.getMessage() + "\n"); exitEmulatorManager(-1); } @@ -224,7 +225,7 @@ public class EmulatorManager { "Another one with the same user name is running now."); exitEmulatorManager(0); } - } catch (Exception e) { + } catch (IOException e) { msg.openInfoDialog("Can not launch Emulator Manager.\n" +e.getMessage()); exitEmulatorManager(-1); } @@ -241,11 +242,7 @@ public class EmulatorManager { CheckSDCard.CheckSDCardDir(); CheckSDCard.CheckSwapDir(); - try { - EmulatorVMs.getInstance().loadProperties(); - } catch (Exception e) { - EMLogger.getLogger().log(Level.WARNING, e.getMessage()); - } + EmulatorVMs.getInstance().loadProperties(); instance.makePlatformList(); diff --git a/src/org/tizen/emulator/manager/console/ActionList.java b/src/org/tizen/emulator/manager/console/ActionList.java index 41d33ae..f611dc5 100644 --- a/src/org/tizen/emulator/manager/console/ActionList.java +++ b/src/org/tizen/emulator/manager/console/ActionList.java @@ -196,7 +196,7 @@ class ListVM extends Action { class ListImage extends Action { public ListImage() { this.action = Actions.AC_LIST_IMAGE; - this.description = "Display list of existing base disk image";; + this.description = "Display list of existing base disk image"; this.usage = "list-image"; } diff --git a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java index 1fa5701..e80baad 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java @@ -271,12 +271,9 @@ public class ConsoleCreateVM { if (skinCommand != null) { ArrayList list = null; int i = 0; - try { - i = Integer.parseInt(skinCommand.getCurrentValue()); - list = SkinList.getInstance().findSkinList(prop.resolution.getValue()); - } catch (Throwable t) { - throw new ConsoleException("Skin value (" + skinCommand.getCurrentValue() + ") is not avaliable."); - } + i = Integer.parseInt(skinCommand.getCurrentValue()); + list = SkinList.getInstance().findSkinList(prop.resolution.getValue()); + if (!list.isEmpty()) { if (i <= 0 || i > list.size()) { throw new ConsoleException("Skin value (" + skinCommand.getCurrentValue() + ") is not avaliable."); diff --git a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java index 18bf54a..92d53c6 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleProcessor.java +++ b/src/org/tizen/emulator/manager/console/ConsoleProcessor.java @@ -109,7 +109,8 @@ public class ConsoleProcessor { if (prop.getConfiguration().getUsability().getAdvancedOptions() != null) { str+= String.format("\t%-17s : %s\n", "Advanced Options: ", prop.getConfiguration().getUsability().getAdvancedOptions()); } - } catch (Exception e) { + } catch (NullPointerException e) { + System.out.println(e.getMessage()); } finally { return str; } diff --git a/src/org/tizen/emulator/manager/image/BaseImage.java b/src/org/tizen/emulator/manager/image/BaseImage.java index ced94b6..18b1b35 100644 --- a/src/org/tizen/emulator/manager/image/BaseImage.java +++ b/src/org/tizen/emulator/manager/image/BaseImage.java @@ -53,7 +53,7 @@ public class BaseImage { private String path; private String information; - public BaseImage(Platform platform, File path, int id) throws Exception { + public BaseImage(Platform platform, File path, int id) throws IOException { this.platform = platform; loadProperty(id, path); settingImagePath(path); @@ -68,7 +68,7 @@ public class BaseImage { " Base Disk Image Path : " + getPath() + "\n"; } - private void loadProperty(int id, File path) throws Exception { + private void loadProperty(int id, File path) throws IOException { this.id = Integer.toString(id); File f = new File(path + File.separator + StringResource.IMAGE_INFO_FILENAME); FileInputStream inputStream = null; @@ -81,7 +81,7 @@ public class BaseImage { type = prop.getProperty(StringResource.IMAGE_TYPE, "default"); name = prop.getProperty(StringResource.IMAGE_NAME).toLowerCase(); if (name == null) { - throw new Exception(); + throw new IOException("Image name is null. This image can not add."); } version = prop.getProperty(StringResource.IMAGE_VERSION, platform.getVersion()); domain = prop.getProperty(StringResource.PRODUCT_DOMAIN, "Phone"); @@ -89,7 +89,7 @@ public class BaseImage { cpu = cpu.toLowerCase(); release = prop.getProperty(StringResource.RELEASE_VERSION, "Not identified"); } else { - throw new Exception("This file does not exist (" + path + ")"); + throw new IOException("This file does not exist (" + path + ")"); } } finally { // clear @@ -103,15 +103,15 @@ public class BaseImage { } } - private void settingImagePath(File path) throws Exception { + private void settingImagePath(File path) throws IOException { for (File f : path.listFiles()) { if (f.isFile() && f.getName().endsWith(cpu.toLowerCase())) { - this.path = f.getAbsolutePath(); + this.path = f.getCanonicalPath(); this.imageName = f.getName(); } } if (this.path == null) { - throw new Exception(); + throw new IOException("Failed getting image file path."); } } public String getID() { diff --git a/src/org/tizen/emulator/manager/image/Platform.java b/src/org/tizen/emulator/manager/image/Platform.java index 7281f0b..233a4a1 100644 --- a/src/org/tizen/emulator/manager/image/Platform.java +++ b/src/org/tizen/emulator/manager/image/Platform.java @@ -30,6 +30,7 @@ package org.tizen.emulator.manager.image; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import org.tizen.emulator.manager.logging.EMLogger; @@ -161,14 +162,14 @@ public class Platform { image = new BaseImage(this, f, ++id); for (BaseImage i : imageList) { if (i.getName().equals(image.getName())){ - // TODO: duplicate name... + // TODO: duplicate name. EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )"); --id; - throw new Exception(); + throw new IOException(); } } imageList.add(image); - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath()); } } @@ -183,14 +184,14 @@ public class Platform { image = new BaseImage(this, f, ++id); for (BaseImage i : imageList) { if (i.getName().equals(image.getName())){ - // TODO: duplicate name... + // TODO: duplicate name. EMLogger.getLogger().warning("The same name of the base disk image already exist.(name : " + image.getName() + " )"); --id; - throw new Exception(); + throw new IOException(); } } imageList.add(image); - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().warning("Failed adding base image..\n" + "Base Disk Image Path: " + f.getAbsolutePath()); } } diff --git a/src/org/tizen/emulator/manager/image/Skin.java b/src/org/tizen/emulator/manager/image/Skin.java index 444aed0..559a8d2 100644 --- a/src/org/tizen/emulator/manager/image/Skin.java +++ b/src/org/tizen/emulator/manager/image/Skin.java @@ -44,7 +44,7 @@ public class Skin { private String type; private String resolution; private String path; - public Skin(File path) throws Exception { + public Skin(File path) throws IOException { loadProperty(path); for (RESOLUTION r : RESOLUTION.values()) { if(r.getValue().equals(resolution)) { @@ -53,7 +53,7 @@ public class Skin { } } - private void loadProperty(File path) throws Exception { + private void loadProperty(File path) throws IOException { this.path = path.getCanonicalPath(); File f = new File(path + File.separator + StringResource.SKIN_INFO_FILENAME); FileInputStream inputStream = null; @@ -72,7 +72,7 @@ public class Skin { resolution = width + "x" + height; } } else { - throw new Exception("This file does not exist (" + path + ")"); + throw new IOException("This file does not exist (" + path + ")"); } } finally { // clear diff --git a/src/org/tizen/emulator/manager/image/SkinList.java b/src/org/tizen/emulator/manager/image/SkinList.java index 9620ede..a05115f 100644 --- a/src/org/tizen/emulator/manager/image/SkinList.java +++ b/src/org/tizen/emulator/manager/image/SkinList.java @@ -30,6 +30,7 @@ package org.tizen.emulator.manager.image; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import org.tizen.emulator.manager.logging.EMLogger; @@ -54,13 +55,13 @@ public class SkinList { try { skinsList.add(new Skins(new File(FilePath.getInstance().getSkinPath()))); //defaultSkin = skinsList.get(0); - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().warning(e.getMessage()); } try { skinsList.add(new Skins(new File(FilePath.getInstance().getDataSkinPath()))); - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().warning(e.getMessage()); } diff --git a/src/org/tizen/emulator/manager/image/Skins.java b/src/org/tizen/emulator/manager/image/Skins.java index 47dfb78..d56f3b3 100644 --- a/src/org/tizen/emulator/manager/image/Skins.java +++ b/src/org/tizen/emulator/manager/image/Skins.java @@ -31,6 +31,7 @@ package org.tizen.emulator.manager.image; import java.io.File; import java.io.FileFilter; +import java.io.IOException; import java.util.ArrayList; import org.tizen.emulator.manager.logging.EMLogger; @@ -38,7 +39,7 @@ public class Skins { private ArrayList skins = null; private String path = null; - public Skins(File dir) throws Exception { + public Skins(File dir) throws IOException { if (dir.exists()) { this.path = dir.getAbsolutePath(); skins = new ArrayList(); @@ -53,14 +54,14 @@ public class Skins { Skin s = null; try { s = new Skin(skin); - } catch(Exception e) { + } catch(IOException e) { EMLogger.getLogger().warning("Error while skin information: " + e.getMessage()); continue; } skins.add(s); } } else { - throw new Exception("This directory does not exist (" + path + ")"); + throw new IOException("This directory does not exist (" + path + ")"); } } diff --git a/src/org/tizen/emulator/manager/logging/EMLogger.java b/src/org/tizen/emulator/manager/logging/EMLogger.java index 764dab3..52249d0 100644 --- a/src/org/tizen/emulator/manager/logging/EMLogger.java +++ b/src/org/tizen/emulator/manager/logging/EMLogger.java @@ -31,6 +31,7 @@ package org.tizen.emulator.manager.logging; import java.io.File; +import java.io.IOException; import java.util.Calendar; import java.util.logging.FileHandler; import java.util.logging.Formatter; @@ -94,7 +95,13 @@ public class EMLogger { logFileHandler.setFormatter(new LoggerFormatter()); logger.addHandler(logFileHandler); - } catch (Exception e) { + } catch (NullPointerException e) { + logger.setLevel(Level.OFF); + e.getMessage(); + } catch (SecurityException e) { + logger.setLevel(Level.OFF); + e.getMessage(); + } catch (IOException e) { logger.setLevel(Level.OFF); e.getMessage(); } diff --git a/src/org/tizen/emulator/manager/tool/CheckSDCard.java b/src/org/tizen/emulator/manager/tool/CheckSDCard.java index c7fc535..cddebe1 100644 --- a/src/org/tizen/emulator/manager/tool/CheckSDCard.java +++ b/src/org/tizen/emulator/manager/tool/CheckSDCard.java @@ -90,14 +90,18 @@ public class CheckSDCard { dest.delete(); }finally { try { - if (fcout != null) + if (fcout != null) { fcout.close(); - if (fcin != null) + } + if (fcin != null) { fcin.close(); - if (outputStream != null) + } + if (outputStream != null) { outputStream.close(); - if (inputStream != null) + } + if (inputStream != null) { inputStream.close(); + } } catch (IOException e) { EMLogger.getLogger().log(Level.WARNING, e.getMessage() + "\n"); } @@ -157,14 +161,18 @@ public class CheckSDCard { continue; }finally { try { - if (fcout != null) + if (fcout != null) { fcout.close(); - if (fcin != null) + } + if (fcin != null) { fcin.close(); - if (outputStream != null) + } + if (outputStream != null) { outputStream.close(); - if (inputStream != null) + } + if (inputStream != null) { inputStream.close(); + } } catch (IOException e) { EMLogger.getLogger().log(Level.WARNING, e.getMessage() + "\n"); } diff --git a/src/org/tizen/emulator/manager/tool/FilePath.java b/src/org/tizen/emulator/manager/tool/FilePath.java index 04780e4..8ac02d7 100644 --- a/src/org/tizen/emulator/manager/tool/FilePath.java +++ b/src/org/tizen/emulator/manager/tool/FilePath.java @@ -121,7 +121,7 @@ public class FilePath { try { tizenSDKDataPath = in.readLine(); } catch (IOException e) { - //e.printStackTrace(); + e.printStackTrace(); } finally { try { in.close(); @@ -193,11 +193,11 @@ public class FilePath { // SDB path { String sdb_suffix; - if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) + if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) { sdb_suffix = File.separator + "sdb.exe"; - else + } else { sdb_suffix = File.separator + "sdb"; - + } sdbPath = toolsPath + sdb_suffix; } diff --git a/src/org/tizen/emulator/manager/tool/SelectWorkspace.java b/src/org/tizen/emulator/manager/tool/SelectWorkspace.java index 3bc1e50..35fff3b 100644 --- a/src/org/tizen/emulator/manager/tool/SelectWorkspace.java +++ b/src/org/tizen/emulator/manager/tool/SelectWorkspace.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; +import java.net.UnknownHostException; import java.util.Enumeration; import java.util.Properties; import java.util.logging.Level; @@ -124,7 +125,7 @@ public class SelectWorkspace { BufferedWriter out = null; out = new BufferedWriter(writer); - + try { out.write(StringResource.SHOW_SELECTION_DIAGLOG + "=false\n"); out.write(StringResource.RECENT_VMS_PATH + "=\n"); @@ -210,7 +211,7 @@ public class SelectWorkspace { } return ni; } - + private static void getMACaddrFromLinuxHost() throws SocketException { NetworkInterface ni = checkNIname(); if ( ni == null) { @@ -227,35 +228,39 @@ public class SelectWorkspace { getHardwareAddressFromNI(ni); } } - - private static void getMACaddrFromWindowsHost() throws Exception { + + private static void getMACaddrFromWindowsHost() throws UnknownHostException, SocketException { NetworkInterface ni; InetAddress addr = InetAddress.getLocalHost(); + if (addr == null) { + return; + } + ni = NetworkInterface.getByInetAddress(addr); if (ni != null) { getHardwareAddressFromNI(ni); } } - + private static void getMACaddrFromMacHost() throws SocketException { //TODO } - + private static void getHardwareAddressFromNI (NetworkInterface ni) throws SocketException { - + byte[] mac = ni.getHardwareAddress(); - + for (int i = 0; i < mac.length; i++) { macAddr += String.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : ""); } - + logger.log(Level.INFO, String.format( "Network name = %s, MAC = %s\n", ni.getDisplayName(), macAddr)); } - + private static String getMACaddrFromHost() { int isLinux = System.getProperty("os.name").toLowerCase() .indexOf("linux"); @@ -263,7 +268,6 @@ public class SelectWorkspace { .indexOf("windows"); int isMac = System.getProperty("os.name").toLowerCase() .indexOf("mac"); - try { if (isLinux > -1) { getMACaddrFromLinuxHost(); @@ -272,13 +276,18 @@ public class SelectWorkspace { }else if (isMac > -1) { getMACaddrFromMacHost(); } - } catch (Exception e1) { + } catch (SocketException e) { logger.log( Level.WARNING, String.format("Failed to get MAC address of host: %s\n", - e1.getMessage())); + e.getMessage())); + } catch (UnknownHostException e) { + logger.log( + Level.WARNING, + String.format("Failed to get MAC address of host: %s\n", + e.getMessage())); } - + return macAddr; } diff --git a/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java b/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java index e732624..d39f6b9 100644 --- a/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java +++ b/src/org/tizen/emulator/manager/ui/ArchitectureGroup.java @@ -41,14 +41,14 @@ import org.tizen.emulator.manager.tool.StringResource; import org.tizen.emulator.manager.vms.VMsProperty.Architecture; public class ArchitectureGroup { - MainDialog dialog; + //MainDialog dialog; Group group; Button x86RadioButton; Button armRadioButton; public ArchitectureGroup(final MainDialog dialog, Composite archComposite) { - this.dialog = dialog; + //this.dialog = dialog; group = new Group(archComposite, SWT.NONE); diff --git a/src/org/tizen/emulator/manager/ui/MainDialog.java b/src/org/tizen/emulator/manager/ui/MainDialog.java index 7e65ec3..2f3e029 100644 --- a/src/org/tizen/emulator/manager/ui/MainDialog.java +++ b/src/org/tizen/emulator/manager/ui/MainDialog.java @@ -247,8 +247,9 @@ public class MainDialog { public void open() { shell.open(); while(!shell.isDisposed()) { - if(!Display.getCurrent().readAndDispatch()) + if(!Display.getCurrent().readAndDispatch()) { Display.getCurrent().sleep(); + } } } @@ -397,8 +398,9 @@ public class MainDialog { public void dispose() { ResourceRegistry.dispose(); - if(icon != null) + if(icon != null) { icon.dispose(); + } } enum State { FALSE, TRUE, CLOSE_DETAIL; diff --git a/src/org/tizen/emulator/manager/ui/MenuHandling.java b/src/org/tizen/emulator/manager/ui/MenuHandling.java index c01e23c..d3d10ee 100644 --- a/src/org/tizen/emulator/manager/ui/MenuHandling.java +++ b/src/org/tizen/emulator/manager/ui/MenuHandling.java @@ -55,8 +55,9 @@ public class MenuHandling { MessageDialog msg = new MessageDialog(); int response = msg.openSelectionDialog("This VM will be formatted.\nAre you sure you want to continue?"); - if (response != SWT.OK) + if (response != SWT.OK) { return; + } VMsProperty[] properties = vmsTree.getSelectionItems(); if (properties.length == 0) { @@ -86,8 +87,9 @@ public class MenuHandling { 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) + if (response != SWT.OK) { return false; + } VMsProperty[] properties = vmsTree.getSelectionItems(); if (properties.length == 0) { diff --git a/src/org/tizen/emulator/manager/ui/ResourceRegistry.java b/src/org/tizen/emulator/manager/ui/ResourceRegistry.java index 178af74..8fb2e8c 100644 --- a/src/org/tizen/emulator/manager/ui/ResourceRegistry.java +++ b/src/org/tizen/emulator/manager/ui/ResourceRegistry.java @@ -85,8 +85,9 @@ public class ResourceRegistry { for(ImageName imageName : ImageName.values()) { is = loader.getResourceAsStream("res/" + imageName.toString() + ".png"); - if(is != null) + if(is != null) { instance.imagesMap.put(imageName, new Image(Display.getCurrent(), is)); + } } } } diff --git a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java b/src/org/tizen/emulator/manager/ui/detail/TableWidget.java index 9291c2c..bae26ce 100644 --- a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java +++ b/src/org/tizen/emulator/manager/ui/detail/TableWidget.java @@ -679,7 +679,7 @@ class RAMSizeCombo extends TableWidget { String str = ramSizeCombo.getItem(ramSizeCombo.getSelectionIndex()); newSize = Integer.valueOf(str.substring(0, str.length() - 3)); - if (!isCreateMode() && oldSize != newSize) { + if (!isCreateMode()) { getListener().ChangeValue(getThis()); } } @@ -726,7 +726,7 @@ class FileShareTypeCombo extends TableWidget { } public boolean settingWidget(Table table, VMPropertyValue value) { - oldIsSupport = value.isFileShareSupport; + newIsSupport = oldIsSupport = value.isFileShareSupport; if (EmulatorManager.isMac()) { shareTypeLabel = new Label(table, SWT.WRAP); diff --git a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java b/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java index 2a95bdb..2eefadc 100644 --- a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java +++ b/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java @@ -128,7 +128,7 @@ public class VMPropertyView implements TableWidgetChangeListener { } public void modifyView(Button confirm) { - // TODO: select Skins... + // TODO: select Skins. //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); newValue = oldValue.clone(); confirmButton = confirm; @@ -137,7 +137,7 @@ public class VMPropertyView implements TableWidgetChangeListener { } public void createView(Button confirm) { - // TODO: select Skins... + // TODO: select Skins. //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); newValue = oldValue.clone(); confirmButton = confirm; diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java b/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java index e4f53f5..c8a8275 100644 --- a/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java +++ b/src/org/tizen/emulator/manager/ui/vmstree/ColumnContentHelper.java @@ -35,7 +35,7 @@ import org.tizen.emulator.manager.vms.xml.DeviceType; import org.tizen.emulator.manager.vms.xml.DisplayType; -// TODO: Support dynamic column editing... +// TODO: Support dynamic column editing. public abstract class ColumnContentHelper { static final int numberOfColumns = 4; static final String[] columnTitles = new String[] { "Name", "CPU", "Resolution", "Density", "RAM size", }; diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java b/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java index 56051c8..bc14c72 100644 --- a/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java +++ b/src/org/tizen/emulator/manager/ui/vmstree/ColumnSortListner.java @@ -44,29 +44,32 @@ public class ColumnSortListner implements SelectionListener { Tree tree = column.getParent(); tree.setSortColumn(column); - if(tree.getSortDirection() == SWT.NONE) + if(tree.getSortDirection() == SWT.NONE) { tree.setSortDirection(SWT.UP); - else if(tree.getSortDirection() == SWT.UP) + } else if(tree.getSortDirection() == SWT.UP) { tree.setSortDirection(SWT.DOWN); - else if(tree.getSortDirection() == SWT.DOWN) + } else if(tree.getSortDirection() == SWT.DOWN) { tree.setSortDirection(SWT.UP); - + } for(TreeItem item : tree.getItems()) { - if(!(item.getData() instanceof Container)) // double checking... + if(!(item.getData() instanceof Container)) {// double checking... continue; + } int count = item.getItemCount(); for(int i = 0; i < count - 1; ++i) { TreeItem subItem0 = item.getItem(i); - if(subItem0.getData() instanceof TreeMarker) + if(subItem0.getData() instanceof TreeMarker) { continue; + } for(int j = i + 1; j < count; ++j) { TreeItem subItem1 = item.getItem(j); - if(subItem1.getData() instanceof TreeMarker) + if(subItem1.getData() instanceof TreeMarker) { continue; + } if(tree.getSortDirection() == SWT.UP) { if(subItem0.getText().compareTo(subItem1.getText()) > 0) { diff --git a/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java b/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java index 844f4d8..1614150 100644 --- a/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java +++ b/src/org/tizen/emulator/manager/ui/vmstree/ContextMenu.java @@ -63,8 +63,9 @@ public class ContextMenu { launchItem.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { - if(vmsTree.getSelectionCount() > 1) + if(vmsTree.getSelectionCount() > 1) { return; + } VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property; try { diff --git a/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java b/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java index f150457..95a0c1d 100644 --- a/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java +++ b/src/org/tizen/emulator/manager/ui/vmstree/VMsTree.java @@ -99,8 +99,9 @@ public class VMsTree { else { Object data = vmsTree.getSelection()[0].getData(); - if(!(data instanceof RowItem)) + if(!(data instanceof RowItem)) { return; + } // TODO : select template using platform if (vmsTree.getSelection()[0].getData() instanceof CreateMarker) { @@ -130,8 +131,9 @@ public class VMsTree { || vmsTree.getSelectionCount() > 1) { return; } - if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) + if(vmsTree.getSelection()[0].getData() instanceof TreeMarker) { return; + } VMsProperty property = ((PropertyContent)vmsTree.getSelection()[0].getData()).property; try { diff --git a/src/org/tizen/emulator/manager/vms/EmulatorVMs.java b/src/org/tizen/emulator/manager/vms/EmulatorVMs.java index 955c35a..c0faf14 100644 --- a/src/org/tizen/emulator/manager/vms/EmulatorVMs.java +++ b/src/org/tizen/emulator/manager/vms/EmulatorVMs.java @@ -114,14 +114,10 @@ public class EmulatorVMs { } public void refreshProperties() { - try { - loadProperties(); - } catch (Exception e) { - e.printStackTrace(); - } + loadProperties(); } - public void loadProperties() throws Exception { + public void loadProperties() { propertiesList.clear(); // traverse VMs... File vmsDirectory = new File(vmsConfigDirectory); diff --git a/src/org/tizen/emulator/manager/vms/VMCreateHelper.java b/src/org/tizen/emulator/manager/vms/VMCreateHelper.java index 47ac69f..a42abf6 100644 --- a/src/org/tizen/emulator/manager/vms/VMCreateHelper.java +++ b/src/org/tizen/emulator/manager/vms/VMCreateHelper.java @@ -44,11 +44,10 @@ public class VMCreateHelper { (ch >= 'A' && ch <= 'Z') || (ch >='0' && ch <= '9') || (ch == '-') || (ch == '_')) { - + continue; } else { return false; } - } return true; } @@ -98,11 +97,13 @@ public class VMCreateHelper { } public void addComboItem(Combo combo, Object[] items, int defaultIndex) { - if (items == null || items.length == 0) + if (items == null || items.length == 0) { return; + } - for (int i = 0; i < items.length; i++) + for (int i = 0; i < items.length; i++) { combo.add(items[i].toString()); + } combo.select(defaultIndex); } diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java index 21528ec..92c0b5c 100644 --- a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java +++ b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java @@ -31,6 +31,7 @@ package org.tizen.emulator.manager.vms; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import org.tizen.emulator.manager.image.BaseImage; @@ -188,8 +189,9 @@ public class VMPropertyValue implements Cloneable { if(this.isFileShareSupport != dest.isFileShareSupport) { return false; } else { - if (!this.fileSharePath.equals(dest.fileSharePath)) + if (!this.fileSharePath.equals(dest.fileSharePath)) { return false; + } } if (this.isHWVirtualization != dest.isHWVirtualization) { return false; @@ -247,7 +249,7 @@ public class VMPropertyValue implements Cloneable { if (skin == null) { try { skin = new Skin(new File(skinPath)); - } catch (Exception e) { + } catch (IOException e) { EMLogger.getLogger().warning(e.getMessage()); skin = null; } diff --git a/src/org/tizen/emulator/manager/vms/VMsProperty.java b/src/org/tizen/emulator/manager/vms/VMsProperty.java index 58709d9..f1e1abb 100644 --- a/src/org/tizen/emulator/manager/vms/VMsProperty.java +++ b/src/org/tizen/emulator/manager/vms/VMsProperty.java @@ -60,21 +60,24 @@ public class VMsProperty { } public String getName() { - if(configuration.getBaseInformation() == null) + if(configuration.getBaseInformation() == null) { return null; + } return configuration.getBaseInformation().getName(); } public Architecture getArch() { - if(configuration.getBaseInformation() == null) + if(configuration.getBaseInformation() == null) { return null; + } return Architecture.x86.toString().equals(configuration.getBaseInformation().getArchitecture()) ? Architecture.x86 : Architecture.ARM; } public FSImageType getImageType() { - if(configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) + if(configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) { return null; + } return FSImageType.standard.toString().equals(configuration.getBaseInformation().getDiskImage().getType()) ? FSImageType.standard : FSImageType.custom; diff --git a/src/org/tizen/emulator/manager/vms/VMsWorker.java b/src/org/tizen/emulator/manager/vms/VMsWorker.java index be45eb5..23937cc 100644 --- a/src/org/tizen/emulator/manager/vms/VMsWorker.java +++ b/src/org/tizen/emulator/manager/vms/VMsWorker.java @@ -122,12 +122,11 @@ public class VMsWorker { worker.wait(); } catch (InterruptedException e) { e.printStackTrace(); - } finally { - if (worker.isError()) { - throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n" - + "You can get more information in log file (" - + FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)"); - } + } + if (worker.isError()) { + throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n" + + "You can get more information in log file (" + + FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)"); } } } else { @@ -136,12 +135,11 @@ public class VMsWorker { worker.wait(2000); } catch (InterruptedException e) { e.printStackTrace(); - } finally { - if (worker.isError()) { - throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n" - + "You can get more information in log file (" - + FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)"); - } + } + if (worker.isError()) { + throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!\n" + + "You can get more information in log file (" + + FilePath.getInstance().getTizenVmsPath() + File.separator + "emulator-manager)"); } } } @@ -327,7 +325,7 @@ public class VMsWorker { logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.\n"); } return result; - } catch (Exception err) { + } catch (IOException err) { logger.log(Level.SEVERE, err.getMessage()); if (!EmulatorManager.isConsoleMode()) { MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent())); -- 2.7.4