本文整理汇总了Java中org.eclipse.ui.IStorageEditorInput类的典型用法代码示例。如果您正苦于以下问题:Java IStorageEditorInput类的具体用法?Java IStorageEditorInput怎么用?Java IStorageEditorInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStorageEditorInput类属于org.eclipse.ui包,在下文中一共展示了IStorageEditorInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEncoding
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
@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;
}
示例2: openEditor
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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);
}
}
示例3: setPartName
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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);
}
示例4: getInputFromEditor
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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;
}
示例5: PropertyKeyHyperlink
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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;
}
}
示例6: isEclipseNLSAvailable
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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;
}
}
示例7: getAdapter
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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;
}
示例8: PropertyKeyHyperlink
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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;
}
}
示例9: createModel
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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;
}
示例10: findContentTypesFromEditorInput
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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;
}
示例11: initializeResourceObject
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
private void initializeResourceObject(IEditorInput editorInput) {
if (editorInput instanceof FileEditorInput) {
initializeResourceObjectFromFile((FileEditorInput) editorInput);
} else if (editorInput instanceof IStorageEditorInput) {
initializeResourceObjectFromStorage((IStorageEditorInput) editorInput);
}
}
示例12: openStream
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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$
}
示例13: doFinish
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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());
}
}
示例14: open
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
/**
* 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");
}
}
示例15: getEditorInputPath
import org.eclipse.ui.IStorageEditorInput; //导入依赖的package包/类
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;
}