Board index » jbuilder » JBX getting the JTree from the Browser problems

JBX getting the JTree from the Browser problems


2004-10-27 05:13:58 AM
jbuilder9
I created a listener in JB8 & 9 that monitors the JTree in case the user
clicks on a different node. However in JBX i'm having a problem that i can't
seem to get the JTree object from the Browser. The way i've done it in the
past is pretty convoluted and i'm hoping someone could help me figure out a
better way. Up till now i've basically gotten the "ProjectView" from that
I've gotten all of it's components and checked to see if any where instances
of JTree or Container (if a container i'd check all of the components in
that). This is kludge at best and doesn't work on JBX. If someone has a
better way could you please post it?
Thanks
Anders
 
 

Re:JBX getting the JTree from the Browser problems

I had similar issue when I was writing my open tool for the test file
marker (cc.borland.com/codecentral/ccWeb.exe/listing
I eneded up doing a traverse through the component hierarchy to look for
it, which works out ok. I suppose it can be slow but so far it works
fine.
Here is the source code. Hope this helps.
public static void initOpenTool(byte majorVersion, byte minorVersion) {
Browser.addStaticBrowserListener(new BrowserAdapter() {
public void browserProjectActivated(Browser browser, Project
project) {
// JComponent component = browser.getProjectView().
// selectProjectTreeViewPage().getContent();
final ProjectView projectView = browser.getProjectView();
ProjectTree projectTree = findProjectTree((browser.getRootPane()));
if (projectTree != null) {
TreeCellRenderer existingCellRenderer = projectTree.
getCellRenderer();
if (! (existingCellRenderer instanceof
TestFileMarkerTreeRenderer)) {
projectTree.setCellRenderer(new TestFileMarkerTreeRenderer(
existingCellRenderer));
}
}
}
});
}
private static ProjectTree findProjectTree(JComponent component) {
for (int i = 0; i < component.getComponentCount(); i++) {
Component child = component.getComponent(i);
if (child instanceof ProjectTree) {
return (ProjectTree) child;
}
else if (child instanceof JComponent) {
ProjectTree tree = findProjectTree((JComponent) child);
if (tree != null) {
return tree;
}
}
}
return null;
}
Anders Swenson wrote:
Quote
I created a listener in JB8 & 9 that monitors the JTree in case the user
clicks on a different node. However in JBX i'm having a problem that i can't
seem to get the JTree object from the Browser. The way i've done it in the
past is pretty convoluted and i'm hoping someone could help me figure out a
better way. Up till now i've basically gotten the "ProjectView" from that
I've gotten all of it's components and checked to see if any where instances
of JTree or Container (if a container i'd check all of the components in
that). This is kludge at best and doesn't work on JBX. If someone has a
better way could you please post it?


Thanks
Anders


 

Re:JBX getting the JTree from the Browser problems

The answer to this was posted a few months ago. I found it again using
Google Groups.
import com.borland.primetime.ide.*;
import com.borland.primetime.ide.view.*;
View view = browser.getViewContainer().getView(
ProjectTree.PROJECT_VIEW_ID);
JComponent jc = view.getContent();
"Anders Swenson" < XXXX@XXXXX.COM >wrote in message
Quote
I created a listener in JB8 & 9 that monitors the JTree in case the user
clicks on a different node. However in JBX i'm having a problem that i
can't
seem to get the JTree object from the Browser. The way i've done it in the
past is pretty convoluted and i'm hoping someone could help me figure out
a
better way. Up till now i've basically gotten the "ProjectView" from that
I've gotten all of it's components and checked to see if any where
instances
of JTree or Container (if a container i'd check all of the components in
that). This is kludge at best and doesn't work on JBX. If someone has a
better way could you please post it?


Thanks
Anders


 

{smallsort}