Saturday, April 11, 2009

Providing custom images for the outline view in Xtext/TMF

Recently I asked a question on the openArchitectureWare forum, how I can change the default image in the outline view of Xtext/TMF. Christian Dietrich was able to give me the correct hints. You can follow the discussion there, and below is a working example of the implementation of my LabelProvider. As you can see it works slightly different. The nice thing is, that due to the generated DSL classes, it is easier now to access the information from the model and static polymorphism more efficiently.


public class AnalysisLabelProvider extends DefaultLabelProvider {

public Image image(Actor actor) {
String image = (actor.isSystem() ? "/icons/Node.gif"
: "/icons/Actor.gif");
return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream(image));
}

public Image image(UseCase useCase) {

return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream("/icons/UseCase.gif"));
}

public Image image(Information information) {
return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream("/icons/Class.gif"));
}

public Image image(Analysis analysis) {
return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream("/icons/Model.gif"));
}

public Image image(Issue issue) {
return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream("/icons/Comment.gif"));
}

public Image image(Step step) {
return new Image(Display.getDefault(), AnalysisLabelProvider.class
.getResourceAsStream("/icons/StructuredActivityNode.gif"));
}
}

That's it. The rest can be seen from the discussion. Link provided above. Oh, one more thing: you need to add the icons folder to your plugin resources! The implementation could also be made more efficient (prevent loading of images again and again).

Thursday, April 9, 2009

ODA Ecore and EMF Query

By accident I already published this article before actually writing this, so it appears in the news feed. Hence the briefest of brief contents:

At http://timezra.blogspot.com/2008/04/oda-ecore-getting-started-guide.html (written by Tim Myer) you will find a very nice description on how to use Ecore Modells as an ODA Datasource, and connect the result to BIRT. I just tested it again using BIRT 2.50 and Eclipse 3.5. Worked like a charm.

I will write more about EMF Queries when I find the time.

Tuesday, April 7, 2009

Wittgensteins take on languages

Having spend half of my life learning UML and with a keen interest in designing domain specific languages, I had to smile when I came accross this quote. Makes for a nice thought. In which language do you guess, you get lost first? How do we design a language so that we do not get lost. Or to quip: "Worüber man nicht sprechen kann, darüber soll man schweigen."
[rough translation into English: "Language is a maze of different paths. You come from one location and you know your way around; you come from another path to the same location, and you don't find your way."]

Monday, April 6, 2009

EMF Reference Card

A very nice reference card about EMF is available from dzone.org. It has been written by Ed Merks and James Sugrue, so that you can trust the information inside.



The reference cards by dzone are usually covering a wide range of topics. I find them quite valuable for exactly the kind of purpose they were designed for: give a reference.

Saturday, April 4, 2009

Architecture


In a recent blog article by Adam Bien, he pointed out that a perfect architecture is one, where there is nothing left for deletion. I agree. Ever in search to look at things at a different perspective, I recently started reading quite a few things about "real" architects and designers, thus not software related, but building related. It is amazing how many of the problems are totally similiar. Hence I'd like to share my favorite quote with you.

Thursday, April 2, 2009

openArchitectureWare and Enterprise Architect UML

Today we released a new version of the Enterprise Architect adapter to the Eclipse UML2 model. With that and additional helper classes, such as a workflow component, it is possible to use Enterprise Architect and openArchitectureWare.

I will post a small tutorial blog entry soon, demonstrating the use of the tool support. The maven artifacts and direct downloads can be found at:
http://components4oaw.sf.net. A release description here: http://components4oaw.sourceforge.net/ea_toolsupport/release.html. An eclipse update site is on the todo list. Actually as the person resonsible to do the releases, I had higher expectations when I decided to use maven, but with multiproject builds it is a plain nightmare to do releases.I will keep it probably to get the reporting and website updated, for which it is reasonably useable.

Wednesday, April 1, 2009

Unit tests to check against cyclic dependencies

Some sample code to write a unit test which checks the project for cyclic dependencies. It is using a paramerized Test class, where each package is passed to the constructor of the test object. It uses jdepend  to  analyse the project based on the compiled class files located in the directory 'target/classes'.


@RunWith(Parameterized.class)
public class JDependTest {

     private static JDepend jdepend = null;
     private static Collection packages = null;
     private JavaPackage pack1 = null;

     @Parameterized.Parameters
     public static Collection data() throws IOException {
         Collection result = new ArrayList();
        jdepend = new JDepend();
        jdepend.addDirectory("target/classes");
        packages = jdepend.analyze();
        for (Object p : packages) {
            result.add(new Object[]{p});
        }
        return result;
     }
     
    public JDependTest(JavaPackage pack) {
        pack1 = pack;
    }
    @Test
    public void cycleTest() {
        assertFalse(pack1.getName() + " failed", pack1.containsCycle());
    }
}

This is the output in Netbeans. It could be improved by adding the cycles which have been detected, but that can also be seen in the jdepend report.