Dynamically open a view and an editor [message #251154] |
Mon, 10 March 2008 10:54  |
Eclipse User |
|
|
|
Originally posted by: naddeo.marco.educ.di.unito.it
Hi,
I need to open, dynamically from my Java code, a view that I have defined
in my plug-in. Could someone please show me the way or API that I can call
to accomplish that?
Besides, I need to open, also dynamically from my Java code, a Java file
(a compilation unit) in the editor, precisely in the point of a certain
method (I use in my plug-in the ASTParser and then I have the pointer to
the ASTNode, of MethodDeclaration type, corresponding to the method on
which I want to open the editor). Could you help me?
Thanks
MN
|
|
|
Re: Dynamically open a view and an editor [message #251161 is a reply to message #251154] |
Mon, 10 March 2008 11:52   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
MN,
Here's some code that might help:
IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow == null) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (workbenchPage == null) {
return;
}
try {
viewPart = workbenchPage.showView(viewId);
IWorkbenchWindow workbenchWindow =
workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
// Open an editor on the new file.
//
try
{
page.openEditor
(new FileEditorInput(modelFile),
workbench.getEditorRegistry().getDefaultEditor(modelFile.get FullPath().toString()).getId());
}
I'm not sure how to make the editor select the right method though.
Marco Naddeo wrote:
> Hi,
>
> I need to open, dynamically from my Java code, a view that I have
> defined in my plug-in. Could someone please show me the way or API
> that I can call to accomplish that?
>
> Besides, I need to open, also dynamically from my Java code, a Java
> file (a compilation unit) in the editor, precisely in the point of a
> certain method (I use in my plug-in the ASTParser and then I have the
> pointer to the ASTNode, of MethodDeclaration type, corresponding to
> the method on which I want to open the editor). Could you help me?
>
>
> Thanks
> MN
>
|
|
|
Re: Dynamically open a view and an editor [message #251165 is a reply to message #251161] |
Mon, 10 March 2008 13:05  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
And please don't cross post the same question to multiple newsgroups as
you did posting this one to the platform newsgroup. That just created
more work for others.
Ed Merks wrote:
> MN,
>
> Here's some code that might help:
>
> IWorkbenchWindow workbenchWindow =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> if (workbenchWindow == null) {
> return;
> }
> IWorkbenchPage workbenchPage =
> workbenchWindow.getActivePage();
> if (workbenchPage == null) {
> return;
> }
> try {
> viewPart = workbenchPage.showView(viewId);
>
> IWorkbenchWindow workbenchWindow =
> workbench.getActiveWorkbenchWindow();
> IWorkbenchPage page = workbenchWindow.getActivePage();
> // Open an editor on the new file.
> //
> try
> {
> page.openEditor
> (new FileEditorInput(modelFile),
>
> workbench.getEditorRegistry().getDefaultEditor(modelFile.get FullPath().toString()).getId());
>
> }
>
> I'm not sure how to make the editor select the right method though.
>
>
> Marco Naddeo wrote:
>> Hi,
>>
>> I need to open, dynamically from my Java code, a view that I have
>> defined in my plug-in. Could someone please show me the way or API
>> that I can call to accomplish that?
>>
>> Besides, I need to open, also dynamically from my Java code, a Java
>> file (a compilation unit) in the editor, precisely in the point of a
>> certain method (I use in my plug-in the ASTParser and then I have the
>> pointer to the ASTNode, of MethodDeclaration type, corresponding to
>> the method on which I want to open the editor). Could you help me?
>>
>>
>> Thanks
>> MN
>>
|
|
|
Powered by
FUDForum. Page generated in 0.09834 seconds