From cd0f828373480ba5d0738996ed5f75c4d04b7455 Mon Sep 17 00:00:00 2001 From: jihoon song Date: Thu, 3 Nov 2011 15:22:01 +0900 Subject: [PATCH] [Title] divided openTray codes in TrayWizard [Type] Enhancement [Module] common [Priority] Major [CQ#] -- [Redmine#] 2909 [Problem] [Cause] [Solution] [TestCase] Change-Id: I1787cb2ce7620f76b5ad223cb33abdc4b30648ca --- .../com/samsung/slp/common/swt/TrayWizardPage.java | 108 ++++++++++++--------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/com.samsung.slp.common/src/com/samsung/slp/common/swt/TrayWizardPage.java b/com.samsung.slp.common/src/com/samsung/slp/common/swt/TrayWizardPage.java index a4c31b2..911e803 100644 --- a/com.samsung.slp.common/src/com/samsung/slp/common/swt/TrayWizardPage.java +++ b/com.samsung.slp.common/src/com/samsung/slp/common/swt/TrayWizardPage.java @@ -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 } (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 Control - 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 Control - 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 Control - 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 -- 2.7.4