}
private void createJavaFile(final IResource resource) {
Assert.isNotNull(resource);
final OpenNewClassWizardAction action = new OpenNewClassWizardAction();
final NewClassWizardPage ncwp = new NewClassWizardPage();
ncwp.setTypeName(resource.getName().replaceAll("\\.html", ""), true);
final IJavaProject javaProject = JavaCore.create(resource.getProject());
IPackageFragmentRoot root = null;
try {
final IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
root = roots[i];
break;
}
}
ncwp.setPackageFragmentRoot(root, true);
} catch (final JavaModelException e) {
}
final String os = root.getParent().getPath().toPortableString();
final String fp = root.getResource().getFullPath().toPortableString().replaceFirst(os, "").substring(1);
final String ps = resource.getProjectRelativePath().toPortableString().replaceFirst(fp, "");
String pn = ps.replaceFirst(resource.getName(), "").substring(1).replaceAll("/", ".");
pn = pn.substring(0, pn.length() - 1);
ncwp.setPackageFragment(root.getPackageFragment(pn), true);
ncwp.setSuperClass("org.apache.wicket.markup.html.WebPage", openJavaFile());
action.setConfiguredWizardPage(ncwp);
action.setOpenEditorOnFinish(true);
action.run();
}