From 8e6532065ad4bb1bf5a7301eda2a05764d9ba35d Mon Sep 17 00:00:00 2001 From: jihye kim Date: Thu, 13 Jun 2013 17:19:13 +0900 Subject: [PATCH] [Title] emulator-manager : add double click listener [Desc.] add double click listener (for launching emulator) [Issue] N/A Change-Id: I438cf3abbd6c6d0697d19fa3dc6cf8e31726d328 Signed-off-by: jihye kim --- package/changelog | 5 +++ package/pkginfo.manifest | 2 +- .../emulator/manager/resources/FontResources.java | 20 +++++---- .../tizen/emulator/manager/ui/list/RowItem.java | 3 +- .../emulator/manager/ui/list/TreeListView.java | 52 ++++++++++++++++++++++ .../emulator/manager/ui/list/VMButtonFactory.java | 17 +++++++ 6 files changed, 89 insertions(+), 10 deletions(-) diff --git a/package/changelog b/package/changelog index 08e3530..0e0b935 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,8 @@ +* 2.2.1 +- add double click listener -> launching vm +- change mac os defualt font "Lucida Grande" +== jihye kim 2013-06-13 + * 2.2.0 - change USER_DATA_PATH -> SDK_DATA_PATH - update version diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 1e5485d..510cf2c 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Source: emulator-manager -Version: 2.2.0 +Version: 2.2.1 Maintainer: Yeong-Kyoon Lee Package: emulator-manager diff --git a/src/org/tizen/emulator/manager/resources/FontResources.java b/src/org/tizen/emulator/manager/resources/FontResources.java index 176cbd4..8ee4cf0 100644 --- a/src/org/tizen/emulator/manager/resources/FontResources.java +++ b/src/org/tizen/emulator/manager/resources/FontResources.java @@ -140,17 +140,21 @@ public enum FontResources { } public static Font getDADefaultFont() { - String fontName = null; - if (EmulatorManager.isLinux() || EmulatorManager.isMac()) { - fontName = "Dejavu Sans"; - } else if (EmulatorManager.isWin()) { - fontName = "Verdana"; - } else { - return Display.getCurrent().getSystemFont(); - } if (defaultFont == null) { + String fontName = null; + if (EmulatorManager.isLinux()) { + fontName = "Dejavu Sans"; + } else if (EmulatorManager.isWin()) { + fontName = "Verdana"; + } else if (EmulatorManager.isMac()) { + fontName = "Lucida Grande"; + } else { + defaultFont = Display.getCurrent().getSystemFont(); + return defaultFont; + } defaultFont = new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 9, SWT.NORMAL) }); } + return defaultFont; } } \ No newline at end of file diff --git a/src/org/tizen/emulator/manager/ui/list/RowItem.java b/src/org/tizen/emulator/manager/ui/list/RowItem.java index 79b8844..58d0619 100644 --- a/src/org/tizen/emulator/manager/ui/list/RowItem.java +++ b/src/org/tizen/emulator/manager/ui/list/RowItem.java @@ -34,6 +34,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.TreeItem; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.resources.FontResources; +import org.tizen.emulator.manager.resources.ImageResources; import org.tizen.emulator.manager.vms.VMProperty; public interface RowItem {} @@ -51,11 +52,11 @@ class PropertyContent implements TreeContent { this.property = property; this.item = item; - // TODO item.setFont(FontResources.TREE_ITEM_FONT.getFont()); for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) { item.setText(helper.getIndex(), helper.getContent(property)); } + item.setImage(0, ImageResources.LAUNCH.getImage()); } public VMProperty getProperty() { diff --git a/src/org/tizen/emulator/manager/ui/list/TreeListView.java b/src/org/tizen/emulator/manager/ui/list/TreeListView.java index 589705b..f55960b 100644 --- a/src/org/tizen/emulator/manager/ui/list/TreeListView.java +++ b/src/org/tizen/emulator/manager/ui/list/TreeListView.java @@ -32,9 +32,12 @@ package org.tizen.emulator.manager.ui.list; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Tree; @@ -81,6 +84,7 @@ public class TreeListView extends AbstractListView { settingListener(); } + private boolean isLaunchButton = false; private void settingListener() { /* vmsTree.addFocusListener(new FocusListener() { @@ -98,6 +102,54 @@ public class TreeListView extends AbstractListView { }); */ + + vmsTree.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + if (vmsTree.getSelection() != null) { + TreeItem item = vmsTree.getSelection()[0]; + if (item.getData() instanceof PropertyContent) { + PropertyContent content = (PropertyContent)item.getData(); + VMsMainView.getInstance().launchEmulator(content.property); + } + } + isLaunchButton = false; + } + + @Override + public void mouseDown(MouseEvent e) { + if (vmsTree.getSelection() != null) { + TreeItem item = vmsTree.getSelection()[0]; + if (item.getData() instanceof PropertyContent) { + Rectangle rect = item.getImageBounds(0); + if (e.x > rect.x && e.x < rect.x + rect.width) { + isLaunchButton = true; + return; + } + } + } + isLaunchButton = false; + } + + @Override + public void mouseUp(MouseEvent e) { + if (vmsTree.getSelection() != null) { + TreeItem item = vmsTree.getSelection()[0]; + if (item.getData() instanceof PropertyContent) { + Rectangle rect = item.getImageBounds(0); + if (e.x > rect.x && e.x < rect.x + rect.width) { + if (isLaunchButton) { + PropertyContent content = (PropertyContent)item.getData(); + VMsMainView.getInstance().launchEmulator(content.property); + } + } + } + } + isLaunchButton = false; + } + }); + vmsTree.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java b/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java index b44a868..15fecc9 100644 --- a/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java +++ b/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java @@ -32,6 +32,8 @@ package org.tizen.emulator.manager.ui.list; import java.util.ArrayList; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; @@ -84,6 +86,21 @@ public class VMButtonFactory { } }); + b.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + ((VMButton)e.widget).clickLaunchButton(); + } + + @Override + public void mouseDown(MouseEvent e) { + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); buttons.add(b); return b; } -- 2.7.4