public void exec() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
ApexClassWizard a;
try {
String[] arguements = new String[1];
arguements[0] = convertPage.getAsyncTrue().toString(); //checks if we want async methods
generator.generate(arguements);
//we have all of the generated classes now
Iterator<String> ii = generator.getAllClasses().iterator();
Iterator<String> jj = generator.getAllClassNames().iterator();
allPackages =
ContainerDelegate.getInstance().getServiceLocator().getProjectService()
.getProjectPackageListInstance();
while (ii.hasNext() && jj.hasNext()) //this loop here purely for checking if the class name is already used
{
String classBody = ii.next().trim();
String className = jj.next().trim();
a = new ApexClassWizard(true, allPackages);
ApexClassWizardPage ap = new ApexClassWizardPage(a);
ApexClassModel apexClassModel = (ApexClassModel) ap.getComponentWizardModel();
a.init(currentWorkBench, initialSelection);
Component apexComponent = apexClassModel.getComponent();
apexComponent.setBodyFromTemplateString(classBody);
apexComponent.setName(className);
if (!ap.getComponentController().isNameUniqueLocalCheck()) {
throw new IOException("There is already a class named " + className);
}
}
Iterator<String> i = generator.getAllClasses().iterator();
Iterator<String> j = generator.getAllClassNames().iterator();
while (i.hasNext() && j.hasNext()) //this loop for creating apex classes by programmatically using the ApexClassWizard
{
String classBody = i.next();
String className = j.next();
a = new ApexClassWizard(true, allPackages);
ApexClassWizardPage ap = new ApexClassWizardPage(a);
ApexClassModel apexClassModel = (ApexClassModel) ap.getComponentWizardModel();
a.init(currentWorkBench, initialSelection);
Component apexComponent = apexClassModel.getComponent();
//set the body and class name of the component
apexComponent.setBodyFromTemplateString(classBody);
apexComponent.setName(className);
if (!i.hasNext() && !j.hasNext()) {
//this is the last class we are creating for this wsdl, so we want to save the packagelist to the server
MultiClassComponentController c =
(MultiClassComponentController) ap.getComponentController();
c.setShouldSaveToServer(true);
}
if (ap.getComponentController().isNameUniqueLocalCheck()) {
a.executeCreateOperation();
}
}
} catch (ForceProjectException e) {
MessageDialog dialog =