|
From: <bh...@us...> - 2006-10-23 21:13:32
|
Revision: 307
http://svn.sourceforge.net/cishell/?rev=307&view=rev
Author: bh2
Date: 2006-10-23 14:13:22 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
finished feature to allow files to be saved w/o a converter.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2006-10-23 21:01:37 UTC (rev 306)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2006-10-23 21:13:22 UTC (rev 307)
@@ -18,7 +18,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
-import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
/**
@@ -86,9 +85,7 @@
* @return Whether or not the save was successful
*/
public boolean save(Converter converter, Data data) {
- ServiceReference[] serviceReferenceArray = converter.getConverterChain();
- String outDataStr = (String)serviceReferenceArray[serviceReferenceArray.length-1]
- .getProperty(AlgorithmProperty.OUT_DATA);
+ String outDataStr = (String)converter.getProperties().get(AlgorithmProperty.OUT_DATA);
String ext = outDataStr.substring(outDataStr.indexOf(':')+1);
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2006-10-23 21:01:37 UTC (rev 306)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2006-10-23 21:13:22 UTC (rev 307)
@@ -2,9 +2,12 @@
import java.io.File;
import java.util.Dictionary;
+import java.util.Hashtable;
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.algorithm.AlgorithmProperty;
import org.cishell.framework.data.Data;
import org.cishell.service.conversion.Converter;
import org.cishell.service.conversion.DataConversionService;
@@ -12,6 +15,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+import org.osgi.framework.ServiceReference;
/**
* Save algorithm for persisting a data object
@@ -62,15 +66,31 @@
"No valid converters for data type: " +
data[0].getData().getClass().getName(),
"Please install a plugin that will save the data type to a file");
- }
- else {
+ } else {
if (!parentShell.isDisposed()) {
guiRun(new Runnable() {
public void run() {
if (converters.length == 0) {
- //TODO: finish this
- //final FileSaver saver = new FileSaver(parentShell, context);
- //saver.save(null, data[0]);
+ final FileSaver saver = new FileSaver(parentShell, context);
+ saver.save(new Converter(){
+ Dictionary props = new Hashtable();
+
+ public Data convert(Data data) {
+ return data;
+ }
+
+ public AlgorithmFactory getAlgorithmFactory() {
+ return null;
+ }
+
+ public ServiceReference[] getConverterChain() {
+ return null;
+ }
+
+ public Dictionary getProperties() {
+ props.put(AlgorithmProperty.OUT_DATA, "file:*");
+ return props;
+ }}, data[0]);
} else if (converters.length == 1) {
final FileSaver saver = new FileSaver(parentShell, context);
saver.save(converters[0], data[0]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|