2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package oic.simulator.serviceprovider.view.dialogs;
19 import org.eclipse.jface.wizard.IWizardPage;
20 import org.eclipse.jface.wizard.WizardPage;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.events.SelectionAdapter;
23 import org.eclipse.swt.events.SelectionEvent;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Button;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.swt.widgets.Label;
29 import org.eclipse.swt.widgets.Text;
31 import org.oic.simulator.server.SimulatorResource.Type;
33 import oic.simulator.serviceprovider.utils.Constants;
35 public class MainPage extends WizardPage {
37 private Button simpleBtn;
38 private Button simpleFromRamlBtn;
39 private Text description;
42 SIMPLE, SIMPLE_FROM_RAML
45 private Option option;
47 protected MainPage() {
52 public void createControl(Composite parent) {
53 setPageComplete(false);
54 setTitle(Constants.MAIN_PAGE_TITLE);
55 setMessage(Constants.MAIN_PAGE_MESSAGE);
56 Composite compContent = new Composite(parent, SWT.NONE);
57 GridLayout gridLayout = new GridLayout();
58 compContent.setLayout(gridLayout);
59 GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
60 compContent.setLayoutData(gd);
62 simpleBtn = new Button(compContent, SWT.RADIO);
63 simpleBtn.setText("Simple resource");
65 simpleFromRamlBtn = new Button(compContent, SWT.RADIO);
66 simpleFromRamlBtn.setText("Simple resource(From RAML)");
68 Label lbl = new Label(compContent, SWT.NULL);
69 lbl.setText("Details:");
71 gd.verticalIndent = 20;
72 lbl.setLayoutData(gd);
74 description = new Text(compContent, SWT.MULTI | SWT.READ_ONLY
75 | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
76 description.setBackground(compContent.getBackground());
77 description.setText("[Select an option to view more details]");
78 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
79 description.setLayoutData(gd);
83 setControl(compContent);
86 private void addUIListeners() {
87 simpleBtn.addSelectionListener(new SelectionAdapter() {
89 public void widgetSelected(SelectionEvent e) {
91 .setText("Create a simple resource by manually entering all the details given below.\n"
92 + "\t1. Basic resource details: URI, Name, Resource Types, etc.\n"
93 + "\t2. Options such as Observable, allowed request types, start/stop resource etc.\n"
94 + "\t3. Adding attributes.");
95 option = Option.SIMPLE;
96 getWizard().getContainer().updateButtons();
100 simpleFromRamlBtn.addSelectionListener(new SelectionAdapter() {
102 public void widgetSelected(SelectionEvent e) {
104 .setText("Create a simple resource from RAML configuration file.\n"
105 + "\t1. Resource details, attributes, and other properties will be read from RAML.\n"
106 + "\t2. Supports multi-instance creation.\n"
107 + "\t3. For single instance creation, allows editing the URI and Name of the resource.\n"
108 + "\t4. Allows to start or stop the resource(s).");
109 option = Option.SIMPLE_FROM_RAML;
110 getWizard().getContainer().updateButtons();
116 public boolean canFlipToNextPage() {
121 public IWizardPage getPreviousPage() {
126 public IWizardPage getNextPage() {
127 CreateResourceWizard createWizard = (CreateResourceWizard) getWizard();
128 if (simpleBtn.getSelection()) {
129 return createWizard.getSimpleResourceBasicDetailsPage();
131 if (simpleFromRamlBtn.getSelection()) {
132 LoadRamlPage page = createWizard.getLoadRamlPage();
133 page.initialSetup(Type.SINGLE);
139 public Option getOption() {