Hi Its possible to deep copy a diagram manually in EA . But is it possible to do it programmatically from an addin .
somethind like
diagram.cop() or diagram.duplicate() ? .
Or any other ways to copy an entire diagram with its diagram objects and diagram links .
There is no genuine method for that. You have to use the "manual" tedious way by iterating DiagramObjects and creating them new in the second diagram.
I thought of using EaPackage.Clone to create a full copy of the package that contains the diagram and the removing the unneeded stuff. But unfortunately the diagram points to the cloned elements.
Solution
Now that I write that: You can move the diagram to a temporary package. Now you use EaPackage.Clone and voila you have an exact copy of the diagram. Move the original diagram back to where it came from and delete the temp package.
Related
i have to change the diagram type of a lot of diagrams within my Enterprise Architect model. The change can be made manually using following option (that works as expected):
Select diagram - Diagram - Advanced - Change Type...
As I have to change a lot of diagrams I have created a script which searches for all concerned diagrams and change the type automatically. I wrote already a lot of JScript EA scripts for changing some modeling elements. Unfortunately, this feature seems not be available over the scripting interface.
I have to change the "MetaType" of the the diagram object. But this is read-only (see http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/diagram2.html). Therefore, I got an error.
var currentDiagram as EA.Diagram
currentDiagram = theDiagram
currentDiagram.MetaType = MY_DIAGRAM_METATYPE // ERROR
In the next step I searched for appropriate functionalities in the Repository interface (http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/repository3.html) and in the project interface. But I found nothing appropiate.
I am using Enterprise Architect 12.0.1215 and I used JScript.
Has anyone already tried this by script?
Have I missed something?
Is there another approach to achieve the diagram type change by script?
Thanks in advance!
You have to do that in two steps (if you change to different MDG diagram types). E.g. to change a Class diagram to a BPMN2.0::BPEL you first change Diagram_Type from Logical to Analysis. Additionally you need to add MDGDgm=BPMN2.0::BPEL; to StyleEx. In case your old diagram is from another MDG you need to modify the existing MDGDgm attribute in StyleEx.
As Uffe noted, the diagram type in the API is r/o. So if you need to change that you would need to do something like
Repository.Execute("UPDATE t_diagram SET Diagram_Type='Analysis' WHERE Diagram_ID=<theId>")
where <theId> would be the correct diagram ID.
I try to build modular, reusable code in labview.
I want to create a UI component that allows me to select one of the files or directories in a given directory.
I created a subvi that does this. So far so good.
I can use this subvi as a component in other vis, by putting it into a subpanel.
I want to have several of such subpanels with an "instance" of the subvi in my main vi.
I cannot do this. Labview opens the subvi in one subpanel and throws an error for opening it in another one.
How can I tell Labview to create a duplicate/new "instance" of the subvi that runs independently from the any other one?
I found out that xcontrol are probably a better approach to creating components, but they are not available to me, whether they solve the above problem or not.
Labview 2013
You need to configure the subvi to be reentrant.
This allows LabVIEW to allocate data space for each instance.
There are different types of reentrancy, I would stick with the pre-allocated option to start.
http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/reentrancy/
I have a custom toolbox with a foo element.
I would like the foo to be green on an class diagram and red on flow chart diagram by default.
Adding more than one stereotype to non- UML type is impossible (as far as I know).
Is it possible to create 2 toolboxes- one for class diagrams and one for flow charts, specifying the default diagram for each toolbox in the profile?
Not quite the way you describe it.
Toolboxes don't specify which diagram they open, it's the other way around: you create a custom diagram type and associate it with a toolbox. Different custom diagrams may use the same custom toolbox.
You can create two custom diagram types, one for class ("Logical") and one for flow chart ("Activity"), but if you're only after getting the same stereotyped element (foo) to display differently in the diagrams, you don't need to.
The solution is to create a shape script for the stereotype, which checks the diagram type and changes the color accordingly. The diagram type can be queried from the shape script using the diagram.type property (for the base UML diagram type), or diagram.mdgtype (for the custom diagram type, if you've defined one). There is no need to create an Add-In, as another answer suggests, at least not in EA 11.
Check the help file under Extending UML Models -- MDG Technology SDK -- Shape Scripts -- Write Scripts -- Display Element/Connector Properties.
A simple script might look like this:
shape main {
if (hasproperty("diagram.type", "Logical")) {
setfillcolor(0, 255, 70);
} else if (hasproperty("diagram.type", "Activity")) {
setfillcolor(255, 87, 87);
}
drawnativeshape();
};
No. You need to have two different stereotypes. The target diagram is independent of the element. If you want the element appear different on the type of the diagram where you use it you need to adapt the shape script so it calls an add-in which detects the diagram type.
Well, writing the last sentence I would not know how to detect the diagram where the element in question is in. Needs investigation. But other than that - no solution I know of.
Edit: Since the add-in just receives the element GUID it has no way to figure out the diagram from where the call is made. Probably worth a feature request. But the time where we saw those realized in the next build are gone (since more than 10 years).
A last though: template packages. I almost never used them. Maybe they offer coloring depending on diagram/element.
Edit2: Last resort EA_OnPostNewDiagramObject. Catch that and you can get all information you need to apply the color.
I create a ScrollingGraphicalViewer to show my figures, but no figure displays.
I debugged the source and it seems all object (figures, editparts, models) are created, no exceptions. Why the figures do not display?
Since the code is larege and spread many Java files, I briefly depict what I did.
creating model objects. In my model, there are two kinds of elements, directory and file. A directory may contain other directories or files.
figure objects. I create two kinds of figures, one for directory, the other for file.
the directory figure can have nested figures for nested directories and files.
editpart objects. for each kind of model elements, i.e., directory and file, to connect relation between model and figures.
an editpart factory object, for create each editpart object.
create a ScrollingGraphicalViewer object (viewer). and invoke the following methods on viewer: viewer.createControl(), viewer.setRootEditPart(), viewer.setEditPartFactory, and viewer.setContents().
Anything missing?
Any clues and comments will be appriciated.
Thanks.
Overriding refreshVisuals() in your EditParts will do the trick. This is the correct place to react to constraint changes as dictated by your model. You will have to set the figures constraint relative to the parent EditPart (and its figure's FreeformLayout) as well, so for FileEditPart (cf. cross-posting on the Eclipse GEF Forum) do something like the following in refreshVisuals().
getParent().setLayoutConstraint(this, figure, layout);
layout here will have to be a draw2d Rectangle. You can calculate that by giving it x and y values, and getFigure().getPreferredSize().width for the layout.width, and dto. for height.
For basic GEF usage - of which this is a case - I'd suggest you have a look at Rubel et al.'s GEF Book.
I'm trying to import some source code into EA, and make packages. In my root class diagram, I want to show each package as a visual grouping and have all classes inside that package in one group.
Can this be done?
Thanks
Not automatically. When you reverse-engineer source code, you have the option of creating either one class diagram in each package, or no diagrams at all.
Doing it manually, you can create a diagram which simply contains the packages: by default, EA lists the contents of each package when the package is placed in a diagram.
You could also drag the classes into the diagram and group them using boundaries or swimlanes. Boundaries are created from the "Common" diagram toolbox, while swimlanes are accessed by right-clicking an empty area of the diagram.
Finally, you can play around with the diagram's properties (also accessed by right-clicking an empty area), specifically the ones concerning namespaces and fully-scoped object names; these affect how EA displays packages and elements in a diagram.