Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Show anchor shapes when connection tool enabled
Show anchor shapes when connection tool enabled [message #630197] Fri, 01 October 2010 02:37 Go to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Hi,

I would like to show all shapes that are children of all anchor when the connection tool
is selected in the tool palette. When disabled, I want to hide all anchor's shapes.

I would also like to show/hide these anchor shapes when the connection tool is enabled
using the ButtonPad...

In my real application, I have many different kind of connection. My idea behind this
request, is to show only the anchor point that are relevant to each connection type when
they are enabled.

Is it possible? How could I achieve this?

Thanks for your answer...

Regards
Vincent
Re: Show anchor shapes when connection tool enabled [message #630273 is a reply to message #630197] Fri, 01 October 2010 11:35 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Currently this is not possible. One would need either to hook into the
palette entry creation or the possiblity to add listeners to palette
entries. Both is not yet enabled.

If you like to see this feature in a future version please raise an
enhancement Bugzilla for Graphiti.

Michael


"Vincent L." <lapointe_vincent_1975@hotmail.com> wrote in message
news:i83hcd$bq7$1@news.eclipse.org...
> Hi,
>
> I would like to show all shapes that are children of all anchor when the
> connection tool is selected in the tool palette. When disabled, I want to
> hide all anchor's shapes.
>
> I would also like to show/hide these anchor shapes when the connection
> tool is enabled using the ButtonPad...
>
> In my real application, I have many different kind of connection. My idea
> behind this request, is to show only the anchor point that are relevant to
> each connection type when they are enabled.
>
> Is it possible? How could I achieve this?
>
> Thanks for your answer...
>
> Regards
> Vincent
>
>
Re: Show anchor shapes when connection tool enabled [message #630870 is a reply to message #630197] Tue, 05 October 2010 12:07 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi,

you can already listen to this type of change
by using GEF API.
To access the GEF API through Graphiti extend DiagramEditor and try with the code snippet below.
(probably it is wise to unregister the listener
via overriding dispose() in DiagramEditor)

Does it work?

Best, Tim

@Override
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
getEditDomain().getPaletteViewer().addPaletteListener(new PaletteListener() {

@Override
public void activeToolChanged(PaletteViewer palette, ToolEntry tool) {
// your coding
}

});
}

[Updated on: Tue, 05 October 2010 12:07]

Report message to a moderator

Re: Show anchor shapes when connection tool enabled [message #631863 is a reply to message #630870] Sat, 09 October 2010 11:02 Go to previous messageGo to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Tim Kaiser wrote:
> Hi,
>
> you can already listen to this type of change
> by using GEF API.
> To access the GEF API through Graphiti extend DiagramEditor and try with
> the code snippet below.
> (probably it is wise to unregister the listener
> via overriding dispose())
>
> Does it work?
>
> Best, Tim
>
> @Override
> protected void initializeGraphicalViewer() {
> super.initializeGraphicalViewer();
> getEditDomain().getPaletteViewer().addPaletteListener(new
> PaletteListener() {
>
> @Override
> public void activeToolChanged(PaletteViewer palette,
> ToolEntry tool) {
> // your coding
> }
>
> });
> }

Thanks,

The listenner is called as suggested. Now I will try to update my pictogram using this
listener.
Re: Show anchor shapes when connection tool enabled [message #631905 is a reply to message #631863] Sun, 10 October 2010 11:54 Go to previous messageGo to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Hi Tim,

I made what you suggested and tryed to call my custom feature from the listener but it
doesn't work correctly. I received an IllegalStateException exception.

Here is a part of my activeToolChanged method:

...
IDiagramTypeProvider dtp = getDiagramTypeProvider();
IFeatureProvider featureProvider = dtp.getFeatureProvider();
featureProvider.CustomContext customContext = new CustomContext();

ICustomFeature[] customFeature = featureProvider.getCustomFeatures(customContext); for
(ICustomFeature customFeature : customFeatures) {
if (customFeature instanceof MyCustomeFeature) {
if (customFeature.canExecute(customContext)) {
customFeature.execute(customContext);
}
}
}

Here is a part of my customFeature's execute method:
...
FixPointAnchor fixPointAnchor = (FixPointAnchor) anchor;
fixPointAnchor.setVisible(show);
...

When I call the setVisible method, I received the following IllegalStateException exception:


java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:348)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:302)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:284)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:240)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:380)
at
org.eclipse.graphiti.mm.pictograms.impl.PictogramElementImpl .setVisible(PictogramElementImpl.java:148)


What should I do to have the write "transaction" ?

Thanks

Regards,

VincentL.
Re: Show anchor shapes when connection tool enabled [message #631985 is a reply to message #631905] Mon, 11 October 2010 07:13 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
"Transaction" means an EMF transaction. What you need to do is to wrap the
call to the execute method of the feature inside an EMF
TransactionalEditingDomain. You should retrieve that from the passed
PictogramElement in the context (get the ResourceSet from it and use
TransactionUtil to get the editing domain for it).

Michael

"Vincent L." <lapointe_vincent_1975@hotmail.com> wrote in message
news:i8s9c9$p84$1@news.eclipse.org...
> Hi Tim,
>
> I made what you suggested and tryed to call my custom feature from the
> listener but it doesn't work correctly. I received an
> IllegalStateException exception.
>
> Here is a part of my activeToolChanged method:
>
> ...
> IDiagramTypeProvider dtp = getDiagramTypeProvider();
> IFeatureProvider featureProvider = dtp.getFeatureProvider();
> featureProvider.CustomContext customContext = new CustomContext();
>
> ICustomFeature[] customFeature =
> featureProvider.getCustomFeatures(customContext); for (ICustomFeature
> customFeature : customFeatures) {
> if (customFeature instanceof MyCustomeFeature) {
> if (customFeature.canExecute(customContext)) {
> customFeature.execute(customContext);
> }
> }
> }
>
> Here is a part of my customFeature's execute method:
> ...
> FixPointAnchor fixPointAnchor = (FixPointAnchor) anchor;
> fixPointAnchor.setVisible(show);
> ...
>
> When I call the setVisible method, I received the following
> IllegalStateException exception:
>
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:348)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:302)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:284)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:240)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:380)
> at
> org.eclipse.graphiti.mm.pictograms.impl.PictogramElementImpl .setVisible(PictogramElementImpl.java:148)
>
>
> What should I do to have the write "transaction" ?
>
> Thanks
>
> Regards,
>
> VincentL.
Re: Show anchor shapes when connection tool enabled [message #632041 is a reply to message #631985] Mon, 11 October 2010 10:36 Go to previous messageGo to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Thanks it works.

Here is an example:

ResourceSet resourceSet = getResourceSet();
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet);
editingDomain.getCommandStack().execute(new Command() {
...
@Override
public void execute() {
...
}
...
});
Re: Show anchor shapes when connection tool enabled [message #820113 is a reply to message #630197] Tue, 13 March 2012 18:47 Go to previous messageGo to next message
Fabio Filippelli is currently offline Fabio FilippelliFriend
Messages: 2
Registered: December 2011
Junior Member
I think this is quite a nice enhancement.

Is therefore a direct support implemented in Graphiti yet?

If no, i would be pleased if someone (maybe VincentL) could provide me some example code snippet to solve this issue.

Regards
Re: Show anchor shapes when connection tool enabled [message #820531 is a reply to message #820113] Wed, 14 March 2012 08:44 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
This has been enabled by the Graphiti framework for the upcoming Juno
(0.9.0) release, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=329517
for details.

An example is shipped as part of the new chess example. When a move is
created (visualized as connection) all possible target squares are
highlighted.

Michael
Previous Topic:GraphitiUi.getUiLayoutService().calculateTextSize
Next Topic:Show a diagram in read-only in a view (IViewPart)
Goto Forum:
  


Current Time: Thu Apr 25 21:43:48 GMT 2024

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

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

Back to the top