org.eclipse.ui.ide.FileStoreEditorInput Java Examples

The following examples show how to use org.eclipse.ui.ide.FileStoreEditorInput. 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: NavigatorLinkHelper.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput input) {
  IFile file = ResourceUtil.getFile(input);

  if (file != null) {
    return new StructuredSelection(file);
  }

  IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class);

  if (fileStore == null && input instanceof FileStoreEditorInput) {
    URI uri = ((FileStoreEditorInput)input).getURI();
    
    try {
      fileStore = EFS.getStore(uri);
    } catch (CoreException e) {

    }
  }
  
  if (fileStore != null) {
    return new StructuredSelection(fileStore);
  }

  return StructuredSelection.EMPTY;
}
 
Example #2
Source File: DataSourceHelper.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取数据源
 * @param editorInput
 * @return ;
 */
@SuppressWarnings("unchecked")
public T getDataSource(IEditorInput editorInput) {
	if (editorInput instanceof FileEditorInput) {
		if (editorInput instanceof FileEditorInput) {
			FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
			IFile file = fileEditorInput.getFile();
			return this.getDataSource(file);
		}
	} else if (editorInput instanceof FileStoreEditorInput) {
		FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
		Object obj = map.get(generateKey(fileStoreEditorInput));
		if (dataSourceClass.isInstance(obj)) {
			return (T) obj;
		}
	}
	return null;
}
 
Example #3
Source File: IDEReportDocumentEditor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init( IEditorSite site, IEditorInput input )
		throws PartInitException
{
	super.init( site, input );
	if ( input instanceof IFileEditorInput )
	{
		String fileName = ( (IFileEditorInput) input ).getFile( )
				.getLocation( )
				.toOSString( );
		setFileName( fileName );
		int index = fileName.lastIndexOf( File.separator );

		setPartName( fileName.substring( index + 1, fileName.length( ) ) );
	}
	else if ( input instanceof FileStoreEditorInput )
	{
		setFileName( ( (FileStoreEditorInput) input ).getURI( )
				.getRawPath( ) );
		setPartName( ( (FileStoreEditorInput) input ).getName( ) );
	}

}
 
Example #4
Source File: DataSourceHelper.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取数据源
 * @param editorInput
 * @return ;
 */
@SuppressWarnings("unchecked")
public T getDataSource(IEditorInput editorInput) {
	if (editorInput instanceof FileEditorInput) {
		if (editorInput instanceof FileEditorInput) {
			FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
			IFile file = fileEditorInput.getFile();
			return this.getDataSource(file);
		}
	} else if (editorInput instanceof FileStoreEditorInput) {
		FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
		Object obj = map.get(generateKey(fileStoreEditorInput));
		if (dataSourceClass.isInstance(obj)) {
			return (T) obj;
		}
	}
	return null;
}
 
Example #5
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 #6
Source File: EditorUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the resource file that the editor belongs to.
 * 
 * @param editor
 * @return
 */
public static IFile getEditorFile(AbstractThemeableEditor editor)
{
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput)
	{
		IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
		return fileEditorInput.getFile();
	}
	else if (editorInput instanceof FileStoreEditorInput)
	{
		FileStoreEditorInput input = (FileStoreEditorInput) editorInput;
		IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(input.getURI());
		if (files != null && files.length > 0)
		{
			return files[0];
		}
	}
	return null;
}
 
Example #7
Source File: FileStoreEditorInputAdapterFactory.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Object getAdapter(Object adaptableObject, Class adapterType)
{
	if (IUniformResource.class == adapterType)
	{
		if (adaptableObject instanceof FileStoreEditorInput)
		{
			return new FileStoreEditorInputUniformResource((FileStoreEditorInput) adaptableObject);
		}
	}
	else if (IFile.class == adapterType)
	{
		if (adaptableObject instanceof FileStoreEditorInput)
		{
			URI uri = ((FileStoreEditorInput) adaptableObject).getURI();
			IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
			if (files.length == 1)
			{
				return files[0];
			}
		}
	}
	return null;
}
 
Example #8
Source File: EditorInputFactory.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates an editor input for the passed file.
 *
 * If forceExternalFile is True, it won't even try to create a FileEditorInput, otherwise,
 * it will try to create it with the most suitable type it can
 * (i.e.: FileEditorInput, FileStoreEditorInput, PydevFileEditorInput, ...)
 */
public static IEditorInput create(File file, boolean forceExternalFile) {
    IPath path = Path.fromOSString(FileUtils.getFileAbsolutePath(file));

    if (!forceExternalFile) {
        //May call again to this method (but with forceExternalFile = true)
        IEditorInput input = new PySourceLocatorBase().createEditorInput(path, false, null, null);
        if (input != null) {
            return input;
        }
    }

    IPath zipPath = new Path("");
    while (path.segmentCount() > 0) {
        if (path.toFile().exists()) {
            break;
        }
        zipPath = new Path(path.lastSegment()).append(zipPath);
        path = path.uptoSegment(path.segmentCount() - 1);
    }

    if (zipPath.segmentCount() > 0 && path.segmentCount() > 0) {
        return new PydevZipFileEditorInput(new PydevZipFileStorage(path.toFile(), zipPath.toPortableString()));
    }

    try {
        URI uri = file.toURI();
        return new FileStoreEditorInput(EFS.getStore(uri));
    } catch (Throwable e) {
        //not always available! (only added in eclipse 3.3)
        return new PydevFileEditorInput(file);
    }
}
 
Example #9
Source File: DiagramPartitioningEditor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (input instanceof FileStoreEditorInput) {
		throw new PartInitException("An error occured while opening the file.\n\n"
				+ "This might have happened because you tried to open a statechart with File->Open File.\n"
				+ "This is not supported. Please import the file into a project instead.");
	}
	super.init(site, input);
}
 
Example #10
Source File: EditorUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private static IEditorInput getEditorInput(IFileStore fileStore) {
    IFile workspaceFile = getWorkspaceFile(fileStore);
    if (workspaceFile != null) {
        return new FileEditorInput(workspaceFile);
    }
    return new FileStoreEditorInput(fileStore);
}
 
Example #11
Source File: ExternalFileDocument.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void init(IEditorPart editor, IActiveDocumentAgentCallback callback) {
	if (!(editor.getEditorInput() instanceof FileStoreEditorInput)) {
		throw new IllegalArgumentException("part must provide FileStoreEditorInput.");
	}
	try {
		fileStore = EFS.getStore(((FileStoreEditorInput) editor.getEditorInput()).getURI());
	} catch (CoreException e) {
		throw new IllegalStateException(e);
	}
	super.init(editor, callback);
}
 
Example #12
Source File: ClassFileSingleDocument.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void init(IEditorPart editor, IActiveDocumentAgentCallback callback) {
	if (!(editor.getEditorInput() instanceof FileStoreEditorInput)) {
		throw new IllegalArgumentException("part must provide FileStoreEditorInput.");
	}
	try {
		fileStore = EFS.getStore(((FileStoreEditorInput) editor.getEditorInput()).getURI());
	} catch (CoreException e) {
		throw new IllegalStateException(e);
	}
	super.init(editor, callback);
}
 
Example #13
Source File: DataSourceHelper.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置数据源
 * @param editorInput
 * @param dataSource
 * @return ;
 */
public boolean setDataSource(IEditorInput editorInput, T dataSource) {
	if (editorInput instanceof FileEditorInput) {
		FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
		IFile file = fileEditorInput.getFile();
		return setDataSource(file, dataSource);
	} else if (editorInput instanceof FileStoreEditorInput) {
		FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
		map.put(generateKey(fileStoreEditorInput), dataSource);
		return true;
	}
	return false;
}
 
Example #14
Source File: IDEEditputProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IEditorInput createEditorInput( Object file )
{
	if (file instanceof File)
	{
		File handle = (File)file;
		String fileName = handle.getAbsolutePath( );
		
		IWorkspace space = ResourcesPlugin.getWorkspace( );
		IWorkspaceRoot root = space.getRoot( );
		try
		{
			//IFile[] resources = root.findFilesForLocationURI( new URL("file:///" + fileName ).toURI( ) ); //$NON-NLS-1$
			IFile[] resources = root.findFilesForLocationURI(new File( fileName ).toURI( ) ); //$NON-NLS-1$
			if (resources != null && resources.length > 0)
			{
				IEditorInput input = new FileEditorInput(resources[0]);
				return input;
			}
			else
			{
				IFileStore fileStore =  EFS.getLocalFileSystem().getStore(new Path(fileName));
				IFileInfo fetchInfo = fileStore.fetchInfo();
				if (!fetchInfo.isDirectory() && fetchInfo.exists())
				{
					return new FileStoreEditorInput(fileStore);
				}
			}
		}
		catch(Exception e)
		{
			return null;
		}
	}
	return null;
}
 
Example #15
Source File: ManifestMultiPageEditor.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void init(IEditorSite editorSite, IEditorInput editorInput) throws PartInitException {
    _editorInput = editorInput;
    _designerProject = ((BluemixManifestEditorInput)_editorInput).getDesignerProject();
    
    // Setup the bean and the bean loader
    _beanLoader = new ManifestBeanLoader("bluemix.manifest", (FileStoreEditorInput) editorInput, this); // $NON-NLS-1$
    _bean = new ManifestBean((FileStoreEditorInput)editorInput);
    
    super.init(editorSite, editorInput);
    getSite().setSelectionProvider(this);
}
 
Example #16
Source File: EditorUtils.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
public static IEditorInput createEditorInput(IStorage storage) {
	if (storage instanceof IFile)
		return new FileEditorInput((IFile) storage);
	try {
		if (storage instanceof IJarEntryResource)
			return new JarEntryEditorInput(storage);
	} catch (NoClassDefFoundError e) {
		// ignore. can happen if JDT is not available.
	}
	if (storage instanceof FileStoreStorage) {
		return new FileStoreEditorInput(((FileStoreStorage)storage).getFileStore());
	}
	return new XtextReadonlyEditorInput(storage);
}
 
Example #17
Source File: EditorUtils.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static IEditorInput getBestEditorInputForUri(URI uri, int memberFlags) {
	IFile[] files = ResourceUtils.getWorkspaceRoot().findFilesForLocationURI(uri, memberFlags);
	if(files.length != 0) {
		// As an improvement, if there is more than one file, we could try to see which one is more relevant
		// instead of just using the first one.
		IFile file = files[0]; 
		return new FileEditorInput(file);
	} else {
		//file not in workspace
		IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(uri);
		return new FileStoreEditorInput(fileOnLocalDisk);
	}
}
 
Example #18
Source File: DataSourceHelper.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置数据源
 * @param editorInput
 * @param dataSource
 * @return ;
 */
public boolean setDataSource(IEditorInput editorInput, T dataSource) {
	if (editorInput instanceof FileEditorInput) {
		FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
		IFile file = fileEditorInput.getFile();
		return setDataSource(file, dataSource);
	} else if (editorInput instanceof FileStoreEditorInput) {
		FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
		map.put(generateKey(fileStoreEditorInput), dataSource);
		return true;
	}
	return false;
}
 
Example #19
Source File: ManifestBean.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public ManifestBean (FileStoreEditorInput fei) {
    _file = new File(fei.getURI());
    loadFromFile();
}
 
Example #20
Source File: ExportAsTextHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	String elementName = event.getParameter("elementName");

	IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
	Shell shell = activeEditor.getEditorSite().getShell();
	if (activeEditor == null || !(activeEditor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) activeEditor;
	if (xliffEditor.isMultiFile()) {
		MessageDialog.openInformation(shell, "", "当前编辑器打开了多个文件,无法执行该操作。");
	}

	IEditorInput input = xliffEditor.getEditorInput();
	URI uri = null;
	if (input instanceof FileEditorInput) {
		uri = ((FileEditorInput) input).getURI();
	} else if (input instanceof FileStoreEditorInput) {
		uri = ((FileStoreEditorInput) input).getURI();
	} else {
		return null;
	}
	File xliff = new File(uri);

	FileDialog fd = new FileDialog(shell, SWT.SAVE);
	String[] names = { "Plain Text Files [*.txt]", "All Files [*.*]" };
	String[] extensions = { "*.txt", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
	fd.setFilterExtensions(extensions);
	fd.setFilterNames(names);

	fd.setFileName(xliff.getName() + ".txt"); //$NON-NLS-1$
	String out = fd.open();
	if (out == null) {
		return null;
	}

	XLFHandler handler = xliffEditor.getXLFHandler();
	boolean result = handler.saveAsText(xliff.getAbsolutePath(), out, elementName);

	if (result) {
		IWorkbenchPage page = xliffEditor.getEditorSite().getPage();
		OpenEditorUtil.OpenFileWithSystemEditor(page, out);
	} else {
		MessageDialog.openInformation(shell, "", "文件 “" + out + "” 保存失败!请重试。");
	}

	return null;
}
 
Example #21
Source File: ExportAsHtmlHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	String elementName = event.getParameter("elementName");

	IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
	Shell shell = activeEditor.getEditorSite().getShell();
	if (activeEditor == null || !(activeEditor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) activeEditor;
	if (xliffEditor.isMultiFile()) {
		MessageDialog.openInformation(shell, "", "当前编辑器打开了多个文件,无法执行该操作。");
	}

	IEditorInput input = xliffEditor.getEditorInput();
	URI uri = null;
	if (input instanceof FileEditorInput) {
		uri = ((FileEditorInput) input).getURI();
	} else if (input instanceof FileStoreEditorInput) {
		uri = ((FileStoreEditorInput) input).getURI();
	} else {
		return null;
	}
	File xliff = new File(uri);

	FileDialog fd = new FileDialog(shell, SWT.SAVE);
	String[] names = { "HTML Files [*.html]", "All Files [*.*]" };
	String[] extensions = { "*.html", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
	fd.setFilterExtensions(extensions);
	fd.setFilterNames(names);

	fd.setFileName(xliff.getName() + ".html"); //$NON-NLS-1$
	String out = fd.open();
	if (out == null) {
		return null;
	}

	XLFHandler handler = xliffEditor.getXLFHandler();
	boolean result = handler.saveAsHtml(xliff.getAbsolutePath(), out, elementName);

	if (result) {
		IWorkbenchPage page = xliffEditor.getEditorSite().getPage();
		OpenEditorUtil.OpenFileWithSystemEditor(page, out);
	} else {
		MessageDialog.openInformation(shell, "", "文件 “" + out + "” 保存失败!请重试。");
	}

	return null;
}
 
Example #22
Source File: Exercise3.java    From dawnsci with Eclipse Public License 1.0 4 votes vote down vote up
private static IEditorInput getExternalFileStoreEditorInput(String filename) {
	final IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(new File(filename));
	return new FileStoreEditorInput(externalFile);
}
 
Example #23
Source File: TestUtils.java    From dawnsci with Eclipse Public License 1.0 4 votes vote down vote up
public static IEditorInput getExternalFileStoreEditorInput(String filename) {
	final IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(new File(filename));
	return new FileStoreEditorInput(externalFile);
}
 
Example #24
Source File: ManifestBeanLoader.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public ManifestBeanLoader(String namespace, FileStoreEditorInput manifestInput, ManifestMultiPageEditor parentEditor) {
    super(namespace);
    _parentEditor = parentEditor;       
}
 
Example #25
Source File: ExportAsTextHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	String elementName = event.getParameter("elementName");

	IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
	Shell shell = activeEditor.getEditorSite().getShell();
	if (activeEditor == null || !(activeEditor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) activeEditor;
	if (xliffEditor.isMultiFile()) {
		MessageDialog.openInformation(shell, "", "当前编辑器打开了多个文件,无法执行该操作。");
	}

	IEditorInput input = xliffEditor.getEditorInput();
	URI uri = null;
	if (input instanceof FileEditorInput) {
		uri = ((FileEditorInput) input).getURI();
	} else if (input instanceof FileStoreEditorInput) {
		uri = ((FileStoreEditorInput) input).getURI();
	} else {
		return null;
	}
	File xliff = new File(uri);

	FileDialog fd = new FileDialog(shell, SWT.SAVE);
	String[] names = { "Plain Text Files [*.txt]", "All Files [*.*]" };
	String[] extensions = { "*.txt", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
	fd.setFilterExtensions(extensions);
	fd.setFilterNames(names);

	fd.setFileName(xliff.getName() + ".txt"); //$NON-NLS-1$
	String out = fd.open();
	if (out == null) {
		return null;
	}

	XLFHandler handler = xliffEditor.getXLFHandler();
	boolean result = handler.saveAsText(xliff.getAbsolutePath(), out, elementName);

	if (result) {
		IWorkbenchPage page = xliffEditor.getEditorSite().getPage();
		OpenEditorUtil.OpenFileWithSystemEditor(page, out);
	} else {
		MessageDialog.openInformation(shell, "", "文件 “" + out + "” 保存失败!请重试。");
	}

	return null;
}
 
Example #26
Source File: ExportAsHtmlHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	String elementName = event.getParameter("elementName");

	IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
	Shell shell = activeEditor.getEditorSite().getShell();
	if (activeEditor == null || !(activeEditor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) activeEditor;
	if (xliffEditor.isMultiFile()) {
		MessageDialog.openInformation(shell, "", "当前编辑器打开了多个文件,无法执行该操作。");
	}

	IEditorInput input = xliffEditor.getEditorInput();
	URI uri = null;
	if (input instanceof FileEditorInput) {
		uri = ((FileEditorInput) input).getURI();
	} else if (input instanceof FileStoreEditorInput) {
		uri = ((FileStoreEditorInput) input).getURI();
	} else {
		return null;
	}
	File xliff = new File(uri);

	FileDialog fd = new FileDialog(shell, SWT.SAVE);
	String[] names = { "HTML Files [*.html]", "All Files [*.*]" };
	String[] extensions = { "*.html", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
	fd.setFilterExtensions(extensions);
	fd.setFilterNames(names);

	fd.setFileName(xliff.getName() + ".html"); //$NON-NLS-1$
	String out = fd.open();
	if (out == null) {
		return null;
	}

	XLFHandler handler = xliffEditor.getXLFHandler();
	boolean result = handler.saveAsHtml(xliff.getAbsolutePath(), out, elementName);

	if (result) {
		IWorkbenchPage page = xliffEditor.getEditorSite().getPage();
		OpenEditorUtil.OpenFileWithSystemEditor(page, out);
	} else {
		MessageDialog.openInformation(shell, "", "文件 “" + out + "” 保存失败!请重试。");
	}

	return null;
}
 
Example #27
Source File: FileStoreEditorInputUniformResource.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
FileStoreEditorInputUniformResource(FileStoreEditorInput editorInput)
{
	super();
	this.editorInput = editorInput;
}
 
Example #28
Source File: ActiveDocumentAgent.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Get a handler for an editor.
 * @return a specific handler, or NullDocument if there is no specific handler for an editor.
 */
private ActiveDocument getDocument(IEditorPart editor) {

	if (editor == null) {
		// No opened editor in workspace
		return new NonOpenedDocument();
	}

	if (editor.getAdapter(IEncodingSupport.class) != null) {

		// Get MultiPartEditor active tab (plugin.xml MANIFEST.MF tab, etc...)
		if (editor instanceof FormEditor) {
			 IEditorPart e = ((FormEditor) editor).getActiveEditor();
			 if (e instanceof ITextEditor) {
				editor = e;
			 }
		}
		IEditorInput editorInput = editor.getEditorInput();
		if (editorInput instanceof IFileEditorInput) {
			return new WorkspaceFileDocument(editor, callback);
		}
		else if (editorInput instanceof FileStoreEditorInput) {
			// Decompiled class file in bin directory
			if (editorInput.getClass().getSimpleName().equals("DecompilerClassEditorInput")) {
				return new ClassFileSingleDocument(editor, callback);
			}
			return new ExternalFileDocument(editor, callback);
		}
		else if (editorInput instanceof IStorageEditorInput) {
			// Non class file resources in jar
			// pom editor Effective pom tab
			StorageFileDocument doc = new StorageFileDocument(editor, callback);
			if (doc.hasContent()) {
				return doc;
			}
			// Fallback
			Activator.info("No Content: " + editorInput.getClass().getName());
			return new ActiveDocument(editor, callback);
		}
		/*
		[Issue] IllegalStateException thrown when JavaScript resource is opened #9
		Seems confused with
			org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput (Java editor)
			org.eclipse.wst.jsdt.internal.ui.javaeditor.InternalClassFileEditorInput (JavaScript editor)
		 */
		//else if (editorInput.getClass().getSimpleName().equals("InternalClassFileEditorInput")) {
		else if (editorInput.getClass().getName().equals("org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput")) {
			// Class file in jar (with source and without source)
			return new ClassFileJarDocument(editor, callback);
		}
	}

	// MultiPageEditor no document tab (plugin.xml overview tab, etc...)
	return new NullDocument(editor);
}
 
Example #29
Source File: AbstractEditorTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected XtextEditor openEditorForExternalFile(File file) throws Exception {
	IFileStore store = EFS.getLocalFileSystem().getStore(file.toURI());
	IEditorPart editor = getActivePage().openEditor(new FileStoreEditorInput(store), getEditorId());
	return getXtextEditor(editor);
}
 
Example #30
Source File: DataSourceHelper.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 生成保存到 Map 的键值
 * @param fileStoreEditorInput
 * @return ;
 */
private String generateKey(FileStoreEditorInput fileStoreEditorInput) {
	return fileStoreEditorInput.getURI().toString() + "\u00A0" + name.toString();
}