Package org.eclipse.jdt.ui.actions

Examples of org.eclipse.jdt.ui.actions.OpenNewClassWizardAction


  }

  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();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.ui.actions.OpenNewClassWizardAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.