org.eclipse.ui.part.FileEditorInput Java Examples

The following examples show how to use org.eclipse.ui.part.FileEditorInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TLAEditor.java    From tlaplus with MIT License 6 votes vote down vote up
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);
               }
           }
       }
}
 
Example #2
Source File: VisualInterfaceEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #3
Source File: PyEditorInputFactory.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@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));
}
 
Example #4
Source File: SyncGraphvizExportHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void openFile(IFile file) {
	IEditorRegistry registry = PlatformUI.getWorkbench()
			.getEditorRegistry();
	if (registry.isSystemExternalEditorAvailable(file.getName())) {

		/**
		 * in case of opening the exported file from an other thread e.g. in
		 * case of listening to an IResourceChangeEvent
		 */
		Display.getDefault().asyncExec(new Runnable() {

			@Override
			public void run() {
				IWorkbenchPage page = PlatformUI.getWorkbench()
						.getActiveWorkbenchWindow().getActivePage();
				try {
					page.openEditor(new FileEditorInput(file),
							IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
				} catch (PartInitException e) {
					DotActivatorEx.logError(e);
				}
			}
		});
	}
}
 
Example #5
Source File: GotoCompilationUnitHandler.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: NewModuleWizard.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
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) {
                   }
               }
           });
       }
   }
  }
 
Example #7
Source File: JavaHistoryActionImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: NewOb2ModuleWizard.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
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) {
                   }
               }
           });
       }
   }
  }
 
Example #9
Source File: ModulaSearchResultPage.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
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();
        }
    }
}
 
Example #10
Source File: DotGraphView.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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);
			}
		}
	}
}
 
Example #11
Source File: ProfileEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #12
Source File: OsgiEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #13
Source File: SpellUncheckAction.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * 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());
       }
}
 
Example #14
Source File: MemoryEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #15
Source File: InfrastructureEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #16
Source File: RecipeEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #17
Source File: ProcessNavigatorLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @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;
}
 
Example #18
Source File: BibDocumentModel.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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));
    }
}
 
Example #19
Source File: ConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example #20
Source File: ResourceCloseManagement.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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$
	}
}
 
Example #21
Source File: ProcessDocumentProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @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;
}
 
Example #22
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @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;
}
 
Example #23
Source File: WakaTime.java    From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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();
}
 
Example #24
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @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);
}
 
Example #25
Source File: EditProgressFA.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example #26
Source File: MatchViewPart.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #27
Source File: NavigatorLinkHelper.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #28
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * 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");
      }
    }
  });
}
 
Example #29
Source File: ChangeConverter.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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();
}
 
Example #30
Source File: ProcessNavigatorActionProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @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;
}