Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Saturday, 14 February 2009

Playing with Jazz

Last night I downloaded a copy of Rational Team Concert, having just heard about the Jazz project.

Having started it up I started to work through the tutorials and was, quite frankly, blown away by what it could do. I'm a big fan of Mylyn on eclipse and the way it can focus you on a single task at a time. Jazz (or Concert, not sure where the boundaries lie right now) seems to take the task oriented development and expand it well beyond the bounds of the coding. It integrates your task/bug tracking with your coding and testing, your commits are associated with the results of your automated tests all in a structured workflow. It also allows for planning your releases, iterations and working hours.

It can also be used to enforce your processes, though I have yet to see how to set it up, but a couple of examples are that a new developer's code will not be committed until it has been reviewed by a more experienced developer (and will create a task for the experienced developer with the code attached), or that code containing warnings cannot be committed.

To do all this, it provides it's own bug/task tracking system, project planning tools and a source control system. The tracking system and the project planning are quite straight forward, but the source control system is a little different to what I'm used to and I have yet to get my head around it. It is made up a streams, I think, and these streams can belong to individuals or teams. You work in your own stream, then when your are done, you integrate it into the team stream, on larger projects you then integrate that into another stream, and so on up.

Sunday, 26 October 2008

Geoff on GEF pt. IV

Wow! Things are now really falling into place.

Most of my effort recently has been spent trying to get my GEF ViewPart to display in a seperate window, as a nice touch I wanted it to display in fullscreen on a second monitor if one is available. Amazingly, I've done it.


@SuppressWarnings("restriction")
@Override
public void run() {
Display display = Display.getDefault();
Monitor[] monitors = display.getMonitors();

Monitor lastMon = monitors[monitors.length - 1];
Rectangle bounds = lastMon.getBounds();

try {
IWorkbenchWindow window = Workbench.getInstance().openWorkbenchWindow("org.gamingclubnetwork.tournament.perspective.display", null);

Shell shell = window.getShell();
shell.setMenuBar(null);
shell.setLocation(bounds.x, bounds.y);
shell.setFullScreen(monitors.length > 1);
}
catch (WorkbenchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


First of all we look for all available monitors and grab the last one (I assumed the secondary display will be used for projectors or large monitors).
With that done, the trick is to open a new workbench window specifying a new perspective that contains just my GEF view. I then grab the shell of this workbench, remove the menu bar, set it's location to the top corner of the monitor to show it on and then set to full screen if not on the primary display.

Friday, 24 October 2008

Geoff on GEF pt. III

I tracked down the reason for my figures not appearing to the layout used in my root figure. I was using the XYLayout from the example, changing it to the ToolbarLayout immediately produced the desired results. e.g.

@Override
protected IFigure createFigure() {
Figure f = new Figure();
f.setOpaque(true);
f.setLayoutManager(new ToolbarLayout());
return f;
}


I can now plough on and create edit parts and figures for the remaining components of my model.

One of the problems I encountered when using the ttolbar layout, is that shapes I have defined are not appearing as expected, is the short term I have replaced them with Labels containing just icons, but I think I will have to revisit this in the future.

Thursday, 23 October 2008

Geoff on GEF pt. II

So, carrying straight on from last night, I fixed the null pointer and now have an empty view displaying. The trouble is, as soon as I plugged in the listeners and updated the children of the EditPart when the model changed, I still get an empty view.

After some investigation I discovered that the following code can be used in a ViewPart to display a GEF diagram.


@Override
public void createPartControl(Composite parent) {
DefaultEditDomain defaultEditDomain = new DefaultEditDomain(null);

sgv = new ScrollingGraphicalViewer();

defaultEditDomain.addViewer(sgv);
sgv.createControl(parent);
ScalableRootEditPart sffrep = new ScalableRootEditPart();
sgv.setRootEditPart(sffrep);
sgv.setEditPartFactory(new TournamentEditPartFactory());

sgv.getControl().setBackground(ColorConstants.listBackground);

initView();
}

private void initView() {
sgv.setContents(TournamentManager.get());
}


However, my diagram is still not displaying as expected...

Wednesday, 22 October 2008

Geoff on GEF pt. I

It's been about 4 years since I last worked with the Graphical Editing Framework, or GEF, in eclipse. I have recently been working on a new application using eclipse RCP to manage tournaments (specifically wargaming events).
Anyway, I have a basic application up and running now and intend to add an additional feature to allow for real-time information to be displayed on a seperate screen (or projector). For this feature I've decided to use GEF once more.
As I said, it has been about 4 years since I last used GEF and I recall that it was a little tricky to get started with. This time around I have decided to document my experience as I develop this new functionality.

To get things started, I paid a visit to the GEF homepage and jumped straight into the tutorial referenced there. The tutorial starts by stating that an updated version was posted in March 2007, not a good sign if the homepage does not point to the more up-to-date documentation.
Skipping quickly over the first section, that explains the MVC architechture, I wrote a couple of EditParts as described, then decided to create a view to display them. Now, the tutorial only deals with creating an editor, not a view. So after some googling I found this post on creating a view for GEF.

One of the methods called is setEditPartFactory(), I know from experience that the Edit Part Factory is a core piece of functionality that creates controllers (EditParts) from your model. I was stunned to find that the Edit PartFactory was not described in the tutorial. I threw one together from memory (see below) to confirm that I could get a view to display.

On launching the app, the view displayed, but there was a null pointer when getting the children of my root object, not really a surprise as I had yet to populate it. Anyway, that was enough for one night. I shall continue to work on it tomorrow.

The content of my EditPartFactory (simply implements EditPartFactory):

public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if(model instanceof TournamentData)
{
part = new FloorplanEditPart();
}
else if(model instanceof Game)
{
part = new GameEditPart();
}

if(part != null)
{
part.setModel(model);
part.setParent(context);
}
return part;
}