1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.ui.dist.editors;
17
18 import javax.jcr.Node;
19
20 import org.argeo.slc.SlcException;
21 import org.argeo.slc.SlcNames;
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.Text;
30 import org.eclipse.ui.forms.IManagedForm;
31 import org.eclipse.ui.forms.editor.FormEditor;
32 import org.eclipse.ui.forms.editor.FormPage;
33 import org.eclipse.ui.forms.widgets.FormToolkit;
34 import org.eclipse.ui.forms.widgets.ScrolledForm;
35
36
37
38
39
40 public class RunInOsgiPage extends FormPage implements SlcNames {
41
42 final static String PAGE_ID = "RunInOsgiPage";
43
44
45 private Node modularDistribution;
46
47
48 private Button launchBtn;
49 private Text consoleTxt;
50
51 private FormToolkit tk;
52
53 public RunInOsgiPage(FormEditor formEditor, String title,
54 Node modularDistribution) {
55 super(formEditor, PAGE_ID, title);
56 this.modularDistribution = modularDistribution;
57 }
58
59 @Override
60 protected void createFormContent(IManagedForm managedForm) {
61 ScrolledForm form = managedForm.getForm();
62 tk = managedForm.getToolkit();
63
64 Composite body = form.getBody();
65 GridLayout layout = new GridLayout();
66 layout.marginTop = layout.marginWidth = 0;
67 body.setLayout(layout);
68
69
70 Composite header = tk.createComposite(body);
71 header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
72 createHeaderPart(header);
73
74
75 Composite console = tk.createComposite(body);
76 console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
77 createConsolePart(console);
78 body.layout();
79 }
80
81 private void createHeaderPart(Composite parent) {
82 GridLayout layout = new GridLayout();
83 parent.setLayout(layout);
84
85
86 launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
87 launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
88
89 launchBtn.addSelectionListener(new SelectionAdapter() {
90 private static final long serialVersionUID = -1633658484882130602L;
91
92 @Override
93 public void widgetSelected(SelectionEvent e) {
94 super.widgetSelected(e);
95 throw new SlcException("Implement this");
96 }
97 });
98 }
99
100 private void createConsolePart(Composite parent) {
101 parent.setLayout(new GridLayout());
102 consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
103 | SWT.BORDER);
104 consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
105 }
106
107 @Override
108 public void setFocus() {
109 launchBtn.setFocus();
110 }
111 }