PrayogShala

"You've got to experiment to figure out what works" – Andrew Weil

Time for a break

leave a comment »

After my system crashed this Monday, I got the partition of hard disk formatted that had Windows XP Professional OS. However, during formatting of the system, another partition (that had almost 60 GB (out of 80 GB) of Free and Open Source Softwares, I have been using or wanted to use over the past years) was inaccessible.

Along with that, I had so many code I wrote to learn some concepts/technologies, etc. which was partially version controlled. I had to format it, there was no way to recover AFAIK. So, everything was lost, including the copies of  source code for FOSS like NetBeans, Flex Builder, etc. By the way, I would be leaving for Training at an IT company (in India) this Sunday and not even in worst nightmares thought this could happen. Now, I just have a formatted drive having approx. 80 GB free space. What a waste!

Anyways, I am not in a mood to download and setup the same again. I had enough of these failures/system-crashes in the past 4 years, and as I don’t have a laptop, I won’t be any longer available on the internet. Frequency of blogging would surely decrease, as I would no longer be able to devote time to FOSS and related stuff.

Indeed, its time for a break.. See ya later!

Written by Varun

July 23, 2009 at 3:53 pm

Posted in Personal

Project NbCreole

leave a comment »

http://kenai.com/projects/nbcreole

Folks,

I have setup this project at Kenai DOT com, you may click the image above to get directed to the project website. Currently, features enabled are Wiki, Chatroom (using Pidgin/NetBeans IDE), Mailing lists and Issue Tracker.

Today, I have just added the sources for the NetBeans Project (Java Application) created using the sources provided by the Eclipse Project (XmlCreator), hosted at Sourceforge. I have made some changes in few classes and have created an Ant Task, as discussed yesterday.

This project is close to my heart and main objective is to create a suite of modules that could integrate into the NetBeans IDE. I am not sure about the timeline, however I will keep blogging about the same over this blog. Also, I’m not looking for new members for the project.

However, I’m more keen on learning the technologies that will help me complete the objective. Technologies will comprise of ANTLR, NetBeans Platform, Java, XML, XSLT, etc. Anyways, you’re welcome to join the mailing lists and provide comments/suggestions.

Stay tuned..

Written by Varun

July 17, 2009 at 4:17 pm

Posted in JIRA, Kenai, NetBeans, SVN, Wiki

Wiki to XML using Ant

with one comment

Folks,

I have been working hard for the past few days, so that I could write an Ant task that could simplify the task of converting WikiCreole Markup to XML format. This conversion was made possible due to the efforts of Martin Junghans and Dirk Riehle. They did research on this subject. As a result, they created an EBNF grammar and an XML interchange format (Creole 1.0).

Brief History

Basically, my friend (Arunesh Bahadur) had checkout the sources from SourceForge, this year. Firstly, he used ANTLR to generate the Lexer and Parser files from given grammar file, using a system that had atleast 2 GB RAM.

He re-used the code and made few new classes, just for the sake of running the project and checking the workflow. It worked, sample files having wikicreole markup content were converted to XML format using the XML Schema, defined in Riehle’s and Martin’s second research paper.

CreoleTask

As I want to create support for the same in the NetBeans IDE. The NetBeans IDE makes good use of Ant and Maven, so I wanted to create a task of my own that will take care of the necessary classes that are required to make it possible to convert Wiki to XML. Today, I spent time learning about writing Ant Tasks and this is what I got;

public class CreoleTask extends Task {

 private String gLoc = "creole10.g";
 private String wikipage;

 @Override
 public void execute() throws BuildException {
   ParserHandler ph = new ParserHandler(new Grammar(gLoc));
   if (wikipage == null) {
     throw new BuildException("File not found..");
   }
   wikipage = wikipage.replace('/', '\\');
   log("Importing wikipage " + this.wikipage);
   ph.parseWp(this.wikipage);
 }

 public void setWikipage(String wikipage) {
   this.wikipage = wikipage;
 }
}

Now, what I need is the JAR that contains CreoleTask.class. So, I created a Java Application using NetBeans IDE and opened its build.xml;

<project name="CreoleAnt" default="default" basedir=".">
    <description>Builds, tests, and runs the project CreoleAnt.</description>
    <import file="nbproject/build-impl.xml"/>
</project>

This file contains comments as well;

There exist several targets which are by default empty and which can be used for execution of your tasks. These targets are usually executed before and after some main targets.

I have done this before, i.e. I override an empty target to deploy war file on build. Today, I overriden target -post-jar and added the following;

    <property name="wiki.dir" value="${basedir}/wikipages"/>    

    <target name="-post-jar" depends="-init-project">
        <antcall target="-xml-to-creole"/>
    </target>

    <target name="-xml-to-creole">
        <taskdef name="creole" classname="creole.ant.CreoleTask"
        classpath="${dist.jar}"/>
        <creole wikipage="${wiki.dir}/description"/>
    </target>

As you can see, I added a dependency on target -init-project, that’s because I wanted to reuse the property created in project.properties by NetBeans IDE. In my case, I reused  dist.jar property and created new one, wiki.dir. So, I have kept few samples in wikipages directory under the basedir, i.e. project’s root directory. Now, I define a task with the name creole which maps to CreoleTask.

Attribute wikipage maps to setter method of private variable wikipage. Its not a bean class, so its not necessary that the setter method relates to the private members. As shown above, I have passed ${wiki.dir}/description.txt as parameter to the setter method and that’s used by execute method. This method is overriden to run your own code. Its called automatically by Ant, whenever there’s tag present for the defined task.

Its just the beginning, exploration continues!

<property name=”wiki.dir” value=”${basedir}/wikipages”/><target name=”-post-jar” depends=”-init-project”>
<antcall target=”-creole-to-html”/>
</target><target name=”-xml-to-creole”>
<taskdef name=”creole” classname=”creole.ant.CreoleTask”
classpath=”${dist.jar}”/>
<creole wikipage=”${wiki.dir}/description”/>
</target>

Written by Varun

July 17, 2009 at 12:43 am

Posted in Ant, NetBeans, SourceForge, Wiki, XML

SVN, Batch Scripts and NetBeans Platform

leave a comment »

Wrote a single-line batch program to add the sources of NetBeans Platform to the local working copy at my system. Recently, I had downloaded the sources for NetBeans Platform 6.0, 6.1, 6.5 and 6.7.  Now, I want to commit and tag these sources at PrayogShala. So, I extracted the zip files and checkout the project’s root (let it be denoted by SVNROOT_DIR) on my system.

As I have SVN repository, so I can add any file/folder locally using svn add to become part of the working copy (SVNROOT_DIR). This way, when I will commit using svn commit, I will be able to commit all the locally added files.

Batch Program

This is easily done using IDE’s like NetBeans IDE. However, I was in mood to run the IDE and open 50+ projects. Then, individually commit them. So, I thought of creating a batch program for this purpose. The batch program should be run from within the working copy, as the svn add command will work only under working copy.

for /d %%X in (%1\*) do svn add %%X

Look simple, isn’t it? Well, it isn’t for a newbie like me. I had to refer internet to learn some batch programming for the purpose. Hence, I was able to code the above. You can refer to one more batch program, I wrote last month for different purpose. Although, its still related to NetBeans IDE.

Explanation

This program loops (for … in … do) through the immediate sub-directories (%%X) of the root passed as runtime argument (%1). Then, each sub-directory is added (svn add) to the working copy.

For instance, I extracted the zip file for NetBeans Platform 6.5 under C:\nb65 directory. Then, this directory will be passed as runtime argument to the batch program. As, this directory would have sources for all the netbeans module projects. Now, svn add command will automatically scan and add any files/folders found under each module project’s directory.

Further Usage

Well, one can tweak the above batch program to create a text file, that will list full-path-name of all the files, under those directories.

for /d %%X in (%1\*) do echo %%X >> list_of_files.txt

Update (July 18th)

I have created another batch file, named it nbsvn.bat

svn add %1
svn commit -m "Tagging %1 of NB 6.5" %1

When I tried to commit all the added folders at one go, I had problems. So, I changed the method, I have created the SVNROOT_DIR and added all the modules once again. Now, I will run the above script for every module found inside the SVNROOT_DIR.

for /d %%X in (%1\*) do call nbsvn %%X

Hope this helps..

Written by Varun

July 15, 2009 at 3:35 pm

Posted in NetBeans, SVN, SourceForge

WikiCreole, XML and NetBeans IDE

leave a comment »

Aug 25, 2008

I had asked a simple question to the NetBeans Community, Are you fed up of using Wiki? Feedback I got was good, if not great. Almost everyone was in favor of the plug in, I wanted to create that would enable editing wikis within NetBeans IDE.

Sep 03, 2008

Just a week later, I thought of sharing some ideas and information, I had by discussing with people on IRC, mailing lists, surfing the web and by reflecting on my experiences working with Multiview editors, not necessarily in NetBeans IDE.

Today,

I just wanted to tell you that, I have researched about the project idea, sporadically for the past 1 year. However, I am once again interested in creating such plugin that would enable you to edit wikis within the NetBeans IDE.

So, stay tuned to this blog for more updates on the project. You may read the above blogs for history of the project, which has not even started yet.

Blog Series (Contd…)
This is the 3rd part of the blog series initiated last year at http://nbguru.wordpress.com/

Written by Varun

July 14, 2009 at 1:39 am

Posted in NetBeans, Wiki, XML

Tagged with ,