TWiki
>
Public Web
>
DpHipe
>
DpHipeViews
(2014-02-18,
AlvarGarcia
)
(raw view)
E
dit
A
ttach
Tags:
create new tag
view all tags
<!-- ANALYTICS CODE - DO NOT EDIT --> %INCLUDE{"%ATTACHURL%/GoogleAnalytics.txt" raw="on"}% <!-- END OF ANALYTICS CODE --> <!-- * Set TOPICTITLE = Creating a view --> | *PDF Version* | [[%SCRIPTURLPATH%/genpdf%SCRIPTSUFFIX%/%WEB%/%TOPIC%?pdforientation=portrait&pdftoclevels=2][Portrait]] | [[%SCRIPTURLPATH%/genpdf%SCRIPTSUFFIX%/%WEB%/%TOPIC%?pdforientation=landscape&pdftoclevels=2][Landscape]] | %ICON{"help"}% *Did you spot something wrong or missing on this page? If you have an account on this TWiki, you can fix it yourself by editing the page. If you don't have an account, you can leave a message at the bottom of the page to tell us about it. Thank you in advance!* ---+ !!Creating a view %STARTINCLUDE% <!-- summary --> You can develop new views and add them to the work-bench of [[DpHipe][HIPE]]. This section briefly explains how to do this. %STOPINCLUDE% %TOC% %STARTSECTION{"contrGuide"}% <br clear="all"/> <!-- Some short-cuts * Set DRMROOT = http://herschel.esac.esa.int/hcss-doc-12.0/index.jsp#hcss_drm: * Set VIEWABLE = Viewable * Set VIEWPART = ViewPart * Set REGISTRY = [[DpHipeRegistry][Extension Registry]] * Set INIT_PY = __init__.py * Set SELISTENER = SiteEventListener --> ---++ Basic steps <blockquote> <img src="%ATTACHURLPATH%/hipe-menu-view.png" align="RIGHT" alt="HIPE View menu" width='551' height='359' /> The aim is that your contribution is automatically picked up by the [[DpHipeOverview][infrastructure]], such that your view is added to the view menu, as shown in the picture on the right. To make this happen, you will have to: * Implement the [[%DRMROOT%herschel.ia.gui.kernel.parts.Viewable][%VIEWABLE%]] interface by sub-classing any [[http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html][JComponent (Java 6)]] implementation for HIPE 11 or older and [[http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html][JComponent (Java 7)]] for HIPE 12 or newer. * Register your implementation to the %REGISTRY% in the %INIT_PY% file of your sub-system. The [[%DRMROOT%herschel.ia.gui.kernel.parts.Viewable][%VIEWABLE%]] interface is a light-weight interface that provides the contents of a View. Your implementation should take the following into account: * The implementation must be an extension of a swing component * The implementation requires a default, but light-weight constructor. Actual construction of a popup menu, a view menu, or a tool bar or contributions to the main tool bar or main menu (or combinations of them) should be done in the ==init(%VIEWPART% part)== method. * In principle only one instance of a view should exist. * The ID returned by your implementation must be unique </blockquote> ---++ Example <blockquote> ---+++ Implementation <blockquote> <pre> public class MyView extends SomeSwingComponent implements Viewable { private ViewPart _part; // Viewable implementation public MyView() {} public void dispose() {} public Icon getIcon() { return getPart().getIcon(); } public String getId() { return getPart().getId(); } public String getTitle() { return getPart().getTitle(); } public void init(ViewPart part) { _part = part; makeActions(); } public ViewPart getPart() { return _part; } private void makeActions() { // create tool bars, menus and other stuff } } </pre> </blockquote> ---+++ Registry <blockquote> The following snippet registers the above view within your package's %INIT_PY%: <pre> REGISTRY.register(VIEWABLE, Extension( "site.view.myview", "resides.in.java.package.MyView", "My View", "resides/in/java/package/myview.gif")) </pre> See also the %REGISTRY% documentation for more details. </blockquote> </blockquote> </pre> ---++ Adding features <blockquote> ---+++ Triggering events <blockquote> Your viewable may want to trigger site events which might be interesting to other views. The [[%DRMROOT%herschel.ia.gui.kernel.parts.ViewPart][%VIEWPART%]] interface that is passed on through the ==init== method gives you the means of triggering site events: <pre> private void someMethod() { : getPart().getEventHandler().trigger(aSiteEvent) : } </pre> </blockquote> ---+++ Receiving events <blockquote> Your viewable may want to listen to site events produced by other views. For that you have to implement the [[%DRMROOT%herschel.ia.gui.kernel.SiteEventListener][%SELISTENER%]] interface and inform the event handler that you are interested in one or more event types, for instance: <pre> public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener { public void init(ViewPart part) { : part.getEventHandler().addEventListener(SelectionEvent.class, this); : } public void selectionChanged(SiteEvent event) { // we *know* that we only receive a SelectionEvent, so: SelectionEvent selection = (SelectionEvent)event; : } } </pre> </blockquote> <!-- - - - + + + Menus, toolbars and other features <blockquote> You can learn about adding actions to your view, and more, following [[Hcss.DpHipeWorkshop200807#General_features_and_utilities][this link]]. </blockquote> --> </blockquote> %ENDSECTION{"contrGuide"}% <!-- Author: Main.JorgoBakker --> <!-- * Set ALLOWTOPICCHANGE = Main.RegisteredUsersGroup, Main.TWikiAdminGroup --> <hr/> <!-- COMMENT BOX CODE - DO NOT EDIT --> <div id="disqus_thread"></div> <script type="text/javascript"> var disqus_shortname = 'herscheltwiki'; // required: replace example with your forum shortname (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a> <!-- END OF COMMENT BOX CODE --> <hr/>
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r19
<
r18
<
r17
<
r16
<
r15
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r19 - 2014-02-18
-
AlvarGarcia
Public
Log In
Public Web
Create New Topic
Index
Search
Changes
Notifications
Statistics
Preferences
Webs
Public
TWiki