Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » First Editor
First Editor [message #727042] Tue, 20 September 2011 09:29 Go to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
This thread is too long to read everything:

Start to use Graphiti (XML-File)
How to get confused by the tutorial (picture shows more than the code can create)
Confused again, methods wich are not in the graphiti package incl. wrong code in the tutorial(maybe my own fault but it doesnt work until now)
How to use the resize Feature and resize children
Behaviors of arrows (No Solution inside, I solved it via SWT-Dialogs and radio buttons)
Move an existing arrow -> ReconnectionFeature
Color the background of a TextDecorator -> 0.9.0
Location call by parent returns zero (not solved)
Property sheet: exception in the refresh method


---------------------------------------------------------------------------------

Hey everyone,

I started to use Graphiti and I want to develop my first plug-in Wink

Actually Ive written the basics and used the standard implementations of Graphiti.
So I got 3 Classes:
- DiagramTypeProvider
- AddEClassFeature
- FeatureProvider

and I registered it in the plugin.xml like this

<plugin>
   <extension
         point="org.eclipse.graphiti.ui.diagramTypes">
      <diagramType
            id="Graphiti.MyTutorialDiagramType"
            name="My Graphiti Tutorial Diagram Type"
            type="mytutorial">
      </diagramType>
   </extension>
   <extension
         point="org.eclipse.graphiti.ui.diagramTypeProviders">
      <diagramTypeProvider
            class="Graphiti.MyTutorialDiagramTypeProvider"
            id="TestPlugin.MyTutorialDiagramType"
            name="My tutorial editor Test">
      </diagramTypeProvider>
   </extension>

</plugin>


My question is, how can I start this editor?
I read the tutorial more than once, but I dont understand, how I can start it.
The only thing I found is to create the tutorial Editor.
But that doesnt help me.

[Updated on: Mon, 27 February 2012 10:09]

Report message to a moderator

Re: First Editor [message #727146 is a reply to message #727042] Tue, 20 September 2011 14:13 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
The Graphiti editor is opened when you click on a diagram file. The graphiti plugin internally declares its DiagramEditor as the editor assotiated with the extension "diagram" (and the content-type "org.eclipse.graphiti.content.diagram").


To create a new ".diagram" file, the tutorial provides a wizard as example. (That means that the normal flow is not to open an empty editor, and from there create a new diagram, but instead create a diagram from a wizard/handler, save the file, and then open that new file with the editor). I suggest you try this with the tutorial if this is not clear to you - remember that this should be done in a new Eclipse instance (which includes the graphiti plugin and the examples)

Then, if you want you can define your own editor (extending the DiagramEditor) and your own extensions in your plugin.xml file.
Re: First Editor [message #727575 is a reply to message #727146] Wed, 21 September 2011 14:43 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
At first, thanks Wink

But thats just that is my problem, how should I open an editor wich doesnt exist?
I just wrote the .java files and wrote everything I need into the plugin.xml.

So if I start a second instance of eclipse, what should I do?
I create a sample project, from the examples, I create in that project a diagram file, from the examples and now? Its everything from the example editor, and nothing from my own editor.

If I create in my developing eclipse a diagram file from the wizard, how should I open it? There is, in my opinion, no way to open it and nowhere in the tutorial is that explained.

Edit: Maybe I read the word "editor" it too often, I suggest you mean the following:

create a diagram file in the developing eclipse, open a new instance and open the diagram via File->Open File.

I did that, but it throws an exception:

Unable to create editor ID org.eclipse.graphiti.ui.editor.DiagramEditor: Unknown editor input: org.eclipse.ui.ide.FileStoreEditorInput@5797c16c

I think the stacktrace is not necessary.

I hope you can help me again.

[Updated on: Wed, 21 September 2011 15:05]

Report message to a moderator

Re: First Editor [message #727610 is a reply to message #727575] Wed, 21 September 2011 16:05 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
mr_sniper wrote on Wed, 21 September 2011 11:43

create a diagram file in the developing eclipse, open a new instance and open the diagram via File->Open File.

I did that, but it throws an exception:

Unable to create editor ID org.eclipse.graphiti.ui.editor.DiagramEditor: Unknown editor input: org.eclipse.ui.ide.FileStoreEditorInput@5797c16c


To clarify: we have the "first" eclipse instance ("developing eclipse") and the "second " eclipse instance (the one started from our first one). Each instance has its own workspace, so you can't (well, you should't) create the diagram in the first and try to open from the second - because the graphiti editor expects to see its input in its running workspace [1]

So, you should test the full workflow (create a new diagram, open the editor) in the "second" instance.

First try it with the tutorial [2] diagram type (.diagram) and the standard Graphiti editor (DiagramEditor).

If this works for you, please clarify what you want to do:

In a first scenario the graphiti developer defines its own diagramtype, (extension "org.eclipse.graphiti.ui.diagramTypes") and provider ("org.eclipse.graphiti.ui.diagramTypeProviders") and code the Features.
In this scenario, you will edit "your" diagram, with all your defined ui elements, behaviours etc (totally different from the tutorial). You can call this "your editor" (as different from the tutorial), though it actually it's the same defined editor in the graphiti plugin.xml , with same default extension and same underlying Java class (DiagramEditor).

In a second scenario, you can add you own editor definition (extension point "org.eclipse.ui.editors" in your plugin.xml), so you have your own name for the editor (appears in the menus, "open with..."), icon, default extension, etc, but using the same graphiti DiagramEditor java class.

In a third scenario you can code your own editor (extending DiagramEditor). This is less needed and frequent, I think, and not much supported by Graphiti today.

I suspect that when you speak of "your editor" you are alluding to scenario 1, (your own diagramtype/provider, actually).
Then, what matters is that, when the diagram is created, it is created with "your" diagramType id (you can check it reading the xml source; look for the tag <pi:Diagram...> ). If that is so, the when you click on it it will open what you call "your editor" (actually, graphiti default editor; he will discover the typediagram and use "your" diagramTypeProvider, etc)

[1] I'm not sure if this prohibition is justified, and if that expection is kind of a bug, but nevertheless...

[2] Actually, the diagram type with its extension and its association with the DiagramEditor is specified not in the tutorial plugings but in the core graphiti plugin (I wonder if this is right...)

[Updated on: Wed, 21 September 2011 16:19]

Report message to a moderator

Re: First Editor [message #728961 is a reply to message #727610] Sat, 24 September 2011 15:18 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Hey Smile

thank you again, now it works, a bit -.-
I dont want to say it, but I think I have to, I tried it with a new instance of eclipse, wich Ive opened by myself.
Ive never tried to start it out of the working eclipse -> couldnt test my own editor.
And I had a fault in my plugin.xml.

Next issue is, if I create a new diagram, there is no EClass in the menu.
So I couldnt create anything.
The only thing I get is an exception:

Contributor mytutorial.PropertyContributor cannot be created.

I looked it up and found it in the tutorial.
But now, I got no object and no exception, it happens nothing.
I am sorry, I realy try to make this tutorial and just want to test Graphiti, but until now, it wont let me.

Maybe my plugin.xml is wrong?

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.graphiti.ui.diagramTypes">
      <diagramType
            id="mytutorial.MyTutorialDiagramType"
            name="My Graphiti Tutorial Diagram Type"
            type="mytutorial">
      </diagramType>
   </extension>
   <extension
         point="org.eclipse.graphiti.ui.diagramTypeProviders">
      <diagramTypeProvider
            class="Graphiti.MyTutorialDiagramTypeProvider"
            id="mytutorial.MyTutorialDiagramTypeProvider"
            name="My tutorial editor Test">
            <diagramType
        id="mytutorial.MyTutorialDiagramType">
      </diagramType>
      </diagramTypeProvider>
   </extension>
   
         <extension
          point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
          <propertyContributor contributorId="mytutorial.PropertyContributor">
              <propertyCategory category="Graphiti">
              </propertyCategory>
          </propertyContributor>
      </extension>

      <extension
          point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
          <propertyTabs contributorId="mytutorial.PropertyContributor">
              <propertyTab label="Main" category="Graphiti"
                  id="graphiti.main.tab">
              </propertyTab>
          </propertyTabs>
      </extension>

      <extension
          point="org.eclipse.ui.views.properties.tabbed.propertySections">
          <propertySections contributorId="mytutorial.PropertyContributor">
              <propertySection tab="graphiti.main.tab"           
               class="Graphiti.MyTutorialEClassSection"
               filter="Graphiti.MyTutorialEClassFilter"
               id="graphiti.main.tab.emfclass">
              </propertySection>
          </propertySections>
      </extension>
</plugin>

[Updated on: Sat, 24 September 2011 15:18]

Report message to a moderator

Re: First Editor [message #729208 is a reply to message #728961] Sun, 25 September 2011 12:17 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
no one who could help me?
Re: First Editor [message #729912 is a reply to message #729208] Tue, 27 September 2011 09:06 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
If you have only the 3 files you described in the beginning of this thread
(DiagramTypeProvider, AddEClassFeature, FeatureProvider) you don't get any
entries to create new EClasses. For this you will need a create feature and
register that with your feature provider. That's the next step in the
tutorial.

HTH,
Michael


"mr_sniper" schrieb im Newsbeitrag news:j5n5em$oli$1@news.eclipse.org...

no one who could help me?
Re: First Editor [message #730411 is a reply to message #729912] Wed, 28 September 2011 10:51 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Yes, indeed.
Jörg had already told me that I have to add this.
I was confused by the picture below the tutorial, because that already has a EClass.
Thanks anyway.

Next question:

In the tutorial is this line of code:

String newClassName = ExampleUtil.askString(TITLE, USER_QUESTION, "");


In wich library is ExampleUtil?

[Updated on: Wed, 28 September 2011 11:04]

Report message to a moderator

Re: First Editor [message #731686 is a reply to message #730411] Sun, 02 October 2011 13:20 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Last try, to see if this forum is usefull -.-'

Next line wich is not explained in the Tutorial is:

boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);


This is in TutorialAddEClassFeature.java, looks inconsistent to me, because roundedRectangle is declared outside of
public PictogramElement add(IAddContext context) { ... }

Re: First Editor [message #731930 is a reply to message #731686] Mon, 03 October 2011 13:57 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Soeren wrote on Sun, 02 October 2011 10:20
Last try, to see if this forum is usefull -.-'


Well, that comment is certainly not useful.

Quote:

Next line wich is not explained in the Tutorial is:

boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);


This is in TutorialAddEClassFeature.java, looks inconsistent to me, because roundedRectangle is declared outside of
public PictogramElement add(IAddContext context) { ... }



Uh? That does not make sense. Read again (the method and your question).
Re: First Editor [message #755892 is a reply to message #727042] Thu, 10 November 2011 03:25 Go to previous messageGo to next message
wjgiraldo@hotmail.com  is currently offline wjgiraldo@hotmail.com Friend
Messages: 1
Registered: November 2011
Junior Member
please, use the example in eclipse.org/graphiti/documentation/

Getting Started with Graphiti
Michael Wenz
November 2010, EclipseSummit in Ludwigsburg, Germany
Libray Example shown there
Re: First Editor [message #757306 is a reply to message #731930] Thu, 17 November 2011 16:00 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Hernan wrote on Mon, 03 October 2011 09:57
Soeren wrote on Sun, 02 October 2011 10:20
Last try, to see if this forum is usefull -.-'


Well, that comment is certainly not useful.


Thats right and I am sorry about it.
I worked on my editor daily and couldnt wait for an answer...

Hernan wrote on Mon, 03 October 2011 09:57

Quote:

Next line wich is not explained in the Tutorial is:

boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);


This is in TutorialAddEClassFeature.java, looks inconsistent to me, because roundedRectangle is declared outside of
public PictogramElement add(IAddContext context) { ... }



Uh? That does not make sense. Read again (the method and your question).


Maybe I havent explained it well enough.

In "Add Connection Feature" - "Anchors", we have to add
boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);

But in my point of view ( and Eclipse says that also Wink ), we couldnt use "roundedRectangle".

The class ExampleUtil ("Create Feature") isnt available as well.
I had to ask for it and got the hint to look into your SVN.

Sören

Re: First Editor [message #757308 is a reply to message #757306] Thu, 17 November 2011 16:10 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
In my editor I have to resize and to change the positions of my child elements.

Situation: I change the size of my parent-element.

I know how I change the size of my child-elements according to their parent-element, but I have to move them also.
Eg. if they are on the bottom or on the right side of the parent element and I resize it to the half of it, they arent visible any more because they are outside of the parent-element.

Can I get the distance between the child- and parent-element or the relative positions in the diagram?

Sören
Re: First Editor [message #757681 is a reply to message #757308] Mon, 21 November 2011 09:07 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I got a solution:

                ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
		GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();

		for (Shape shape : containerShape.getChildren()) {
			GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
			IGaService gaService = Graphiti.getGaService();
			if (graphicsAlgorithm instanceof Polygon) {
				Polygon Polygon = (Polygon) graphicsAlgorithm;
				
				//Factor to resize/move elements
				double factor = (containerGa.getHeight() / oldHeight);
				
				//Set new Position
				shape.getGraphicsAlgorithm().setX((int) ((shape.getGraphicsAlgorithm().getX() * factor) + 0.5));
				shape.getGraphicsAlgorithm().setY((int) ((shape.getGraphicsAlgorithm().getY() * factor) + 0.5));
				
                                ...
			}
		}
Re: First Editor [message #757735 is a reply to message #757306] Mon, 21 November 2011 12:17 Go to previous messageGo to next message
Adrian Mouat is currently offline Adrian MouatFriend
Messages: 16
Registered: September 2011
Junior Member
Soeren wrote on Thu, 17 November 2011 11:00


The class ExampleUtil ("Create Feature") isnt available as well.
I had to ask for it and got the hint to look into your SVN.



I successfully worked through the tutorial without running into this issue or touching SVN - perhaps you haven't installed the Graphiti Examples plug-in?

Adrian.
Re: First Editor [message #757811 is a reply to message #757735] Mon, 21 November 2011 18:49 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I found three of them Example -

- Common
- Capabilities
- Tutorial
Re: First Editor [message #759326 is a reply to message #757811] Mon, 28 November 2011 11:40 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
At the moment i try to give each side in my diagram an own anchor, but it doesnt work as expected.
If I use polyService.setLocationAndSize(anchor, 0, 10, 12, 12); the anchor doesnt appear at those coordiantes and if I
resize the element the anchors disappear. I think they got moved.

I want to disallow arrows from the left side to the right side of an other element or upper to lower and so on...

http://s7.directupload.net/images/111128/amtuy3eq.png

Two questions:
- As you can see above I resize every child, are the anchors Polygon-Childs as well or why they got moved?
- Is there an other way to control the arrow position/direction?

[Updated on: Sun, 04 December 2011 18:34]

Report message to a moderator

Re: First Editor [message #760219 is a reply to message #759326] Thu, 01 December 2011 16:04 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Question one, if I resize my Shape directly, the anchors were moved, because they are realtive to their parent.

But, if I resize my Layer, the Shapes got resized, but the anchors not. Is that a bug?
Re: First Editor [message #760382 is a reply to message #760219] Fri, 02 December 2011 08:55 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
I'm not sure what your example really is (the link you posted simply points
to the entry page of directupload).

A first idea may be to check your update and layout features if they cause
that behavior.

HTH,
Michael
Re: First Editor [message #760719 is a reply to message #760382] Sun, 04 December 2011 18:39 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
The picture isnt realy necessary, its just a picture how it looks like. (Its displayed in my browser)
Its possible that my resizeFeature cause that problem, if I resize a Shape, I calc the new point and just set each it for each edge.
I thought, that that should be the same, if I resize the Shape by hand.

The more important question is, how can I control the arrows?
Re: First Editor [message #774748 is a reply to message #727042] Wed, 04 January 2012 14:18 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
.

[Updated on: Wed, 04 January 2012 14:40]

Report message to a moderator

Re: First Editor [message #776144 is a reply to message #774748] Sat, 07 January 2012 16:16 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
If I have three EClasses and it looks like this:

(Spaces have been deleted, i used dots instead.)
_____________
|..__......__ .....|
|.|__|->|__|....|
|_____________|

The arrow points to the other inner EClass.

Now I take the arrow and point him on the parent EClass, in my point of view the canAdd function
in the AddConnectionFeature has to be called or the canCreate in the CreateArrowFeature, but this never happens?
I want to check it, because sometimes I want to disallow that.

[Updated on: Sat, 07 January 2012 16:21]

Report message to a moderator

Re: First Editor [message #777376 is a reply to message #776144] Tue, 10 January 2012 11:13 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
In that case not an add feature but a reconnection feature is triggered, see
the DefaultReconnectionFeature in the Graphiti framework.

Michael
Re: First Editor [message #778545 is a reply to message #777376] Fri, 13 January 2012 08:15 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Michael Wenz wrote on Tue, 10 January 2012 06:13
In that case not an add feature but a reconnection feature is triggered, see
the DefaultReconnectionFeature in the Graphiti framework.

Michael


Great! Thats what I am looking for Smile
Re: First Editor [message #779643 is a reply to message #778545] Mon, 16 January 2012 08:44 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I tried to set the backgroundcolor of a TextDecorator, but it has no effect.

		Style style = gaService.createStyle(getDiagram(), "default");
		style.setForeground(gaService.manageColor(getDiagram(), ColorConstant.BLACK));
		style.setBackground(gaService.manageColor(getDiagram(), ColorConstant.RED));
		style.setFont(Graphiti.getGaService().manageFont(getDiagram(), "Sans", 10));
		text.setStyle(style);
Re: First Editor [message #780143 is a reply to message #779643] Tue, 17 January 2012 09:05 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Would be nice if someone knows how I can fix that issue above Smile

Another question is, why do I get coordinates of:
Graphiti.getLayoutService().getLocationRelativeToDiagram(anchors.get(i))


but if I try to get coordinates with:
anchors.get(i).getGraphicsAlgorithm().getX()

its always 0.

[Updated on: Tue, 17 January 2012 09:07]

Report message to a moderator

Re: First Editor [message #780221 is a reply to message #779643] Tue, 17 January 2012 11:53 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Texts support setting their background color only starting from Graphiti
0.9.0 (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=360800). I guess
you are using the Indigo version Graphiti 0.8.1?

Michael
Re: First Editor [message #780223 is a reply to message #780143] Tue, 17 January 2012 11:55 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The anchor itself stores the location relative to the direct parent
container, while the service call returns the location relative to the
diagram (some parent containers above?).
Michael
Re: First Editor [message #780260 is a reply to message #780221] Tue, 17 January 2012 13:49 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Michael Wenz wrote on Tue, 17 January 2012 06:53
Texts support setting their background color only starting from Graphiti
0.9.0 (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=360800). I guess
you are using the Indigo version Graphiti 0.8.1?

Michael


indeed, doesnt know that there was an update.

Michael Wenz wrote on Tue, 17 January 2012 06:55
The anchor itself stores the location relative to the direct parent
container, while the service call returns the location relative to the
diagram (some parent containers above?).
Michael


Yes there is one container and I know that they return their location relative to it, but I create the anchors by myself and I never set them to zero.
Thats why I am confused Smile
Re: First Editor [message #806801 is a reply to message #727042] Sat, 25 February 2012 14:04 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Hey,

Ive got some problems with the property sheet refresh method.
I try to use it to edit my arrows and their ConnectionDecorators and it works if the refresh method is empty or if I dont try to
set the text in the property sheet.

Actually it looks like this

	@Override
	public void refresh() {
		PictogramElement pe = getSelectedPictogramElement();
		if (pe != null) {
			Connection c = (Connection) pe;
			org.eclipse.graphiti.mm.algorithms.Text text = null;
			EList<ConnectionDecorator> cd = c.getConnectionDecorators();
			text = (org.eclipse.graphiti.mm.algorithms.Text) cd.get(0).getGraphicsAlgorithm();
			textDecorator.setText(text.getValue());
		}
	}


And it throws this exception:

java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context

if I make a new connection to another object.
Re: First Editor [message #807994 is a reply to message #806801] Mon, 27 February 2012 09:10 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
setText (in fact all modifying operations) needs to be called from with an
EMF Transaction since Graphiti uses a TransactionalEditingDomain to hold all
the EMF objects.

Michael
Re: First Editor [message #808013 is a reply to message #807994] Mon, 27 February 2012 09:45 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Thanks, but then you should edit your tutorial Wink

How can I set the name of the decorator in my property sheet?
Re: First Editor [message #809758 is a reply to message #808013] Wed, 29 February 2012 08:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
If I remember correctly the property sheets in the tutorial are read-only,
aren't they?

There's an example how to build an editable property sheet on our FAQ page:
http://www.eclipse.org/graphiti/developers/faq.php
Does that help?

Michael
Re: First Editor [message #811386 is a reply to message #727042] Fri, 02 March 2012 09:33 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Maybe I am wrong, but that:

	public void refresh() {
		PictogramElement pe = getSelectedPictogramElement();
		if (pe != null) {
			Object bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
			// the filter assured, that it is a EClass
			if (bo == null)
				return;
			String name = ((EClass) bo).getName();
			nameText.setText(name == null ? "" : name); //$NON-NLS-1$
		}
	}


looks like the same, isnt it?
The only difference is that this method use an EClass.

Edit: I tried it with an EClass and it works, the only difference is the decorator.
What I can imagine is that I cant write into a decorator like I tried it...

[Updated on: Fri, 02 March 2012 10:06]

Report message to a moderator

Re: First Editor [message #815117 is a reply to message #727042] Wed, 07 March 2012 08:51 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Back to the roots...

If I initialize a FixPointAnchor, I have to set the location.
But then, I cant use
anchor.getGraphicsAlgorithm()

because he just know his own location.
Instead of that, I can use
Graphiti.getLayoutService().getLocationRelativeToDiagram(anchor);


The other way ist to set the location to 0,0
and set the location via
Graphiti.getGaService().setLocation(rectangle, x, y);

now I can use
anchor.getGraphicsAlgorithm()

but not
Graphiti.getLayoutService().getLocationRelativeToDiagram(anchor);


But I need both...
If I set the location and use the setLocation() method, it seems like he adds the
location to the setLocation() Method and the anchor is somewhere else.

thanks... Smile

edit:
I need to that because I need to know the location of my anchor relative to his parent and I have to set the bendpoints. But I can set the coordinates of the bendpoints only relative to the diagram. Thats why I need both coordinates.

[Updated on: Wed, 07 March 2012 08:57]

Report message to a moderator

Re: First Editor [message #818461 is a reply to message #815117] Sun, 11 March 2012 17:26 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I solved it with an own method, it was very simple.
I just add the coordinates from the GraphicsAlgorithm with the location and return a new point.
Re: First Editor [message #822990 is a reply to message #727042] Sat, 17 March 2012 15:59 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
Sounds stupid, but I need a horizontal threshold line in the background of the editor.
How can I solve that?
Re: First Editor [message #893819 is a reply to message #822990] Thu, 05 July 2012 14:52 Go to previous messageGo to next message
Miriam Baran is currently offline Miriam BaranFriend
Messages: 16
Registered: May 2012
Junior Member
hi,
earlier in this post you had a problem with resize, have you solved it yet? I have a similar one and i am a little lost with it. I have BoxRelativeAnchors on a shape, if I resize the shape directly, the anchors will move as well, but if i resize it programmatically the resize will be done, while anchors stay where they are. If you have solved your problem, could you please share the solution?
Re: First Editor [message #893941 is a reply to message #893819] Fri, 06 July 2012 07:01 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
How do you trigger the programmatic resize?

Michael
Re: First Editor [message #894086 is a reply to message #893941] Fri, 06 July 2012 14:56 Go to previous messageGo to previous message
Miriam Baran is currently offline Miriam BaranFriend
Messages: 16
Registered: May 2012
Junior Member
The following code is part of my collapseFeature, which is called by contextButton or contextMenu.
ResizeShapeContext context1 = new ResizeShapeContext(moduleShape);
context1.setSize(100, 100);
context1.setLocation(moduleShape.getGraphicsAlgorithm().getX(), moduleShape.getGraphicsAlgorithm().getY());
IResizeShapeFeature rsf = getFeatureProvider().getResizeShapeFeature(context1);
if (rsf.canExecute(context1)) {
	rsf.execute(context1);
}

moduleShape has 4 BoxRelativeAnchors, which will not move with this resizeFeature. Am I supposed to move them additionally? this seems weird to me, because if you resize the shape with the mouse, it will work just fine.
Previous Topic:Set Text to the right position
Next Topic:change visulization when selecting Object in diagram
Goto Forum:
  


Current Time: Mon Dec 22 17:49:20 GMT 2014

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

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