| Sign In/My Account | View Cart |
Eclipse Plugins Exposed, Part 3: Customizing a Wizard
Pages: 1, 2, 3, 4, 5, 6
Validation can be done in any part of the plugin with which the user enters data. Thus, it makes sense to put the validation code in reusable classes, rather than having multiple copies all over the place. The following is an example of a validation class.
public class InterfacesValidator implements ICellEditorValidator
{
public String isValid(Object value)
{
if( !( value instanceof String) )
return null;
String interfaces = ((String)value).trim();
if( interfaces.equals(""))
return null;
String[] interfaceArray = interfaces.split(",");
for (int i = 0; i < interfaceArray.length; i++)
{
IStatus status = JavaConventions
.validateJavaTypeName(interfaceArray[i]);
if (status.getCode() != IStatus.OK)
return "Validation of interface " + interfaceArray[i]
+ ": " + status.getMessage();
}
return null;
}
}
The other validation classes are very similar to this one--refer to the source code at the end of the article.
Another nifty class in the Eclipse arsenal is
JavaConventions, which validates this data for us! It
contains many validation methods, such as:
validateJavaTypeName() to check class and
interface names.validatePackageName() to check package names.validateFieldName() to check data member
names.validateMethodName() to check method names.validateIdentifierName() to check variable
names.The interface ICellEditorValidator is not needed
right now, but we will need it in the next article.
At this point, we have a working wizard with a graphic and a second page, which creates our initial Invokatron document. Figure 2 shows the result:

Figure 2. Customized wizard
As we've seen, it is data that often drives applications. Presentation is important, too. An ugly gizmo won't sell; a shiny one may. But data is the very nature of what we, programmers, do.
In this article, we first decided on the data we would process. Secondly, we captured visually this data in the form of a customized wizard. The next article will continue on the presentation side, with a customized editor and property page.
Emmanuel Proulx is an expert in J2EE and Enterprise JavaBeans, and is a certified WebLogic Server 7.0 engineer. He works in the fields of telecommunications and web development.
Return to ONJava.com.
Showing messages 1 through 4 of 4.
I think i am in tune with everyone here when I say that this is an excellent column. It has helped me a lot in the process of learning about developing plug-in in Eclipse. Therefore, thank you for the material so far.
But... sadly, i see that the 4th part of the column has not been posted. Is there any hope for updates?
Best regards,
mariusp