Author: rob.stryker(a)jboss.com
Date: 2007-06-01 16:43:10 -0400 (Fri, 01 Jun 2007)
New Revision: 2092
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
Log:
moved some code to xmlbinding instead
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2007-06-01
20:42:27 UTC (rev 2091)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2007-06-01
20:43:10 UTC (rev 2092)
@@ -281,44 +281,25 @@
public void saveModel (IPath project, IProgressMonitor monitor) {
// get a list of dirty nodes
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+
+ IPath packagesFile = project.append(ArchivesModel.PROJECT_PACKAGES_FILE);
+ XbPackages packs = getXbPackages(project);
+
+ XMLBinding.savePackagesToFile(packs, packagesFile, monitor);
+
+ // get deltas
try {
- if (monitor == null)
- monitor = new NullProgressMonitor();
+ ArchiveModelNode root = (ArchiveModelNode)getRoot(project);
+ IArchiveNodeDelta delta = root.getDelta();
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- OutputStreamWriter writer = new OutputStreamWriter(bytesOut);
- XbPackages packs = getXbPackages(project);
- XMLBinding.marshal(packs, writer, monitor);
- writer.close();
+ // clear deltas
+ root.clearDeltas();
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
- IPath packagesFile = project.append(ArchivesModel.PROJECT_PACKAGES_FILE);
- OutputStream out = new FileOutputStream(packagesFile.toFile());
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = bytesIn.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- out.close();
- bytesIn.close();
- bytesOut.close();
-
- // get deltas
- try {
- ArchiveModelNode root = (ArchiveModelNode)getRoot(project);
- IArchiveNodeDelta delta = root.getDelta();
-
- // clear deltas
- root.clearDeltas();
-
- // fire delta events
- EventManager.fireDelta(delta);
- } catch( Exception e ) {
- e.printStackTrace();
- }
- } catch (IOException e) {
+ // fire delta events
+ EventManager.fireDelta(delta);
+ } catch( Exception e ) {
e.printStackTrace();
}
}
Show replies by date