[Title] divided openTray codes in TrayWizard
authorjihoon song <jihoon80.song@samsung.com>
Thu, 3 Nov 2011 06:22:01 +0000 (15:22 +0900)
committerjihoon song <jihoon80.song@samsung.com>
Thu, 3 Nov 2011 06:22:01 +0000 (15:22 +0900)
[Type] Enhancement
[Module] common
[Priority] Major
[CQ#] --
[Redmine#] 2909
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I1787cb2ce7620f76b5ad223cb33abdc4b30648ca

com.samsung.slp.common/src/com/samsung/slp/common/swt/TrayWizardPage.java

index a4c31b2..911e803 100644 (file)
@@ -18,6 +18,7 @@
 
 package com.samsung.slp.common.swt;
 
+import org.eclipse.jface.dialogs.DialogTray;
 import org.eclipse.jface.dialogs.TrayDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.wizard.IWizardContainer;
@@ -38,52 +39,63 @@ import org.eclipse.swt.widgets.Control;
  * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
  */
 public abstract class TrayWizardPage extends WizardPage {
-       
-       protected TrayWizardPage(String pageName) {
-               super(pageName);
-       }
-       
-       protected TrayWizardPage(String pageName, String title, ImageDescriptor titleImage) {
-               super(pageName, title, titleImage);
-       }
-       
-       /**
-        * a extended WizardPage class using ClosableTray class
-        * 
-        * @param parent a composite control which will be the parent of the new instance (cannot be null)
-        * @param buttonText the new text of Button control
-        * @param tray the ClosableTray to show in dialog
-        * @return <b>Control</b> - return created Button control
-        */
-       protected Control createTrayButtonControl(Composite parent, String buttonText, final ClosableTray tray) {
-               Composite child = new Composite(parent, SWT.NONE);
-               child.setLayout(new GridLayout());
-               child.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-               
-               Button expandButton = new Button(child, SWT.NONE);
-               expandButton.setText(buttonText);
-               expandButton.addSelectionListener(new SelectionListener() {
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               IWizardContainer wc = getContainer();
-                               if (wc instanceof TrayDialog) {
-                                       TrayDialog wd = (TrayDialog) wc;
-                                       
-                                       // alreay opened
-                                       if (wd.getTray() instanceof ClosableTray) {
-                                               return;
-                                       } else if (wd.getTray() != null) {
-                                               wd.closeTray();
-                                       }
-                                       
-                                       wd.openTray(tray);
-                               }
-                       }
-                       
-                       @Override
-                       public void widgetDefaultSelected(SelectionEvent e) {}
-               });
-               
-               return expandButton;
-       }
+    
+    protected TrayWizardPage(String pageName) {
+        super(pageName);
+    }
+    
+    protected TrayWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+        super(pageName, title, titleImage);
+    }
+    
+    /**
+     * a extended WizardPage class using ClosableTray class
+     * 
+     * @param parent a composite control which will be the parent of the new instance (cannot be null)
+     * @param buttonText the new text of Button control
+     * @param tray the ClosableTray to show in dialog
+     * @return <b>Control</b> - return created Button control
+     */
+    protected Control createTrayButtonControl(Composite parent, String buttonText, final ClosableTray tray) {
+        Composite child = new Composite(parent, SWT.NONE);
+        child.setLayout(new GridLayout());
+        child.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+        
+        Button expandButton = new Button(child, SWT.NONE);
+        expandButton.setText(buttonText);
+        expandButton.addSelectionListener(new SelectionListener() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                openClosableTray(tray);
+            }
+            
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e) {
+            }
+        });
+        
+        return expandButton;
+    }
+    
+    /**
+     * open a tray using ClosableTray class. If another tray was opened, open new tray after close the opened tray automatically
+     * 
+     * @param tray the ClosableTray to show in dialog
+     * @return <b>Control</b> - return created Button control
+     */
+    protected void openClosableTray(ClosableTray tray) {
+        IWizardContainer wc = getContainer();
+        if (wc instanceof TrayDialog) {
+            TrayDialog wd = (TrayDialog) wc;
+            
+            // alreay opened
+            DialogTray currentTray = wd.getTray();
+            if (! (currentTray instanceof ClosableTray)) {
+                if (currentTray != null) {
+                    wd.closeTray();
+                }
+                wd.openTray(tray);
+            }
+        }
+    }
 }
\ No newline at end of file