From: giwoong.kim Date: Mon, 23 Jul 2012 02:29:29 +0000 (+0900) Subject: [Title] extract some codes which platform comparing X-Git-Tag: TizenStudio_2.0_p2.3~1396^2~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=523302b7bbe93d175c41627a1f9c5089f480fdc4;p=sdk%2Femulator%2Fqemu.git [Title] extract some codes which platform comparing [Type] feature [Module] Emulator / skin [Priority] minor [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 041f0f6..71d2dc8 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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() ); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java index edc0d2c..ddaeadf 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java @@ -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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java index b01d402..811f60e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java @@ -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" ); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java index 82acd19..9d78edb 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java @@ -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 ); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index 155fc91..1685c33 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -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 index 0000000..0435f30 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SwtUtil.java @@ -0,0 +1,53 @@ +/** + * + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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() ); + } +}