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

下面列出了怎么用org.eclipse.ui.IPathEditorInput的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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;
}
 
源代码2 项目: 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;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: 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;
	}
 
源代码5 项目: 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;
}
 
源代码6 项目: 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;
}
 
@Test
public void testExecuteWithPathEditorInput() throws IOException {
  File file = tempFolder.newFile( "foo.txt" );
  IPathEditorInput editorInput = mockPathEditorInput( file );

  executeHandler( editorInput );

  assertThat( file ).doesNotExist();
}
 
源代码8 项目: 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 );
  }
}
 
源代码9 项目: 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;
}
 
源代码10 项目: 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 );
	}
}
 
源代码11 项目: 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;
}
 
源代码12 项目: birt   文件: FileReportProvider.java
public IPath getInputPath( IEditorInput input )
{
	if ( input instanceof IPathEditorInput )
	{
		return ( (IPathEditorInput) input ).getPath( );
	}
	return null;
}
 
源代码13 项目: 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;
}
 
源代码14 项目: 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 );
}
 
源代码15 项目: 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 );
}
 
源代码16 项目: birt   文件: WizardSaveAsPage.java
public void setOriginalFile( IEditorInput input )
{
	String container = ( (IPathEditorInput) input ).getPath( )
			.removeLastSegments( 1 )
			.toOSString( );
	support.setInitialFileLocation( container );
	support.setInitialFileName( input.getName( ) );
}
 
源代码17 项目: Pydev   文件: PySourceLocatorBase.java
public IEditorInput findFromOpenedPyEdits() {
    Object ret = OpenEditors.iterOpenEditorsUntilFirstReturn(new ICallback<Object, IPyEdit>() {

        @Override
        public Object call(IPyEdit pyEdit) {
            IEditorInput editorInput = (IEditorInput) 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;
}
 
private static IPathEditorInput mockPathEditorInput( File file ) throws IOException {
  IPathEditorInput editorInput = mock( IPathEditorInput.class );
  when( editorInput.getPath() ).thenReturn( new Path( file.getCanonicalPath() ) );
  return editorInput;
}
 
源代码19 项目: 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;
}
 
源代码20 项目: birt   文件: ReportEditorInput.java
/**
 * Constructor
 * 
 * @param input
 */
public ReportEditorInput( IPathEditorInput input )
{
	this( input.getPath( ).toFile( ) );
}
 
 类所在包
 同包方法