🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.together.integrations
3 messages
3 total messages Started by Dave Couture Wed, 07 Feb 2007 21:10
Eclipse Integration (How to add shortcut into a diagram)
#178
Author: Dave Couture
Date: Wed, 07 Feb 2007 21:10
46 lines
2456 bytes
Hi,

I've had a menu item that initializes use case diagrams based on the 
Macroscope approach (Fujitsu). My problem is that I'm able to add a new use 
case into the package who contains the diagram, but I'm not able to add a 
shortcut of this new created element into the use case diagram. Here is my 
code. You see in comment all the things I'd tried. Sorry for the French :-).
public void initialiser(Element element) {


    UseCase casDUtilisation;


    this._diagram = (UseCaseDiagramImpl)element;
    this._paquetage = (Package)this._diagram.getOwner();
    this._usecasesFactory = 
UsecasesFactory.REGISTRY.getFactory(this._paquetage.getIProject(), 
this._paquetage.getSession());


    if (this._paquetage.getStereotypes().contains(Stereotypes.P_FONCTION)) {

        casDUtilisation = this.creerCasDUtilisation("UniteDeTache", 
Stereotypes.P_UNITE_DE_TACHE);
        this._paquetage.getOwnedMembers().add(casDUtilisation);
        //this._diagram.eContents().add(casDUtilisation);
        //this._diagram.eCrossReferences().add(casDUtilisation);
        //this._diagram.getAttachments().add(casDUtilisation);
        //this._diagram.getChildren().add(casDUtilisation);
        //this._diagram.getDependencies().add(casDUtilisation);

    }

else {

    JOptionPane.showMessageDialog(null, "Aucune initialisation n'est 
disponible pour l'�l�ment s�lectionn�.");

    }

}


Regards,

Dave 
Re: Eclipse Integration (How to add shortcut into a diagram)
#179
Author: ElenaA
Date: Thu, 08 Feb 2007 14:48
96 lines
4297 bytes
diagram.getChildren().add() is the right way. But you can't add an element 
(e.g. UseCase) to a collectuion of diagram children; you can only add nodes 
(references) there.

the code below creates a diagram reference 
(com.borland.tg.emfapi.diagram.Node) for element and adds it to UseCase 
diagram:

UsecasesFactory ucFactory = 
UsecasesFactory.REGISTRY.getFactory(_paquetage.getIProject(), 
_paquetage.getSession());
    DiagramFactory diagramFactory = 
DiagramFactory.REGISTRY.getFactory(_paquetage.getIProject(), 
_paquetage.getSession());
//create a new UseCase diagram
    UseCaseDiagram myUseCaseDiagram = ucFactory.createUseCaseDiagram();
    myUseCaseDiagram.setName("MyUsecases");

//create a new UseCase
    UseCase myUseCase = ucFactory.createUseCase();
    myUseCase.setName("MyUC");
    _paquetage.getOwnedMembers().add(myUseCase);
//create a new reference
    Node node = diagramFactory.createNode();
//set usecase created above as reference's element (node becomes a shortcut 
to myUseCase)
    node.setElement(myUseCase);
//now add this shortcut to the diagram
    myUseCaseDiagram.getChildren().add(node);
//this is just FYI - bonus: how to set positions for the newly added 
shortcut
    Bounds bounds = diagramFactory.createBounds();
    LocationStyle style = diagramFactory.createLocationStyle();
    style.setLocationSetByUser(true);
    BoundsStyle bStyle = diagramFactory.createBoundsStyle();
    bStyle.setBoundsSetByUser(true);
    node.getStyles().add(style);
    node.getStyles().add(bStyle);
    bounds.setX(100);
    bounds.setY(200);
    bounds.setHeight(80);
    bounds.setWidth(50);
    node.setLayoutConstraint(bounds);


"Dave Couture" <dave_couture@dmr.ca> wrote in message 
news:45ca404e$1@newsgroups.borland.com...
> Hi,
>
> I've had a menu item that initializes use case diagrams based on the 
> Macroscope approach (Fujitsu). My problem is that I'm able to add a new 
> use case into the package who contains the diagram, but I'm not able to 
> add a shortcut of this new created element into the use case diagram. Here 
> is my code. You see in comment all the things I'd tried. Sorry for the 
> French :-).
> public void initialiser(Element element) {
>
>
>    UseCase casDUtilisation;
>
>
>    this._diagram = (UseCaseDiagramImpl)element;
>    this._paquetage = (Package)this._diagram.getOwner();
>    this._usecasesFactory = 
> UsecasesFactory.REGISTRY.getFactory(this._paquetage.getIProject(), 
> this._paquetage.getSession());
>
>
>    if (this._paquetage.getStereotypes().contains(Stereotypes.P_FONCTION)) 
> {
>
>        casDUtilisation = this.creerCasDUtilisation("UniteDeTache", 
> Stereotypes.P_UNITE_DE_TACHE);
>        this._paquetage.getOwnedMembers().add(casDUtilisation);
>        //this._diagram.eContents().add(casDUtilisation);
>        //this._diagram.eCrossReferences().add(casDUtilisation);
>        //this._diagram.getAttachments().add(casDUtilisation);
>        //this._diagram.getChildren().add(casDUtilisation);
>        //this._diagram.getDependencies().add(casDUtilisation);
>
>    }
>
> else {
>
>    JOptionPane.showMessageDialog(null, "Aucune initialisation n'est 
> disponible pour l'�l�ment s�lectionn�.");
>
>    }
>
> }
>
>
> Regards,
>
> Dave
> 
Re: Eclipse Integration (How to add shortcut into a diagram)
#180
Author: Dave Couture
Date: Thu, 08 Feb 2007 16:58
102 lines
4658 bytes
Cool! And thanks for the bonus!

"ElenaA" <Elena.Alekseeva@borland.com> a �crit dans le message de news: 
45cb384b@newsgroups.borland.com...
> diagram.getChildren().add() is the right way. But you can't add an element 
> (e.g. UseCase) to a collectuion of diagram children; you can only add 
> nodes (references) there.
>
> the code below creates a diagram reference 
> (com.borland.tg.emfapi.diagram.Node) for element and adds it to UseCase 
> diagram:
>
> UsecasesFactory ucFactory = 
> UsecasesFactory.REGISTRY.getFactory(_paquetage.getIProject(), 
> _paquetage.getSession());
>    DiagramFactory diagramFactory = 
> DiagramFactory.REGISTRY.getFactory(_paquetage.getIProject(), 
> _paquetage.getSession());
> //create a new UseCase diagram
>    UseCaseDiagram myUseCaseDiagram = ucFactory.createUseCaseDiagram();
>    myUseCaseDiagram.setName("MyUsecases");
>
> //create a new UseCase
>    UseCase myUseCase = ucFactory.createUseCase();
>    myUseCase.setName("MyUC");
>    _paquetage.getOwnedMembers().add(myUseCase);
> //create a new reference
>    Node node = diagramFactory.createNode();
> //set usecase created above as reference's element (node becomes a 
> shortcut to myUseCase)
>    node.setElement(myUseCase);
> //now add this shortcut to the diagram
>    myUseCaseDiagram.getChildren().add(node);
> //this is just FYI - bonus: how to set positions for the newly added 
> shortcut
>    Bounds bounds = diagramFactory.createBounds();
>    LocationStyle style = diagramFactory.createLocationStyle();
>    style.setLocationSetByUser(true);
>    BoundsStyle bStyle = diagramFactory.createBoundsStyle();
>    bStyle.setBoundsSetByUser(true);
>    node.getStyles().add(style);
>    node.getStyles().add(bStyle);
>    bounds.setX(100);
>    bounds.setY(200);
>    bounds.setHeight(80);
>    bounds.setWidth(50);
>    node.setLayoutConstraint(bounds);
>
>
> "Dave Couture" <dave_couture@dmr.ca> wrote in message 
> news:45ca404e$1@newsgroups.borland.com...
>> Hi,
>>
>> I've had a menu item that initializes use case diagrams based on the 
>> Macroscope approach (Fujitsu). My problem is that I'm able to add a new 
>> use case into the package who contains the diagram, but I'm not able to 
>> add a shortcut of this new created element into the use case diagram. 
>> Here is my code. You see in comment all the things I'd tried. Sorry for 
>> the French :-).
>> public void initialiser(Element element) {
>>
>>
>>    UseCase casDUtilisation;
>>
>>
>>    this._diagram = (UseCaseDiagramImpl)element;
>>    this._paquetage = (Package)this._diagram.getOwner();
>>    this._usecasesFactory = 
>> UsecasesFactory.REGISTRY.getFactory(this._paquetage.getIProject(), 
>> this._paquetage.getSession());
>>
>>
>>    if (this._paquetage.getStereotypes().contains(Stereotypes.P_FONCTION)) 
>> {
>>
>>        casDUtilisation = this.creerCasDUtilisation("UniteDeTache", 
>> Stereotypes.P_UNITE_DE_TACHE);
>>        this._paquetage.getOwnedMembers().add(casDUtilisation);
>>        //this._diagram.eContents().add(casDUtilisation);
>>        //this._diagram.eCrossReferences().add(casDUtilisation);
>>        //this._diagram.getAttachments().add(casDUtilisation);
>>        //this._diagram.getChildren().add(casDUtilisation);
>>        //this._diagram.getDependencies().add(casDUtilisation);
>>
>>    }
>>
>> else {
>>
>>    JOptionPane.showMessageDialog(null, "Aucune initialisation n'est 
>> disponible pour l'�l�ment s�lectionn�.");
>>
>>    }
>>
>> }
>>
>>
>> Regards,
>>
>> Dave
>>
>
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads