Skip to main content



      Home
Home » Newcomers » Newcomers » running editor programatically
running editor programatically [message #198196] Wed, 07 March 2007 05:27 Go to next message
Eclipse UserFriend
Originally posted by: raushansharma2004.yahoo.com

hi,
i want to know how to run an editor programmatically.
i have written editor in MyEditor class
i have created one toolbar button ,what i require is when this button
is pressed, the editor should be called.can someone give me its solution
Re: running editor programatically [message #198220 is a reply to message #198196] Wed, 07 March 2007 06:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Markus.Bon.qgrp.com

The standard way to open an editor is using openEditor(...) from
org.eclipse.ui.ide.IDE:

IFile myFile = ...
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
IEditorPart editor = IDE.openEditor(page,myFile);

This opens the editor which is associated to the type of file you selected.

If you want to specify the editor to be opened explicitely (e.G. your
MyEditor), you can open the editor with a call like this:

IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(myFile, editorID, true);

regards
Markus


raushan schrieb:
> hi, i want to know how to run an editor programmatically.
> i have written editor in MyEditor class
> i have created one toolbar button ,what i require is when this
> button is pressed, the editor should be called.can someone give me its
> solution
>
Re: running editor programatically [message #198248 is a reply to message #198196] Wed, 07 March 2007 07:46 Go to previous message
Eclipse UserFriend
Hi Raushan,

Inside the run method of an Action that you associate with your toolbar
button, use the following:

IWorkbenchWindow iWorkbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage iWorkbenchPage = iWorkbenchWindow.getActivePage();

iWorkbenchPage.openEditor(myEditorInput, MyEditor.ID);

You will need to create a class that extends EditorInput.

Charlie



raushan wrote:
> hi, i want to know how to run an editor programmatically.
> i have written editor in MyEditor class
> i have created one toolbar button ,what i require is when this
> button is pressed, the editor should be called.can someone give me its
> solution
>
Previous Topic:Killing Eclipse does not start even after -clean option
Next Topic:Building workspace in command line
Goto Forum:
  


Current Time: Mon May 05 23:56:51 EDT 2025

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

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

Back to the top