[Title] add Always On Top, add new icons, increase VERSION to 1.0
authorSon Hyunjun <hj79.son@samsung.com>
Wed, 28 Mar 2012 12:53:21 +0000 (21:53 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Wed, 28 Mar 2012 12:53:21 +0000 (21:53 +0900)
[Type] Feature
[Module]
[Priority] Major
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: I33e865cbb39d42326ceef61f591be680a8f29bf4

30 files changed:
tizen/src/VERSION
tizen/src/skin/client/resource/icons/about.png
tizen/src/skin/client/resource/icons/advanced.png
tizen/src/skin/client/resource/icons/close.png
tizen/src/skin/client/resource/icons/copy_screenshot_dialog.png [new file with mode: 0644]
tizen/src/skin/client/resource/icons/detail_info.png [new file with mode: 0644]
tizen/src/skin/client/resource/icons/device_info.png [deleted file]
tizen/src/skin/client/resource/icons/execute.png [deleted file]
tizen/src/skin/client/resource/icons/gps.png [deleted file]
tizen/src/skin/client/resource/icons/keypad.png [deleted file]
tizen/src/skin/client/resource/icons/open.png [deleted file]
tizen/src/skin/client/resource/icons/option.png [deleted file]
tizen/src/skin/client/resource/icons/refresh_screenshot_dialog.png [new file with mode: 0644]
tizen/src/skin/client/resource/icons/rotate.png
tizen/src/skin/client/resource/icons/save_screenshot_dialog.png [new file with mode: 0644]
tizen/src/skin/client/resource/icons/scale.png [new file with mode: 0644]
tizen/src/skin/client/resource/icons/scaling.png [deleted file]
tizen/src/skin/client/resource/icons/screenshot.png
tizen/src/skin/client/resource/icons/shell.png
tizen/src/skin/client/resource/icons/telephony.png [deleted file]
tizen/src/skin/client/resource/icons/usb_keyboard.png [new file with mode: 0644]
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/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/AboutDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/LicenseDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/SkinDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java

index 5320adc..9f8e9b6 100644 (file)
@@ -1 +1 @@
-0.21
+1.0
\ No newline at end of file
index 8dea1a0..4f76588 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/about.png and b/tizen/src/skin/client/resource/icons/about.png differ
index 53d3520..14cf9fa 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/advanced.png and b/tizen/src/skin/client/resource/icons/advanced.png differ
index 39de0f0..a1395ce 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/close.png and b/tizen/src/skin/client/resource/icons/close.png differ
diff --git a/tizen/src/skin/client/resource/icons/copy_screenshot_dialog.png b/tizen/src/skin/client/resource/icons/copy_screenshot_dialog.png
new file mode 100644 (file)
index 0000000..a07a5f7
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/copy_screenshot_dialog.png differ
diff --git a/tizen/src/skin/client/resource/icons/detail_info.png b/tizen/src/skin/client/resource/icons/detail_info.png
new file mode 100644 (file)
index 0000000..149ffa2
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/detail_info.png differ
diff --git a/tizen/src/skin/client/resource/icons/device_info.png b/tizen/src/skin/client/resource/icons/device_info.png
deleted file mode 100644 (file)
index f1db57e..0000000
Binary files a/tizen/src/skin/client/resource/icons/device_info.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/execute.png b/tizen/src/skin/client/resource/icons/execute.png
deleted file mode 100644 (file)
index 638d5b3..0000000
Binary files a/tizen/src/skin/client/resource/icons/execute.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/gps.png b/tizen/src/skin/client/resource/icons/gps.png
deleted file mode 100644 (file)
index a1cf0f8..0000000
Binary files a/tizen/src/skin/client/resource/icons/gps.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/keypad.png b/tizen/src/skin/client/resource/icons/keypad.png
deleted file mode 100644 (file)
index ecdadca..0000000
Binary files a/tizen/src/skin/client/resource/icons/keypad.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/open.png b/tizen/src/skin/client/resource/icons/open.png
deleted file mode 100644 (file)
index e08db0f..0000000
Binary files a/tizen/src/skin/client/resource/icons/open.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/option.png b/tizen/src/skin/client/resource/icons/option.png
deleted file mode 100644 (file)
index 6f34bb9..0000000
Binary files a/tizen/src/skin/client/resource/icons/option.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/refresh_screenshot_dialog.png b/tizen/src/skin/client/resource/icons/refresh_screenshot_dialog.png
new file mode 100644 (file)
index 0000000..e1616d9
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/refresh_screenshot_dialog.png differ
index a571aee..b2fc00f 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/rotate.png and b/tizen/src/skin/client/resource/icons/rotate.png differ
diff --git a/tizen/src/skin/client/resource/icons/save_screenshot_dialog.png b/tizen/src/skin/client/resource/icons/save_screenshot_dialog.png
new file mode 100644 (file)
index 0000000..523fe9e
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/save_screenshot_dialog.png differ
diff --git a/tizen/src/skin/client/resource/icons/scale.png b/tizen/src/skin/client/resource/icons/scale.png
new file mode 100644 (file)
index 0000000..1f3f872
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/scale.png differ
diff --git a/tizen/src/skin/client/resource/icons/scaling.png b/tizen/src/skin/client/resource/icons/scaling.png
deleted file mode 100644 (file)
index 5a8114b..0000000
Binary files a/tizen/src/skin/client/resource/icons/scaling.png and /dev/null differ
index c039596..74c8515 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/screenshot.png and b/tizen/src/skin/client/resource/icons/screenshot.png differ
index faa04db..e89f1b1 100644 (file)
Binary files a/tizen/src/skin/client/resource/icons/shell.png and b/tizen/src/skin/client/resource/icons/shell.png differ
diff --git a/tizen/src/skin/client/resource/icons/telephony.png b/tizen/src/skin/client/resource/icons/telephony.png
deleted file mode 100644 (file)
index add86a8..0000000
Binary files a/tizen/src/skin/client/resource/icons/telephony.png and /dev/null differ
diff --git a/tizen/src/skin/client/resource/icons/usb_keyboard.png b/tizen/src/skin/client/resource/icons/usb_keyboard.png
new file mode 100644 (file)
index 0000000..69a87f3
Binary files /dev/null and b/tizen/src/skin/client/resource/icons/usb_keyboard.png differ
index 7d5b101..50e9224 100644 (file)
@@ -43,12 +43,16 @@ import org.eclipse.swt.events.DragDetectEvent;
 import org.eclipse.swt.events.DragDetectListener;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MenuAdapter;
 import org.eclipse.swt.events.MenuDetectEvent;
 import org.eclipse.swt.events.MenuDetectListener;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.MouseMoveListener;
 import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.MouseTrackListener;
 import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -99,8 +103,30 @@ import org.tizen.emulator.skin.util.StringUtil;
  */
 public class EmulatorSkin {
 
+       public class SkinReopenPolicy {
+
+               private EmulatorSkin reopenSkin;
+               private boolean reopen;
+
+               private SkinReopenPolicy( EmulatorSkin reopenSkin, boolean reopen ) {
+                       this.reopenSkin = reopenSkin;
+                       this.reopen = reopen;
+               }
+
+               public EmulatorSkin getReopenSkin() {
+                       return reopenSkin;
+               }
+
+               public boolean isReopen() {
+                       return reopen;
+               }
+
+       }
+
        private Logger logger = SkinLogger.getSkinLogger( EmulatorSkin.class ).getLogger();
 
+       private static final String MENU_ITEM_IMAGE = "ITEM_IMAGE";
+
        private EmulatorConfig config;
        private Shell shell;
        private ImageRegistry imageRegistry;
@@ -109,7 +135,7 @@ public class EmulatorSkin {
        private Image currentKeyPressedImage;
        private Color hoverColor;
        private boolean isDefaultHoverColor;
-       
+
        private int currentScale;
        private short currentRotationId;
        private int currentAngle;
@@ -123,14 +149,43 @@ public class EmulatorSkin {
        private boolean isDragStartedInLCD;
        private boolean isHoverState;
        private boolean isShutdownRequested;
-       
+       private boolean isAboutToReopen;
+       private boolean isOnTop;
+       private boolean isScreenShotOpened;
+
+       private ScreenShotDialog screenShotDialog;
+
        private SocketCommunicator communicator;
        private int windowHandleId;
 
-       protected EmulatorSkin( EmulatorConfig config ) {
+       private Listener shellCloseListener;
+       private PaintListener shellPaintListener;
+       private MouseTrackListener shellMouseTrackListener;
+       private MouseMoveListener shellMouseMoveListener;
+       private MouseListener shellMouseListener;
+
+       private DragDetectListener canvasDragDetectListener;
+       private MouseMoveListener canvasMouseMoveListener;
+       private MouseListener canvasMouseListener;
+       private KeyListener canvasKeyListener;
+       private MenuDetectListener canvasMenuDetectListener;
+
+       private MenuListener menuListener;
+
+       private EmulatorSkin reopenSkin;
+
+       protected EmulatorSkin( EmulatorConfig config, boolean isOnTop ) {
                this.config = config;
-               this.shell = new Shell( new Display(), SWT.NO_TRIM );
                this.isDefaultHoverColor = true;
+
+               this.isOnTop = isOnTop;
+
+               int style = SWT.NO_TRIM;
+               if ( isOnTop ) {
+                       style |= SWT.ON_TOP;
+               }
+               this.shell = new Shell( Display.getDefault(), style );
+
        }
 
        public void setCommunicator( SocketCommunicator communicator ) {
@@ -139,57 +194,135 @@ public class EmulatorSkin {
 
        public int compose() {
 
-               imageRegistry = new ImageRegistry( shell.getDisplay(), config );
-
-               shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
+               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 scale = SkinUtil.getValidScale( config );
+               // int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION, RotationInfo.PORTRAIT.id() );
+               // has to be portrait mode at first booting time
+               short rotationId = RotationInfo.PORTRAIT.id();
+               
+               composeInternal( lcdCanvas, x, y, lcdWidth, lcdHeight, scale, rotationId );
+
+               // sdl uses this handle id.
+               windowHandleId = getWindowHandleId();
+
+               return windowHandleId;
+
+       }
+
+       private void composeInternal( Canvas lcdCanvas, int x, int y, int lcdWidth, int lcdHeight, int scale,
+                       short rotationId ) {
+
+               lcdCanvas.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
+
+               imageRegistry = ImageRegistry.getInstance();
+
+               shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
+
                shell.setLocation( x, y );
 
                String emulatorName = SkinUtil.makeEmulatorName( config );
                shell.setText( emulatorName );
-               
-               if( SkinUtil.isWindowsPlatform() ) {
+
+               if ( SkinUtil.isWindowsPlatform() ) {
                        shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE_ICO ) );
-               }else {
+               } else {
                        shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE ) );
                }
-               
-               this.lcdCanvas = new Canvas( shell, SWT.EMBEDDED );
-               lcdCanvas.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
-               
-               int lcdWidth = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
-               int lcdHeight = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
-               
-               int scale = SkinUtil.getValidScale( config );
-               
-//             short rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION, RotationInfo.PORTRAIT.id() );
-               // has to be portrait mode at first booting time
-               arrangeSkin( lcdWidth, lcdHeight, scale, RotationInfo.PORTRAIT.id() );
-               
-               decideHoverColor();
 
-               Menu menu = new Menu( shell );
-               addMenuItems( menu );
-               shell.setMenu( menu );
-               
-               addLCDListener( lcdCanvas );
+               arrangeSkin( lcdWidth, lcdHeight, scale, rotationId );
+
+               seteHoverColor();
+
+               setMenu();
+
+       }
+
+       private void setMenu() {
+
+               Menu contextMenu = new Menu( shell );
+
+               menuListener = new MenuAdapter() {
+                       @Override
+                       public void menuShown( MenuEvent e ) {
+
+                               Menu menu = (Menu) e.getSource();
+                               MenuItem[] items = menu.getItems();
+
+                               for ( MenuItem menuItem : items ) {
+
+                                       Image image = (Image) menuItem.getData( MENU_ITEM_IMAGE );
+                                       if ( null != image ) {
+                                               menuItem.setImage( image );
+                                       }
+
+                                       Menu subMenu = menuItem.getMenu();
+                                       if ( null != subMenu ) {
+                                               subMenu.removeMenuListener( menuListener );
+                                               subMenu.addMenuListener( menuListener );
+                                       }
+
+                               }
+
+                       }
+
+               };
+
+               contextMenu.addMenuListener( menuListener );
+
+               addMenuItems( shell, contextMenu );
+
                addShellListener( shell );
+               addCanvasListener( shell, lcdCanvas );
 
-               // sdl uses this handle id.
-               windowHandleId = getWindowHandleId( lcdCanvas );
+               shell.setMenu( contextMenu );
 
-               return windowHandleId;
+       }
+
+       private void readyToReopen( EmulatorSkin sourceSkin, boolean isOnTop ) {
+
+               logger.info( "Start Changing AlwaysOnTop status" );
+
+               sourceSkin.reopenSkin = new EmulatorSkin( sourceSkin.config, isOnTop );
+
+               sourceSkin.reopenSkin.lcdCanvas = sourceSkin.lcdCanvas;
+               Point previousLocation = sourceSkin.shell.getLocation();
+
+               sourceSkin.reopenSkin.composeInternal( sourceSkin.lcdCanvas, previousLocation.x, previousLocation.y,
+                               sourceSkin.currentLcdWidth, sourceSkin.currentLcdHeight, sourceSkin.currentScale,
+                               sourceSkin.currentRotationId );
+
+               sourceSkin.reopenSkin.windowHandleId = sourceSkin.windowHandleId;
+
+               sourceSkin.reopenSkin.communicator = sourceSkin.communicator;
+               sourceSkin.reopenSkin.communicator.resetSkin( reopenSkin );
+
+               sourceSkin.isAboutToReopen = true;
+               sourceSkin.isShutdownRequested = true;
+
+               if ( sourceSkin.isScreenShotOpened && ( null != sourceSkin.screenShotDialog ) ) {
+                       sourceSkin.screenShotDialog.setReserveImage( true );
+                       sourceSkin.screenShotDialog.setEmulatorSkin( reopenSkin );
+                       reopenSkin.isScreenShotOpened = true;
+                       reopenSkin.screenShotDialog = sourceSkin.screenShotDialog;
+                       // see open() method to know next logic for screenshot dialog.
+               }
+
+               sourceSkin.lcdCanvas.setParent( reopenSkin.shell );
+               sourceSkin.shell.close();
 
        }
-       
-       private int getWindowHandleId( Canvas lcdCanvas ) {
-               
+
+       private int getWindowHandleId() {
+
                int windowHandleId = 0;
-               
-               if( SkinUtil.isLinuxPlatform() ) {
-                       
+
+               if ( SkinUtil.isLinuxPlatform() ) {
+
                        try {
                                Field field = lcdCanvas.getClass().getField( "embeddedHandle" );
                                windowHandleId = field.getInt( lcdCanvas );
@@ -207,27 +340,27 @@ public class EmulatorSkin {
                                logger.log( Level.SEVERE, e.getMessage(), e );
                                shutdown();
                        }
-                       
-               }else if( SkinUtil.isWindowsPlatform() ) {
-                       
+
+               } else if ( SkinUtil.isWindowsPlatform() ) {
+
                        logger.info( "lcdCanvas.handle:" + lcdCanvas.handle );
                        windowHandleId = lcdCanvas.handle;
-                       
-               }else if( SkinUtil.isMacPlatform() ) {
-                       
-                       //TODO
-                       
-               }else {
+
+               } else if ( SkinUtil.isMacPlatform() ) {
+
+                       // TODO
+
+               } else {
                        logger.severe( "Not Supported OS platform:" + SWT.getPlatform() );
                        System.exit( -1 );
                }
 
                return windowHandleId;
-               
+
        }
-       
-       private void decideHoverColor() {
-               
+
+       private void seteHoverColor() {
+
                ColorsType colors = config.getDbiContents().getColors();
                if ( null != colors ) {
                        RgbType hoverRgb = colors.getHoverColor();
@@ -242,31 +375,41 @@ public class EmulatorSkin {
                        }
                }
 
-               if( isDefaultHoverColor ) {
-                       hoverColor = shell.getDisplay().getSystemColor( SWT.COLOR_WHITE );                      
+               if ( isDefaultHoverColor ) {
+                       hoverColor = shell.getDisplay().getSystemColor( SWT.COLOR_WHITE );
                }
 
        }
-       
-       public void open() {
+
+       public SkinReopenPolicy open() {
 
                if ( null == this.communicator ) {
                        logger.severe( "communicator is null." );
-                       shell.close();
-                       return;
+                       return null;
                }
 
                Display display = this.shell.getDisplay();
 
                this.shell.open();
 
+               // logic only for reopen case ///////
+               if ( isScreenShotOpened && ( null != screenShotDialog ) ) {
+                       try {
+                               screenShotDialog.setReserveImage( false );
+                               screenShotDialog.open();
+                       } finally {
+                               isScreenShotOpened = false;
+                       }
+               }
+               // ///////////////////////////////////
+
                while ( !shell.isDisposed() ) {
                        if ( !display.readAndDispatch() ) {
                                display.sleep();
                        }
                }
 
-               display.dispose();
+               return new SkinReopenPolicy( reopenSkin, isAboutToReopen );
 
        }
 
@@ -299,19 +442,34 @@ public class EmulatorSkin {
        }
 
        private void addShellListener( final Shell shell ) {
-               
-               shell.addListener( SWT.Close, new Listener() {
+
+               shellCloseListener = new Listener() {
                        @Override
                        public void handleEvent( Event event ) {
 
                                if ( isShutdownRequested ) {
 
-                                       config.setSkinProperty( SkinPropertiesConstants.WINDOW_X, shell.getLocation().x );
-                                       config.setSkinProperty( SkinPropertiesConstants.WINDOW_Y, shell.getLocation().y );
-                                       config.setSkinProperty( SkinPropertiesConstants.WINDOW_SCALE, currentScale );
-                                       config.setSkinProperty( SkinPropertiesConstants.WINDOW_ROTATION, currentRotationId );
+                                       removeShellListeners();
+                                       removeCanvasListeners();
+
+                                       if ( !isAboutToReopen ) {
 
-                                       config.saveSkinProperties();
+                                               if ( isScreenShotOpened && ( null != screenShotDialog ) ) {
+                                                       Shell scShell = screenShotDialog.getShell();
+                                                       if ( !scShell.isDisposed() ) {
+                                                               scShell.close();
+                                                       }
+                                               }
+
+                                               // save config only for emulator close
+                                               config.setSkinProperty( SkinPropertiesConstants.WINDOW_X, shell.getLocation().x );
+                                               config.setSkinProperty( SkinPropertiesConstants.WINDOW_Y, shell.getLocation().y );
+                                               config.setSkinProperty( SkinPropertiesConstants.WINDOW_SCALE, currentScale );
+                                               config.setSkinProperty( SkinPropertiesConstants.WINDOW_ROTATION, currentRotationId );
+                                               config.setSkinProperty( SkinPropertiesConstants.WINDOW_ONTOP, Boolean.toString( isOnTop ) );
+                                               config.saveSkinProperties();
+
+                                       }
 
                                        if ( null != currentImage ) {
                                                currentImage.dispose();
@@ -320,9 +478,7 @@ public class EmulatorSkin {
                                                currentKeyPressedImage.dispose();
                                        }
 
-                                       imageRegistry.dispose();
-                                       
-                                       if( !isDefaultHoverColor ) {
+                                       if ( !isDefaultHoverColor ) {
                                                hoverColor.dispose();
                                        }
 
@@ -337,9 +493,11 @@ public class EmulatorSkin {
                                }
 
                        }
-               } );
+               };
 
-               shell.addPaintListener( new PaintListener() {
+               shell.addListener( SWT.Close, shellCloseListener );
+
+               shellPaintListener = new PaintListener() {
 
                        @Override
                        public void paintControl( final PaintEvent e ) {
@@ -350,28 +508,32 @@ public class EmulatorSkin {
                                }
 
                        }
-               } );
+               };
+
+               shell.addPaintListener( shellPaintListener );
 
-               shell.addMouseTrackListener( new MouseTrackAdapter() {
+               shellMouseTrackListener = new MouseTrackAdapter() {
                        @Override
                        public void mouseExit( MouseEvent e ) {
                                // MouseMoveListener of shell does not receive event only with MouseMoveListener
                                // in case that : hover hardkey -> mouse move into LCD area
-                               if( isHoverState ) {
-                                       if (currentHoverRegion.width == 0 && currentHoverRegion.height == 0) {
+                               if ( isHoverState ) {
+                                       if ( currentHoverRegion.width == 0 && currentHoverRegion.height == 0 ) {
                                                shell.redraw();
                                        } else {
-                                               shell.redraw( currentHoverRegion.x, currentHoverRegion.y,
-                                                               currentHoverRegion.width + 1, currentHoverRegion.height + 1, false );
+                                               shell.redraw( currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width + 1,
+                                                               currentHoverRegion.height + 1, false );
                                        }
                                        isHoverState = false;
                                        currentHoverRegion.width = currentHoverRegion.height = 0;
                                }
                        }
-                       
-               } );
-               
-               shell.addMouseMoveListener( new MouseMoveListener() {
+
+               };
+
+               shell.addMouseTrackListener( shellMouseTrackListener );
+
+               shellMouseMoveListener = new MouseMoveListener() {
 
                        @Override
                        public void mouseMove( MouseEvent e ) {
@@ -394,12 +556,12 @@ public class EmulatorSkin {
                                        SkinRegion region = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
 
                                        if ( null == region ) {
-                                               if( isHoverState ) {
-                                                       if (currentHoverRegion.width == 0 && currentHoverRegion.height == 0) {
+                                               if ( isHoverState ) {
+                                                       if ( currentHoverRegion.width == 0 && currentHoverRegion.height == 0 ) {
                                                                shell.redraw();
                                                        } else {
-                                                               shell.redraw( currentHoverRegion.x, currentHoverRegion.y,
-                                                                               currentHoverRegion.width + 1, currentHoverRegion.height + 1, false );
+                                                               shell.redraw( currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width + 1,
+                                                                               currentHoverRegion.height + 1, false );
                                                        }
                                                        isHoverState = false;
                                                        currentHoverRegion.width = currentHoverRegion.height = 0;
@@ -417,9 +579,11 @@ public class EmulatorSkin {
                                }
 
                        }
-               } );
+               };
 
-               shell.addMouseListener( new MouseListener() {
+               shell.addMouseMoveListener( shellMouseMoveListener );
+
+               shellMouseListener = new MouseListener() {
 
                        @Override
                        public void mouseUp( MouseEvent e ) {
@@ -432,16 +596,16 @@ public class EmulatorSkin {
                                        int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
 
                                        if ( EmulatorConstants.UNKNOWN_KEYCODE != keyCode ) {
-                                               if (currentHoverRegion.width == 0 && currentHoverRegion.height == 0) {
+                                               if ( currentHoverRegion.width == 0 && currentHoverRegion.height == 0 ) {
                                                        shell.redraw();
                                                } else {
-                                                       shell.redraw( currentHoverRegion.x, currentHoverRegion.y,
-                                                                       currentHoverRegion.width + 1, currentHoverRegion.height + 1, false );
+                                                       shell.redraw( currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width + 1,
+                                                                       currentHoverRegion.height + 1, false );
                                                }
                                                KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
                                                communicator.sendToQEMU( SendCommand.SEND_HARD_KEY_EVENT, keyEventData );
                                        }
-                                       
+
                                }
                        }
 
@@ -462,9 +626,9 @@ public class EmulatorSkin {
 
                                                if ( null != currentKeyPressedImage ) {
                                                        GC gc = new GC( shell );
-                                                       gc.drawImage( currentKeyPressedImage,
-                                                                       region.x + 1, region.y + 1, region.width - 1, region.height - 1, //src
-                                                                       region.x + 1, region.y + 1, region.width - 1, region.height - 1 ); //dst
+                                                       gc.drawImage( currentKeyPressedImage, region.x + 1, region.y + 1, region.width - 1,
+                                                                       region.height - 1, // src
+                                                                       region.x + 1, region.y + 1, region.width - 1, region.height - 1 ); // dst
                                                        gc.dispose();
                                                }
 
@@ -477,14 +641,35 @@ public class EmulatorSkin {
                        @Override
                        public void mouseDoubleClick( MouseEvent e ) {
                        }
-               } );
+               };
+
+               shell.addMouseListener( shellMouseListener );
+
+       }
+
+       private void removeShellListeners() {
+
+               if ( null != shellCloseListener ) {
+                       shell.removeListener( SWT.Close, shellCloseListener );
+               }
+               if ( null != shellPaintListener ) {
+                       shell.removePaintListener( shellPaintListener );
+               }
+               if ( null != shellMouseTrackListener ) {
+                       shell.removeMouseTrackListener( shellMouseTrackListener );
+               }
+               if ( null != shellMouseMoveListener ) {
+                       shell.removeMouseMoveListener( shellMouseMoveListener );
+               }
+               if ( null != shellMouseListener ) {
+                       shell.removeMouseListener( shellMouseListener );
+               }
 
        }
 
-       private void addLCDListener( final Canvas canvas ) {
+       private void addCanvasListener( final Shell shell, final Canvas canvas ) {
 
-               // remove 'input method' menu item 
-               canvas.addMenuDetectListener( new MenuDetectListener() {
+               canvasMenuDetectListener = new MenuDetectListener() {
                        @Override
                        public void menuDetected( MenuDetectEvent e ) {
                                Menu menu = shell.getMenu();
@@ -492,28 +677,33 @@ public class EmulatorSkin {
                                menu.setVisible( true );
                                e.doit = false;
                        }
-               } );
+               };
 
-               canvas.addDragDetectListener( new DragDetectListener() {
+               // remove 'input method' menu item ( avoid bug )
+               canvas.addMenuDetectListener( canvasMenuDetectListener );
+
+               canvasDragDetectListener = new DragDetectListener() {
 
                        @Override
                        public void dragDetected( DragDetectEvent e ) {
-                               if( logger.isLoggable( Level.FINE ) ) {
+                               if ( logger.isLoggable( Level.FINE ) ) {
                                        logger.fine( "dragDetected e.button:" + e.button );
                                }
                                if ( 1 == e.button && // left button
                                                e.x > 0 && e.x < canvas.getSize().x && e.y > 0 && e.y < canvas.getSize().y ) {
 
-                                       if( logger.isLoggable( Level.FINE ) ) {
+                                       if ( logger.isLoggable( Level.FINE ) ) {
                                                logger.fine( "dragDetected in LCD" );
                                        }
                                        EmulatorSkin.this.isDragStartedInLCD = true;
 
                                }
                        }
-               } );
+               };
+
+               canvas.addDragDetectListener( canvasDragDetectListener );
 
-               canvas.addMouseMoveListener( new MouseMoveListener() {
+               canvasMouseMoveListener = new MouseMoveListener() {
 
                        @Override
                        public void mouseMove( MouseEvent e ) {
@@ -543,14 +733,16 @@ public class EmulatorSkin {
 
                                        int[] geometry = SkinUtil.convertMouseGeometry( e.x, e.y, currentLcdWidth, currentLcdHeight,
                                                        currentScale, currentAngle );
-                                       
+
                                        MouseEventData mouseEventData = new MouseEventData( eventType, geometry[0], geometry[1], 0 );
                                        communicator.sendToQEMU( SendCommand.SEND_MOUSE_EVENT, mouseEventData );
                                }
                        }
-               } );
+               };
+
+               canvas.addMouseMoveListener( canvasMouseMoveListener );
 
-               canvas.addMouseListener( new MouseListener() {
+               canvasMouseListener = new MouseListener() {
 
                        @Override
                        public void mouseUp( MouseEvent e ) {
@@ -586,9 +778,11 @@ public class EmulatorSkin {
                        @Override
                        public void mouseDoubleClick( MouseEvent e ) {
                        }
-               } );
+               };
+
+               canvas.addMouseListener( canvasMouseListener );
 
-               canvas.addKeyListener( new KeyListener() {
+               canvasKeyListener = new KeyListener() {
 
                        @Override
                        public void keyReleased( KeyEvent e ) {
@@ -607,64 +801,81 @@ public class EmulatorSkin {
                                communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
                        }
 
-               } );
+               };
+
+               canvas.addKeyListener( canvasKeyListener );
+
+       }
+
+       private void removeCanvasListeners() {
+
+               if ( null != canvasDragDetectListener ) {
+                       lcdCanvas.removeDragDetectListener( canvasDragDetectListener );
+               }
+               if ( null != canvasMouseMoveListener ) {
+                       lcdCanvas.removeMouseMoveListener( canvasMouseMoveListener );
+               }
+               if ( null != canvasMouseListener ) {
+                       lcdCanvas.removeMouseListener( canvasMouseListener );
+               }
+               if ( null != canvasKeyListener ) {
+                       lcdCanvas.removeKeyListener( canvasKeyListener );
+               }
+               if ( null != canvasMenuDetectListener ) {
+                       lcdCanvas.removeMenuDetectListener( canvasMenuDetectListener );
+               }
 
        }
 
-       private void addMenuItems( final Menu menu ) {
+       private void addMenuItems( final Shell shell, final Menu menu ) {
 
                final MenuItem deviceInfoItem = new MenuItem( menu, SWT.PUSH );
 
                String emulatorName = SkinUtil.makeEmulatorName( config );
                deviceInfoItem.setText( emulatorName );
-//             deviceInfoItem.setImage( imageRegistry.getIcon( IconName.DEVICE_INFO ) );
-               //FIXME
-               deviceInfoItem.setEnabled( false );
+               deviceInfoItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.DETAIL_INFO ) );
                deviceInfoItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-                               if( logger.isLoggable( Level.FINE ) ) {
+                               if ( logger.isLoggable( Level.FINE ) ) {
                                        logger.fine( "Open device info" );
                                }
                        }
                } );
 
-               deviceInfoItem.addListener( SWT.PaintItem, new Listener() {
-                       @Override
-                       public void handleEvent( Event event ) {
-                               event.gc.drawImage( imageRegistry.getIcon( IconName.DEVICE_INFO ), 0, 0 );
-                       }
-               } );
-               
                new MenuItem( menu, SWT.SEPARATOR );
 
-               final MenuItem aotItem = new MenuItem( menu, SWT.CHECK );
-               aotItem.setText( "Always On Top" );
-               //FIXME
-               aotItem.setEnabled( false );
-               aotItem.addSelectionListener( new SelectionAdapter() {
-                       private boolean isTop;
+               final MenuItem onTopItem = new MenuItem( menu, SWT.CHECK );
+               onTopItem.setText( "Always On Top" );
+               onTopItem.setSelection( isOnTop );
+
+               onTopItem.addSelectionListener( new SelectionAdapter() {
 
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-                               if( logger.isLoggable( Level.FINE ) ) {
-                                       logger.fine( "Select Always On Top. : " + aotItem.getSelection() );
+
+                               final boolean isOnTop = onTopItem.getSelection();
+
+                               if ( logger.isLoggable( Level.FINE ) ) {
+                                       logger.fine( "Select Always On Top. : " + isOnTop );
                                }
-                               isTop = !isTop;
-                               //TODO
+
+                               readyToReopen( EmulatorSkin.this, isOnTop );
+
                        }
                } );
 
                final MenuItem rotateItem = new MenuItem( menu, SWT.CASCADE );
                rotateItem.setText( "Rotate" );
-//             rotateItem.setImage( imageRegistry.getIcon( IconName.ROTATE ) );
+               rotateItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.ROTATE ) );
 
                Menu rotateMenu = createRotateMenu( menu.getShell() );
                rotateItem.setMenu( rotateMenu );
 
                final MenuItem scaleItem = new MenuItem( menu, SWT.CASCADE );
                scaleItem.setText( "Scale" );
-//             scaleItem.setImage( imageRegistry.getIcon( IconName.SCALING ) );
+               scaleItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.SCALE ) );
+
                Menu scaleMenu = createScaleMenu( menu.getShell() );
                scaleItem.setMenu( scaleMenu );
 
@@ -672,13 +883,15 @@ public class EmulatorSkin {
 
                final MenuItem advancedItem = new MenuItem( menu, SWT.CASCADE );
                advancedItem.setText( "Advanced" );
-//             advancedItem.setImage( imageRegistry.getIcon( IconName.ADVANCED ) );
+               advancedItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.ADVANCED ) );
+
                Menu advancedMenu = createAdvancedMenu( menu.getShell() );
                advancedItem.setMenu( advancedMenu );
 
                final MenuItem shellItem = new MenuItem( menu, SWT.PUSH );
                shellItem.setText( "Shell" );
-//             shellItem.setImage( imageRegistry.getIcon( IconName.SHELL ) );
+               shellItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.SHELL ) );
+
                shellItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
@@ -688,28 +901,27 @@ public class EmulatorSkin {
                                }
 
                                String sdbPath = SkinUtil.getSdbPath();
-                               String portNumber = StringUtil.nvl(config.getArg( ArgsConstants.NET_BASE_PORT ));
+                               String portNumber = StringUtil.nvl( config.getArg( ArgsConstants.NET_BASE_PORT ) );
 
-                               if (!StringUtil.isEmpty(portNumber) && !StringUtil.isEmpty(portNumber)) {
-                                       int portSdb = Integer.parseInt(portNumber) + 1;
+                               if ( !StringUtil.isEmpty( portNumber ) && !StringUtil.isEmpty( portNumber ) ) {
+                                       int portSdb = Integer.parseInt( portNumber ) + 1;
 
-                                       ProcessBuilder procConnect = new ProcessBuilder(sdbPath, "connect", "localhost:" + portSdb);
+                                       ProcessBuilder procConnect = new ProcessBuilder( sdbPath, "connect", "localhost:" + portSdb );
                                        ProcessBuilder procSdb = new ProcessBuilder();
 
-                                       if (SkinUtil.isLinuxPlatform()) {
-                                               procSdb.command("/usr/bin/gnome-terminal", "--disable-factory",
-                                                               "--title=" + SkinUtil.makeEmulatorName(config), "-x",
-                                                               sdbPath, "-s", "localhost:" + portSdb, "shell");
-                                       } else if (SkinUtil.isWindowsPlatform()) {
-                                               procSdb.command("cmd.exe", "/c", "start",
-                                                               sdbPath, "-s", "localhost:" + portSdb, "shell");
+                                       if ( SkinUtil.isLinuxPlatform() ) {
+                                               procSdb.command( "/usr/bin/gnome-terminal", "--disable-factory",
+                                                               "--title=" + SkinUtil.makeEmulatorName( config ), "-x", sdbPath, "-s", "localhost:"
+                                                                               + portSdb, "shell" );
+                                       } else if ( SkinUtil.isWindowsPlatform() ) {
+                                               procSdb.command( "cmd.exe", "/c", "start", sdbPath, "-s", "localhost:" + portSdb, "shell" );
                                        }
 
                                        try {
-                                               procConnect.start(); //connect with sdb
-                                               procSdb.start(); //open sdb shell
-                                       } catch (Exception ee) {
-                                               logger.log(Level.SEVERE, ee.getMessage(), ee);
+                                               procConnect.start(); // connect with sdb
+                                               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 );
                                        }
                                }
@@ -722,7 +934,7 @@ public class EmulatorSkin {
 
                MenuItem closeItem = new MenuItem( menu, SWT.PUSH );
                closeItem.setText( "Close" );
-//             closeItem.setImage( imageRegistry.getIcon( IconName.CLOSE ) );
+               closeItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.CLOSE ) );
                closeItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
@@ -738,10 +950,6 @@ public class EmulatorSkin {
 
                final List<MenuItem> rotationList = new ArrayList<MenuItem>();
 
-//             final short storedDirectionId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION,
-//                             (short) RotationInfo.PORTRAIT.id() );
-               final short storedDirectionId = RotationInfo.PORTRAIT.id();
-               
                Iterator<Entry<Short, RotationType>> iterator = SkinRotation.getRotationIterator();
 
                while ( iterator.hasNext() ) {
@@ -753,11 +961,8 @@ public class EmulatorSkin {
                        final MenuItem menuItem = new MenuItem( menu, SWT.RADIO );
                        menuItem.setText( section.getName().value() );
                        menuItem.setData( rotationId );
-                       if ( storedDirectionId == rotationId ) {
-                               menuItem.setSelection( true );
-                       }
 
-                       if ( RotationInfo.PORTRAIT.id() == rotationId ) {
+                       if ( currentRotationId == rotationId ) {
                                menuItem.setSelection( true );
                        }
 
@@ -789,9 +994,10 @@ public class EmulatorSkin {
                                                        break;
                                                }
                                        }
-                                       ///////////
-                                       
-                                       SkinUtil.openMessage( shell, null, "Rotation is not ready.\nPlease, wait.", SWT.ICON_WARNING, config );
+                                       // /////////
+
+                                       SkinUtil.openMessage( shell, null, "Rotation is not ready.\nPlease, wait.", SWT.ICON_WARNING,
+                                                       config );
 
                                        return;
 
@@ -880,54 +1086,50 @@ public class EmulatorSkin {
 
        private Menu createAdvancedMenu( final Shell shell ) {
 
-               Menu menu = new Menu( shell, SWT.DROP_DOWN );
+               final Menu menu = new Menu( shell, SWT.DROP_DOWN );
 
                final MenuItem screenshotItem = new MenuItem( menu, SWT.PUSH );
                screenshotItem.setText( "Screen Shot" );
-//             screenshotItem.setImage( imageRegistry.getIcon( IconName.SCREENSHOT ) );
+               screenshotItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.SCREENSHOT ) );
                screenshotItem.addSelectionListener( new SelectionAdapter() {
-                       
-                       private boolean isOpen;
-                       
+
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-                               
-                               ScreenShotDialog dialog = null;
-                               
+
+                               if ( isScreenShotOpened ) {
+                                       return;
+                               }
+
                                try {
-                                       
-                                       if( !isOpen ) {
-                                               isOpen = true;
-                                               dialog = new ScreenShotDialog( shell, communicator, EmulatorSkin.this, config );
-                                               dialog.open();
-                                       }
-                                       
+
+                                       isScreenShotOpened = true;
+
+                                       screenShotDialog = new ScreenShotDialog( shell, communicator, EmulatorSkin.this, config );
+                                       screenShotDialog.open();
+
                                } catch ( ScreenShotException ex ) {
-                                       
+
                                        logger.log( Level.SEVERE, ex.getMessage(), ex );
                                        SkinUtil.openMessage( shell, null, "Fail to create a screen shot.", SWT.ICON_ERROR, config );
-                                       
+
                                } catch ( Exception ex ) {
-                                       
+
                                        // defense exception handling.
                                        logger.log( Level.SEVERE, ex.getMessage(), ex );
                                        String errorMessage = "Internal Error.\n[" + ex.getMessage() + "]";
                                        SkinUtil.openMessage( shell, null, errorMessage, SWT.ICON_ERROR, config );
-                                       if( null != dialog ) {
-                                               dialog.close();
-                                       }
-                                       
+
                                } finally {
-                                       isOpen = false;
+                                       isScreenShotOpened = false;
                                }
-                               
+
                        }
                } );
 
                final MenuItem usbKeyboardItem = new MenuItem( menu, SWT.CASCADE );
                usbKeyboardItem.setText( "USB Keyboard" );
-//             usbKeyboardItem.setImage( imageRegistry.getIcon( IconName.USB_KEBOARD ) );
-               
+               usbKeyboardItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.USB_KEBOARD ) );
+
                Menu usbKeyBoardMenu = new Menu( shell, SWT.DROP_DOWN );
 
                final MenuItem usbOnItem = new MenuItem( usbKeyBoardMenu, SWT.RADIO );
@@ -936,7 +1138,7 @@ public class EmulatorSkin {
                final MenuItem usbOffItem = new MenuItem( usbKeyBoardMenu, SWT.RADIO );
                usbOffItem.setText( "Off" );
                usbOffItem.setSelection( true );
-               
+
                SelectionAdapter usbSelectionAdaptor = new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
@@ -957,14 +1159,16 @@ public class EmulatorSkin {
 
                final MenuItem aboutItem = new MenuItem( menu, SWT.PUSH );
                aboutItem.setText( "About" );
-//             aboutItem.setImage( imageRegistry.getIcon( IconName.ABOUT ) );
+               aboutItem.setData( MENU_ITEM_IMAGE, imageRegistry.getIcon( IconName.ABOUT ) );
+
                aboutItem.addSelectionListener( new SelectionAdapter() {
                        private boolean isOpen;
+
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-                               if( !isOpen ) {
+                               if ( !isOpen ) {
                                        isOpen = true;
-                                       AboutDialog dialog = new AboutDialog( shell, SWT.DIALOG_TRIM );
+                                       AboutDialog dialog = new AboutDialog( shell );
                                        dialog.open();
                                        isOpen = false;
                                }
@@ -981,16 +1185,16 @@ public class EmulatorSkin {
 
                /* disconnect with sdb */
                String sdbPath = SkinUtil.getSdbPath();
-               String portNumber = StringUtil.nvl(config.getArg( ArgsConstants.NET_BASE_PORT ));
+               String portNumber = StringUtil.nvl( config.getArg( ArgsConstants.NET_BASE_PORT ) );
 
-               if (!StringUtil.isEmpty(portNumber) && !StringUtil.isEmpty(portNumber)) {
-                       int portSdb = Integer.parseInt(portNumber) + 1;
+               if ( !StringUtil.isEmpty( portNumber ) && !StringUtil.isEmpty( portNumber ) ) {
+                       int portSdb = Integer.parseInt( portNumber ) + 1;
 
-                       ProcessBuilder procDisconnect = new ProcessBuilder(sdbPath, "connect", "localhost:" + portSdb);
+                       ProcessBuilder procDisconnect = new ProcessBuilder( sdbPath, "connect", "localhost:" + portSdb );
                        try {
                                procDisconnect.start();
-                       } catch (IOException e) {
-                               logger.log(Level.SEVERE, e.getMessage(), e);
+                       } catch ( IOException e ) {
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                        }
                }
 
index 5e41fbe..7d7f6c0 100644 (file)
@@ -39,10 +39,13 @@ import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.skin.EmulatorSkin.SkinReopenPolicy;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 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.dbi.EmulatorUI;
 import org.tizen.emulator.skin.exception.JaxbException;
 import org.tizen.emulator.skin.image.ImageRegistry;
@@ -101,7 +104,12 @@ public class EmulatorSkinMain {
                        EmulatorConfig config = new EmulatorConfig( argsMap, dbiContents, skinProperties, skinPropFilePath,
                                        configProperties );
 
-                       EmulatorSkin skin = new EmulatorSkin( config );
+                       ImageRegistry.getInstance().initialize( config );
+                       
+                       String onTopVal = config.getSkinProperty( SkinPropertiesConstants.WINDOW_ONTOP, Boolean.FALSE.toString() );
+                       boolean isOnTop = Boolean.parseBoolean( onTopVal );
+
+                       EmulatorSkin skin = new EmulatorSkin( config, isOnTop );
                        int windowHandleId = skin.compose();
 
                        int uid = Integer.parseInt( config.getArg( ArgsConstants.UID ) );
@@ -117,9 +125,29 @@ public class EmulatorSkinMain {
 
                                Thread communicatorThread = new Thread( communicator );
                                communicatorThread.start();
+                               
+                               SkinReopenPolicy reopenPolicy = skin.open();
+                               
+                               while( true ) {
+
+                                       if( null != reopenPolicy ) {
+                                               
+                                               if( reopenPolicy.isReopen() ) {
+                                                       
+                                                       EmulatorSkin reopenSkin = reopenPolicy.getReopenSkin();
+                                                       logger.info( "Reopen skin dialog." );
+                                                       reopenPolicy = reopenSkin.open();
+                                                       
+                                               }else {
+                                                       break;
+                                               }
+                                               
+                                       }else {
+                                               break;
+                                       }
 
-                               skin.open();
-
+                               }
+                               
                        } else {
                                logger.severe( "CommSocket is null." );
                        }
@@ -133,6 +161,8 @@ public class EmulatorSkinMain {
                        }
 
                } finally {
+                       ImageRegistry.getInstance().dispose();
+                       Display.getDefault().close();
                        SkinLogger.end();
                }
 
@@ -281,7 +311,5 @@ public class EmulatorSkinMain {
                return properties;
 
        }
-
-       
        
 }
index aed2de8..7f73707 100644 (file)
@@ -114,7 +114,7 @@ public class SocketCommunicator implements ICommunicator {
        private ScheduledExecutorService heartbeatExecutor;
 
        private boolean isSensorDaemonStarted;
-
+       
        public SocketCommunicator( EmulatorConfig config, int uId, int windowHandleId, EmulatorSkin skin ) {
 
                this.config = config;
@@ -396,7 +396,15 @@ public class SocketCommunicator implements ICommunicator {
                        heartbeatExecutor.shutdownNow();
                }
                IOUtil.closeSocket( socket );
-               skin.shutdown();
+               synchronized ( this ) {
+                       skin.shutdown();
+               }
+       }
+
+       public void resetSkin( EmulatorSkin skin ) {
+               synchronized ( this ) {
+                       this.skin = skin;
+               }
        }
 
 }
\ No newline at end of file
index 21e3ba6..7009096 100644 (file)
@@ -68,6 +68,7 @@ public class EmulatorConfig {
                public static final String WINDOW_Y = "window.y";
                public static final String WINDOW_ROTATION = "window.rotate";
                public static final String WINDOW_SCALE = "window.scale";
+               public static final String WINDOW_ONTOP = "window.ontop"; // always on top
        }
 
        public interface ConfigPropertiesConstants {
index 807d9b8..d75befb 100644 (file)
@@ -55,10 +55,14 @@ public class AboutDialog extends SkinDialog {
        
        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";
+       
        private Logger logger = SkinLogger.getSkinLogger( AboutDialog.class ).getLogger();
 
-       public AboutDialog( Shell parent, int style ) {
-               super( parent, "About Tizen Emulator", style );
+       public AboutDialog( Shell parent ) {
+               super( parent, "About Tizen Emulator", SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL );
        }
 
        @Override
@@ -94,31 +98,36 @@ public class AboutDialog extends SkinDialog {
                        noInformation = true;
                }
                
-               String defaultInformation = "no information";
+               String defaultInformation = "No information";
                
                Text versionText = new Text( composite, SWT.NONE );
                if( noInformation ) {
-                       versionText.setText( "Version      : " + defaultInformation );
+                       versionText.setText( "Version" + "      : " + defaultInformation );
                }else {
-                       versionText.setText( "Version      : Tizen SDK " + StringUtil.nvl( properties.getProperty( "version" ) ) );
+                       versionText.setText( "Version" + "      : Tizen SDK " + getValue( properties, PROP_KEY_VERSION ) );
                }
                versionText.setEditable( false );
                versionText.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
 
                Text buildText = new Text( composite, SWT.NONE );
                if( noInformation ) {
-                       buildText.setText( "Build time  : " + defaultInformation );
+                       buildText.setText( "Build time" + "  : " + defaultInformation );
                }else {
-                       buildText.setText( "Build time  : " + StringUtil.nvl( properties.getProperty( "build_time" ) ) + " (GMT)" );
+                       String time = properties.getProperty( PROP_KEY_BUILD_TIME );
+                       if( StringUtil.isEmpty( time ) ) {
+                               buildText.setText( "Build time" + "  : " + "Not identified" );
+                       }else {
+                               buildText.setText( "Build time" + "  : " + time + " (GMT)" );
+                       }
                }
                buildText.setEditable( false );
                buildText.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
 
                Text gitText = new Text( composite, SWT.NONE );
                if( noInformation ) {
-                       gitText.setText( "Git version : " + defaultInformation );
+                       gitText.setText( "Git version" + " : " + defaultInformation );
                }else {
-                       gitText.setText( "Git version : " + StringUtil.nvl( properties.getProperty( "build_git_commit" ) ) );
+                       gitText.setText( "Git version" + " : " + getValue( properties, PROP_KEY_GIT_VERSION ) );
                }
                gitText.setEditable( false );
                gitText.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
@@ -127,6 +136,15 @@ public class AboutDialog extends SkinDialog {
 
        }
 
+       private String getValue( Properties properties, String key ) {
+               String property = properties.getProperty(  key );
+               if( StringUtil.isEmpty( property ) ) {
+                       return "Not identified";
+               }else {
+                       return property;
+               }
+       }
+       
        @Override
        protected void createButtons( Composite parent ) {
 
@@ -140,7 +158,7 @@ public class AboutDialog extends SkinDialog {
                        public void widgetSelected( SelectionEvent e ) {
                                if ( !isOpen ) {
                                        isOpen = true;
-                                       LicenseDialog licenseDialog = new LicenseDialog( shell, "License", SWT.DIALOG_TRIM );
+                                       LicenseDialog licenseDialog = new LicenseDialog( shell, "License" );
                                        licenseDialog.open();
                                        isOpen = false;
                                }
index 6d8d9a0..7080f9a 100644 (file)
@@ -58,10 +58,10 @@ public class LicenseDialog extends SkinDialog {
        
        private Logger logger = SkinLogger.getSkinLogger( LicenseDialog.class ).getLogger();
 
-       public LicenseDialog( Shell parent, String title, int style ) {
+       public LicenseDialog( Shell parent, String title ) {
                // FIXME resizable
-               // super( parent, title, style | SWT.MAX | SWT.RESIZE );
-               super( parent, title, style );
+               // super( parent, title, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MAX | SWT.RESIZE );
+               super( parent, title, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
        }
 
        @Override
index 64ed86c..0cb6fd2 100644 (file)
@@ -53,19 +53,12 @@ public abstract class SkinDialog extends Dialog {
        private Shell parent;
        private String title;
        private int style;
-       private boolean pack;
 
        public SkinDialog( Shell parent, String title, int style ) {
                super( parent, style );
                this.parent = parent;
                this.title = title;
                this.style = style;
-               this.pack = true;
-       }
-
-       public SkinDialog( Shell parent, String title, int style, boolean pack ) {
-               this( parent, title, style );
-               this.pack = pack;
        }
 
        public void open() {
@@ -98,10 +91,8 @@ public abstract class SkinDialog extends Dialog {
                buttonComposite.setLayout( new FillLayout( SWT.HORIZONTAL ) );
 
                createButtons( buttonComposite );
-
-               if ( pack ) {
-                       shell.pack();
-               }
+               
+               shell.pack();
 
                if ( !isReady ) {
                        return;
index b87e2e4..c7cd655 100644 (file)
@@ -72,16 +72,20 @@ public class ImageRegistry {
        
        public enum IconName {
                
-               DEVICE_INFO( "device_info.png" ),
+               DETAIL_INFO( "detail_info.png" ),
                ROTATE( "rotate.png" ),
-               SCALING( "scaling.png" ),
+               SCALE( "scale.png" ),
                SHELL( "shell.png" ),
                ADVANCED( "advanced.png" ),
                CLOSE( "close.png" ),
                SCREENSHOT( "screenshot.png" ),
-               USB_KEBOARD( "keypad.png" ),
+               USB_KEBOARD( "usb_keyboard.png" ),
                ABOUT( "about.png" ),
-               
+
+               COPY_SCREEN_SHOT( "copy_screenshot_dialog.png" ),
+               REFRESH_SCREEN_SHOT( "refresh_screenshot_dialog.png" ),
+               SAVE_SCREEN_SHOT( "save_screenshot_dialog.png" ),
+
                EMULATOR_TITLE( "Emulator_20x20.png" ),
                EMULATOR_TITLE_ICO( "Emulator.ico" );
                
@@ -104,11 +108,29 @@ public class ImageRegistry {
        
        private Map<String, Image> skinImageMap;
        private Map<String, Image> iconMap;
+
+       private static ImageRegistry instance;
+       private static boolean isInitialized;
        
-       public ImageRegistry(Display display, EmulatorConfig config ) {
+       private ImageRegistry() {
+       }
+       
+       public static ImageRegistry getInstance() {
+               if( null == instance ) {
+                       instance = new ImageRegistry();
+               }
+               return instance;
+       }
+       
+       public void initialize(  EmulatorConfig config  ) {
                
-               this.display = display;
+               if( isInitialized ) {
+                       return;
+               }
+               isInitialized = true;
                
+               this.display = Display.getDefault();
+
                int lcdWidth = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
                int lcdHeight = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
                String skinPath = (String) config.getArg( ArgsConstants.SKIN_PATH );
@@ -118,9 +140,9 @@ public class ImageRegistry {
                this.dbiContents = config.getDbiContents();
                this.skinImageMap = new HashMap<String, Image>();
                this.iconMap = new HashMap<String, Image>();
-               
-               init(skinPath);
-               
+
+               init( skinPath );
+
        }
        
        public static String getSkinPath( String argSkinPath, int lcdWidth, int lcdHeight ) {
@@ -188,7 +210,7 @@ public class ImageRegistry {
                        try {
                                is = classLoader.getResourceAsStream( iconPath );
                                if( null != is ) {
-                                       logger.info( "load icon:" + iconPath );
+                                       logger.fine( "load icon:" + iconPath );
                                        iconMap.put( name, new Image( display, is ) );
                                }else {
                                        logger.severe( "missing icon:" + iconPath );
index 941e2fc..c205ad0 100644 (file)
@@ -48,6 +48,7 @@ import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.ImageLoader;
@@ -56,7 +57,7 @@ import org.eclipse.swt.graphics.Transform;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Listener;
@@ -71,12 +72,14 @@ import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.exception.ScreenShotException;
+import org.tizen.emulator.skin.image.ImageRegistry;
+import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 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;
 
-public class ScreenShotDialog extends Dialog {
+public class ScreenShotDialog {
 
        public final static String DEFAULT_FILE_EXTENSION = "png";
 
@@ -96,7 +99,6 @@ public class ScreenShotDialog extends Dialog {
        private Image image;
        private Canvas imageCanvas;
        private Shell shell;
-       private Shell parent;
        private ScrolledComposite scrollComposite;
 
        private SocketCommunicator communicator;
@@ -105,32 +107,32 @@ public class ScreenShotDialog extends Dialog {
 
        private RotationInfo currentRotation;
        private boolean needToStoreRotatedImage;
+       private boolean reserveImage;
        
-       public ScreenShotDialog( Shell parent, SocketCommunicator commuicator, EmulatorSkin emulatorSkin,
+       public ScreenShotDialog( Shell parent, SocketCommunicator communicator, EmulatorSkin emulatorSkin,
                        EmulatorConfig config ) throws ScreenShotException {
 
-               super( parent, SWT.DIALOG_TRIM | SWT.RESIZE );
-
-               this.parent = parent;
-               this.communicator = commuicator;
+               this.communicator = communicator;
                this.emulatorSkin = emulatorSkin;
                this.config = config;
                this.needToStoreRotatedImage = true;
                
-               shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE );
+               shell = new Shell( Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE );
                shell.setText( "Screen Shot - " + SkinUtil.makeEmulatorName( config ) );
                shell.setLocation( parent.getLocation().x + parent.getSize().x + 30, parent.getLocation().y );
                shell.addListener( SWT.Close, new Listener() {
                        @Override
                        public void handleEvent( Event event ) {
                                if ( null != image ) {
-                                       image.dispose();
+                                       if( !reserveImage ) {
+                                               image.dispose();
+                                       }
                                }
                        }
                } );
 
                GridLayout gridLayout = new GridLayout();
-               gridLayout.marginWidth = 2;
+               gridLayout.marginWidth = 0;
                gridLayout.marginHeight = 0;
                gridLayout.horizontalSpacing = 0;
                gridLayout.verticalSpacing = 0;
@@ -168,48 +170,8 @@ public class ScreenShotDialog extends Dialog {
                                        } else {
                                                
                                                if( needToStoreRotatedImage ) {
-                                                       
-                                                       Transform transform = new Transform( shell.getDisplay() );
-
-                                                       float angle = currentRotation.angle();
-                                                       transform.rotate( angle );
-
-                                                       int w = 0;
-                                                       int h = 0;
-                                                       ImageData imageData = image.getImageData();
-
-                                                       if ( RotationInfo.LANDSCAPE.equals( currentRotation ) ) {
-                                                               transform.translate( -width - ( 2 * CANVAS_MARGIN ), 0 );
-                                                               w = imageData.height;
-                                                               h = imageData.width;
-                                                       } else if ( RotationInfo.REVERSE_PORTRAIT.equals( currentRotation ) ) {
-                                                               transform.translate( -width - ( 2 * CANVAS_MARGIN ), -height - ( 2 * CANVAS_MARGIN ) );
-                                                               w = imageData.width;
-                                                               h = imageData.height;
-                                                       } else if ( RotationInfo.REVERSE_LANDSCAPE.equals( currentRotation ) ) {
-                                                               transform.translate( 0, -height - ( 2 * CANVAS_MARGIN ) );
-                                                               w = imageData.height;
-                                                               h = imageData.width;
-                                                       } else {
-                                                               w = imageData.width;
-                                                               h = imageData.height;
-                                                       }
-
-                                                       e.gc.setTransform( transform );
-
-                                                       e.gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN );
-
-                                                       transform.dispose();
-
-                                                       // 'gc.drawImage' is only for the showing without changing image data,
-                                                       // so change image data fully to support the roated image in a saved file and a pasted image.
-                                                       Image rotatedImage = new Image( shell.getDisplay(), w, h );
-                                                       e.gc.copyArea( rotatedImage, CANVAS_MARGIN, CANVAS_MARGIN );
-                                                       image.dispose();
-                                                       image = rotatedImage;
-
+                                                       drawRotatedImage( e.gc, width, height );
                                                        needToStoreRotatedImage = false;
-
                                                }else {
                                                        //just redraw rotated image
                                                        e.gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN );
@@ -236,9 +198,53 @@ public class ScreenShotDialog extends Dialog {
                }
 
                shell.pack();
-
+               
        }
 
+       
+       private void drawRotatedImage( GC gc, int width, int height ) {
+               
+               Transform transform = new Transform( shell.getDisplay() );
+
+               float angle = currentRotation.angle();
+               transform.rotate( angle );
+
+               int w = 0;
+               int h = 0;
+               ImageData imageData = image.getImageData();
+
+               if ( RotationInfo.LANDSCAPE.equals( currentRotation ) ) {
+                       transform.translate( -width - ( 2 * CANVAS_MARGIN ), 0 );
+                       w = imageData.height;
+                       h = imageData.width;
+               } else if ( RotationInfo.REVERSE_PORTRAIT.equals( currentRotation ) ) {
+                       transform.translate( -width - ( 2 * CANVAS_MARGIN ), -height - ( 2 * CANVAS_MARGIN ) );
+                       w = imageData.width;
+                       h = imageData.height;
+               } else if ( RotationInfo.REVERSE_LANDSCAPE.equals( currentRotation ) ) {
+                       transform.translate( 0, -height - ( 2 * CANVAS_MARGIN ) );
+                       w = imageData.height;
+                       h = imageData.width;
+               } else {
+                       w = imageData.width;
+                       h = imageData.height;
+               }
+
+               gc.setTransform( transform );
+
+               gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN );
+
+               transform.dispose();
+
+               // 'gc.drawImage' is only for the showing without changing image data,
+               // so change image data fully to support the roated image in a saved file and a pasted image.
+               Image rotatedImage = new Image( shell.getDisplay(), w, h );
+               gc.copyArea( rotatedImage, CANVAS_MARGIN, CANVAS_MARGIN );
+               image.dispose();
+               image = rotatedImage;
+
+       }
+       
        private void clickShutter() throws ScreenShotException {
                capture();
                arrageImageLayout();
@@ -290,7 +296,7 @@ public class ScreenShotDialog extends Dialog {
                                int height = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
                                ImageData imageData = new ImageData( width, height, COLOR_DEPTH, paletteData, 1, receivedData );
 
-                               this.image = new Image( parent.getDisplay(), imageData );
+                               this.image = new Image( Display.getDefault(), imageData );
 
                                needToStoreRotatedImage = true;
                                imageCanvas.redraw();
@@ -334,7 +340,7 @@ public class ScreenShotDialog extends Dialog {
        }
 
        private RotationInfo getCurrentRotation() {
-               short currentRotationId = ScreenShotDialog.this.emulatorSkin.getCurrentRotationId();
+               short currentRotationId = emulatorSkin.getCurrentRotationId();
                RotationInfo rotationInfo = RotationInfo.getValue( currentRotationId );
                return rotationInfo;
        }
@@ -344,13 +350,11 @@ public class ScreenShotDialog extends Dialog {
                ToolBar toolBar = new ToolBar( shell, SWT.HORIZONTAL );
                GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
                toolBar.setLayoutData( gridData );
-
+               
                ToolItem saveItem = new ToolItem( toolBar, SWT.FLAT );
-               // FIXME icon
-               // saveItem.setImage( null );
-               saveItem.setText( "Save" );
-               saveItem.setToolTipText( "Save" );
-
+               saveItem.setImage( ImageRegistry.getInstance().getIcon( IconName.SAVE_SCREEN_SHOT ) );
+               saveItem.setToolTipText( "Save to file" );
+               
                saveItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
@@ -383,11 +387,9 @@ public class ScreenShotDialog extends Dialog {
                        }
 
                } );
-
+               
                ToolItem copyItem = new ToolItem( toolBar, SWT.FLAT );
-               // FIXME icon
-               // refreshItem.setImage( null );
-               copyItem.setText( "Copy" );
+               copyItem.setImage( ImageRegistry.getInstance().getIcon( IconName.COPY_SCREEN_SHOT ) );
                copyItem.setToolTipText( "Copy to clipboard" );
 
                copyItem.addSelectionListener( new SelectionAdapter() {
@@ -418,10 +420,8 @@ public class ScreenShotDialog extends Dialog {
                } );
 
                ToolItem refreshItem = new ToolItem( toolBar, SWT.FLAT );
-               // FIXME icon
-               // refreshItem.setImage( null );
-               refreshItem.setText( "Refresh" );
-               refreshItem.setToolTipText( "Refresh" );
+               refreshItem.setImage( ImageRegistry.getInstance().getIcon( IconName.REFRESH_SCREEN_SHOT ) );
+               refreshItem.setToolTipText( "Refresh image" );
 
                refreshItem.addSelectionListener( new SelectionAdapter() {
                        @Override
@@ -525,16 +525,26 @@ public class ScreenShotDialog extends Dialog {
 
                while ( !shell.isDisposed() ) {
                        if ( !shell.getDisplay().readAndDispatch() ) {
-                               shell.getDisplay().sleep();
+                               if( reserveImage ) {
+                                       break;
+                               }else {
+                                       shell.getDisplay().sleep();
+                               }
                        }
                }
-
+               
        }
 
-       public void close() {
-               if ( null != shell ) {
-                       shell.close();
-               }
+       public void setEmulatorSkin( EmulatorSkin emulatorSkin ) {
+               this.emulatorSkin = emulatorSkin;
        }
 
+       public void setReserveImage( boolean reserveImage ) {
+               this.reserveImage = reserveImage;
+       }
+       
+       public Shell getShell() {
+               return shell;
+       }
+       
 }
\ No newline at end of file