Skip to main content



      Home
Home » Newcomers » Newcomers » Dynamically open a view and an editor
Dynamically open a view and an editor [message #251154] Mon, 10 March 2008 10:54 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
>>
Previous Topic:difference between two jre configuration options
Next Topic:Strange Problem!
Goto Forum:
  


Current Time: Sun Jul 27 11:14:38 EDT 2025

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

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

Back to the top