当前位置: 首页>>代码示例>>Java>>正文


Java FileStoreEditorInput类代码示例

本文整理汇总了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);
    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:24,代码来源:FileEditor.java

示例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);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:FileUtilsUi.java

示例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());
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:24,代码来源:ELTGraphicalEditor.java

示例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;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:22,代码来源:SubJobOpenAction.java

示例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);
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:18,代码来源:DSPDebugModelPresentation.java

示例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());
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:23,代码来源:TextEditorBookmarkPropertiesProvider.java

示例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);
			}
		}
	}
}
 
开发者ID:secondfiddle,项目名称:pep-tools,代码行数:22,代码来源:ProductEditorWithSource.java

示例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);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:21,代码来源:ABasicEditor.java

示例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);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:20,代码来源:ApplicationWorkbenchWindowAdvisor.java

示例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;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:FileStoreEditorInputAdapterFactory.java

示例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;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:26,代码来源:EditorUtil.java

示例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;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:DataSourceHelper.java

示例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;
}
 
开发者ID:joereddington,项目名称:EclipseEditorPluginExample,代码行数:28,代码来源:EditorActions.java

示例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( ) );
	}

}
 
开发者ID:eclipse,项目名称:birt,代码行数:24,代码来源:IDEReportDocumentEditor.java

示例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));
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:27,代码来源:PyEditorInputFactory.java


注:本文中的org.eclipse.ui.ide.FileStoreEditorInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。