topComp.setLayoutData(gd);
if (project != null) {
try {
IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
final PythonNature nature = PythonNature.getPythonNature(project);
Map<String, String> variableSubstitution = pathNature.getVariableSubstitution(false);
Label label = new Label(topComp, SWT.None);
label.setText("Django manage.py");
Text text = new Text(topComp, SWT.BORDER);
textDjangoManage = text;
textDjangoManage
.setToolTipText("This is the name of the project-relative location of manage.py (i.e.: src/myapp/manage.py)");
label = new Label(topComp, SWT.None);
labelErrorManage = new Label(topComp, SWT.None);
labelErrorManage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
ModifyListener manageValidator = new ModifyListener() {
public void modifyText(ModifyEvent e) {
try {
String path = textDjangoManage.getText().trim();
if (path.trim().length() == 0) {
labelErrorSettings
.setText("Please specify the manage.py relative name (i.e.: src/myapp/manage.py)");
return;
}
IFile file = project.getFile(new Path(path));
if (!file.exists()) {
labelErrorManage.setText(com.aptana.shared_core.string.StringUtils.format("File: %s could not be found.", path));
} else {
labelErrorManage.setText("");
}
} catch (Exception e1) {
Log.log(e1);
}
}
};
text.addModifyListener(manageValidator);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
String string = variableSubstitution.get(DjangoConstants.DJANGO_MANAGE_VARIABLE);
if (string != null) {
text.setText(string);
} else {
text.setText("");
}
// Settings
label = new Label(topComp, SWT.None);
label.setText("Django settings module");
text = new Text(topComp, SWT.BORDER);
textDjangoSettings = text;
textDjangoSettings
.setToolTipText("This is the name of the django settings module (i.e.: myapp.settings)");
label = new Label(topComp, SWT.None);
labelErrorSettings = new Label(topComp, SWT.None);
labelErrorSettings.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
ModifyListener settingsValidator = new ModifyListener() {
public void modifyText(ModifyEvent e) {
try {
String moduleName = textDjangoSettings.getText().trim();
if (moduleName.trim().length() == 0) {
labelErrorSettings
.setText("Please specify the name of the module (i.e.: myapp.settings)");
return;
}
ICodeCompletionASTManager astManager = nature.getAstManager();
ProjectModulesManager modulesManager = (ProjectModulesManager) astManager
.getModulesManager();
IModule moduleInDirectManager = modulesManager.getModuleInDirectManager(moduleName, nature,
true);
if (moduleInDirectManager == null) {