Merge branch 'master' into simulator.
[platform/upstream/iotivity.git] /
1 package oic.simulator.serviceprovider.view.dialogs;
2
3 import oic.simulator.serviceprovider.utils.Constants;
4
5 import org.eclipse.jface.wizard.IWizardPage;
6 import org.eclipse.jface.wizard.WizardPage;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.events.SelectionAdapter;
9 import org.eclipse.swt.events.SelectionEvent;
10 import org.eclipse.swt.layout.GridData;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.widgets.Button;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Label;
15 import org.eclipse.swt.widgets.Text;
16
17 public class StartStopResourcePage extends WizardPage {
18
19     private Button  startButton;
20
21     private boolean start;
22
23     protected StartStopResourcePage() {
24         super("Start/Stop Resource");
25         setStart(true);
26     }
27
28     @Override
29     public void createControl(Composite parent) {
30         setPageComplete(false);
31         setTitle(Constants.START_STOP_PAGE_TITLE);
32         setMessage(Constants.START_STOP_PAGE_MESSAGE);
33         Composite compContent = new Composite(parent, SWT.NONE);
34         GridLayout gridLayout = new GridLayout();
35         compContent.setLayout(gridLayout);
36         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
37         compContent.setLayoutData(gd);
38
39         startButton = new Button(compContent, SWT.CHECK);
40         startButton.setText("Start Resource(s)");
41         startButton.setSelection(true);
42         gd = new GridData();
43         gd.verticalIndent = 10;
44         startButton.setLayoutData(gd);
45
46         Label descLbl = new Label(compContent, SWT.NONE);
47         descLbl.setText("Description:");
48         gd = new GridData();
49         gd.verticalIndent = 50;
50         descLbl.setLayoutData(gd);
51
52         final Text text = new Text(compContent, SWT.MULTI | SWT.READ_ONLY
53                 | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
54         text.setText("Starting the resource will register it with the platform and makes it visible on the network.\n"
55                 + "Resources can be started or stopped later from 'Resource Manager' view.");
56         gd = new GridData();
57         gd.horizontalAlignment = SWT.FILL;
58         gd.grabExcessHorizontalSpace = true;
59         gd.heightHint = 100;
60         gd.verticalAlignment = SWT.BOTTOM;
61         text.setLayoutData(gd);
62
63         addUIListeners();
64
65         setControl(compContent);
66     }
67
68     private void addUIListeners() {
69         startButton.addSelectionListener(new SelectionAdapter() {
70             @Override
71             public void widgetSelected(SelectionEvent e) {
72                 setStart(startButton.getSelection());
73             }
74         });
75     }
76
77     public boolean isStart() {
78         return start;
79     }
80
81     public void setStart(boolean start) {
82         this.start = start;
83     }
84
85     @Override
86     public IWizardPage getNextPage() {
87         System.out.println(this.getClass().getName() + ": getNextPage");
88         return null;
89     }
90 }