Home » Modeling » GMF (Graphical Modeling Framework) » GMF and SWT widgets
GMF and SWT widgets [message #121039] |
Sat, 21 April 2007 12:26 |
Eclipse User |
|
|
|
Originally posted by: chris.spilio.hotmail.com
Hi guys!
I'd like to ask if it's possible to use the visual interface of SWT
widgets within a GMF canvas. I'm building a visual page editor and the
ideal scenario for me would be to combine the visual display of all the
standard SWT widgets (Button, Listbox, Tree, etc) with the GMF visual
facilities.
For example, i would like to use in a custom Figure the drawing code of
an SWT button, instead of writing it myself. Is it possible to do that?
If yes, could you provide me with an example? If not, are there any
alternative approaches to the matter?
Thank you!
Chris
|
|
|
Re: GMF and SWT widgets [message #121050 is a reply to message #121039] |
Sun, 22 April 2007 09:16 |
Eclipse User |
|
|
|
Originally posted by: serefarikan.kurumsalteknoloji.com
Hi Chris,
This is one of the issues that I had come across before. I believe every
once in a while someone asks the same question in slighly different ways
:) The thing is, there appears to be a "gap" if that's the correct word,
between GEF and SWT.
The visual designers like VE and Window Builder seems to use screen
scrapping. This means that they are creating the components that belong
to swing or swt somewhere else (off screen, in other vm etc) and they
copy the image of the component and draw it as a figure on a GEF canvas
(please correct me if I am wrong)
I have once copied the image of a swing button and placed it on a gef
canvas using a custom figure. The resize etc stuff worked by using a
background button. The problem is the same thing happens to be harder in SWT
What you have been asking would be a great thing if it could be done
easily, but I am not aware of any shortcuts. It's been a while since I
have dealt with this issue.
this is what I now about the issue, and I'd be more than happy to get
the updates :)
Best Regards
Seref
Chris wrote:
> Hi guys!
>
> I'd like to ask if it's possible to use the visual interface of SWT
> widgets within a GMF canvas. I'm building a visual page editor and the
> ideal scenario for me would be to combine the visual display of all the
> standard SWT widgets (Button, Listbox, Tree, etc) with the GMF visual
> facilities.
>
> For example, i would like to use in a custom Figure the drawing code of
> an SWT button, instead of writing it myself. Is it possible to do
> that? If yes, could you provide me with an example? If not, are there
> any alternative approaches to the matter?
>
> Thank you!
> Chris
>
|
|
|
Re: GMF and SWT widgets [message #121057 is a reply to message #121050] |
Sun, 22 April 2007 10:32 |
Eclipse User |
|
|
|
Originally posted by: chris.spilio.hotmail.com
Seraf hi!
Thanks for your prompt reply! Ok, that's what I'd thought myself from
the beginning, therefore i'll do a bit more investigation and post the
question to the Visual Editor newsgroup. Maybe they can give us a short
hint and if i can manage to improvise something, i'll let you know!
Chris
|
|
|
Re: GMF and SWT widgets [message #121085 is a reply to message #121057] |
Sun, 22 April 2007 22:35 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Chris,
The screen-scraping technique has been mentioned. It's also possible to
add the widget directly to the viewer's control. In this case, the
widget will be "live", i.e. it will respond to user interaction. If
you're careful to react to layout changes, it's possible to make such a
widget look like the content of a Figure. Some time ago, I implemented a
ControlFigure, that handled such logic, so I know it's possible (but
where's the code?). If the widget shouldn't be live, but just should
look real, I believe there is another trick (that I've only read about
and not tried): wrap it in a container and set the enabled flag of this
container to false. Apparently, the container blocks the user's
interaction, but since the Control thinks it's enabled, it isn't dimmed
or whatever. Try it!
Hallvard
chris wrote:
> Seraf hi!
>
> Thanks for your prompt reply! Ok, that's what I'd thought myself from
> the beginning, therefore i'll do a bit more investigation and post the
> question to the Visual Editor newsgroup. Maybe they can give us a short
> hint and if i can manage to improvise something, i'll let you know!
>
> Chris
>
|
|
|
Re: GMF and SWT widgets [message #121137 is a reply to message #121085] |
Mon, 23 April 2007 08:53 |
Eclipse User |
|
|
|
Originally posted by: serefarikan.kurumsalteknoloji.com
Hi Hallvard,
Simple question: how do you add a swt control (say a button) to an
IFigure implementation? Any pointers as an answer to this question would
be great!
If this can be done (and you're saying that it is possible) than the
trick you describe becomes similar to using a glasspane in swing.
Worth checking out.
Regards
Seref
Hallvard Trætteberg wrote:
> Chris,
>
> The screen-scraping technique has been mentioned. It's also possible to
> add the widget directly to the viewer's control. In this case, the
> widget will be "live", i.e. it will respond to user interaction. If
> you're careful to react to layout changes, it's possible to make such a
> widget look like the content of a Figure. Some time ago, I implemented a
> ControlFigure, that handled such logic, so I know it's possible (but
> where's the code?). If the widget shouldn't be live, but just should
> look real, I believe there is another trick (that I've only read about
> and not tried): wrap it in a container and set the enabled flag of this
> container to false. Apparently, the container blocks the user's
> interaction, but since the Control thinks it's enabled, it isn't dimmed
> or whatever. Try it!
>
> Hallvard
>
> chris wrote:
>> Seraf hi!
>>
>> Thanks for your prompt reply! Ok, that's what I'd thought myself
>> from the beginning, therefore i'll do a bit more investigation and
>> post the question to the Visual Editor newsgroup. Maybe they can give
>> us a short hint and if i can manage to improvise something, i'll let
>> you know!
>>
>> Chris
>>
|
|
|
Re: GMF and SWT widgets [message #121167 is a reply to message #121039] |
Mon, 23 April 2007 11:01 |
Eclipse User |
|
|
|
Originally posted by: serefarikan.kurumsalteknoloji.com
Chris and Hallvard,
I believe this thread is relevant
http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 7520.html
Regards
Seref
Chris wrote:
> Hi guys!
>
> I'd like to ask if it's possible to use the visual interface of SWT
> widgets within a GMF canvas. I'm building a visual page editor and the
> ideal scenario for me would be to combine the visual display of all the
> standard SWT widgets (Button, Listbox, Tree, etc) with the GMF visual
> facilities.
>
> For example, i would like to use in a custom Figure the drawing code of
> an SWT button, instead of writing it myself. Is it possible to do
> that? If yes, could you provide me with an example? If not, are there
> any alternative approaches to the matter?
>
> Thank you!
> Chris
>
|
|
|
Re: GMF and SWT widgets [message #121328 is a reply to message #121137] |
Mon, 23 April 2007 14:46 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Seref,
The Control must be added to the Viewer's Control,
e.g. new Text(editPart.getViewer().getControl(), SWT.NONE);
The idea is then to insert a RectangleFigure subclass that references
this Control and updates the Control's bounds whenever it (the
RectangleFigure) is moved or resized. It must both handle the case when
itself is moved or resized or when one of its parents are moved or
resized. I did this by attaching a special (subclass of) Anchor to it,
since Anchors already have logic to track all parents' bounds change (I
made a subclass of Anchor that notified the RectangleFigure subclass of
bounds changes). Unfortunately, I don't know where the code is now, so I
can only give hints like this :-(
As you have discovered, another technique is scraping, where a Control
is somehow drawn to a Graphics created from an Image. You'll have to
find out what works best for you.
Since this is something that is requested once in a while, perhaps the
GEF project could include it, if a working implementation is contributed.
Hallvard
Seref Arikan wrote:
> Hi Hallvard,
> Simple question: how do you add a swt control (say a button) to an
> IFigure implementation? Any pointers as an answer to this question would
> be great!
> If this can be done (and you're saying that it is possible) than the
> trick you describe becomes similar to using a glasspane in swing.
> Worth checking out.
>
> Regards
> Seref
>
> Hallvard Trætteberg wrote:
>> Chris,
>>
>> The screen-scraping technique has been mentioned. It's also possible
>> to add the widget directly to the viewer's control. In this case, the
>> widget will be "live", i.e. it will respond to user interaction. If
>> you're careful to react to layout changes, it's possible to make such
>> a widget look like the content of a Figure. Some time ago, I
>> implemented a ControlFigure, that handled such logic, so I know it's
>> possible (but where's the code?). If the widget shouldn't be live, but
>> just should look real, I believe there is another trick (that I've
>> only read about and not tried): wrap it in a container and set the
>> enabled flag of this container to false. Apparently, the container
>> blocks the user's interaction, but since the Control thinks it's
>> enabled, it isn't dimmed or whatever. Try it!
>>
>> Hallvard
>>
>> chris wrote:
>>> Seraf hi!
>>>
>>> Thanks for your prompt reply! Ok, that's what I'd thought myself
>>> from the beginning, therefore i'll do a bit more investigation and
>>> post the question to the Visual Editor newsgroup. Maybe they can
>>> give us a short hint and if i can manage to improvise something, i'll
>>> let you know!
>>>
>>> Chris
>>>
|
|
|
Re: GMF and SWT widgets [message #121377 is a reply to message #121328] |
Mon, 23 April 2007 17:42 |
Eclipse User |
|
|
|
Originally posted by: serefarikan.kurumsalteknoloji.com
Hallvard,
Thanks for the details, I agree that this would be a good feature to see
in GEF. Let's hope it will be noticed :)
Regards
Seref
Hallvard Trætteberg wrote:
> Seref,
>
> The Control must be added to the Viewer's Control,
> e.g. new Text(editPart.getViewer().getControl(), SWT.NONE);
>
> The idea is then to insert a RectangleFigure subclass that references
> this Control and updates the Control's bounds whenever it (the
> RectangleFigure) is moved or resized. It must both handle the case when
> itself is moved or resized or when one of its parents are moved or
> resized. I did this by attaching a special (subclass of) Anchor to it,
> since Anchors already have logic to track all parents' bounds change (I
> made a subclass of Anchor that notified the RectangleFigure subclass of
> bounds changes). Unfortunately, I don't know where the code is now, so I
> can only give hints like this :-(
>
> As you have discovered, another technique is scraping, where a Control
> is somehow drawn to a Graphics created from an Image. You'll have to
> find out what works best for you.
>
> Since this is something that is requested once in a while, perhaps the
> GEF project could include it, if a working implementation is contributed.
>
> Hallvard
>
> Seref Arikan wrote:
>> Hi Hallvard,
>> Simple question: how do you add a swt control (say a button) to an
>> IFigure implementation? Any pointers as an answer to this question would
>
>
>
>> be great!
>> If this can be done (and you're saying that it is possible) than the
>> trick you describe becomes similar to using a glasspane in swing.
>> Worth checking out.
>>
>> Regards
>> Seref
>>
>> Hallvard Trætteberg wrote:
>>> Chris,
>>>
>>> The screen-scraping technique has been mentioned. It's also possible
>>> to add the widget directly to the viewer's control. In this case, the
>>> widget will be "live", i.e. it will respond to user interaction. If
>>> you're careful to react to layout changes, it's possible to make such
>>> a widget look like the content of a Figure. Some time ago, I
>>> implemented a ControlFigure, that handled such logic, so I know it's
>>> possible (but where's the code?). If the widget shouldn't be live,
>>> but just should look real, I believe there is another trick (that
>>> I've only read about and not tried): wrap it in a container and set
>>> the enabled flag of this container to false. Apparently, the
>>> container blocks the user's interaction, but since the Control thinks
>>> it's enabled, it isn't dimmed or whatever. Try it!
>>>
>>> Hallvard
>>>
>>> chris wrote:
>>>> Seraf hi!
>>>>
>>>> Thanks for your prompt reply! Ok, that's what I'd thought myself
>>>> from the beginning, therefore i'll do a bit more investigation and
>>>> post the question to the Visual Editor newsgroup. Maybe they can
>>>> give us a short hint and if i can manage to improvise something,
>>>> i'll let you know!
>>>>
>>>> Chris
>>>>
|
|
|
Re: GMF and SWT widgets [message #121401 is a reply to message #121167] |
Mon, 23 April 2007 19:02 |
Eclipse User |
|
|
|
Originally posted by: chris.spilio.hotmail.com
Seraf, Hallvard,
thank you very much guys for your input! If i come up with a concrete
reusable pattern for this task, i'll post it to the forum so that we can
share it with the rest of the community.
Thanks a lot!
Chris
|
|
|
Re: GMF and SWT widgets [message #124858 is a reply to message #121328] |
Tue, 08 May 2007 13:51 |
Eclipse User |
|
|
|
Originally posted by: snej_NO-SPAM_.esuark.de
Hallvard Trætteberg wrote:
> The Control must be added to the Viewer's Control,
> e.g. new Text(editPart.getViewer().getControl(), SWT.NONE);
> The idea is then to insert a RectangleFigure subclass that references
> this Control and updates the Control's bounds whenever it (the
> RectangleFigure) is moved or resized.
Hello Hallvard,
could you describe the procedure a little bit "easier"? I've tried to
get it by myself, but i get no swt widget visible :(.
I tried to make a combobox by creating a rectangle in gmfgraph, then
edit the ComboBoxEditPart and insert the swt combo widget. A little bit
confusing for me was this part of your sentence:
"to insert a RectangleFigure subclass that references this Control"
This task is not my main task, so i could not invest much time in
research. So it would be kind if you (or someone else) could give me a
hand with that.
regards
jens
|
|
|
Goto Forum:
Current Time: Fri Dec 27 10:36:14 GMT 2024
Powered by FUDForum. Page generated in 0.02756 seconds
|