类org.eclipse.ui.part.FileEditorInput源码实例Demo

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

源代码1 项目: Pydev   文件: PyEditorInputFactory.java
@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));
}
 
源代码2 项目: neoscada   文件: DetailViewEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码3 项目: neoscada   文件: VisualInterfaceEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码4 项目: neoscada   文件: ProfileEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码5 项目: neoscada   文件: OsgiEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码6 项目: neoscada   文件: MemoryEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码7 项目: neoscada   文件: RecipeEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码8 项目: neoscada   文件: InfrastructureEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码9 项目: tlaplus   文件: TLAEditor.java
protected void initEditorNameAndDescription(final IEditorInput input) {
       // setup the content description and image of spec root
       if (input instanceof FileEditorInput)
       {
           final FileEditorInput finput = (FileEditorInput) input;
           if (finput != null)
           {
               final IPath path = finput.getPath();
               setContentDescription(path.toString());

               if (ResourceHelper.isRoot(finput.getFile()))
               {
                   setTitleImage(rootImage);
               }
           }
       }
}
 
源代码10 项目: bonita-studio   文件: ProcessNavigatorLinkHelper.java
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
源代码11 项目: neoscada   文件: ConfigurationEditor.java
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
 
源代码12 项目: birt   文件: ResourceCloseManagement.java
private static String getResourceType( List<IResource> resources,
		List<IEditorPart> openedFiles )
{

	IResource currentResource = resources.get( 0 );
	IEditorInput editorInput = openedFiles.get( 0 ).getEditorInput( );

	if ( editorInput instanceof FileEditorInput )
	{
		currentResource = ( (FileEditorInput) editorInput ).getFile( );
	}

	switch ( currentResource.getType( ) )
	{
		case IResource.FILE :
			return openedFiles.size( ) != 1 ? Messages.getString( "renameChecker.closeResourceMessage.forManyFile" ) //$NON-NLS-1$
					: currentResource.getName( ) + " " //$NON-NLS-1$
							+ Messages.getString( "renameChecker.closeResourceMessage.forOneFile" ); //$NON-NLS-1$
		case IResource.PROJECT :
			return Messages.getString( "renameChecker.closeResourceMessage.forProject" ); //$NON-NLS-1$
		default :
			return Messages.getString( "renameChecker.closeResourceMessage.forFolder" ); //$NON-NLS-1$
	}
}
 
源代码13 项目: bonita-studio   文件: ProcessDocumentProvider.java
/**
* @generated BonitaSoft
*/
protected IDocument createDocument(Object element) throws CoreException {
	if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
		throw new CoreException(new Status(IStatus.ERROR,
				org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditorPlugin.ID, 0,
				NLS.bind(Messages.ProcessDocumentProvider_IncorrectInputError,
						new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$
								"org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ 
				null));
	}
	String id = null;
	if (element instanceof FileEditorInput) {
		FileEditorInput fInput = (FileEditorInput) element;
		id = fInput.getName();
	} else if (element instanceof URIEditorInput) {
		id = URI.decode(((URIEditorInput) element).getURI().lastSegment());
	}
	IDocument document = createEmptyDocument(id);
	setDocumentContent(document, (IEditorInput) element);
	setupDocument(element, document);
	return document;
}
 
源代码14 项目: scava   文件: CrossflowDocumentProvider.java
/**
* @generated
*/
protected ElementInfo createElementInfo(Object element) throws CoreException {
	if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
		throw new CoreException(new Status(IStatus.ERROR, CrossflowDiagramEditorPlugin.ID, 0,
				NLS.bind(Messages.CrossflowDocumentProvider_IncorrectInputError,
						new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$
								"org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ 
				null));
	}
	IEditorInput editorInput = (IEditorInput) element;
	IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);

	ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
	info.setModificationStamp(computeModificationStamp(info));
	info.fStatus = null;
	return info;
}
 
源代码15 项目: eclipse-wakatime   文件: WakaTime.java
public static String getActiveProject() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) return null;
    if (window.getPartService() == null) return null;
    if (window.getPartService().getActivePart() == null) return null;
    if (window.getPartService().getActivePart().getSite() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return null;

    IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput();

    IProject project = null;

    if (input instanceof FileEditorInput) {
        project = ((FileEditorInput)input).getFile().getProject();
    }

    if (project == null)
        return null;

    return project.getName();
}
 
源代码16 项目: scava   文件: CrossflowDocumentProvider.java
/**
* @generated
*/
public boolean isModifiable(Object element) {
	if (!isStateValidated(element)) {
		if (element instanceof FileEditorInput || element instanceof URIEditorInput) {
			return true;
		}
	}
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		if (info.isUpdateCache()) {
			try {
				updateCache(element);
			} catch (CoreException ex) {
				CrossflowDiagramEditorPlugin.getInstance().logError(Messages.CrossflowDocumentProvider_isModifiable,
						ex);
				// Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
			}
		}
		return info.isModifiable();
	}
	return super.isModifiable(element);
}
 
源代码17 项目: translationstudio8   文件: EditProgressFA.java
public void printTransProgFAReslut() {
	String htmlPath = createFAResultHtml();
	try {
		model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_ONE, null);
	} catch (CoreException e1) {
		e1.printStackTrace();
		logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log1"), e1);
	}
	
	final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
	
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
			} catch (PartInitException e) {
				e.printStackTrace();
				logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log2"), e);
			}
		}
	});
}
 
源代码18 项目: statecharts   文件: NavigatorLinkHelper.java
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (Iterator<EObject> it = diagramResource.getContents().iterator(); it
			.hasNext();) {
		EObject nextEObject = (EObject) it.next();
		if (nextEObject == diagram) {
			return new FileEditorInput(
					WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + "#"
			+ diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
源代码19 项目: uima-uimaj   文件: MultiPageEditor.java
/**
 * Open text editor.
 *
 * @param fileToOpen the file to open
 */
public void openTextEditor(IFile fileToOpen) {
  final IFile ffile = fileToOpen;
  Shell shell = new Shell();
  shell.getDisplay().asyncExec(new Runnable() {
    @Override
    public void run() {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      try {
        page.openEditor(new FileEditorInput(ffile), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
      } catch (PartInitException e) {
        throw new InternalErrorCDE("unexpected exception");
      }
    }
  });
}
 
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
源代码21 项目: xtext-eclipse   文件: ChangeConverter.java
protected ITextEditor findOpenEditor(IFile file) {
	if (workbench == null) {
		return null;
	}

	return new DisplayRunnableWithResult<ITextEditor>() {

		@Override
		protected ITextEditor run() throws Exception {
			FileEditorInput editorInput = new FileEditorInput(file);
			IEditorPart editorPart = workbench.getActiveWorkbenchWindow().getActivePage().findEditor(editorInput);
			if (editorPart instanceof ITextEditor) {
				return (ITextEditor) editorPart;
			}
			return null;
		}
	}.syncExec();
}
 
源代码22 项目: translationstudio8   文件: MatchViewPart.java
public void reLoadMatches(IXliffEditor editor, int rowIndex) {
	// 修复 Bug #3064 编辑匹配--更换记忆库后再编辑原记忆库匹配,出现异常.刷新问题
	TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);// handler.getTransUnit(rowId);
	if (transUnit == null) {
		return;
	}
	XLFHandler handler = editor.getXLFHandler();
	if (handler == null) {
		return;
	}

	IProject prj = null;
	if (editor instanceof IEditorPart) {
		IEditorPart p = (IEditorPart) editor;
		FileEditorInput input = (FileEditorInput) p.getEditorInput();
		prj = input.getFile().getProject();
	}
	if (prj == null) {
		return;
	}
	String rowId = handler.getRowId(rowIndex);
	TransUnitInfo2TranslationBean tuInfoBean = getTuInfoBean(transUnit, handler, rowId);
	executeMatch(editor, rowId, transUnit, tuInfoBean, prj);
}
 
源代码23 项目: texlipse   文件: BibDocumentModel.java
/**
 * Updates the BibTeX -data in the BibTeX-container.
 */
private void updateBibContainer() {
	IProject project = editor.getProject();
	if (project == null) return;
	
    IResource resource = ((FileEditorInput)editor.getEditorInput()).getFile();
    if (bibContainer == null) {
        ReferenceContainer refCon = (ReferenceContainer) TexlipseProperties.getSessionProperty(project,
                TexlipseProperties.BIBCONTAINER_PROPERTY);
        if (refCon != null) {
            bibContainer = refCon;
        } else {
            return;
        }
    }
    boolean changed = bibContainer.updateRefSource(
            resource.getFullPath().removeFirstSegments(1).toString(),
            entryList);
    if (changed) {
        TexlipseProperties.setSessionProperty(project,
                TexlipseProperties.BIBFILES_CHANGED,
                new Boolean(true));
    }
}
 
源代码24 项目: texlipse   文件: SpellUncheckAction.java
/**
    * Clear the spelling error markers.
    * @param action the action
 */
public void run(IAction action) {
       
       if (targetEditor == null) {
           return;
       }
       if (!(targetEditor instanceof ITextEditor)) {
           return;
       }
       
       ITextEditor textEditor = (ITextEditor) targetEditor;
       IEditorInput input = textEditor.getEditorInput();
       
       if (input instanceof FileEditorInput) {
           SpellChecker.clearMarkers(((FileEditorInput)input).getFile());
       }
}
 
源代码25 项目: xds-ide   文件: GotoCompilationUnitHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = WorkbenchUtils.getActivePartShell();
    
    HashSet<String> exts = new HashSet<String>(); 
    exts.addAll(XdsFileUtils.COMPILATION_UNIT_FILE_EXTENSIONS);
    
    SelectModulaSourceFileDialog dlg = new SelectModulaSourceFileDialog(Messages.GotoCompilationUnitHandler_OpenModule, shell, ResourceUtils.getWorkspaceRoot(), exts);
    if (SelectModulaSourceFileDialog.OK == dlg.open()){
        IFile file = (IFile)dlg.getResultAsResource();
        if (file != null) {
            IEditorInput editorInput = new FileEditorInput(file);
            try {
            	CoreEditorUtils.openInEditor(editorInput, true);
            } catch (CoreException e) {
                LogHelper.logError(e);
            }
        }
    }
    return null;
}
 
源代码26 项目: xds-ide   文件: NewModuleWizard.java
private void openInEditor(final IProject project, File f) {
if (f.isFile()) {
       // Open created main module in editor:
       final String resoureRelativePath = ResourceUtils.getRelativePath(project, f.getAbsolutePath());
       if (resoureRelativePath != null) {
           Display.getDefault().asyncExec(new Runnable() {
               @Override
               public void run() {
                   IFile file = project.getFile(resoureRelativePath);
                   IEditorInput editorInput = new FileEditorInput(file);
                   try {
                   	CoreEditorUtils.openInEditor(editorInput, true);
                   } catch (CoreException e) {
                   }
               }
           });
       }
   }
  }
 
源代码27 项目: xds-ide   文件: NewOb2ModuleWizard.java
private void openInEditor(final IProject project, File f) {
if (f.isFile()) {
       // Open created main module in editor:
       final String resoureRelativePath = ResourceUtils.getRelativePath(project, f.getAbsolutePath());
       if (resoureRelativePath != null) {
           Display.getDefault().asyncExec(new Runnable() {
               @Override
               public void run() {
                   IFile file = project.getFile(resoureRelativePath);
                   IEditorInput editorInput = new FileEditorInput(file);
                   try {
                   	CoreEditorUtils.openInEditor(editorInput, true);
                   } catch (CoreException e) {
                   }
               }
           });
       }
   }
  }
 
源代码28 项目: xds-ide   文件: ModulaSearchResultPage.java
protected void showMatch( Match match, int currentOffset
                        , int currentLength, boolean activate 
                        ) throws PartInitException 
{
    if (match instanceof ModulaSymbolMatch) {
        try {
            ModulaSymbolMatch em = (ModulaSymbolMatch)match;
            IFile f = em.getFile();
            IWorkbenchPage page = WorkbenchUtils.getActivePage();
            IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(f.getName());
            IEditorPart ep = page.openEditor(new FileEditorInput(f), desc.getId());
            ITextEditor te = (ITextEditor)ep;
            Control ctr = (Control)te.getAdapter(Control.class);
            ctr.setFocus();
            te.selectAndReveal(em.getOffset(), em.getLength());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码29 项目: gef   文件: DotGraphView.java
/**
 * if the active editor is the DOT Editor, update the graph, otherwise
 * do nothing
 */
private void checkActiveEditorAndUpdateGraph(IWorkbenchPart part) {
	if (DotEditorUtils.isDotEditor(part)) {
		IEditorInput editorInput = ((EditorPart) part).getEditorInput();
		if (editorInput instanceof FileEditorInput) {
			IFile file = ((FileEditorInput) editorInput).getFile();
			try {
				File resolvedFile = DotFileUtils
						.resolve(file.getLocationURI().toURL());
				if (!resolvedFile.equals(currentFile)) {
					updateGraph(resolvedFile);
				}
			} catch (MalformedURLException e) {
				DotActivatorEx.logError(e);
			}
		}
	}
}
 
final JavaEditor getEditor(IFile file) {
	FileEditorInput fei= new FileEditorInput(file);
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
	for (int i= 0; i < windows.length; i++) {
		IWorkbenchPage[] pages= windows[i].getPages();
		for (int x= 0; x < pages.length; x++) {
			IEditorPart[] editors= pages[x].getDirtyEditors();
			for (int z= 0; z < editors.length; z++) {
				IEditorPart ep= editors[z];
				if (ep instanceof JavaEditor) {
					JavaEditor je= (JavaEditor) ep;
					if (fei.equals(je.getEditorInput()))
						return (JavaEditor) ep;
				}
			}
		}
	}
	return null;
}
 
 类所在包
 类方法
 同包方法