Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Moving ContainerShape onto Shape(Forbidden Symbol is shown and canMove() is not called)
Moving ContainerShape onto Shape [message #1404613] Mon, 04 August 2014 13:30 Go to next message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Dear Graphiti community,

I am struggeling to implement a move feature that allows the user of my editor to move a ContainerShape onto a normal Shape. Once he moves the ContainerShape over the Shape, a red "forbidden sign" is displayed instead of the cursor even though the corresponding MoveFeature should allow this move.

Here's some background on what I need to implement:
From the graphical side I have a rounded Rectangle with a MultiText next to it and both are contained in an invisible and inactive Rectangle. They are arranged in the following structure:

  • ContainerShape (inactive) -> invisible Rectangle

    • ContainerShape -> rounded Rectangle
    • Shape -> MultiText



Now I need the user to be able to move the rounded Rectangle over the MultiText. It is possible to create an overlap by grabbing the rounded rectangle at the top and moving the cursor just above the multi text, but once the cursor is directly over the MultiText the "forbidden symbol" is displayed. The MultiText is the label of the rounded Rectangle and will be automatically moved along with the rounded Rectangle once the rounded Rectangle is moved (to keep the label and the labelled shape together) but the inability of moving the rounded Rectangle to the place where the MultiText is confuses the user.

Here's what I tried so far:
1. turn the Shape of the MultiText into a ContainerShape. The "forbidden symbol" is not shown anymore but neither is the MultiText. After some experimenting I found out it is not rendered at all. Only when I nest it into another GraphicsAlgorithm like an invisible Rectangle it is rendered again. But that would in turn mess up my automatic text shortening (if the MultiText is too small to hold its content, the text will first be wrapped automatically and if that's not enaugh it will be shortened with ..., e.g. "a very long text" will be shortened to "a very l...")

2. allow the move of a ContainerShape onto a Shape. It turns out the canMove() method of my own MoveFeature is not even called and I was not able to find the origin of the "forbidden symbol".

To sum this up:
How can I move a ContainerShape (or a normal Shape) onto a normal Shape? Why does the framework not ask my MoveFeature if this should be allowed or not?

Best regards,
Martin
Re: Moving ContainerShape onto Shape [message #1411072 is a reply to message #1404613] Fri, 22 August 2014 10:18 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Martin,

Option 2) will not work, the only difference between Shapes and
ContainesShapes is that the first cannot have children, thus dropping
another shape is onto it is not supported.

Option 1) should work and I'm not sure why your MultiText vanishes. I just
tried in the tutorial by simply replacing the Shape for the text by a
ContainerShape in TutorialAddEClassFeature; that works, the only thing is
that the text appears in red because I did not adapt the update feature.

There must be something else in your code (update feature, layout feature
come directly to my mind) that influence this. But option 1) is surely the
way to go here.

Michael
Re: Moving ContainerShape onto Shape [message #1419297 is a reply to message #1411072] Mon, 08 September 2014 11:46 Go to previous messageGo to next message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Dear Michael,

Thanks for having a look at this. I double checked my layout and update code and couldn't find anything that would mess with the GraphicsAlgorithm of the label or its rendering. I also tried the example you mentioned and noticed that the text of an EClass is a simple Text and not a MultiText. SO I tried to reproduce my problem in the tutorial example.

Here's what I tried:
1. changed the code so TutorialAddEClassFeature#add(...) creates a ContainerShape for the text in line 99
final Shape shape = peCreateService.createContainerShape(containerShape, false);

2. changed the code so TutorialAddEClassFeature#add(...) creates a MultiText in line 102
final MultiText text = gaService.createMultiText(shape, addedClass.getName());


Step 2 breaks the direct editing of the example and some other things so I decided to do only step 1 and manually edited the diagram file to make the text a MultiText (set xsi:type="al:MultiText") and have a value (set value="Test").

This is the final XML I get in the example:
<children xsi:type="pi:ContainerShape" visible="true">
    <graphicsAlgorithm xsi:type="al:MultiText" lineStyle="UNSPECIFIED" width="100" height="20" style="/0/@styles.0/@styles.1" horizontalAlignment="UNSPECIFIED" verticalAlignment="UNSPECIFIED" value="Test"/>
    <link businessObjects="/1"/>
</children>


This is the XML I get from my application:
<children xsi:type="pi:ContainerShape" visible="true" active="true">
    <properties key="isLabelPictogramElement" value="true"/>
    <graphicsAlgorithm xsi:type="al:MultiText" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="78" height="14" x="111" y="82" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="New Channel">
        <properties key="fullTextValue" value="New Channel"/>
    </graphicsAlgorithm>
</children>


The main difference seems to be the usage of styles, but both versions won't render any text.
Do you have any ideas why MultiTexts are not rendered when they are the GA of container shapes? I'd appreciate any hints.

EDIT:
To further drill down the reproduction of the issue, consider the following CustomFeature:
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.mm.algorithms.MultiText;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;

public class TestCustomFeature extends AbstractCustomFeature {

    public TestCustomFeature(IFeatureProvider fp) {
        super(fp);
    }

    @Override
    public boolean canExecute(ICustomContext context) {
        return true;
    }

    @Override
    public void execute(ICustomContext context) {
        Shape container = Graphiti.getPeCreateService().createShape(getDiagram(), true);
        MultiText ga = Graphiti.getGaCreateService().createMultiText(container, "Test");
        ga.setHeight(100);
        ga.setWidth(100);
        ga.setX(context.getX());
        ga.setY(context.getY());
    }
}

Once you change it to create a ContainerShape the text will not be rendered anymore.
Shape container = Graphiti.getPeCreateService().createContainerShape(getDiagram(), true);


Best regards,
Martin

[Updated on: Mon, 08 September 2014 12:03]

Report message to a moderator

Re: Moving ContainerShape onto Shape [message #1425494 is a reply to message #1419297] Wed, 17 September 2014 11:54 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Martin,

sorry, it took me some time to get back to this...

I tried to reproduce this and succeeded using the Graphiti plugin project
wizard. This appears to be a bug and I created
https://bugs.eclipse.org/bugs/show_bug.cgi?id=444352 for this.

Michael
Previous Topic:NPE when closing my Graphiti editor...
Next Topic:Integrating Kieler algorithms into Graphiti editors
Goto Forum:
  


Current Time: Tue Mar 19 06:30:41 GMT 2024

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

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

Back to the top