public void save(TemplatePersistenceData[] templates, OutputStream stream) throws IOException { super.save(templates, stream); }
public void save(TemplatePersistenceData[] templates, Writer writer) throws IOException { super.save(templates, writer); }
/** * Saves the templates as XML, encoded as UTF-8 onto the given byte stream. * * @param templates the templates to save * @param stream the byte output to write the templates to in XML * @throws IOException if writing the templates fails */ public void save(TemplatePersistenceData[] templates, OutputStream stream) throws IOException { save(templates, new StreamResult(stream)); }
/** * Saves the templates as XML. * * @param templates the templates to save * @param writer the writer to write the templates to in XML * @throws IOException if writing the templates fails */ public void save(TemplatePersistenceData[] templates, Writer writer) throws IOException { save(templates, new StreamResult(writer)); }
/** * Saves the templates to the preferences. * * @throws IOException if the templates cannot be written */ public void save() throws IOException { ArrayList<TemplatePersistenceData> custom= new ArrayList<>(); for (TemplatePersistenceData data : fTemplates) { if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates custom.add(data); } StringWriter output= new StringWriter(); TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(custom.toArray(new TemplatePersistenceData[custom.size()]), output); fIgnorePreferenceStoreChanges= true; try { fPreferenceStore.put(fKey, output.toString()); fPreferenceStore.flush(); } catch (BackingStoreException e) { } finally { fIgnorePreferenceStoreChanges= false; } }
/** * Saves the templates to the preferences. * * @throws IOException if the templates cannot be written */ @Override public void save() throws IOException { ArrayList<TemplatePersistenceData> custom= new ArrayList<>(); for (TemplatePersistenceData data : internalGetTemplates()) { if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates custom.add(data); } StringWriter output= new StringWriter(); TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(custom.toArray(new TemplatePersistenceData[custom.size()]), output); fIgnorePreferenceStoreChanges= true; try { fPreferenceStore.setValue(getKey(), output.toString()); if (fPreferenceStore instanceof IPersistentPreferenceStore) ((IPersistentPreferenceStore)fPreferenceStore).save(); } finally { fIgnorePreferenceStoreChanges= false; } }
private void export(TemplatePersistenceData[] templates) { FileDialog dialog= new FileDialog(getShell(), SWT.SAVE); dialog.setText(TemplatesMessages.TemplatePreferencePage_export_title); dialog.setFilterExtensions(new String[] {TemplatesMessages.TemplatePreferencePage_export_extension}); dialog.setFileName(TemplatesMessages.TemplatePreferencePage_export_filename); String path= dialog.open(); if (path == null) return; File file= new File(path); if (file.isHidden()) { String title= TemplatesMessages.TemplatePreferencePage_export_error_title; String message= NLSUtility.format(TemplatesMessages.TemplatePreferencePage_export_error_hidden, file.getAbsolutePath()); MessageDialog.openError(getShell(), title, message); return; } if (file.exists() && !file.canWrite()) { String title= TemplatesMessages.TemplatePreferencePage_export_error_title; String message= NLSUtility.format(TemplatesMessages.TemplatePreferencePage_export_error_canNotWrite, file.getAbsolutePath()); MessageDialog.openError(getShell(), title, message); return; } if (!file.exists() || confirmOverwrite(file)) { try (OutputStream output = new BufferedOutputStream(new FileOutputStream(file))) { TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(templates, output); } catch (IOException e) { openWriteErrorDialog(e); } } }
output= new BufferedOutputStream(new FileOutputStream(file)); TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(templates, output); output.close(); } catch (IOException e) {
@Override public void save() throws IOException { TemplatePersistenceData[] templateData= ProjectTemplateStore.this.getTemplateData(); for (int i= 0; i < templateData.length; i++) { if (isProjectSpecific(templateData[i].getId())) { StringWriter output= new StringWriter(); TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(getTemplateData(false), output); projectSettings.put(KEY, output.toString()); try { projectSettings.flush(); } catch (BackingStoreException e) { } return; } } // See IPreferenceStore for default String value projectSettings.put(KEY, ""); //$NON-NLS-1$ try { projectSettings.flush(); } catch (BackingStoreException e) { } } };
trw.save(templateData, wrt); defEclipsePrefs.put(CUSTOM_CODE_TEMPLATES, wrt.toString()); } catch (IOException e) {