本文整理汇总了Java中org.eclipse.ui.ide.FileStoreEditorInput类的典型用法代码示例。如果您正苦于以下问题:Java FileStoreEditorInput类的具体用法?Java FileStoreEditorInput怎么用?Java FileStoreEditorInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileStoreEditorInput类属于org.eclipse.ui.ide包,在下文中一共展示了FileStoreEditorInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editFile
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException {
if (file == null || !file.exists() || !file.isFile() || !file.canRead()) {
throw new IOException("Invalid file: '" + file + "'");
}
IWorkbench workBench = PlatformUI.getWorkbench();
IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage();
IPath location = Path.fromOSString(file.getAbsolutePath());
IFileStore fileStore = EFS.getLocalFileSystem().getStore(location);
FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore);
String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
if (preferIdeEditor) {
IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName());
if (editorDescriptor != null) {
editorId = editorDescriptor.getId();
}
}
return page.openEditor(fileStoreEditorInput, editorId);
}
示例2: saveOpenTmpSqlEditor
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
/**
* Saves the content as a temp-file, opens it using SQL-editor
* and ensures that UTF-8 is used for everything.
*/
public static void saveOpenTmpSqlEditor(String content, String filenamePrefix) throws IOException, CoreException {
Log.log(Log.LOG_INFO, "Creating file " + filenamePrefix); //$NON-NLS-1$
Path path = Files.createTempFile(filenamePrefix + '_', ".sql"); //$NON-NLS-1$
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(path.toFile());
IEditorInput input = new FileStoreEditorInput(externalFile);
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, EDITOR.SQL);
if (part instanceof ITextEditor) {
IDocumentProvider prov = ((ITextEditor) part).getDocumentProvider();
if (prov instanceof TextFileDocumentProvider) {
((TextFileDocumentProvider) prov).setEncoding(input, ApgdiffConsts.UTF_8);
prov.resetDocument(input);
}
}
}
示例3: setInput
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
@Override
public void setInput(IEditorInput input) {
if(input instanceof FileStoreEditorInput){
MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(),SWT.ICON_WARNING);
messageBox.setText(Messages.WARNING);
messageBox.setMessage(Messages.JOB_OPENED_FROM_OUTSIDE_WORKSPACE_WARNING);
messageBox.open();
}
try {
GenrateContainerData genrateContainerData = new GenrateContainerData();
genrateContainerData.setEditorInput(input, this);
if(StringUtils.equals(this.getJobName()+Messages.JOBEXTENSION, input.getName()) || StringUtils.equals(this.getJobName(), Messages.ELT_GRAPHICAL_EDITOR)){
container = genrateContainerData.getContainerData();
}else{
this.setPartName(input.getName());
}
super.setInput(input);
} catch (CoreException | IOException ce) {
logger.error("Exception while setting input", ce);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().dispose();
MessageDialog.openError(new Shell(), "Error", "Exception occured while opening the graph -\n"+ce.getMessage());
}
}
示例4: openEditor
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
private Container openEditor(IPath jobFilePath) throws CoreException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (!isJobAlreadyOpen(jobFilePath)) {
if (ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath).exists()) {
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath);
IDE.openEditor(page, iFile);
} else {
if (jobFilePath.toFile().exists()) {
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(jobFilePath.toFile());
IEditorInput store = new FileStoreEditorInput(fileStore);
IDE.openEditorOnFileStore(page, fileStore);
}
}
return SubJobUtility.getCurrentEditor().getContainer();
}else
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
"Unable to open subjob : "+jobFilePath.lastSegment()+" Subjob is already open \n" +
"Please close the job and retry");
return null;
}
示例5: getEditorInput
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
@Override
public IEditorInput getEditorInput(Object element) {
if (element instanceof ILineBreakpoint) {
return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource());
}
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(element.toString()));
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile[] files = root.findFilesForLocationURI(fileStore.toURI());
if (files != null) {
for (IFile file : files) {
if (file.exists()) {
return new FileEditorInput(file);
}
}
}
return new FileStoreEditorInput(fileStore);
}
示例6: getFilePath
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
private IPath getFilePath(ITextEditor textEditor) {
IEditorInput editorInput = textEditor.getEditorInput();
IFile file = ResourceUtil.getFile(editorInput);
File localFile = null;
if (file != null) {
localFile = file.getLocation().toFile();
} else if (editorInput instanceof FileStoreEditorInput) {
FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
URI uri = fileStoreEditorInput.getURI();
IFileStore location = EFS.getLocalFileSystem().getStore(uri);
try {
localFile = location.toLocalFile(EFS.NONE, null);
} catch (CoreException e) {
// ignore
}
}
if (localFile == null) {
return null;
} else {
return Path.fromOSString(localFile.toString());
}
}
示例7: createSystemFileContexts
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
/**
* Adapted from {@link ProductEditor}, replacing references to
* {@link ProductInputContext}.
*/
@Override
protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) {
File file = new File(input.getURI());
if (file != null) {
String name = file.getName();
if (name.endsWith(".product")) {
IFileStore store;
try {
store = EFS.getStore(file.toURI());
IEditorInput in = new FileStoreEditorInput(store);
manager.putContext(in, new ProductXMLInputContext(this, in, true));
} catch (CoreException e) {
PDEPlugin.logException(e);
}
}
}
}
示例8: init
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
IFile file = null;
if (input instanceof FileStoreEditorInput) {
input = FileUtils.checkAndConvertEditorInput(input, new NullProgressMonitor());
init(site, input);
return;
} else if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
}
try {
getJrContext(file);
setSite(site);
setPartName(input.getName());
setInput(input);
} catch (Exception e) {
throw new PartInitException(e.getMessage(), e);
}
}
示例9: setTitlePath
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
private void setTitlePath()
{
String titlePath = null;
if (lastActiveEditor != null)
{
IEditorInput editorInput = lastActiveEditor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
titlePath = computeTitlePath((IFileEditorInput) editorInput);
}
else if (editorInput instanceof FileStoreEditorInput)
{
titlePath = computeTitlePath((FileStoreEditorInput) editorInput);
}
}
titlePathUpdater.updateTitlePath(getWindowConfigurer().getWindow()
.getShell(), titlePath);
}
示例10: getAdapter
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
public Object getAdapter(Object adaptableObject, Class adapterType)
{
if (IUniformResource.class == adapterType)
{
if (adaptableObject instanceof FileStoreEditorInput)
{
return new FileStoreEditorInputUniformResource((FileStoreEditorInput) adaptableObject);
}
}
else if (IFile.class == adapterType)
{
if (adaptableObject instanceof FileStoreEditorInput)
{
URI uri = ((FileStoreEditorInput) adaptableObject).getURI();
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
if (files.length == 1)
{
return files[0];
}
}
}
return null;
}
示例11: getEditorFile
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
/**
* Returns the resource file that the editor belongs to.
*
* @param editor
* @return
*/
public static IFile getEditorFile(AbstractThemeableEditor editor)
{
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
return fileEditorInput.getFile();
}
else if (editorInput instanceof FileStoreEditorInput)
{
FileStoreEditorInput input = (FileStoreEditorInput) editorInput;
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(input.getURI());
if (files != null && files.length > 0)
{
return files[0];
}
}
return null;
}
示例12: getDataSource
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
/**
* 获取数据源
* @param editorInput
* @return ;
*/
@SuppressWarnings("unchecked")
public T getDataSource(IEditorInput editorInput) {
if (editorInput instanceof FileEditorInput) {
if (editorInput instanceof FileEditorInput) {
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
return this.getDataSource(file);
}
} else if (editorInput instanceof FileStoreEditorInput) {
FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
Object obj = map.get(generateKey(fileStoreEditorInput));
if (dataSourceClass.isInstance(obj)) {
return (T) obj;
}
}
return null;
}
示例13: getFile
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
/**
* Returns the file current viewed in the editor as an IFile Object so it can be passed to other
* calls. If there is NO such file it will throw an Assertion Error.
*
* @return
*/
public static IFile getFile() {
IFile file = null;
IWorkbenchWindow win = getWorkBenchWindow();
IWorkbenchPage page = win.getActivePage();
if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor != null) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
} else if (input instanceof FileStoreEditorInput) {
// What goes here?
}
}
}
if (file == null) {
throw new AssertionError("null file returned");
}
return file;
}
示例14: init
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
@Override
public void init( IEditorSite site, IEditorInput input )
throws PartInitException
{
super.init( site, input );
if ( input instanceof IFileEditorInput )
{
String fileName = ( (IFileEditorInput) input ).getFile( )
.getLocation( )
.toOSString( );
setFileName( fileName );
int index = fileName.lastIndexOf( File.separator );
setPartName( fileName.substring( index + 1, fileName.length( ) ) );
}
else if ( input instanceof FileStoreEditorInput )
{
setFileName( ( (FileStoreEditorInput) input ).getURI( )
.getRawPath( ) );
setPartName( ( (FileStoreEditorInput) input ).getName( ) );
}
}
示例15: createElement
import org.eclipse.ui.ide.FileStoreEditorInput; //导入依赖的package包/类
@Override
public IAdaptable createElement(IMemento memento) {
String fileStr = memento.getString(TAG_FILE);
if (fileStr == null || fileStr.length() == 0) {
return null;
}
String zipPath = memento.getString(TAG_ZIP_PATH);
final File file = new File(fileStr);
if (zipPath == null || zipPath.length() == 0) {
//return EditorInputFactory.create(new File(file), false);
final URI uri = file.toURI();
IFile[] ret = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri,
IContainer.INCLUDE_HIDDEN | IContainer.INCLUDE_PHANTOMS | IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
if (ret != null && ret.length > 0) {
return new FileEditorInput(ret[0]);
}
try {
return new FileStoreEditorInput(EFS.getStore(uri));
} catch (CoreException e) {
return new PydevFileEditorInput(file);
}
}
return new PydevZipFileEditorInput(new PydevZipFileStorage(file, zipPath));
}