try {
PythonPackageSelectionDialog dialog = new PythonPackageSelectionDialog(getShell(), false);
dialog.open();
Object firstResult = dialog.getFirstResult();
if (firstResult instanceof SourceFolder) { //it is the default package
SourceFolder f = (SourceFolder) firstResult;
textPackage.setText("");
textSourceFolder.setText(f.folder.getFullPath().toString());
}
if (firstResult instanceof org.python.pydev.ui.dialogs.Package) {
org.python.pydev.ui.dialogs.Package f = (org.python.pydev.ui.dialogs.Package) firstResult;
textPackage.setText(f.getPackageName());
textSourceFolder.setText(f.sourceFolder.folder.getFullPath().toString());
}
} catch (Exception e1) {
Log.log(e1);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
Object element = selection.getFirstElement();
try {
if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
element = adaptable.getAdapter(IFile.class);
if (element == null) {
element = adaptable.getAdapter(IFolder.class);
}
}
if (element instanceof IFile) {
IFile f = (IFile) element;
element = f.getParent();
}
if (element instanceof IFolder) {
IFolder f = (IFolder) element;
String srcPath = getSrcFolderFromFolder(f);
if (srcPath == null) {
return false;
}
String complete = f.getFullPath().toString();
if (complete.startsWith(srcPath)) {
complete = complete.substring(srcPath.length()).replace('/', '.');
if (complete.startsWith(".")) {
complete = complete.substring(1);
}