4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Kangho Kim <kh5325.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
26 package org.tizen.common.swt;
28 import org.eclipse.jface.dialogs.DialogTray;
29 import org.eclipse.jface.dialogs.TrayDialog;
30 import org.eclipse.jface.resource.ImageDescriptor;
31 import org.eclipse.jface.wizard.IWizardContainer;
32 import org.eclipse.jface.wizard.WizardPage;
33 import org.eclipse.swt.SWT;
34 import org.eclipse.swt.events.SelectionEvent;
35 import org.eclipse.swt.events.SelectionListener;
36 import org.eclipse.swt.layout.GridData;
37 import org.eclipse.swt.layout.GridLayout;
38 import org.eclipse.swt.widgets.Button;
39 import org.eclipse.swt.widgets.Composite;
40 import org.eclipse.swt.widgets.Control;
44 * a extended WizardPage class using ClosableTray class
46 * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
48 public abstract class TrayWizardPage extends WizardPage {
50 protected TrayWizardPage(String pageName) {
54 protected TrayWizardPage(String pageName, String title, ImageDescriptor titleImage) {
55 super(pageName, title, titleImage);
59 * a extended WizardPage class using ClosableTray class
61 * @param parent a composite control which will be the parent of the new instance (cannot be null)
62 * @param buttonText the new text of Button control
63 * @param tray the ClosableTray to show in dialog
64 * @return <b>Control</b> - return created Button control
66 protected Control createTrayButtonControl(Composite parent, String buttonText, final ClosableTray tray) {
67 Composite child = new Composite(parent, SWT.NONE);
68 child.setLayout(new GridLayout());
69 child.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
71 Button expandButton = new Button(child, SWT.NONE);
72 expandButton.setText(buttonText);
73 expandButton.addSelectionListener(new SelectionListener() {
75 public void widgetSelected(SelectionEvent e) {
76 openClosableTray(tray);
80 public void widgetDefaultSelected(SelectionEvent e) {
88 * open a tray using ClosableTray class. If another tray was opened, open new tray after close the opened tray automatically
90 * @param tray the ClosableTray to show in dialog
91 * @return <b>Control</b> - return created Button control
93 protected void openClosableTray(ClosableTray tray) {
94 IWizardContainer wc = getContainer();
95 if (wc instanceof TrayDialog) {
96 TrayDialog wd = (TrayDialog) wc;
99 DialogTray currentTray = wd.getTray();
100 if (! (currentTray instanceof ClosableTray)) {
101 if (currentTray != null) {