ECLIPSE:

A De­vel­oper-friendly Tool

OpenSource For You - - DEVELOPERS -

Eclipse is an open source frame­work that pro­vides mul­ti­ple ser­vices and built-in sup­port to Java de­vel­op­ers, to help them build GUI and non-GUI based ap­pli­ca­tions. It sup­ports bind­ing of ap­pli­ca­tions to other ap­pli­ca­tions with great flex­i­bil­ity and ro­bust­ness.

Ev­ery day, we are faced with nu­mer­ous chal­lenges and in­tro­duced to many so­phis­ti­cated tech­nolo­gies to sim­plify or speed up our work. There are a plethora of tools (ba­si­cally ap­pli­ca­tions that com­plete a task) that of­fer sim­ple and quick so­lu­tions to help us to­wards our goals. Th­ese tools have be­come an in­sep­a­ra­ble part of our lives - right from the wake up caller, diet plan­ner, re­minder, time man­ager, goal man­ager, to-do-lister, mu­sic player, photo edi­tor, file man­ager, and fi­nan­cial ad­viser, to the mod­ern day blog­ger tool, col­lab­o­ra­tor, so­cial net­work­ing tools, etc. The list is only limited by the bound­aries of hu­man cre­ativ­ity.

Trip to Toolville

To en­cour­age bud­ding de­vel­op­ers to ex­plore their area of ex­per­tise and to pro­mote emerg­ing en­trepreneurs, there are com­pa­nies com­ing up with a va­ri­ety of APIs rec­om­mended for use by stu­dents, pro­fes­sion­als and SMEs. For any pro­ject that’s be­ing started from scratch, we seek the right com­bi­na­tion of tools to de­sign, code, in­te­grate, test and de­ploy. The In­te­grated De­vel­op­ment En­vi­ron­ment (IDE) is a pow­er­ful set of tools which pro­vides a sin­gle por­tal to or­gan­ise re­sources, as well as de­velop, in­te­grate, build, run and de­bug pro­grams. There are many IDEs that cater to tool de­vel­op­ment in spe­cific pro­gram­ming lan­guages.

Let’s walk through some pop­u­lar open source frame­works that help users in build­ing tools.

wxWid­gets: wxWid­gets of­fers a cross-plat­form tools li­brary for cre­at­ing C++ GUI ap­pli­ca­tions. wxWid­gets ap­pli­ca­tions run on all ma­jor OS plat­forms like Win­dows, UNIu, Mac and mo­bile plat­forms in­clud­ing Win­dows Mo­bile, iPhone SDh and em­bed­ded GTh+. It has pop­u­lar lan­guage bind­ings for Python, Perl, ouby and many oth­ers. Un­like other cross-plat­form tool­kits, wxWid­gets gives its ap­pli­ca­tions a truly na­tive look and feel, be­cause it uses the plat­form's na­tive API rather than em­u­lat­ing the GUI. The Google Drive sys­tem desk­top client uses wxPython.

Tcl/Tk: Let’s split th­ese as Tcl (Tool Com­mand Lan­guage) and Tk (Tool hit). Tcl is a script­ing lan­guage with each op­er­a­tion de­fined as a com­mand. Tk is an open source, cross­plat­form wid­get tool­kit that pro­vides a li­brary of wid­gets to de­velop desk­top ap­pli­ca­tions with a can­vas, frames, la­bels, but­tons, menus, text, etc. Tk has been ported to run on most flavours of Linux, Mac OS, UNIu, and Mi­crosoft Win­dows. The Tk tool­kit is a pro­gram­ming en­vi­ron­ment for cre­at­ing

graph­i­cal user in­ter­faces (GUI) us­ing Tcl. They can be ex­tended and em­bed­ded in other ap­pli­ca­tions eas­ily.

Eclipse: The Eclipse plat­form can be used to de­velop ap­pli­ca­tions in gava and other pro­gram­ming lan­guages (by means of var­i­ous plug-ins) in­clud­ing Ada, C, C++, COBOL, FOoToAN, Haskell, gavaScript, Perl, PHP, Python, o, ouby (in­clud­ing the ouby on oails frame­work), etc. The Eclipse SDh in­cludes the Eclipse gava De­vel­op­ment Tools (gDT), a built-in in­cre­men­tal gava com­piler and gava source files.

NetBeans: NetBeans is an in­te­grated de­vel­op­ment en­vi­ron­ment (IDE) for de­vel­op­ing ap­pli­ca­tions pri­mar­ily with gava and with other lan­guages like PHP, C/C++, and HTML5. It can run on Win­dows, OS u, Linux, So­laris and other plat­forms sup­port­ing a com­pat­i­ble gVM. The Netbeans IDE in­cludes the NetBeans pro­filer, GUI de­signer tool, and the NetBeans gava Script edi­tor. The NetBeans IDE bun­dles are tai­lored to spe­cific de­vel­op­ment needs like stand­alone, Web and mo­bile ap­pli­ca­tions. The NetBeans Plat­form al­lows ap­pli­ca­tions to be de­vel­oped from a set of mod­u­lar soft­ware com­po­nents called mod­ules, which can be ex­tended by third party de­vel­op­ers.

Qt: nt is a cross-plat­form ap­pli­ca­tion frame­work that is widely used for de­vel­op­ing ap­pli­ca­tion soft­ware with a graph­i­cal user in­ter­face (GUI), and for non-GUI pro­grams such as com­mand-line tools and con­soles for servers. nt uses stan­dard C++. nt can also be used in sev­eral other pro­gram­ming lan­guages via lan­guage bind­ings. It works on a va­ri­ety of plat­forms like Win­dows, OS u, u11, Em­bed­ded Linux, Way­land, nNu / Black­Berry 10, An­droid, iOS and VxWorks.

For the sake of sim­plic­ity, let us nar­row down our search to a list of gava IDEs that come with handy plug-ins for com­mer­cial and per­sonal use. Let us tar­get our mis­sion at the Eclipse IDE, which is con­sid­ered by many to be the best gava de­vel­op­ment tool.

Eclipse ar­chi­tec­ture

All of us are given the freedom to se­lect the best tool for any task. How­ever, most soft­ware mod­els only in­te­grate with se­lec­tive pro­grams ow­ing to de­pen­den­cies and tech­nol­ogy lim­i­ta­tions. Ad­di­tion­ally, hu­man in­ter­ven­tion is needed to man­age file and data trans­fer be­tween tools. Eclipse is a plat­form that has been de­signed to build in­te­grated Web and ap­pli­ca­tion de­vel­op­ment tools. In this ar­range­ment, loose cou­pling is achieved through the mech­a­nism of ex­ten­sions and ex­ten­sion points.

The Eclipse plat­form uses the model of a com­mon work­bench. The tools that we de­velop can plug into the work­bench us­ing well de­fined hooks called ex­ten­sion points.

A work­bench is the main Eclipse win­dow, which opens when you start the Eclipse IDE. In­side the work­bench is a work­bench win­dow, the frame that holds the menu bar, a tool­bar, a sta­tus line, short-cut bar and pages. The page re­ferred to here is the work­bench page, which sup­plies the win­dow contents, namely, the views and edi­tors.

In a real world sit­u­a­tion, you nav­i­gate to var­i­ous screens and ex­pect a cus­tomised look and feel for each screen. This func­tion­al­ity is achieved through ‘per­spec­tives’. A per­spec­tive acts as a con­tainer for views and edi­tors. It de­fines the ini­tial set of views to be shown along with their lay­outs. Ad­di­tion­ally, per­spec­tives con­trol menus and tool bars that ap­pear on the screen. Al­though per­spec­tives ap­pear to con­tain views and edi­tors, they only own the lay­out. It is the work­bench page that owns the views and edi­tors, and main­tains a ref­er­ence of how many per­spec­tives use each view.

If you com­pare a work­bench to a book, then the per­spec­tives are pages of the book. Like each page, a per­spec­tive pos­sesses a unique com­bi­na­tion of de­tails.

Now that the ba­sic or­gan­i­sa­tion of a work­bench is clear, how do I hook my tool?

Be­fore we start, you need to un­der­stand the term ‘plug-in’. It is a struc­tured bun­dle of code that con­trib­utes a func­tion to the sys­tem. The Eclipse plat­form in it­self is a built-in layer of plug-ins, each one defin­ing ex­ten­sions to ex­ten­sion points of lower-level plug-ins. When a plug-in wants to add other plug-ins to ex­tend por­tions of its func­tion­al­ity, it will de­clare an ex­ten­sion point. The ex­ten­sion point de­clares a con­tract that ex­ten­sions must con­form to. This ex­ten­sion model al­lows the de­vel­oper to ex­pand the func­tion­al­ity with the ba­sic tool­ing plat­form.

Eclipse uses OSGi as the ba­sis for its plug-in sys­tem. The OSGi (Open Ser­vices Gate­way ini­tia­tive) tech­nol­ogy is a set of spec­i­fi­ca­tions that define a dy­namic com­po­nent sys­tem for gava. Com­po­nents in the form of bun­dles can be re­motely in­stalled, started, stopped, up­dated and unin­stalled with­out re­quir­ing a re­boot. The OSGi spec­i­fi­ca­tions en­able com­po­nents to hide their im­ple­men­ta­tions from other com­po­nents while com­mu­ni­cat­ing through ser­vices, which are ob­jects that are specif­i­cally shared be­tween com­po­nents. The OSGi has a lay­ered model that is de­picted in Fig­ure 1.

A mod­ule (also called a bun­dle) here is a ready-to-de­ploy ap­pli­ca­tion (ex­e­cutable file/ jar file), the jar file of our plug-in. Th­ese ex­ten­sions are bound to a life­cy­cle. The OSGi frame­work of­fers APIs to man­age the life­cy­cle of mod­ules like in­stall, start, stop, re­fresh, up­date, and unin­stall. A bun­dle reg­is­ters zero or more ser­vices for in­ter­op­er­abil­ity. The ser­vice layer con­nects the bun­dles dy­nam­i­cally by the Pub­lish-Find-Bind model.

Thus the plat­form run­time core im­ple­ments the run­time engine that starts the plat­form base and dy­nam­i­cally dis­cov­ers and runs plug-ins. The plat­form main­tains a reg­istry of in­stalled plug-ins and the func­tion­al­ity they pro­vide.

Eclipse guno has in­tro­duced new fea­tures and has brought in a high level of flex­i­bil­ity to the pro­gram­ming. Equinox is one im­ple­men­ta­tion of OSGi and is used by the Eclipse plat­form. The Equinox run­time pro­vides the nec­es­sary frame­work to run a mod­u­lar Eclipse ap­pli­ca­tion.

What is RCP?

Eclipse oCP is a plat­form for build­ing and de­ploy­ing rich client ap­pli­ca­tions. It is based on the fa­mil­iar Eclipse plug-in ar­chi­tec­ture. oCP (oich Client Plat­form) opens the door to achiev­ing desk­top ap­pli­ca­tions writ­ten in the

gava pro­gram­ming lan­guage. The col­lec­tion of un­der­ly­ing frame­works al­lows dy­namic com­po­nent re-us­abil­ity, vast UI cus­tomi­sa­tion, plug­ging and un­plug­ging mod­ules based on user re­quire­ments, and pro­vides a rich client-side ap­pli­ca­tion.

Orig­i­nally, the Eclipse plat­form was de­signed to serve as an open tool plat­form. Start­ing with Eclipse V3.0, it was re-ar­chi­tec­tured so that its com­po­nents could be used to build any client ap­pli­ca­tion. The min­i­mal set of plug­ins needed to build a rich client ap­pli­ca­tion is col­lec­tively called the oich Client Plat­form or oCP.

The frame­work has the abil­ity to de­ploy na­tive GUI ap­pli­ca­tions to a va­ri­ety of desk­top op­er­at­ing sys­tems such as Win­dows, Linux and Mac OSu, and an in­te­grated up­date mech­a­nism for de­ploy­ing desk­top ap­pli­ca­tions from a cen­tral server. The oCP uses SWT and gFace from the Plug-in De­vel­op­ment En­vi­ron­ment (PDE). The Stan­dard Wid­get Tool­kit (SWT) is a wid­get tool­kit for gava de­vel­op­ers with por­ta­ble API for text con­trols, ra­dio but­tons, etc, used to cre­ate oCP user in­ter­faces. There is tight in­te­gra­tion with the un­der­ly­ing na­tive OS GUI plat­form, which al­lows the tool­kit to im­me­di­ately re­flect any changes in the un­der­ly­ing OS GUI look and feel. On the other hand, the gFace UI frame­work pro­vides higher-level ap­pli­ca­tion con­structs for sup­port­ing di­a­logues, wiz­ards, ac­tions, user pref­er­ences and wid­get man­age­ment. The gFace APIs are in­de­pen­dent of the work­bench ex­ten­sion points and APIs. gFace is de­signed to pro­vide com­mon ap­pli­ca­tion UI func­tion­al­ity on top of the SWT li­brary.

Such lower-level frame­works are in­te­grated to form the work­bench and struc­tured to pro­vide a cus­tomis­able por­tal, where users can add the contents in the places de­fined.

What do I need to build an RCP ap­pli­ca­tion?

First, gava ver­sion 1.6 or above needs to be in­stalled. To de­velop the plug-ins, you need the Eclipse plat­form. For Eclipse in­stal­la­tion, the lat­est of­fi­cial build can be ob­tained from http:// down­load.eclipse.org/eclipse/down­loads/

Get set and go ....

Be­fore we start with sim­ple tool de­vel­op­ment, let’s get fa­mil­iar with two con­fig­u­ra­tion files.

MAN­I­FEST.MF: This con­tains the OSGi con­fig­u­ra­tion in­for­ma­tion. The file de­scribes gava pack­ages that can be used by other plug-ins and their de­pen­den­cies.

plugin.xml: This of­fers the pos­si­bil­ity of defin­ing ex­ten­sion points and ex­ten­sions.

Let's now cre­ate a sim­ple oCP ap­pli­ca­tion. In the Eclipse IDE, go to File-> New Pro­ject. From the list, se­lect ‘Plug-In Pro­ject’.

Pro­vide the pro­ject name as com.lfy.rcp.first and press Next. Make sure you chose ‘ Yes’ for Rich Client Ap­pli­ca­tion when prompted. Now press Next and se­lect the tem­plate ‘Hello RCP’. Press Next, se­lect ‘Add brand­ing’ and then press Fin­ish. Take a look at the left pane. The view ‘Pack­age Ex­plorer’ shows up a directory struc­ture with source files, con­fig­u­ra­tion files and li­braries. Un­der source files, you will see some im­por­tant files that are re­quired for the oCP ap­pli­ca­tion de­vel­op­ment. You may also see MAN­I­FEST.MF and Plugin.xml listed in the Pack­age Ex­plorer.

We are now go­ing to start the oCP ap­pli­ca­tion. Let’s ex­e­cute our code in the IDE us­ing a run con­fig­u­ra­tion. A run con­fig­u­ra­tion de­fines which ap­pli­ca­tion or prod­uct to launch, and which bun­dles are to be made avail­able dur­ing run­time. In the Over­view tab on the cen­tral pane, click on the iaunch an Eclipse ap­pli­ca­tion link.

Fig­ure 3 shows the out­put af­ter run­ning your first oCP ap­pli­ca­tion.

This isn’t enough. We need to add contents in the form of views and menus. So let’s con­tinue to use the same oCP pro­ject. Se­lect ‘plugin.xml’ and click the tab ‘Ex­ten­sions’. Add org. eclipse.ui.views and cre­ate a new view.

Pro­vide an ID (say com.lfy.rcp.first.MyView) and name for the view. Fur­ther click on the class to cre­ate a gava class for the view. An edi­tor opens up with the cho­sen class name. Fur­nish the

code as shown be­low:

pub­lic class MyView ex­tends ViewPart {

You have to add the view to your per­spec­tive. To cre­ate a per­spec­tive, add the ex­ten­sion ‘ org.eclipse. ui.per­spec­tiveEx­ten­sions’ to your plug-in.

oight-click ‘*( per­spec­tiveEx­ten­sion)” -> New -> View’. Main­tain your view ID, which is ‘com.lfy.rcp.first.MyView’. Make the view rel­a­tive to "org.eclipse.ui.ed­i­torss", set the re­la­tion­ship to "top" and pro­vide the max­i­mum ra­tio as "0.05f". Now run the ap­pli­ca­tion. Now let’s add a menu to this. We need some com­mands to fall un­der a menu. Let’s start cre­at­ing a com­mand.

Go to ex­ten­sions and type com­mands to choose the avail­able ex­ten­sion points. Then cre­ate a new com­mand called ‘Exit’ with the ID com.lfy.rcp.first.com­mands.exit. Click on the de­fault­Han­dler to cre­ate a han­dler class for the com­mand. Type in the fol­low­ing code:

pub­lic class Ex­itHan­dler ex­tends Ab­strac­tHan­dler { @Over­ride pub­lic void cre­atePartCon­trol(Com­pos­ite par­ent) { Text text = new Text(par­ent, SWT.BOR­DER); text.setText("I am get­ting com­fort­able with RCP !");

} @Over­ride pub­lic void setFo­cus() { }

}

@Over­ride pub­lic Ob­ject ex­e­cute(Ex­e­cu­tionEvent event) throws Ex­e­cu­tionEx­cep­tion { Han­dlerUtil.getAc­tiveWork­benchWin­dow(event).close(); re­turn null;

}

}

Make sure that the fol­low­ing func­tions in the han­dler class re­turn true, for the com­mand to be ex­e­cuted. pub­lic boolean isEn­abled() {

re­turn true;

} pub­lic boolean isHan­dled() {

re­turn true;

}

Fur­ther, to use the han­dler in the menu, add the menus ex­ten­tion point, cre­ate a new menuCon­tri­bu­tion and, fi­nally, add a new menu to that as shown in fig­ure 4.

Click on (menuCon­tri­bu­tion) and set lo­ca­tionUoI to menu:org.eclipse.ui.main.menu.

Cre­ate a label ‘ File’ with id fileMenu. oight-click the menu, se­lect New-> Com­mand. Main­tain your com­mandID. Set the label to ‘ Exit’ and the tooltip to ‘Ex­its the ap­pli­ca­tion’. oun the ap­pli­ca­tion. You can see the menu ap­pear­ing with the menu item ‘ Exit’. Click on ‘ Exit’ and the ap­pli­ca­tion ex­its. To this you can add many fea­tures like a con­text menu, ta­ble edi­tors and views, di­a­logues and wiz­ards, all of which end up re­sult­ing in a ro­bust and so­phis­ti­cated tool built by YOU!!

Get­ting equipped with the right set of skills, un­der­stand­ing the un­der­ly­ing tech­nol­ogy, ex­per­i­ment­ing with new fea­tures, de­bug­ging er­rors with the help of sys­tem sup­port, the help of blog­gers and crack­ing it with your grey cells—it re­quires all of this as well as im­mense per­se­ver­ance to mas­ter a tool like Eclipse.

Fig­ure 2: New pro­ject

Fig­ure 1: OSGi lay­ered model

Fig­ure 3: Out­put of RCP ap­pli­ca­tion

Fig­ure 4: Out­put af­ter adding menu

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.