/** * Saves the non-default-valued preferences known to this preference store * to the file from which they were originally loaded. * * @exception java.io.IOException * if there is a problem saving this store */ public void save() throws IOException { if (filename == null) { throw new IOException("File name not specified");//$NON-NLS-1$ } FileOutputStream out = null; try { out = new FileOutputStream(filename); save(out, null); } finally { if (out != null) { out.close(); } } }
/** * Saves the non-default-valued preferences known to this preference store * to the file from which they were originally loaded. * * @exception java.io.IOException * if there is a problem saving this store */ @Override public void save() throws IOException { if (filename == null) { throw new IOException("File name not specified");//$NON-NLS-1$ } FileOutputStream out = null; try { out = new FileOutputStream(filename); save(out, null); } finally { if (out != null) { out.close(); } } }
/** * Saves the non-default-valued preferences known to this preference store * to the file from which they were originally loaded. * * @exception java.io.IOException * if there is a problem saving this store */ @Override public void save() throws IOException { if (filename == null) { throw new IOException("File name not specified");//$NON-NLS-1$ } FileOutputStream out = null; try { out = new FileOutputStream(filename); save(out, null); } finally { if (out != null) { out.close(); } } }
private void copy(PreferenceStore store) { try { File file = File.createTempFile("sset", null); //$NON-NLS-1$ FileOutputStream fos = new FileOutputStream(file); store.save(fos, ""); //$NON-NLS-1$ fos.close(); FileInputStream fis = new FileInputStream(file); getPreferenceStore(); preferenceStore.load(fis); //when we clone the defult set, we should //clear the default marker preferenceStore.setValue(KEY_DEFAULT, false); fis.close(); } catch (IOException e) { } } /**
public void propertyChange(PropertyChangeEvent event) { IResource tsFile = ResourcesPlugin.getWorkspace().getRoot() .findMember((getTypesystemId(element))); PreferenceStore prefStore = (PreferenceStore) getSessionPreferenceStore(element); ByteArrayOutputStream prefBytes = new ByteArrayOutputStream(); try { prefStore.save(prefBytes, ""); } catch (IOException e) { CasEditorIdePlugin.log(e); } try { tsFile.setPersistentProperty(new QualifiedName("", CAS_EDITOR_SESSION_PROPERTIES), new String(prefBytes.toByteArray(), "UTF-8")); } catch (CoreException e) { CasEditorIdePlugin.log(e); } catch (IOException e) { CasEditorIdePlugin.log(e); } } }
/** * @param name The name to set. */ public void setName(String name) { String oldFileName = getFileName(this.name); File oldFile = new File(oldFileName); if (oldFile.exists()) { // store under the old name already exists if (preferenceStore==null) { // just rename the file oldFile.renameTo(new File(getFileName(name))); } else { // remove the old file, set the new file name, // then save to create the new file oldFile.delete(); preferenceStore.setFilename(getFileName(name)); try { preferenceStore.save(); } catch (IOException e) { String message = Messages.bind(Messages.ScopeSet_errorSaving, name); HelpUIPlugin.logError(message, e); } } } this.name = name; }
@Override public void saveTypeSystemPreferenceStore(Object element) { String prefereceFileId = getPreferenceFileForTypeSystem(getTypesystemId(element)); PreferenceStore preferences = typeSystemPreferences.get(prefereceFileId); // serialize ... IFile preferenceFile = ResourcesPlugin.getWorkspace().getRoot() .getFile(Path.fromPortableString(prefereceFileId)); ByteArrayOutputStream preferenceBytes = new ByteArrayOutputStream(); try { preferences.save(preferenceBytes, ""); } catch (IOException e) { // will not fail, writing to memory CasEditorPlugin.log(e); } try { if (preferenceFile.exists()) { preferenceFile.setContents(new ByteArrayInputStream(preferenceBytes.toByteArray()), true, false, null); } else { preferenceFile.create(new ByteArrayInputStream(preferenceBytes.toByteArray()), true, null); } } catch (CoreException e) { // might fail if writing is not possible // for some reason CasEditorPlugin.log(e); } }
public void save() { getPreferenceStore(); if (preferenceStore.needsSaving() || needsSaving) { try { if (defaultSet != -1) preferenceStore.setValue(KEY_DEFAULT, defaultSet>0); preferenceStore.save(); needsSaving = false; } catch (IOException e) { String message = Messages.bind(Messages.ScopeSet_errorSaving, name); HelpUIPlugin.logError(message, e); } } }
tsPrefStore.save(prefOut, ""); } catch (IOException e) {