Skip to main content



      Home
Home » Modeling » EMF Parsley » Context menu in SelectionTreeView(How to get Context menu in SelectionTreeView)
Context menu in SelectionTreeView [message #1703761] Tue, 04 August 2015 13:59 Go to next message
Eclipse UserFriend
Have worked to this point with savable TreeViews. Due to the multiple kinds of EMF resources I have for a project I now need to use SelectionTreeView instead.

I see that there are no context menus on the EMF elements visualized in a SelectionTreeView. Is there a way to add the menus?
Re: Context menu in SelectionTreeView [message #1703890 is a reply to message #1703761] Wed, 05 August 2015 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
did you see the "menu" part on the documentation?
https://www.eclipse.org/emf-parsley/documentation.html#par12

We are working on that stuff to simplify the APIs..
They'll be available with the next release (and in the nightly updatesite ASAP).

Cheers.
Francesco
Re: Context menu in SelectionTreeView [message #1703901 is a reply to message #1703890] Wed, 05 August 2015 13:09 Go to previous messageGo to next message
Eclipse UserFriend
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
					])
				]
			}
	}
			
}


Perhaps this is a bug?

thanks
John
Re: Context menu in SelectionTreeView [message #1703979 is a reply to message #1703901] Thu, 06 August 2015 07:10 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Context menu in SelectionTreeView [message #1704217 is a reply to message #1703979] Sat, 08 August 2015 23:57 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Context menu in SelectionTreeView [message #1705467 is a reply to message #1704217] Sun, 16 August 2015 06:31 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Context menu in SelectionTreeView [message #1708616 is a reply to message #1704217] Fri, 18 September 2015 02:52 Go to previous message
Eclipse UserFriend
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
Previous Topic:How to Customize Context Menu to create child that is not a containment *list*?
Next Topic:Use getDisplayName() of PropertyDescriptors to get display names of features
Goto Forum:
  


Current Time: Wed Jul 09 08:28:34 EDT 2025

Powered by FUDForum. Page generated in 0.04597 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top