How to set documentation for custom components? - install4j

How can I set up the documentation for our custom components and actions so that they will be displayed at the IDE? The same goes for the variable names of these classes. Now the will be displayed like variableName instead of Variable Name.
Thanks in advance
Hardie

This is done with BeanInfo classes.
Look at samples/customCode/src/ManyFeaturesActionBeanInfo.java for an example. That BeanInfo class describes the properties for the class defined in ManyFeaturesAction.java.

Related

How do I use the _MeaningForwards and _MeaningBackwards when defining stereotypes?

When defining stereotypes in a UML profile in EA there are special attributes _MeaningForwards and _MeaningBackwards.
How do I use those exactly to define the entries in the quicklinker?
When I add them to the stereotype, they don't show up in the quicklinker.
The attributes _MeaningForwards and _MeaningBackwards should be added to the metaclass, not to the stereotype.
If you use the profile helper to create them for you, you can't miss.
This is also the reason why you should not reuse metaclasses, but instead create a metaclass for each stereotype.
The result can be seen in the quicklinker

How to show attribute as "readonly" in UML?

I want to describe some models of an API in a diagram. Is there a standard how to mark an attribute as readonly? These attributes are set by the system and cannot be modified by the API consumer.
Currently I abuse the class diagram notation for private and public attributes. But I am not satisfied with this.
Thanks for your thoughts :)
The usual way when you interface coding you would make private properties and use getter/setter operations. You could also leave it on a more abstract level and simply stereotype them with <<readonly>> or <<r/o>>. And finally you could use an appropriate getter method.
Edit The current UML 2.5 spec states on p. 17
Attributes: each specified by its name, type, and multiplicity, and any additional properties such as {readOnly}.
An example on how to use this is found on p. 113:

Intersystems caché - programmatically create new class

Is it possible to write ObjectScript method, which will create new class in namespace and compile it? I mean programmatically create new class and store it. If so, can I edit this class using ObjectScript later(and recompile)?
Reason: I have class structure defined in string variable and I need to add new class to namespace according this string.
Nothing is impossible. Everything in Caché can be created programmatically. And, Classes is not a execution. There are at least two ways to do it:
simple SQL Query CREATE TABLE, will create a class.
and as you already mentioned ObjectScript Code, which can do this.
All of definition of any classes defined in other classes. Which you can find in package %Dictionary.
The class itself defined in %Dictionary.ClassDefinition. Which have some properties, for defining any parts of classes. So, this is a simple code which create some class, with one property.
set clsDef=##class(%Dictionary.ClassDefinition).%New()
set clsDef.Name="package.classname"
set clsDef.Super="%Persistent"
set propDef=##class(%Dictionary.PropertyDefinition).%New()
set propDef.Name="SomeProperty"
set propDef.Type="%String"
do clsDef.Properties.Insert(propDef)
do clsDef.%Save()
And in latest versions, there is one more way for create/change class. If you have text of class as you can see it in Studio. Then, you can load it in Caché, with class %Compiler.UDL.TextServices
Yes, it is. You likely want to make use of %Dictionary.ClassDefinition and the related %Dictionary.*Definition classes (especially %Dictionary.PropertyDefinition, %Dictionary.MethodDefinition and %Dictionary.IndexDefinition) to create and/or modify your class. Provided your string contains some reasonable representation of the data, you should be able to create the class this way.
The actual class documentation is available at http://docs.intersystems.com/cache20141/csp/documatic/%25CSP.Documatic.cls?CLASSNAME=%25Dictionary.ClassDefinition
You can then compile the class by calling $system.OBJ.Compile("YourPackage.YourClass","ck").
(Note: If your string contains the exported XML definition of the class, you could also write the XML representation to a stream and then call $system.OBJ.LoadStream() to import the XML definition. I would only recommend this if you have an exported class definition to start with.)

Adding and removing Data Annotation attributes dynamically

I have a little bit of a curve ball for you. Maybe just a design issue...maybe even something as simple as me not understanding Data annotation providers.
Anyway here we go:
I have a class which represents some model data. Let's say it represents a package/box/carton.
It actually represents all of these things so I use the class in several different views. Sometimes I want the attribute of the field Package_Description to be
So that it shows up as Box Number : input box here.
Now if i want it to appear as "Carton Name" my only option would be to sub type it. Or use a separate class to have the annotations for this class. My quandary is that some of the field names are user configurable and therefore I cannot have a static definition!
(By the way i am using third party librarys [Telerik MVC Grid] do display these field names so i cannot change the fact that it's looking at data annotation )
So I just need to know is there a way to add attributes dynamically?
Create an anonymous type on the fly, sub class the original and then add attributes using reflection?
Or what other options are open to me, do I need to somehow implement a different annotation provider?
Attributes are part of the definition of the type. Because of that, you can't modify attributes of existing classes during runtime.
You could create a new type during runtime (not an anonymous type), but I think that's not such a good idea. I'm sure whatever component you're using, it allows you to specify the appearance explicitly.

Using Generic Types with MVC2 Templates

I have a model class that is a generic type. I would like to create a custom editor template that would display it (and put it in the Shared folder).
How can I do that?
I can't figure out how to name it so that MVC2 would pick it up over the generic template.
Additionally I am wondering if there is a way to explicitly specify which template a top-level class should use (like you can do with a property using UIHint attribute). Is there a way to override the functionality that picks the templates based on the class name?
Please help.
The easiest way is to accomplish #1 is to specify the template name when displaying the model, as the second parameter:
<%= Html.DisplayFor(m => m.GenericList, "DisplayList")%>
The handling is generics isn't very good in MVC2. The source code says:
// TODO: Make better string names for generic types
So, when rendering a list, it look for a template named List`1 be default to render it, if you don't specify another name.
On the second point, you would would do the same as #1. Specify the templatename or use UIHint when rendering the item.