Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Customizing Context Menu (remove standard features)
Customizing Context Menu (remove standard features) [message #714467] Wed, 10 August 2011 15:08 Go to next message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
Hi,

I just finished the tutorial parts for Context Buttons and Context menus. It is possible to remove standard features of the Context Buttons. (e.g. just by not adding the remove button)
setGenericContextButtons(data, pe, CONTEXT_BUTTON_DELETE |
		CONTEXT_BUTTON_UPDATE);


But i found no way to remove standard features of the context menu, if i dont need them.

How to remove the "Remove" - feature from the context menu?

[Updated on: Wed, 10 August 2011 15:10]

Report message to a moderator

Re: Customizing Context Menu (remove standard features) [message #714653 is a reply to message #714467] Thu, 11 August 2011 07:53 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
Hi,

the standard entries for the context menu (delete, remove and update) will only be shown if a feature is available which fits. Why do you want remove them?

BR
Matthias
Re: Customizing Context Menu (remove standard features) [message #714660 is a reply to message #714653] Thu, 11 August 2011 08:12 Go to previous messageGo to next message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
I don't want the "remove" functionality. For every business object there is exact one graphical representation.
Re: Customizing Context Menu (remove standard features) [message #714664 is a reply to message #714660] Thu, 11 August 2011 08:19 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
Don't provide a remove feature via your feature provider and you will achieve what you want.
Re: Customizing Context Menu (remove standard features) [message #714668 is a reply to message #714664] Thu, 11 August 2011 08:32 Go to previous messageGo to next message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
I tried that yesterday, but the delete feature relies on the remove feature. So i need the remove functionality, but only in combination with delete.
Is there easy (fast) way to do so or do i have to create my own delete feature which does not rely on the remove feature?

[Updated on: Thu, 11 August 2011 08:40]

Report message to a moderator

Re: Customizing Context Menu (remove standard features) [message #720239 is a reply to message #714668] Tue, 30 August 2011 07:51 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The easiest way I can think off solving that would be what Mattias proposed
plus additionally to provide a custom delete feature (deriving from
DefaultDeletefeature) for your object and override preDelete; there you can
create your (or the standard) RemoveFeature manually instead of requesting
it from the feature provider. So you can benefit from reusing the standard
remove functionality without providing the functionality to the user.

Other solutions one could think of go in the direction of the open Bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352113 where a seperation
between user facing and internal features is requested.

HTH,
Michael

Sorry for the late reply, this dropped somehow off the radar and only Hernan
brought it back there...


"buschcobolt" schrieb im Newsbeitrag news:j203f2$k0p$1@news.eclipse.org...

I tried that yesterdays, but the delete feature relies on the remove
feature. So i need the remove functionality, but only in combination with
delete.
Is there easy way to do so or do i have to create my own delete feature
which does not rely on the remove feature?
Re: Customizing Context Menu (remove standard features) [message #720417 is a reply to message #720239] Tue, 30 August 2011 14:41 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
I agree that a separation between "user facing and internal features is requested", or at least some conceptual clarification.

I wasn't confortable with the proposed solution, because I saw that getFeatureProvider().getRemoveFeature()) is called in several places, and I feared that it would return null during some operation inside the Delete operation.

Instead, I did something much simpler and cleaner (though it's still hackish), I provided the Delete feature with an extended feature provider

 public class MyFeatureProvider extends DefaultFeatureProvider {
   ...
   	@Override
	public IRemoveFeature getRemoveFeature(IRemoveContext context) {
		return null; // remove disabled for the UI  
	}
	
	protected IRemoveFeature getRemoveFeatureEnabled(IRemoveContext context) {
		return super.getRemoveFeature(context); // used where we enable remove (deleting...) 
	}

	@Override
	public IDeleteFeature getDeleteFeature(IDeleteContext context) {
		return new MyDeleteFeature(this);
	}
   }

  public class MyFeatureProviderWithRemove extends MyFeatureProvider {

	public MyFeatureProviderWithRemove(IDiagramTypeProvider dtp) {
		super(dtp);
	}

	@Override
	public IRemoveFeature getRemoveFeature(IRemoveContext context) {
		return super.getRemoveFeatureEnabled(context);  
	}	
   }
   
   public class MyDeleteFeature extends DefaultDeleteFeature {

	public MyDeleteFeature(IFeatureProvider fp) {
		super(new MyFeatureProviderWithRemove(fp.getDiagramTypeProvider()));
	}

   }



It seems to work ok.

[Updated on: Tue, 30 August 2011 14:42]

Report message to a moderator

Re: Customizing Context Menu (remove standard features) [message #1015708 is a reply to message #720417] Fri, 01 March 2013 20:50 Go to previous message
Johnny Qin is currently offline Johnny QinFriend
Messages: 40
Registered: April 2012
Member
Here's my solution to not adding "Remove" to context menu. "Delete" is still there, so this fix does meet my needs.

public class MyFeatureProvider extends DefaultFeatureProvider {
...

@Override
    public IRemoveFeature getRemoveFeature(IRemoveContext context) {
        /**
         * return <code>NULL</code> will disable Remove action but at the same time disable Delete action, because delete uses remove.
         */
        return new DefaultRemoveFeature(this) {
            
            /* 
             * (non-Javadoc)
             * @see org.eclipse.graphiti.features.impl.AbstractFeature#isAvailable(org.eclipse.graphiti.features.context.IContext)
             */
            @Override
            public boolean isAvailable(IContext context) {
                return false;
            }
        };
    }
}

[Updated on: Fri, 01 March 2013 20:50]

Report message to a moderator

Previous Topic:Separating domain and pictogram model
Next Topic:Graphiti & Eclipse E4
Goto Forum:
  


Current Time: Sat Apr 20 12:07:53 GMT 2024

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

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

Back to the top