Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Making a Node not resizable
Making a Node not resizable [message #653644] Thu, 10 February 2011 14:19 Go to next message
Giovanni De Sossi is currently offline Giovanni De SossiFriend
Messages: 161
Registered: October 2009
Location: Rome, Italy
Senior Member

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 16:13 Go to previous messageGo to next message
Giovanni De Sossi is currently offline Giovanni De SossiFriend
Messages: 161
Registered: October 2009
Location: Rome, Italy
Senior Member

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 15:02 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
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 15:16 Go to previous messageGo to next message
Giovanni De Sossi is currently offline Giovanni De SossiFriend
Messages: 161
Registered: October 2009
Location: Rome, Italy
Senior Member

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 15:29 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
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 15:42 Go to previous messageGo to next message
Giovanni De Sossi is currently offline Giovanni De SossiFriend
Messages: 161
Registered: October 2009
Location: Rome, Italy
Senior Member

Really better, thanks.

Bye,
Giovanni.
Re: Making a Node not resizable [message #655392 is a reply to message #654215] Sun, 20 February 2011 14:12 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
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 14:12]

Report message to a moderator

Re: Making a Node not resizable [message #1075375 is a reply to message #655392] Mon, 29 July 2013 10:17 Go to previous message
Susinda Perera is currently offline Susinda PereraFriend
Messages: 5
Registered: July 2013
Junior Member
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: Tue Nov 25 22:22:09 GMT 2014

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

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