Bug 57815 - [Workbench] Need public code to open a file from the save state or plugin location
Summary: [Workbench] Need public code to open a file from the save state or plugin loc...
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2004-04-07 17:10 EDT by Darrell Loverin CLA
Modified: 2009-08-30 02:11 EDT (History)
0 users

See Also:


Attachments
File that uses code from AbstractUIPlugin to open a file from the save state location or plugin installation location (123.02 KB, text/plain)
2004-04-07 17:14 EDT, Darrell Loverin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darrell Loverin CLA 2004-04-07 17:10:54 EDT
I needed to do load a file from the save state location or the plugin 
installation location the same as AbstractUIPlugin does for its 
dialog_settings.xml in loadDialogSettings. I had to copy and modify the code 
for my use. I need a public method to perform this operation that will take a 
path name as an argument.

Here what my version of the code looks like:
	private void loadTableFormat(Table table) {
		// try r/w state area in the local file system
		if (ListViewerLogger.get().isTraceEntryExitEnabled()) {
			ListViewerLogger.get().traceEntry
(this, "loadTableFormat");
		}
		
		/* When read form the state location there is no formats 
directory. all the formats are in
		 * the plugin. Didn't what the hassle of creating the formats 
directory in the state location.
		 * Only the plugin will have the formats directory.
		 */
		String readPath = _plugin.getStateLocation().append
(getTableFormatFilename()).toOSString();
		File settingsFile = new File(readPath);
		if (settingsFile.exists()) {
			try {
				table.loadFormat(readPath);
			} catch (IOException e) {
				ListViewerLogger.get().fatal
("err.loading.table.format", 
						Situation.SITUATION_REQUEST, 
						new Object[] {readPath}, 
						(Throwable) e);
				return;
			}
		} else {
			// not found - use installed  defaults if available
			URL baseURL = _plugin.getDescriptor().getInstallURL();

			URL dsURL = null;
			try {
				dsURL = new URL(baseURL, getTableFormatPathname
());
			} catch (MalformedURLException e) {
				ListViewerLogger.get().fatal
("err.loading.table.format", 
						Situation.SITUATION_REQUEST, 
						new Object[] {dsURL}, 
						(Throwable) e);
				return;
			}
			InputStream is = null;
			try {
				is = dsURL.openStream();
				BufferedReader reader = new BufferedReader(new 
InputStreamReader(is, "utf-8")); //$NON-NLS-1$
				table.loadFormat(reader);
			} catch (IOException e) {
				// load failed so ensure we have an empty 
settings
				ListViewerLogger.get().fatal
("err.loading.table.format", 
						Situation.SITUATION_REQUEST, 
						new Object[] {dsURL}, 
						(Throwable) e);
				return;
			} finally {
				try {
					if (is != null)
						is.close();
				} catch (IOException e) {
					// not catching exception if we can't 
close 
					// the file.
				}
			}
		}
		
		if (ListViewerLogger.get().isTraceEntryExitEnabled()) {
			ListViewerLogger.get().traceExit
(this, "loadTableFormat");
		}
	}
Comment 1 Darrell Loverin CLA 2004-04-07 17:14:08 EDT
Created attachment 9306 [details]
File that uses code from AbstractUIPlugin to open a file from the save state location or plugin installation location

File that contains the modified code from AbstractUIPlugin.
Comment 2 Tod Creasey CLA 2006-04-13 17:04:01 EDT
There is currently no plan to work on this
Comment 3 Denis Roy CLA 2009-08-30 02:11:07 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.