/** * Subclasses may extend this method to create their own specialized default WTP operation. This * implementation creates an instance of the NewJavaClassOperation to create a new java class. * This method will not return null. * * @see WTPOperationDataModel#getDefaultOperation() * @see NewJavaClassOperation * * @return WTPOperation */ public IDataModelOperation getDefaultOperation() { return new NewJavaClassOperation(getDataModel()); }
/** * @deprecated use {@link #findMethodInHierarchy(ITypeHierarchy, IType, String, String[], boolean)} */ public static IMethod findMethodImplementationInHierarchy(ITypeHierarchy hierarchy, IType type, String name, String[] paramTypes, boolean isConstructor) throws JavaModelException { return findMethodInHierarchy(hierarchy, type, name, paramTypes, isConstructor); }
/** * Sets all compliance settings in the given map to 5.0 */ public static void set50CompilanceOptions(Map map) { setCompilanceOptions(map, JavaCore.VERSION_1_5); }
/** * Subclasses may extend this method to add their own actions during execution. * The implementation of the execute method drives the running of the operation. This * method will create the source folder, the java package, and then create the java file. * This method will accept null. * @see AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) * * @param monitor ProgressMonitor * @throws CoreException * @throws InterruptedException * @throws InvocationTargetException */ public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { // Ensure source folder exists IFolder sourceFolder = createJavaSourceFolder(); // Ensure java package exists IPackageFragment pack = createJavaPackage(); // Create java class createJavaFile(sourceFolder, pack); return OK_STATUS; }
public IDataModelOperation getDefaultOperation() { return new JARDependencyOperation(model); } }
private void getImportStatements(String signature, IType declaringType) throws JavaModelException{ String erasure = Signature.getTypeErasure(signature); String resolvedTypeName = JavaModelUtil.getResolvedTypeName(erasure, declaringType); if (resolvedTypeName != null && !importStatements.contains(resolvedTypeName) && !resolvedTypeName.startsWith("java.lang")) { //$NON-NLS-1$ importStatements.add(resolvedTypeName); } String [] params = Signature.getTypeArguments(signature); for(int i=0;i<params.length; i++){ getImportStatements(params[i], declaringType); } }
public IProject getEARProject() { return ProjectUtilities.getProject(getStringProperty(EAR_PROJECT_NAME)); }
private static IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException{ IType[] types= cu.getAllTypes(); for (int i= 0; i < types.length; i++) { IType type= types[i]; if (getFullyQualifiedName(type).equals(fullyQualifiedName)) return type; } return null; }
@Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { // TODO Auto-generated method stub return doExecute(monitor, info); }
public static boolean is50OrHigher(String compliance) { return !isVersionLessThan(compliance, JavaCore.VERSION_1_5); }
private void filterUnselectedEntries(List cp) { if (allUnselectedClasspathEntries != null) { for (int i = 0; i < allUnselectedClasspathEntries.size(); i++) { ClasspathElement element = (ClasspathElement) allUnselectedClasspathEntries.get(i); ensureRemoveElementInList(cp, element); } } }
/** * Get all compilation units of a selection. * @param javaElements the selected java elements * @return all compilation units containing and contained in elements from javaElements * @throws JavaModelException */ public static ICompilationUnit[] getAllCompilationUnits(IJavaElement[] javaElements) throws JavaModelException { HashSet result= new HashSet(); for (int i= 0; i < javaElements.length; i++) { addAllCus(result, javaElements[i]); } return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]); }
public static boolean is50OrHigher(IJavaProject project) { return is50OrHigher(project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
public static boolean is50OrHigherJRE(IJavaProject project) throws CoreException { IVMInstall vmInstall= JavaRuntime.getVMInstall(project); if (!(vmInstall instanceof IVMInstall2)) return true; // assume 5.0. String compliance= getCompilerCompliance((IVMInstall2) vmInstall, null); if (compliance == null) return true; // assume 5.0 return compliance.startsWith(JavaCore.VERSION_1_5) || compliance.startsWith(JavaCore.VERSION_1_6); }
protected void ensureRemoveElementInList(List cp, ClasspathElement element) { IClasspathEntry[] cpEntries = element.newClasspathEntries(); if (cpEntries == null || cpEntries.length == 0) return; for (int i = 0; i < cpEntries.length; i++) { if (cp.contains(cpEntries[i])) { int index = getIndex(cp, cpEntries[i]); if (index != -1) cp.remove(index); } } }
private static IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException{ ICompilationUnit[] cus= pack.getCompilationUnits(); for (int i= 0; i < cus.length; i++) { ICompilationUnit unit= cus[i]; IType type= findType(unit, fullyQualifiedName); if (type != null && type.exists()) return type; } return null; }
protected UpdateJavaBuildPathOperation createBuildPathOperation(ClasspathModel aModel) { IJavaProject javaProject = JemProjectUtilities.getJavaProject(aModel.getProject()); return new UpdateJavaBuildPathOperation(javaProject, aModel.getClassPathSelection()); }
public IProject getReferencedProject() { return ProjectUtilities.getProject(getStringProperty(REFERENCED_PROJECT_NAME)); }
/** * Returns the fully qualified name of a type's container. (package name or enclosing type name) */ public static String getTypeContainerName(IType type) { IType outerType= type.getDeclaringType(); if (outerType != null) { return getFullyQualifiedName(outerType); } else { return type.getPackageFragment().getElementName(); } }
public IProject getOppositeProject() { return ProjectUtilities.getProject(getStringProperty(OPPOSITE_PROJECT_NAME)); }