Mittwoch, 21. Juli 2010

android API source JAR

Howto

A few days ago I installed the android SDK and the ADT plugin for eclipse. When I started playing with the android API I was a little disappointed. I was missing the source attachment for the android.jar which contains the android API. I was searching the web for the android sources jar and found a guide how to create an android sources jar [1].

I've adapted the sources howto and created my own android sources jar for android platform 7 aka android 2.1. You can download it here: http://www.bughome.de/android/platforms/android-7/android-src.jar

I'm pretty sure that the android-src.jar is missing some sources, because the source jar is smaller than the binary jar. Comment me if you find the missing sources.

References

  1. http://androidforums.com/android-developers/1045-source-code-android-jar.html

Freitag, 9. Juli 2010

implementing a new eclipse remote control command

Introduction

eclipse remote control is an eclipse plugin which allows to execute remote commands within eclipse. Right now it's pretty limited to a very few number of commands. Currently you can open a file and launch a build command. Launching commands is done via the java client application.

Implement a command

To create a new command you have to implement a few classes within eclipse remote control. So you have to check out the eclipse remote control source from the github repository: git://github.com/marook/eclipse-remote-control.git

Implementing a new command requires the following steps:

  1. Implement a communication class. This class contains the data which is sent from the eclipse remote control client to the eclipse remote control plugin in the eclipse IDE.
  2. Extend the eclipse remote control. You need to parse the client's command line arguments and create an instance of your communication class.
  3. Implement a command runner. The command runner contains the actual work which is performed when the command is executed within eclipse.

Implement communication class

The communication classes are located in the com.github.marook.eclipse_remote_control.command project. Add a new java class to the com.github.marook.eclipse_remote_control.command.command package. Your new command class must implement the abstract Command java class from the same package.

The communication class must set a unique ID. This ID is used to identifiy commands in the eclipse remote control plugin. The unique ID is passed to the Command constructor.

The communication class contains all the information which is sent from the eclipse remote control client to the eclipse remote control plugin. So the communication class needs to contain fields for all transfered information. Also you have to add getter and setter methods for all the fields.

All communication classes implement the Serializable interface. Make sure your command class and the command class's fields implement the Serializeable requirements.

Extend eclipse remote control client

The client is implemented in the com.github.marook.eclipse_remote_control.client project. The client creates command classes from command line arguments and sends it to the eclipse remote control plugin. To create and send your command class you have to add the parse and send code to the com.github.marook.eclipse_remote_control.client.Client class's main method. The following listing is an example of the parse and send code for the open file command:

if("open_file".equals(command)){
 if(args.length < 2){
  printUsage(System.err);
    
  System.exit(1);
    
  return;
 }
   
 final OpenFileCommand cmd = new OpenFileCommand();
 cmd.setFileName(args[1]);
   
 fireCommand(cmd);
}

Implement command runner

Here comes the actual work. You have to implement a command runner which executes the command within the eclipse instance. All command runners are implemented within the com.github.marook.eclipse_remote_control.run project. Create a new command runner class in the com.github.marook.eclipse_remote_control.run.runner.impl.simple.atom package. All command runnerst must implement the ICommandRunner interface from the same project. For your convenience you should use the AbstractAtomCommandRunner superclass for your command.

The commands's work is implemented in the command runner's internalExecute(...) method. This method is specified by the ICommandRunner interface.

At last you must register the command runner in the SimpleCommandRunner class. Add a putAtomRunner method call to the static block in the SimpleCommandRunner class. Right now this static block contains only two registrations:

static {
 putAtomRunner(new OpenFileCommandRunner());
 putAtomRunner(new ExternalToolsCommandRunner());
}

Basically that's all you need to do for a new command. If you need more information check out the eclipse remote control source code. Read the source from the existing commands. I think this will be the best for getting started.

Sonntag, 18. Oktober 2009

xtext for recipes

Yesterday I was at my parent's place. The weather wasen't very well so we enjoyed one of my mother's delicious dishes for dinner. At that time my mother and my girl friend started to exchange recipes and I started to think about writing a cookbook. It's more like a male cookbook... that's why I think the following aspects should matter the most for my book:
  • You should get a fast overview about the dish
  • More headwords than prose
I thik both of these aspects can be reached by using a diagram notation. My diagram should be some kind of UML sequence diagram which looks like a UML flowchart diagram. Recipes should have a defined start state and multiple operations which can occure in parallel. As I am more one of the text guys I prefere a textual notation for the recipies. The diagram should be generated from the textual recipe notation. The idea is a TeX approach: Define your document in a specialized language, then render the document. As cooking is much like executing a Makefile :-) there should be many subtasks which depend on each other. Dependencies are very easy for humans to express and dependencies are enough for the recipe generator to determine which tasks can be executed in parallel. So last but not least here is my recipe language draft. I mixed the concepts from above with some meta information about the ingredients, cooking duration, etc.
measure Prise {
}

measure Gramm {
}

measure Liter {
}

measure Blaetter {
}

ingredient Wasser;
ingredient Salz;
ingredient Nudeln;
ingredient Tomatenmark;
ingredient Basilikum;

recipe Tomatennudeln {
     step WasserKochen {
             title "Wasser zum kochen bringen";

             ingredient 0.5 Liter Wasser;

             duration 10 minutes;
     }
     step WasserSalzen {
             title "Wasser salzen";

             ingredient 1 Prise Salz;

             duration 10 seconds;
     }
     step NudelnInWasser {
             title "Nudeln weichkochen";

             depends WasserKochen;
             depends WasserSalzen;

             ingredient 200 Gramm Nudeln;

             duration 5 minutes;
     }
     step NudelnAbgiessen {
             title "Nudeln abgiessen"
          
             depends NudelnInWasser

             duration 30 seconds;
     }
     step TomatenmarkErhitzen {
             title "Tomatenmark wuerzen und erhitzen"

             depends NudelnAbgiessen;

             ingredient 10 Blaetter Basilikum;

             duration 2 minutes;
     }
     step AllesVerruehren {
             title "Nudeln und Tomatensosse verruehren"

             depends NudelnAbgiessen;
             depends TomatenmarkErhitzen;

             duration 30 seconds;
     }
  
}
Hopefully I will get some time soon to implement a prototype using TMF Xtext.

Dienstag, 11. August 2009

Wally sagt: "Der Tüchtige hält immer möglichst viele SVN-Locks."