First Generator Model Tutorial for Acceleo - acceleo

I am new to Eclipse and Acceleo, and I have been trying to complete the First Generator Model Tutorial. I am using Juno 4.2 and Acceleo 3.3.
Here is what I have done so far:
I created an Accelo projece with a UML Metamodel and Generate
Type Class.
I added the provided code for the generate file, and
put the [comment #main/] below the template line.
I made changes to the MANIFEST file. Under the Bundle SymbolicName, I added singleton:=true. I added the files for runtime, added all the necessary plugins and under extensions, I added the UML generate and dynamic package.
I then created a new Java Project, and then selected UML Model and made it a package. I then created a class by right clicking on the package, selecting New Child and then class.
I go to launch the generate file. I selected the uml model and the target as the src file under the new Java Project. It says it is launching it, but I can not see the generated file, or it is not actually generating it.
I would really appreciate any help or feedback. I am really stuck on this!

I'm also quite new to Acceleo, but I can give it a try:
do you have a [file] construct in your generate.mtl file? Because without it Acceleo doesn't generate any file.
This is an example of usage of the [file] in the generate.mtl file. It creates a myFile.txt file with a class name inside:
[comment encoding = UTF-8 /]
[module genAFile('http:///org/eclipse/uml.... etc ')/]
[template public genAFile(aClass : Class)]
[file ('myFile.txt', false, 'UTF-8')]
[aClass.name/]
[/file]
[/template]
Hope it helps

Related

Visual Studio DSL interaction with my classes

I'm getting start with DSL, I have build my DSL and I have a T4 template for generate code from a design.
I can create a new element in my project of my DSL type, I can create my design and then I have to run my T4 to generate code.
But, I can see how to work the default Visual Studio Class Diagram, it don't need to run any T4. For example when you drop a class in the diagram it shows a dialog to choose the class name and file.
When I change a class (adding properties for example) by edit the file the diagram update itself the new information (properties, methods, ...). When you add a property in a class using the diagram its update the file adding the correct property ...
How to do it? I'm newbie and I would like to find documentation about it.

Why is Xcode not prefixing filenames?

When I start an iOS single view application project, the AppDelegate files and ViewController files are not prefixing with the project name like they used to.
files names are as follows when I open a new project:
AppDelegate.h
AppDelegate.m
MainStoryBoard.storyboard
ViewController.h
ViewController.m
Why is this?
You have to add it manually. When you create a new project just fill out the "Class Prefix" field on the screen where you name the project/bundle id/ etc..
Just add your prefix where I wrote "THIS IS THE PREFIX" in the screenshot below
If you want to add a prefix after you've created your project, you can do so in the file inspector on Xcode's right pane:
Personally, I prefer not to prefix class names within an application.
When you are writing code for libraries, or custom classes, or categories, they are recommended, as there aren't namespaces in Objective-C.
But for application classes, I find they are just noise. Looking down a list of files that all have the same three letters in the front makes it just a bit harder to find what I'm looking for.
I mean, are you really going to have more than one class called AppDelegate? I'm all for full and descriptive naming of my classes, but prefixes for all the classes doesn't help me.
If it helps there are a few conventions for writing code. Search and you'll find them. Here are mine, for example.
You don't have to follow them, but pick a style and be consistent with it.
XCode 8 does NOT have the 'Class Prefix' field. It only has 'Product Name' and this does not ripple down to the view controller or the app delegate. I think 8.3 has bugs.
Class Prefix is file & template business. For the sake of organised files in a project it makes sense to have filenames that express their contents.
The workflow to achieve that was actually simplified with the Class Prefix field in the File inspector panel while your project name is active (clicked) in the file browser.
When there is a class prefix set the class name field when creating new files is predefined. That way you can choose file by file (class by class) if you want to use it and class name and file name will result in similar name scheme.

Problem while including custom framework in Project

I am trying to learn how to create custom frameworks and use them in a project in cocoa, so I began with a simple custom framework named - SimpleFramework.
It contains one class with only one class method:
// class name: SimpleClass, role: Public
+ (void)displayMessage{
NSLog(#"Hello World");
}
I also set its Installation Directory path to - #executable_path/../Frameworks then compiled it.
I included it in another project - SimpleTest, using following steps-
Dragged SimpleFramework.framework into Frameworks folder in project. Also selected Copy items to destination group's folder and Add To Targets check box.
Created a New Copy Files Build Phase. Selected its destination as Frameworks.
Dragged SimpleFramework.framework into it.
Problem is, when I am trying to import
SimpleClass.h in SimpleTestAppDelegate
class, it is giving this error message
on compilation-
SimpleClass.h: No such file or
directory.
Can anyone suggest me if I am doing anything wrong?
Code for application can be found here- Sample code link
Thanks,
Miraaj
I found its solution. I was missing this line:
#import "SimpleFramework/SimpleClass.h"

Why can't I see a Managed Object Class file template in Xcode?

I created a .xcdatamodel Managed Object Model file in Xcode. I selected that file in Groups & Files. Then I go to File > New... > and nowhere in the iPhone Templates / Cocoa Touch Class templates I see the "Managed Object Class" file template.
Does anyone know what can be wrong?
I usually need to also select the entities for which I want to generate the class files.
In Xcode 4, select the entity in the xcdatamodeld, then choose Editor Menu > Create NSManagedObject Subclass
If you are wanting to subclass NSManagedObject then I would highly recommend talking a look at mogenerator (github). It will autogenerate the subclasses for you AND keep them in sync as you update your model. It also has the concept of machine classes vs. human classes so that you can add convenience methods, etc. without your code being stepped on each time you update your model.
I've seen this problem before as well. Solution for me was to click on a non-data model file (in Groups & Files) and then click back on the versioned data model file (and entity within it) and then try File -> New File. Alternatively, restarting xcode, selecting the data model file (and entity within it) and then trying File -> New File also worked for me.
Click On the top left where it says "Simulator 3.1.2 | debug". Change it to "IPHONE Device 3.1.2 (BASE SDK)... voila. (SAMS iphone in 24hrs?? lots of typos and incomplete procedures!)
Managed Object Class file template can be seen under "Core Data" section of new file creation option of XCode 4.
The following screenshot depicts it.
Thanks,
prodeveloper.

Best way to deploy and reference an XSLT file

In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs

Resources