Getting nsuri in Eclipse - eclipse

I have Tree.ecore as source Metamodel. I need to write something like this:
model Tree driver EMF {nsuri="http://www.eclipse.org/emf/2002/Tree"};
How can I get exact nsuri of my registered ecore in eclipse?

If you are using #namespace(uri="Tree", prefix="Tree") in your Emfatic metamodel, then the nsuri you're looking for is Tree (nsuri stands for "namespace URI")

I suppose you have generated the model code for your Tree.ecore
Then you get the nsuri and all other elements (like all EAttributes, EReferences etc) via the generated static Package class.
In your case it is probably called TreePackage.
So you get the nsuri like this:
TreePackage.eNS_URI or TreePackage.eINSTANCE.getNsURI()
Update:
If you only have the *.ecore file and want to know the uri, open the file with a text editor and look in the <ecore:EPackage tag at the beginning of the file. There you see the attribut nsURI

Related

FactoryGirl rename auto generated files

When using FactoryGirl and generating a new model company it generates a factory as well in: spec/factories/companies.rb.
For personal preference and the way I use ctrl+p in sublime text I want to rename the auto generated files to spec/factories/companies_factory.rb.
I've viewed the generators documentation but I don't see any way to overide another gems implementation.
A point in the right direction will be super :)
Adding this to your application.rb should do what you want:
config.generators do |g|
g.factory_girl suffix: 'factory'
end

Generating the separate ecore files for the sub-Epackes present in the existing model

Problem: I have an ecore file which has the sub-E Packages. Using this model I am trying to create the GUI part using Sirius. But the problem with Sirius is that it does not support ecore files containing sub-E Packages. So we have to extract those sub-E Packages to separate ecore files. But each sub-E Packages has relation with the other sub-E Packages. So how can we extract those sub-E Packages to separate ecore files such that the relations still exists between separate ecore files after extracting them.
Thanks
By extracting them the ecore Editor will lose the information unfortunately, which means some extra work...
I had the same issue with sirius and sub e-packages leading to sirius crashing the diagram constantly.
Here is how i solved extracting a sub-epackage:
First Create a new .ecore file for your desired sub-package.
Open both .ecore files (your main and the new one) with the Sample
ecore model editor (treeview).
Copy the Package properties to your new epackage node(ns, praefix,
uri) you need to do this manually.
Then drag and drop your whole contents(excluding the purple package
node) from your subpackage into the new Epackage
Save and make sure no errors in your new file occur.
load your new .ecore file into your main file by clicking "Load
resource" Now your main file knows 2 kinds of the EClasses you have in your sub-package, their names are identical but their uri is
different.
you could now simply replace all occurrences of sub-epackage-eclasses with the newer ones or smarter and safer
Replace an etype one time (where actually use the etype in your root package)
open your main .ecore file as text, you will see that the etype values all
have a path like eType="ecore:EClass
../../org.eclipse.emf.ecore/model/Ecore.ecore#//EObject" Then You need to know how your etype paths (from your sub-epackage and your new one) differ so you can simply replace them all and your good.
finally delete the sub-epackage
Hope this helps
In eclipse ecore editor you can use "Load Resource" in pop-up menu to load any ecore file and use objects from it.

How to accomplish drop-down lists in KIE workbench?

I'm new to JBPM and am trying to wrap my head around a new project, and recently noticed that while trying to define some user task forms I couldn't find a form option for a drop-down list
At this point my knowledge of the technology is pretty small, and this seems like a strange limitation at first glance, which should have an easy work-around, but I'm having difficulty finding a quick and dirty solution.
Is this something I'd have to code in Eclipse, or something else?
The answer that #cego provides is correct for "hard-coded" values, if you want to load dynamic values (from a database for example) you can use the Select Box field type and configure it to use a SelectValuesProvider that calculates the combo values.
To create a SelectValuesProvider you should create a java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
Once you did that you can create your class that implements org.jbpm.formModeler.core.config.SelectValuesProvider. This interface provides two methods:
String getIdentifier(): should return a unique String that identifies this provider. This String will be shown on the Select Box configuration popup.
Map getSelectOptions(Field field, String value, FormRenderContext renderContext, Locale locale): This method have to return a Map containting the key, text that are going to be load on the Select box. The received parameters are:
Field field: the configuration of the field that is going to be evaluated.
String Value: the current value of the field
FormRenderContext renderContext: a class that contains all the information about the form that is rendered at that moment.
Locale locale: the locale in which is being rendered the form.
Once you've created this provider, you must compile your project and put the jar on the server classpath and restart it. After doing that you'll be able to create a form (or edit an existing one), add a Select Box field and choose your provider on the "Data provider" combo box.
Hope it helps, if you have any doubt please ask and I'll try to create an example.
Regards,
Pere
Ok, for old versions you can do it turning a textbox to a combobox using a RangeProvider. This is a very similar solution to the previous one.
First you should create java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
After that you have to create your RangeProvider class that implements org.jbpm.formModeler.api.model.RangeProvider and implement it's methods. As the SelectValuesProvider on the previous example this interface provides two methods:
- String getType(): A unique String to identify the provider
- Map getRangesMap(String namespace): This method have to return a Map containting the key, text that are going to be load on the combo box. It only receives a String parameter, it is an identifier that allows you to get all the information about the form that is being rendered.
Also you have to create a META-INF/beans.xml file to allow to lookup your provider via CDI (I missed this step on the previous example, sorry).
As the previous example, once you've created the provider you must compile your project and put the jar on the server classpath and restart it.
When the server is started you have to create a new form (or open an existing one), add a TextBox field, edit it's properties and write the string returned by your RangeProvider's getType method on the "Range value" property.
Save the field properties and if everything is fine the field would be rendered as a combobox showing the values returned by your provider.
To create a select element(drop-down list) look for "Setting a Range Formula" in this part of the documentation: http://docs.jboss.org/jbpm/v6.1/userguide/chap-formmodeler.html#sect-formmodeler-FormulasExpression

Unable to loacte properites file in wicket

In my wicket application i have 3-4 different packages say pack1,pack2 and so on .
In pack1 i have different html and java classes. I am validating the null check by setRequired(true) and getting the message from properties file.I am naming my properties file as Send.properties ... as i have Send.html and Send.java in pack1.In properties file i am mentioning like this
formname.field.Required=The ${label} is missing
I want to validate all the html fields which are present in different html pages of the same package (pack1)in one properties file say pack1.properties .So my question here is will one singe properties will be sufficient for one package where in all the validation will be taken care.
Yes, wicket first looks for the property in the properties file associated to the page, and then in the properties asociated to the package (and after that in parents packages...).
But, as long as I know the package properties file is called package.properties (independently of the package name).

poEdit not creating source files

I am using poedit with zend_translate.
I have done everything required in zend. I have created some sample code in zend view files
$this->translate("Hello");
I have then created a new catalog in poedit.
I specified the initial settings (like base directory, translation function)
I edited php parser tab:
a) *.php to *.php;*.phtml
b) adding '-L php'
Then also its not getting any strings.
Anyone has any idea what i am doing wrong.
Under catalog settings, go to "Keywords" and add "translate" — that should fix it.