}
}
}
protected IStatus componentContainerChanged() {
StatusInfo status = new StatusInfo();
//fComponentContainerRoot = null;
String str = getComponentContainerRootText();
if (str.length() == 0) {
status.setError(NewWizardMessages.NewContainerWizardPage_error_EnterContainerName);
return status;
}
else if (str.endsWith(".wo")) {
status.setError("A component cannot be created within another component");
return status;
}
IPath path = new Path(str);
IResource res = getWorkspaceRoot().findMember(path);
if (res != null) {
int resType = res.getType();
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
status.setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ProjectClosed, BasicElementLabels.getPathLabel(proj.getFullPath(), false)));
return status;
}
IJavaProject jproject = JavaCore.create(proj);
IPackageFragmentRoot fragmentRoot = jproject.getPackageFragmentRoot(res);
if (res.exists()) {
try {
if (!proj.hasNature(JavaCore.NATURE_ID)) {
if (resType == IResource.PROJECT) {
status.setError(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject);
} else {
status.setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotInAJavaProject);
}
return status;
}
if (fragmentRoot.isArchive()) {
status.setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ContainerIsBinary, BasicElementLabels.getPathLabel(path, false)));
return status;
}
// now throws a JavaModelException if not a source folder
if (fragmentRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
status.setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_inside_classfolder, BasicElementLabels.getPathLabel(path, false)));
} else if (!jproject.isOnClasspath(fragmentRoot)) {
status.setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_NotOnClassPath, BasicElementLabels.getPathLabel(path, false)));
}
} catch (JavaModelException e) {
// no problems. Just a standard components folder.
} catch (CoreException e) {
System.err.println(getClass().getName() + ".componentContainerChanged threw an exception.");
e.printStackTrace(System.err);
status.setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject);
}
}
return status;
}
status.setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_NotAFolder, BasicElementLabels.getPathLabel(path, false)));
return status;
}
status.setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ContainerDoesNotExist, BasicElementLabels.getPathLabel(path, false)));
return status;
}