]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java
Add cglib back
[gpl/argeo-slc.git] / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / RunInOsgiPage.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
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.jcr.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 * Enable launch of the current distribution in a separate osgi run time.
38 * Display also a console to interract with the launched runtime
39 */
40 public class RunInOsgiPage extends FormPage implements SlcNames {
41
42 final static String PAGE_ID = "RunInOsgiPage";
43
44 // Business Objects
45 private Node modularDistribution;
46
47 // This page widgets
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 // Main Layout
64 Composite body = form.getBody();
65 GridLayout layout = new GridLayout();
66 layout.marginTop = layout.marginWidth = 0;
67 body.setLayout(layout);
68
69 // The header
70 Composite header = tk.createComposite(body);
71 header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
72 createHeaderPart(header);
73
74 // The console
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 // Text Area to filter
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 @Override
91 public void widgetSelected(SelectionEvent e) {
92 super.widgetSelected(e);
93 throw new SlcException("Implement this");
94 }
95 });
96 }
97
98 private void createConsolePart(Composite parent) {
99 parent.setLayout(new GridLayout());
100 consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
101 | SWT.BORDER);
102 consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
103 }
104
105 @Override
106 public void setFocus() {
107 launchBtn.setFocus();
108 }
109 }