forked from RedhawkSDR/Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainch24.html
711 lines (669 loc) · 35.3 KB
/
mainch24.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title>24 Creating a REDHAWK Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html,2,next,javascript,charset="utf-8" -->
<meta name="src" content="main.tex">
<meta name="date" content="2013-03-12 19:46:00">
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="scripts/shCore.js"></script>
<script type="text/javascript" src="scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="scripts/shBrushJava.js"></script>
<script type="text/javascript" src="scripts/shBrushPython.js"></script>
<script type="text/javascript" src="scripts/shBrushBash.js"></script>
<script type="text/javascript" src="scripts/shBrushXml.js"></script>
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</head><body
>
<script>
function f() {
document.getElementById('main_content_wrap').focus();
}
if (window.addEventListener) {
window.addEventListener("load", f, false);
} else if (window.attachEvent) {
window.attachEvent("onload", f);
}
</script>
<div class="header">
<ul class="navbar">
<li><a class="logo-small" href="index.html"><img src="images/RedHawk_Logo_ALT_B_121px.png"/></a></li> <li><a href="index.html">Home</a></li>
<li><a href="gettingstarted/main.html">Getting Started</a></li>
<li><a class="active" href="main.html">Documentation</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="support.html">Support</a></li>
</ul>
<div class="pattern right"></div>
<a id="forkme_banner" href="https://github.com/redhawksdr">View on GitHub</a>
</div>
<!-- Custom MAIN CONTENT -->
<div id="main_content_wrap" tabindex="0" class="outer">
<section id="main_content" class="inner">
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainap1.html" >next</a>] [<a
href="mainch23.html" >prev</a>] [<a
href="mainch23.html#tailmainch23.html" >prev-tail</a>] [<a
href="#tailmainch24.html">tail</a>] [<a
href="main.html#mainch24.html" >up</a>] </p></div>
<h2 class="chapterHead"><span class="titlemark">Chapter 24</span><br /><a
id="x26-31700024"></a>Creating a REDHAWK Control Panel</h2>
<h3 class="sectionHead"><span class="titlemark">24.1 </span> <a
id="x26-31800024.1"></a>What is a Control Panel?</h3>
<!--l. 4--><p class="noindent" >A control panel is a contributed <a
href="mainap3.html#ui">UI</a> Component for a specific <a
href="mainli2.html#glo:domain">Domain</a> object to allow easier
interaction with that <a
href="mainli2.html#glo:domain">Domain</a> object. These usually appear in either the <a
href="mainli2.html#glo:property">Property</a> view or within
an editor.
<!--l. 8--><p class="noindent" >For example, all <a
href="mainli2.html#glo:component">Components</a> and <a
href="mainli2.html#glo:application">Applications</a> can be configured via the <a
href="mainli2.html#glo:property"><span
class="cmbx-12">Property</span></a> view. While
powerful, this view can be confusing to end users who are not familiar with REDHAWK or with
the <a
href="mainli2.html#glo:property">Properties</a>. Control panels allow the <a
href="mainli2.html#glo:component">Component</a> or <a
href="mainli2.html#glo:application">Application</a> developer to create a tailored
user experience.
<!--l. 13--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.1.1 </span> <a
id="x26-31900024.1.1"></a>Prerequisites</h4>
<!--l. 14--><p class="noindent" >To aid in understanding of the concepts and examples discussed in this chapter, the following
prerequisites should be met:
<ul class="itemize1">
<li class="itemize">The reader should have some level of Java programming experience.
</li>
<li class="itemize">The reader should have some level of understanding of Eclipse (specifically within the
context of the REDHAWK <a
href="mainap3.html#ide">IDE</a>).
</li>
<li class="itemize">Though not required, basic knowledge of Eclipse Rich Client Platform (<a
href="mainap3.html#rcp">RCP</a>)
development is helpful.</li></ul>
<!--l. 24--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">24.2 </span> <a
id="x26-32000024.2"></a>Creating a New REDHAWK Control Panel</h3>
<!--l. 27--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.2.1 </span> <a
id="x26-32100024.2.1"></a>Evoking the Eclipse Plug-in Wizard</h4>
<!--l. 28--><p class="noindent" >The following steps describe the process for evoking the Eclipse Plug-in Wizard.
<ol class="enumerate1" >
<li
class="enumerate" id="x26-321002x1">Open the <span
class="cmbx-12">New Project Wizard</span>
<ol class="enumerate2" >
<li
class="enumerate" id="x26-321004x1">Click <span
class="cmbx-12">File </span><span
class="cmmi-12">> </span><span
class="cmbx-12">New </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Project</span>
</li>
<li
class="enumerate" id="x26-321006x2">Expand <span
class="cmbx-12">Plug-in Development</span>
</li>
<li
class="enumerate" id="x26-321008x3">Select <span
class="cmbx-12">Plug-in Project</span></li></ol>
</li>
<li
class="enumerate" id="x26-321010x2">Type a name for the plug-in and click <span
class="cmbx-12">Next</span>
</li>
<li
class="enumerate" id="x26-321012x3">Ensure <span
class="cmbx-12">This plug-in will make contributions to the </span><a
href="mainap3.html#ui"><span
class="cmbx-12">UI</span></a> is selected and click
<span
class="cmbx-12">Next</span>
</li>
<li
class="enumerate" id="x26-321014x4">Select <a
href="mainap3.html#sca"><span
class="cmbx-12">SCA</span></a> <span
class="cmbx-12">Plug-in with </span><a
href="mainli2.html#glo:component"><span
class="cmbx-12">Component</span></a> <span
class="cmbx-12">Control Panel </span><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> Other forms of control panels
include: <a
href="mainap3.html#corba">CORBA</a>, <a
href="mainli2.html#glo:device">Device</a>, and Waveform.</p></div></div>
</li>
<li
class="enumerate" id="x26-321016x5">Select the <a
href="mainli2.html#glo:component">Component</a> to create a control panel, and click <span
class="cmbx-12">Finish</span></li></ol>
<!--l. 43--><p class="noindent" ><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> Control Panels are created within Eclipse plug-in projects. The wizard creates a new plug-in
project, and opens the main plug-in project form editor. This editor is very similar to the <a
href="mainap3.html#sca">SCA</a>
<a
href="mainli2.html#glo:component">Component</a> form editor. There are multiple tabs to control various aspects of the plug-in project.
To learn more about Eclipse development, see Eclipse <a
href="mainap3.html#ui">UI</a> Development References in Appendix
<a
href="mainap1.html#x27-333000A">Chapter A</a>. </p></div></div>
<!--l. 50--><p class="noindent" >Open the new plug-in project and expand the <span
class="cmbx-12">src </span>directory.
<!--l. 52--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.2.2 </span> <a
id="x26-32200024.2.2"></a>Control Panel Files</h4>
<!--l. 53--><p class="noindent" >This section describes the control panel files that are created by the wizard.
<ul class="itemize1">
<li class="itemize"><span
class="cmtt-12">src</span>: This is the Java source directory.
</li>
<li class="itemize"><span
class="cmtt-12">src/*.controlPanels</span>: Contains the main control panel code
</li>
<li class="itemize"><span
class="cmtt-12">SampleComponentControlPanel.java</span>: The main control panel code. The main entry
point is <span
class="cmtt-12">createPartControl</span>; add developer-defined code here.
</li>
<li class="itemize"><span
class="cmtt-12">SampleComponentControlPanelContributor.java</span>: Manages custom actions
associated with the control panel
</li>
<li class="itemize"><span
class="cmtt-12">SampleComponentControlPanelPropertyFilter.java</span>: Dictates when the control
panel will show up in the <a
href="mainli2.html#glo:property"><span
class="cmbx-12">Property</span></a> view
</li>
<li class="itemize"><span
class="cmtt-12">SampleComponentControlPanelPropertySection.java</span>: The <a
href="mainli2.html#glo:property">Property</a> section the
control panel will appear in by default; this opens the editor within the <a
href="mainli2.html#glo:property">Property</a>
section.
</li>
<li class="itemize"><span
class="cmtt-12">icons</span>: Directory to contain graphics
</li>
<li class="itemize"><span
class="cmtt-12">META-INF/MANIFEST.MF</span>: the main Manifest file for the plug-in
</li>
<li class="itemize"><span
class="cmtt-12">build.properties</span>: Used by the plug-in builder when compiling
</li>
<li class="itemize"><span
class="cmtt-12">plugin.xml</span>: The plug-in manifest file, plugin.xml, describes how the plug-in extends
the platform, what extensions it publishes itself, and how it implements its
functionality.</li></ul>
<!--l. 67--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">24.3 </span> <a
id="x26-32300024.3"></a>Programming with SWT and JFace</h3>
<!--l. 68--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.3.1 </span> <a
id="x26-32400024.3.1"></a>SWT</h4>
<!--l. 69--><p class="noindent" >The Standard Widget Toolkit (<a
href="mainap3.html#swt">SWT</a>) is a widget toolkit for Java developers that provides a
portable <a
href="mainap3.html#api">API</a> and tight integration with the underlying native <a
href="mainap3.html#os">OS</a> Graphical User Interface (<a
href="mainap3.html#gui">GUI</a>)
platform.<br
class="newline" /><br
class="newline" /><a
href="mainap3.html#swt">SWT</a> basic building blocks:
<ul class="itemize1">
<li class="itemize"><span
class="cmtt-12">org.eclipse.swt.widgets.Label</span>: A basic label widget
</li>
<li class="itemize"><span
class="cmtt-12">org.eclipse.swt.widgets.Button</span>: A basic button widget can be used with PUSH
or RADIO or CHECK styles
</li>
<li class="itemize"><span
class="cmtt-12">org.eclipse.swt.widgets.Text</span>: An input-text field
</li>
<li class="itemize"><span
class="cmtt-12">org.eclipse.swt.widgets.Composite</span>: The main container widget
</li>
<li class="itemize"><span
class="cmtt-12">org.eclipse.swt.widgets.Group</span>: A container widget with text and a border</li></ul>
<!--l. 78--><p class="noindent" >Some <a
href="mainap3.html#swt">SWT</a> examples can be found at <a
href="http://www.eclipse.org/swt/examples.php" class="url" ><span
class="cmtt-12">http://www.eclipse.org/swt/examples.php</span></a>.
<!--l. 80--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x26-32500024.3.1"></a>Examples</h5>
<!--l. 81--><p class="noindent" >To create a label: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
Label label = new Label(main, SWT.None);
label.setText("Hello World");
]]></script>
<!--l. 87--><p class="noindent" >To create a text field: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
Text text = new Text(main, SWT.BORDER);
text.setText("Initial Input");
]]></script>
<!--l. 93--><p class="noindent" >To use GridLayout and sub groups within the <span
class="cmtt-12">createPartControl </span>method: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
public void createPartControl(final Composite main) {
main.setLayout(new GridLayout(2, false));
GridDataFactory factory =
GridDataFactory.fillDefaults().grab(false, true);
Group controlGroup = new Group(main,SWT.SHADOW_ETCHED_OUT);
controlGroup.setLayoutData(factory.create());
controlGroup.setText("Controls");
createControlGroup(controlGroup);
Group viewerGroup = new Group(main, SWT.SHADOW_ETCHED_OUT);
viewerGroup.setLayoutData(factory.create());
viewerGroup.setText("Plot");
}
]]></script>
<!--l. 111--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.3.2 </span> <a
id="x26-32600024.3.2"></a>JFace</h4>
<!--l. 112--><p class="noindent" >JFace is a <a
href="mainap3.html#ui">UI</a> toolkit that provides helper classes for developing <a
href="mainap3.html#ui">UI</a> features that can be tedious to
implement. JFace operates above the level of a raw widget system. It includes classes for handling
common <a
href="mainap3.html#ui">UI</a> programming tasks:
<ul class="itemize1">
<li class="itemize">Viewers handle the drudgery of populating, sorting, filtering, and updating widgets. <br
class="newline" /><span
class="cmtt-12">org.eclipse.jface.viewers.TableViewer</span>
</li>
<li class="itemize">Actions and contributions introduce semantics for defining user actions and specifying
where to make them available. <br
class="newline" /><span
class="cmtt-12">org.eclipse.jface.action.Action</span>
</li>
<li class="itemize">Image and font registries provide common patterns for handling <a
href="mainap3.html#ui">UI</a> resources. <br
class="newline" /><span
class="cmtt-12">org.eclipse.swt.graphics.Image</span>
</li>
<li class="itemize">Dialogs and wizards define a framework for building complex interactions with the
user. <br
class="newline" /><span
class="cmtt-12">org.eclipse.jface.wizard.Wizard</span>
</li>
<li class="itemize">Field assist provides classes that help guide the user in choosing appropriate content
for fields in dialogs, wizards, or forms.</li></ul>
<!--l. 122--><p class="noindent" >JFace frees a developer up to focus on the implementation of a specific plug-in’s
function, rather than focusing on the underlying widget system or solving problems
that are common in almost any <a
href="mainap3.html#ui">UI</a> application. Some JFace examples can be found at
<a
href="http://wiki.eclipse.org/JFaceSnippets" class="url" ><span
class="cmtt-12">http://wiki.eclipse.org/JFaceSnippets</span></a>.
<!--l. 125--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">24.4 </span> <a
id="x26-32700024.4"></a>Using the SCA Model in a Control Panel</h3>
<!--l. 127--><p class="noindent" >The REDHAWK back-end libraries provide implementations of various <a
href="mainap3.html#sca">SCA</a> interfaces. To
facilitate interaction with the provided REDHAWK interface implementations in conjunction with
various <a
href="mainap3.html#xml">XML</a> configuration files, the REDHAWK <a
href="mainap3.html#ide">IDE</a> utilizes an underlying <a
href="mainli2.html#glo:domain">Domain</a> model: the
<a
href="mainap3.html#sca">SCA</a> Model. The <a
href="mainap3.html#sca">SCA</a> Model uses the Eclipse Modeling Framework (<a
href="mainap3.html#emf">EMF</a>).
<!--l. 131--><p class="noindent" >The control panel is passed, as its input, a reference to an <a
href="mainap3.html#sca">SCA</a> Model object, such as a
<a
href="mainli2.html#glo:component">Component</a>. The control panel should use this model object when interacting with the back-end
system. By using <a
href="mainap3.html#emf">EMF</a> several common operations become easier, such as listening for
changes, displaying modeling objects within a viewer, and connecting model objects to text
fields.
<!--l. 139--><p class="noindent" >There are a few things the control panel developer should be aware of. REDHAWK is a remote
system; therefore, many of the calls within the <a
href="mainap3.html#sca">SCA</a> Model may be blocking and the state within
the model may be stale.
<!--l. 143--><p class="noindent" >There are ways to identify and deal with these aspects:
<ul class="itemize1">
<li class="itemize">Blocking calls: All calls within the <a
href="mainap3.html#sca">SCA</a> Model that are potentially blocking take an
<span
class="cmtt-12">org.eclipse.core.runtime.IProgressMonitor </span>parameter. <div class="admonition block caution block-indent"><div class="caution-inner"><p class="para block block-first"> Never call a potentially
blocking call from the <a
href="mainap3.html#ui">UI</a> thread. This has the potential to DEAD-LOCK the application.</p></div></div>
</li>
<li class="itemize">Stale state: The state of the local model objects is cached. To update this state,
there are several <span
class="cmtt-12">refresh</span>, and <span
class="cmtt-12">fetch* </span>methods. <div class="admonition block caution block-indent"><div class="caution-inner"><p class="para block block-first"> These are also blocking calls.</p></div></div>
</li>
<li class="itemize">Lazy instantiation: The <a
href="mainap3.html#sca">SCA</a> Model is lazy, on purpose. This avoids network traffic and
unnecessary strain on the back-end processing system. Therefore, do not assume the state of
an object has ever been fetched.</li></ul>
<!--l. 150--><p class="noindent" ><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> Once the model is aware of an object, it will try and keep the state of that object up to date
automatically.</p></div></div>
<!--l. 152--><p class="noindent" ><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> Use Eclipse Jobs when calling potentially blocking methods.
<a
href="http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html" class="url" ><span
class="cmtt-12">http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html</span></a>
</p></div></div>
<h4 class="subsectionHead"><span class="titlemark">24.4.1 </span> <a
id="x26-32800024.4.1"></a>Examples</h4>
<!--l. 157--><p class="noindent" >Below is an example of calling a blocking call and refreshing state: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
final ScaComponent component = getInput();
Job job = new Job("Update Job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
// Ensures the properties are fetched and up to
// date upon completion of this method
EList<ScaAbstractProperty<?>> properties =
component.fetchProperties(monitor);
return Status.OK_STATUS;
}
};
job.schedule();
]]></script>
<!--l. 176--><p class="noindent" >Below is an example of using JFace with the <a
href="mainap3.html#sca">SCA</a> Model objects: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
private void createViewer(Composite parent) {
// Set the viewer to use all available space
// within the parent, and some margin.
FillLayout layout = new FillLayout();
layout.marginHeight = 4;
layout.marginWidth = 4;
parent.setLayout(layout);
final ComposedAdapterFactory factory =
new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
factory.addAdapterFactory(
new ScaItemProviderAdapterFactory());
factory.addAdapterFactory(
new ReflectiveItemProviderAdapterFactory());
// Sample Viewer
viewer = new TreeViewer(parent);
viewer.setContentProvider(
new AdapterFactoryContentProvider(factory));
viewer.setLabelProvider(
new AdapterFactoryLabelProvider(factory));
viewer.setInput(getInput());
}
]]></script>
<!--l. 204--><p class="noindent" >Below is an example of using using data bindings. Data bindings have the benefit of keeping a field
in-sync with a back-end resource. It handles all the appropriate listeners and actions
automatically.<br
class="newline" />
<!--l. 207--><p class="noindent" >First add the additional plug-in dependencies:
<ul class="itemize1">
<li class="itemize">org.eclipse.core.databinding
</li>
<li class="itemize">org.eclipse.core.databinding.property
</li>
<li class="itemize">org.eclipse.emf.databinding
</li>
<li class="itemize">org.eclipse.jface.databinding
</li>
<li class="itemize">gov.redhawk.sca.observables</li></ul>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
Text propValue = new Text(main, SWT.BORDER);
EMFDataBindingContext context = new EMFDataBindingContext();
IObservableValue observable =
SCAObservables.observeSimpleProperty(component,
"simplePropId");
context.bindValue(
WidgetProperties.text().observeDelayed(5000, propValue),
observable);
]]></script>
<!--l. 228--><p class="noindent" >Below is an example of how to create a plot. First, add the additional plug-in dependencies:
<ul class="itemize1">
<li class="itemize">gov.redhawk.ui.port.nxmplot</li></ul>
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
final ScaComponent component = getInput();
<!--l. 259--><p class="noindent" >final AbstractNxmPlotWidget plot =
PlotActivator.getDefault().getPlotFactory().createPlotWidget(
main, SWT.None);
plot.addPlotListener(new AbstractPlotWidgetListener(){
@Override
public void click(double x, double y, double t) {
// TODO Handle Click
}
});
Job job = new Job("Plot setup job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
ScaUsesPort out =
(ScaUsesPort) component.getScaPort("bulkioOut");
String sourcePipeId = NxmPlotUtil.addSource(out, plot);
return Status.OK_STATUS;
}
};
job.schedule();
]]></script>
<!--l. 261--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">24.5 </span> <a
id="x26-32900024.5"></a>Testing a Control Panel</h3>
<!--l. 262--><p class="noindent" >At this stage, all the pieces needed to run the new plug-in are now available. Next, the plug-in
needs to be built. If the Eclipse workbench is set up to build automatically, then the new
view class should compile as soon as the new <a
href="mainli2.html#glo:component">Component</a> is saved. If not, then select
the project and choose <span
class="cmbx-12">Project </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Build Project</span>. The class should compile without
error.
<!--l. 269--><p class="noindent" >There are two ways to run a plug-in once it has been built.
<ul class="itemize1">
<li class="itemize">The plug-in’s <a
href="mainap3.html#jar">JAR</a> file can be installed in the eclipse/plugins directory. When the
Workbench is restarted, it will find the new plug-in.
</li>
<li class="itemize">The Plug-in Development Environment (<a
href="mainap3.html#pde">PDE</a>) tool can be used to run another
Workbench from within the current Workbench. This runtime Workbench is handy for
testing new plug-ins from the Workbench immediately as they are developed. For more
information about how a runtime workbench works, check the <a
href="mainap3.html#pde">PDE</a> guide.</li></ul>
<!--l. 279--><p class="noindent" >For simplicity, the plug-in can be run from within the Eclipse Workbench.
<!--l. 281--><p class="noindent" >To launch a runtime Workbench, choose <span
class="cmbx-12">Run </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Run Configurations</span>. This dialog will show all
the different ways to launch a program. Choose <span
class="cmbx-12">Eclipse Application</span>, click <span
class="cmbx-12">New </span>and accept all of
the default settings. This will cause another instance of the Eclipse Workbench, the runtime
Workbench, to start.
<!--l. 287--><p class="noindent" ><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> An <a
href="mainli2.html#glo:application">Application</a> may also be launched from the <span
class="cmbx-12">Overview </span>page of the plug-in manifest editor.
To do so, click <span
class="cmbx-12">Launch an Eclipse Application </span>from within the <span
class="cmbx-12">Testing </span>section. </p></div></div>
<!--l. 291--><p class="noindent" >To access the new panel, connect to a <a
href="mainli2.html#glo:domain">Domain</a> that is running the desired <a
href="mainli2.html#glo:component">Component</a>. Right-click
the <a
href="mainli2.html#glo:component">Component</a>, and in the <span
class="cmbx-12">Open With</span><span
class="cmbx-12">… </span>menu, select the control panel. If the control panel is
registered with the highest priority, then double clicking the <a
href="mainli2.html#glo:component">Component</a> will also open the new
control panel. <div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> This <a
href="mainli2.html#glo:component">Component</a> may be run within the Sandbox in this <a
href="mainap3.html#ide">IDE</a> just like any other
<a
href="mainli2.html#glo:component">Component</a>. </p></div></div>
The control panel may also be debugged by running the Eclipse application within debug mode. To
run in debug mode, select <span
class="cmbx-12">Debug </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Debug Configurations</span>.
<!--l. 299--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">24.6 </span> <a
id="x26-33000024.6"></a>Building and Installing the Control Panel</h3>
<!--l. 301--><p class="noindent" >A control panel project is an Eclipse plug-in. Eclipse plug-ins can either be built into a <a
href="mainap3.html#jar">JAR</a> that
can be dropped-in to the Eclipse environment or be wrapped into an Eclipse feature. Using the
drop-in approach is simpler to implement, while creating a feature, the preferred method, provides
a more user-friendly product through the use of p2 repositories (Explained in <a
href="#x26-33200024.6.2">Section
24.6.2</a>).
<!--l. 305--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.6.1 </span> <a
id="x26-33100024.6.1"></a>Drop-Ins</h4>
<!--l. 306--><p class="noindent" >Creating a drop-in module is accomplished through the following steps:
<ol class="enumerate1" >
<li
class="enumerate" id="x26-331002x1">Export the plug-in. Go to the plug-in manifest editor. On the <span
class="cmbx-12">Overview </span>page, follow
the instructions in the <span
class="cmbx-12">Exporting </span>section. This will produce a <a
href="mainap3.html#jar">JAR</a> file.
</li>
<li
class="enumerate" id="x26-331004x2">Copy this <a
href="mainap3.html#jar">JAR</a> file to the drop-in folder of the target Eclipse / REDHAWK Application.
The Application must be restarted for the control panel to be installed.</li></ol>
<!--l. 313--><p class="noindent" >While by far the easiest approach to implement, creating a drop-in module is not considered the
most correct nor extensible method. Deploying via the drop-in folder can run into problems if all
dependencies are not satisfied. These errors usually occur silently and are difficult to
diagnose.
<!--l. 315--><p class="noindent" >The preferred mechanism for deploying an Eclipse plug-in is via an Eclipse Update site using
p2.
<!--l. 317--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">24.6.2 </span> <a
id="x26-33200024.6.2"></a>p2</h4>
<!--l. 319--><p class="noindent" >p2 is a component of the Equinox project; it provides a provisioning platform for Eclipse-based
applications. Eclipse update sites are essentially p2 repositories.
<!--l. 321--><p class="noindent" >To create an Eclipse update site, a feature must first be created. Features are a way to organize a
set of plug-ins as one installable unit.
<!--l. 323--><p class="noindent" >To create a feature:
<ol class="enumerate1" >
<li
class="enumerate" id="x26-332002x1">Open the <span
class="cmbx-12">New Project Wizard</span>
<ol class="enumerate2" >
<li
class="enumerate" id="x26-332004x1">Click <span
class="cmbx-12">File </span><span
class="cmmi-12">> </span><span
class="cmbx-12">New </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Project</span>
</li>
<li
class="enumerate" id="x26-332006x2">Expand <span
class="cmbx-12">Plug-in Development</span>
</li>
<li
class="enumerate" id="x26-332008x3">Select <span
class="cmbx-12">Feature Project</span></li></ol>
</li>
<li
class="enumerate" id="x26-332010x2">Type a name, Click <span
class="cmbx-12">Finish</span>. A new project will be created and the feature.xml form editor
will open.
</li>
<li
class="enumerate" id="x26-332012x3">Click the <span
class="cmbx-12">Plug-ins </span>tab
</li>
<li
class="enumerate" id="x26-332014x4">Click <span
class="cmbx-12">Add</span>
</li>
<li
class="enumerate" id="x26-332016x5">Type the name of the plug-in into the text field, select it, and then click <span
class="cmbx-12">OK</span>.
</li>
<li
class="enumerate" id="x26-332018x6">Save the file</li></ol>
<!--l. 337--><p class="noindent" ><div class="admonition block tip block-indent"><div class="tip-inner"><p class="para block block-first"> The drop-in folder technique may also be used with features. </p></div></div>
<!--l. 341--><p class="noindent" >To create an update site:
<ol class="enumerate1" >
<li
class="enumerate" id="x26-332020x1">Go to the <span
class="cmbx-12">Overview </span>tab of the feature.xml editor
</li>
<li
class="enumerate" id="x26-332022x2">Within the <span
class="cmbx-12">Publishing </span>section, click <span
class="cmbx-12">Update site project</span>
</li>
<li
class="enumerate" id="x26-332024x3">Follow the directions to create an update site. The update site project will be created
and the site.xml file will be opened.
</li>
<li
class="enumerate" id="x26-332026x4">Add the feature to the site and click <span
class="cmbx-12">Add Feature</span>
</li>
<li
class="enumerate" id="x26-332028x5">Enter the name of the feature and click <span
class="cmbx-12">OK</span>
</li>
<li
class="enumerate" id="x26-332030x6">Click <span
class="cmbx-12">Build</span></li></ol>
<!--l. 350--><p class="noindent" >Clicking <span
class="cmbx-12">Build </span>will run the entire build process (compiling the plug-in, packaging the feature, and
finally deploying it within the update site). A set of new items will appear in the site
project: a <span
class="cmtt-12">feature </span>folder, a <span
class="cmtt-12">plugins </span>folder and two <a
href="mainap3.html#jar">JAR</a> files (<span
class="cmtt-12">artifacts.jar </span>and
<span
class="cmtt-12">content.jar</span>). Copy these to any web-server to make them available as an update site.
Alternatively, these files and directories can be exported as an archive to be distributed
manually.
<!--l. 354--><p class="noindent" >While p2 is much more complicated than the drop-in approach, it provides dependency
resolution while installing the new plug-ins. p2 also allows the user to update plug-ins after
installation.
<!--l. 357--><p class="noindent" >To install a plug-in from a p2 archive:
<ol class="enumerate1" >
<li
class="enumerate" id="x26-332032x1">Click <span
class="cmbx-12">Help </span><span
class="cmmi-12">> </span><span
class="cmbx-12">Install new software</span>
</li>
<li
class="enumerate" id="x26-332034x2">Click <span
class="cmbx-12">Add</span>
</li>
<li
class="enumerate" id="x26-332036x3">Click <span
class="cmbx-12">Archive</span>
</li>
<li
class="enumerate" id="x26-332038x4">Locate the archive on disk and click <span
class="cmbx-12">OK</span>
</li>
<li
class="enumerate" id="x26-332040x5">Select the feature to install. If no features show up, deselect <span
class="cmbx-12">Group items by</span>
<span
class="cmbx-12">category</span>
</li>
<li
class="enumerate" id="x26-332042x6">Click <span
class="cmbx-12">Finish</span></li></ol>
<!--l. 74--><div class="crosslinks"><p class="noindent">[<a
href="mainap1.html" >next</a>] [<a
href="mainch23.html" >prev</a>] [<a
href="mainch23.html#tailmainch23.html" >prev-tail</a>] [<a
href="mainch24.html" >front</a>] [<a
href="main.html#mainch24.html" >up</a>] </p></div>
<!--l. 74--><p class="noindent" ><a
id="tailmainch24.html"></a>
<div class=license>
<hr>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br /><span xmlns:dct="http:// purl.org/dc/terms/" property="dct:title">REDHAWK Documentation</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
</div>
</body></html>