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.ModifyEvent;
23 import org.eclipse.swt.events.ModifyListener;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Group;
28 import org.eclipse.swt.widgets.Label;
29 import org.eclipse.swt.widgets.Text;
31 import oic.simulator.serviceprovider.utils.Constants;
33 public class UpdatePropertiesPage extends WizardPage {
35 private Text resNameTxt;
36 private Text resUriTxt;
38 private String resName;
39 private String resURI;
41 protected UpdatePropertiesPage() {
42 super("Update Properties");
46 public void createControl(Composite parent) {
47 setPageComplete(true);
48 setTitle(Constants.UPDATE_PROP_PAGE_TITLE);
49 setMessage(Constants.UPDATE_PROP_PAGE_MESSAGE);
51 Composite comp = new Composite(parent, SWT.NONE);
52 GridLayout gridLayout = new GridLayout();
53 comp.setLayout(gridLayout);
54 GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
55 comp.setLayoutData(gd);
57 Group grp = new Group(comp, SWT.NONE);
58 gridLayout = new GridLayout(2, false);
59 grp.setLayout(gridLayout);
60 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
61 grp.setLayoutData(gd);
63 Label resNameLbl = new Label(grp, SWT.NULL);
64 resNameLbl.setText("Resource Name");
66 gd.verticalIndent = 20;
67 resNameLbl.setLayoutData(gd);
69 resNameTxt = new Text(grp, SWT.BORDER);
70 resNameTxt.setFocus();
73 gd.verticalIndent = 20;
74 resNameTxt.setLayoutData(gd);
76 Label resUriLbl = new Label(grp, SWT.NULL);
77 resUriLbl.setText("Resource URI");
79 gd.verticalIndent = 10;
80 resUriLbl.setLayoutData(gd);
82 resUriTxt = new Text(grp, SWT.BORDER);
85 gd.verticalIndent = 10;
86 resUriTxt.setLayoutData(gd);
88 Label descLbl = new Label(comp, SWT.NONE);
89 descLbl.setText("Description:");
91 descLbl.setLayoutData(gd);
93 final Text text = new Text(comp, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER
94 | SWT.WRAP | SWT.V_SCROLL);
95 text.setText("These properties can be changed later from properties view.");
96 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
97 text.setLayoutData(gd);
102 if (resUriTxt.getText().length() < 1 && null != resURI) {
103 resUriTxt.setText(resURI);
105 if (resNameTxt.getText().length() < 1 && null != resName) {
106 resNameTxt.setText(resName);
112 private void addUIListeners() {
113 resNameTxt.addModifyListener(new ModifyListener() {
115 public void modifyText(ModifyEvent e) {
116 resName = resNameTxt.getText();
117 setPageComplete(isSelectionDone());
121 resUriTxt.addModifyListener(new ModifyListener() {
123 public void modifyText(ModifyEvent e) {
124 resURI = resUriTxt.getText();
125 if (null == resURI) {
129 setPageComplete(isSelectionDone());
135 public boolean canFlipToNextPage() {
139 public boolean isSelectionDone() {
140 boolean done = false;
141 if (null != resName && resName.trim().length() > 0 && null != resURI
142 && resURI.trim().length() > 0) {
149 public IWizardPage getNextPage() {
153 public void setResName(String resName) {
154 this.resName = resName;
155 if (!resNameTxt.isDisposed())
156 resNameTxt.setText(resName);
159 public void setResURI(String resURI) {
160 this.resURI = resURI;
161 if (!resUriTxt.isDisposed())
162 resUriTxt.setText(resURI);
165 public String getResName() {
169 public String getResURI() {