In EA we are using the API
Repository.GetContextObject()
to get the current selected objects in EA.But how to check whether the selected object is of type Element or package or diagram in EA using API
Repository.GetContextItemType()
Test for Element.ObjectType
4 = Element
5 = Package
8 = Diagram
Read the documentation for the whole list.
Related
Eclipse has a feature that represents some types of Java collections (most notably ArrayList and ArrayDeque) in a simplified way in the inspect tool (also in the Variables and Expression views):
d = ArrayDeque<E> (id=33)
[0] = "somevalue" (id=57)
[1] = "someothervalue (id=59)
In most other classes, instead of the [0] and [1] entries, the inspect tool will show fields of the object, including their names. I'm interested in looking at the internals of a live ArrayDeque.
Is there a way to make the inspect tool show the real fields of the ArrayDeque, so that the output looks more like this?:
"d" = ArrayDeque<E> (id=33)
elements = Object[] (id=34)
head = 2
tail = 4
I'm using Eclipse 2018-12 (4.10.0).
EDIT: I have already tried using a subclass of ArrayDeque, but it doesn't help.
I have found a way:
In Preferences > Java > Debug > Logical Structures, there is a definiton that performs toArray() on any java.util.Collection before the inspect tool shows the result.
While it is not possible to remove that default entry, you can add an entry for a more specific type:
Qualified type name: java.util.ArrayDeque
Description: Shows ArrayDeque internals
Code: this
Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.
Short answer - check here for screenshots http://imgur.com/a/tVBlD
Long answer - You have two options
1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter
2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.
If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.
Note the second route is what I did to solve a similar issue.
You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.
Python regex search example
baseurl = "http://mywebsite.com:9001/"
# Parse the document
# Build the URL + File Path and Parse the Document
url = baseurl + 'Data'
xmlLink = urllib.request.urlopen(url)
xmlData = etree.parse(xmlLink)
xmlLink.close()
# Find the number of elements to cycle through
numberOfElements = xmlData.xpath("count(//myData/data)")
numberOfElements = int(numberOfElements)
types = xmlData.xpath("//myData/data")
# Search the string
i = 0
while numberOfElements > i:
listSearch= types[i].text
match = re.search(parameter, listSearch, re.IGNORECASE)
if match is None:
i += 1
else:
# Grab the ID
elementID = types[i].get('id')
i = 0
break
An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.
Using Add-In we are creating EA Elements in some random alphabetical order.
The sequence for EA elements in the project browser is shown in the below figure:
While fetching the EA Elements using the below mentioned code, the sequence is: a, c, D, E, g, H, J, B, f, i (B, f, i is of type Enumeration class and others are of type Class).
for (short k = 0; k < getElement.Elements.Count; k++)
{
EA.Element dataTypeEle = getElement.Elements.GetAt(k);
}
But the required output should be as per EA Elements sequence present in the Project browser as shown in the above figure.
How can we read EA Elements as per the sequence present in the project browser ?
EA.Element.Treepos contains the position in the project browser.
If that is all 0, or does not correspond with the order you are seeing then it might be that you have the option not to allow free sorting in the project browser on, which means everything is ordered alphabetically like set the underlying database (there can be tricky settings with umlaut etc.).
In that case you'll have to use the name to sort the collection.
Another thing is that EA has a strange way of grouping element types (such as diagrams, packages, elements, enumerations) which is probably hardcoded somewhere in the EA code, but it is always the same. So if you can't use Treepos then you'll have to figure it out yourself using the name and the grouping EA uses.
I create a model using EA Scripting. The model consists of interfaces and each interface has operations. I also add these interfaces in a composition diagram , how can I not show the operations in diagram in EA.
Is it possible by some settings in EA or I need to do it programatically
Thanks
Doing it for single elements manually is simple:
From the context menu in the diagram choose Features/...Visibility
In Operation Visibility click Custom
Choose the operations you need to suppress
Now for the tricky part, if you need to do that for many diagrams at once. The information is stored in t_diagram.StyleEx. This contains a semicolon separated list of entries. One of those entries might look like
SPL=S_E4BB5A=69A30E,2A49EF:;
Now E4BB5A are the first 6 nibbles of the element GUID which is affected. 69A30E and 2A49EF are those of attributes or operations which shall be suppressed. So in order to suppress an operation on all diagrams you need to do the following:
oGuid = operation.methodGuid.substring(1,6) // get "69A30E" from "{69A30E-..."
eGuid = element.elementGuid.substring(1,6) // E4BB5A
sup = "SPL=S_" + eGuid + "=" + oGuid + ":;"
for dia in allDiagramsInRepos { // you need to build that on your own
dia.styleEx += sup
dia.update()
}
Of course you need to merge with existing SPL entries rather than simply adding them. But you should get the idea.
I am writing a Model Advisor check right now and I need to know the size of a subcharted Stateflow State or Box. But the "Stateflow.State" and "Stateflow.Box" objects only have a "Position" attribute, which gives their position inside their parent elements. I need to know the size of the subchart itself (where their contents reside). How can I get this size?
The "Position" attribute is the absolute position of "Stateflow.State" inside the Chart.Here is an example:
___________________
|AA |
|___________ |
||BB | |
||_________| |
-------------------
AA = r.find('-isa', 'Stateflow.State', 'Name', 'AA').Position
AA = 330.0924 542.7458 157.4576 94.6164
BB = r.find('-isa', 'Stateflow.State', 'Name', 'BB').Position
BB = 334.5304 571.1490 115.7404 62.6628
I finally asked the MathWorks support for a solution and got this answer:
[...] there is currently no API functionality to retrieve the size of the subchart in the subchart subviewer. Unfortunately there are no workarounds to access this information currently.
Update: I recently learned about the undocumented sf API. It is possible to get information about the subchart with it. Therefore you need to get the ID of the State whos dimensions are needed. Here is an example:
r = sfroot;
s = r.find('-isa', 'Stateflow.State', '-and', 'IsSubchart', 1);
sf('get', s(1).id, '.subviewS.pos')
This does the following:
Store the Simulink.Root object in r.
Find all subcharted States and store them in s. You might need to refine the search to detect the exact State you need.
Use the sf API to retrieve the position .pos of the first Subchart, which is represented by .subviewS
There is plenty of information about each of the Stateflow objects. To investigate further, you just need to find the appropriate object (using r.find()) and use sf('get', <object>.id). This lists all available information about the Stateflow object <object>.