Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Open View from Dialog
Open View from Dialog [message #448833] Thu, 04 May 2006 04:58 Go to next message
Eclipse UserFriend
Originally posted by: b.h.stud.uni-goettingen.de

Hello,

I have a RCP applcation. I open a view from menu and it works. Now I want
to open the view from a button in a Dialog. The view is multiple. I can
open many views from the menu.
The method makeAction(..) in class ApplicationActionBarAdvisor.java called

new OpenViewAction(window, TreeView.ID);

and the view open. I tried to called this from my Dialog but I need the
window. How can I get the window? In the moment where the Dialog is open I
can't get the activeWorkbenchwindow.

What can I do, to open the view? Sorry my english is very bad but I hope
you understand me?


Gruß

Björn
Re: Open View from Dialog [message #448841 is a reply to message #448833] Thu, 04 May 2006 16:00 Go to previous messageGo to next message
Eclipse UserFriend
What about the time when your are creating the Dialog?
Is the window available at this point in time?

If yes, you could pass it as argument in the constructor.

Regards,
Stefan

Björn schrieb:
> Hello,
>
> I have a RCP applcation. I open a view from menu and it works. Now I
> want to open the view from a button in a Dialog. The view is multiple. I
> can open many views from the menu.
> The method makeAction(..) in class ApplicationActionBarAdvisor.java called
> new OpenViewAction(window, TreeView.ID);
>
> and the view open. I tried to called this from my Dialog but I need the
> window. How can I get the window? In the moment where the Dialog is open
> I can't get the activeWorkbenchwindow.
> What can I do, to open the view? Sorry my english is very bad but I hope
> you understand me?
>
>
> Gruß
>
> Björn
>
Re: Open View from Dialog [message #448848 is a reply to message #448841] Fri, 05 May 2006 02:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: b.h.stud.uni-goettingen.de

Hello Stefan,

I start my RCP application and wenn I press a button a Dialog open. In
this Dialog I can choose a datasource. After that I press the OK Button
and now I want to open a view to fill this with data from the datasource.

I dont't understand what you mean with I could pass it as argument in the
constructor? I don't get the window, this is my problem. My class
ViewOpenAction need as argument (IWorkbenchWindow window, String viewid).

The String is viewid = TreeView.ID;

But I don't know how to get the window? I have tried this but it doesn't
work, because I think the dialog is active and not the window.

IWorkbench wb = PlatformUI.getWorkbench();

IWorkbenchWindow window = wb.getActiveWorkbenchWindow();

What can I do? :-(




public class OpenViewAction extends Action {



private final IWorkbenchWindow window;



private int instanceNum;



private final String viewId;



public OpenViewAction(IWorkbenchWindow window, String viewId) {

this.window = window;

this.viewId = viewId;

}



public void run() {

try {

window.getActivePage().showView(viewId,

Integer.toString(instanceNum++),

IWorkbenchPage.VIEW_ACTIVATE);

} catch (PartInitException e) {

e.printStackTrace();

}

}

}
Re: Open View from Dialog [message #448892 is a reply to message #448848] Sat, 06 May 2006 11:06 Go to previous messageGo to next message
Eclipse UserFriend
Björn wrote:
> Hello Stefan,
>
> I start my RCP application and wenn I press a button a Dialog open. In
> this Dialog I can choose a datasource. After that I press the OK Button
> and now I want to open a view to fill this with data from the datasource.
>
> I dont't understand what you mean with I could pass it as argument in
> the constructor? I don't get the window, this is my problem. My class
> ViewOpenAction need as argument (IWorkbenchWindow window, String viewid).
>
> The String is viewid = TreeView.ID;
>
> But I don't know how to get the window? I have tried this but it doesn't
> work, because I think the dialog is active and not the window.
>
> IWorkbench wb = PlatformUI.getWorkbench();
>
> IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
>
> What can I do? :-(
>

What Stefan was saying was, save the workbench window when you open the
dialog. When do you create the dialog? Where in the code? Where in
the code do you open it?

Later,
PW
Re: Open View from Dialog [message #448896 is a reply to message #448848] Sat, 06 May 2006 11:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom.seidel.javawiki.org

Hi Björn,

why don't you open the view _after_ closing the dialog

something like that:

MyDialog diag = new MyDialog(currentShell);

if (diag.open() == IDialogConstants.OK_ID) {
MyDataFromDialog data = diag.getData();
openNewView(data);
}

Cheerz,


Björn wrote:
> Hello Stefan,
>
> I start my RCP application and wenn I press a button a Dialog open. In
> this Dialog I can choose a datasource. After that I press the OK Button
> and now I want to open a view to fill this with data from the datasource.
>
> I dont't understand what you mean with I could pass it as argument in
> the constructor? I don't get the window, this is my problem. My class
> ViewOpenAction need as argument (IWorkbenchWindow window, String viewid).
>
> The String is viewid = TreeView.ID;
>
> But I don't know how to get the window? I have tried this but it doesn't
> work, because I think the dialog is active and not the window.
>
> IWorkbench wb = PlatformUI.getWorkbench();
>
> IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
>
> What can I do? :-(
>
>
>
>
> public class OpenViewAction extends Action {
>
>
>
> private final IWorkbenchWindow window;
>
>
>
> private int instanceNum;
>
>
>
> private final String viewId;
>
>
>
> public OpenViewAction(IWorkbenchWindow window, String viewId) {
>
> this.window = window;
>
> this.viewId = viewId;
>
> }
>
>
>
> public void run() {
>
> try {
>
> window.getActivePage().showView(viewId,
>
> Integer.toString(instanceNum++),
>
> IWorkbenchPage.VIEW_ACTIVATE);
>
> } catch (PartInitException e) {
>
> e.printStackTrace();
>
> }
>
> }
>
> }
>
>
>
>
>
>
>
Re: Open View from Dialog [message #448907 is a reply to message #448848] Sun, 07 May 2006 11:26 Go to previous message
Eclipse UserFriend
Hello Björn,

afaik you can get the active WorkbenchWindow anytime staticly by:

PlatformUI.getWorkbench().getActiveWorkbenchWindow()

Hope that helps

Best regards
Alex
Previous Topic:RCP, default preferences
Next Topic:Errors when building in 3.2 an RCP plug-in project created in 3.1
Goto Forum:
  


Current Time: Sat Aug 30 19:38:47 EDT 2025

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

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

Back to the top