]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java
Clarify SLC project structure.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / RunInOsgiPage.java
1 package org.argeo.slc.client.ui.dist.editors;
2
3 import javax.jcr.Node;
4
5 import org.argeo.slc.SlcException;
6 import org.argeo.slc.SlcNames;
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.Text;
15 import org.eclipse.ui.forms.IManagedForm;
16 import org.eclipse.ui.forms.editor.FormEditor;
17 import org.eclipse.ui.forms.editor.FormPage;
18 import org.eclipse.ui.forms.widgets.FormToolkit;
19 import org.eclipse.ui.forms.widgets.ScrolledForm;
20
21 /**
22 * Enable launch of the current distribution in a separate osgi run time.
23 * Display also a console to interract with the launched runtime
24 */
25 public class RunInOsgiPage extends FormPage implements SlcNames {
26
27 final static String PAGE_ID = "RunInOsgiPage";
28
29 // Business Objects
30 private Node modularDistribution;
31
32 // This page widgets
33 private Button launchBtn;
34 private Text consoleTxt;
35
36 private FormToolkit tk;
37
38 public RunInOsgiPage(FormEditor formEditor, String title,
39 Node modularDistribution) {
40 super(formEditor, PAGE_ID, title);
41 this.modularDistribution = modularDistribution;
42 }
43
44 @Override
45 protected void createFormContent(IManagedForm managedForm) {
46 ScrolledForm form = managedForm.getForm();
47 tk = managedForm.getToolkit();
48 // Main Layout
49 Composite body = form.getBody();
50 GridLayout layout = new GridLayout();
51 layout.marginTop = layout.marginWidth = 0;
52 body.setLayout(layout);
53
54 // The header
55 Composite header = tk.createComposite(body);
56 header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
57 createHeaderPart(header);
58
59 // The console
60 Composite console = tk.createComposite(body);
61 console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
62 createConsolePart(console);
63 body.layout();
64 }
65
66 private void createHeaderPart(Composite parent) {
67 GridLayout layout = new GridLayout();
68 parent.setLayout(layout);
69
70 // Text Area to filter
71 launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
72 launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
73
74 launchBtn.addSelectionListener(new SelectionAdapter() {
75 private static final long serialVersionUID = -1633658484882130602L;
76
77 @Override
78 public void widgetSelected(SelectionEvent e) {
79 super.widgetSelected(e);
80 throw new SlcException("Implement this");
81 }
82 });
83 }
84
85 private void createConsolePart(Composite parent) {
86 parent.setLayout(new GridLayout());
87 consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
88 | SWT.BORDER);
89 consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
90 }
91
92 @Override
93 public void setFocus() {
94 launchBtn.setFocus();
95 }
96 }