use of org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput in project Pydev by fabioz.
the class PyOpenExternalAction method openFiles.
@Override
protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
try {
PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
PydevZipFileEditorInput input = new PydevZipFileEditorInput(storage);
IDE.openEditor(page, input, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
} catch (PartInitException e) {
Log.log(e);
}
}
}
use of org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput in project Pydev by fabioz.
the class PyOpenResourceAction method openFiles.
@Override
protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
try {
if (PythonPathHelper.isValidSourceFile(n.zipPath)) {
new PyOpenAction().run(new ItemPointer(n.zipStructure.file, new Location(), new Location(), null, n.zipPath));
} else {
IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(n.zipPath);
PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
PydevZipFileEditorInput input = new PydevZipFileEditorInput(storage);
if (defaultEditor != null) {
IDE.openEditor(page, input, defaultEditor.getId());
} else {
IDE.openEditor(page, input, EditorsUI.DEFAULT_TEXT_EDITOR_ID);
}
}
} catch (PartInitException e) {
Log.log(e);
}
}
}
use of org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput in project Pydev by fabioz.
the class EditorInputFactory method create.
/**
* Creates an editor input for the passed file.
*
* If forceExternalFile is True, it won't even try to create a FileEditorInput, otherwise,
* it will try to create it with the most suitable type it can
* (i.e.: FileEditorInput, FileStoreEditorInput, PydevFileEditorInput, ...)
*/
public static IEditorInput create(File file, boolean forceExternalFile) {
IPath path = Path.fromOSString(FileUtils.getFileAbsolutePath(file));
if (!forceExternalFile) {
// May call again to this method (but with forceExternalFile = true)
IEditorInput input = new PySourceLocatorBase().createEditorInput(path, false, null, null);
if (input != null) {
return input;
}
}
IPath zipPath = new Path("");
while (path.segmentCount() > 0) {
if (path.toFile().exists()) {
break;
}
zipPath = new Path(path.lastSegment()).append(zipPath);
path = path.uptoSegment(path.segmentCount() - 1);
}
if (zipPath.segmentCount() > 0 && path.segmentCount() > 0) {
return new PydevZipFileEditorInput(new PydevZipFileStorage(path.toFile(), zipPath.toPortableString()));
}
try {
URI uri = file.toURI();
return new FileStoreEditorInput(EFS.getStore(uri));
} catch (Throwable e) {
// not always available! (only added in eclipse 3.3)
return new PydevFileEditorInput(file);
}
}
use of org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput in project Pydev by fabioz.
the class PydevPackageExplorer method getElementOfInput.
/**
* Returns the element contained in the EditorInput
*/
Object getElementOfInput(IEditorInput input) {
if (input instanceof IFileEditorInput) {
return ((IFileEditorInput) input).getFile();
}
if (input instanceof IURIEditorInput) {
IURIEditorInput iuriEditorInput = (IURIEditorInput) input;
URI uri = iuriEditorInput.getURI();
return new File(uri);
}
if (input instanceof PydevZipFileEditorInput) {
PydevZipFileEditorInput pydevZipFileEditorInput = (PydevZipFileEditorInput) input;
try {
IStorage storage = pydevZipFileEditorInput.getStorage();
if (storage instanceof PydevZipFileStorage) {
PydevZipFileStorage pydevZipFileStorage = (PydevZipFileStorage) storage;
return pydevZipFileStorage;
}
} catch (CoreException e) {
Log.log(e);
}
}
return null;
}
Aggregations