Added some null check.
And define DEFAULT_DOCK_POSITION value for Key Window.
Change-Id: Ifdd8895e5a41508e842eab0c8e9515320436adb4
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
if (getKeyWindowKeeper().getKeyWindow() == null) {
if (getKeyWindowKeeper().getRecentlyDocked() != SWT.NONE) {
getKeyWindowKeeper().openKeyWindow(
- getKeyWindowKeeper().getRecentlyDocked(),
- false);
+ getKeyWindowKeeper().getRecentlyDocked(), false);
getKeyWindowKeeper().setRecentlyDocked(SWT.NONE);
} else {
/* opening for first time */
getKeyWindowKeeper().openKeyWindow(
- SWT.RIGHT | SWT.CENTER, false);
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION, false);
}
} else {
getKeyWindowKeeper().openKeyWindow(
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.info.EmulatorSkinState;
import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.menu.KeyWindowKeeper;
import org.tizen.emulator.skin.menu.PopupMenu;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
public void mouseDown(MouseEvent e) {
if (skin.isKeyWindow == true) {
skin.getKeyWindowKeeper().closeKeyWindow();
- skin.getKeyWindowKeeper().setRecentlyDocked(SWT.RIGHT | SWT.CENTER);
+ skin.getKeyWindowKeeper().setRecentlyDocked(
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION);
} else {
skin.getKeyWindowKeeper().openKeyWindow(
- SWT.RIGHT | SWT.CENTER, true);
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION, true);
}
}
if (popupMenu != null && popupMenu.keyWindowItem != null) {
final int dockValue = config.getSkinPropertyInt(
- SkinPropertiesConstants.KEYWINDOW_POSITION, 0);
+ SkinPropertiesConstants.KEYWINDOW_POSITION, SWT.NONE);
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (dockValue == SWT.NONE) {
skin.getKeyWindowKeeper().openKeyWindow(
- SWT.RIGHT | SWT.CENTER, false);
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION, false);
} else {
skin.getKeyWindowKeeper().openKeyWindow(dockValue, false);
}
import org.tizen.emulator.skin.image.ProfileSkinImageRegistry.SkinImageType;
import org.tizen.emulator.skin.info.EmulatorSkinState;
import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.menu.KeyWindowKeeper;
import org.tizen.emulator.skin.menu.PopupMenu;
import org.tizen.emulator.skin.util.HWKeyRegion;
import org.tizen.emulator.skin.util.SkinRotation;
if (popupMenu != null && popupMenu.keyWindowItem != null) {
final int dockValue = config.getSkinPropertyInt(
- SkinPropertiesConstants.KEYWINDOW_POSITION, 0);
+ SkinPropertiesConstants.KEYWINDOW_POSITION, SWT.NONE);
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (dockValue == SWT.NONE) {
skin.getKeyWindowKeeper().openKeyWindow(
- SWT.RIGHT | SWT.CENTER, false);
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION, false);
} else {
skin.getKeyWindowKeeper().openKeyWindow(
dockValue, false);
public GeneralKeyWindow(EmulatorSkin skin,
GeneralKeyWindowImageRegistry imageRegstry, List<KeyMapType> keyMapList) {
- super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
+ super(skin.getShell(), KeyWindowKeeper.DEFAULT_DOCK_POSITION);
this.skin = skin;
this.parent = skin.getShell();
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.custom.SkinWindow;
import org.tizen.emulator.skin.util.SkinUtil;
public class KeyWindowKeeper {
+ public static final int DEFAULT_DOCK_POSITION = (SWT.RIGHT | SWT.CENTER);
+
private static Logger logger =
SkinLogger.getSkinLogger(KeyWindowKeeper.class).getLogger();
/* create a Key Window */
determineLayout();
- if (isGeneralKeyWindow() == true
- || skin.getPopupMenu().keyWindowItem.getMenu() == null) {
+ if (isGeneralKeyWindow() == true) {
if (imageRegstry == null) {
logger.warning("GeneralKeyWindowImageRegistry is null");
return;
keyWindow = new GeneralKeyWindow(skin, imageRegstry, keyMapList);
} else {
- // TODO:
- String layoutName =
- skin.getPopupMenu().keyWindowItem.getMenu().getItem(indexLayout).getText();
+ Menu keywindowMenu = skin.getPopupMenu().keyWindowItem.getMenu();
+ MenuItem layout = keywindowMenu.getItem(indexLayout);
+ if (layout == null) {
+ layout = keywindowMenu.getItem(0);
+ layout.setSelection(true);
+ }
+
+ String layoutName = layout.getText();
logger.info("generate a \'" + layoutName + "\' key window!");
keyWindow = new SpecialKeyWindow(skin, layoutName);
if (keywindowItem != null && keywindowItem.getMenu() != null) {
logger.info("key window has a special layout");
+ indexLayout = 0;
+
MenuItem[] layouts = keywindowItem.getMenu().getItems();
for (int i = 0; i < layouts.length; i++) {
MenuItem layout = layouts[i];
if (isGeneralKeyWindow() == true) {
return keywindowMenu.getSelection();
} else {
- if (keywindowMenu.getMenu() == null) {
- logger.info("Special KeyWindow menu item is null");
- } else {
- for (MenuItem layout : keywindowMenu.getMenu().getItems()) {
- if (layout.getSelection() == true) {
- return true;
- }
+ for (MenuItem layout : keywindowMenu.getMenu().getItems()) {
+ if (layout.getSelection() == true) {
+ return true;
}
}
}
if (isGeneralKeyWindow() == true) {
keywindowMenu.setSelection(on);
} else {
- if (keywindowMenu.getMenu() == null) {
- logger.info("Special KeyWindow menu item is null");
- } else {
- keywindowMenu.getMenu().getItem(indexLayout).setSelection(on);
+ MenuItem layout = keywindowMenu.getMenu().getItem(indexLayout);
+ if (layout != null) {
+ layout.setSelection(on);
}
}
}
if (matchedItem == null) {
matchedItem = scaleSubMenu.getItem(0);
+ if (matchedItem == null) {
+ return;
+ }
skin.getEmulatorSkinState().setCurrentScale(
(Integer) matchedItem.getData());
}
private boolean isTouch;
public SpecialKeyWindow(EmulatorSkin skin, String layoutName) {
- super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
+ super(skin.getShell(), KeyWindowKeeper.DEFAULT_DOCK_POSITION);
this.parent = skin.getShell();
this.shell = new Shell(parent.getDisplay() /* for Mac & Always on Top */,