Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Shortcuts to read-only models
Shortcuts to read-only models [message #660991] Tue, 22 March 2011 15:36 Go to next message
Christian  is currently offline Christian Friend
Messages: 14
Registered: February 2011
Junior Member
Hi!

I want to make selected models read-only.
Let's say I created 2 models <modelBase.mindmap> and <modelsub.mindmap> in my editor. modelBase holds a few classes e.g. classBase.
In modelSub.mindmap I create a new class classSub which inherits from a shortcut to classBase in modelBase.mindmap.

Now I don't want classes from modelBase to be editable.

I tried setting the file modelBase.mindmap to read-only via the OS. But when I try to save my modelSub.mindmap_dia it says "File modelBase.mindmap is read-only. Do you want the make it writeable?". Obviously not. But after clicking <No> the whole modelSub.mindmap_dia diagram is suddenly read.only.
I suspect this is beacause i have the shortcut to classBase on my diagram and GMF isn't smart enough to make only that specific class object read-only..

Do you have any idea how i could tackle this issue?

Maybe via EMFs "editable" attribute? The problem with this is that I dont want all models to be non-editable but only specific instances.

Cheers,
Christian

[Updated on: Tue, 22 March 2011 19:37]

Report message to a moderator

Re: Read-only models [message #661012 is a reply to message #660991] Tue, 22 March 2011 17:19 Go to previous messageGo to next message
Romain Bioteau is currently offline Romain BioteauFriend
Messages: 65
Registered: August 2009
Location: Grenoble
Member
Hi,
here is a piece of code we are using in our soft :
public void setReadOnly(boolean readOnly) {
		IResource resource = getResource();
		if(resource != null && resource.exists()){
			ResourceAttributes resourceAttributes = resource.getResourceAttributes();
			resourceAttributes.setReadOnly(readOnly);
			try {
				resource.setResourceAttributes(resourceAttributes);
			} catch (CoreException e) {
				BonitaStudioLog.log(e);
			}
		}
	}


HTH
Romain


R&D Engineer at BonitaSoft
Re: Read-only models [message #661031 is a reply to message #660991] Tue, 22 March 2011 19:35 Go to previous messageGo to next message
Christian  is currently offline Christian Friend
Messages: 14
Registered: February 2011
Junior Member
Thanks for the reply!

I implemented your code example but unfortunately doing that has the same effect as setting the file to itself to read-only (via the OS e.g. Windows Explorer).


The moment I include shortcuts to a read-only/non-editable model on my GMF diagram, i can't edit the whole diagram anymore after saving.
When a close & open the diagram, it is editable again (until the next save).

Is this a GMF bug, or am i missing something?
Re: Read-only models [message #667302 is a reply to message #661031] Wed, 27 April 2011 22:27 Go to previous messageGo to next message
Christian  is currently offline Christian Friend
Messages: 14
Registered: February 2011
Junior Member
Hi there!

I'm still having troubles with this issue.

Let's say that i made two models A and B with their respective diagrams A_dia and B_dia in my custom editor.

Model A is set to be read-only.
Diagram B_dia has a shortcut to an element from model A.

When i open B_dia i expect the shortcut element to be read-only while the other elements on the diagram should be still editable.

When i open B_dia its elements are editable. Unfortunately, whenever i try to edit the shortcut element on B_dia (or even if i just try to save B_dia) i get a message "File is set to read-only. Do you want to make it writeable?"
When i click "No", suddenly the whole B_dia is read-only! Not only the shortcut element, but all elements on the diagram.

When i close and reopen the diagram, the elements (except the shortcut) are editable again.

What can i do to fix this problem?
Is this a GMF bug?

For compatibility reasons i use GMF 2.2.2.

Help would be appreciated!
Thanks
Re: Shortcuts to read-only models [message #667525 is a reply to message #660991] Fri, 29 April 2011 11:27 Go to previous message
Christian  is currently offline Christian Friend
Messages: 14
Registered: February 2011
Junior Member
This seems to be a bug in the gmf framework.

I built a small new project on GMF 2.3.0 and i have the same exact behaviour.

I suppose the save method checks whether or not there is a read-only element on the diagram, and if yes, the whole diagram is set to be read-only.
Note that i can still change an elements' properties via the properties view. And after reopening the diagram, the elements are writeable again.

Does anybody have an idea where i should start looking for a fix? Where in the frameworks' code can i find the save methods - specifically the check whether there is a read-only object?
Previous Topic:AbstractViewProvider.getCreationMethod getting the wrong method when creating a Diagram
Next Topic:Validation failed unexpectedly: java.lang.ArrayStoreException
Goto Forum:
  


Current Time: Wed Apr 24 18:07:25 GMT 2024

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

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

Back to the top