本文整理汇总了Java中org.eclipse.ui.IPathEditorInput类的典型用法代码示例。如果您正苦于以下问题:Java IPathEditorInput类的具体用法?Java IPathEditorInput怎么用?Java IPathEditorInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPathEditorInput类属于org.eclipse.ui包,在下文中一共展示了IPathEditorInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJavaProjects
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
public static IJavaProject[] getJavaProjects(final IEditorPart part) {
if (part == null || part.getEditorInput() == null) {
return new IJavaProject[0];
}
final IEditorInput editorInput = part.getEditorInput();
if (editorInput instanceof IPathEditorInput) {
final IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
final IJavaProject javaProject = getJavaProject(pathEditorInput.getPath());
if (javaProject != null && javaProject.exists()) {
return new IJavaProject[] { javaProject };
}
}
final IJavaElement element = editorInput.getAdapter(IJavaElement.class);
if (element == null) {
return new IJavaProject[0];
}
return new IJavaProject[] { element.getJavaProject() };
}
示例2: equals
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
@Override
public boolean equals(final Object obj) {
if (obj instanceof QueryDocumentEditorInput) {
final QueryDocumentEditorInput other = (QueryDocumentEditorInput) obj;
return targetEditorId.equals(other.targetEditorId) && queryDocument.equals(other.queryDocument);
}
if (obj instanceof IPathEditorInput
&& queryDocument.getFile() != null
&& targetEditorId.equals(QueryEditor.ID)) {
final IPathEditorInput pathEditorInput = (IPathEditorInput) obj;
final File file = pathEditorInput.getPath().toFile();
return queryDocument.getFile().equals(file);
}
return false;
}
示例3: getURI
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
* Returns the URI for the specific editor input.
*
* @param input
* the editor input
* @return the URI, or null if none could be determined
*/
public static URI getURI(IEditorInput input)
{
if (input instanceof IFileEditorInput)
{
return ((IFileEditorInput) input).getFile().getLocationURI();
}
if (input instanceof IURIEditorInput)
{
return ((IURIEditorInput) input).getURI();
}
if (input instanceof IPathEditorInput)
{
return URIUtil.toURI(((IPathEditorInput) input).getPath());
}
return null;
}
示例4: getPath
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
private IPath getPath(IEditorPart otherEditor)
{
IEditorInput input = otherEditor.getEditorInput();
try
{
if (input instanceof IPathEditorInput)
{
return ((IPathEditorInput) input).getPath();
}
URI uri = (URI) input.getAdapter(URI.class);
if (uri != null)
{
return new Path(uri.getHost() + Path.SEPARATOR + uri.getPath());
}
if (input instanceof IURIEditorInput)
{
return URIUtil.toPath(((IURIEditorInput) input).getURI());
}
}
catch (Exception e)
{
}
return null;
}
示例5: run
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
@Override
public void run() {
IEditorPart ed = ActionBarContributor.getActiveEditor();
if (!(ed instanceof MarkdownEditor)) {
return;
}
MarkdownEditor editor = (MarkdownEditor) ed;
IEditorInput i = editor.getEditorInput();
if (i instanceof IPathEditorInput) {
IPathEditorInput input = (IPathEditorInput) i;
IPath path = input.getPath();
path = path.removeFileExtension();
path = path.addFileExtension("html");
File file = path.toFile();
String html = editor.getMarkdownPage().html();
FileUtils.write(file, html);
}
}
示例6: getProjectFolder
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
* Gets the project folder from the input
*
* @param input
* @return
*/
public static String getProjectFolder( IEditorInput input )
{
Object fileAdapter = input.getAdapter( IFile.class );
IFile file = null;
if ( fileAdapter != null )
file = (IFile) fileAdapter;
if ( file != null && file.getProject( ) != null )
{
return file.getProject( ).getLocation( ).toOSString( );
}
if ( input instanceof IPathEditorInput )
{
File fileSystemFile = ( (IPathEditorInput) input ).getPath( )
.toFile( );
return fileSystemFile.getParent( );
}
return null;
}
示例7: findOpenedEditor
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
*
* @param fileName
* the fileName
* @return the editor with the given fileName, or null if not found.
*/
public static IEditorPart findOpenedEditor( String fileName )
{
IWorkbenchPage page = PlatformUI.getWorkbench( )
.getActiveWorkbenchWindow( )
.getActivePage( );
IEditorReference[] editors = page.getEditorReferences( );
for ( int i = 0; i < editors.length; i++ )
{
IEditorPart part = editors[i].getEditor( true );
IPath location = ( (IPathEditorInput) part.getEditorInput( ) ).getPath( );
if ( fileName.equalsIgnoreCase( location.toOSString( ) ) )
{
return part;
}
}
return null;
}
示例8: getProvider
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
public IReportProvider getProvider( IEditorInput input )
{
if ( input instanceof IFileEditorInput )
{
return new IDEFileReportProvider( );
}
else if ( input instanceof IPathEditorInput )
{
return super.getProvider( input );
}
// else
// {
// return FileReportProvider.getInstance( );
// }
return null;
}
示例9: getExternalFileEditorInput
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
* @return the IEditorInput if we're dealing with an external file (or null otherwise)
*/
public static IEditorInput getExternalFileEditorInput(ITextEditor editor) {
IEditorInput input = editor.getEditorInput();
//only return not null if it's an external file (IFileEditorInput marks a workspace file, not external file)
if (input instanceof IFileEditorInput) {
return null;
}
if (input instanceof IPathEditorInput) { //PydevFileEditorInput would enter here
return input;
}
try {
if (input instanceof IURIEditorInput) {
return input;
}
} catch (Throwable e) {
//IURIEditorInput not added until eclipse 3.3
}
//Note that IStorageEditorInput is not handled for external files (files from zip)
return input;
}
示例10: init
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException
{
setSite(site);
setInput(input);
setPartName(input.getName());
mResource = null;
mFilePath = null;
if (input instanceof IFileEditorInput)
{
mResource = ((IFileEditorInput)input).getFile();
mFilePath = mResource.getLocation().toOSString();
}
else if (input instanceof IPathEditorInput)
{
mFilePath = ((IPathEditorInput)input).getPath().toOSString();
}
if (mFilePath==null)
throw new PartInitException("Invalid editor input");
load(mFilePath,mXmlWarnings);
}
示例11: getUpdate
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
* Gets the current document html content with a header containing only the title. Intended only for
* React updates of the body content.
*/
public String getUpdate() {
IPathEditorInput input = (IPathEditorInput) editor.getEditorInput();
if (input == null) return "";
String title = input.getPath().toString();
return String.format(Update, title, convert().trim());
}
示例12: getFile
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
private static File getFile( IEditorInput editorInput ) {
File result = null;
if( editorInput instanceof IPathEditorInput ) {
IPathEditorInput pathEditorInput = ( IPathEditorInput )editorInput;
result = pathEditorInput.getPath().toFile();
} else if( editorInput instanceof IURIEditorInput ) {
IURIEditorInput uriEditorInput = ( IURIEditorInput )editorInput;
result = URIUtil.toFile( uriEditorInput.getURI() );
}
return result;
}
示例13: testExecuteWithPathEditorInput
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
@Test
public void testExecuteWithPathEditorInput() throws IOException {
File file = tempFolder.newFile( "foo.txt" );
IPathEditorInput editorInput = mockPathEditorInput( file );
executeHandler( editorInput );
assertThat( file ).doesNotExist();
}
示例14: checkEditorInput
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
private static void checkEditorInput( IEditorInput input ) {
if( !( input instanceof IStorageEditorInput )
&& !( input instanceof IPathEditorInput )
&& !( input instanceof IURIEditorInput ) )
{
throw new IllegalArgumentException( "Invalid input: " + input );
}
}
示例15: getIndex
import org.eclipse.ui.IPathEditorInput; //导入依赖的package包/类
/**
* Gets the indexing associated with the editor.
*
* @param editor
* @return
*/
public static Index getIndex(AbstractThemeableEditor editor)
{
// NOTE: Moved from CommonContentAssistProcessor
if (editor != null)
{
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
return getIndexManager().getIndex(file.getProject().getLocationURI());
}
if (editorInput instanceof IURIEditorInput)
{
IURIEditorInput uriEditorInput = (IURIEditorInput) editorInput;
// FIXME This file may be a child, we need to check to see if there's an index with a parent URI.
return getIndexManager().getIndex(uriEditorInput.getURI());
}
if (editorInput instanceof IPathEditorInput)
{
IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
// FIXME This file may be a child, we need to check to see if there's an index with a parent URI.
return getIndexManager().getIndex(URIUtil.toURI(pathEditorInput.getPath()));
}
}
return null;
}