How to programmatically new a java class which implements sepecified interface in eclipse plugin development

时间:2021-10-04 00:06:20

http://w3facility.org/question/how-to-programmatically-new-a-java-class-which-implements-sepecified-interface-in-eclipse-plugin-development/

OpenNewClassWizardAction wizard = new OpenNewClassWizardAction();

wizard.setOpenEditorOnFinish(false);

NewClassWizardPage page = new NewClassWizardPage();

page.setPackageFragmentRoot(sourceFolder, false);

wizard.setConfiguredWizardPage(page);

wizard.run();

return (IType) wizard.getCreatedElement();

add more here:

check which button use is clicked,

if finished button is clicked : wizard.getCreatedElement() will not return null ,otherwise it will return null value.