From: GiWoong Kim Date: Wed, 24 Jul 2013 07:18:43 +0000 (+0900) Subject: menu: added dynamic menu loading for key window layout X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~880^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f49efcecd4f6c6b35567c7e839e2959ed3dfa308;p=sdk%2Femulator%2Fqemu.git menu: added dynamic menu loading for key window layout Change-Id: Idae9a41162a222f889be8a1177047c02a170cbc4 Signed-off-by: GiWoong Kim --- 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 498b92fac0..2d6791d1a0 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 @@ -247,10 +247,12 @@ public class EmulatorSkin { public long initLayout() { imageRegistry = ImageRegistry.getInstance(); - /* attach a menu */ + /* create and attach a popup menu */ isOnKbd = false; popupMenu = new PopupMenu(config, this, shell, imageRegistry); + getKeyWindowKeeper().determineLayout(); + /* build a skin layout */ if (skinInfo.isGeneralPurposeSkin() == false) { skinComposer = new ProfileSpecificSkinComposer(config, this, @@ -1250,8 +1252,30 @@ public class EmulatorSkin { SelectionAdapter listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + /* control the menu */ + if (getKeyWindowKeeper().isGeneralKeyWindow() == false) { + MenuItem layoutSelected = (MenuItem) e.widget; + + if (layoutSelected.getSelection() == true) { + for (MenuItem layout : layoutSelected.getParent().getItems()) { + if (layout != layoutSelected) { + /* uncheck other menu items */ + layout.setSelection(false); + } else { + int layoutIndex = getKeyWindowKeeper().getLayoutIndex(); + if (getKeyWindowKeeper().determineLayout() != layoutIndex) { + /* switch */ + getKeyWindowKeeper().closeKeyWindow(); + layoutSelected.setSelection(true); + } + } + } + } + } + + /* control the window */ if (getKeyWindowKeeper().isSelectKeyWindowMenu() == true) - { + { /* checked */ if (getKeyWindowKeeper().getKeyWindow() == null) { if (getKeyWindowKeeper().getRecentlyDocked() != SWT.NONE) { getKeyWindowKeeper().openKeyWindow( @@ -1269,7 +1293,7 @@ public class EmulatorSkin { } } else - { /* hide a key window */ + { /* unchecked */ if (getKeyWindowKeeper().getDockPosition() != SWT.NONE) { /* close the Key Window if it is docked to Main Window */ getKeyWindowKeeper().setRecentlyDocked( @@ -1277,6 +1301,7 @@ public class EmulatorSkin { getKeyWindowKeeper().closeKeyWindow(); } else { + /* hide a Key Window */ getKeyWindowKeeper().hideKeyWindow(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index a2594720f7..dd902b90a5 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -139,7 +139,7 @@ public class EmulatorConfig { reader.close(); } else { - logger.info("cannot find version file" + versionFilePath); + logger.warning("cannot read version from " + versionFilePath); } } catch (FileNotFoundException e) { logger.log(Level.SEVERE, e.getMessage(), e); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java index 2b248ba463..f4c63a30dc 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java @@ -130,7 +130,9 @@ public class KeyWindow extends SkinWindow { int heightTailPart = SHELL_MARGIN_BOTTOM; /* make a frame image */ - this.cntHiddenButton = keyMapList.size() - BUTTON_DEFAULT_CNT; + if (keyMapList != null) { + this.cntHiddenButton = keyMapList.size() - BUTTON_DEFAULT_CNT; + } this.imageFrame = frameMaker.getPatchedImage( widthBase + ((cntHiddenButton > 0) ? widthScrollbar : 0), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 34e3efce5b..59ab257bf8 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -324,6 +324,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { e.gc.drawImage(currentState.getCurrentImage(), 0, 0); } + skin.getKeyWindowKeeper().redock(false, false); } }; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java index 3c9d7b6293..007ef265a7 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.logging.Logger; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.MenuItem; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.custom.KeyWindow; import org.tizen.emulator.skin.custom.SkinWindow; @@ -46,6 +47,7 @@ public class KeyWindowKeeper { private EmulatorSkin skin; private SkinWindow keyWindow; private int recentlyDocked; + private int indexLayout; /** * Constructor @@ -53,12 +55,13 @@ public class KeyWindowKeeper { public KeyWindowKeeper(EmulatorSkin skin) { this.skin = skin; this.recentlyDocked = SWT.NONE; + this.indexLayout = -1; } public void openKeyWindow(int dockValue, boolean recreate) { if (keyWindow != null) { if (recreate == false) { - /* show the key window */ + /* show the Key Window */ selectKeyWindowMenu(skin.isKeyWindow = true); if (skin.pairTag != null) { @@ -75,22 +78,32 @@ public class KeyWindowKeeper { } } - /* create a key window */ - List keyMapList = SkinUtil.getHWKeyMapList( - skin.getEmulatorSkinState().getCurrentRotationId()); - - if (keyMapList == null) { - selectKeyWindowMenu(skin.isKeyWindow = false); - logger.info("keyMapList is null"); - return; - } else if (keyMapList.isEmpty() == true) { - selectKeyWindowMenu(skin.isKeyWindow = false); - logger.info("keyMapList is empty"); - return; - } + /* create a Key Window */ + if (isGeneralKeyWindow() == true) { + List keyMapList = SkinUtil.getHWKeyMapList( + skin.getEmulatorSkinState().getCurrentRotationId()); - keyWindow = new KeyWindow( - skin, skin.getShell(), skin.communicator, keyMapList); + if (keyMapList == null) { + selectKeyWindowMenu(skin.isKeyWindow = false); + logger.info("keyMapList is null"); + return; + } else if (keyMapList.isEmpty() == true) { + selectKeyWindowMenu(skin.isKeyWindow = false); + logger.info("keyMapList is empty"); + return; + } + + keyWindow = new KeyWindow( + skin, skin.getShell(), skin.communicator, keyMapList); + } else { + // TODO: + String layoutName = + skin.getPopupMenu().keyWindowItem.getMenu().getItem(indexLayout).getText(); + logger.info("generate a \'" + layoutName + "\' key window!"); + + keyWindow = new KeyWindow( + skin, skin.getShell(), skin.communicator, null); + } selectKeyWindowMenu(skin.isKeyWindow = true); SkinUtil.setTopMost(keyWindow.getShell(), skin.isOnTop); @@ -131,18 +144,68 @@ public class KeyWindowKeeper { return keyWindow; } + public int getLayoutIndex() { + return indexLayout; + } + + public boolean isGeneralKeyWindow() { + return (getLayoutIndex() < 0); + } + + public int determineLayout() { + MenuItem keywindowItem = skin.getPopupMenu().keyWindowItem; + + if (keywindowItem != null && keywindowItem.getMenu() != null) { + logger.info("key window has a special layout"); + + MenuItem[] layouts = keywindowItem.getMenu().getItems(); + for (int i = 0; i < layouts.length; i++) { + MenuItem layout = layouts[i]; + + if (layout.getSelection() == true) { + indexLayout = i; + + logger.info("the \'" + layout.getText() + + "\' layout is selected for key window"); + break; + } + } + } else { + logger.info("key window has a general layout"); + indexLayout = -1; + } + + return indexLayout; + } + /* for Menu */ public boolean isSelectKeyWindowMenu() { - if (skin.getPopupMenu().keyWindowItem != null) { - return skin.getPopupMenu().keyWindowItem.getSelection(); + MenuItem keywindow = skin.getPopupMenu().keyWindowItem; + + if (keywindow != null) { + if (isGeneralKeyWindow() == true) { + return keywindow.getSelection(); + } else { + for (MenuItem layout : keywindow.getMenu().getItems()) { + if (layout.getSelection() == true) { + return true; + } + } + } } return false; } public void selectKeyWindowMenu(boolean on) { - if (skin.getPopupMenu().keyWindowItem != null) { - skin.getPopupMenu().keyWindowItem.setSelection(on); + MenuItem keywindow = skin.getPopupMenu().keyWindowItem; + + if (keywindow != null) { + if (isGeneralKeyWindow() == true) { + keywindow.setSelection(on); + } else { + keywindow.getMenu().getItem(indexLayout).setSelection(on); + } } } @@ -165,7 +228,7 @@ public class KeyWindowKeeper { return recentlyDocked; } - public void setRecentlyDocked(int recentlyDocked) { - this.recentlyDocked = recentlyDocked; + public void setRecentlyDocked(int dockValue) { + recentlyDocked = dockValue; } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java index 8f51df1781..28a82c69be 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java @@ -204,7 +204,6 @@ public class PopupMenu { if (layouts != null) { keyWindowItem = new MenuItem(menu, SWT.CASCADE); keyWindowItem.setText(menuName); - //TODO: advancedItem.setImage Menu keywindowSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); { @@ -213,15 +212,14 @@ public class PopupMenu { for (int i = 0; i < layouts.size(); i++) { File dir = layouts.get(i); - keywindowLayoutItem = new MenuItem(keywindowSubMenu, SWT.RADIO); + keywindowLayoutItem = new MenuItem(keywindowSubMenu, SWT.CHECK); keywindowLayoutItem.setText(dir.getName()); if (i == 0) { keywindowLayoutItem.setSelection(true); } - // TODO: - //SelectionAdapter keywindowLayoutListener = - //keywindowLayoutItem.addSelectionListener(keywindowLayoutListener); + SelectionAdapter keywindowLayoutListener = skin.createKeyWindowMenu(); + keywindowLayoutItem.addSelectionListener(keywindowLayoutListener); } } keyWindowItem.setMenu(keywindowSubMenu);