TWiki
>
Public Web
>
DpHipe
>
DpMenusToolbarsDragDrop
(revision 9) (raw view)
Edit
Attach
Tags:
view all tags
<!-- ANALYTICS CODE - DO NOT EDIT --> %INCLUDE{"%ATTACHURL%/GoogleAnalytics.txt" raw="on"}% <!-- END OF ANALYTICS CODE --> <!-- * Set TOPICTITLE = Menus, toolbars, drag and drop --> | *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!* ---+!! Menus, toolbars, drag & drop <!-- Some short-cuts * Set DRMROOT = http://herschel.esac.esa.int/hcss-doc-12.0#hcss_drm: * Set VIEWPART = [[%DRMROOT%herschel.ia.gui.kernel.parts.ViewPart][ViewPart]] * Set EVENTHANDLER = [[%DRMROOT%herschel.ia.gui.kernel.SiteEventHandler][SiteEventHandler]] * Set UTIL = [[%DRMROOT%herschel.ia.gui.kernel.SiteUtil][SiteUtil]] * Set COMMAND = [[%DRMROOT%herschel.ia.gui.kernel.Command][Command]] * Set EXECUTION = [[%DRMROOT%herschel.ia.gui.kernel.event.CommandExecutionRequestEvent][CommandExecutionRequestEvent]] * Set EXECUTED = [[%DRMROOT%herschel.ia.gui.kernel.event.CommandExecutedEvent][CommandExecutedEvent]] * Set CONSOLE = [[%DRMROOT%herschel.ia.jconsole.views.ConsoleView][ConsoleView]] * Set HISTORY = [[%DRMROOT%herschel.ia.jconsole.views.HistoryView][HistoryView]] * Set EVENT = [[%DRMROOT%herschel.ia.gui.kernel.SiteEvent][SiteEvent]] * Set SELECTION_EVENT = [[%DRMROOT%herschel.ia.gui.kernel.SelectionEvent][SelectionEvent]] * Set SELECTION_EVENT = [[%DRMROOT%herschel.ia.gui.kernel.event.SelectionEvent][SelectionEvent]] * Set VARIABLE_CHANGED_EVENT = [[%DRMROOT%herschel.ia.gui.kernel.event.VariablesChangedEvent][VariablesChangedEvent]] * Set EDITOR_COMPONENT = [[%DRMROOT%herschel.ia.gui.kernel.parts.EditorComponent][EditorComponent]] * Set SITE_ACTION = [[%DRMROOT%herschel.ia.gui.kernel.SiteAction][SiteAction]] * Set SITE_ACTION_UTIL = [[%DRMROOT%herschel.ia.gui.kernel.AbstractSiteAction][AbstractSiteAction]] * Set INSERT = [[%DRMROOT%herschel.ia.gui.kernel.menus.Insert][Insert]] * Set EXTENSION = [[%DRMROOT%herschel.ia.gui.kernel.menus.Insert.Extension][Extension]] * Set DND = [[%DRMROOT%herschel.ia.gui.kernel.dnd.DnDSelection][DnDSelection]] * Set VIEWABLE = [[%DRMROOT%herschel.ia.gui.kernel.parts.Viewable][Viewable]] --> %STARTINCLUDE% Menus, toolbars, pop-ups and drag & drop are supported in the HIPE interface and in the View components via the same set of interfaces. %STOPINCLUDE% The main contract is to implement the %SITE_ACTION% interface which has an utility implementation %SITE_ACTION_UTIL% where the only required task is to define the ==actionPerformed== method: <pre> clear = new AbstractSiteAction(SiteAction.Style.AS_PUSH, CLEAR_ACTION, "Clear", IconLibrary.DELETE) { @Override public void actionPerformed(ActionEvent e) { _button.setText("Cleared"); } }; </pre> Once the action is defined it is possible to associate it to a visible entry. HIPE comes with a predefined set of entries which are commonplaces for standard look and feel and similar operations. This insertion points are available via the %INSERT% class which enumerates the allowed %EXTENSION% values. <pre> actions.insert(new Insert(Insert.Scheme.TOOLBAR, ID, Insert.Extension.RUN_ADDON), clear); </pre> This code associates the clear action to an entry in the toolbar. More specialized examples are provided in the later paragraphs. ---++ Menus HIPE supports the development of menus in two areas: * Main menu * View menu Once the action responsible for performing the code is defined, associating it with the predefined set of menus, toolbars and pop-ups just requires to get the handle to the right entity. Each View has at its disposal an area for adding menu entries based on the general contract of the HIPE menu items. It is possible to access the HIPE menu associated to each View via the !ViewPart received at initialization time (method ==init== of the %VIEWABLE% contract for View). <pre> clear = // AS BEFORE ActionBars viewMenu = getPart().getActionBars(ID); viewMenu.insert(new Insert(MENU, ID, RUN_ADDON), clear); </pre> As for the main menu, _only the Editor area is allowed to redefine it_. Nevertheless its internal behaviour is identical to the View one and it is described here for completeness. The main menu entries are accessible via =herschel.ia.gui.kernel.menus.Insert.MAIN=, which provides the handle to the identifier used for the main toolbar and menus. Adding a new entry to the main menu: <pre> ActionBars mainMenu = getPart().getActionBars(MAIN); mainMenu.insert(new Insert(MENU, MAIN, RUN_ADDON),run); </pre> Retargeting the default entries: <pre> mainMenu.retarget(Retarget.COPY, copy); mainMenu.retarget(Retarget.SAVE, save); </pre> ---++ Toolbars Developing entries for the toolbar is identical to menu development. Only the Insert specification is different <pre> clear = // AS BEFORE ActionBars menus = getPart().getActionBars(ID); menus.insert(new Insert(TOOLBAR, ID, RUN_ADDON), clear); </pre> Adding entries to the main toolbar is just as easy: <pre> clear = // AS BEFORE ActionBars menus = getPart().getActionBars(MAIN); menus.insert(new Insert(TOOLBAR, ID, RUN_ADDON), clear); </pre> Note that these instructions assume that the action belongs to a View, so that you can use the ViewPart of the View to access the ActionBars. If an action is not associated to any View, then you should introduce an ActionMaker for the action. For an example, see =herschel.ia.gui.apps.views.status.StopActionMaker=. ---++ Pop-up menus Again, support for pop up menus is just as easy: <pre> clear = // AS BEFORE ActionBars menus = getPart().getActionBars(ID); menus.insert(new Insert(POPUP, ID, RUN_ADDON), clear); </pre> An extra action is required to make your displayed compoment aware of the pop-up: <pre> this.addMouseListener(getPart().getMouseListener()); </pre> </blockquote> ---++ Drag & drop HIPE supports drag & drop of selections. A component that wants to enable it must implement the %DND% interface and register itself: <pre> SelectionTransferHandler.register(this); // this is the Component being built </pre> The selection type returned by =getSelectionType()= specifies the kind of selections that can be handled: variables, files... <!-- * 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/>
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r10
<
r9
<
r8
<
r7
<
r6
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r9 - 2013-10-18
-
JaimeSaiz
Public
Log In
Public Web
Create New Topic
Index
Search
Changes
Notifications
Statistics
Preferences
Webs
Public
TWiki