[Title] add validating configurations
authorSon Hyunjun <hj79.son@samsung.com>
Fri, 6 Apr 2012 08:13:44 +0000 (17:13 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Fri, 6 Apr 2012 08:13:44 +0000 (17:13 +0900)
[Type] Enhancement
[Module] Skin
[Priority] Minor
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: Ie62a23e5739c0ea53d72479994ad6ad371a86d40

tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/exception/ConfigException.java [moved from tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorConstants.java with 68% similarity]
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java

index 6780156..df813ea 100644 (file)
@@ -68,7 +68,7 @@ import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.comm.ICommunicator.Scale;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.comm.sock.data.BooleanData;
@@ -92,7 +92,6 @@ import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
 import org.tizen.emulator.skin.util.SkinRegion;
 import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinUtil;
-import org.tizen.emulator.skin.util.StringUtil;
 
 /**
  * 
@@ -189,14 +188,15 @@ public class EmulatorSkin {
 
                this.lcdCanvas = new Canvas( shell, SWT.EMBEDDED );
 
-               int x = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_X, 50 );
-               int y = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_Y, 50 );
-               int lcdWidth = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
-               int lcdHeight = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
+               int x = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_X, EmulatorConfig.DEFAULT_WINDOW_X );
+               int y = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_Y, EmulatorConfig.DEFAULT_WINDOW_Y );
+               int lcdWidth = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+               int lcdHeight = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
                int scale = SkinUtil.getValidScale( config );
-               // int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION, RotationInfo.PORTRAIT.id() );
+//             int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION,
+//                             EmulatorConfig.DEFAULT_WINDOW_ROTATION );
                // has to be portrait mode at first booting time
-               short rotationId = RotationInfo.PORTRAIT.id();
+               short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
                
                composeInternal( lcdCanvas, x, y, lcdWidth, lcdHeight, scale, rotationId );
 
@@ -568,7 +568,7 @@ public class EmulatorSkin {
 
                                        int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
 
-                                       if ( EmulatorConstants.UNKNOWN_KEYCODE != keyCode ) {
+                                       if ( SkinUtil.UNKNOWN_KEYCODE != keyCode ) {
                                                if ( currentHoverRegion.width == 0 && currentHoverRegion.height == 0 ) {
                                                        shell.redraw();
                                                } else {
@@ -593,7 +593,7 @@ public class EmulatorSkin {
 
                                        int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
 
-                                       if ( EmulatorConstants.UNKNOWN_KEYCODE != keyCode ) {
+                                       if ( SkinUtil.UNKNOWN_KEYCODE != keyCode ) {
                                                // draw the button region as the cropped keyPressed image area
                                                SkinRegion region = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
 
@@ -874,28 +874,24 @@ public class EmulatorSkin {
                                }
 
                                String sdbPath = SkinUtil.getSdbPath();
-                               String portNumber = StringUtil.nvl( config.getArg( ArgsConstants.NET_BASE_PORT ) );
+                               int portSdb = config.getArgInt( ArgsConstants.NET_BASE_PORT );
 
-                               if ( !StringUtil.isEmpty( portNumber ) && !StringUtil.isEmpty( portNumber ) ) {
-                                       int portSdb = Integer.parseInt( portNumber );
+                               ProcessBuilder procSdb = new ProcessBuilder();
 
-                                       ProcessBuilder procSdb = new ProcessBuilder();
-
-                                       if ( SkinUtil.isLinuxPlatform() ) {
-                                               procSdb.command( "/usr/bin/gnome-terminal", "--disable-factory",
-                                                               "--title=" + SkinUtil.makeEmulatorName( config ), "-x", sdbPath, "-s", "emulator-"
-                                                                               + portSdb, "shell" );
-                                       } else if ( SkinUtil.isWindowsPlatform() ) {
-                                               procSdb.command( "cmd.exe", "/c", "start", sdbPath, "-s", "emulator-" + portSdb, "shell" );
-                                       }
-                                       logger.log( Level.INFO, procSdb.command().toString() );
+                               if ( SkinUtil.isLinuxPlatform() ) {
+                                       procSdb.command( "/usr/bin/gnome-terminal", "--disable-factory",
+                                                       "--title=" + SkinUtil.makeEmulatorName( config ), "-x", sdbPath, "-s", "emulator-"
+                                                                       + portSdb, "shell" );
+                               } else if ( SkinUtil.isWindowsPlatform() ) {
+                                       procSdb.command( "cmd.exe", "/c", "start", sdbPath, "-s", "emulator-" + portSdb, "shell" );
+                               }
+                               logger.log( Level.INFO, procSdb.command().toString() );
 
-                                       try {
-                                               procSdb.start(); // open sdb shell
-                                       } catch ( Exception ee ) {
-                                               logger.log( Level.SEVERE, ee.getMessage(), ee );
-                                               SkinUtil.openMessage( shell, null, "Fail to open Shell.", SWT.ICON_ERROR, config );
-                                       }
+                               try {
+                                       procSdb.start(); // open sdb shell
+                               } catch ( Exception ee ) {
+                                       logger.log( Level.SEVERE, ee.getMessage(), ee );
+                                       SkinUtil.openMessage( shell, null, "Fail to open Shell.", SWT.ICON_ERROR, config );
                                }
 
                                communicator.sendToQEMU( SendCommand.OPEN_SHELL, null );
@@ -999,22 +995,22 @@ public class EmulatorSkin {
 
                final MenuItem scaleOneItem = new MenuItem( menu, SWT.RADIO );
                scaleOneItem.setText( "1x" );
-               scaleOneItem.setData( 100 );
+               scaleOneItem.setData( Scale.SCALE_100 );
                scaleList.add( scaleOneItem );
 
                final MenuItem scaleThreeQtrItem = new MenuItem( menu, SWT.RADIO );
                scaleThreeQtrItem.setText( "3/4x" );
-               scaleThreeQtrItem.setData( 75 );
+               scaleThreeQtrItem.setData( Scale.SCALE_75 );
                scaleList.add( scaleThreeQtrItem );
 
                final MenuItem scalehalfItem = new MenuItem( menu, SWT.RADIO );
                scalehalfItem.setText( "1/2x" );
-               scalehalfItem.setData( 50 );
+               scalehalfItem.setData( Scale.SCALE_50 );
                scaleList.add( scalehalfItem );
 
                final MenuItem scaleOneQtrItem = new MenuItem( menu, SWT.RADIO );
                scaleOneQtrItem.setText( "1/4x" );
-               scaleOneQtrItem.setData( 25 );
+               scaleOneQtrItem.setData( Scale.SCALE_25 );
                scaleList.add( scaleOneQtrItem );
 
                SelectionAdapter selectionAdapter = new SelectionAdapter() {
@@ -1030,7 +1026,7 @@ public class EmulatorSkin {
                                        return;
                                }
 
-                               int scale = (Integer) item.getData();
+                               int scale = ( (Scale) item.getData() ).value();
 
                                arrangeSkin( currentLcdWidth, currentLcdHeight, scale, currentRotationId );
                                LcdStateData lcdStateData = new LcdStateData( scale, currentRotationId );
@@ -1043,7 +1039,7 @@ public class EmulatorSkin {
 
                for ( MenuItem menuItem : scaleList ) {
 
-                       int scale = (Integer) menuItem.getData();
+                       int scale = ( (Scale) menuItem.getData() ).value();
                        if ( scale == storedScale ) {
                                menuItem.setSelection( true );
                        }
index 0855195..2eda2c2 100644 (file)
@@ -91,6 +91,10 @@ public class EmulatorSkinMain {
                        // able to use log file after loading properties
                        initLog( argsMap, configProperties );
 
+                       EmulatorConfig.validateArgs( argsMap );
+                       EmulatorConfig.validateSkinProperties( skinProperties );
+                       EmulatorConfig.validateSkinConfigProperties( configProperties );
+                       
                        int lcdWidth = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_WIDTH ) );
                        int lcdHeight = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_HEIGHT ) );
                        String argSkinPath = (String) argsMap.get( ArgsConstants.SKIN_PATH );
@@ -112,7 +116,7 @@ public class EmulatorSkinMain {
                        EmulatorSkin skin = new EmulatorSkin( config, isOnTop );
                        int windowHandleId = skin.compose();
 
-                       int uid = Integer.parseInt( config.getArg( ArgsConstants.UID ) );
+                       int uid = config.getArgInt( ArgsConstants.UID );
                        SocketCommunicator communicator = new SocketCommunicator( config, uid, windowHandleId, skin );
 
                        skin.setCommunicator( communicator );
@@ -186,10 +190,10 @@ public class EmulatorSkinMain {
                }else if( !StringUtil.isEmpty( configPropertyLogLevel ) ) {
                        logLevel = configPropertyLogLevel;
                }else {
-                       logLevel = SkinLogLevel.DEBUG.value();
+                       logLevel = EmulatorConfig.DEFAULT_LOG_LEVEL.value();
                }
                
-               SkinLogLevel skinLogLevel = SkinLogLevel.DEBUG;
+               SkinLogLevel skinLogLevel = EmulatorConfig.DEFAULT_LOG_LEVEL;
                
                SkinLogLevel[] values = SkinLogLevel.values();
                
index 5fd163d..f185d27 100644 (file)
@@ -38,6 +38,23 @@ import org.tizen.emulator.skin.dbi.RotationNameType;
  */
 public interface ICommunicator extends Runnable {
 
+       public enum Scale {
+               SCALE_25(25),
+               SCALE_50(50),
+               SCALE_75(75),
+               SCALE_100(100);
+
+               private int value;
+
+               Scale( int value ) {
+                       this.value = value;
+               }
+
+               public int value() {
+                       return this.value;
+               }
+       }
+       
        public enum MouseEventType {
                DOWN( (short)1 ),
                UP( (short)2 ),
index 290825d..a3faeea 100644 (file)
@@ -49,12 +49,9 @@ import org.tizen.emulator.skin.comm.sock.data.ISendData;
 import org.tizen.emulator.skin.comm.sock.data.StartData;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
-import org.tizen.emulator.skin.config.EmulatorConfig.ConfigPropertiesConstants;
-import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.SkinUtil;
-import org.tizen.emulator.skin.util.StringUtil;
 
 
 /**
@@ -130,8 +127,7 @@ public class SocketCommunicator implements ICommunicator {
 
                try {
 
-                       String portString = config.getArg( ArgsConstants.SERVER_PORT );
-                       int port = Integer.parseInt( portString );
+                       int port = config.getArgInt( ArgsConstants.SERVER_PORT );
                        socket = new Socket( "127.0.0.1", port );
                        logger.info( "socket.isConnected():" + socket.isConnected() );
 
@@ -151,11 +147,13 @@ public class SocketCommunicator implements ICommunicator {
                        dis = new DataInputStream( socket.getInputStream() );
                        dos = new DataOutputStream( socket.getOutputStream() );
 
-                       int width = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
-                       int height = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
+                       int width = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+                       int height = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
                        int scale = SkinUtil.getValidScale( config );
-                       short rotation = config.getSkinPropertyShort( SkinPropertiesConstants.WINDOW_ROTATION, RotationInfo.PORTRAIT.id() );
-
+//                     short rotation = config.getSkinPropertyShort( SkinPropertiesConstants.WINDOW_ROTATION,
+//                                     EmulatorConfig.DEFAULT_WINDOW_ROTATION );
+                       // has to be portrait mode at first booting time
+                       short rotation = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
                        StartData startData = new StartData( windowHandleId, width, height, scale, rotation );
 
                        sendToQEMU( SendCommand.SEND_START, startData );
@@ -166,13 +164,7 @@ public class SocketCommunicator implements ICommunicator {
                        return;
                }
 
-               String ignoreHeartbeatString = config.getArg( ArgsConstants.TEST_HEART_BEAT_IGNORE );
-               if ( StringUtil.isEmpty( ignoreHeartbeatString ) ) {
-                       ignoreHeartbeatString = config.getConfigProperty( ConfigPropertiesConstants.TEST_HEART_BEAT_IGNORE,
-                                       Boolean.FALSE.toString() );
-               }
-
-               Boolean ignoreHeartbeat = Boolean.parseBoolean( ignoreHeartbeatString );
+               boolean ignoreHeartbeat = config.getArgBoolean( ArgsConstants.TEST_HEART_BEAT_IGNORE );
 
                if ( ignoreHeartbeat ) {
                        logger.info( "Ignore Skin heartbeat." );
index f5d149f..4b4a8fc 100644 (file)
@@ -37,8 +37,12 @@ import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.comm.ICommunicator.Scale;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
+import org.tizen.emulator.skin.exception.ConfigException;
 import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.StringUtil;
 
@@ -48,9 +52,15 @@ import org.tizen.emulator.skin.util.StringUtil;
  *
  */
 public class EmulatorConfig {
-       
+
        private Logger logger = SkinLogger.getSkinLogger( EmulatorConfig.class ).getLogger();
-       
+
+       public static final int DEFAULT_WINDOW_SCALE = Scale.SCALE_50.value();
+       public static final short DEFAULT_WINDOW_ROTATION = RotationInfo.PORTRAIT.id();
+       public static final int DEFAULT_WINDOW_X = 50;
+       public static final int DEFAULT_WINDOW_Y = 50;
+       public static final SkinLogLevel DEFAULT_LOG_LEVEL = SkinLogLevel.DEBUG;
+
        public interface ArgsConstants {
                public static final String UID = "uid";
                public static final String SERVER_PORT = "svr.port";
@@ -76,12 +86,12 @@ public class EmulatorConfig {
                public static final String LOG_LEVEL = "log.level";
        }
 
-       private Map<String,String> args;
+       private Map<String, String> args;
        private EmulatorUI dbiContents;
        private Properties skinProperties;
        private Properties configProperties;
        private String skinPropertiesFilePath;
-       
+
        public EmulatorConfig( Map<String, String> args, EmulatorUI dbiContents, Properties skinProperties,
                        String skinPropertiesFilePath, Properties configProperties ) {
                this.args = args;
@@ -89,11 +99,95 @@ public class EmulatorConfig {
                this.skinProperties = skinProperties;
                this.skinPropertiesFilePath = skinPropertiesFilePath;
                this.configProperties = configProperties;
-               if( null == configProperties ) {
+               if ( null == configProperties ) {
                        this.configProperties = new Properties();
                }
        }
 
+       public static void validateArgs( Map<String, String> args ) throws ConfigException {
+               if ( null == args ) {
+                       return;
+               }
+
+               String uid = args.get( ArgsConstants.UID );
+               try {
+                       Integer.parseInt( uid );
+               } catch ( NumberFormatException e ) {
+                       String msg = ArgsConstants.UID + " argument is not numeric. : " + uid;
+                       throw new ConfigException( msg );
+               }
+
+               String serverPort = args.get( ArgsConstants.SERVER_PORT );
+               try {
+                       Integer.parseInt( serverPort );
+               } catch ( NumberFormatException e ) {
+                       String msg = ArgsConstants.SERVER_PORT + " argument is not numeric. : " + serverPort;
+                       throw new ConfigException( msg );
+               }
+
+               String width = args.get( ArgsConstants.RESOLUTION_WIDTH );
+               try {
+                       Integer.parseInt( width );
+               } catch ( NumberFormatException e ) {
+                       String msg = ArgsConstants.RESOLUTION_WIDTH + " argument is not numeric. : " + width;
+                       throw new ConfigException( msg );
+               }
+
+               String height = args.get( ArgsConstants.RESOLUTION_HEIGHT );
+               try {
+                       Integer.parseInt( height );
+               } catch ( NumberFormatException e ) {
+                       String msg = ArgsConstants.RESOLUTION_HEIGHT + " argument is not numeric. : " + height;
+                       throw new ConfigException( msg );
+               }
+
+       }
+
+       public static void validateSkinProperties( Properties skinProperties ) throws ConfigException {
+               if ( null == skinProperties ) {
+                       return;
+               }
+
+               String x = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_X );
+               try {
+                       Integer.parseInt( x );
+               } catch ( NumberFormatException e ) {
+                       String msg = SkinPropertiesConstants.WINDOW_X + " in .skin.properties is not numeric. : " + x;
+                       throw new ConfigException( msg );
+               }
+
+               String y = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_Y );
+               try {
+                       Integer.parseInt( y );
+               } catch ( NumberFormatException e ) {
+                       String msg = SkinPropertiesConstants.WINDOW_Y + " in .skin.properties is not numeric. : " + y;
+                       throw new ConfigException( msg );
+               }
+
+               String rotation = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_ROTATION );
+               try {
+                       Integer.parseInt( rotation );
+               } catch ( NumberFormatException e ) {
+                       String msg = SkinPropertiesConstants.WINDOW_ROTATION + " in .skin.properties is not numeric. : " + rotation;
+                       throw new ConfigException( msg );
+               }
+
+               String scale = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_SCALE );
+               try {
+                       Integer.parseInt( scale );
+               } catch ( NumberFormatException e ) {
+                       String msg = SkinPropertiesConstants.WINDOW_SCALE + " in .skin.properties is not numeric. : " + scale;
+                       throw new ConfigException( msg );
+               }
+
+       }
+
+       public static void validateSkinConfigProperties( Properties skinConfigProperties ) throws ConfigException {
+               if ( null == skinConfigProperties ) {
+                       return;
+               }
+       }
+
        public void saveSkinProperties() {
 
                File file = new File( skinPropertiesFilePath );
@@ -143,6 +237,27 @@ public class EmulatorConfig {
                }
        }
 
+       public int getArgInt( String argKey ) {
+               String arg = args.get( argKey );
+               if ( StringUtil.isEmpty( arg ) ) {
+                       return 0;
+               }
+               return Integer.parseInt( arg );
+       }
+
+       public int getArgInt( String argKey, int defaultValue ) {
+               String arg = args.get( argKey );
+               if ( StringUtil.isEmpty( arg ) ) {
+                       return defaultValue;
+               }
+               return Integer.parseInt( arg );
+       }
+
+       public boolean getArgBoolean( String argKey ) {
+               String arg = args.get( argKey );
+               return Boolean.parseBoolean( arg );
+       }
+
        private String getProperty( Properties properties, String key ) {
                return properties.getProperty( key );
        }
@@ -188,7 +303,7 @@ public class EmulatorConfig {
        }
 
        // skin properties //
-       
+
        public String getSkinProperty( String key ) {
                return getProperty( skinProperties, key );
        }
@@ -222,7 +337,7 @@ public class EmulatorConfig {
        }
 
        // config properties //
-       
+
        public String getConfigProperty( String key ) {
                return getProperty( configProperties, key );
        }
index d42ad67..31f8f3f 100644 (file)
@@ -223,7 +223,7 @@ public class DetailInfoDialog extends SkinDialog {
                                                exec = exec.substring( 0, exec.length() - 4 );
                                        }
                                }
-                               logger.info( "exec:" + exec );
+                               
                                if ( exec.endsWith( "x86" ) ) {
                                        cpu = "X86";
                                } else if ( exec.endsWith( "arm" ) ) {
@@ -239,7 +239,6 @@ public class DetailInfoDialog extends SkinDialog {
                                        if ( "-m".equals( arg ) ) {
 
                                                ram = split[i + 1].trim();
-                                               logger.info( "ram:" + ram );
 
                                        } else if ( "-drive".equals( arg ) ) {
 
@@ -306,8 +305,8 @@ public class DetailInfoDialog extends SkinDialog {
                result.put( "Name", SkinUtil.getVmName( config ) );
                result.put( "CPU", cpu );
 
-               String width = config.getArg( ArgsConstants.RESOLUTION_WIDTH );
-               String height = config.getArg( ArgsConstants.RESOLUTION_HEIGHT );
+               int width = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+               int height = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
                result.put( "Display Resolution", width + "x" + height );
                result.put( "Display Density", dpi );
 
  *
  */
 
-package org.tizen.emulator.skin;
+package org.tizen.emulator.skin.exception;
 
 /**
  * 
  *
  */
-public interface EmulatorConstants {
-       
-       public static final int UNKNOWN_KEYCODE = -1;
-       
+public class ConfigException extends EmulatorException {
+
+       private static final long serialVersionUID = -1363305002416148505L;
+
+       public ConfigException() {
+               super();
+       }
+
+       public ConfigException( Throwable cause ) {
+               super( cause );
+       }
+
+    public ConfigException( String message ) {
+        super( message );
+    }
+
+    public ConfigException( String message, Throwable cause ) {
+        super( message, cause );
+    }
+
 }
index 18aaac9..20924c3 100644 (file)
@@ -132,9 +132,9 @@ public class ImageRegistry {
 
                this.display = Display.getDefault();
 
-               int lcdWidth = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
-               int lcdHeight = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
-               this.argSkinPath = (String) config.getArg( ArgsConstants.SKIN_PATH );
+               int lcdWidth = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+               int lcdHeight = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
+               this.argSkinPath = config.getArg( ArgsConstants.SKIN_PATH );
 
                this.resolutionWidth = lcdWidth;
                this.resolutionHeight = lcdHeight;
@@ -280,22 +280,30 @@ public class ImageRegistry {
 
        public void dispose() {
 
-               Collection<Image> images = skinImageMap.values();
+               if ( null != skinImageMap ) {
 
-               Iterator<Image> imageIterator = images.iterator();
+                       Collection<Image> images = skinImageMap.values();
+
+                       Iterator<Image> imageIterator = images.iterator();
+
+                       while ( imageIterator.hasNext() ) {
+                               Image image = imageIterator.next();
+                               image.dispose();
+                       }
 
-               while ( imageIterator.hasNext() ) {
-                       Image image = imageIterator.next();
-                       image.dispose();
                }
 
-               Collection<Image> icons = iconMap.values();
+               if ( null != iconMap ) {
 
-               Iterator<Image> iconIterator = icons.iterator();
+                       Collection<Image> icons = iconMap.values();
+
+                       Iterator<Image> iconIterator = icons.iterator();
+
+                       while ( iconIterator.hasNext() ) {
+                               Image image = iconIterator.next();
+                               image.dispose();
+                       }
 
-               while ( iconIterator.hasNext() ) {
-                       Image image = iconIterator.next();
-                       image.dispose();
                }
 
        }
index fc008dc..ceca7ea 100644 (file)
@@ -246,8 +246,8 @@ public class ScreenShotDialog {
                                        this.image.dispose();
                                }
 
-                               int width = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
-                               int height = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
+                               int width = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+                               int height = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
                                ImageData imageData = new ImageData( width, height, COLOR_DEPTH, paletteData, 1, receivedData );
 
                                RotationInfo rotation = getCurrentRotation();
index 644852a..3019d1c 100644 (file)
@@ -40,8 +40,8 @@ import org.eclipse.swt.graphics.Region;
 import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.skin.EmulatorConstants;
 import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.comm.ICommunicator.Scale;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
@@ -60,7 +60,7 @@ import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
  */
 public class SkinUtil {
 
-       public static final int DEFAULT_SCALE = 50; // 1/2x
+       public static final int UNKNOWN_KEYCODE = -1;
        public static final int SCALE_CONVERTER = 100;
        public static final String EMULATOR_PREFIX = "emulator";
 
@@ -104,13 +104,8 @@ public class SkinUtil {
                        vmName = EMULATOR_PREFIX;
                }
 
-               String portNumber = StringUtil.nvl( config.getArg( ArgsConstants.NET_BASE_PORT ) );
-
-               if ( StringUtil.isEmpty( portNumber ) ) {
-                       return vmName;
-               } else {
-                       return vmName + ":" + portNumber;
-               }
+               int portNumber = config.getArgInt( ArgsConstants.NET_BASE_PORT );
+               return vmName + ":" + portNumber;
 
        }
 
@@ -198,7 +193,7 @@ public class SkinUtil {
                        }
                }
 
-               return EmulatorConstants.UNKNOWN_KEYCODE;
+               return UNKNOWN_KEYCODE;
 
        }
 
@@ -298,10 +293,11 @@ public class SkinUtil {
 
        public static int getValidScale( EmulatorConfig config ) {
 
-               int storedScale = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_SCALE, DEFAULT_SCALE );
-               
+               int storedScale = config.getSkinPropertyInt( SkinPropertiesConstants.WINDOW_SCALE,
+                               EmulatorConfig.DEFAULT_WINDOW_SCALE );
+
                if ( !SkinUtil.isValidScale( storedScale ) ) {
-                       return DEFAULT_SCALE;
+                       return EmulatorConfig.DEFAULT_WINDOW_SCALE;
                }else {
                        return storedScale;
                }
@@ -309,7 +305,8 @@ public class SkinUtil {
        }
 
        public static boolean isValidScale( int scale ) {
-               if ( 100 == scale || 75 == scale || 50 == scale || 25 == scale ) {
+               if ( Scale.SCALE_100.value() == scale || Scale.SCALE_75.value() == scale
+               || Scale.SCALE_50.value() == scale || Scale.SCALE_25.value() == scale ) {
                        return true;
                } else {
                        return false;