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;
* @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