Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Help with using ChangePropertyValueRequest
Help with using ChangePropertyValueRequest [message #550541] Fri, 30 July 2010 18:01
Charles Chiasson is currently offline Charles ChiassonFriend
Messages: 1
Registered: May 2010
Junior Member
Hi,

I am currently working on a project that requires that I load a diagram and display this diagram into a read-only View. I've accomplished this with a DiagramGraphicalViewer. This part works fine.

My next objective is to programmatically modify certain properties on nodes of this diagram such as line color, line width, etc... I have accomplished this with the code below (as desbribed http://wiki.eclipse.org/GMF_Newsgroup_Q_and_A#How_do_I_chang e_the_color_of_a_line_using_an_action.3F )

@SuppressWarnings("restriction")
	public void changeEditPartColor(GraphicalEditPart editPart, Color color) {

		ChangePropertyValueRequest req;

		req = new ChangePropertyValueRequest(StringStatics.BLANK,
				Properties.ID_LINECOLOR, FigureUtilities.colorToInteger(color));

		final Command cmd = (Command) editPart.getCommand(req);

		AbstractEMFOperation operation = new AbstractEMFOperation(
				((IGraphicalEditPart) editPart).getEditingDomain(),
				StringStatics.BLANK, null) {
			protected IStatus doExecute(IProgressMonitor monitor,
					IAdaptable info) {
				cmd.execute();
				return Status.OK_STATUS;
			}

		};

		try {
			operation.execute(new NullProgressMonitor(), null);
		} catch (org.eclipse.core.commands.ExecutionException e) {

			e.printStackTrace();
		}

	}


This also works.

My first question is:
Is this the correct way to do so? I noticed that using org.eclipse.gmf.runtime.diagram.ui.internal.properties.Prope rties gives me a "restriction" warning telling me that Properties is not meant to be accessible. Intuitively it seems as thought I should refrain from using this. Can anyone correct me on why I'm wrong with this. If I do use it, what are the long term implications on the stability of my software (will it's implementation change, etc.)?

My second question is:
Where can I find details on how to set the property values? For example, if I want to create a ChangePropertyValueRequest for Properties.ID_LINE_WIDTH, how do I know at what values to set these? I've tried a few random int values and it doesnt seem to be doing anything. Or should I be using a different technique all together to accomplish these property changes?

Any hints are appreciated,
Charles
Previous Topic:Add link (contained by canvas element) between two nodes not contained by canvas element
Next Topic:Ecore Model of Graphical Definition Model
Goto Forum:
  


Current Time: Fri May 24 23:00:03 GMT 2024

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

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

Back to the top