PDA

View Full Version : included an external class with my project



mholland
06-09-2004, 01:37 PM
I would like to include a few "utility" java classes with my project to handle some custom validation, etc... that I will be doing on several different dialogs. Rather than cut and paste code among the different dialogs, as well as among silent, console, and swing in each dialog event area, I figured I would write some external classes that I can compile against and then build into my project.

I tried several methods to get the code in to my project by reading newsgroups, etc... but have been unsuccessfully.

So far, I have tried the following:
1) Compile class into package com.test under the ISX/Unversal Installer/classes directory
2) Under Tools->options->compiler options, I added my classfile to the classpath.
3) I created a custom event, and overrode the "build" method to look like the following:
public void build(WizardBuilderSupport support)
{
try
{
support.putClass("com.test.Test");
}
catch (IOException e)
{
}
}

4) I added a queryEnter event to a dialog... in the class, I imported com.test.Test and then tried to use a method in Test.

Unfortunately, after all of this, I see no results... I can't compile b/c the swing class in (4) can't import com.test.Test. Furthermore, when I look at my setup.jar, I don't see com.test.Test.class included.

Any suggestions?

thanks,
mike.

mholland
06-09-2004, 05:52 PM
I have since filed a support ticket and recieved support on this... here is what I learned:

Steps to add external java file to your build:
1) Create your external java file and compile it into the ISX\Universal Installer\classes directory
2) Create a custom wizard action following the steps in the online help.
3) Override the build method of the custom wizard action, adding in putClass lines for each class that you want included in your build.
4) Compile your custom wizard action into the ISX\Universal Installer\classes directory (so it would look like: classes\com\company\installer\TestCustomAction.java
5) Tools->options->compiler options: add the directory that your class files are in

Use the "add in manager" to add your custom action class to the project.

Now, you can use your external class in a dialog, etc.... just include it in the import statements and then use away!

mike.

mholland
06-09-2004, 05:53 PM
As a point of reference, here is my custom class:

package com.<mycompany>.collab.installer;

import java.io.*;
import java.util.*;

import com.installshield.wizard.*;
import com.installshield.util.*;

public class ImportClassesBean extends WizardAction
{
public void execute(WizardBeanEvent event)
{
}

public void build(WizardBuilderSupport support)
{
try
{
support.putClass("com.<mycompany>.collab.installer.Test");
}
catch (IOException e)
{
}
}
}


and Test looks like this:


package com.<mycompany>.collab.installer;

import java.util.*;

public class Test
{

public static boolean testMe()
{
return false;
}

public static boolean testMeTrue()
{
return true;
}


public static String testMeString()
{
return "yasta";
}

}