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

项目:libraries    文件:JavaProjectUtilities.java   
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() };
}
项目:team-explorer-everywhere    文件:QueryDocumentEditorInput.java   
@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;
}
项目:APICloud-Studio    文件:UIUtils.java   
/**
 * 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;
}
项目:APICloud-Studio    文件:FilenameDifferentiator.java   
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;
}
项目:Eclipse-Markdown-Editor-Plugin    文件:ExportHTMLAction.java   
@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);
    }
}
项目:birt    文件:UIUtil.java   
/**
 * 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;
}
项目:birt    文件:UIUtil.java   
/**
 * 
 * @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;
}
项目:birt    文件:IDEReportProviderFactory.java   
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;
    }
项目:Pydev    文件:AbstractBreakpointRulerAction.java   
/**
 * @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;
}
项目:dLabPro-Plugin    文件:VisEditor.java   
@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);
}
项目:fluentmark    文件:HtmlGen.java   
/**
 * 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());
}
项目:eclipse-extras    文件:DeleteEditorFileHandler.java   
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;
}
项目:eclipse-extras    文件:DeleteEditorFileHandler_FilePDETest.java   
@Test
public void testExecuteWithPathEditorInput() throws IOException {
  File file = tempFolder.newFile( "foo.txt" );
  IPathEditorInput editorInput = mockPathEditorInput( file );

  executeHandler( editorInput );

  assertThat( file ).doesNotExist();
}
项目: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 );
  }
}
项目:APICloud-Studio    文件:EditorUtil.java   
/**
 * 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;
}
项目:Eclipse-Markdown-Editor-Plugin    文件:MarkdownEditor.java   
private IFile getResource(MarkdownEditor markdownEditor) {
    IPathEditorInput input = (IPathEditorInput) getEditorInput();
    IPath path = input.getPath();       
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IFile[] files = root.findFilesForLocation(path);
    if (files.length != 1) return null;
    IFile docFile = files[0];       
    return docFile;
}
项目:birt    文件:FileReportProvider.java   
public void saveReport( ModuleHandle moduleHandle, Object element,
        IPath origReportPath, IProgressMonitor monitor )
{
    if ( element instanceof IPathEditorInput )
    {
        IPathEditorInput input = (IPathEditorInput) element;

        saveFile( moduleHandle,
                input.getPath( ).toFile( ),
                origReportPath,
                monitor );
    }
}
项目:birt    文件:FileReportProvider.java   
public IPath getSaveAsPath( Object element )
{
    if ( element instanceof IPathEditorInput )
    {
        IEditorInput input = (IEditorInput) element;

        SaveReportAsWizardDialog dialog = new SaveReportAsWizardDialog( UIUtil.getDefaultShell( ),
                new SaveReportAsWizard( model, input ) );
        if ( dialog.open( ) == Window.OK )
        {
            return dialog.getResult( );
        }
    }
    return null;
}
项目:birt    文件:FileReportProvider.java   
public IPath getInputPath( IEditorInput input )
{
    if ( input instanceof IPathEditorInput )
    {
        return ( (IPathEditorInput) input ).getPath( );
    }
    return null;
}
项目:birt    文件:LibraryProvider.java   
private File getInputForlder( )
{
    IEditorPart editor = UIUtil.getActiveEditor( true );
    if ( editor != null )
    {
        IEditorInput input = editor.getEditorInput( );
        if ( input instanceof IPathEditorInput )
        {
            return ( (IPathEditorInput) input ).getPath( )
                    .toFile( )
                    .getParentFile( );
        }
    }
    return null;
}
项目:birt    文件:FileReportDocumentProvider.java   
public boolean isReadOnly( Object element )
{
    if ( element instanceof IPathEditorInput )
    {
        File file = ( (IPathEditorInput) element ).getPath( ).toFile( );
        return !file.canWrite( );
    }
    return super.isReadOnly( element );
}
项目:birt    文件:ReportEditorInput.java   
public boolean equals( Object obj )
{
    if ( this == obj )
        return true;
    if ( obj instanceof IPathEditorInput )
    {
        obj = new ReportEditorInput( (IPathEditorInput) obj );
    }
    if ( !( obj instanceof ReportEditorInput ) )
        return false;
    return file.equals( ( (ReportEditorInput) obj ).file );
}
项目:birt    文件:WizardSaveAsPage.java   
public void setOriginalFile( IEditorInput input )
{
    String container = ( (IPathEditorInput) input ).getPath( )
            .removeLastSegments( 1 )
            .toOSString( );
    support.setInitialFileLocation( container );
    support.setInitialFileName( input.getName( ) );
}
项目:Pydev    文件:PySourceLocatorBase.java   
public IEditorInput findFromOpenedPyEdits() {
    Object ret = PyEdit.iterOpenEditorsUntilFirstReturn(new ICallback<Object, PyEdit>() {

        @Override
        public Object call(PyEdit pyEdit) {
            IEditorInput editorInput = pyEdit.getEditorInput();
            if (editorInput instanceof IPathEditorInput) {
                IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
                IPath localPath = pathEditorInput.getPath();
                if (localPath != null) {
                    if (matchesPath(matchName, editorInput, localPath)) {
                        return editorInput;
                    }
                }
            } else {
                File editorFile = pyEdit.getEditorFile();
                if (editorFile != null) {
                    if (matchesFile(matchName, editorInput, editorFile)) {
                        return editorInput;
                    }
                }
            }
            return null;
        }
    });
    return (IEditorInput) ret;
}
项目:avro-schema-editor    文件:AvroSchemaEditorPart.java   
protected AvroSchema getAvroSchema() {
    IPathEditorInput pathInput = (IPathEditorInput) getEditorInput();
    IPath path = pathInput.getPath();       
    File file = path.toFile();
    return new AvroSchemaFile(file);
}
项目:eclipse-extras    文件:DeleteEditorFileHandler_FilePDETest.java   
private static IPathEditorInput mockPathEditorInput( File file ) throws IOException {
  IPathEditorInput editorInput = mock( IPathEditorInput.class );
  when( editorInput.getPath() ).thenReturn( new Path( file.getCanonicalPath() ) );
  return editorInput;
}
项目:APICloud-Studio    文件:EditorUtil.java   
/**
 * Gets the URI associated with the editor.
 * 
 * @param editor
 * @return
 */
public static URI getURI(IEditorPart editor)
{
    // NOTE: Moved from CommonContentAssistProcessor
    if (editor != null)
    {
        IEditorInput editorInput = editor.getEditorInput();

        if (editorInput instanceof IURIEditorInput)
        {
            IURIEditorInput uriEditorInput = (IURIEditorInput) editorInput;
            return uriEditorInput.getURI();
        }
        if (editorInput instanceof IPathEditorInput)
        {
            IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
            return URIUtil.toURI(pathEditorInput.getPath());
        }
        if (editorInput instanceof IFileEditorInput)
        {
            IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
            return fileEditorInput.getFile().getLocationURI();
        }
        try
        {
            if (editorInput instanceof IStorageEditorInput)
            {
                IStorageEditorInput storageEditorInput = (IStorageEditorInput) editorInput;
                IStorage storage = storageEditorInput.getStorage();
                if (storage != null)
                {
                    IPath path = storage.getFullPath();
                    if (path != null)
                    {
                        return URIUtil.toURI(path);
                    }
                }
            }
        }
        catch (CoreException e)
        {
            IdeLog.logError(CommonEditorPlugin.getDefault(), e);
        }
        if (editorInput instanceof ILocationProviderExtension)
        {
            ILocationProviderExtension lpe = (ILocationProviderExtension) editorInput;
            return lpe.getURI(null);
        }
        if (editorInput instanceof ILocationProvider)
        {
            ILocationProvider lp = (ILocationProvider) editorInput;
            return URIUtil.toURI(lp.getPath(null));
        }
    }

    return null;
}
项目:fluentmark    文件:HtmlGen.java   
/**
 * Gets the current document html content with a header as determined by HtmlKind.
 * 
 * @param hdr defines the intended use of the HTML: for export, for the embedded view, or minimal.
 */
public String getPage(HtmlKind hdr) {
    IPathEditorInput input = (IPathEditorInput) editor.getEditorInput();
    return addHeader(hdr, convert(), input.getPath());
}
项目:birt    文件:ReportEditorInput.java   
/**
 * Constructor
 * 
 * @param input
 */
public ReportEditorInput( IPathEditorInput input )
{
    this( input.getPath( ).toFile( ) );
}