[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-ui-dev] How to open a view programmatically
|
Rishi,
Please post questions on how to use the Eclipse APIs in the eclipse.tools
newsgroup rather than the developer mailing lists.
The main problem is that you are constructing your own instance of
PackageView, after it has already been created using
showView("test.PackageView").
The workbench does not recognize the second instance.
showView will instantiate your PackageView and call createPartControl. You
do not have to call activate yourself in this situation -- showView
already activates the view.
I suggest adding a setInput method to PackageView so your code can do
something like:
PackageView packageView = (PackageView) page.showView("test.PackageView");
packageView.setInput(htableListFile)
In setInput, you would refresh to view's widgets to show the new input.
Also, be aware that getActiveWorkbenchWindow and getActivePage may return
null.
Nick
Rishi.Sahni@xxxxxxxxxxx
Sent by: platform-ui-dev-admin@xxxxxxxxxxx
01/10/03 12:01 AM
Please respond to platform-ui-dev
To: platform-ui-dev@xxxxxxxxxxx
cc:
Subject: [platform-ui-dev] How to open a view programmatically
Can any body tell me how to open a view programmatically?
I have already used showView()
written following lines of code to open a view
IWorkbenchWindow dw =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = dw.getActivePage();
try{
page.showView("test.PackageView");
}catch (PartInitException e){
DialogUtil.openError(dw.getShell(), ResourceMessages.getString(
"DataFileResource.errorMessage"),e.getMessage(),e);
}
now in Package View i want to populate a tree the information of tree
Elements is passed in the constructor as shown below
if (page != null){
PackageView pv = new PackageView(htableListFile);
pv.createPartControl(parent);
IViewPart part =(IViewPart) pv.getViewSite() ;
page.activate(part) ;
}
and in createPartControl method of PackageView am populating the Tree View
as
if(table != null){
Enumeration enum= table.keys();
while(enum.hasMoreElements()){
String Key = enum.nextElement().toString();
TreeParent p31 = new TreeParent(Key);
ArrayList tempalist =(ArrayList) table.get(Key);
for(int i = 0;i<tempalist.size();i++){
System.out.println("Key--"+Key+" >> "
+tempalist.get(i).toString());
}
root.addChild(p31);
}
}else{
System.out.println("table is Null");
}
the above Code is adding Childs in tree but its not showing up Childs ,may
be its not updating the view
Help required
Thanks in advance
Rishi Sahni
_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-ui-dev