Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - philchudley

Pages: 1 ... 48 49 [50] 51
736
Automation Interface, Add-Ins and Tools / Cloning a Root Node
« on: May 29, 2009, 11:35:02 pm »
Is it possible to clone a project root and its subsequent View/package structure?

If I export a Root, and attempt to re-import into the same project the process fails with a "Root with the samer name already exists" message.

The reason for this is for modelling variations of a model all adhering to a common structure

I would like to be to export the root to xmi and import the xmi into the same project.

How is this achieved?

737
Thanks Simon, a lot easier than the method I discovered!

738
Hi All

I have found the solution, for anyone interested here is the code to copy a formatted string obtained via the EA object model as a property to the Windows Clipboard, so that the formatting is preserved when written to a Word document

        private void copyToClipBoardAsHTML(string text)
        {
            Encoding enc = Encoding.UTF8;

            string begin = "Version:0.9\r\nStartHTML:{0:000000}\r\nEndHTML:{1:000000}"
                           + "\r\nStartFragment:{2:000000}\r\nEndFragment:{3:000000}\r\n";

            string htmlBegin = "<html>\r\n<head>\r\n"
               + "<meta http-equiv=\"Content-Type\""
               + " content=\"text/html; charset=" + enc.WebName + "\">\r\n"
               + "<title>HTML clipboard</title>\r\n</head>\r\n<body>\r\n"
               + "<!--StartFragment-->";

            string htmlEnd = "<!--EndFragment-->\r\n</body>\r\n</html>\r\n";

            string beginSample = String.Format(begin, 0, 0, 0, 0);

            int countBegin = enc.GetByteCount(beginSample);
            int countHTMLBegin = enc.GetByteCount(htmlBegin);
            int countHTML = enc.GetByteCount(text);
            int countHTMLEnd = enc.GetByteCount(htmlEnd);

            string htmlTotal = String.Format(
                begin,
                countBegin,
                countBegin + countHTMLBegin + countHTML + countHTMLEnd,
                countBegin + countHTMLBegin,
                countBegin + countHTMLBegin + countHTML) + htmlBegin + text + htmlEnd;
            DataObject obj = new DataObject();
            obj.SetData(DataFormats.Html, new System.IO.MemoryStream(
                enc.GetBytes(htmlTotal)));
            Clipboard.SetDataObject(obj, true);
        }

Cheers

739
Hi All

I am developing an add-in which produces customized documentation in Word using the EA object model and MS Word Interop.

Output into Word of the Notes property of an element is easy as below

Range.InsertAfter(element.Notes);

However, if the Notes field contains RTF formatting, the output appears similar to below:

This group of users has access to <font color="#ff0000"><b><i>all</i></b></font><b><i> </i></b>functionality of the application

Copying and Pasting directly from the element property dialog into Word works just fine, preserving all the formatting.

But using the Windows clipboard as:

Clipboard.SetText(element.Notes, TextDataFormat.Rtf);
Range.Paste();

Outputs the text as if the notes were written directly (ie with the tags)

Using the below produces a Word error, persumably since the Html is incomplete (no <html><body> tags):

Clipboard.SetText(element.Notes, TextDataFormat.Html);
Range.Paste();

Adding the missing <html><body> ... </body></html> stiil produces a word error.

Does anyone know:

1) How to get the notes property form an element with ALL the formatting so that it will output/paste correctly?

OR

2) How to copy/paste elemen.Notes so as to preserve the formatting?

Cheers

740
Automation Interface, Add-Ins and Tools / DualCollection vs Collection
« on: January 27, 2009, 10:43:08 pm »
Simple question, what is the difference between EA.IDualCollection and EA.Collection?

When would you use one over the other?

My Add-In uses EA.IDualCollection at the momment and works fine, but I would like to see a formal definition.

I believe there is also EA.IDualElement and EA.Element, so on a more generic level what is the difference between EA.IDualx and EA.x?

Cheers

741
Automation Interface, Add-Ins and Tools / Re-connection of a Connector
« on: November 27, 2008, 03:10:21 am »
Hi All

I am working on an add-in that deals with connectors and I need to detect if a connector is being re-connected using the dragging to a new element method.

My add-in is registered to receive the event EA_OnNotifyContextItemModified and at the momment, I simply display a simple dialog capturing the connector GUID, names of the elements using clientId and supplierID as shown in the code below:

public void EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType type)
        {

            if (type.ToString() == "otConnector")
            {
                EA.IDualConnector theConnector = Repository.GetConnectorByGuid(GUID);
                string[] details = new string[3];
                int clientID = theConnector.ClientID;
                int supplierID = theConnector.SupplierID;
                details[0] = "client : " + Repository.GetElementByID(clientID).Name;
                details[1] = "supplier : " + Repository.GetElementByID(supplierID).Name;
                details[2] = "connector GUID : " + GUID;
                debugForm = new DebugForm(details);
                debugForm.Text += " : Modified";
                debugForm.ShowDialog();
            }
        }

All works well, when I move a connector which starts at Element A (the client) from its supplier (Element B) to a new supplier (Element C), the event is captured twice.

This I would expect since the connector is being disconnected and re-connected (two changes), but the client and supplier info is the same in both events. Specifically, only the new supplier info is shown.

Is there any method of detecting the original supplierID and the new supplierID when a connector is moved in this manner?

Hope what I seeking to do is clear in the above

Cheers

742
Hi David

Thanks, that confirms what I had suspected ... but it is always good to pose the questions in case there any hidden gems

Cheers
Phil

743
Correction to previous post:

Of course the method PutDiagramImageOnClipboard belongs to the Project class and not Repository as I stated before!

744
Automation Interface, Add-Ins and Tools / Placing Diagrams to Clipboard
« on: October 06, 2008, 11:29:02 pm »
I have developed an Add-In which produces documentation using Word. To place diagrams into this document I have used the following method from the Repository class

PutDiagramImageOnClipboard

This works just fine, however when the images are placed on the clipboard, they are opened and appear as diagrams.

I have noticed that when using the in-built RTF generator this does not happen. Is there anyway using an Add-In to place a diagram image on the clipboard without it opening ... just like the RFT generator.

In addition, once on the clipboar, a simple Paste in Word does the job, but large diagrams do not scale to fit the page in the word document. Is it possible to scale the diagram to the page size, before copying to the clipboard?

Cheers

745
Thanks Jim!!

746
Hi All

Is there any way to extract the Keywords text (as entered in an Element properties), using the Object Model?

I have searched the UserGuide and can find no such method or property

Cheers

747
Automation Interface, Add-Ins and Tools / Re: Server Busy Dialog
« on: August 22, 2008, 06:31:56 pm »
Thanks Frank, I will try that ... but for now I'll accept the server busy dialog


748
Automation Interface, Add-Ins and Tools / Re: Server Busy Dialog
« on: August 21, 2008, 12:31:16 am »
Hi Frank

Here is an extract of the relevant code:

System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("path to executable");
psi.WindowsStyle = System.Diagnostics.ProcessWindowStyle.Normal;
psi.UseShellExecute = false;
System.Diagnostics.Prcocess launch;
launch = System.Diagnostics.Process.Start(psi);
launch.WaitForExit();

The last line is wait suspends the add-in waiting for the external tool to complete.

Cheers

Phil

749
Automation Interface, Add-Ins and Tools / Server Busy Dialog
« on: August 20, 2008, 02:02:37 am »
Hi All

I have written an Add-in which launches an external tool from within EA, the add-in then waits for the external tool to finish executing (it behaves therefore like a modal dilaog)

All works just fine, when I close the external tool, a dialog appears in EA titled "Server Busy".

Upon clicking the Retry button on this dialog, everything resumes as normal.

Is there are way to stop this dialog appearing?

Cheers

750
Automation Interface, Add-Ins and Tools / Re: Add-in not registering
« on: August 22, 2008, 06:25:27 pm »
Cheers Guys! Worked a treat!

Pages: 1 ... 48 49 [50] 51