Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Property Page + Classpath ordering problem
Property Page + Classpath ordering problem [message #9910] Wed, 30 April 2003 13:05
Eclipse UserFriend
Originally posted by: roy.paterson.net

I have a problem with property page ordering and the JDT. My property page
modifies the java build path for a java project. If I use the following
path, it works:

Right-click on java project
select properties
select my property page
make changes
click OK

After "OK" is clicked, my property page's performOK() function is called and
it does it's work of changing the classpath.

The problem arises when the user selects the JDT's "Java Build Paths"
property page in addition to mine. Even if the user makes no changes using
the "Java Build Path" property page, it clobbers my classpath settings.
This happens because when the user selects the "Java Build Paths" page, it
initializes itself from the file system (the project's .classpath file).
When it's performOk() function is called, it writes it's current state to
the project.

It appears that the order the pages are called is on alphabetical based on
page title. My page's name comes before "Java Build Paths" which means that
I go first. So my page makes it's changes to the classpath and exits it's
performOk() function successfully. But then the "Java Build Paths" page is
called, and it clobbers my changes to the classpath.

Can anyone suggest a clean solution to this problem? I have a hack that
works, but it is based on the JDT internal API and is fragile. Basically my
hack gets the list of pages from the PropertyPage Dialog, and then calls
createControl(...) on the "Java Build Paths" page. This makes the page
reload from the file system, picking up my changes. Here is the code:

public boolean performOk() {

//make my classpath changes here

//force "Java Build Paths" page to re-initialize if it exists
Iterator pageNodeIterator =
((PreferenceDialog)getContainer()).getPreferenceManager().ge tElements(Prefer
enceManager.PRE_ORDER).iterator();
while (pageNodeIterator.hasNext()) {
IWorkbenchPropertyPage page =
(IWorkbenchPropertyPage)((IPreferenceNode)pageNodeIterator.n ext()).getPage()
;
if (page != null && page instanceof
org.eclipse.jdt.internal.ui.preferences.BuildPathsPropertyPa ge) {
//re-init the page - it will read from the workspace and pick
up my classpath settings
page.createControl(myComposite.getParent());
}
}
} //end of performOk() function

Can anyone suggest a better solution to this problem?

Thanks,
Roy Paterson
Previous Topic:how do I add a listener to the default java editor
Next Topic:Quick Fix Disappearing
Goto Forum:
  


Current Time: Sun Jun 08 03:48:01 EDT 2025

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

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

Back to the top