Bug 17383 create getter/setter - no explicit hint if getter/setter already exist
Create getter/setter seems to know which getter/setters exist already. However, there's no explicit way to show this. I can figure out by selecting the type (only not existing getter/setter are shown). If I select a field, I see all the setter/getter of the type and I loose the information which setter and getter exist already.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java
}
				
	}
	
	private boolean canEnable(IStructuredSelection selection) throws JavaModelException{
		if (canEnableOn(getSelectedFields(selection)))
			return true;
			
		if ((selection.size() == 1) && (selection.getFirstElement() instanceof IType))
			return canEnableOn((IType)selection.getFirstElement());
		if ((selection.size() == 1) && (selection.getFirstElement() instanceof ICompilationUnit))
			return canEnableOn(JavaElementUtil.getMainType((ICompilationUnit)selection.getFirstElement()));
		return false;	
	}
	private static boolean canEnableOn(IType type) throws JavaModelException {
		if (type == null)
			return false;
		if (type.getFields().length == 0)
			return false;
		if (type.getCompilationUnit() == null)
			return false;
		if (JavaModelUtil.isEditable(type.getCompilationUnit()))
			return true;
		return false;	
	}
	
	private static boolean canEnableOn(IField[] fields) throws JavaModelException {
		return fields != null && fields.length > 0 && JavaModelUtil.isEditable(fields[0].getCompilationUnit());
	}