Home » Modeling » EMF Parsley » Context menu in SelectionTreeView(How to get Context menu in SelectionTreeView)
| | |
Re: Context menu in SelectionTreeView [message #1703979 is a reply to message #1703901] |
Thu, 06 August 2015 11:10   |
|
On 05/08/2015 19:09, John Conlon wrote:
> Hi Francesco,
>
> Yes, I am familiar with that part of the documentation.
> I have to this point worked with both the DSL and the non-DSL types of
> projects and have done a lot of menu customization. I tried to do the
> same things to customize menus in non-DSL SelectionTreeView and
> SelectionTreeForm based Parsley projects but could not get any
> ContextMenus to show.
> I even tried creating a simple DSL based Parsley project that uses a
> SelectionTreeView but could not get it to show any ContextMenus either.
> Here is my Parsley DSL from this project:
>
>
> import
> com.verticon.parsley.selectionTreeViewTest.SelectionTreeViewTestOnSelectionTreeView
>
> import com.verticon.im.Location
>
> /* com.verticon.parsley.selectionTreeViewTest Emf Parsley Dsl Module
> file */
> module com.verticon.parsley.selectionTreeViewTest {
>
> parts {
> viewpart com.verticon.parsley.selectionTreeViewTest {
> viewname "SelectionTreeViewTest"
> viewclass SelectionTreeViewTestOnSelectionTreeView
> }
> }
> menuBuilder{
> menus{
> Location-> #[
> submenu("Edit",#[
> actionCopy,
> actionCut,
> separator,
> actionPaste
> ])
> ]
> }
> }
>
> }
>
Hi John
Francesco was referring to the section "Contextual Menu" not to the
"Menu Builder"; the custom menu builder you implemented is fine, but in
Parsley we automatically set context menus only on viewers inside a
"saveable view", not the ones inside "on selection views"; this is
because saveable views act on a resource and are meant to be editable,
while on selection views are usually used in read-only mode (at least,
we found this default behavior sensible :)
If you want the context menu on a viewer (inside any view that is not a
saveable one), you need to setup it yourself with the Java lines
documented in the section "Contextual Menu"; you also need to override
menuAboutToShow; you may want to have a look at
http://git.eclipse.org/c/emf-parsley/org.eclipse.emf-parsley.git/tree/plugins/org.eclipse.emf.parsley.views.common/src/org/eclipse/emf/parsley/views/AbstractSaveableViewerView.java
which is how we setup the context menu on saveable views.
As Francesco said, we're working on making this API much easier to use
and it should only take fewer lines to have a context menu on a viewer
(even without menuAboutToShow).
Please let us know if this fixes your problem.
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| |
Re: Context menu in SelectionTreeView [message #1705467 is a reply to message #1704217] |
Sun, 16 August 2015 10:31   |
|
On 09/08/2015 05:57, John Conlon wrote:
> Hi Lorenzo,
>
> Finally got it to work with:
>
>
> @Override
> public void menuAboutToShow(IMenuManager menuManager) {
> actionBarContributor.setActivePart(this);
> actionBarContributor.menuAboutToShow(menuManager);
> treeActionBarContributor.menuAboutToShow(menuManager);
> }
>
> @Override
> public void createPartControl(Composite parent) {
> super.createPartControl(parent);
>
> AdapterFactoryEditingDomain editingDomain =
> (AdapterFactoryEditingDomain) editingDomainProvider.get();
> treeActionBarContributor.initialize(editingDomain);
> viewerInitializer.addContextMenu(getViewer(),
> treeActionBarContributor, editingDomain, this);
> getViewer().addSelectionChangedListener(treeActionBarContributor);
>
> viewerInitializer.addMouseListener(getViewer());
>
> makeActions();
> contributeToActionBars();
> }
>
>
> thanks for the help,
> John
Great! :)
please, keep an eye on
https://bugs.eclipse.org/bugs/show_bug.cgi?id=455727 which should
simplify the overall process.
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: Context menu in SelectionTreeView [message #1708616 is a reply to message #1704217] |
Fri, 18 September 2015 06:52  |
|
On 09/08/2015 05:57, John Conlon wrote:
> Hi Lorenzo,
>
> Finally got it to work with:
>
>
> @Override
> public void menuAboutToShow(IMenuManager menuManager) {
> actionBarContributor.setActivePart(this);
> actionBarContributor.menuAboutToShow(menuManager);
> treeActionBarContributor.menuAboutToShow(menuManager);
> }
>
> @Override
> public void createPartControl(Composite parent) {
> super.createPartControl(parent);
>
> AdapterFactoryEditingDomain editingDomain =
> (AdapterFactoryEditingDomain) editingDomainProvider.get();
> treeActionBarContributor.initialize(editingDomain);
> viewerInitializer.addContextMenu(getViewer(),
> treeActionBarContributor, editingDomain, this);
> getViewer().addSelectionChangedListener(treeActionBarContributor);
>
> viewerInitializer.addMouseListener(getViewer());
>
> makeActions();
> contributeToActionBars();
> }
>
>
> thanks for the help,
> John
Hi
Please have a look at the new release 0.5.0 which is already available,
and at the updated documentation (and migration guide). The procedure
is much simpler now :)
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Goto Forum:
Current Time: Sat Dec 09 18:27:58 GMT 2023
Powered by FUDForum. Page generated in 0.02812 seconds
|