[Title] DACombo mouse wheel
authorjy.exe.lee <jy.exe.lee@samsung.com>
Tue, 3 Jul 2012 10:21:29 +0000 (19:21 +0900)
committerjy.exe.lee <jy.exe.lee@samsung.com>
Tue, 3 Jul 2012 10:21:29 +0000 (19:21 +0900)
[Type] new feature
[Module] DynamicAnalyzer
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DACombo.java

index 991c067..18189f8 100644 (file)
@@ -124,16 +124,16 @@ public class DACombo extends Composite {
                                        }
                                }
 
-                               if (event.type == SWT.MouseExit) {
-                                       changeComboState(STATE_NORMAL);
-                                       if (null != childShell && !childShell.isDisposed()) {
-                                               Rectangle rect = combo.getBounds();
-                                               if (rect.y + rect.height > event.y) {
-                                                       childShell.close();
-                                                       childShell = null;
-                                               }
-                                       }
-                               }
+                               // if (event.type == SWT.MouseExit) {
+                               // changeComboState(STATE_NORMAL);
+                               // if (null != childShell && !childShell.isDisposed()) {
+                               // Rectangle rect = combo.getBounds();
+                               // if (rect.y + rect.height > event.y) {
+                               // childShell.close();
+                               // childShell = null;
+                               // }
+                               // }
+                               // }
 
                                if (event.type == SWT.MouseDown) {
                                        changeComboState(STATE_PUSH);
@@ -233,6 +233,7 @@ public class DACombo extends Composite {
                popup.addListener(SWT.MouseMove, canvasMouseEventListener);
                popup.addListener(SWT.MouseUp, canvasMouseUpListener);
                popup.addListener(SWT.FocusOut, canvasMouseEventListener);
+               popup.addListener(SWT.MouseWheel, canvasMouseEventListener);
 
                if (size > MAX_SIZE) {
                        upArrowButton = new DAButton(childShell, SWT.NONE);
@@ -244,8 +245,8 @@ public class DACombo extends Composite {
                        data.height = height;
                        upArrowButton.setLayoutData(data);
                        upArrowButton.addClickListener(upArrowListener);
-                       upArrowButton.setDAButtonAction(new ComboButtonAction(childShell,
-                                       upArrowButton, true));
+//                     upArrowButton.setDAButtonAction(new ComboButtonAction(childShell,
+//                                     upArrowButton, true));
                        shellHeight += height;
 
                        data = new FormData();
@@ -264,8 +265,8 @@ public class DACombo extends Composite {
                        data.height = height;
                        downArrowButton.setLayoutData(data);
                        downArrowButton.addClickListener(downArrowListener);
-                       downArrowButton.setDAButtonAction(new ComboButtonAction(childShell,
-                                       downArrowButton, false));
+//                     downArrowButton.setDAButtonAction(new ComboButtonAction(childShell,
+//                                     downArrowButton, false));
                        shellHeight += height;
 
                        childShell.setSize(shellWidth, shellHeight);
@@ -402,22 +403,51 @@ public class DACombo extends Composite {
                                }
                        }
 
-                       if (event.type == SWT.MouseExit) {
-                               if (null != upArrowButton && null != downArrowButton) {
-                                       Rectangle rect = popup.getClientArea();
-                                       if (rect.y < event.y && rect.y + rect.height > event.y) {
-                                               childShell.close();
-                                               childShell = null;
-                                       }
-                               } else {
-                                       childShell.close();
-                                       childShell = null;
-                               }
-                       }
+                       // if (event.type == SWT.MouseExit) {
+                       // if (null != upArrowButton && null != downArrowButton) {
+                       // Rectangle rect = popup.getClientArea();
+                       // if (rect.y < event.y && rect.y + rect.height > event.y) {
+                       // childShell.close();
+                       // childShell = null;
+                       // }
+                       // } else {
+                       // childShell.close();
+                       // childShell = null;
+                       // }
+                       // }
                        if (event.type == SWT.FocusOut) {
                                childShell.close();
                                childShell = null;
                        }
+
+                       if (event.type == SWT.MouseWheel) {
+                               int size = getItems().size();
+                               if (event.count < 0) {
+                                       if (itemIndex - event.count + MAX_SIZE >= size - 1) {
+                                               itemIndex = size - MAX_SIZE;
+                                               downArrowButton.setEnabled(false);
+                                       } else {
+                                               itemIndex -= event.count;
+                                       }
+
+                                       if (itemIndex - pageSize > 0) {
+                                               upArrowButton.setEnabled(true);
+                                       }
+                               } else {
+
+                                       if (itemIndex - event.count < 0) {
+                                               itemIndex = 0;
+                                               upArrowButton.setEnabled(false);
+                                       } else {
+                                               itemIndex -= event.count;
+                                       }
+
+                                       if (itemIndex + event.count < size - 1) {
+                                               downArrowButton.setEnabled(true);
+                                       }
+                               }
+                               popup.redraw();
+                       }
                }
        };
        private Listener canvasMouseUpListener = new Listener() {