X

Geertjan's Blog

  • December 15, 2009

Project-Based Customer Application (Part 2)

Geertjan Wielenga
Product Manager
Some progress on the project-based customer application. As shown yesterday, you can select one of two types of customers (e.g., "internal" or "external", for example):

But now, you can also set an icon for the customer:

...so that the project node now, instead of a generic project-level icon, has a customer-specific icon, i.e., the image of the particular customer:

I am not necessarily recommending the approach I took. There are probably definitely better ways of doing this.

Anyway, this is what I did. In the "instantiate()" method within the template's iterator, I create folders and an attribute in the System FileSystem, based on the project name and icon set in the wizard:

//Project name set in the project template wizard:
String projName = this.wiz.getProperty("name").toString();
//Project icon set in the project template wizard:
String icon = this.wiz.getProperty("icon").toString();
//Create a "Customers" folder in the SystemFileSystem:
FileObject customersFolder = FileUtil.getConfigFile("Customers");
if (customersFolder == null) {
FileUtil.getConfigRoot().createFolder("Customers");
}
//Within the "Customers" folder, create a new folder,
//using the name of the project:
FileObject customerFolder = FileUtil.getConfigFile("Customers").createFolder(projName);
//Set the location of the icon as an attribute of the folder:
customerFolder.setAttribute("icon", icon);

Then, in the "ProjectInformation.getIcon", I copy the icon into the System FileSystem, then I find it there, and return it. The last piece of this part of the code is as follows (a lot more comes before it, for the copying of the file from the user's location on disk, into the System FileSystem, via FileUtils.copyFile):

URL imageURL = new URL("nbfs:/SystemFileSystem/" + copiedFo.getPath());
return new ImageIcon(imageURL);

And now each customer in the application has a user-defined customer-specific icon, rather than one hard-coded for the project type.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha