Search in sources :

Example 1 with PythonpathZipChildTreeNode

use of org.python.pydev.navigator.PythonpathZipChildTreeNode 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);
        }
    }
}
Also used : PythonpathZipChildTreeNode(org.python.pydev.navigator.PythonpathZipChildTreeNode) PydevZipFileStorage(org.python.pydev.shared_ui.editor_input.PydevZipFileStorage) PydevZipFileEditorInput(org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with PythonpathZipChildTreeNode

use of org.python.pydev.navigator.PythonpathZipChildTreeNode 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);
        }
    }
}
Also used : PythonpathZipChildTreeNode(org.python.pydev.navigator.PythonpathZipChildTreeNode) PyOpenAction(org.python.pydev.editor.actions.PyOpenAction) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) PydevZipFileStorage(org.python.pydev.shared_ui.editor_input.PydevZipFileStorage) PydevZipFileEditorInput(org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput) PartInitException(org.eclipse.ui.PartInitException) IEditorRegistry(org.eclipse.ui.IEditorRegistry) ItemPointer(org.python.pydev.ast.item_pointer.ItemPointer) Location(org.python.pydev.shared_core.structure.Location)

Example 3 with PythonpathZipChildTreeNode

use of org.python.pydev.navigator.PythonpathZipChildTreeNode in project Pydev by fabioz.

the class PyOpenPythonFileAction method fillSelections.

/**
 * This method will get the given selection and fill the related attributes to match the selection correctly
 * (files, nodes and containers).
 */
protected synchronized void fillSelections() {
    filesSelected.clear();
    nodesSelected.clear();
    containersSelected.clear();
    pythonPathFilesSelected.clear();
    pythonPathZipFilesSelected.clear();
    ISelection selection = provider.getSelection();
    if (!selection.isEmpty()) {
        IStructuredSelection sSelection = (IStructuredSelection) selection;
        Iterator iterator = sSelection.iterator();
        while (iterator.hasNext()) {
            Object element = iterator.next();
            if (element instanceof PythonNode) {
                nodesSelected.add((PythonNode) element);
            } else if (element instanceof PythonpathZipChildTreeNode) {
                PythonpathZipChildTreeNode node = (PythonpathZipChildTreeNode) element;
                if (node.isDir) {
                    containersSelected.add(node);
                } else {
                    pythonPathZipFilesSelected.add(node);
                }
            } else if (element instanceof PythonpathTreeNode) {
                PythonpathTreeNode node = (PythonpathTreeNode) element;
                if (node.file.isFile()) {
                    pythonPathFilesSelected.add(node);
                } else {
                    containersSelected.add(node);
                }
            } else if (element instanceof IAdaptable) {
                IAdaptable adaptable = (IAdaptable) element;
                IFile file = adaptable.getAdapter(IFile.class);
                if (file != null) {
                    filesSelected.add(file);
                } else {
                    IContainer container = adaptable.getAdapter(IContainer.class);
                    if (container != null) {
                        containersSelected.add(element);
                    }
                }
            }
        }
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IFile(org.eclipse.core.resources.IFile) PythonpathZipChildTreeNode(org.python.pydev.navigator.PythonpathZipChildTreeNode) PythonNode(org.python.pydev.navigator.elements.PythonNode) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IContainer(org.eclipse.core.resources.IContainer) PythonpathTreeNode(org.python.pydev.navigator.PythonpathTreeNode)

Aggregations

PythonpathZipChildTreeNode (org.python.pydev.navigator.PythonpathZipChildTreeNode)3 PartInitException (org.eclipse.ui.PartInitException)2 PydevZipFileEditorInput (org.python.pydev.shared_ui.editor_input.PydevZipFileEditorInput)2 PydevZipFileStorage (org.python.pydev.shared_ui.editor_input.PydevZipFileStorage)2 Iterator (java.util.Iterator)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)1 IEditorRegistry (org.eclipse.ui.IEditorRegistry)1 ItemPointer (org.python.pydev.ast.item_pointer.ItemPointer)1 PyOpenAction (org.python.pydev.editor.actions.PyOpenAction)1 PythonpathTreeNode (org.python.pydev.navigator.PythonpathTreeNode)1 PythonNode (org.python.pydev.navigator.elements.PythonNode)1 Location (org.python.pydev.shared_core.structure.Location)1