Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Custom node with Sirius(Impossible to go through my classes)
Custom node with Sirius [message #1792480] Wed, 18 July 2018 13:25 Go to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi all

I want to create a Custom node for my editor.

    I create a Provider and a Style editPart
    I add the good dependencies to the plugin.
    I use extension point
    I set for the custom node the good ID


But when I set a break point in the method getNodeEditPartClass(View view) of my provider even when I create a new node it never stop so I cannot undertsand why this class is not used.

I add different images to explain the # screen of ObeoDesigner.

Here the code of the provider:

package lacen.design;

import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.CustomStyle;


public class EditPartLacenProvider extends AbstractEditPartProvider {
    private static final String LACEN_ID = "LACEN_ID";

	@Override
    protected Class getNodeEditPartClass(View view) {
        if (view.getElement() instanceof CustomStyle) {
            CustomStyle customStyle = (CustomStyle) view.getElement();
            if (customStyle.getId().equals(LACEN_ID)) {
                return InstanceRoleStyleEditPart.class;
            }
        }
        return super.getNodeEditPartClass(view);
    }
 }



and here the Edit Part code

package lacen.design;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.ImageFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.Request;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.sirius.diagram.CustomStyle;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractNotSelectableShapeNodeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IStyleEditPart;
import org.eclipse.sirius.diagram.ui.tools.api.figure.AirStyleDefaultSizeNodeFigure;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class InstanceRoleStyleEditPart extends AbstractNotSelectableShapeNodeEditPart implements IStyleEditPart {

    /**
     * the content pane.
     */
    protected IFigure contentPane;

    /**
     * the primary shape.
     */
    protected ImageFigure primaryShape;

    /**
     * Create a new {@link ChangingImageEditPart}.
     *
     * @param view
     *            the view.
     */
    public InstanceRoleStyleEditPart(View view) {
        super(view);
    }

    public DragTracker getDragTracker(Request request) {
        return getParent().getDragTracker(request);
    }

    protected NodeFigure createNodeFigure() {
        NodeFigure figure = createNodePlate();
        figure.setLayoutManager(new XYLayout());
        IFigure shape = createNodeShape();
        figure.add(shape);
        contentPane = setupContentPane(shape);
        return figure;
    }

    private NodeFigure createNodePlate() {
        DefaultSizeNodeFigure result = new AirStyleDefaultSizeNodeFigure(getMapMode().DPtoLP(40), getMapMode().DPtoLP(40));
        return result;
    }

    /**
     * Create the instance role figure.
     *
     * @return the created figure.
     */
    protected ImageFigure createNodeShape() {
        if (primaryShape == null) {
            primaryShape = new ImageFigure();
        }
        return primaryShape;
    }

    /**
     * Return the instance role figure.
     *
     * @return the instance role figure.
     */
    public ImageFigure getPrimaryShape() {
        return primaryShape;
    }

    /**
     * Default implementation treats passed figure as content pane. Respects
     * layout one may have set for generated figure.
     *
     * @param nodeShape
     *            instance of generated figure class
     * @return the figure
     */
    protected IFigure setupContentPane(IFigure nodeShape) {
        return nodeShape; // use nodeShape itself as contentPane
    }

    public IFigure getContentPane() {
        if (contentPane != null) {
            return contentPane;
        }
        return super.getContentPane();
    }

    protected void refreshVisuals() {
        CustomStyle customStyle = (CustomStyle) this.resolveSemanticElement();
        if (customStyle.eContainer() instanceof DNode) {
        	 ImageDescriptor imageDescriptorFromPlugin = AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "/icons/macron.png");
             this.getPrimaryShape().setImage(imageDescriptorFromPlugin.createImage());
        }
    }

    protected void createDefaultEditPolicies() {
        // empty.
    }
}

Thanks a lot for your help



  • Attachment: laCen0.PNG
    (Size: 171.56KB, Downloaded 120 times)
  • Attachment: laCen1.PNG
    (Size: 74.47KB, Downloaded 112 times)
  • Attachment: laCen2.PNG
    (Size: 51.17KB, Downloaded 99 times)
  • Attachment: laCen3.PNG
    (Size: 59.09KB, Downloaded 106 times)
  • Attachment: laCen4.PNG
    (Size: 81.02KB, Downloaded 110 times)
Re: Custom node with Sirius [message #1792487 is a reply to message #1792480] Wed, 18 July 2018 14:52 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

Are you sure your node is defined correctly meaning if you change your custom style by a shape style for example, do you see your node on the diagram?

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792492 is a reply to message #1792487] Wed, 18 July 2018 15:46 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Pierre,

Yes they are well define the proof: when I set an ellipse I have it (see picture normal). When I set Custom I have a custom style the classical custom (green inside) . But No way to go through my classes using debug, as if my classes are not used!!!!!!

I think that I have forget to do something, but what????


Regards
Re: Custom node with Sirius [message #1792566 is a reply to message #1792492] Thu, 19 July 2018 14:42 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

The problem is that you have no public constructor in your part provider.
You must add :

public EditPartLacenProvider (){
}
The instance is created from reflexive call without parameter so you need to provide a public one.

You should have an error in your error log view about the failure.

This is also why the breakpoint are never reached.

Regards


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792569 is a reply to message #1792566] Thu, 19 July 2018 14:51 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Pierre

Thanks a lot for your reply, I have add the null constructor, with a print, and a break point but still no way to stop on the print?????
I think that I forgot to do something important but the question is what. Or may be the way to launch debug here is a special case?????

package lacen.design;

import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.CustomStyle;


public class EditPartLacenProvider extends AbstractEditPartProvider {
    private static final String LACEN_ID = "LACEN_ID";

    public EditPartLacenProvider (){
    	System.out.println("Here I am");
    }
    
	@Override
    protected Class getNodeEditPartClass(View view) {
        if (view.getElement() instanceof CustomStyle) {
            CustomStyle customStyle = (CustomStyle) view.getElement();
            if (customStyle.getId().equals(LACEN_ID)) {
                return InstanceRoleStyleEditPart.class;
            }
        }
        return super.getNodeEditPartClass(view);
    }
 }


thanks a lot for your help

Regards

Antonio
Re: Custom node with Sirius [message #1792579 is a reply to message #1792569] Thu, 19 July 2018 16:18 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

This is strange, it should work. Check your error log to see if there is still an error regarding your provider.

Regards


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

[Updated on: Thu, 19 July 2018 16:19]

Report message to a moderator

Re: Custom node with Sirius [message #1792586 is a reply to message #1792579] Thu, 19 July 2018 21:56 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
HI Pierre,

The error log is empty nothing, it's for this reason that I ask all these questions.

How can I debug the representation????

If you want I can send you the projects?

Regrads

Antonio

Re: Custom node with Sirius [message #1792605 is a reply to message #1792586] Fri, 20 July 2018 07:53 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

If its not a problem for you, yes you can send it to us and I will take a quick look or a minimalist version of your project with the problem.

Regard,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792606 is a reply to message #1792605] Fri, 20 July 2018 07:54 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Just to be sure, your breakpoint is in your dev environment and your project in the runtime one?

Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792611 is a reply to message #1792606] Fri, 20 July 2018 08:12 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Pierre,

I don' undertsand. what I do:


    I launch Obeo designer
    I have launch the editor tool (cf launch 1).
    In this new environnement I select mycustomer and I create a new representation on right click (cf launch2)


Can you ^precise what you are meaning?

Best regards
  • Attachment: launch 1.PNG
    (Size: 136.55KB, Downloaded 130 times)
  • Attachment: launch 2.PNG
    (Size: 136.24KB, Downloaded 88 times)
Re: Custom node with Sirius [message #1792616 is a reply to message #1792611] Fri, 20 July 2018 09:21 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
ok so your design project with your custom style code where you put the breakpoint is in the runtime environment (launch2) if I believe what I am seeing.
This cannot work.
To debug java code, the java code must be deployed in the environment.
This is not the case when the project is in the workspace.
So what you need to do is to put your design project in your OD workspace, put the breakpoint here. Launch your runtime where your sample is and open your diagram that will trigger the breakpoint in the other OD workspace.

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792627 is a reply to message #1792616] Fri, 20 July 2018 10:42 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Pierre,

Thanks a lot for your help. But I am not specialist of all this. And I don't understand well what your are telling, I apologize.

If I understand i must copy the project lacen.design in the same workspace of the model from were was launch the application to buid the editor!!!!

Then set the break points here.

Then launch the editor from the lacen.sample as befor!!!

What is waht you call OD workspace? What you mean with "Launch your runtime where your sample is and open your diagram that will trigger the breakpoint in the other OD workspace."

Regards

Antonio
Re: Custom node with Sirius [message #1792629 is a reply to message #1792627] Fri, 20 July 2018 10:49 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Pierre,

It works, but I don't understand well why!!! Why OD create the design project in another workspace when first time I launch OD, if after I am obliged to copy it in the same WS than the model????!!!!

Regards


Antonio
Re: Custom node with Sirius [message #1792645 is a reply to message #1792629] Fri, 20 July 2018 13:34 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Why do you say you are oblige to copy it in the same workspace?

The only interest to have the design project in the same workspace as the model one is to create the design more easily when you are doing changes only in the odesign because changes can be seen at the same time.
When having the design in the first workspace and the model in the runtime, each time you are doing a change in the design you have to relaunch the runtime.
But with Sirius 6.0 you have a hot reload button to be able to reload the design when changes have been done in the first workspace.
Any extension point usage usage needs the design plugin to be in first workspace and to be deployed in runtime where model project is.
So I recommend with Sirius 6 to always have the design plugin in first workspace and the model in runtime.

Regards


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom node with Sirius [message #1792653 is a reply to message #1792645] Fri, 20 July 2018 14:24 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Thanks a lot Pierre,

Thanks for your explanations, anyway I still don't understand all. It's not a big deal, we hope to have trainings in September or October, I can still go ahead with these questions...

Regards

Antonio
Re: Custom node with Sirius [message #1792720 is a reply to message #1792653] Mon, 23 July 2018 08:15 Go to previous message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

The essential to understand is when you start using extension point to define your odesign, you must have your design project in the first launched environment. And your sample in the runtime you launch from the first one.

Then if you do a modification in your design, you have to quit your runtime and relaunch it so it can be taken in consideration.

If you are doing only design and services modification, in the first environment, with Sirius 6.0.0 you can use a reload button available in menu bar that will have the same effect as a relaunch of the runtime environment. I.e your modification will be taken in consideration for your sample diagrams and others.

Don't hesitate to continue to ask questions,

Regards


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Get Value of the TextArea
Next Topic:[SOLVED] Hello, I have hit the "...exceeding the 65535 bytes limit". Any help?
Goto Forum:
  


Current Time: Fri Apr 19 19:59:24 GMT 2024

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

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

Back to the top