Who’s On Phirst

Official blog of Phurnace Software.

Tag >> Eclipse

Posted by: Casey Marshall on

Summer is here, which means it's time to cool off in the San Marcos river and escape the Texas heat. It's also time to download a new Eclipse -- Eclipse Galileo (3.5) released today. Phurnace Deliver builds on Eclipse technology, so I follow the latest developments in the community.

I want to highlight just a few of the features that have impressed me the most so far in Galileo, which has much general appeal for Java & web developers.

Eclipse Memory Analyzer
I've been using the Eclipse Memory Analyzer (MAT) for several months now, and it's helped me through some tricky memory leaks. MAT provides detailed memory usage reports and charts from a Java heap dump (created with jmap, for example). In the latest MAT release for Galileo, MAT has added stack frame information to the memory analysis -- you can more easily find where the leaks are, in addition to what's leaking. The new support for IBM JVM heap dumps could prove useful for diagnosing leaks, even in a live WebSphere instance. Once you get Galileo installed, here is a guide on getting started with the latest MAT, with some nice screenshots of the new stuff!

XML Tooling
If you muck around at all in large XML files (IBM WebSphere Portal snapshots come to mind), the new Web Tools Platform (WTP) release is reason enough to download Galileo. You can now test XPath queries directly on XML documents open in the editor and jump to the matching nodes. This has all sorts of potential for XSLT and custom XML parser development, but most importantly, it can be a powerful navigation tool. Read more in Eclipse Galileo: XML gets some love!

And More...
There are over 33 projects included in the Galileo release. For an overview of what else is included in Galileo, check out Eclipse Galileo - A Quick Glance on DZone and Eclipse Galileo Feature Top 10 List on EclipseSource.

In Eclipse GalileoEclipse
Comment (0) Read More...


Posted by: Casey Marshall on

At Phurnace I'm leveraging the Eclipse Modeling Framework (EMF) to streamline our development and add some exciting new features. EMF was difficult to get to know at first, if only because the modeling terminology seemed new, strange, and kind of dry. The time invested in learning EMF was well-spent; once I "got EMF", it seemed pure genius.

My initial impression of modeling and model-driven architecture was kind of comical too; I imagined (with great disdain) this self-proclaimed "enterprise architect" in an ivory tower, trying to solve all manner of problems by dragging UML diagrams around. "Of course 'real software development' is never so simple!", I'd think. Like so many other technologies, modeling is heavily diluted with enterprisey buzzwords, and there probably *are* architects in ivory towers somewhere trying to generate all their code from UML tools... but this is only a comical extreme of the modeling spectrum.

For example, consider the popular web framework Django. Django, like so many other of the dynamic-language web frameworks, provides an object-relational mapping library in which you first define... models in your application. These frameworks introspect on your definition of the models to generate parts of your web application automatically for you. "Scaffolding" in Rails, the "admin" interface and newforms in Django all demonstrate a "model-driven architecture".

As far as I'm concerned what EMF does for the Eclipse platform (or elsewhere -- EMF is not limited to the Eclipse platform) is conceptually no different. Just as Django dynamically generates forms and content based on the structure of your models, EMF can generate a UI for interacting with your models and much more. Knowing this simple fact would have helped me at a time I was struggling to learn Eclipse RCP and considering EMF; it was not entirely clear to me at first, as an outsider, what EMF exactly was, what it could do for me, and why I should use it. It would be silly and somewhat inaccurate for EMF documentation to say "EMF: It's kind of like ActiveRecord!", but in a way, that's how I've come to know & relate it.

Of course, EMF can do much more than a typical web framework's model layer. The tooling is highly adaptable to custom development workflow demands; you can customize your generated model code, or avoid code generation altogether. Models can be defined with Java code, XSD, Ecore, or dynamically at runtime. EMF brings a powerful level of introspection to modeling, since the definition of your model (Ecore) is itself a model that can be manipulated in the same way. In this respect, EMF is "turtles all the way down".

In other news, I'm looking forward to the upcoming Galileo release of Eclipse (Eclipse 3.5). I've already had a chance to try a few of the new features (native Cocoa & 64-bit Java support for OS X, improved PDE tooling) and it's looking great. Last week I became a Friend of Eclipse, a great chance to contribute back to a community that's given me so much -- plus I get early access to releases and an exclusive, blazing-fast download mirror.

In Eclipse Modeling FrameworkEclipseDjango
Comment (0) Read More...


Posted by: Shawn Spiars on

 We use the Eclipse Rich Client Platform (RCP) extensively here at Phurnace Software. Because of that and my years of experience, I was recently invited to do a presentation on the Eclipse RCP at a technical user’s group in Silicon Valley.

Preparing my talk got me thinking a lot about how Eclipse has evolved over the years and how misunderstood it often is. I think the most common misunderstanding is that Eclipse is simply a popular open source Java IDE (Integrated Development Environment). It’s true that Eclipse is a very popular open source Java IDE, but that’s just the tip of the iceberg. Eclipse is also an extensible platform for Developing IDE’s, tools, and applications.

Eclipse is built upon a mechanism for discovering, integrating, and running modules called plug-ins. A plug-in is an encapsulation of behavior and/or data that interacts with other plug-ins to form a running program. This plug-in extensibility makes it easy for third-party software tool vendors to integrate with Eclipse and/or contribute to the Eclipse Platform.

One of the coolest things about Eclipse to me, as a commercial application developer, is the extensible framework for building applications. Removing Eclipse’s IDE elements, Java support, and a few other components leaves you with a fairly comprehensive framework for building your own application. Using the Eclipse RCP gives you a huge head start when developing your own application and allows developers to focus on the core application rather than the plumbing. Another big advantage to using Eclipse RCP for your application framework is that when you need to add functionality there are so many available Plug-ins to leverage rather than writing everything yourself. For example, when Phurnace needed an XML Editor in our Phurnace Deliver product, we simply bundled the XML Editor from the Web Tools Platform (WTP) and we had an awesome, free, XML Editor as part of our offering.

For more information on the Eclipse Rich Client Platform check out these links.
Eclipse Rich Client Platform FAQ
Eclipse Rich Client Platform Wiki

In Eclipse
Comment (0) Read More...


Posted by: Shawn Spiars on

The Eclipse Resources Plug-in (org.eclipse.core.resources) is one of the handiest Eclipse plug-ins that no one ever talks about. The Resources Plug-in is rarely talked about because it works behind-the-scenes to enable other plug-ins and APIs to function well. For example, it is the Resources Plug-in that enables the Resource Navigator view to expose a tree hierarchy of all the projects, folders, and files in your Eclipse workspace.

Before we get into the details of the Resources Plug-in it's important to understand the function of the Eclipse Workspace. The Eclipse Workspace is where the Eclipse IDE stores all your development artifacts (Projects/Folders/Files). The Eclipse Workspace's resource model is very similar to a file system. All Workspace resources are backed by a real file or directory in the native file system.

The Resources Plug-in, or API, contains many interfaces to help developers access and manipulate the artifacts within the workspace. Here are a few definitions of the more common interface classes.

 

  • IResource – all artifacts in the workspace are resources
  • IWorkspace – the basis for the Eclipse Platform resource management
  • IWorkspaceRoot – a root resource that represents the top of the workspace hierarchy
  • IContainer – resources which may contain other resources (projects and folders)
  • IProject – a type of resource which groups resources into buildable, reusable units
  • IFolder – may be leaf or non-leaf resources, and may contain files or other folders
  • IFile – files are leaf resources which contain data

If you are a java developer you are probably familiar with the java.io.* class library. The java.io.File class is what java developers normally use when reading and writing files and directories. When you are working with files and directories within the Eclipse workspace you should use the Eclipse Resources API, rather than the java.io.File class. If you use the standard java.io.File class to modify files or directories within the workspace you will need to force a refresh in your viewer so the changes made to the model (resources) are visible to the user.

The screenshot below shows a Package Explorer view exposing the contents of an Eclipse Workspace. This workspace contains a single project named “My Project”. The project contains a single folder named “My Folder”, and the folder contains a single file named “deleteMe.txt”.

 

The following code snippet demonstrates how to use the Resources API to access the project, folder, and file in this workspace example. After getting a handle to the workspace file “deleteMe.txt” we use the IFile delete method to delete the file from the folder.


try {

IWorkspace workspace = ResourcesPlugin.getWorkspace();

IWorkspaceRoot workspaceRoot = workspace.getRoot();

IProject myProject = workspaceRoot.getProject("MyProject");

if (myProject.exists()) {
IFolder myFolder = myProject.getFolder("My Folder");

if (myFolder.exists()) {
IFile myFile = myFolder.getFile("deleteMe.txt");

if (myFile.exists()) {
myFile.delete(true, true, null);
}

}

}

} catch (CoreException e) {
}

This is a very simple demonstration of how to use the Resources API to access and manipulate artifacts within the Eclipse Workspace. For more information on the Resources Plug-in and the Eclipse Workspace, check out these links:

Eclipse Wiki - Resources
Eclipse Workspace Team
Eclipse.org

In Eclipse
Comment (0) Read More...


Posted by: Shawn Spiars on

From time to time I visit the Eclipse news groups to find a solution to a problem I am having with a particular area of Eclipse. Since Eclipse is such a huge platform with many projects there are many different news groups, each designed to cover a particular project or API (Application Programming Interface).

Some of my favorite Eclipse news groups are:

eclipse.platform
eclipse.platform.rcp
eclipse.platform.swt

Often while I am looking for answers in a news group I run across questions that I have already conquered and so I try to give back and help others. Recently I responded to a question about how to perform in-line editing within the cell of an SWT (Standard Widget Toolkit) table. I have included my example java program below. If you are a Java developer and somewhat familiar with SWT/JFace then you should have no problems understanding the example code. If you are new to SWT/JFace I have provided a brief summary of the primary components used to create the example.

Looking at the java code below you will see that the program contains a main method to launch the java program. The primary UI component is an SWT Table which is added to an SWT Composite. Under the table I have added SWT buttons to “Add” and “Remove” rows from the table. The SelectionListeners on the buttons handle the add and remove actions. The model for the table is a POJO (Plain Old Java Object) which I have named “Row”. A TableContentProvider and TableLabelProvider provide the content and labels for the table and the TextCellEditor provides the ability to edit the table allowing a user to type data directly into the table’s cells.


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

/**
* This is an example program showing how to use a TableCellEditor
* to allow direct editing of a table's cell.
*
* @author Shawn Spiars
*
*/

public class TableCellModifierExample {

private Table table;
private TableViewer tableViewer;

private final static String[] COLUMN_HEADINGS = {"Property",
"Value"}
;

public static void main(String [] args) {
new TableCellModifierExample();
}

public TableCellModifierExample() {
Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText("TableCellModifier Example");
shell.setLayout(new FillLayout());

createContents(shell);

shell.setSize(400, 400);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.verticalSpacing = 10;
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);

table = new Table(composite, SWT.BORDER | SWT.V_SCROLL
| SWT.MULTI | SWT.FULL_SELECTION);
table.setLinesVisible(true);
table.setHeaderVisible(true);
data = new GridData(SWT.FILL, SWT.FILL, true, false);
data.heightHint = 300;
table.setLayoutData(data);

TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);

tableLayout.addColumnData(new ColumnWeightData(10, 100,
true));
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(COLUMN_HEADINGS[0]);
column.setAlignment(SWT.LEFT);

tableLayout.addColumnData(new ColumnWeightData(15, 200,
true));
column = new TableColumn(table, SWT.NONE);
column.setText(COLUMN_HEADINGS[1]);
column.setAlignment(SWT.LEFT);

tableViewer = new TableViewer(table);
tableViewer.setColumnProperties(COLUMN_HEADINGS);
tableViewer.setContentProvider(new
TableContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());

CellEditor[] editors = new CellEditor[2];
editors[0] = new TextCellEditor(table);
editors[1] = new TextCellEditor(table);
tableViewer.setCellEditors(editors);
tableViewer.setCellModifier(new TableCellModifier());

Composite buttonComposite = new Composite(composite,
SWT.NONE);
FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL);
fillLayout.spacing = 10;
buttonComposite.setLayout(fillLayout);

Button addButton = new Button(buttonComposite,
SWT.PUSH);
addButton.setText("Add");
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Row row = new Row("", "");
tableViewer.add(row);
table.setTopIndex(table.getItemCount());
table.select(table.getItemCount()-1);
tableViewer.editElement(row, 0);
}
});

Button removeButton = new Button(buttonComposite,
SWT.PUSH);
removeButton.setText("Remove");
removeButton.addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ISelection selection =
tableViewer.getSelection();
if (selection instanceof
IStructuredSelection) {
Iterator iterator =
((IStructuredSelection)selection).iterator();
while(iterator.hasNext()) {
Object obj = iterator.next();
tableViewer.remove(obj);
}
}
}
});

return composite;
}

public class TableLabelProvider extends LabelProvider
implements
ITableLabelProvider {
public Image getColumnImage(Object element, int
columnIndex) {
return null;
}

public String getColumnText(Object element,
int columnIndex) {
Row row = (Row) element;

switch
(columnIndex) {
case 0:
return row.getKey();
case 1:
return row.getValue();
}

return null;
}

}

public class TableContentProvider implements
IStructuredContentProvider {
public Object[] getElements(Object parent) {
List results = new ArrayList();
if (parent instanceof ArrayList) {
results = (ArrayList) parent;
}
return results.toArray();
}

public void dispose() {
}

public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
}

}

class TableCellModifier implements ICellModifier {

public boolean canModify(Object element,
String property) {
return true;
}

public Object getValue(Object element,
String property) {
Object result = null;

Row row = (Row) element;

List list = Arrays.asList(COLUMN_HEADINGS);
int columnIndex = list.indexOf(property);

switch (columnIndex) {
case 0:
result = row.getKey();
break;
case 1:
result = row.getValue();
break;
}

return result;
}

public void modify(Object element, String property,
Object value) {
List list = Arrays.asList(COLUMN_HEADINGS);
int columnIndex = list.indexOf(property);

TableItem tableItem = (TableItem) element;
Row row = (Row) tableItem.getData();

switch (columnIndex) {
case 0:
String key = (String) value;
if (key.length() > 0) {
row.setKey(key);
}
break;

case 1:
String v = (String) value;
if (v.length() > 0) {
row.setValue(v);
}
break;
}
tableViewer.update(row, null);
}

}

private class Row {
private String key;
private String value;

public Row(String key, String value) {
setKey(key);
setValue(value);
}

public void setKey(String key) {
this.key = key
}

public String getKey() {
return key;
}

public void setValue(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

}

In SWTJFaceSWTStandard Widget ToolkitEclipse
Comment (0) Read More...


Posted by: Alexander Bibighaus on

Switching IDE's has always been something I feel is important to keep an open mind about. I learned this early on when I was an emacs fanatic. I started software development in a Unix/C environment where emacs and vi were the two editors of choice (or debate). Despite all of the vi/emacs wars , my experience was that both came in handy, but at different times.

I recently feel this way about Netbeans vs Eclipse in the Java IDE world. Both IDE's contribute different tools to a Java developer that are extremely useful.

Let's take Eclipse for example. I like Eclipse's efficiency. Everything takes less clicks! In addition, the SWT toolkit still feels and performs better than any Java application out there. Netbeans continues to have small quirks about it that cause discomfort for the user because the application does not behave as a normal native application. Something as simple as managing the cursor in the code does not feel natural to me. So, the “Everyday IDE” still goes to Eclipse.

On the flip side, Netbeans has far more integrated tools and wizards than Eclipse. Netbeans has a rich set of wizards and tools for mobility, J2EE, Web development etc. Moreover, the Java Profiler is excellent! The best part about Netbeans is that it is one coherent tool from a single vendor. The “Most Complete IDE” goes to NetBeans.

Netbeans Visual Development tools are the first visual tools for Java I can say I enjoyed. The best part is the ability to integrate manually written code with the visual designer and vice-versa. In addition, the visual designer generates simple code. The generated code is straightforward Java that anyone unfamiliar with the visual tools would understand. The “Most Innovative IDE” goes to NetBeans for finally giving Java a set of useful visual tools.

Eclipse has a one big leg up on Netbeans. Eclipse RCP is a fantastic development framework. It is rich in features and has a unifying effect on product development. Anyone thinking about developing a desktop application should seriously consider Eclipse RCP. The “Best Application Development IDE” goes to Eclipse because you should be developing RCP applications in that case.

In conclusion, just as vi and emacs both brought different ideas as an editor, it is worth the effort to learn both. You will find that rather wasting your time arguing for one or the other, you just have more tools in you tool chest since you tried them both!

In NetbeansIDEEclipse
Comment (0) Read More...


Posted by: Shawn Spiars on

It seems like there are more visual GUI builder products available on the market today than ever before. Visual GUI builders propose an easier way to design and create user interface components. They usually consist of a palette from which you select and drag controls or widgets onto a window, frame, or dialog. Then they provide a table or list where you can manipulate the properties of your controls (size, font, color, coordinates, etc) without requiring the user to know the subtleties’ of the syntax or layout managers. Here is a really good link if you are interested in Java GUI Builders.

Call me old fashion, but I always prefer a language editor (HTML, XML, Java, etc…) over a visual editor because I want to understand the commands I write, and I want to format and organize the code in a way that is meaningful to me so I can easily edit the code later. A good language editor will have syntax highlighting, syntax checking, command completion and various other features to assist you in developing the code, but it won’t generate the substance of the code for you.

Another type of code generation tool falls into the Model Driven Development (MDA) category. With MDD, logical models are used to capture design decisions and generate code, and sometimes the generated code is user interface code. The problem I have with user interfaces generated from models is that there is no consideration by the machine for who the user is, their technical aptitude, or the way they approach a task (workflow). The entire human experience is missing and the user interface has been reduced to a bunch of domain objects and business rules.

For example, the Eclipse Modeling Framework (EMF) can use a model to quickly generate a cool looking prototype consisting of a relational tree, object listeners, pop-up menus, and a properties view, but this in no way resembles a complex, well designed, user friendly application. And don’t be fooled into thinking you can easily tweak the generated code to get it to behave the way you want it to. I’ve spent hours and hours digging thru layers and layers of cryptic machine generated code trying to find the one line that needs to be changed to get the desired behavior.

There are plenty of MDD advocates out there who will disagree with me. Most of them are experts in modeling, but I’ve never met one who is an expert in user interface design. Since most project leads and architects today are very familiar with UML and modeling tools they often buy into the promise that MDD will save them time on their UI development. This has not been my experience.

If you do choose to use a modeling tool to generate UI code – I recommend you decouple the UI model from the back-end model. Just imagine a project where every time the back-end architect decides to change a relationship in the model the UI mysteriously breaks with no warnings.

“And that’s all I have to say about that.”

-Shawn

In Java GUIEclipse
Comment (0) Read More...


Posted by: Shawn Spiars on

When I started working with Eclipse in 2003 I would just download the plug-ins I needed from the Eclipse website, unzip them into my plugins directory, and restart Eclipse. Sometime later, the Eclipse Update Manager was introduced to help you configure your Eclipse development environment providing the ability to update your existing features and plug-ins and search for new features. I have always found the Update Manager dialogs difficult to understand and use. Customizing the Update Manager to work with my Rich Client Platform (RCP) applications has also been very difficult.

When I heard about the new Equinox p2 provisioning system at EclipseCon this year I was excited that the Update Manager was finally being replaced. However, one thing I have learned when working with Eclipse is to take a “wait and see” approach before adopting the newest and improved APIs and methodologies. So, I have been reading various blogs to see what experiences developers are having implementing p2 in their products. Here are a couple of postings that make me think that p2 may not be quite ready for prime time:

Why Eclipse Equinox P2 Update Manager Sucks

Why Eclipse Equinox P2 Update Manager is not good enough for me yet #2

If you have had a positive experience replacing Update Manager functionality with p2 in your software product I would love to hear about it.

-Shawn

 

In Eclipse
Comment (0) Read More...


Posted by: Shawn Spiars on

 Last week I attended the EclipseCon 2008 conference in Santa Clara, CA.  This was my third EclipseCon and by far my best experience.  ThisEclipseCon year there were a lot more technical sessions to choose from and overall the presentations seemed more professional than in the previous years.  I also liked that the Monday tutorials were included in the overall conference registration fee, rather than an extra charge.

I think the highlight of the conference was the key note speech of Dan Lyon (Fake Steve Jobs).   Here's a quote about Dan from the EclipseCon website.

"At his blog, fakesteve.blogspot.com, Lyons has captured the Zeitgeist, from perhaps the one place it is clearest-the point of view of Steve Jobs. In the tradition of Jonathan Swift and The Onion, he uses a pitch-perfect satirical style to deliver trenchant social commentary, reflecting on everything from the Cult of Steve and the rise of Apple ("Dude, I invented the friggin' iPhone. Perhaps you've heard of it!") to the ubiquitous influence of the tech industry on our everyday lives."

Another key note speaker was Sam Ramji, Director of Platform Strategy at Microsoft.   I think of Microsoft as the Borg and their presence at EclipseCon as another strategy to assimilate the Eclipse Community and open source.

The sessions that I found most interesting were those discussing the Rich AJAX Platform (RAP), The Rich Client Platform (RCP), and the Web Tools Platform (WTP).  I particularly enjoyed the "GWT vs RAP" presentation by Mark Russell and Dan Rubel, discussing the differences between Google Web Toolkit (GWT) and Eclipse Rich AJAX Platform (RAP) development.

If you are a software developer I would highly recommend you check out next year's EclipseCon.                 

In Open SourceEclipse
Comment (1) Read More...