org.eclipse.jdt.ui.wizards.NewClassWizardPage Java Examples

The following examples show how to use org.eclipse.jdt.ui.wizards.NewClassWizardPage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateJavaTypeQuickfixes.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void newJavaClassQuickfix(final String typeName, final String explicitPackage, final XtextResource resource, Issue issue,
		IssueResolutionAcceptor issueResolutionAcceptor) {
	String packageDescription = getPackageDescription(explicitPackage);
	issueResolutionAcceptor.accept(issue, "Create Java class '" + typeName + "'" + packageDescription,
			"Opens the new Java class wizard to create the type '" + typeName + "'" + packageDescription, "java_file.gif",
			new ISemanticModification() {
				@Override
				public void apply(EObject element, IModificationContext context) throws Exception {
					runAsyncInDisplayThread(new Runnable() {
						@Override
						public void run() {
							NewClassWizardPage classWizardPage = new NewClassWizardPage();
							NewClassCreationWizard wizard = new NewClassCreationWizard(classWizardPage, true);
							WizardDialog dialog = createWizardDialog(wizard);
							configureWizardPage(classWizardPage, resource.getURI(), typeName, explicitPackage);
							dialog.open();
						}
					});
				}
			});
}
 
Example #2
Source File: NewClassCreationWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public NewClassCreationWizard(NewClassWizardPage page, boolean openEditorOnFinish) {
	setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWCLASS);
	setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
	setWindowTitle(NewWizardMessages.NewClassCreationWizard_title);

	fPage= page;
	fOpenEditorOnFinish= openEditorOnFinish;
}
 
Example #3
Source File: ClassGenerator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static IType generateAbstractClass(String packageName, String className, String superClassName,
        SourceRepositoryStore sourceStore,
        IProgressMonitor progressMonitor) throws Exception {

    final IJavaProject javaProject = RepositoryManager.getInstance().getCurrentRepository().getJavaProject();
    final ProjectTemplateStore fTemplateStore = new ProjectTemplateStore(
            RepositoryManager.getInstance().getCurrentRepository().getProject());
    try {
        fTemplateStore.load();
    } catch (final IOException e) {
        BonitaStudioLog.error(e);
    }
    final Template t = fTemplateStore.findTemplateById("org.eclipse.jdt.ui.text.codetemplates.typecomment");
    String tempatePattern = "/**\n*This abstract class is generated and should not be modified. */";
    t.setPattern(tempatePattern);

    final NewClassWizardPage classWizard = new NewClassWizardPage();
    classWizard.enableCommentControl(true);
    classWizard.setSuperClass(superClassName, false);
    classWizard.setAddComments(true, false);
    classWizard.setModifiers(classWizard.F_PUBLIC | classWizard.F_ABSTRACT, false);
    classWizard.setTypeName(className, false);
    classWizard.setMethodStubSelection(false, false, false, false);
    IPackageFragmentRoot packageFragmentRoot = null;
    final IResource srcFolder = sourceStore.getResource();
    packageFragmentRoot = javaProject.getPackageFragmentRoot(srcFolder);
    classWizard.setPackageFragmentRoot(packageFragmentRoot, false);
    IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(packageName == null ? "" : packageName);
    if (!packageFragment.exists()) {
        packageFragment = packageFragmentRoot.createPackageFragment(packageName, true, progressMonitor);
    }
    classWizard.setPackageFragment(packageFragment, false);
    classWizard.createType(progressMonitor);
    return classWizard.getCreatedType();
}
 
Example #4
Source File: ClassGenerator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private static IType generateImplementationClass(String packageName, String className, SourceRepositoryStore sourceStore,
        IProgressMonitor progressMonitor)
        throws Exception {
    final IJavaProject javaProject = RepositoryManager.getInstance().getCurrentRepository().getJavaProject();

    final IType abstractConnectorType = javaProject.findType(AbstractConnector.class.getName());
    final IType abstractFilterType = javaProject.findType(AbstractUserFilter.class.getName());
    String abstractClassName = "Abstract" + className;
    if (packageName != null && !packageName.isEmpty()) {
        abstractClassName = packageName + "." + abstractClassName;
    }
    final IType classType = javaProject.findType(abstractClassName);
    if (classType == null) {
        throw new ClassNotFoundException(abstractClassName);
    }
    final ITypeHierarchy hierarchy = classType.newTypeHierarchy(javaProject, progressMonitor);
    String tempatePattern = null;
    if (hierarchy.contains(abstractConnectorType)) {
        tempatePattern = "/**\n*The connector execution will follow the steps" +
                "\n* 1 - setInputParameters() --> the connector receives input parameters values" +
                "\n* 2 - validateInputParameters() --> the connector can validate input parameters values" +
                "\n* 3 - connect() --> the connector can establish a connection to a remote server (if necessary)" +
                "\n* 4 - executeBusinessLogic() --> execute the connector" +
                "\n* 5 - getOutputParameters() --> output are retrieved from connector" +
                "\n* 6 - disconnect() --> the connector can close connection to remote server (if any)\n*/";
    } else if (hierarchy.contains(abstractFilterType)) {
        tempatePattern = "/**\n*The actor filter execution will follow the steps" +
                "\n* 1 - setInputParameters() --> the actor filter receives input parameters values" +
                "\n* 2 - validateInputParameters() --> the actor filter can validate input parameters values" +
                "\n* 3 - filter(final String actorName) --> execute the user filter" +
                "\n* 4 - shouldAutoAssignTaskIfSingleResult() --> auto-assign the task if filter returns a single result\n*/";
    }

    final NewClassWizardPage classWizard = new NewClassWizardPage();
    classWizard.enableCommentControl(true);

    final ProjectTemplateStore fTemplateStore = new ProjectTemplateStore(
            RepositoryManager.getInstance().getCurrentRepository().getProject());
    try {
        fTemplateStore.load();
    } catch (final IOException e) {
        BonitaStudioLog.error(e);
    }
    final Template t = fTemplateStore.findTemplateById("org.eclipse.jdt.ui.text.codetemplates.typecomment");
    t.setPattern(tempatePattern);

    classWizard.setSuperClass(abstractClassName, false);
    classWizard.setAddComments(true, false);
    classWizard.setModifiers(classWizard.F_PUBLIC, false);
    classWizard.setTypeName(className, false);
    classWizard.setMethodStubSelection(false, false, false, false);
    IPackageFragmentRoot packageFragmentRoot = null;
    final IResource srcFolder = sourceStore.getResource();
    packageFragmentRoot = javaProject.getPackageFragmentRoot(srcFolder);
    classWizard.setPackageFragmentRoot(packageFragmentRoot, false);
    IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(packageName == null ? "" : packageName);
    if (!packageFragment.exists()) {
        packageFragment = packageFragmentRoot.createPackageFragment(packageName, true, progressMonitor);
    }
    classWizard.setPackageFragment(packageFragment, false);
    classWizard.createType(progressMonitor);
    return classWizard.getCreatedType();
}
 
Example #5
Source File: OpenNewClassWizardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Sets a page to be used by the wizard or <code>null</code> to use a page initialized with values
 * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
 * @param page the page to use or <code>null</code>
 */
public void setConfiguredWizardPage(NewClassWizardPage page) {
	fPage= page;
}