Bug 2046 - org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings() is using URLgetFile() (1GDTWUZ)
Summary: org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings() is using URLgetFi...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Randy Giffen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:25 EDT by Randy Giffen CLA
Modified: 2002-03-19 16:39 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Giffen CLA 2001-10-10 22:25:19 EDT
org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings() is using URLgetFile()
this will fail when the install directory is not local
see initializePluginPreferences for an example of using a stream

NOTES:
Comment 1 Randy Giffen CLA 2001-10-19 16:37:51 EDT
Posted the following in response to a questoin on EC

Thank you Mazen. You are correct in your diagnosis. 

This is a know bug #2046

I am curious to know why you want to use a default DialogSettings file and how 
you created it.
Since we have not published a spec for this file we are wondering if the 
correct "fix" is to fix the code or change the spec for 
loadDialogSettings().

You can ofcourse override this method in you own plugin.
Here is some source that does what the comment claims

protected void loadDialogSettings() {
 dialogSettings = new DialogSettings("Workbench");//$NON-NLS-1$

 // try r/w state area in the local file system
 String readWritePath = getStateLocation().append(FN_DIALOG_SETTINGS).toOSString
();
 File settingsFile = new File(readWritePath);
 if (settingsFile.exists()) {  
  try {
   dialogSettings.load(readWritePath);
  } catch (IOException e) {
   dialogSettings = new DialogSettings("Workbench");  // load failed so ensure 
we have an empty settings//$NON-NLS-1$
  }
 } else {   
  // not found - use installed  defaults if available
  URL baseURL = getDescriptor().getInstallURL();

  URL dsURL = null;
  try {
   dsURL = new URL(baseURL, FN_DIALOG_SETTINGS);
  } catch (MalformedURLException e) {
   return;
  }
  InputStream is = null;
  try {
   is = dsURL.openStream();
   InputStreamReader reader = new InputStreamReader(is, "utf-8");
   dialogSettings.load(reader);
  } catch (IOException e) {
   dialogSettings = new DialogSettings("Workbench");  // load failed so ensure 
we have an empty settings//$NON-NLS-1$
  } finally {
   try { 
    if (is != null)
     is.close(); 
   } catch (IOException e) {}
  }
 }
}
Comment 2 Randy Giffen CLA 2001-10-19 17:14:34 EDT
Reply from EC

Randy,
the specs are great :-) so please don't change them....
The only missing piece is the DTD for the dialog_settings.xml  file.

What I did is I ran my Wizard once, this generates the dialog_settings.xml
in the r/w directory
of my plugin.
I then shutdown, copied the generated dialog_settings.xml file to my
plugin's install directory,
edited the values, deleted the initial dialog_settings.xml in the r/w
directory and relaunched
Eclipse, hopping to see my Wizard populated.

I want to be able to ship default Wizard settings (similar to Preference
Store hardcoded defaults
values versus Preferences.ini).
It's not must, I can hard code defaults, but it is nice to have.

regards,
Mazen...





Comment 3 DJ Houghton CLA 2001-10-29 17:47:50 EST
PRODUCT VERSION:
106

Comment 4 Randy Giffen CLA 2002-03-19 16:39:24 EST
fixed > 20020319