[Title] Refactoring table tool tip listener
authorho.namkoong <ho.namkoong@samsung.com>
Fri, 17 Aug 2012 11:32:16 +0000 (20:32 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Fri, 17 Aug 2012 11:32:16 +0000 (20:32 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I91bbeb95e2fd11b44d8671bd58c3c37b0b99edcf

org.tizen.common/src/org/tizen/common/ui/TableToolTipListener.java
org.tizen.common/src/org/tizen/common/util/SWTUtil.java

index 6b71bff..e49672a 100644 (file)
@@ -63,16 +63,9 @@ public abstract class TableToolTipListener implements Listener{
      * 
      * @param table will be added listener.
      */
-    public TableToolTipListener (Table table) {
-        this.table = table;
-        this.addListners();
-    }
     
-    private void addListners() {
-        this.table.addListener(SWT.MouseMove, this);
-        this.table.addListener(SWT.MouseWheel, this);
-        this.table.addListener(SWT.Dispose, this);
-        this.table.addListener(SWT.MouseHover, this);
+    public void setTable(Table table) {
+        this.table = table;
     }
     
     @Override
@@ -80,17 +73,12 @@ public abstract class TableToolTipListener implements Listener{
         int eventType = event.type;
         
         if(SWT.MouseMove == eventType || SWT.MouseWheel == eventType || SWT.Dispose == eventType) {
-            if(label != null) {
-                label.dispose();
+            if(tip != null) {
+                tip.dispose();
+                tip = null;
                 label = null;
                 return;
             }
-//            if(tip != null) {
-//                tip.dispose();
-//                tip = null;
-//                label = null;
-//                return;
-//            }
         }
         if(SWT.MouseHover == eventType) {
             TableItem item = this.table.getItem(new Point(event.x, event.y));
index 18291b5..a641f42 100644 (file)
@@ -45,6 +45,7 @@ import org.eclipse.swt.graphics.Resource;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
@@ -55,6 +56,7 @@ import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.tizen.common.ui.TableToolTipListener;
 
 
 @SuppressWarnings("restriction")
@@ -392,6 +394,14 @@ public class SWTUtil {
         return projectPath;
     }
     
+    public static void addTableToolTipListener(Table table, TableToolTipListener listener) {
+        listener.setTable(table);
+        table.addListener(SWT.MouseMove, listener);
+        table.addListener(SWT.MouseWheel, listener);
+        table.addListener(SWT.Dispose, listener);
+        table.addListener(SWT.MouseHover, listener);
+    }
+    
     /**
      * Expands tree and its sub treeitems.
      *