[Title] extract some codes which platform comparing
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 23 Jul 2012 02:29:29 +0000 (11:29 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Mon, 23 Jul 2012 02:39:00 +0000 (11:39 +0900)
[Type] feature
[Module] Emulator / skin
[Priority] minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.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
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SwtUtil.java [new file with mode: 0644]

index 041f0f6..71d2dc8 100644 (file)
@@ -95,6 +95,7 @@ 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.SwtUtil;
 
 /**
  * 
@@ -230,7 +231,7 @@ public class EmulatorSkin {
                String emulatorName = SkinUtil.makeEmulatorName( config );
                shell.setText( emulatorName );
 
-               if ( SkinUtil.isWindowsPlatform() ) {
+               if ( SwtUtil.isWindowsPlatform() ) {
                        shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE_ICO ) );
                } else {
                        shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE ) );
@@ -303,7 +304,7 @@ public class EmulatorSkin {
 
                long windowHandleId = 0;
 
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
 
                        try {
                                Field field = lcdCanvas.getClass().getField( "embeddedHandle" );
@@ -323,12 +324,12 @@ public class EmulatorSkin {
                                shutdown();
                        }
 
-               } else if ( SkinUtil.isWindowsPlatform() ) {
+               } else if ( SwtUtil.isWindowsPlatform() ) {
 
                        logger.info( "lcdCanvas.handle:" + lcdCanvas.handle );
                        windowHandleId = lcdCanvas.handle;
 
-               } else if ( SkinUtil.isMacPlatform() ) {
+               } else if ( SwtUtil.isMacPlatform() ) {
 
                        // TODO
 
@@ -833,7 +834,7 @@ public class EmulatorSkin {
 
                                previous = null;
                                
-                               if( SkinUtil.isWindowsPlatform() && disappearEvent) {
+                               if( SwtUtil.isWindowsPlatform() && disappearEvent) {
                                        disappearEvent = false;
                                        if (isMetaKey(e) && e.character != '\0') {
                                                logger.info( "send previous release : keycode=" + disappearKeycode +
@@ -855,7 +856,7 @@ public class EmulatorSkin {
                        public void keyPressed( KeyEvent e ) {
                                int keyCode = e.keyCode | e.stateMask;
                                
-                               if( SkinUtil.isWindowsPlatform() ) {
+                               if( SwtUtil.isWindowsPlatform() ) {
                                        if ( null != previous ) {
                                                if ( previous.keyCode != e.keyCode ) {
 
@@ -928,9 +929,9 @@ public class EmulatorSkin {
        private Field getOSField( String field ) {
 
                String className = "";
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        className = GTK_OS_CLASS;
-               } else if ( SkinUtil.isWindowsPlatform() ) {
+               } else if ( SwtUtil.isWindowsPlatform() ) {
                        className = WIN32_OS_CLASS;
                }
 
@@ -951,9 +952,9 @@ public class EmulatorSkin {
        private Method getOSMethod( String method, Class<?>... parameterTypes ) {
 
                String className = "";
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        className = GTK_OS_CLASS;
-               } else if ( SkinUtil.isWindowsPlatform() ) {
+               } else if ( SwtUtil.isWindowsPlatform() ) {
                        className = WIN32_OS_CLASS;
                }
 
@@ -1000,7 +1001,7 @@ public class EmulatorSkin {
        }
 
        private boolean setTopMost32(boolean isOnTop) {
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        // reference : http://wmctrl.sourcearchive.com/documentation/1.07/main_8c-source.html
 
                        /* if ( !OS.GDK_WINDOWING_X11() ) {
@@ -1224,7 +1225,7 @@ public class EmulatorSkin {
                        invokeOSMethod( xSendEvent, xDisplay, rootWin, false, (int) ( 1L << 20 | 1L << 19 ), malloc );
                        invokeOSMethod( getOSMethod( "g_free", int.class ), malloc ) ;
 
-               } else if( SkinUtil.isWindowsPlatform() ) {
+               } else if( SwtUtil.isWindowsPlatform() ) {
                        Point location = shell.getLocation();
 
                        /* int hWndInsertAfter = 0;
@@ -1271,7 +1272,7 @@ public class EmulatorSkin {
                                        int.class, int.class );
 
                        invokeOSMethod( m, shell.handle, hWndInsertAfter, location.x, location.y, 0, 0, noSize );
-               } else if( SkinUtil.isMacPlatform() ) {
+               } else if( SwtUtil.isMacPlatform() ) {
                        //TODO:
                }
 
@@ -1280,7 +1281,7 @@ public class EmulatorSkin {
 
        private boolean setTopMost64(boolean isOnTop)
        {
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        Boolean gdkWindowingX11 = (Boolean) invokeOSMethod( getOSMethod( "GDK_WINDOWING_X11" ) );
                        if (null == gdkWindowingX11) {
                                return false;
@@ -1450,9 +1451,9 @@ public class EmulatorSkin {
                        // SubstructureRedirectMask:1L<<20 | SubstructureNotifyMask:1L<<19
                        invokeOSMethod( xSendEvent, xDisplay, rootWin, false, (long) ( 1L << 20 | 1L << 19 ), malloc );
                        invokeOSMethod( getOSMethod( "g_free", long.class ), malloc );
-               } else if (SkinUtil.isWindowsPlatform()) {
+               } else if (SwtUtil.isWindowsPlatform()) {
                        //TODO:
-               } else if( SkinUtil.isMacPlatform() ) {
+               } else if( SwtUtil.isMacPlatform() ) {
                        //TODO:
                }
 
@@ -1560,11 +1561,11 @@ public class EmulatorSkin {
 
                                ProcessBuilder procSdb = new ProcessBuilder();
 
-                               if ( SkinUtil.isLinuxPlatform() ) {
+                               if ( SwtUtil.isLinuxPlatform() ) {
                                        procSdb.command( "/usr/bin/gnome-terminal", "--disable-factory",
                                                        "--title=" + SkinUtil.makeEmulatorName( config ), "-x", sdbPath, "-s", "emulator-"
                                                                        + portSdb, "shell" );
-                               } else if ( SkinUtil.isWindowsPlatform() ) {
+                               } else if ( SwtUtil.isWindowsPlatform() ) {
                                        procSdb.command( "cmd.exe", "/c", "start", sdbPath, "-s", "emulator-" + portSdb, "shell" );
                                }
                                logger.log( Level.INFO, procSdb.command().toString() );
index edc0d2c..ddaeadf 100644 (file)
@@ -49,8 +49,8 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 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;
+import org.tizen.emulator.skin.util.SwtUtil;
 
 public class AboutDialog extends SkinDialog {
        
@@ -97,7 +97,7 @@ public class AboutDialog extends SkinDialog {
                
                Text versionText = new Text( composite, SWT.NONE );
                String version = getValue( properties, PROP_KEY_VERSION );
-               if (SkinUtil.isWindowsPlatform()) {
+               if (SwtUtil.isWindowsPlatform()) {
                        versionText.setText("Version" + "      : " + version);
                } else {
                        versionText.setText("Version" + "        : " + version);
index b01d402..811f60e 100644 (file)
@@ -57,6 +57,7 @@ import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.StringUtil;
+import org.tizen.emulator.skin.util.SwtUtil;
 
 /**
  * 
@@ -142,11 +143,11 @@ public class DetailInfoDialog extends SkinDialog {
                                        String logPath = refinedData.get(logKey);
                                        ProcessBuilder procBrowser = new ProcessBuilder();
 
-                                       if (SkinUtil.isLinuxPlatform()) {
+                                       if (SwtUtil.isLinuxPlatform()) {
                                                procBrowser.command("nautilus", "--browser", logPath);
-                                       } else if (SkinUtil.isWindowsPlatform()) {
+                                       } else if (SwtUtil.isWindowsPlatform()) {
                                                procBrowser.command("explorer", "\"" + logPath + "\"");
-                                       } else if (SkinUtil.isMacPlatform()) {
+                                       } else if (SwtUtil.isMacPlatform()) {
                                                //TODO:
                                        }
 
@@ -168,7 +169,7 @@ public class DetailInfoDialog extends SkinDialog {
 
        @Override
        protected void setShellSize() {
-               if( SkinUtil.isLinuxPlatform() ) {
+               if( SwtUtil.isLinuxPlatform() ) {
                        shell.setSize( (int) ( 402 * 1.618 ), 402 );
                } else {
                        shell.setSize( (int) ( 372 * 1.618 ), 372 );
@@ -209,9 +210,9 @@ public class DetailInfoDialog extends SkinDialog {
                String logPath = "";
                boolean isHaxError = false;
                
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        hwVirtualCompare = "-enable-kvm";
-               } else if ( SkinUtil.isWindowsPlatform() ) {
+               } else if ( SwtUtil.isWindowsPlatform() ) {
                        hwVirtualCompare = "-enable-hax";
                }
                
@@ -222,7 +223,7 @@ public class DetailInfoDialog extends SkinDialog {
                        if ( 0 == i ) {
 
                                String exec = split[i].trim().toLowerCase();
-                               if( SkinUtil.isWindowsPlatform() ) {
+                               if( SwtUtil.isWindowsPlatform() ) {
                                        if( 4 <= exec.length() ) {
                                                // remove '.exe' in Windows
                                                exec = exec.substring( 0, exec.length() - 4 );
@@ -339,7 +340,7 @@ public class DetailInfoDialog extends SkinDialog {
 
                result.put( "RAM Size", ram );
 
-               if ( SkinUtil.isLinuxPlatform() ) {
+               if ( SwtUtil.isLinuxPlatform() ) {
                        if ( StringUtil.isEmpty( sharedPath ) ) {
                                result.put( "File Sharing", "Not Supported" );
                                result.put( "File Shared Path", "None" );
index 82acd19..9d78edb 100644 (file)
@@ -79,6 +79,7 @@ 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;
+import org.tizen.emulator.skin.util.SwtUtil;
 
 public class ScreenShotDialog {
 
@@ -498,7 +499,7 @@ public class ScreenShotDialog {
 
                                ImageData data = null;
 
-                               if ( SkinUtil.isWindowsPlatform() ) {
+                               if ( SwtUtil.isWindowsPlatform() ) {
                                        // change RGB mask
                                        ImageData imageData = image.getImageData();
                                        PaletteData paletteData = new PaletteData( BLUE_MASK, GREEN_MASK, RED_MASK );
index 155fc91..1685c33 100644 (file)
@@ -67,24 +67,12 @@ public class SkinUtil {
        private SkinUtil() {
        }
 
-       public static boolean isLinuxPlatform() {
-               return "gtk".equalsIgnoreCase( SWT.getPlatform() );
-       }
-
-       public static boolean isWindowsPlatform() {
-               return "win32".equalsIgnoreCase( SWT.getPlatform() );
-       }
-
-       public static boolean isMacPlatform() {
-               return "cocoa".equalsIgnoreCase( SWT.getPlatform() );
-       }
-
        public static String getVmName( EmulatorConfig config ) {
                
                String vmPath = config.getArg( ArgsConstants.VM_PATH );
 
                String regex = "";
-               if ( isWindowsPlatform() ) {
+               if ( SwtUtil.isWindowsPlatform() ) {
                        regex = "\\" + File.separator;
                } else {
                        regex = File.separator;
@@ -112,7 +100,7 @@ public class SkinUtil {
        public static String getSdbPath() {
                String sdbPath = null;
 
-               if (SkinUtil.isWindowsPlatform()) {
+               if (SwtUtil.isWindowsPlatform()) {
                        sdbPath = ".\\..\\..\\sdb.exe";
                } else {
                        sdbPath = "./../../sdb";
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SwtUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SwtUtil.java
new file mode 100644 (file)
index 0000000..0435f30
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * 
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.util;
+
+import org.eclipse.swt.SWT;
+
+
+/**
+ * 
+ *
+ */
+public class SwtUtil {
+       private SwtUtil() {
+       }
+
+       public static boolean isLinuxPlatform() {
+               return "gtk".equalsIgnoreCase( SWT.getPlatform() );
+       }
+
+       public static boolean isWindowsPlatform() {
+               return "win32".equalsIgnoreCase( SWT.getPlatform() ); //win32-win32-x86_64
+       }
+
+       public static boolean isMacPlatform() {
+               return "cocoa".equalsIgnoreCase( SWT.getPlatform() );
+       }
+}