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.clientcontroller.view.dialogs;
19 import oic.simulator.clientcontroller.utils.Constants;
21 import org.eclipse.jface.dialogs.TitleAreaDialog;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.SelectionAdapter;
24 import org.eclipse.swt.events.SelectionEvent;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
27 import org.eclipse.swt.widgets.Button;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.FileDialog;
31 import org.eclipse.swt.widgets.Label;
32 import org.eclipse.swt.widgets.Shell;
33 import org.eclipse.swt.widgets.Text;
34 import org.eclipse.ui.PlatformUI;
37 * This dialog is used for loading the RAML file.
39 public class LoadRAMLDialog extends TitleAreaDialog {
41 private Text locationTxt;
42 private Button btnBrowse;
43 private String configFilePath;
45 public LoadRAMLDialog(Shell parentShell) {
50 public void create() {
52 setTitle("Load Remote Resource Configuration");
53 setMessage("Select the RAML Configuration file of the resource to enable Automation.");
57 protected Control createDialogArea(Composite parent) {
58 Composite compLayout = (Composite) super.createDialogArea(parent);
59 Composite container = new Composite(compLayout, SWT.NONE);
60 container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
61 GridLayout layout = new GridLayout(3, false);
62 layout.verticalSpacing = 10;
63 layout.marginTop = 10;
64 container.setLayout(layout);
66 Label loadRamlLbl = new Label(container, SWT.NONE);
67 loadRamlLbl.setText("Load RAML File");
70 gd.horizontalSpan = 3;
71 loadRamlLbl.setLayoutData(gd);
73 Label locationLbl = new Label(container, SWT.NONE);
74 locationLbl.setText("Location:");
76 locationTxt = new Text(container, SWT.BORDER);
78 gd.minimumWidth = 300;
79 gd.horizontalAlignment = SWT.FILL;
80 gd.grabExcessHorizontalSpace = true;
81 locationTxt.setLayoutData(gd);
83 btnBrowse = new Button(container, SWT.NONE);
84 btnBrowse.setText("Browse");
87 gd.horizontalAlignment = SWT.FILL;
88 btnBrowse.setLayoutData(gd);
95 private void addUIListeners() {
96 btnBrowse.addSelectionListener(new SelectionAdapter() {
98 public void widgetSelected(SelectionEvent e) {
99 FileDialog fileDialog = new FileDialog(PlatformUI
100 .getWorkbench().getDisplay().getActiveShell(), SWT.NONE);
102 .setFilterExtensions(Constants.BROWSE_RAML_FILTER_EXTENSIONS);
103 configFilePath = fileDialog.open();
104 if (null == configFilePath) {
105 System.out.println("Config file path is null");
108 locationTxt.setText(configFilePath);
113 public String getConfigFilePath() {
114 return configFilePath;
118 public boolean isHelpAvailable() {