Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Accessing the extensions for an (active) editor
Accessing the extensions for an (active) editor [message #533903] Mon, 17 May 2010 12:26 Go to next message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Hello peoples, I would like to be able to find the extensions that an Editor
can handle, programmatically.

Use case: Save as, when the user has not entered a file extension.

What is the best way to intercept the file name, and then add the correct
extension?
Re: Accessing the extensions for an (active) editor [message #533911 is a reply to message #533903] Mon, 17 May 2010 13:08 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can check if your IEditorInput is an instance of IFileEditorInput to
get the name. You can try
org.eclipse.ui.IEditorRegistry.getFileEditorMappings() from IWorkbench
and org.eclipse.core.runtime.Platform.getContentTypeManager() to see
what information is available.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Accessing the extensions for an (active) editor [message #533936 is a reply to message #533911] Mon, 17 May 2010 14:03 Go to previous messageGo to next message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Thanks Paul

I am trying IEditorRegistry.getFileEditorMappings(), like this:

IFileEditorMapping[] fileEditorMappings =
PlatformUI.getWorkbench().getEditorRegistry().getFileEditorM appings();
for (IFileEditorMapping mapping : fileEditorMappings) {
if (mapping.getDefaultEditor().getId().equals("myEditor"))
extension = mapping.getExtension();
}

I get an IEditorDescriptor, which has an getId() method. From here, how do I
get the ID for the current editor? IEditorPart has not getId() method...


"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:hsrf13$5qq$2@build.eclipse.org...
> You can check if your IEditorInput is an instance of IFileEditorInput to
> get the name. You can try
> org.eclipse.ui.IEditorRegistry.getFileEditorMappings() from IWorkbench and
> org.eclipse.core.runtime.Platform.getContentTypeManager() to see what
> information is available.
>
> PW
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
> http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Accessing the extensions for an (active) editor [message #533995 is a reply to message #533936] Mon, 17 May 2010 16:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

geejay wrote:
>
> I get an IEditorDescriptor, which has an getId() method. From here, how
> do I get the ID for the current editor? IEditorPart has not getId()
> method...

editorPart.getSite().getId() is the ID of the editorPart instance.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Accessing the extensions for an (active) editor [message #534754 is a reply to message #533995] Thu, 20 May 2010 08:52 Go to previous message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Thanks Paul. Perfect.

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:hsrq0p$i4t$1@build.eclipse.org...
> geejay wrote:
>>
>> I get an IEditorDescriptor, which has an getId() method. From here, how
>> do I get the ID for the current editor? IEditorPart has not getId()
>> method...
>
> editorPart.getSite().getId() is the ID of the editorPart instance.
>
> PW
>
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
> http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Previous Topic:Strongly typed databinding?
Next Topic:RCP e4: Activities
Goto Forum:
  


Current Time: Wed Sep 17 07:45:35 GMT 2014

Powered by FUDForum. Page generated in 0.05501 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software