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

The following examples show how to use org.eclipse.jdt.ui.wizards.NewTypeWizardPage. 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 setPackageName(NewTypeWizardPage page, URI contextUri, String packageName) {
	IJavaProject javaProject = getJavaProject(contextUri);
	String path = contextUri.trimSegments(1).toPlatformString(true);
	try {
		if(javaProject != null) {
			IPackageFragment contextPackageFragment = javaProject.findPackageFragment(new Path(path));
			if (contextPackageFragment != null) {
				IPackageFragmentRoot root = (IPackageFragmentRoot) contextPackageFragment
						.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
				IPackageFragment packageFragment;
				if(!isEmpty(packageName)) {
					packageFragment = root.getPackageFragment(packageName);
				} else {
					packageFragment = contextPackageFragment;
				}
				page.setPackageFragment(packageFragment, true);
				page.setPackageFragmentRoot(root, true);
			}
		}
	} catch (JavaModelException e) {
		LOG.error("Could not find package for " + path, e);
	}
}
 
Example #2
Source File: CreateAsyncInterfaceProposal.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fill-in the "Package" and "Name" fields.
 *
 * @param page the wizard page.
 */
private void configureWizardPage(NewTypeWizardPage page) {
  /*
   * Don't allow this to be edited. If do allow edits then we should only allow either the type
   * parameters from the sync type or no type parameters at all.
   */
  page.setTypeName(typeNameWithParameters, false);

  boolean isInEnclosingType = typeContainer instanceof IType;
  if (isInEnclosingType) {
    page.setEnclosingType((IType) typeContainer, false);
  } else {
    page.setPackageFragment((IPackageFragment) typeContainer, false);
  }
  page.setEnclosingTypeSelection(isInEnclosingType, false);
}
 
Example #3
Source File: NewCUUsingWizardProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fill-in the "Super Class" and "Super Interfaces" fields.
 * @param page the wizard page.
 */
private void fillInWizardPageSuperTypes(NewTypeWizardPage page) {
	ITypeBinding type= getPossibleSuperTypeBinding(fNode);
	type= Bindings.normalizeTypeBinding(type);
	if (type != null) {
		if (type.isArray()) {
			type= type.getElementType();
		}
		if (type.isTopLevel() || type.isMember()) {
			if (type.isClass() && (fTypeKind == K_CLASS)) {
				page.setSuperClass(type.getQualifiedName(), true);
			} else if (type.isInterface()) {
				List<String> superInterfaces= new ArrayList<String>();
				superInterfaces.add(type.getQualifiedName());
				page.setSuperInterfaces(superInterfaces, true);
			}
		}
	}
}
 
Example #4
Source File: NewCheckProjectWizardPage.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor for NewCheckProjectWizardPage.
 * 
 * @param selection
 */
@Inject
public NewCheckProjectWizardPage() {
  super(NewTypeWizardPage.CLASS_TYPE, "NewCheckProjectWizardPage");
  setTitle(Messages.PROJECT_WIZARD_TITLE);
  setDescription(Messages.PROJECT_WIZARD_DESCRIPTION);
  projectName = new StringDialogField();
  projectNameStatus = new StatusInfo();
}
 
Example #5
Source File: NewCheckCatalogWizardPage.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Instantiates a new new check catalog wizard page.
 */
@Inject
public NewCheckCatalogWizardPage() {
  super(NewTypeWizardPage.CLASS_TYPE, "NewCheckCatalogWizardPage");
  setTitle(Messages.CATALOG_WIZARD_TITLE);
  setDescription(Messages.CATALOG_WIZARD_DESCRIPTION);
  projectInfo = new CheckProjectInfo();
  grammarStatus = new StatusInfo();
}
 
Example #6
Source File: NewCUUsingWizardProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fill-in the "Package" and "Name" fields.
 * @param page the wizard page.
 */
private void fillInWizardPageName(NewTypeWizardPage page) {
	// allow to edit when there are type parameters
	page.setTypeName(fTypeNameWithParameters, fTypeNameWithParameters.indexOf('<') != -1);

	boolean isInEnclosingType= fTypeContainer instanceof IType;
	if (isInEnclosingType) {
		page.setEnclosingType((IType) fTypeContainer, true);
	} else {
		page.setPackageFragment((IPackageFragment) fTypeContainer, true);
	}
	page.setEnclosingTypeSelection(isInEnclosingType, true);
}
 
Example #7
Source File: CreateJavaTypeQuickfixes.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void configureWizardPage(NewTypeWizardPage page, URI contextUri, String typeName, String packageName) {
	setPackageName(page, contextUri, packageName);
	page.setTypeName(typeName, true);
}
 
Example #8
Source File: CreateAsyncInterfaceProposal.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
private NewTypeWizardPage getPage(NewElementWizard wizard) {
  IWizardPage[] pages = wizard.getPages();
  Assert.isTrue(pages.length > 0 && pages[0] instanceof NewTypeWizardPage);
  return (NewTypeWizardPage) pages[0];
}
 
Example #9
Source File: NewCUUsingWizardProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private NewTypeWizardPage getPage(NewElementWizard wizard) {
	IWizardPage[] pages= wizard.getPages();
	Assert.isTrue(pages.length > 0 && pages[0] instanceof NewTypeWizardPage);
	return (NewTypeWizardPage) pages[0];
}
 
Example #10
Source File: NewCUUsingWizardProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void configureWizardPage(NewTypeWizardPage page) {
	fillInWizardPageName(page);
	fillInWizardPageSuperTypes(page);
}
 
Example #11
Source File: SuperInterfaceSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates new instance of SuperInterfaceSelectionDialog
 *
 * @param parent
 *            shell to parent the dialog on
 * @param context
 *            context used to execute long-running operations associated
 *            with this dialog
 * @param page
 *            page that opened this dialog
 * @param p
 *            the java project which will be considered when searching for
 *            interfaces
 */
public SuperInterfaceSelectionDialog(Shell parent, IRunnableContext context, NewTypeWizardPage page, IJavaProject p) {
	super(parent, true, context, createSearchScope(p), IJavaSearchConstants.INTERFACE);
	fTypeWizardPage= page;
	// to restore the content of the dialog field if the dialog is canceled
	fOldContent= fTypeWizardPage.getSuperInterfaces();
	setStatusLineAboveButtons(true);
}