use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class TeamProject method saveXML.
/** Save a WBSModel. Return false on error. */
private boolean saveXML(WBSModel model, File directory, String filename) {
try {
File f = new File(directory, filename);
RobustFileWriter out = new RobustFileWriter(f, "UTF-8");
BufferedWriter buf = new BufferedWriter(out);
model.getAsXML(buf);
buf.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class WBSTabPanel method saveTabs.
/**
* Save custom tab definitions to file.
* @param file
* @throws IOException
*/
public void saveTabs(File file) throws IOException {
try {
RobustFileWriter out = new RobustFileWriter(file, "UTF-8");
// write out xml
out.write("<?xml version='1.0' encoding='utf-8'?>\n");
out.write("<" + WBS_TABS_ELEMENT + " " + VERSION_ATTRIBUTE + "='" + getVersionNumber() + "'>\n");
for (int i = 0; i < tabbedPane.getTabCount() - 1; i++) {
if (isTabEditable(i)) {
out.write("\t<" + TAB_ELEMENT + " " + NAME_ATTRIBUTE + "='" + XMLUtils.escapeAttribute(tabbedPane.getTitleAt(i)) + "'>\n");
TableColumnModel tableColumnModel = (TableColumnModel) tableColumnModels.get(i);
for (Enumeration e = tableColumnModel.getColumns(); e.hasMoreElements(); ) {
TableColumn column = (TableColumn) e.nextElement();
out.write("\t\t<" + COLUMN_ELEMENT + " " + NAME_ATTRIBUTE + "='" + XMLUtils.escapeAttribute(column.getHeaderValue().toString()) + "'" + " " + ID_ATTRIBUTE + "='" + XMLUtils.escapeAttribute(column.getIdentifier().toString()) + "'/>\n");
}
out.write("\t</" + TAB_ELEMENT + ">\n");
}
}
out.write("</" + WBS_TABS_ELEMENT + ">\n");
out.close();
} catch (Exception e) {
IOException exception = new IOException(SAVE_TABS_ERROR_MESSAGE);
exception.initCause(e);
throw exception;
}
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class WorkingTimeLog method ensureTimeLogFileExists.
private File ensureTimeLogFileExists(File file) throws IOException {
if (!file.exists()) {
RobustFileWriter rout = new RobustFileWriter(file, TIME_LOG_ENCODING);
BufferedWriter out = new BufferedWriter(rout);
TimeLogWriter.write(out, Collections.EMPTY_LIST.iterator());
}
return file;
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class WBSDataWriter method write.
/** Write XML WBS data to the given file.
*/
public void write(File f) throws IOException {
RobustFileWriter out = new RobustFileWriter(f, "UTF-8");
write(out);
out.close();
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class InternalSettings method saveSettings.
static synchronized void saveSettings() {
if (isReadOnly())
return;
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
if (fsettings != null)
try {
String oldName, destName;
if (settingsFileRename == null) {
oldName = null;
destName = settingsFile;
} else {
oldName = settingsFile;
destName = settingsFileRename;
}
File destFile = new File(destName);
Writer out = new RobustFileWriter(destFile);
fsettings.store(out);
out.close();
if (oldName != null) {
new File(oldName).delete();
settingsFile = destName;
settingsFileRename = null;
}
settingsFileTimestamp = destFile.lastModified();
dirty = false;
} catch (Exception e) {
logger.log(Level.SEVERE, "Unable to save settings file.", e);
}
return null;
}
});
}
Aggregations