Java 类org.eclipse.ui.IStorageEditorInput 实例源码

项目:bts    文件:XtextDocumentProvider.java   
@Override
public String getEncoding(Object element) {
    String encoding = super.getEncoding(element);
    if (encoding == null && element instanceof IStorageEditorInput) {
        try {
            IStorage storage = ((IStorageEditorInput) element).getStorage();
            URI uri = storage2UriMapper.getUri(storage);
            if (uri != null) {
                encoding = encodingProvider.getEncoding(uri);
            } else if (storage instanceof IEncodedStorage) {
                encoding = ((IEncodedStorage)storage).getCharset();
            }
        } catch (CoreException e) {
            throw new WrappedException(e);
        }
    }
    return encoding;
}
项目:PDFReporter-Studio    文件:SelectionHelper.java   
public static final void openEditor(String content, String name) {
    IStorageEditorInput input = streditors.get(content);
    if (input == null) {
        IStorage storage = new StringStorage(content);
        input = new StringInput(storage);
        streditors.put(content, input);
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null)
        window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
    IWorkbenchPage page = window.getActivePage();
    try {
        IEditorReference[] er = page.findEditors(input, name, IWorkbenchPage.MATCH_INPUT);
        if (er != null)
            page.closeEditors(er, false);

        page.openEditor(input, name);
    } catch (PartInitException e) {
        UIUtils.showError(e);
    }
}
项目:gama    文件:ImageViewer.java   
/**
 * Set the part name based on the editor input.
 */
private void setPartName(final IEditorInput input) {
    String imageName = null;
    if (input instanceof IStorageEditorInput) {
        try {
            imageName = ((IStorageEditorInput) input).getStorage().getName();
        } catch (final CoreException ex) {
            // intentionally blank
        }
    }
    // this will catch ImageDataEditorInput as well
    if (imageName == null) {
        imageName = input.getName();
    }
    if (imageName == null) {
        imageName = getSite().getRegisteredName();
    }
    setPartName(imageName);
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageExplorerPart.java   
private Object getInputFromEditor(IEditorInput editorInput) {
    Object input= JavaUI.getEditorInputJavaElement(editorInput);
    if (input instanceof ICompilationUnit) {
        ICompilationUnit cu= (ICompilationUnit) input;
        if (!cu.getJavaProject().isOnClasspath(cu)) { // test needed for Java files in non-source folders (bug 207839)
            input= cu.getResource();
        }
    }
    if (input == null) {
        input= editorInput.getAdapter(IFile.class);
    }
    if (input == null && editorInput instanceof IStorageEditorInput) {
        try {
            input= ((IStorageEditorInput) editorInput).getStorage();
        } catch (CoreException e) {
            // ignore
        }
    }
    return input;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertyKeyHyperlink.java   
/**
 * Creates a new properties key hyperlink.
 *
 * @param region the region
 * @param key the properties key
 * @param editor the text editor
 */
public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) {
    Assert.isNotNull(region);
    Assert.isNotNull(key);
    Assert.isNotNull(editor);

    fRegion= region;
    fPropertiesKey= key;
    fEditor= editor;
    fIsFileEditorInput= fEditor.getEditorInput() instanceof IFileEditorInput;
    IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput();
    fShell= fEditor.getEditorSite().getShell();
    try {
        fStorage= storageEditorInput.getStorage();
    } catch (CoreException e) {
        fStorage= null;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertyKeyHyperlinkDetector.java   
private static boolean isEclipseNLSAvailable(IStorageEditorInput editorInput) {
    IStorage storage;
    try {
        storage= editorInput.getStorage();
    } catch (CoreException ex) {
        return false;
    }
    if (!(storage instanceof IJarEntryResource))
        return false;

    IJavaProject javaProject= ((IJarEntryResource) storage).getPackageFragmentRoot().getJavaProject();

    if (javaProject == null || !javaProject.exists())
        return false;

    try {
        return javaProject.findType("org.eclipse.osgi.util.NLS") != null; //$NON-NLS-1$
    } catch (JavaModelException e) {
        return false;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:EditorInputAdapterFactory.java   
public Object getAdapter(Object element, Class key) {
    updateLazyLoadedAdapters();
    if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key) && element instanceof IEditorInput && JavaUI.getEditorInputJavaElement((IEditorInput)element) != null)
        return fSearchPageScoreComputer;

    if (IJavaElement.class.equals(key) && element instanceof IEditorInput) {
        IJavaElement je= JavaUI.getWorkingCopyManager().getWorkingCopy((IEditorInput)element);
        if (je != null)
            return je;
        if (element instanceof IStorageEditorInput) {
            try {
                return ((IStorageEditorInput)element).getStorage().getAdapter(key);
            } catch (CoreException ex) {
                // Fall through
            }
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PackageExplorerPart.java   
private Object getInputFromEditor(IEditorInput editorInput) {
    Object input= JavaUI.getEditorInputJavaElement(editorInput);
    if (input instanceof ICompilationUnit) {
        ICompilationUnit cu= (ICompilationUnit) input;
        if (!cu.getJavaProject().isOnClasspath(cu)) { // test needed for Java files in non-source folders (bug 207839)
            input= cu.getResource();
        }
    }
    if (input == null) {
        input= editorInput.getAdapter(IFile.class);
    }
    if (input == null && editorInput instanceof IStorageEditorInput) {
        try {
            input= ((IStorageEditorInput) editorInput).getStorage();
        } catch (CoreException e) {
            // ignore
        }
    }
    return input;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PropertyKeyHyperlink.java   
/**
 * Creates a new properties key hyperlink.
 *
 * @param region the region
 * @param key the properties key
 * @param editor the text editor
 */
public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) {
    Assert.isNotNull(region);
    Assert.isNotNull(key);
    Assert.isNotNull(editor);

    fRegion= region;
    fPropertiesKey= key;
    fEditor= editor;
    IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput();
    fShell= fEditor.getEditorSite().getShell();
    try {
        fStorage= storageEditorInput.getStorage();
    } catch (CoreException e) {
        fStorage= null;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:EditorInputAdapterFactory.java   
public Object getAdapter(Object element, Class key) {
    updateLazyLoadedAdapters();
    if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key) && element instanceof IEditorInput && JavaUI.getEditorInputJavaElement((IEditorInput)element) != null)
        return fSearchPageScoreComputer;

    if (IJavaElement.class.equals(key) && element instanceof IEditorInput) {
        IJavaElement je= JavaUI.getWorkingCopyManager().getWorkingCopy((IEditorInput)element);
        if (je != null)
            return je;
        if (element instanceof IStorageEditorInput) {
            try {
                return ((IStorageEditorInput)element).getStorage().getAdapter(key);
            } catch (CoreException ex) {
                // Fall through
            }
        }
    }
    return null;
}
项目:patternbox-eclipse    文件:DesignPatternInputContext.java   
protected IBaseModel createModel(IEditorInput input) throws CoreException {
    BuildModel model = null;
    if (input instanceof IStorageEditorInput) {
        boolean isReconciling = input instanceof IFileEditorInput;
        IDocument document = getDocumentProvider().getDocument(input);
        model = new BuildModel(document, isReconciling);
        if (input instanceof IFileEditorInput) {
            IFile file = ((IFileEditorInput)input).getFile();
            model.setUnderlyingResource(file);
            model.setCharset(file.getCharset());
        /*} else if (input instanceof SystemFileEditorInput){
            File file = (File)((SystemFileEditorInput)input).getAdapter(File.class);
            model.setInstallLocation(file.getParent());
            model.setCharset(getDefaultCharset());*/
        } else {
            model.setCharset(getDefaultCharset());              
        }
        model.load();
    }
    return model;
}
项目:tm4e    文件:ContentTypeHelper.java   
/**
 * Find the content types from the given {@link IDocument} by using
 * {@link IEditorInput} and null otherwise.
 * 
 * @param document
 * @return the content types from the given {@link IDocument} by using
 *         {@link IEditorInput} and null otherwise.
 */
private static ContentTypeInfo findContentTypesFromEditorInput(IDocument document) {
    IEditorInput editorInput = getEditorInput(document);
    if (editorInput != null) {
        if (editorInput instanceof IStorageEditorInput) {
            InputStream input = null;
            try {
                IStorage storage = ((IStorageEditorInput) editorInput).getStorage();
                String fileName = storage.getName();
                input = storage.getContents();
                return new ContentTypeInfo(fileName,
                        Platform.getContentTypeManager().findContentTypesFor(input, fileName));
            } catch (Exception e) {
                return null;
            } finally {
                try {
                    if (input != null)
                        input.close();
                } catch (IOException x) {
                }
            }
        } else {
            // TODO: manage other type of IEditorInput
        }
    }
    return null;
}
项目:DarwinSPL    文件:DwprofileEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HyexpressionEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HyvalidityformulaEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HydatavalueEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HymappingEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HyconstraintsEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:DarwinSPL    文件:HymanifestEditor.java   
private void initializeResourceObject(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        initializeResourceObjectFromFile((FileEditorInput) editorInput);
    } else if (editorInput instanceof IStorageEditorInput) {
        initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
    }
}
项目:eclemma    文件:ExecutionDataContent.java   
private InputStream openStream(IEditorInput input) throws CoreException,
    IOException {
  if (input instanceof IStorageEditorInput) {
    final IStorage storage = ((IStorageEditorInput) input).getStorage();
    return storage.getContents();
  }
  if (input instanceof IURIEditorInput) {
    final URI uri = ((IURIEditorInput) input).getURI();
    return uri.toURL().openStream();
  }
  throw new IOException("Unsupported input type: " + input.getClass()); //$NON-NLS-1$
}
项目:hybris-commerce-eclipse-plugin    文件:RunTSVWizard.java   
/**
 * The worker method...
 */
private void doFinish(File scanDir, IProgressMonitor monitor) throws CoreException {

    monitor.beginTask("Creating analysis file", 3);
    monitor.worked(1);

    try {
        runTSVAnalysis(scanDir);
        monitor.worked(1);

        monitor.setTaskName("Opening results file...");
        getShell().getDisplay().asyncExec(new Runnable() {
            public void run() {

                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

                try {
                    IStorage storage = new TSVResultsStorage(getResultsString(), new Path("garbage"));
                    IStorageEditorInput input = new TSVResultsInput(storage, "TSV Analysis");
                    IDE.openEditor(page, input, "com.hybris.hyeclipse.tsv.editors.TSVEditor", true);
                }
                catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
        });
        monitor.worked(1);
    }
    catch (RuntimeException re) {
        System.out.println(re.getMessage());
    }

}
项目:hadoop-2.6.0-cdh5.4.3    文件:DFSActionImpl.java   
/**
 * Open the selected DfsPath in the editor window
 * 
 * @param selection
 * @throws JSchException
 * @throws IOException
 * @throws PartInitException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void open(IStructuredSelection selection) throws IOException,
    PartInitException, InvocationTargetException, InterruptedException {

  for (DFSFile file : filterSelection(DFSFile.class, selection)) {

    IStorageEditorInput editorInput = new DFSFileEditorInput(file);
    targetPart.getSite().getWorkbenchWindow().getActivePage().openEditor(
        editorInput, "org.eclipse.ui.DefaultTextEditor");
  }
}
项目:hadoop-EAR    文件:DFSActionImpl.java   
/**
 * Open the selected DfsPath in the editor window
 * 
 * @param selection
 * @throws JSchException
 * @throws IOException
 * @throws PartInitException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void open(IStructuredSelection selection) throws IOException,
    PartInitException, InvocationTargetException, InterruptedException {

  for (DFSFile file : filterSelection(DFSFile.class, selection)) {

    IStorageEditorInput editorInput = new DFSFileEditorInput(file);
    targetPart.getSite().getWorkbenchWindow().getActivePage().openEditor(
        editorInput, "org.eclipse.ui.DefaultTextEditor");
  }
}
项目:typescript.java    文件:AbstractAnnotationHover.java   
private IPath getEditorInputPath() {
    if (getEditor() == null)
        return null;

    IEditorInput input = getEditor().getEditorInput();
    if (input instanceof IStorageEditorInput) {
        try {
            return ((IStorageEditorInput) input).getStorage().getFullPath();
        } catch (CoreException ex) {
            TypeScriptUIPlugin.log(ex.getStatus());
        }
    }
    return null;
}
项目:typescript.java    文件:TypeScriptMergeViewer.java   
@Override
protected IEditorInput getEditorInput(ISourceViewer sourceViewer) {
    IEditorInput editorInput = super.getEditorInput(sourceViewer);
    if (editorInput == null)
        return null;
    if (getSite() == null)
        return null;
    if (!(editorInput instanceof IStorageEditorInput))
        return null;
    return editorInput;
}
项目:bts    文件:DefaultEditorInputLabelProvider.java   
public String text(IStorageEditorInput editorInput) {
    try {
        return editorInput.getStorage().getFullPath().lastSegment();
    } catch (CoreException e) {
        LOG.error("Error resolving IStorage from IStorageEditorInput", e);
    }
    return null;
}
项目:bts    文件:DefaultMergeViewer.java   
@Override
protected IEditorInput getEditorInput(ISourceViewer sourceViewer) {
    IEditorInput editorInput = super.getEditorInput(sourceViewer);
    if (editorInput == null) {
        return null;
    }
    if (getSite() == null) {
        return null;
    }
    if (!(editorInput instanceof IStorageEditorInput)) {
        return null;
    }
    return editorInput;
}
项目:bts    文件:XtextReadonlyEditorInput.java   
@Override
public boolean equals(Object obj) {
    try {
        return (obj == this || obj != null && (obj instanceof IStorageEditorInput) &&
                storage.equals(((IStorageEditorInput)obj).getStorage()));
    } catch (CoreException e) {
        return false;
    }
}
项目:bts    文件:OpenDocumentTracker.java   
protected URI getResourceURI(XtextEditor editor) {
    IEditorInput editorInput = editor.getEditorInput();
    if (editorInput instanceof IStorageEditorInput) {
        try {
            return storage2UriMapper.getUri(((IStorageEditorInput) editorInput).getStorage());
        } catch (CoreException e) {
            LOG.error("Error getting URI for storage", e);
        }
    }
    return null;
}
项目:openhab-hdl    文件:ResourceForFileEditorFactory.java   
public Resource createResource(IEditorInput editorInput) {
    try {
        if (editorInput instanceof IStorageEditorInput) {
            IStorage storage = ((IStorageEditorInput) editorInput).getStorage();
            return createResourceFor(storage);
        }
        throw new IllegalArgumentException("Couldn't create EMF Resource for input " + editorInput);
    } catch (CoreException e) {
        throw new WrappedException(e);
    }
}
项目:eclipse-extras    文件:ImageViewerEditor.java   
private static void checkEditorInput( IEditorInput input ) {
  if(    !( input instanceof IStorageEditorInput )
      && !( input instanceof IPathEditorInput )
      && !( input instanceof IURIEditorInput ) )
  {
    throw new IllegalArgumentException( "Invalid input: " + input );
  }
}
项目:pep-tools    文件:ProductEditorWithSource.java   
/**
 * Adapted from {@link ProductEditor}, replacing references to
 * {@link ProductInputContext}.
 */
@Override
protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) {
    if (input.getName().endsWith(".product")) {
        manager.putContext(input, new ProductXMLInputContext(this, input, true));
    }
}
项目:skin4eclipse    文件:EditorInfo.java   
static String getPath(IStorageEditorInput storageInp) {
    try {
        IStorage storage = storageInp.getStorage();
        return getPath(storage.getFullPath());
    } catch (CoreException e) {
        return null;
    }
}
项目:gama    文件:ImageViewer.java   
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
    // we need either an IStorage or an input that can return an ImageData
    if (!(input instanceof IStorageEditorInput) && input
            .getAdapter(ImageData.class) == null) { throw new PartInitException("Unable to read input: " + input); //$NON-NLS-1$
    }
    setSite(site);
    setInput(input, false);
}
项目:gama    文件:ImageViewer.java   
/**
 * Get the IFile corresponding to the specified editor input, or null for none.
 */
private IFile getFileFor(final IEditorInput input) {
    if (input instanceof IFileEditorInput) {
        return ((IFileEditorInput) input).getFile();
    } else if (input instanceof IStorageEditorInput) {
        try {
            final IStorage storage = ((IStorageEditorInput) input).getStorage();
            if (storage instanceof IFile) { return (IFile) storage; }
        } catch (final CoreException ignore) {
            // intentionally blank
        }
    }
    return null;
}
项目:gama    文件:ImageViewer.java   
/**
 * Load the image data from the current editor input. This operation can take time and should not be called on the
 * ui thread.
 */
private void loadImageData() throws CoreException {
    final IEditorInput input = getEditorInput();
    final Object o = input.getAdapter(ImageData.class);
    if (o instanceof ImageData) {
        imageData = (ImageData) o;
    } else if (input instanceof IStorageEditorInput) {
        final IFile file = getFileFor(input);
        imageData = ImageDataLoader.getImageData(file);
    }
    // save this away so we don't compute it all the time
    this.maxZoomFactor = determineMaxZoomFactor();
}
项目:gama    文件:MultiPageCSVEditor.java   
private static IFile getFileFor(final IEditorInput input) {
    if (input instanceof IFileEditorInput) {
        return ((IFileEditorInput) input).getFile();
    } else if (input instanceof IStorageEditorInput) {
        try {
            final IStorage storage = ((IStorageEditorInput) input).getStorage();
            if (storage instanceof IFile) { return (IFile) storage; }
        } catch (final CoreException ignore) {
            // intentionally blank
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertyKeyHyperlinkDetector.java   
static boolean checkEnabled(ITextEditor textEditor, int offset) {
    if (offset < 0)
        return false;

    IEditorInput editorInput= textEditor.getEditorInput();
    return editorInput instanceof IFileEditorInput || (editorInput instanceof IStorageEditorInput && isEclipseNLSAvailable((IStorageEditorInput) editorInput));
}
项目:Eclipse-Postfix-Code-Completion    文件:AbstractAnnotationHover.java   
private IPath getEditorInputPath() {
    if (getEditor() == null)
        return null;

    IEditorInput input= getEditor().getEditorInput();
    if (input instanceof IStorageEditorInput) {
        try {
            return ((IStorageEditorInput)input).getStorage().getFullPath();
        } catch (CoreException ex) {
            JavaPlugin.log(ex.getStatus());
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaMergeViewer.java   
@Override
protected IEditorInput getEditorInput(ISourceViewer sourceViewer) {
    IEditorInput editorInput= super.getEditorInput(sourceViewer);
    if (editorInput == null)
        return null;
    if (getSite() == null)
        return null;
    if (!(editorInput instanceof IStorageEditorInput))
        return null;
    return editorInput;
}