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

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

/**
 * This method will get the DesignerProject for the current XPage and return it. 
 * @param compEditor
 * @return
 */
private DesignerProject getDesignerProjectForEditor(CompositeEditor compEditor){
    IWorkbenchPart part = super.getWorkBenchPart();
    if(part instanceof EditorPart){
        EditorPart editor = (EditorPart)part;
        IEditorInput input = editor.getEditorInput();
        if(input instanceof IFileEditorInput){
            IFileEditorInput fileInput = (IFileEditorInput)input;
            IFile xpageFile = fileInput.getFile();
            if(null != xpageFile){
                IProject project = xpageFile.getProject();
                if(null != project){
                    DesignerProject designerProj = DesignerResource.getDesignerProject(project);
                    if(null != designerProj){
                        return designerProj;
                    }
                }
            }
        }
    }
    return null;
}
 
public boolean isShownInEditor(Match match, IEditorPart editor) {
	Object element= match.getElement();
	IJavaElement je= ((JavaElementLine) element).getJavaElement();
	IEditorInput editorInput= editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		try {
			return ((IFileEditorInput)editorInput).getFile().equals(je.getCorrespondingResource());
		} catch (JavaModelException e) {
			return false;
		}
	} else if (editorInput instanceof IClassFileEditorInput) {
		return ((IClassFileEditorInput)editorInput).getClassFile().equals(je);
	}

	return false;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: KaiZen-OpenAPI-Editor   文件: QuickOutline.java
@Override
public void setInput(Object input) {
    if (input instanceof Model) {
        Model model = (Model) input;
        if (model.getPath() == null) {
            IFile currentFile = null;
            IEditorInput editorInput = editor.getEditorInput();

            if (editorInput instanceof IFileEditorInput) {
                currentFile = ((IFileEditorInput) editorInput).getFile();
            }
            if (currentFile != null) {
                model.setPath(currentFile.getFullPath());
            }
        }
    }

    treeViewer.setInput(input);
    treeViewer.setSelection(null, true);
}
 
源代码5 项目: slr-toolkit   文件: MetainformationEditor.java
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	setSite(site);
	setInput(input);
	
	//to avoid errors, close editor, when project is not open
	//use case : project deleted
	if(!getProjectFromIEditorPart(this).isOpen()) {
		this.getEditorSite().getPage().closeEditor(this, false);
	}

	// initialize whole project
	unloadDocumentResources();
	initializeWholeProject(getProjectFromIEditorPart(this));

	// set filename as displayed tab name
	activeFilePath = ((IFileEditorInput) input).getFile().getLocation();
	String pathString = activeFilePath.toOSString();
	this.setPartName(pathString.substring(pathString.lastIndexOf(File.separator) + 1));

	activeFilePath = ((IFileEditorInput) input).getFile().getLocation();
}
 
源代码6 项目: 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;
	}
 
源代码7 项目: birt   文件: IDEMultiPageReportEditor.java
protected void setInput( IEditorInput input )
{

	// The workspace never changes for an editor. So, removing and re-adding
	// the
	// resourceListener is not necessary. But it is being done here for the
	// sake
	// of proper implementation. Plus, the resourceListener needs to be
	// added
	// to the workspace the first time around.
	if ( isWorkspaceResource )
	{
		getFile( getEditorInput( ) ).getWorkspace( )
				.removeResourceChangeListener( resourceListener );
	}

	isWorkspaceResource = input instanceof IFileEditorInput;

	super.setInput( input );

	if ( isWorkspaceResource )
	{
		getFile( getEditorInput( ) ).getWorkspace( )
				.addResourceChangeListener( resourceListener );
	}
}
 
源代码8 项目: xds-ide   文件: CoreEditorUtils.java
/**
    * Returns File underlying this editor input. 
    * 
    * This method should be modified, whenever new editor input is supported 
    * for some editor requiring access to File.
    * 
    * @param input the editor input to operate on.
    * 
    * @return file underlying given editor input.
    */    
   public static File editorInputToFile(IEditorInput input) {
	if (input == null) 
	    return null;
	
       if (input instanceof IFileEditorInput) {
       	IFile file = editorInputToIFile(input);
           if (file != null) {
               return ResourceUtils.getAbsoluteFile(file);
           }
       }
       else if (input instanceof IURIEditorInput) {
           IURIEditorInput uriEditorInput = (IURIEditorInput) input;
           return new File(uriEditorInput.getURI());
       }
       else if (input instanceof CommonSourceNotFoundEditorInput || input instanceof CompareEditorInput || input instanceof IStorageEditorInput) {
       	// do nothing
	}
       else{
       	LogHelper.logError("Unknown editor input");
       }
       
       return null;
}
 
源代码9 项目: APICloud-Studio   文件: EditorUtil.java
/**
 * Returns the project that the file for the editor belongs.
 * 
 * @param editor
 *            a file editor
 * @return the project the editor belongs
 */
public static IProject getProject(AbstractThemeableEditor editor)
{
	if (editor != null)
	{
		IEditorInput editorInput = editor.getEditorInput();

		if (editorInput instanceof IFileEditorInput)
		{
			IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
			return fileEditorInput.getFile().getProject();
		}
	}

	return null;
}
 
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
	//TODO same code in JavaSearchResult
	IEditorInput editorInput= editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput)  {
		IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
		return computeContainedMatches(result, fileEditorInput.getFile());

	} else if (editorInput instanceof IClassFileEditorInput) {
		IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
		IClassFile classFile= classFileEditorInput.getClassFile();

		Object[] elements= getElements();
		if (elements.length == 0)
			return NO_MATCHES;
		//all matches from same file:
		JavaElementLine jel= (JavaElementLine) elements[0];
		if (jel.getJavaElement().equals(classFile))
			return collectMatches(elements);
	}
	return NO_MATCHES;
}
 
源代码11 项目: spotbugs   文件: BugInfoView.java
private boolean matchInput(IEditorInput input) {
    if (file != null && (input instanceof IFileEditorInput)) {
        return file.equals(((IFileEditorInput) input).getFile());
    }
    if (javaElt != null && input != null) {
        IJavaElement javaElement = JavaUI.getEditorInputJavaElement(input);
        if (javaElt.equals(javaElement)) {
            return true;
        }
        IJavaElement parent = javaElt.getParent();
        while (parent != null && !parent.equals(javaElement)) {
            parent = parent.getParent();
        }
        if (parent != null && parent.equals(javaElement)) {
            return true;
        }
    }
    return false;
}
 
源代码12 项目: CppStyle   文件: ClangFormatFormatter.java
private static IPath getSourceFilePathFromEditorInput(IEditorInput editorInput) {
	if (editorInput instanceof IURIEditorInput) {
		URI uri = ((IURIEditorInput) editorInput).getURI();
		if (uri != null) {
			IPath path = URIUtil.toPath(uri);
			if (path != null) {
				  return path;
			}
		}
	}

	if (editorInput instanceof IFileEditorInput) {
		IFile file = ((IFileEditorInput) editorInput).getFile();
		if (file != null) {
			return file.getLocation();
		}
	}

	if (editorInput instanceof ILocationProvider) {
		return ((ILocationProvider) editorInput).getPath(editorInput);
	}

	return null;
}
 
源代码13 项目: tlaplus   文件: TLAProofFoldingStructureProvider.java
/**
 * Initializes this folding structure provider for the given editor.
 * 
 * @param editor
 */
public TLAProofFoldingStructureProvider(TLAEditor editor)
{
    canPerformFoldingCommands = true;
    this.editor = editor;
    this.document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    foldPositions = new Vector<TLAProofPosition>();

    // add this as listener to document to listen for changes
    document.addDocumentListener(this);

    // get a parse result if the parse result broadcaster has already stored one
    if (editor.getEditorInput() instanceof IFileEditorInput) {
    	IFileEditorInput editorInput = (IFileEditorInput) editor.getEditorInput();
    	IPath location = editorInput.getFile().getLocation();
    	ParseResult parseResult = ParseResultBroadcaster.getParseResultBroadcaster().getParseResult(location);
    	if (parseResult != null)
    	{
    		newParseResult(parseResult);
    	}
    }

    // now listen to any new parse results
    ParseResultBroadcaster.getParseResultBroadcaster().addParseResultListener(this);

}
 
源代码14 项目: birt   文件: ResourceCloseManagement.java
private static IFile getEditorFile( IEditorReference fileRef )
{
	if ( fileRef != null )
	{
		IEditorPart part = (IEditorPart) fileRef.getPart( false );
		if ( part != null )
		{
			IEditorInput input = part.getEditorInput( );

			if ( input != null && input instanceof IFileEditorInput )
			{
				return ( (IFileEditorInput) input ).getFile( );
			}
		}
	}
	return null;
}
 
源代码15 项目: tracecompass   文件: EditorInputPropertyTester.java
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {

    if (IS_EXPERIMENT_EDITOR_INPUT.equals(property)) {
        if (receiver instanceof IFileEditorInput) {
            IFileEditorInput editorInput = (IFileEditorInput) receiver;
            IFile file = editorInput.getFile();
            if (file != null) {
                try {
                    final String traceTypeId = file.getPersistentProperty(TmfCommonConstants.TRACETYPE);
                    if (traceTypeId != null && ITmfEventsEditorConstants.EXPERIMENT_INPUT_TYPE_CONSTANTS.contains(traceTypeId)) {
                        return true;
                    }
                } catch (CoreException e) {
                    // Ignore
                }
            }
        }
    }
    return false;
}
 
源代码16 项目: APICloud-Studio   文件: ReViewerAction.java
@Override
public void run(IAction action) {
	IFile file = null;
	IEditorInput input = targetEditor.getEditorInput();
	if(input instanceof IFileEditorInput) {
		file = ((IFileEditorInput) input).getFile();
	}
	String url = file.getLocation().toOSString();
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if(window == null) return;
	IWorkbenchPage  page = window.getActivePage();
	if(page == null) return;
	WebBrowserView part = (WebBrowserView)page.findView("com.aptana.browser.views.webbrowser");
	if(part != null) {
		page.bringToTop(part);
		part.setURL(url);
		return;
	}
	try {
		WebBrowserView view = (WebBrowserView)page.showView("com.aptana.browser.views.webbrowser");
		view.setURL(url);
	} catch (PartInitException e) {
		e.printStackTrace();
	}

}
 
源代码17 项目: statecharts   文件: ActiveEditorTracker.java
/**
 * @return The project which contains the file that is open in the last
 *         active editor in the current workbench page.
 */
public static IProject getLastActiveEditorProject() {
	final IEditorPart editor = getLastActiveEditor();
	if (editor == null)
		return null;
	final IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		final IFileEditorInput input = (IFileEditorInput) editorInput;
		return input.getFile().getProject();
	} else if (editorInput instanceof URIEditorInput) {
		final URI uri = ((URIEditorInput) editorInput).getURI();
		if (uri.isPlatformResource()) {
			final String platformString = uri.toPlatformString(true);
			return ResourcesPlugin.getWorkspace().getRoot().findMember(platformString).getProject();
		}
	}
	return null;
}
 
/**
 * Creates a new properties key hyperlink.
 *
 * @param region the region
 * @param key the properties key
 * @param editor the text editor
 */
public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) {
	Assert.isNotNull(region);
	Assert.isNotNull(key);
	Assert.isNotNull(editor);

	fRegion= region;
	fPropertiesKey= key;
	fEditor= editor;
	fIsFileEditorInput= fEditor.getEditorInput() instanceof IFileEditorInput;
	IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput();
	fShell= fEditor.getEditorSite().getShell();
	try {
		fStorage= storageEditorInput.getStorage();
	} catch (CoreException e) {
		fStorage= null;
	}
}
 
/**
 * Checks whether the passed file editor input defines a Java properties file.
 * 
 * @param element the file editor input
 * @return <code>true</code> if element defines a Java properties file, <code>false</code>
 *         otherwise
 * @throws CoreException
 * 
 * @since 3.7
 */
public static boolean isJavaPropertiesFile(Object element) throws CoreException {
	if (JAVA_PROPERTIES_FILE_CONTENT_TYPE == null || !(element instanceof IFileEditorInput))
		return false;

	IFileEditorInput input= (IFileEditorInput)element;

	IFile file= input.getFile();
	if (file == null || !file.isAccessible())
		return false;

	IContentDescription description= file.getContentDescription();
	if (description == null || description.getContentType() == null || !description.getContentType().isKindOf(JAVA_PROPERTIES_FILE_CONTENT_TYPE))
		return false;

	return true;
}
 
源代码20 项目: depan   文件: GraphEditor.java
private void initFromInput(IEditorInput input) throws PartInitException {

    if (!(input instanceof IFileEditorInput)) {
      throw new PartInitException("Invalid Input: Must be IFileEditorInput");
    }

    // load the graph
    file = ((IFileEditorInput) input).getFile();

    GraphDocLogger.LOG.info("Reading {}", file.getRawLocationURI());
    graph = ResourceCache.fetchGraphDocument(file);
    GraphDocLogger.LOG.info("  DONE");

    DependencyModel model = graph.getDependencyModel();
    graphResources = GraphResourceBuilder.forModel(model);

    // set the title to the filename, excepted the file extension
    String title = file.getName();
    title = title.substring(0, title.lastIndexOf('.'));
    this.setPartName(title);
  }
 
源代码21 项目: dartboard   文件: LaunchShortcut.java
@Override
public void launch(IEditorPart editor, String mode) {
	IProject project = null;
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		project = ((IFileEditorInput) editorInput).getFile().getProject();
	}

	launchProject(project, mode);
}
 
源代码22 项目: n4js   文件: LaunchXpectShortcut.java
@Override
public void launch(IEditorPart editor, String mode) {
	try {
		IEditorInput editorInput = editor.getEditorInput();
		if (editorInput instanceof IFileEditorInput) {
			IFile selectObj = ((IFileEditorInput) editorInput).getFile();
			launchFile(selectObj, mode);
		} else {
			showDialogNotImplemented(editor.getClass().getName());
		}
	} catch (CoreException e) {
		System.out.println(e.getLocalizedMessage() + "\n");
	}
}
 
源代码23 项目: n4js   文件: GenerateXpectReportShortcut.java
@Override
public void launch(IEditorPart editor, String mode) {
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		IFile selectObj = ((IFileEditorInput) editorInput).getFile();
		generateBug(selectObj);
	} else {
		showDialogNotImplemented(editor.getClass().getName());
	}
}
 
源代码24 项目: e4macs   文件: TagsSearchHandler.java
protected IProject getCurrentProject(ITextEditor editor) {
	if (editor != null) {
		IEditorInput input = editor.getEditorInput();
		if (input instanceof IFileEditorInput) {
			return ((IFileEditorInput) input).getFile().getProject();
		}
	}
	return null;
}
 
源代码25 项目: n4js   文件: FileExtensionBasedPropertTester.java
private IFile tryGetFileFromActiveEditor() {
	final Optional<IEditorPart> editor = getActiveEditor();
	if (editor.isPresent() && editor.get().getEditorInput() instanceof IFileEditorInput) {
		return ((IFileEditorInput) editor.get().getEditorInput()).getFile();
	}
	return null;

}
 
源代码26 项目: erflute   文件: AbstractBaseAction.java
protected void refreshProject() {
    final IFile iFile = ((IFileEditorInput) getEditorPart().getEditorInput()).getFile();
    final IProject project = iFile.getProject();
    try {
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (final CoreException e) {
        Activator.showExceptionDialog(e);
    }
}
 
源代码27 项目: tesb-studio-se   文件: ServiceEditorInput.java
@Override
public boolean equals(final Object obj) {
    if (obj == null) {
        return false;
    }
    if (obj instanceof IFileEditorInput) {
        return getFile().equals(((IFileEditorInput) obj).getFile());
    }
    return false;
}
 
源代码28 项目: n4js   文件: AbstractRunnerLaunchShortcut.java
@Override
public void launch(IEditorPart editor, String mode) {
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		IFile selectObj = ((IFileEditorInput) editorInput).getFile();
		launchFile(selectObj, mode);
	} else {
		showDialogNotImplemented(editor.getClass().getName());
	}
}
 
源代码29 项目: ContentAssist   文件: EditorUtilities.java
/**
 * Obtains a file existing on an editor.
 * @param editor the editor
 * @return the file existing on the editor, or <code>null</code> if none
 */
public static IFile getInputFile(IEditorPart editor) {
    IEditorInput input = editor.getEditorInput();
    if (input instanceof IFileEditorInput) {
        IFile file = ((IFileEditorInput)input).getFile();
        return file;
    }
    return null;
}
 
private IResource getResource() {
	IEditorInput input= fTextEditor.getEditorInput();
	if (input instanceof IFileEditorInput) {
		IFileEditorInput fileInput= (IFileEditorInput) input;
		return fileInput.getFile();
	}
	return null;
}
 
 类所在包
 类方法
 同包方法