Community
Participate
Working Groups
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"); } }
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.
There is currently no plan to work on this
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.