Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re: Opening an editor with focus on an element
Re: Opening an editor with focus on an element [message #2161] Tue, 01 August 2006 09:08 Go to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090208090300080300030307
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kannan,

Have a look at how the gotoMarker method selects the object referenced
by a marker using setSelectionToViewer:

public void gotoMarker(IMarker marker)
{
try
{
if (marker.getType().equals(EValidator.MARKER))
{
String uriAttribute =
marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null)
{
URI uri = URI.createURI(uriAttribute);
EObject eObject =
editingDomain.getResourceSet().getEObject(uri, true);
if (eObject != null)
{

setSelectionToViewer(Collections.singleton(editingDomain.get Wrapper(eObject)));
}
}
}
}
catch (CoreException exception)
{
LibraryEditorPlugin.INSTANCE.log(exception);
}
}

The other part of your question seems better for the GMF newsgroup.


Kannan Ekanath wrote:
> Hi,
> I am using GMF with EMF. My user is typically expected to create a
> skeleton structure using GMF. My diagram is quite complicated with
> xmls running until 7-10 levels. Hence modelling all of them using GMF
> can be quite messy.
>
> Hence we support graphical models with links upto 2-3 levels, and
> other levels are supposed to be edited using EMF (editor code). So in
> GMF when i right click an element i must be able to say "Open this
> item in EMF editor" and it must open the EMF editor code with the
> *focus set on that particular item.*
>
> a) Opening EMF editor is fine, but can some one tell me how to focus
> one particular element in EMF editor? By default all nodes are
> collapsed in the EMF editor view?
>
> b) In addition to the above has someone done say 6-7 levels of
> modelling in GMF(like a compartment inside a compartment etc), i am
> sure it will get messy, What are the typical approaches you would
> advice/take for this?
>
> Regards,
> Kannan


--------------090208090300080300030307
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Kannan,<br>
<br>
Have a look at how the gotoMarker method selects the object referenced
by a marker using setSelectionToViewer:<br>
<blockquote><small>&nbsp; public void gotoMarker(IMarker marker)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; try<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (marker.getType().equals(EValidator.MARKER))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; String uriAttribute =
marker.getAttribute(EValidator.URI_ATTRIBUTE, null);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (uriAttribute != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; URI uri = URI.createURI(uriAttribute);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EObject eObject =
editingDomain.getResourceSet().getEObject(uri, true);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (eObject != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
setSelectionToViewer(Collections.singleton(editingDomain.get Wrapper(eObject))); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; catch (CoreException exception)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LibraryEditorPlugin.INSTANCE.log(exception);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp; }</small><br>
</blockquote>
The other part of your question seems better for the GMF newsgroup.<br>
<br>
<br>
Kannan Ekanath wrote:
<blockquote cite="mideangkb$vpn$1@utils.eclipse.org" type="cite">Hi,
<br>
I am using GMF with EMF. My user is typically expected to create a
skeleton structure using GMF. My diagram is quite complicated with xmls
running until 7-10 levels. Hence modelling all of them using GMF can be
quite messy.
<br>
<br>
Hence we support graphical models with links upto 2-3 levels, and other
levels are supposed to be edited using EMF (editor code). So in GMF
when i right click an element i must be able to say "Open this item in
EMF editor" and it must open the EMF editor code with the *focus set on
that particular item.*
<br>
<br>
a) Opening EMF editor is fine, but can some one tell me how to focus
one particular element in EMF editor? By default all nodes are
collapsed in the EMF editor view?
<br>
<br>
b) In addition to the above has someone done say 6-7 levels of
modelling in GMF(like a compartment inside a compartment etc), i am
sure it will get messy, What are the typical approaches you would
advice/take for this?
<br>
<br>
Regards,
<br>
Kannan
<br>
</blockquote>
<br>
</body>
</html>

--------------090208090300080300030307--
Re: Opening an editor with focus on an element [message #2374 is a reply to message #2161] Wed, 02 August 2006 00:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

Ed,
I called the setSelectionToViewer API, it opens the editor but the focus
is still not set on that element, my EditCommand looks like this,

EObject object; //the object on which the focus has to be set.

protected CommandResult doExecuteWithResult(IProgressMonitor
progressMonitor, IAdaptable info) throws ExecutionException {
IFile file = getEMFStudioFile();
StudioEditor studioEditor = (StudioEditor) provider.openEditor(new
FileEditorInput(file));
Object wrapper =
((AdapterFactoryEditingDomain)(studioEditor.getEditingDomain ())).getWrapper(object);
studioEditor.setSelectionToViewer( Collections.singleton(wrapper));
return CommandResult.newOKCommandResult();
}

Here am opening the EMF file in the editor, and am trying to focus on
the "object" which is member variable of Command. However
setSelectionToViewer doesnt seem to have intended effect. I tried to
debug through the code, which goes into jface methods like
updateSelection() etc, no error logs are generated or exceptions in
console. Am I missing something?

Is it some deferred effect like when i called provider.openEditor the
editor was already opened and setting selection wont have any effect on
the editor?

Regards,
Kannan

Ed Merks wrote:
> Kannan,
>
> Have a look at how the gotoMarker method selects the object referenced
> by a marker using setSelectionToViewer:
>
> public void gotoMarker(IMarker marker)
> {
> try
> {
> if (marker.getType().equals(EValidator.MARKER))
> {
> String uriAttribute =
> marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
> if (uriAttribute != null)
> {
> URI uri = URI.createURI(uriAttribute);
> EObject eObject =
> editingDomain.getResourceSet().getEObject(uri, true);
> if (eObject != null)
> {
>
> setSelectionToViewer(Collections.singleton(editingDomain.get Wrapper(eObject)));
> }
> }
> }
> }
> catch (CoreException exception)
> {
> LibraryEditorPlugin.INSTANCE.log(exception);
> }
> }
>
> The other part of your question seems better for the GMF newsgroup.
>
>
> Kannan Ekanath wrote:
>> Hi,
>> I am using GMF with EMF. My user is typically expected to create a
>> skeleton structure using GMF. My diagram is quite complicated with
>> xmls running until 7-10 levels. Hence modelling all of them using GMF
>> can be quite messy.
>>
>> Hence we support graphical models with links upto 2-3 levels, and
>> other levels are supposed to be edited using EMF (editor code). So in
>> GMF when i right click an element i must be able to say "Open this
>> item in EMF editor" and it must open the EMF editor code with the
>> *focus set on that particular item.*
>>
>> a) Opening EMF editor is fine, but can some one tell me how to focus
>> one particular element in EMF editor? By default all nodes are
>> collapsed in the EMF editor view?
>>
>> b) In addition to the above has someone done say 6-7 levels of
>> modelling in GMF(like a compartment inside a compartment etc), i am
>> sure it will get messy, What are the typical approaches you would
>> advice/take for this?
>>
>> Regards,
>> Kannan
>
Re: Opening an editor with focus on an element [message #2469 is a reply to message #2374] Wed, 02 August 2006 07:26 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090207020105020100000600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kannan,

It seems a little odd to do this as a command because commands are
typically undoable things put onto the command stack whereas this is
more of an action. I would imagine that the editor you open will have
a *copy *of the model in it and hence it can't select "object" because
there is a copy of "object" in that editor, rather than "object"
itself. You could use
studioEditor.getEditingDomain().getResourceSet().getEObject( EcoreUtil.getURI(object))
to find the copy.


Kannan Ekanath wrote:

> Ed,
> I called the setSelectionToViewer API, it opens the editor but the
> focus is still not set on that element, my EditCommand looks like this,
>
> EObject object; //the object on which the focus has to be set.
>
> protected CommandResult doExecuteWithResult(IProgressMonitor
> progressMonitor, IAdaptable info) throws ExecutionException {
> IFile file = getEMFStudioFile();
> StudioEditor studioEditor = (StudioEditor) provider.openEditor(new
> FileEditorInput(file));
> Object wrapper =
> ((AdapterFactoryEditingDomain)(studioEditor.getEditingDomain ())).getWrapper(object);
>
> studioEditor.setSelectionToViewer( Collections.singleton(wrapper));
> return CommandResult.newOKCommandResult();
> }
>
> Here am opening the EMF file in the editor, and am trying to focus on
> the "object" which is member variable of Command. However
> setSelectionToViewer doesnt seem to have intended effect. I tried to
> debug through the code, which goes into jface methods like
> updateSelection() etc, no error logs are generated or exceptions in
> console. Am I missing something?
>
> Is it some deferred effect like when i called provider.openEditor the
> editor was already opened and setting selection wont have any effect
> on the editor?
>
> Regards,
> Kannan
>
> Ed Merks wrote:
>
>> Kannan,
>>
>> Have a look at how the gotoMarker method selects the object
>> referenced by a marker using setSelectionToViewer:
>>
>> public void gotoMarker(IMarker marker)
>> {
>> try
>> {
>> if (marker.getType().equals(EValidator.MARKER))
>> {
>> String uriAttribute =
>> marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
>> if (uriAttribute != null)
>> {
>> URI uri = URI.createURI(uriAttribute);
>> EObject eObject =
>> editingDomain.getResourceSet().getEObject(uri, true);
>> if (eObject != null)
>> {
>>
>> setSelectionToViewer(Collections.singleton(editingDomain.get Wrapper(eObject)));
>>
>> }
>> }
>> }
>> }
>> catch (CoreException exception)
>> {
>> LibraryEditorPlugin.INSTANCE.log(exception);
>> }
>> }
>>
>> The other part of your question seems better for the GMF newsgroup.
>>
>>
>> Kannan Ekanath wrote:
>>
>>> Hi,
>>> I am using GMF with EMF. My user is typically expected to create a
>>> skeleton structure using GMF. My diagram is quite complicated with
>>> xmls running until 7-10 levels. Hence modelling all of them using
>>> GMF can be quite messy.
>>>
>>> Hence we support graphical models with links upto 2-3 levels, and
>>> other levels are supposed to be edited using EMF (editor code). So
>>> in GMF when i right click an element i must be able to say "Open
>>> this item in EMF editor" and it must open the EMF editor code with
>>> the *focus set on that particular item.*
>>>
>>> a) Opening EMF editor is fine, but can some one tell me how to focus
>>> one particular element in EMF editor? By default all nodes are
>>> collapsed in the EMF editor view?
>>>
>>> b) In addition to the above has someone done say 6-7 levels of
>>> modelling in GMF(like a compartment inside a compartment etc), i am
>>> sure it will get messy, What are the typical approaches you would
>>> advice/take for this?
>>>
>>> Regards,
>>> Kannan
>>
>>


--------------090207020105020100000600
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Kannan,<br>
<br>
It seems a little odd to do this as a command because commands are
typically undoable things put onto the command stack whereas this is
more of an action. &nbsp; I would imagine that the editor you open will have
a <b>copy </b>of the model in it and hence it can't select "object"
because there is a copy of "object" in that editor, rather than
"object" itself.&nbsp; You could use
studioEditor.getEditingDomain().getResourceSet().getEObject( EcoreUtil.getURI(object))
to find the copy.<br>
<br>
<br>
Kannan Ekanath wrote:
<blockquote cite="mideapavd$j47$1@utils.eclipse.org" type="cite">Ed,
<br>
I called the setSelectionToViewer API, it opens the editor but the
focus is still not set on that element, my EditCommand looks like this,
<br>
<br>
EObject object; //the object on which the focus has to be set.
<br>
<br>
protected CommandResult doExecuteWithResult(IProgressMonitor
progressMonitor, IAdaptable info) throws ExecutionException {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IFile file = getEMFStudioFile();
<br>
&nbsp;&nbsp;&nbsp;&nbsp;StudioEditor studioEditor = (StudioEditor) provider.openEditor(new
FileEditorInput(file));
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Object wrapper =
((AdapterFactoryEditingDomain)(studioEditor.getEditingDomain ())).getWrapper(object);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;studioEditor.setSele ctionToViewer( Collections.singleton(wrapper));
<br>
&nbsp;&nbsp;&nbsp;&nbsp;return CommandResult.newOKCommandResult();
<br>
}
<br>
<br>
Here am opening the EMF file in the editor, and am trying to focus on
the "object" which is member variable of Command. However
setSelectionToViewer doesnt seem to have intended effect. I tried to
debug through the code, which goes into jface methods like
updateSelection() etc, no error logs are generated or exceptions in
console. Am I missing something?
<br>
<br>
Is it some deferred effect like when i called provider.openEditor the
editor was already opened and setting selection wont have any effect on
the editor?
<br>
<br>
Regards,
<br>
Kannan
<br>
<br>
Ed Merks wrote:
<br>
<blockquote type="cite">Kannan,
<br>
<br>
Have a look at how the gotoMarker method selects the object referenced
by a marker using setSelectionToViewer:
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void gotoMarker(IMarker marker)
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; try
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (marker.getType().equals(EValidator.MARKER))
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String uriAttribute =
<br>
&nbsp;&nbsp;&nbsp; marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uriAttribute != null)
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; URI uri = URI.createURI(uriAttribute);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; EObject eObject =
<br>
&nbsp;&nbsp;&nbsp; editingDomain.getResourceSet().getEObject(uri, true);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (eObject != null)
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
setSelectionToViewer(Collections.singleton(editingDomain.get Wrapper(eObject)));
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; catch (CoreException exception)
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LibraryEditorPlugin.INSTANCE.log(exception);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>
<br>
The other part of your question seems better for the GMF newsgroup.
<br>
<br>
<br>
Kannan Ekanath wrote:
<br>
<blockquote type="cite">Hi,
<br>
I am using GMF with EMF. My user is typically expected to create a
skeleton structure using GMF. My diagram is quite complicated with xmls
running until 7-10 levels. Hence modelling all of them using GMF can be
quite messy.
<br>
<br>
Hence we support graphical models with links upto 2-3 levels, and other
levels are supposed to be edited using EMF (editor code). So in GMF
when i right click an element i must be able to say "Open this item in
EMF editor" and it must open the EMF editor code with the *focus set on
that particular item.*
<br>
<br>
a) Opening EMF editor is fine, but can some one tell me how to focus
one particular element in EMF editor? By default all nodes are
collapsed in the EMF editor view?
<br>
<br>
b) In addition to the above has someone done say 6-7 levels of
modelling in GMF(like a compartment inside a compartment etc), i am
sure it will get messy, What are the typical approaches you would
advice/take for this?
<br>
<br>
Regards,
<br>
Kannan
<br>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------090207020105020100000600--
Previous Topic:Getting child elements in the property view (Was originally posted in eclipse.techonology.gmf)
Next Topic:GMF ecore editor and EMF validation framework
Goto Forum:
  


Current Time: Sat Jul 05 10:11:41 EDT 2025

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

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

Back to the top