Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Making a Node not resizable
Making a Node not resizable [message #653644] Thu, 10 February 2011 09:19 Go to next message
Eclipse UserFriend
Hi,

I have a GMF-based graphical editor in my RCP application, which displays some figures and connectors: for my needs, I have to forbid the resizing of figures...anybody knows how can I reach this goal?

Thanx,
Giovanni
Re: Making a Node not resizable [message #653671 is a reply to message #653644] Thu, 10 February 2011 11:13 Go to previous messageGo to next message
Eclipse UserFriend
I found a solution by myself: I installed a new ComponentEditPolicy in my editPart, with the following lines:

if (RequestConstants.REQ_RESIZE.equals(request.getType())) {
return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;



Maybe this can help,

Regards
Giovanni
Re: Making a Node not resizable [message #654200 is a reply to message #653671] Mon, 14 February 2011 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I have the following code based on your experiences:

installEditPolicy(ComponentEditPolicy.REQ_RESIZE, new ComponentEditPolicy(){
  @Override
  public Command getCommand(Request request) {
    if (RequestConstants.REQ_RESIZE.equals(request.getType())) 
      return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;

     return super.getCommand(request);
  }
});


But this does not hide the resize handles, when the edit part is selected. Any idea on how to remove those?

Thanks!

Ralph
Re: Making a Node not resizable [message #654206 is a reply to message #654200] Mon, 14 February 2011 10:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ralph,

the most rapid way to suite your needs is working at "Preference" level:
in your DiagramGeneralPreferencePage.class you add the following:

/**
* Override default values for popup and connection handles
* @param preferenceStore
*/
public static void overrideDefaultValues(IPreferenceStore preferenceStore) {
preferenceStore.setDefault(IPreferenceConstants.PREF_SHOW_CO NNECTION_HANDLES, false);
preferenceStore.setDefault(IPreferenceConstants.PREF_SHOW_PO PUP_BARS, false);
}

and, in your DiagramPreferenceInitializer.class, you call it:

/**
* @generated NOT
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = getPreferenceStore();
DiagramGeneralPreferencePage.initDefaults(store);
/**
* Eliminate popup and connection handles
*/
DiagramGeneralPreferencePage.overrideDefaultValues(store);
DiagramAppearancePreferencePage.initDefaults(store);
DiagramConnectionsPreferencePage.initDefaults(store);
DiagramPrintingPreferencePage.initDefaults(store);
DiagramRulersAndGridPreferencePage.initDefaults(store);

}


Hope this helps, bye

Giovanni
Re: Making a Node not resizable [message #654211 is a reply to message #654206] Mon, 14 February 2011 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I will try your solutions. A few seconds ago I found the posibilty to override this method in the edit part

@Override
public EditPolicy getPrimaryDragEditPolicy() {
  return new NonResizableEditPolicyEx(); 
}


Ralph
Re: Making a Node not resizable [message #654215 is a reply to message #654211] Mon, 14 February 2011 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Really better, thanks.

Bye,
Giovanni.
Re: Making a Node not resizable [message #655392 is a reply to message #654215] Sun, 20 February 2011 09:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you might also try this.

Switch of resizing:

removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicyEx());


Switch on resizing:

removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy());


Ralph

[Updated on: Sun, 20 February 2011 09:12] by Moderator

Re: Making a Node not resizable [message #1075375 is a reply to message #655392] Mon, 29 July 2013 06:17 Go to previous message
Eclipse UserFriend
Hi all
I' have a similar problem. I want to hide all the resize/vertices point from the node when it is selected (by mouse click),, but shape should be able to move.
As an example i want to remove all 8 rectangular shape handlers in "A Topic" shape in following figure

http://wiki.eclipse.org/Image:Basic_mindmap.png


installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicyEx()); was worked fine and was able to remove the resize handlers in East, West, North and South directions.
But how to remove corner points of the shape. Is this possible? Any idea




Previous Topic:How to draw the edge using the relative points and anchor information available in the .notation
Next Topic:Unresolved dependency on org.eclipse.gmf.tooling.runtime
Goto Forum:
  


Current Time: Wed Jul 23 16:14:22 EDT 2025

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

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

Back to the top