You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
|
Sep
(46) |
Oct
(102) |
Nov
(10) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(3) |
Mar
(14) |
Apr
(9) |
May
(12) |
Jun
(4) |
Jul
(40) |
Aug
(60) |
Sep
(38) |
Oct
(2) |
Nov
(1) |
Dec
(42) |
2008 |
Jan
(23) |
Feb
(29) |
Mar
(107) |
Apr
(27) |
May
(3) |
Jun
(1) |
Jul
(15) |
Aug
(7) |
Sep
(19) |
Oct
|
Nov
(2) |
Dec
|
2009 |
Jan
(36) |
Feb
(4) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(15) |
Jul
(30) |
Aug
(32) |
Sep
(11) |
Oct
(21) |
Nov
(12) |
Dec
(15) |
2010 |
Jan
(29) |
Feb
(9) |
Mar
(25) |
Apr
|
May
(7) |
Jun
(5) |
Jul
(21) |
Aug
(32) |
Sep
(10) |
Oct
(8) |
Nov
(29) |
Dec
(8) |
2011 |
Jan
(9) |
Feb
(35) |
Mar
(11) |
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(30) |
2012 |
Jan
(5) |
Feb
(7) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <re...@us...> - 2011-12-20 16:39:52
|
Revision: 1270 http://cishell.svn.sourceforge.net/cishell/?rev=1270&view=rev Author: rescdsk Date: 2011-12-20 16:39:41 +0000 (Tue, 20 Dec 2011) Log Message: ----------- argh, svn branches and eclipse interfaces. Added Paths: ----------- branches/tgs-tycho/deployment/.settings/ branches/tgs-tycho/deployment/.settings/org.eclipse.m2e.core.prefs branches/tgs-tycho/deployment/pom.xml Added: branches/tgs-tycho/deployment/.settings/org.eclipse.m2e.core.prefs =================================================================== --- branches/tgs-tycho/deployment/.settings/org.eclipse.m2e.core.prefs (rev 0) +++ branches/tgs-tycho/deployment/.settings/org.eclipse.m2e.core.prefs 2011-12-20 16:39:41 UTC (rev 1270) @@ -0,0 +1,5 @@ +#Fri Dec 16 11:23:16 EST 2011 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 Added: branches/tgs-tycho/deployment/pom.xml =================================================================== --- branches/tgs-tycho/deployment/pom.xml (rev 0) +++ branches/tgs-tycho/deployment/pom.xml 2011-12-20 16:39:41 UTC (rev 1270) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.cishell</groupId> + <artifactId>parent</artifactId> + <version>0.0.1</version> + <relativePath>../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.cishell.reference.feature</artifactId> + <version>1.0.0</version> + <packaging>eclipse-feature</packaging> + +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <re...@us...> - 2011-12-20 16:36:53
|
Revision: 1269 http://cishell.svn.sourceforge.net/cishell/?rev=1269&view=rev Author: rescdsk Date: 2011-12-20 16:36:43 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Working on Maven/Tycho build system Modified Paths: -------------- branches/tgs-tycho/deployment/.project branches/tgs-tycho/deployment/build.properties Added Paths: ----------- branches/tgs-tycho/ branches/tgs-tycho/deployment/ branches/tgs-tycho/deployment/extra-files/ Modified: branches/tgs-tycho/deployment/.project =================================================================== --- trunk/deployment/org.cishell.reference.feature/.project 2011-12-15 18:56:03 UTC (rev 1268) +++ branches/tgs-tycho/deployment/.project 2011-12-20 16:36:43 UTC (rev 1269) @@ -1,17 +1,23 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.cishell.reference.feature</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.pde.FeatureBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.FeatureNature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.reference.feature</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.FeatureBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.FeatureNature</nature> + </natures> +</projectDescription> Modified: branches/tgs-tycho/deployment/build.properties =================================================================== --- trunk/deployment/org.cishell.reference.feature/build.properties 2011-12-15 18:56:03 UTC (rev 1268) +++ branches/tgs-tycho/deployment/build.properties 2011-12-20 16:36:43 UTC (rev 1269) @@ -1 +1,2 @@ bin.includes = feature.xml +root=extra-files This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-11-21 18:02:40
|
Revision: 1250 http://cishell.svn.sourceforge.net/cishell/?rev=1250&view=rev Author: jrbibers Date: 2011-11-21 18:02:33 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Punctuation in Javadoc. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java 2011-11-21 17:59:11 UTC (rev 1249) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java 2011-11-21 18:02:33 UTC (rev 1250) @@ -18,7 +18,7 @@ * * @param datum Object to wrap * @param format The {@link Data#getFormat() format} of {@code object} - * @param type The {@link DataProperty#TYPE type} of {@code object} + * @param type The {@link DataProperty#TYPE type} of {@code object}. * See {@link DataProperty}.*_TYPE for possible values * @param parent The {@link Data} from which {@code object} was derived * @param label A concise String describing {@code object} in relation to {@code parent} @@ -35,11 +35,11 @@ * Creates a Data wrapping {@code object} having the same {@link Data#getFormat() format} and * {@link DataProperty#TYPE type} as its {@code parent}. * - * @param object Object to wrap - * @param parent The {@link Data} from which {@code object} was derived - * @param label A concise String describing {@code object} in relation to {@code parent} + * @param object Object to wrap. + * @param parent The {@link Data} from which {@code object} was derived. + * @param label A concise String describing {@code object} in relation to {@code parent}. * @return A Data wrapping {@code object} using {@code parent}'s {@code format} - * and {@code type} + * and {@code type}. */ public static Data likeParent(Object object, Data parent, String label) { return forObject( @@ -53,13 +53,13 @@ * Creates a Data wrapping {@code object} using {@code object.getClass().getName()} as its * format. * - * @param object Object to wrap as Data - * @param type The {@link DataProperty#TYPE type} of {@code object} - * See {@link DataProperty}.*_TYPE for possible values - * @param parent The {@link Data} from which {@code object} was derived - * @param label A concise String describing {@code object} in relation to {@code parent} + * @param object Object to wrap as Data. + * @param type The {@link DataProperty#TYPE type} of {@code object}. + * See {@link DataProperty}.*_TYPE for possible values. + * @param parent The {@link Data} from which {@code object} was derived. + * @param label A concise String describing {@code object} in relation to {@code parent}. * @return A Data wrapping {@code object} using {@code object.getClass().getName()} as its - * format + * format. */ public static Data withClassNameAsFormat( Object object, String type, Data parent, String label) { @@ -68,13 +68,13 @@ /** * Creates a Data wrapping {@code file} using {@code mimeType} as its format. * - * @param file File to wrap as Data + * @param file File to wrap as Data. * @param mimeType {@code file}'s MIME type, e.g. "file:text/plain". - * @param type The {@link DataProperty#TYPE type} of {@code object} - * See {@link DataProperty}.*_TYPE for possible values - * @param parent The {@link Data} from which {@code object} was derived - * @param label A concise String describing {@code object} in relation to {@code parent} - * @return A Data wrapping {@code file} using {@code mimeType} as its format + * @param type The {@link DataProperty#TYPE type} of {@code object}. + * See {@link DataProperty}.*_TYPE for possible values. + * @param parent The {@link Data} from which {@code object} was derived. + * @param label A concise String describing {@code object} in relation to {@code parent}. + * @return A Data wrapping {@code file} using {@code mimeType} as its format. */ public static Data forFile( File file, String mimeType, String type, Data parent, String label) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-11-21 17:59:18
|
Revision: 1249 http://cishell.svn.sourceforge.net/cishell/?rev=1249&view=rev Author: jrbibers Date: 2011-11-21 17:59:11 +0000 (Mon, 21 Nov 2011) Log Message: ----------- New class org.cishell.utilities.DataFactory with static factory methods for creating Data instances. This should reduce the need for those pervasive 5-to-7 line "wrapWithMetadata"-type methods in almost every algorithm. Convenience methods for four common Data creation cases: * With prescribed format and type. * With a prescribed type, but format = {wrapped object}.getClass().getName(). * Inheriting the parent's format and type. * For a file with prescribed MIME-type (format) and type. This is just an alias for the first. Currently uses BasicData as the Data implementation, but this can be changed later. Reviewed by Thomas. Added Paths: ----------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java (rev 0) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DataFactory.java 2011-11-21 17:59:11 UTC (rev 1249) @@ -0,0 +1,83 @@ +package org.cishell.utilities; + +import java.io.File; +import java.util.Dictionary; +import java.util.Hashtable; + +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.framework.data.DataProperty; + +public final class DataFactory { + private DataFactory() { + // Static factory methods only. + } + + /** + * Creates a Data wrapping {@code object}. + * + * @param datum Object to wrap + * @param format The {@link Data#getFormat() format} of {@code object} + * @param type The {@link DataProperty#TYPE type} of {@code object} + * See {@link DataProperty}.*_TYPE for possible values + * @param parent The {@link Data} from which {@code object} was derived + * @param label A concise String describing {@code object} in relation to {@code parent} + */ + public static Data forObject(Object object, String format, String type, Data parent, String label) { + Dictionary<String, Object> metadata = new Hashtable<String, Object>(); + metadata.put(DataProperty.TYPE, type); + metadata.put(DataProperty.PARENT, parent); + metadata.put(DataProperty.LABEL, label); + + return new BasicData(metadata, object, format); + } + /** + * Creates a Data wrapping {@code object} having the same {@link Data#getFormat() format} and + * {@link DataProperty#TYPE type} as its {@code parent}. + * + * @param object Object to wrap + * @param parent The {@link Data} from which {@code object} was derived + * @param label A concise String describing {@code object} in relation to {@code parent} + * @return A Data wrapping {@code object} using {@code parent}'s {@code format} + * and {@code type} + */ + public static Data likeParent(Object object, Data parent, String label) { + return forObject( + object, + parent.getFormat(), + (String) parent.getMetadata().get(DataProperty.TYPE), + parent, + label); + } + /** + * Creates a Data wrapping {@code object} using {@code object.getClass().getName()} as its + * format. + * + * @param object Object to wrap as Data + * @param type The {@link DataProperty#TYPE type} of {@code object} + * See {@link DataProperty}.*_TYPE for possible values + * @param parent The {@link Data} from which {@code object} was derived + * @param label A concise String describing {@code object} in relation to {@code parent} + * @return A Data wrapping {@code object} using {@code object.getClass().getName()} as its + * format + */ + public static Data withClassNameAsFormat( + Object object, String type, Data parent, String label) { + return forObject(object, object.getClass().getName(), type, parent, label); + } + /** + * Creates a Data wrapping {@code file} using {@code mimeType} as its format. + * + * @param file File to wrap as Data + * @param mimeType {@code file}'s MIME type, e.g. "file:text/plain". + * @param type The {@link DataProperty#TYPE type} of {@code object} + * See {@link DataProperty}.*_TYPE for possible values + * @param parent The {@link Data} from which {@code object} was derived + * @param label A concise String describing {@code object} in relation to {@code parent} + * @return A Data wrapping {@code file} using {@code mimeType} as its format + */ + public static Data forFile( + File file, String mimeType, String type, Data parent, String label) { + return forObject(file, mimeType, type, parent, label); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-11-16 19:06:32
|
Revision: 1248 http://cishell.svn.sourceforge.net/cishell/?rev=1248&view=rev Author: jrbibers Date: 2011-11-16 19:06:26 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Javadoc location for Guava plugin. Modified Paths: -------------- trunk/libs/google_guava/.classpath Modified: trunk/libs/google_guava/.classpath =================================================================== --- trunk/libs/google_guava/.classpath 2011-10-24 19:50:53 UTC (rev 1247) +++ trunk/libs/google_guava/.classpath 2011-11-16 19:06:26 UTC (rev 1248) @@ -3,6 +3,9 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry exported="true" kind="lib" path="guava-r08.jar" sourcepath="guava-src-r08.zip"> + <attributes> + <attribute name="javadoc_location" value="http://guava-libraries.googlecode.com/svn/tags/release08/javadoc"/> + </attributes> <accessrules> <accessrule kind="discouraged" pattern="com/google/common/base/internal/*"/> </accessrules> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <re...@us...> - 2011-10-24 19:51:00
|
Revision: 1247 http://cishell.svn.sourceforge.net/cishell/?rev=1247&view=rev Author: rescdsk Date: 2011-10-24 19:50:53 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Document what happens when you throw an exception in MutateParameters Modified Paths: -------------- trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java Modified: trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java 2011-10-24 19:49:39 UTC (rev 1246) +++ trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java 2011-10-24 19:50:53 UTC (rev 1247) @@ -20,27 +20,38 @@ /** * An additional interface an {@link AlgorithmFactory} can implement that allows * for adding, modifying, or removing input parameters before being shown to the - * end-user for input. This interface is often implemented by algorithms that + * end-user for input. This interface is often implemented by algorithms that * wish to customize the user interface based on the actual input data. * * @author Bruce Herr (bh...@bh...) */ public interface ParameterMutator { - /** - * Adds, modifies, or removes {@link Algorithm} parameters - * ({@link AttributeDefinition}s) from a given {@link ObjectClassDefinition} - * returning either the same (if no changes are made) input or a new, - * mutated version of the input - * - * @param data An optional argument, the Data array that will be given to - * this class to create an Algorithm with the createAlgorithm - * method. Applications that don't know the Data array that is going - * to be used ahead of time can give a <code>null</code> value. - * @param parameters A set of AttributeDefinitions which define the - * algorithm's input parameters - * @return An OSGi {@link ObjectClassDefinition} that defines the parameters - * needed by the Algorithm this class creates - */ - public ObjectClassDefinition mutateParameters(Data[] data, ObjectClassDefinition parameters); + /** + * Adds, modifies, or removes {@link Algorithm} parameters ( + * {@link AttributeDefinition}s) from a given {@link ObjectClassDefinition} + * returning either the same (if no changes are made) input or a new, + * mutated version of the input + * + * <p> + * If the mutateParameters method happens to find out that the algorithm + * will be unable to run, for instance if an input file does not have the + * correct format, it may throw a {@link AlgorithmCreationFailedException}. + * The user may be made aware of the exception, for example by printing the + * .getMessage to the console. + * + * @param data + * An optional argument, the Data array that will be given to + * this class to create an Algorithm with the createAlgorithm + * method. Applications that don't know the Data array that is + * going to be used ahead of time can give a <code>null</code> + * value. + * @param parameters + * A set of AttributeDefinitions which define the algorithm's + * input parameters + * @return An OSGi {@link ObjectClassDefinition} that defines the parameters + * needed by the Algorithm this class creates + */ + public ObjectClassDefinition mutateParameters(Data[] data, + ObjectClassDefinition parameters); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <re...@us...> - 2011-10-24 19:49:45
|
Revision: 1246 http://cishell.svn.sourceforge.net/cishell/?rev=1246&view=rev Author: rescdsk Date: 2011-10-24 19:49:39 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Add version numbers, so that other bundles can insist on newer versions of packages that may also be present in google_collections. Modified Paths: -------------- trunk/libs/google_guava/META-INF/MANIFEST.MF Added Paths: ----------- trunk/libs/google_guava/Updating.txt Modified: trunk/libs/google_guava/META-INF/MANIFEST.MF =================================================================== --- trunk/libs/google_guava/META-INF/MANIFEST.MF 2011-06-22 21:34:34 UTC (rev 1245) +++ trunk/libs/google_guava/META-INF/MANIFEST.MF 2011-10-24 19:49:39 UTC (rev 1246) @@ -4,12 +4,12 @@ Bundle-SymbolicName: google_guava Bundle-Version: 0.8.0 Bundle-ClassPath: guava-r08.jar -Export-Package: com.google.common.annotations, - com.google.common.base, - com.google.common.base.internal, - com.google.common.collect, - com.google.common.io, - com.google.common.net, - com.google.common.primitives, - com.google.common.util.concurrent +Export-Package: com.google.common.annotations;version="8.0.0", + com.google.common.base;version="8.0.0", + com.google.common.base.internal;version="8.0.0", + com.google.common.collect;version="8.0.0", + com.google.common.io;version="8.0.0", + com.google.common.net;version="8.0.0", + com.google.common.primitives;version="8.0.0", + com.google.common.util.concurrent;version="8.0.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Added: trunk/libs/google_guava/Updating.txt =================================================================== --- trunk/libs/google_guava/Updating.txt (rev 0) +++ trunk/libs/google_guava/Updating.txt 2011-10-24 19:49:39 UTC (rev 1246) @@ -0,0 +1,7 @@ +When updating this to a new version of Guava, consider using +the externally packaged version: + +http://code.google.com/p/guava-osgi/ + +We've set up the Export-Package: part of the Manifest to use +version numbers that are compatible with that project. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-06-22 21:34:41
|
Revision: 1245 http://cishell.svn.sourceforge.net/cishell/?rev=1245&view=rev Author: jrbibers Date: 2011-06-22 21:34:34 +0000 (Wed, 22 Jun 2011) Log Message: ----------- Null argument needs to be cast to String so that the correct overload is called. The call is ambiguous otherwise. Reviewed by Chintan. Modified Paths: -------------- trunk/libs/org.knopflerfish.bundle.ksoap_osgi/src/org/knopflerfish/bundle/ksoap/Activator.java Modified: trunk/libs/org.knopflerfish.bundle.ksoap_osgi/src/org/knopflerfish/bundle/ksoap/Activator.java =================================================================== --- trunk/libs/org.knopflerfish.bundle.ksoap_osgi/src/org/knopflerfish/bundle/ksoap/Activator.java 2011-04-11 19:39:19 UTC (rev 1244) +++ trunk/libs/org.knopflerfish.bundle.ksoap_osgi/src/org/knopflerfish/bundle/ksoap/Activator.java 2011-06-22 21:34:34 UTC (rev 1245) @@ -113,7 +113,7 @@ bc.addServiceListener(this); // Make sure we get services already registered - ServiceReference[] srl = bc.getServiceReferences(null, null); + ServiceReference[] srl = bc.getServiceReferences((String) null, null); for(int i = 0; srl != null && i < srl.length; i++) { serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srl[i])); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kon...@us...> - 2011-04-11 19:39:25
|
Revision: 1244 http://cishell.svn.sourceforge.net/cishell/?rev=1244&view=rev Author: kongchinhua Date: 2011-04-11 19:39:19 +0000 (Mon, 11 Apr 2011) Log Message: ----------- Fixed the duplicated extensions while save is invoked Modified Paths: -------------- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-04-07 17:26:42 UTC (rev 1243) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-04-11 19:39:19 UTC (rev 1244) @@ -39,7 +39,9 @@ dialog.setFilterPath(currentDirectory.getPath()); - if ((fileExtension != null) && !"*".equals(fileExtension) && !"".equals(fileExtension)) { + if ((fileExtension != null) && !"*".equals(fileExtension) && !"".equals(fileExtension) && + !suggestedFileName.endsWith(fileExtension)) { + String isolatedFileName = stripFileExtension(suggestedFileName); suggestedFileName = String.format("%s.%s", suggestedFileName, suggestedFileExtension); dialog.setFilterExtensions(new String[] { String.format("*.%s", fileExtension) }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-04-07 17:26:51
|
Revision: 1243 http://cishell.svn.sourceforge.net/cishell/?rev=1243&view=rev Author: jrbibers Date: 2011-04-07 17:26:42 +0000 (Thu, 07 Apr 2011) Log Message: ----------- Fixing static executable problems stemming from CIShell revision 1191 (January 11 2001). Specifically, since the GUESS static executable substitutes its arguments into (on Windows) a batch file or (on *nix) a shell script, the presence of whitespace or special/shell characters was not working cross-platform. In this revision we simplify the string substitution performed at the StaticExecutableRunner level, attempt to clean the string of troublesome characters like ">" and "&", and apply platform-appropriate argument quotation in the mentioned GUESS batch files and shell scripts. Renaming unrelated variables to conform to our CheckStyle. Reviewed by Micah. Revision Links: -------------- http://cishell.svn.sourceforge.net/cishell/?rev=1191&view=rev Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-04-04 15:35:31 UTC (rev 1242) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-04-07 17:26:42 UTC (rev 1243) @@ -24,6 +24,7 @@ import java.nio.channels.ReadableByteChannel; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; @@ -34,7 +35,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.regex.Pattern; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; @@ -53,18 +53,33 @@ * @author Bruce Herr (bh...@bh...) */ public class StaticExecutableRunner implements Algorithm { + public static final String DEFAULT_SAFE_SUBSTITUTE = "_"; + public static final Map<String, String> TROUBLE_CHARACTER_SUBSTITUTIONS; + static { + Map<String, String> m = new HashMap<String, String>(); + m.put("\"", "''"); + m.put(";", DEFAULT_SAFE_SUBSTITUTE); + m.put(",", DEFAULT_SAFE_SUBSTITUTE); + m.put("&", DEFAULT_SAFE_SUBSTITUTE); + m.put("|", DEFAULT_SAFE_SUBSTITUTE); + m.put("<", DEFAULT_SAFE_SUBSTITUTE); + m.put(">", DEFAULT_SAFE_SUBSTITUTE); + + TROUBLE_CHARACTER_SUBSTITUTIONS = Collections.unmodifiableMap(m); + } + public static final String EXECUTABLE_PLACEHOLDER = "executable"; public static final String DATA_LABEL_PLACEHOLDER = "data_label"; public static final String IN_FILE_PLACEHOLDER = "inFile"; - private String ALGORITHM; - private String macOSX_PPC_DirectoryPath; - private String MACOSX; - private String ALGORITHM_WIN32; - private String WIN32; - private String ALGORITHM_LINUX_X86; - private String LINUX; - private String ALGORITHM_DEFAULT; + private String algorithm; + private String macOsXPpcDirectoryPath; + private String macOsX; + private String algorithmWin32; + private String win32; + private String algorithmLinuxX86; + private String linux; + private String algorithmDefault; private String algorithmDirectoryPath; private String temporaryDirectoryPath; @@ -96,14 +111,14 @@ // Determine directory paths for each platform, based on algorithmName. - this.ALGORITHM = algorithmName + "/"; - this.macOSX_PPC_DirectoryPath = ALGORITHM + "macosx.ppc/"; - this.MACOSX = "macosx"; - this.ALGORITHM_WIN32 = ALGORITHM + "win32/"; - this.WIN32 = "win32"; - this.ALGORITHM_LINUX_X86 = ALGORITHM + "linux.x86/"; - this.LINUX = "linux"; - this.ALGORITHM_DEFAULT = ALGORITHM + "default/"; + this.algorithm = algorithmName + "/"; + this.macOsXPpcDirectoryPath = algorithm + "macosx.ppc/"; + this.macOsX = "macosx"; + this.algorithmWin32 = algorithm + "win32/"; + this.win32 = "win32"; + this.algorithmLinuxX86 = algorithm + "linux.x86/"; + this.linux = "linux"; + this.algorithmDefault = algorithm + "default/"; // if a constructor variable was null, use a null object version of it if possible @@ -168,26 +183,26 @@ String path = null; // take the default, if there - if (entries.contains(ALGORITHM_DEFAULT)) { - String default_path = ALGORITHM_DEFAULT; + if (entries.contains(algorithmDefault)) { + String defaultPath = algorithmDefault; // logger.log(LogService.LOG_DEBUG, "base path: "+default_path+ // "\n\t"+dir.getAbsolutePath() + "\n\n"); - copyDir(dir, default_path, 0); + copyDir(dir, defaultPath, 0); } // but override with platform idiosyncracies - if (os.equals(WIN32) && entries.contains(ALGORITHM_WIN32)) { - path = ALGORITHM_WIN32; - } else if (os.equals(MACOSX) && entries.contains(macOSX_PPC_DirectoryPath)) { - path = macOSX_PPC_DirectoryPath; - } else if (os.equals(LINUX) && entries.contains(ALGORITHM_LINUX_X86)) { - path = ALGORITHM_LINUX_X86; + if (os.equals(win32) && entries.contains(algorithmWin32)) { + path = algorithmWin32; + } else if (os.equals(macOsX) && entries.contains(macOsXPpcDirectoryPath)) { + path = macOsXPpcDirectoryPath; + } else if (os.equals(linux) && entries.contains(algorithmLinuxX86)) { + path = algorithmLinuxX86; } - String platform_path = ALGORITHM + os + "." + arch + "/"; + String platformPath = algorithm + os + "." + arch + "/"; // and always override anything with an exact match - if (entries.contains(platform_path)) { - path = platform_path; + if (entries.contains(platformPath)) { + path = platformPath; } if (path == null) { @@ -216,7 +231,8 @@ } } - protected File[] executeProgram(String[] commandArray, String baseDirPath) throws AlgorithmExecutionException { + protected File[] executeProgram(String[] commandArray, String baseDirPath) + throws AlgorithmExecutionException { /* * Remember which files were in the directory before we ran * the program. @@ -226,8 +242,11 @@ //create and run the executing process Process process = null; - try { - process = Runtime.getRuntime().exec(commandArray, null, new File(baseDirPath)); + try { + ProcessBuilder processBuilder = new ProcessBuilder(commandArray); + processBuilder.directory(new File(baseDirPath)); + process = processBuilder.start(); + process.getOutputStream().close(); } catch (IOException e1) { throw new AlgorithmExecutionException(e1.getMessage(), e1); @@ -238,10 +257,10 @@ monitor.start(ProgressMonitor.CANCELLABLE, -1); InputStream in = process.getInputStream(); - StringBuffer in_buffer = new StringBuffer(); + StringBuffer inBuffer = new StringBuffer(); InputStream err = process.getErrorStream(); - StringBuffer err_buffer = new StringBuffer(); + StringBuffer errBuffer = new StringBuffer(); Integer exitValue = null; boolean killedOnPurpose = false; @@ -249,8 +268,8 @@ while (!killedOnPurpose && exitValue == null) { //print its output, and watch to see if it has finished/died. - in_buffer = logStream(LogService.LOG_INFO, in, in_buffer); - err_buffer = logStream(LogService.LOG_ERROR, err, err_buffer); + inBuffer = logStream(LogService.LOG_INFO, in, inBuffer); + errBuffer = logStream(LogService.LOG_ERROR, err, errBuffer); if (monitor.isCanceled()) { killedOnPurpose = true; @@ -276,7 +295,9 @@ // if the process failed unexpectedly... if (process.exitValue() != 0 && !killedOnPurpose) { - throw new AlgorithmExecutionException("Algorithm exited unexpectedly (exit value: " + process.exitValue() + throw new AlgorithmExecutionException( + "Algorithm exited unexpectedly (exit value: " + + process.exitValue() + "). Please check the console window for any error messages."); } @@ -347,7 +368,8 @@ String label = properties.getProperty("outFile[" + i + "].label", f.getName()); data[i].getMetadata().put(DataProperty.LABEL, label); - String type = properties.getProperty("outFile[" + i + "].type", DataProperty.OTHER_TYPE); + String type = + properties.getProperty("outFile[" + i + "].type", DataProperty.OTHER_TYPE); type = type.trim(); if (type.equalsIgnoreCase(DataProperty.MATRIX_TYPE)) { type = DataProperty.MATRIX_TYPE; @@ -398,7 +420,8 @@ } catch (EOFException e) { // normal operation } catch (IOException e) { - throw new AlgorithmExecutionException("Error when processing the algorithm's screen output", e); + throw new AlgorithmExecutionException( + "Error when processing the algorithm's screen output", e); } return buffer; @@ -459,13 +482,16 @@ return commands; } - - // replaces place-holder variables in the template with the actual arguments the executable needs to work. - // (real names of files instead of inFile[i], for instance) - // (also, real values like "6" or "dog" instead of placeholders for parameters) + + /* replaces place-holder variables in the template with the actual arguments the executable + * needs to work. + * (real names of files instead of inFile[i], for instance) + * (also, real values like "6" or "dog" instead of placeholders for parameters) + */ protected String substituteVars(String template, Data[] data, Dictionary parameters) { - template = template.replaceAll( - "\\$\\{" + EXECUTABLE_PLACEHOLDER + "\\}", properties.getProperty(EXECUTABLE_PLACEHOLDER)); + template = template.replace( + String.format("${%s}", EXECUTABLE_PLACEHOLDER), + properties.getProperty(EXECUTABLE_PLACEHOLDER)); /* * Re-think: @@ -481,9 +507,11 @@ String key = (String) i.nextElement(); Object value = parameters.get(key); - if (value == null) value = ""; + if (value == null) { + value = ""; + } - template = template.replaceAll("\\$\\{" + key + "\\}", value.toString()); + template = template.replace(String.format("${%s}", key), value.toString()); } return template; @@ -502,17 +530,30 @@ label = labelObject.toString(); } - /* TODO Re-think converting backslash to slash for the following expects: - * i) Need to consider what is the system file separator - * ii) The backslash in data_label might have special meaning. - * iii) may be we should use " to quote the data_label - */ - String escapedLabel = label.replaceAll("\\\\", "/"); + String cleanedLabel = cleanDataLabel(label); - return template.replaceAll(Pattern.quote(key), escapedLabel); + return template.replace(key, cleanedLabel); } } + /* Replace each double-quote with two single-quotes. + * This alleviates some cross-platform problems with command-line template substitution. + * In particular, GUESS substitutes its values into batch/shell scripts and will not behave + * properly on every platform if these troublesome characters occur. + */ + private String cleanDataLabel(String label) { + String cleanedLabel = label; + + for (String troubleCharacter : TROUBLE_CHARACTER_SUBSTITUTIONS.keySet()) { + cleanedLabel = + cleanedLabel.replace( + troubleCharacter, + TROUBLE_CHARACTER_SUBSTITUTIONS.get(troubleCharacter)); + } + + return cleanedLabel; + } + private String substituteForFilePath(String template, Data[] data, int ii) { String key = String.format("${%s[%d]}", IN_FILE_PLACEHOLDER, ii); @@ -526,20 +567,9 @@ File file = (File) datumObject; filePath = file.getAbsolutePath(); } - - if (File.separatorChar == '\\') { - filePath = filePath.replace(File.separatorChar, '/'); - } - String substituted = template.replaceAll(Pattern.quote(key), filePath); + String substituted = template.replace(key, filePath); - /* TODO: Re-think - This auto convert every backslash and slash. - * Which might convert everything that you don't intend to convert. - */ - if (File.separatorChar == '\\') { - substituted = substituted.replace('/', File.separatorChar); - } - return substituted; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-04-04 15:35:40
|
Revision: 1242 http://cishell.svn.sourceforge.net/cishell/?rev=1242&view=rev Author: jrbibers Date: 2011-04-04 15:35:31 +0000 (Mon, 04 Apr 2011) Log Message: ----------- As of revision 5366, the console text processor no longer attempts to automatically detect URLs in plain text. Text for formatting as a clickable link must be marked up in the plain text with [url] tags by the console's client. Because of this, URLs from the documentation_url and reference_url of an algorithm's properties were no longer automatically clickable. This commit adds [url] tags around those two kinds of common URLs. Reviewed by Micah. Revision Links: -------------- http://cishell.svn.sourceforge.net/cishell/?rev=5366&view=rev Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2011-04-01 20:57:29 UTC (rev 1241) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2011-04-04 15:35:31 UTC (rev 1242) @@ -127,7 +127,7 @@ if ((reference != null) && (reference_url != null)) { acknowledgement.append( - "Reference: " + reference + " (" + reference_url + ")\n"); + "Reference: " + reference + " ([url]" + reference_url + "[/url])\n"); } else if ((reference != null) && (reference_url == null)) { acknowledgement.append("Reference: " + reference + "\n"); } @@ -135,7 +135,7 @@ String documentationURL = (String) serviceReference.getProperty(DOCUMENTATION_URL); if (documentationURL != null) { - acknowledgement.append("Documentation: " + documentationURL + "\n"); + acknowledgement.append("Documentation: [url]" + documentationURL + "[/url]\n"); } if (acknowledgement.length() > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-04-01 20:57:36
|
Revision: 1241 http://cishell.svn.sourceforge.net/cishell/?rev=1241&view=rev Author: jrbibers Date: 2011-04-01 20:57:29 +0000 (Fri, 01 Apr 2011) Log Message: ----------- Welcome text URLs. Changed method of hyperlinking from welcome text. Previously we attempted to detect URLs in bare strings. This is a hard problem; consider cases like "(URL)", "(URL).", "(text URL)", and "(URL text)", especially when URL may contain infrequent-but-valid characters like parentheses. See http://www.codinghorror.com/blog/2008/10/the-problem-with-urls.html . Now we do not attempt URL detection. Strings in a piece of welcome text intended for formatting as a clickable link should be enclosed in "url" tags as in "Visit our website ([url]http://example.com[/url]) for more details". Reviewed by Micah. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/plugin.properties trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/plugin.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/plugin.properties 2011-03-31 20:10:14 UTC (rev 1240) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/plugin.properties 2011-04-01 20:57:29 UTC (rev 1241) @@ -2,6 +2,7 @@ appName = CIShellApplication aboutImage = icons/about.gif windowImages = icons/alt16.gif,icons/alt32.gif,icons/alt64.gif +# Mark up URLs with url tags, like [url]http://example.com[/url]. blurb = Welcome to the Cyberinfrastructure Shell (CIShell) \ developed at the InfoVis Lab and the CI for Network Science Center \ at Indiana University.\n\n\ @@ -9,5 +10,5 @@ Bruce Herr, Weixia Huang, Shashikant Penumarthy, and Katy Borner. (in press). \ Designing Highly Flexible and Usable Cyberinfrastructures for Convergence. \ William S. Bainbridge (Ed.) Progress in Convergence. Annals of the New York Academy of Sciences.\n\ -http://cishell.org/papers/06-cishell.pdf +[url]http://cishell.org/papers/06-cishell.pdf[/url] Modified: trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java 2011-03-31 20:10:14 UTC (rev 1240) +++ trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java 2011-04-01 20:57:29 UTC (rev 1241) @@ -127,8 +127,8 @@ for (StyleRange highlightStyle : highlights) { int start = nonHighlightStyle.start; - if ((start >= highlightStyle.start) && - (start < (highlightStyle.start + highlightStyle.length))) { + if ((start >= highlightStyle.start) + && (start < (highlightStyle.start + highlightStyle.length))) { newStyle = (StyleRange) newStyle.clone(); newStyle.background = HIGHLIGHTED_BACKGROUND_COLOR; } @@ -208,7 +208,8 @@ @SuppressWarnings("unchecked") public void createPartControl(Composite parent) { this.parent = parent; - this.textField = new StyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY); + this.textField = + new StyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY); this.textField.setEditable(false); this.textField.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); this.textField.getCaret().setVisible(false); @@ -261,11 +262,10 @@ Enumeration backLogEntries = logReaderService.getLog(); while (backLogEntries.hasMoreElements()) { - LogEntry logEntry = (LogEntry)backLogEntries.nextElement(); + LogEntry logEntry = (LogEntry) backLogEntries.nextElement(); this.logged(logEntry); } - } - else { + } else { System.out.println("reader is null"); } @@ -328,7 +328,7 @@ } } - Collection<StyleRange> styles = SWTUtilities.appendStringWithURL( + Collection<StyleRange> styles = SWTUtilities.urlifyUrls( LogView.this.textField, LogView.this.urlListener, LogView.this.urlCursorListener, @@ -348,10 +348,10 @@ } private boolean goodMessage(String msg) { - if (msg == null || - msg.startsWith("ServiceEvent ") || - msg.startsWith("BundleEvent ") || - msg.startsWith("FrameworkEvent ")) { + if (msg == null + || msg.startsWith("ServiceEvent ") + || msg.startsWith("BundleEvent ") + || msg.startsWith("FrameworkEvent ")) { return false; } else { return true; Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java 2011-03-31 20:10:14 UTC (rev 1240) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java 2011-04-01 20:57:29 UTC (rev 1241) @@ -2,6 +2,7 @@ import java.util.Collection; import java.util.HashSet; +import java.util.regex.Pattern; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; @@ -10,131 +11,90 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -/** TODO: The URL (http://-prefixed) parsing utilities in this class need to be updated to handle - * https as well. - */ public class SWTUtilities { - public static final Color DEFAULT_BACKGROUND_COLOR = - new Color(Display.getDefault(), 255, 255, 255); - /* - * Append the given string to the console with the given color, this will do the job of - * checking for URLs within the string and registering the proper listeners on them as well. + public static final String URL_START_TAG = "[url]"; + public static final String URL_END_TAG = "[/url]"; + + /** Do not instantiate utilities. */ + protected SWTUtilities() { + throw new UnsupportedOperationException(); + } + + /** + * Style text within URL_START_TAG and URL_END_TAG like URLs and make them clickable links. */ - public static Collection<StyleRange> appendStringWithURL( + public static Collection<StyleRange> urlifyUrls( StyledText textField, URLClickedListener urlListener, URLMouseCursorListener urlCursorListener, String message, Color normalColor, Color urlColor) { - return appendStringWithURL( - textField, - urlListener, - urlCursorListener, - message, - DEFAULT_BACKGROUND_COLOR, - normalColor, - urlColor); - } - - public static Collection<StyleRange> appendStringWithURL( - StyledText textField, - URLClickedListener urlListener, - URLMouseCursorListener urlCursorListener, - String message, - Color backgroundColor, - Color normalColor, - Color urlColor) { - - //find a URL in the message - - int index = message.indexOf("http://"); - if (index == -1) { - index = message.indexOf("https://"); - } - if (index == -1) { - index = message.indexOf("www."); - } - - if (index > -1) { - String url = message.substring(index); - if (url.indexOf(") ") > -1) { - url = url.substring(0, url.indexOf(") ")); - } - else if (url.indexOf(" ") > -1) { - url = url.substring(0, url.indexOf(" ")); - if (url.trim().endsWith(".") ){ - url=url.substring(0, url.length()-1); - } - } - if (url.endsWith(".\n") || url.endsWith(".\t")){ - url=url.substring(0, url.length()-2); - } - if (url.indexOf("\n") > -1) { - url = url.substring(0, url.indexOf("\n")); - } - if (url.indexOf("\t") > -1) { - url = url.substring(0, url.indexOf("\n")); - } - - - StyleRange preURLStyle = syncedStyledPrint( - textField, message.substring(0, index), backgroundColor, normalColor, SWT.NORMAL); - urlListener.addURL(textField.getText().length(), url); - urlCursorListener.addURL(textField.getText().length(), url); - StyleRange urlStyle = - syncedStyledPrint(textField, url, backgroundColor, urlColor, SWT.BOLD); - Collection<StyleRange> postURLStyles = appendStringWithURL( - textField, - urlListener, - urlCursorListener, - message.substring(index + url.length()), - backgroundColor, - normalColor, - urlColor); - - Collection<StyleRange> finalStyles = new HashSet<StyleRange>(); - - if (preURLStyle != null) { - finalStyles.add(preURLStyle); - } - - if (urlStyle != null) { - finalStyles.add(urlStyle); - } - - finalStyles.addAll(postURLStyles); - - return finalStyles; - } else { - StyleRange style = syncedStyledPrint( - textField, message, backgroundColor, normalColor, SWT.NORMAL); - - if (style != null) { - Collection<StyleRange> finalStyles = new HashSet<StyleRange>(); - finalStyles.add(style); - - return finalStyles; - } else { - return new HashSet<StyleRange>(); - } - } + int startTagIndex = message.indexOf(URL_START_TAG); + int endTagIndex = message.indexOf(URL_END_TAG); + + boolean urlDetected = startTagIndex >= 0 && endTagIndex >= 0; + if (urlDetected) { + String urlWithTags = + message.substring(startTagIndex, endTagIndex + URL_END_TAG.length()); + String url = + urlWithTags.substring( + URL_START_TAG.length(), + urlWithTags.length() - URL_END_TAG.length()); + + String messageWithFirstUrlDetagged = + message.replaceFirst(Pattern.quote(urlWithTags), url); + + String messageBeforeUrl = messageWithFirstUrlDetagged.substring(0, startTagIndex); + StyleRange preURLStyle = syncedStyledPrint( + textField, messageBeforeUrl, normalColor, SWT.NORMAL); + urlListener.addURL(textField.getText().length(), url); + urlCursorListener.addURL(textField.getText().length(), url); + StyleRange urlStyle = + syncedStyledPrint(textField, url, urlColor, SWT.BOLD); + String messageBeyondFirstUrl = + messageWithFirstUrlDetagged.substring(startTagIndex + url.length()); + Collection<StyleRange> postURLStyles = urlifyUrls( + textField, + urlListener, + urlCursorListener, + messageBeyondFirstUrl, + normalColor, + urlColor); + + Collection<StyleRange> finalStyles = new HashSet<StyleRange>(); + + if (preURLStyle != null) { + finalStyles.add(preURLStyle); + } + + if (urlStyle != null) { + finalStyles.add(urlStyle); + } + + finalStyles.addAll(postURLStyles); + + return finalStyles; + } else { + StyleRange style = syncedStyledPrint(textField, message, normalColor, SWT.NORMAL); + + if (style != null) { + Collection<StyleRange> finalStyles = new HashSet<StyleRange>(); + finalStyles.add(style); + + return finalStyles; + } else { + return new HashSet<StyleRange>(); + } + } } - /* - * Helper to actually format the string with a style range and - * append it to the StyledText control. + /** + * Format the string with a style range and append it to the StyledText control. */ - public static StyleRange syncedStyledPrint( - StyledText textField, String message, Color color, int style) { - return syncedStyledPrint(textField, message, DEFAULT_BACKGROUND_COLOR, color, style); - } - - public static StyleRange syncedStyledPrint( final StyledText textField, final String message, - final Color backgroundColor, final Color color, final int style) { final StyleRange[] styleRange = new StyleRange[1]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-03-31 20:10:21
|
Revision: 1240 http://cishell.svn.sourceforge.net/cishell/?rev=1240&view=rev Author: jrbibers Date: 2011-03-31 20:10:14 +0000 (Thu, 31 Mar 2011) Log Message: ----------- Updating wiki link. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2011-03-30 21:04:34 UTC (rev 1239) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2011-03-31 20:10:14 UTC (rev 1240) @@ -1,11 +1,11 @@ -menu_path=File/start -label=Load... -shortcut=ctrl+alt+o -description=This allows users to select files from the file system and load them to Data Model window. -in_data=null -out_data=java.lang.Object -service.pid=org.cishell.reference.gui.persistence.load.FileLoadAlgorithm -remoteable=true -prefs_published=local -receive_prefs=true -documentation_url=http://wiki.slis.indiana.edu:8080/display/ALGDOC/Data+Formats \ No newline at end of file +menu_path=File/start +label=Load... +shortcut=ctrl+alt+o +description=This allows users to select files from the file system and load them to Data Model window. +in_data=null +out_data=java.lang.Object +service.pid=org.cishell.reference.gui.persistence.load.FileLoadAlgorithm +remoteable=true +prefs_published=local +receive_prefs=true +documentation_url=http://wiki.cns.iu.edu/display/CISHELL/Data+Formats Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties 2011-03-30 21:04:34 UTC (rev 1239) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties 2011-03-31 20:10:14 UTC (rev 1240) @@ -1,11 +1,11 @@ -menu_path=File/start -label=Save... -shortcut=ctrl+alt+s -description=Saves data to disk -in_data=java.lang.Object -out_data=null -service.pid=org.cishell.reference.gui.persistence.save.Save -remoteable=true -prefs_published=local -receive_prefs=true -documentation_url=http://wiki.slis.indiana.edu:8080/display/ALGDOC/Data+Formats \ No newline at end of file +menu_path=File/start +label=Save... +shortcut=ctrl+alt+s +description=Saves data to disk +in_data=java.lang.Object +out_data=null +service.pid=org.cishell.reference.gui.persistence.save.Save +remoteable=true +prefs_published=local +receive_prefs=true +documentation_url=http://wiki.cns.iu.edu/display/CISHELL/Data+Formats This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-03-30 21:04:40
|
Revision: 1239 http://cishell.svn.sourceforge.net/cishell/?rev=1239&view=rev Author: jrbibers Date: 2011-03-30 21:04:34 +0000 (Wed, 30 Mar 2011) Log Message: ----------- StaticExecutableRunner now only checks each datum's label and file path when necessary, that is, when it occurs in the static executable's command-line template (as specified in config.properties files). Additionally, when either of these pieces of information are requested, we now check whether they are null before calling toString. In the case that we are null, we get the semi-palatable defaults "unknown_data_label" and "unknown_file_path", respectively. Reviewed by Chin Hua. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-03-07 19:35:47 UTC (rev 1238) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-03-30 21:04:34 UTC (rev 1239) @@ -34,6 +34,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.regex.Pattern; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; @@ -462,41 +463,85 @@ // replaces place-holder variables in the template with the actual arguments the executable needs to work. // (real names of files instead of inFile[i], for instance) // (also, real values like "6" or "dog" instead of placeholders for parameters) - protected String substituteVars(String str, Data[] data, Dictionary parameters) { - str = str.replaceAll( + protected String substituteVars(String template, Data[] data, Dictionary parameters) { + template = template.replaceAll( "\\$\\{" + EXECUTABLE_PLACEHOLDER + "\\}", properties.getProperty(EXECUTABLE_PLACEHOLDER)); + /* + * Re-think: + * Shall we just name the same in config.propertities? + * Why not use parameter key for all inFile and data? + */ for (int ii = 0; ii < data.length; ii++) { - System.err.println(data[0]); - String label = data[0].getMetadata().get(DataProperty.LABEL).toString(); + template = substituteForDataLabel(template, data, ii); + template = substituteForFilePath(template, data, ii); + } + + for (Enumeration i = parameters.keys(); i.hasMoreElements();) { + String key = (String) i.nextElement(); + Object value = parameters.get(key); + + if (value == null) value = ""; + + template = template.replaceAll("\\$\\{" + key + "\\}", value.toString()); + } + + return template; + } + + private String substituteForDataLabel(String template, Data[] data, int ii) { + String key = String.format("${%s[%d]}", DATA_LABEL_PLACEHOLDER, ii); + + if (!template.contains(key)) { + return template; + } else { + Object labelObject = data[ii].getMetadata().get(DataProperty.LABEL); + + String label = "unknown_data_label"; + if (labelObject != null) { + label = labelObject.toString(); + } + + /* TODO Re-think converting backslash to slash for the following expects: + * i) Need to consider what is the system file separator + * ii) The backslash in data_label might have special meaning. + * iii) may be we should use " to quote the data_label + */ String escapedLabel = label.replaceAll("\\\\", "/"); - str = str.replaceAll( - "\\$\\{" + DATA_LABEL_PLACEHOLDER + "\\[" + ii + "\\]\\}", escapedLabel); + + return template.replaceAll(Pattern.quote(key), escapedLabel); + } + } - File inFile = (File)data[ii].getData(); - String filePath = inFile.getAbsolutePath(); - + private String substituteForFilePath(String template, Data[] data, int ii) { + String key = String.format("${%s[%d]}", IN_FILE_PLACEHOLDER, ii); + + if (!template.contains(key)) { + return template; + } else { + Object datumObject = data[ii].getData(); + + String filePath = "unknown_file_path"; + if (datumObject != null && datumObject instanceof File) { + File file = (File) datumObject; + filePath = file.getAbsolutePath(); + } + if (File.separatorChar == '\\') { filePath = filePath.replace(File.separatorChar, '/'); } - str = str.replaceAll("\\$\\{" + IN_FILE_PLACEHOLDER + "\\[" + ii + "\\]\\}", filePath); + String substituted = template.replaceAll(Pattern.quote(key), filePath); + /* TODO: Re-think - This auto convert every backslash and slash. + * Which might convert everything that you don't intend to convert. + */ if (File.separatorChar == '\\') { - str = str.replace('/', File.separatorChar); + substituted = substituted.replace('/', File.separatorChar); } + + return substituted; } - - for (Enumeration i = parameters.keys(); i.hasMoreElements();) { - String key = (String) i.nextElement(); - Object value = parameters.get(key); - - if (value == null) value = ""; - - str = str.replaceAll("\\$\\{" + key + "\\}", value.toString()); - } - - return str; } public File getTempDirectory() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-07 19:35:53
|
Revision: 1238 http://cishell.svn.sourceforge.net/cishell/?rev=1238&view=rev Author: pataphil Date: 2011-03-07 19:35:47 +0000 (Mon, 07 Mar 2011) Log Message: ----------- * Trying to clean up the File IO Services, but there are still some issues. See the wiki. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 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 2011-03-07 19:35:10 UTC (rev 1237) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2011-03-07 19:35:47 UTC (rev 1238) @@ -8,7 +8,6 @@ import org.cishell.framework.algorithm.AlgorithmCanceledException; import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; -import org.cishell.service.conversion.Converter; import org.osgi.service.log.LogService; public class Save implements Algorithm { @@ -37,30 +36,31 @@ private void tryToSave(final Data outData, String outFormat) throws AlgorithmExecutionException { try { - Converter userChosenConverter = - this.fileSaver.promptForConverter(outData, outFormat); - - if (userChosenConverter == null) { + File outputFile = this.fileSaver.saveData(outData); +// Converter userChosenConverter = +// this.fileSaver.promptForConverter(outData, outFormat); +// +// if (userChosenConverter == null) { +// throw new AlgorithmCanceledException( +// "User canceled file saving when choosing what kind of file to save as."); +// } +// +// File userChosenFile = this.fileSaver.promptForTargetFile(outData); +// + if (outputFile == null) { throw new AlgorithmCanceledException( - "User canceled file saving when choosing what kind of file to save as."); - } - - File userChosenFile = this.fileSaver.promptForTargetFile(outData); - - if (userChosenFile == null) { - throw new AlgorithmCanceledException( "User canceled file saving when choosing the destination of the file."); } +// +// Data outputDatum = +// this.fileSaver.save(userChosenConverter, outData, userChosenFile); +// +// // TODO: Should we bother handling this? sure, why not. maybe algexec would be appropriate +// if (outputDatum == null) { +// return; +// } - Data outputDatum = - this.fileSaver.save(userChosenConverter, outData, userChosenFile); - - // TODO: Should we bother handling this? sure, why not. maybe algexec would be appropriate - if (outputDatum == null) { - return; - } - - String logMessage = String.format("Saved: %s", userChosenFile.getPath()); + String logMessage = String.format("Saved: %s", outputFile.getPath()); this.logger.log(LogService.LOG_INFO, logMessage); } catch (FileSaveException e) { String logMessage = String.format( Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java 2011-03-07 19:35:10 UTC (rev 1237) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java 2011-03-07 19:35:47 UTC (rev 1238) @@ -7,6 +7,7 @@ import java.util.Dictionary; import java.util.HashSet; +import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; import org.cishell.service.conversion.ConversionException; @@ -26,6 +27,8 @@ new Character('|'), new Character('%')))); public static final char FILENAME_CHARACTER_REPLACEMENT = '#'; + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + public static final String FILE_PREFIX = "file:"; private Collection<FileSaveListener> listeners; @@ -41,68 +44,77 @@ return promptForTargetFile(""); } - public File promptForTargetFile(Data datum) throws FileSaveException { + public File promptForTargetFile(String defaultFileExtension) throws FileSaveException { + return promptForTargetFile("", defaultFileExtension); + } + + public File promptForTargetFile( + Data datum, String defaultFileExtension) throws FileSaveException { Object dataObject = datum.getData(); if (dataObject instanceof File) { - return promptForTargetFile((File) datum.getData()); + String fileName = ((File) datum.getData()).getName(); + return promptForTargetFile(fileName, defaultFileExtension); } else { - return promptForTargetFile(suggestFileName(datum)); + return promptForTargetFile(suggestFileName(datum), defaultFileExtension); } } public File promptForTargetFile(File outputFile) throws FileSaveException { - return promptForTargetFile(outputFile.getName()); + return promptForTargetFile(outputFile.getName(), ""); } - public File save(Data sourceDatum) throws FileSaveException { - return save((File) sourceDatum.getData()); + public File saveData(Data sourceDatum) throws FileSaveException { + return saveData(sourceDatum, ANY_FILE_EXTENSION); } - public File save(File sourceFile) throws FileSaveException { - File targetFile = promptForTargetFile(sourceFile); - saveTo(sourceFile, targetFile); - - return targetFile; - } - - public Data save(Data sourceDatum, String targetMimeType) + public File saveData(Data sourceDatum, String targetMimeType) throws FileSaveException { Converter converter = promptForConverter(sourceDatum, targetMimeType); if (converter != null) { - return save(converter, sourceDatum); + return saveData(sourceDatum, converter); } else { // TODO: CanceledException? return null; } } - // TODO: What to actually return here? Maybe Pair<Data, File> (LOL)? - public Data save(Converter converter, Data sourceDatum) - throws FileSaveException { - File targetFile = promptForTargetFile(sourceDatum); + public File saveData(Data sourceDatum, Converter converter) throws FileSaveException { + String outputMimeType = + converter.getProperties().get(AlgorithmProperty.OUT_DATA).toString(); + System.err.println("outputMimeType: " + outputMimeType); + String suggestedFileExtension = suggestFileExtension(outputMimeType); + System.err.println("suggestedFileExtension: " + suggestedFileExtension); + File targetFile = promptForTargetFile(sourceDatum, suggestedFileExtension); if (targetFile != null) { - return save(converter, sourceDatum, targetFile); + return saveData(sourceDatum, converter, targetFile); } else { // TODO: CanceledException? return null; } } - public Data save( - Converter converter, Data sourceDatum, File targetFile) throws FileSaveException { + public File saveData(Data sourceDatum, Converter converter, File targetFile) + throws FileSaveException { try { Data convertedDatum = converter.convert(sourceDatum); saveTo((File) convertedDatum.getData(), targetFile); - return convertedDatum; + return targetFile; } catch (ConversionException e) { throw new FileSaveException(e.getMessage(), e); } } + public File save(File sourceFile) throws FileSaveException { + File targetFile = promptForTargetFile(sourceFile); + saveTo(sourceFile, targetFile); + + return targetFile; + } + public String suggestFileName(Data datum) { return replaceInvalidFilenameCharacters(getLabel(datum)); } @@ -134,4 +146,26 @@ return cleanedFilename; } + + private static String suggestFileExtension(String targetMimeType) { + if (targetMimeType.startsWith(FILE_EXTENSION_PREFIX)) { + return targetMimeType.substring(FILE_EXTENSION_PREFIX.length()); + } else if (targetMimeType.startsWith(FILE_PREFIX)) { + int forwardSlashCharacterIndex = targetMimeType.indexOf('/'); + + if (forwardSlashCharacterIndex != -1) { + int parsedOutFileExtensionStart = (forwardSlashCharacterIndex + 1); + + if (parsedOutFileExtensionStart < targetMimeType.length()) { + return targetMimeType.substring(parsedOutFileExtensionStart); + } else { + return ""; + } + } else { + return ""; + } + } else { + return targetMimeType; + } + } } \ No newline at end of file Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java 2011-03-07 19:35:10 UTC (rev 1237) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java 2011-03-07 19:35:47 UTC (rev 1238) @@ -19,26 +19,21 @@ throws FileSaveException; public File promptForTargetFile() throws FileSaveException; - public File promptForTargetFile(Data datum) throws FileSaveException; + public File promptForTargetFile(String defaultFileExtension) throws FileSaveException; + public File promptForTargetFile( + Data datum, String defaultFileExtension) throws FileSaveException; public File promptForTargetFile(File outputFile) throws FileSaveException; - public File promptForTargetFile(String fileName) throws FileSaveException; + public File promptForTargetFile( + String suggestedFileName, String defaultFileExtension) throws FileSaveException; - /* TODO I'm seriously tempted to recommend that all methods beyond this point be called - * "save" or "saveToFile" or something, and just have a bit of very concise Javadoc that - * explains what may be prompted for? Alternatively, ask another dev about doing the null - * arguments idea. - */ - // TODO (NEW): Just Javadoc these really well? - public File save(Data sourceDatum) throws FileSaveException; + public File saveData(Data sourceDatum) throws FileSaveException; + public File saveData(Data sourceDatum, String targetMimeType) throws FileSaveException; + public File saveData(Data sourceDatum, Converter converter) throws FileSaveException; + public File saveData( + Data sourceDatum, Converter converter, File targetFile) throws FileSaveException; + public File save(File sourceFile) throws FileSaveException; public void saveTo(File sourceFile, File targetFile) throws FileSaveException; - // TODO: What to actually return here? the File object for the one on disk - /* TODO sourceDatum always first, targetType/File last */ - public Data save(Data sourceDatum, String targetMimeType) throws FileSaveException; - public Data save(Converter converter, Data sourceDatum) throws FileSaveException; - public Data save( - Converter converter, Data sourceDatum, File targetFile) throws FileSaveException; - public String suggestFileName(Data datum); } \ No newline at end of file Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java 2011-03-07 19:35:10 UTC (rev 1237) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java 2011-03-07 19:35:47 UTC (rev 1238) @@ -75,7 +75,9 @@ } } - public File promptForTargetFile(final String fileName) throws FileSaveException { + public File promptForTargetFile( + final String suggestedFileName, + final String defaultFileExtension) throws FileSaveException { final File[] resultFile = new File[1]; try { @@ -84,7 +86,7 @@ SaveAsController saveAs = new SaveAsController(FileSaverServiceImpl.this.guiBuilder); - resultFile[0] = saveAs.open(fileName); + resultFile[0] = saveAs.open(suggestedFileName, defaultFileExtension); } }); Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-03-07 19:35:10 UTC (rev 1237) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-03-07 19:35:47 UTC (rev 1238) @@ -27,13 +27,8 @@ this.guiBuilder = guiBuilder; } - public File open(String fileName) { - String fileExtension = getFileExtension(fileName); - - return open(fileName, fileExtension); - } - - public File open(String suggestedFileName, String fileExtension) { + public File open(String suggestedFileName, String suggestedFileExtension) { + String fileExtension = determineFileExtension(suggestedFileName, suggestedFileExtension); Shell parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); FileDialog dialog = new FileDialog(parentShell, SWT.SAVE); @@ -45,6 +40,8 @@ dialog.setFilterPath(currentDirectory.getPath()); if ((fileExtension != null) && !"*".equals(fileExtension) && !"".equals(fileExtension)) { + String isolatedFileName = stripFileExtension(suggestedFileName); + suggestedFileName = String.format("%s.%s", suggestedFileName, suggestedFileExtension); dialog.setFilterExtensions(new String[] { String.format("*.%s", fileExtension) }); } @@ -70,6 +67,30 @@ } } + private String determineFileExtension( + String suggestedFileName, String suggestedFileExtension) { + if ((suggestedFileExtension != null) && !"".equals(suggestedFileExtension)) { + return suggestedFileExtension; + } else { + String fileExtension = getFileExtension(suggestedFileName); + + if (!"".equals(fileExtension)) { + return fileExtension; + } else { + return ""; + } + } +// if (!"".equals(fileExtension)) { +// return fileExtension; +// } else { +// if (defaultFileExtension != null) { +// return defaultFileExtension; +// } else { +// return ""; +// } +// } + } + private boolean confirmFileOverwrite(File file) { String message = "The file:\n" + file.getPath() + "\nalready exists. Are you sure you want to overwrite it?"; @@ -112,4 +133,15 @@ return cleanedFilename; } + + // TODO: Use cns-utilities when that's done. + private static String stripFileExtension(String filePath) { + int periodPosition = filePath.lastIndexOf("."); + + if ((periodPosition != -1) && ((periodPosition + 1) < filePath.length())) { + return filePath.substring(0, periodPosition); + } else { + return filePath; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-07 19:35:17
|
Revision: 1237 http://cishell.svn.sourceforge.net/cishell/?rev=1237&view=rev Author: pataphil Date: 2011-03-07 19:35:10 +0000 (Mon, 07 Mar 2011) Log Message: ----------- * Tried to implement drag-and-dropping into the tool. See wiki for notes on this. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/CIShellDataTransfer.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2011-03-07 19:18:57 UTC (rev 1236) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2011-03-07 19:35:10 UTC (rev 1237) @@ -8,11 +8,13 @@ org.eclipse.core.runtime Import-Package: org.cishell.app.service.datamanager;version="1.0.0", org.cishell.app.service.fileloader, + org.cishell.app.service.filesaver, org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", org.cishell.reference.gui.datamanager, org.cishell.reference.gui.workspace, + org.cishell.service.conversion;version="1.0.0", org.cishell.service.guibuilder;version="1.0.0", org.cishell.utilities, org.osgi.service.log;version="1.3.0" Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2011-03-07 19:18:57 UTC (rev 1236) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2011-03-07 19:35:10 UTC (rev 1237) @@ -50,6 +50,9 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TreeEditor; import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DragSource; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.DragSourceListener; import org.eclipse.swt.dnd.DropTarget; import org.eclipse.swt.dnd.DropTargetAdapter; import org.eclipse.swt.dnd.DropTargetEvent; @@ -98,7 +101,7 @@ private boolean updatingTreeItem; private Tree tree; private Menu menu; - private Map<Data, DataGUIItem> dataToDataGUIItemMap; + private Map<Data, DataGUIItem> dataToDataGUIItem; private AlgorithmFactory saveFactory; private AlgorithmFactory viewFactory; private AlgorithmFactory viewWithFactory; @@ -110,7 +113,7 @@ public AbstractDataManagerView(String brandPluginID) { this.brandPluginID = brandPluginID; - this.dataToDataGUIItemMap = new HashMap<Data, DataGUIItem>(); + this.dataToDataGUIItem = new HashMap<Data, DataGUIItem>(); this.manager = Activator.getDataManagerService(); this.logger = Activator.getLogService(); @@ -204,6 +207,11 @@ } private void setupDataManagerViewForDragAndDrop(Composite parent) { + setupDataManagerViewForDragAndDropInto(parent); + setupDataManagerViewForDragAndDropOutOf(parent); + } + + private void setupDataManagerViewForDragAndDropInto(Composite parent) { DropTarget dropTarget = new DropTarget(parent.getParent(), DND.DROP_DEFAULT | DND.DROP_MOVE); dropTarget.setTransfer(new Transfer[] { FileTransfer.getInstance() }); @@ -273,6 +281,34 @@ }); } + private void setupDataManagerViewForDragAndDropOutOf(Composite parent) { + Transfer[] types = new Transfer[] { new CIShellDataTransfer(Activator.context) }; + DragSource dragSource = new DragSource(parent, DND.DROP_DEFAULT | DND.DROP_MOVE); + dragSource.setTransfer(types); + dragSource.addDragListener(new DragSourceListener() { + private Data[] selectedData; + + public void dragStart(DragSourceEvent event) { + System.err.println("dragStart"); + Data[] selectedData = AbstractDataManagerView.this.manager.getSelectedData(); + + if ((selectedData != null) && (selectedData.length != 0)) { + event.doit = true; + this.selectedData = selectedData; + } + } + + public void dragSetData(DragSourceEvent event) { + // TODO: Create the target files. +// event.data = + } + + public void dragFinished(DragSourceEvent event) { + // TODO: Convert the source files, given the target files. + } + }); + } + private Collection<File> flattenDraggedFileStructures(String[] fileNames) { Collection<File> flattenedFileStructure = new ArrayList<File>(); @@ -337,7 +373,7 @@ /* Keep a reference to the new model in the model->TreeItem mapping so that it can be used * in the future if it has a child. */ - this.dataToDataGUIItemMap.put(newData, newItem); + this.dataToDataGUIItem.put(newData, newItem); // update the ModelManager with the new selection final Set<Data> selection = new HashSet<Data>(); @@ -370,7 +406,7 @@ parentItem = this.rootItem; } else { // Otherwise find the associated DataModelGUIItem for the parent. - parentItem = this.dataToDataGUIItemMap.get(parent); + parentItem = this.dataToDataGUIItem.get(parent); // The parent may not be in the GUI. If its not, then use root item. if (parentItem == null) { @@ -419,6 +455,7 @@ for (int i = 0; i < data.length; ++i) { TreeItem[] treeItems = tree.getItems(); +// tree.getSelection() for (int j = 0; j < treeItems.length; ++j) { if (treeItems[j].getData() == data[i]) { itemSet.add(treeItems[j]); @@ -427,6 +464,7 @@ } } + // TODO: Add dnd listeners to itemSet elements (if necessary) tree.setSelection(itemSet.toArray(new TreeItem[0])); getSite().getSelectionProvider().setSelection(new StructuredSelection(data)); } @@ -700,7 +738,7 @@ parent.removeChild(item); } - AbstractDataManagerView.this.dataToDataGUIItemMap.remove(item.getModel()); + AbstractDataManagerView.this.dataToDataGUIItem.remove(item.getModel()); AbstractDataManagerView.this.manager.removeData(item.getModel()); } @@ -774,7 +812,7 @@ (Data) next, AbstractDataManagerView.this.tree.getItems()); newTreeSelection[i] = result; AbstractDataManagerView.this.viewer.expandToLevel( - AbstractDataManagerView.this.dataToDataGUIItemMap.get(next), 0); + AbstractDataManagerView.this.dataToDataGUIItem.get(next), 0); } i++; Added: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/CIShellDataTransfer.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/CIShellDataTransfer.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/CIShellDataTransfer.java 2011-03-07 19:35:10 UTC (rev 1237) @@ -0,0 +1,91 @@ +package org.cishell.reference.gui.datamanager; + +import java.io.File; + +import org.cishell.app.service.filesaver.FileSaveException; +import org.cishell.app.service.filesaver.FileSaverService; +import org.cishell.framework.data.Data; +import org.cishell.service.conversion.ConversionException; +import org.cishell.service.conversion.Converter; +import org.eclipse.swt.dnd.ByteArrayTransfer; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.TransferData; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +/* I'm calling this CIShellDataTransfer to make it clear that it's domain-specific. + */ +public class CIShellDataTransfer extends ByteArrayTransfer { + public static final String TYPE_NAME = "CIShellData"; + public static final int TYPE_ID = registerType(TYPE_NAME); + + private BundleContext bundleContext; + + public CIShellDataTransfer(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + public void javaToNative(Object object, TransferData transferData) { + System.err.println(String.format( + "javaToNative: %s (%s) %s", object, object.getClass().getName(), transferData)); + if ((object == null) || !(object instanceof Data[])) { + return; + } + + if (isSupportedType(transferData)) { + Data[] data = (Data[]) object; + Data[] convertedData = convertData(data); + String[] convertedFilePaths = formConvertedFilePaths(convertedData); + FileTransfer.getInstance().javaToNative(convertedFilePaths, transferData); + } + } + + public Object nativeToJava(TransferData transferData) { + // TODO: I probably won't get to implementing this. Maybe throw an exception? + return null; + } + + protected String[] getTypeNames() { + return new String[] { TYPE_NAME }; + } + + protected int[] getTypeIds() { + return new int[] { TYPE_ID }; + } + + private Data[] convertData(Data[] data) { + Data[] convertedData = new Data[data.length]; + + for (int ii = 0; ii < data.length; ii++) { + try { + convertedData[ii] = convertDatum(data[ii]); + } catch (Throwable e) { + // TODO: Log this. + } + } + + return convertedData; + } + + private Data convertDatum(Data datum) throws ConversionException, FileSaveException { + ServiceReference fileSaverServiceReference = + this.bundleContext.getServiceReference(FileSaverService.class.getName()); + FileSaverService fileSaver = + (FileSaverService) this.bundleContext.getService(fileSaverServiceReference); + + Converter converter = + fileSaver.promptForConverter(datum, FileSaverService.ANY_FILE_EXTENSION); + + return converter.convert(datum); + } + + private String[] formConvertedFilePaths(Data[] convertedData) { + String[] convertedFilePaths = new String[convertedData.length]; + + for (int ii = 0; ii < convertedData.length; ii++) { + convertedFilePaths[ii] = ((File) convertedData[ii].getData()).getAbsolutePath(); + } + + return convertedFilePaths; + } +} \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2011-03-07 19:18:57 UTC (rev 1236) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2011-03-07 19:35:10 UTC (rev 1237) @@ -8,8 +8,8 @@ import java.io.File; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.cishell.framework.data.Data; @@ -29,11 +29,10 @@ * @author Team IVC */ public class DataGUIItem { - private String brandPluginID; //images for the defined types - private Image matrixIcon; +// private Image matrixIcon; private Image treeIcon; private Image networkIcon; private Image unknownIcon; @@ -46,9 +45,8 @@ private Image modelIcon; private Image rIcon; - private Map typeToImageMapping; - - private List children; + private Map<String, Image> typeToImage = new HashMap<String, Image>(); + private Collection<DataGUIItem> children = new ArrayList<DataGUIItem>(); private Data data; private DataGUIItem parent; @@ -62,10 +60,9 @@ public DataGUIItem(Data data, DataGUIItem parent, String brandPluginID) { this.data = data; this.parent = parent; - children = new ArrayList(); this.brandPluginID = brandPluginID; - matrixIcon = getImage("matrix.png", this.brandPluginID); +// matrixIcon = getImage("matrix.png", this.brandPluginID); treeIcon = getImage("tree.png", this.brandPluginID); networkIcon = getImage("network.png", this.brandPluginID); unknownIcon = getImage("unknown.png", this.brandPluginID); @@ -78,7 +75,6 @@ modelIcon = getImage("model.jpg", this.brandPluginID); rIcon = getImage("r.png", this.brandPluginID); - typeToImageMapping = new HashMap(); registerImage(DataProperty.OTHER_TYPE, unknownIcon); /******************************************** @@ -127,7 +123,7 @@ * @param item the new child of this DataModelGUIItem */ public void addChild(DataGUIItem item) { - children.add(item); + this.children.add(item); } /** @@ -136,7 +132,7 @@ * @return an array of all of the children of this DataModelGUIItem */ public Object[] getChildren() { - return children.toArray(); + return this.children.toArray(); } /** @@ -146,7 +142,7 @@ * @param item the child of this DataModelGUIItem to remove */ public void removeChild(DataGUIItem item) { - children.remove(item); + this.children.remove(item); } /** @@ -154,43 +150,46 @@ * * @return the icon associated with this DataModel for display in IVC */ - public Image getIcon(){ - Image icon = (Image)typeToImageMapping.get(data.getMetadata().get(DataProperty.TYPE)); - if(icon == null) icon = unknownIcon; + public Image getIcon() { + Image icon = this.typeToImage.get(data.getMetadata().get(DataProperty.TYPE)); + + if (icon == null) { + icon = unknownIcon; + } + return icon; } - public void registerImage(String type, Image image){ - typeToImageMapping.put(type, image); + public void registerImage(String type, Image image) { + this.typeToImage.put(type, image); } - - - - public static Image getImage(String name, String brandPluginID){ - if(Platform.isRunning()) { - String imageLocation = File.separator + "icons" + File.separator + name; - ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin( - brandPluginID, - imageLocation); + + public static Image getImage(String name, String brandPluginID) { + if (Platform.isRunning()) { + String imageLocation = + String.format("%sicons%s%s", File.separator, File.separator, name); + ImageDescriptor imageDescriptor = + AbstractUIPlugin.imageDescriptorFromPlugin(brandPluginID, imageLocation); + if (imageDescriptor != null) { return imageDescriptor.createImage(); } else { - System.err.println("Could not find the icon " + - "'" + imageLocation + "'" + - "in" + - "'" + brandPluginID + "'." + - "Using the default image instead."); + String errorMessage = String.format( + "Could not find the icon '%s' in '%s'. Using the default image instead.", + imageLocation, + brandPluginID); + System.err.println(errorMessage); + return getDefaultImage(); } - } - else { - System.err.println("Could not obtain the image " + - "'" + name + "'" + - "in" + - "'" + brandPluginID + "'" + - ", since the platform was not running (?)." + - "Using the default image instead."); + } else { + String format = + "Could not obtain the image '%s' in '%s', since the platform was not " + + "running (?). Using the default image instead."; + String errorMessage = String.format(format, name, brandPluginID); + System.err.println(errorMessage); + return getDefaultImage(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-07 19:19:04
|
Revision: 1236 http://cishell.svn.sourceforge.net/cishell/?rev=1236&view=rev Author: pataphil Date: 2011-03-07 19:18:57 +0000 (Mon, 07 Mar 2011) Log Message: ----------- * Documentation. Modified Paths: -------------- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/ModelDataSynchronizer.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/AbstractDataModelArea.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelArea.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelAreaContainer.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/field/DataModelFieldContainer.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/group/DataModelGroup.java trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/gui/AbstractGUIDataModel.java Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/ModelDataSynchronizer.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/ModelDataSynchronizer.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/ModelDataSynchronizer.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -1,7 +1,8 @@ package org.cishell.utility.datastructure.datamodel; -/** - * +/** ModelDataSynchronizer<T> is an interface for synchronizing DataModelFields to their actual + * GUI widgets. For this reason, most or all implementations of this interface will be + * GUI-specific. */ public interface ModelDataSynchronizer<T> { public int updateListenerCode(); Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/AbstractDataModelArea.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/AbstractDataModelArea.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/AbstractDataModelArea.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -8,6 +8,8 @@ import org.cishell.utility.datastructure.datamodel.exception.UniqueNameException; import org.cishell.utility.datastructure.datamodel.field.DataModelField; +/** See AbstractGUIDataModel. + */ public abstract class AbstractDataModelArea< BaseGUIComponentType, GUIContainerComponentType extends BaseGUIComponentType> implements DataModelArea { Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelArea.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelArea.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelArea.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -7,8 +7,7 @@ import org.cishell.utility.datastructure.datamodel.field.DataModelField; import org.cishell.utility.datastructure.datamodel.field.DataModelFieldContainer; -/** - * DataModelArea corresponds to a physical area tied to a DataModel GUI. +/** DataModelArea corresponds to a physical area tied to a DataModel GUI. * DataModelAreas can contain other DataModelAreas, as well as DataModelFields. */ public interface DataModelArea extends DataModelAreaContainer, DataModelFieldContainer { Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelAreaContainer.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelAreaContainer.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/area/DataModelAreaContainer.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -5,7 +5,10 @@ import org.cishell.utility.datastructure.datamodel.exception.ModelStructureException; import org.cishell.utility.datastructure.datamodel.exception.UniqueNameException; -// TODO: addToContainer type stuff +/** A DataModelAreaContainer is anything that contains DataModelAreas. For example, DataModel + * and DataModelArea itself both can contain (other) DataModelAreas. + * TODO: addToContainer type stuff. + */ public interface DataModelAreaContainer { public Collection<String> getAreaNames(); public Collection<DataModelArea> getAreas(); @@ -22,7 +25,7 @@ public void addArea(DataModelArea area) throws ClassCastException, ModelStructureException, UniqueNameException; - //TODO: why is this returning boolean? + // TODO: Why is this returning boolean? public boolean areaDisposed(String name); public boolean areaDisposed(DataModelArea area); } \ No newline at end of file Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/field/DataModelFieldContainer.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/field/DataModelFieldContainer.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/field/DataModelFieldContainer.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -4,6 +4,8 @@ import org.cishell.utility.datastructure.datamodel.exception.UniqueNameException; +/** A DataModelFieldContainer is anything that contains DataModelFields. + */ public interface DataModelFieldContainer { public Collection<String> getFieldNames(); public Collection<DataModelField<?>> getFields(); Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/group/DataModelGroup.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/group/DataModelGroup.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/group/DataModelGroup.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -6,8 +6,7 @@ import org.cishell.utility.datastructure.datamodel.field.DataModelField; import org.cishell.utility.datastructure.datamodel.field.DataModelFieldContainer; -/** - * Model groups are organizational structures for related DataModelFields. +/** Model groups are organizational structures for related DataModelFields. * They are not tied to the physical structure of a GUI. * Anything that wishes to retrieve data from a DataModel can ask for ModelGroups. */ Modified: trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/gui/AbstractGUIDataModel.java =================================================================== --- trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/gui/AbstractGUIDataModel.java 2011-03-07 11:33:16 UTC (rev 1235) +++ trunk/core/org.cishell.utility.datastructure/src/org/cishell/utility/datastructure/datamodel/gui/AbstractGUIDataModel.java 2011-03-07 19:18:57 UTC (rev 1236) @@ -12,8 +12,16 @@ import org.cishell.utility.datastructure.datamodel.group.BasicModelGroup; import org.cishell.utility.datastructure.datamodel.group.DataModelGroup; -/// TODO: Document this. -/// TODO: Figure out a way to generically express styles for both widgets and areas. +/** AbstractGUIDataModel is parameterized by BaseGUIComponentType and GUIContainerComponentType. + * It provides a default GUI-based implementation of DataModel that could be used in SWT, Swing, + * or any other Java GUI framework. + * BaseGUIComponentType should be the base type of the specific GUI framework widget (i.e. + * Control for SWT and Component for Swing. + * GUIContainerComponentType MUST extend BaseGUIComponentType, and in order for it to make any + * sense to this layer, it should be a GUI container type (i.e. Composite for SWT and + * Container for Swing). + * TODO: Figure out a way to generically express styles for both widgets and areas. + */ public abstract class AbstractGUIDataModel< BaseGUIComponentType, GUIContainerComponentType extends BaseGUIComponentType> implements DataModel { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-07 11:33:23
|
Revision: 1235 http://cishell.svn.sourceforge.net/cishell/?rev=1235&view=rev Author: pataphil Date: 2011-03-07 11:33:16 +0000 (Mon, 07 Mar 2011) Log Message: ----------- * Documentation. Modified Paths: -------------- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/FileSaveAs.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GridContainer.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ScrolledComponentFactory.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLClickedListener.java trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLMouseCursorListener.java Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -13,8 +13,28 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -/** - * This is meant to be subclassed. +/** See ScrolledComponentFactory for more information on the overall picture of the layer that this + * class is part of. + * A LITTLE BIT OF HISTORY: + ** When tasked with writing the Static Executable Wizard, I ran into a lot of difficulty with + ** gracefully handling the dynamic addition and deletion of child components to scrolling + ** components. (By scrolling components, I mean the components that actually do the scrolling; that + ** is, they SCROLL their child components.) The problem relates to how SWT grid layouts want to be + ** sized--I believe that SWT is largely implemented to only handle GUIs that've been setup by time + ** the user interacts with them. + ** In order to try to make this process more graceful, I came up with this and its + ** related classes. + * HOW TO USE IT: + ** This class only makes sense if T corresponds to a GUI component in some fashion (though it + ** doesn't literally have to be an SWT component). + ** Override getColumnCount() to specify the number of columns each row has. + ** Override createHeaderArea() and createFooterArea() to specify if there should be a header and + ** footer, respectively, that is OUTSIDE of the scrolling area. + ** Override createColumnLabelTexts() to specify the column labels. The default implementation of + ** this method uses the column index to generate labels. + ** It's recommended against overriding addComponent() and removeComponent(). + ** This class should be subclassed so specific column labels and any desired header/footer + ** can be generated. */ public class ExpandableComponentWidget<T> extends Composite { public static final int COLUMN_AREA_LAYOUT_VERTICAL_SPACING = 1; Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/FileSaveAs.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/FileSaveAs.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/FileSaveAs.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -7,6 +7,7 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; +// TODO: Find other places in the code base that do the same thing as this. public class FileSaveAs { public static final String DEFAULT_WINDOW_TITLE = "Save As"; public static final String CONFIRMATION_DIALOG_FORMAT = Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -11,6 +11,10 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; +/** These utilities are meant to handle a lot of common SWT operations that have little or no + * variation, such as the event dispatch loop (swtLoop()). + * Given the complex nature of UI programming, I'd consider this class to be deprecated. + */ public class GUIBuilderUtilities { public static Display createDisplay() { return new Display(); Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GridContainer.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GridContainer.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/GridContainer.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -7,6 +7,12 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Widget; +/** SWT composite components with grid layouts don't have a way of accessing a child component at + * a given cell (x, y). + * GridContainer is designed to remedy this problem in a general sense. However, in order for it to + * be able to reliably do so, all child components should be added to the parent composite via + * (objects of) this class. + */ public class GridContainer { private Composite actualParent; private int columnCount; Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/SWTUtilities.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -10,6 +10,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +/** TODO: The URL (http://-prefixed) parsing utilities in this class need to be updated to handle + * https as well. + */ public class SWTUtilities { public static final Color DEFAULT_BACKGROUND_COLOR = new Color(Display.getDefault(), 255, 255, 255); Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ScrolledComponentFactory.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ScrolledComponentFactory.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/ScrolledComponentFactory.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -2,7 +2,32 @@ import java.util.Map; +/** + * Used with ExpandableComponentWidget<T> as part of a SWT-based layer for managing scrolling + * components, whose contents are dynamic (as in, rows can be added and removed dynamically). + * The original inspiration for this layer is that SWT doesn't play very nicely with this type of + * dynamic scrolling component (i.e. the ones where content is changed real-time). + * The scrolling components involved can be thought of as having rows of content, where all rows + * have the same number of elements. (So, think of a grid--hence GridContainer.) + */ public interface ScrolledComponentFactory<T> { + /** Construct a child widget of type T to be added to componentWidget. + * NOTE: The term "widget" in the name "constructWidget" refers to whatever T happens to be, + * which is not necessarily a widget (but may wrap one or more actual widgets). + * Parameters: + * componentWidget -- the parent component of the T (or its wrapped components) + * that we're creating. + * scrolledAreaGrid -- tracks the actual SWT components so individual rows of them can easily + * be removed in one operation. + * style -- any SWT style flags that should be used when creating child components. Somewhat + * deprecated; perhaps should be removed. + * arguments -- if any implementation ever had custom arguments, this would be the channel + * to use. + * index -- the index of the constructed T within componentWidget, such that calling + * componentWidget.removeComponent(index) will remove this constructed T object. + * uniqueIndex -- has no functional purpose in this layer, but can be used for things like + * unique name creation. (NOTE: It may have functional purposes in users of this layer.) + */ public T constructWidget( ExpandableComponentWidget<T> componentWidget, GridContainer scrolledAreaGrid, @@ -11,5 +36,12 @@ int index, int uniqueIndex) throws WidgetConstructionException; + /* + * Whenever a T is added or removed, the set of T may need to be reindexed so future add/remove + * operations behave properly. + * Parameters: + * component -- the component to reindex. + * newIndex -- the new index to give to component. + */ public void reindexComponent(T component, int newIndex); } \ No newline at end of file Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLClickedListener.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLClickedListener.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLClickedListener.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -9,8 +9,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.program.Program; -/* - * Listens for clicks on urls and launches a browser. +/** Listens for clicks on urls and launches a browser. */ public class URLClickedListener extends MouseAdapter { private Map<Integer, String> offsetsToURLs = new HashMap<Integer, String>(); Modified: trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLMouseCursorListener.java =================================================================== --- trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLMouseCursorListener.java 2011-03-04 16:27:45 UTC (rev 1234) +++ trunk/core/org.cishell.utility.swt/src/org/cishell/utility/swt/URLMouseCursorListener.java 2011-03-07 11:33:16 UTC (rev 1235) @@ -11,8 +11,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; -/* - * Monitors the mouse and changes the cursor when it is over a URL. +/** Monitors the mouse and changes the cursor when it is over a URL. */ public class URLMouseCursorListener implements MouseMoveListener { private Map<Integer, String> offsetsToURLs = new HashMap<Integer, String>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-04 16:27:51
|
Revision: 1234 http://cishell.svn.sourceforge.net/cishell/?rev=1234&view=rev Author: pataphil Date: 2011-03-04 16:27:45 +0000 (Fri, 04 Mar 2011) Log Message: ----------- * Very minor log message printing cleanup. * Not reviewed (but doesn't need to be). Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2011-03-02 21:54:21 UTC (rev 1233) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2011-03-04 16:27:45 UTC (rev 1234) @@ -324,9 +324,12 @@ try { data[i] = converters[i][0].convert(data[i]); } catch (ConversionException e) { - log(LogService.LOG_ERROR, - "Error: Unable to convert data for use by the " - + "algorithm:\n " + e.getMessage(), e); + String logMessage = String.format( + "Error: Unable to convert data for use by the algorithm:%n %s", + e.getMessage()); + log(LogService.LOG_ERROR, logMessage, e); + e.printStackTrace(); + return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-02 21:54:28
|
Revision: 1233 http://cishell.svn.sourceforge.net/cishell/?rev=1233&view=rev Author: pataphil Date: 2011-03-02 21:54:21 +0000 (Wed, 02 Mar 2011) Log Message: ----------- * Fixed a bug when trying to parse out a file extension from a file name. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 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 2011-03-01 20:14:29 UTC (rev 1232) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2011-03-02 21:54:21 UTC (rev 1233) @@ -12,7 +12,6 @@ import org.osgi.service.log.LogService; public class Save implements Algorithm { - public static final String ANY_FILE_EXTENSION = "file-ext:*"; public static final String SAVE_DIALOG_TITLE = "Save"; private Data data; @@ -30,7 +29,7 @@ } public Data[] execute() throws AlgorithmExecutionException { - tryToSave(this.data, ANY_FILE_EXTENSION); + tryToSave(this.data, FileSaverService.ANY_FILE_EXTENSION); return null; } @@ -67,7 +66,8 @@ String logMessage = String.format( "Error occurred while converting data to saved format:\n %s", e.getMessage()); this.logger.log(LogService.LOG_ERROR, logMessage, e); - throw new AlgorithmExecutionException(e.getMessage(), e); +// throw new AlgorithmExecutionException(e.getMessage(), e); + throw new RuntimeException(e.getMessage(), e); } } } \ No newline at end of file Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java 2011-03-01 20:14:29 UTC (rev 1232) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java 2011-03-02 21:54:21 UTC (rev 1233) @@ -1,13 +1,32 @@ package org.cishell.app.service.filesaver; import java.io.File; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.Dictionary; +import java.util.HashSet; import org.cishell.framework.data.Data; +import org.cishell.framework.data.DataProperty; import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; public abstract class AbstractFileSaverService implements FileSaverService { + public static final Collection<Character> INVALID_FILENAME_CHARACTERS = + Collections.unmodifiableSet(new HashSet<Character>(Arrays.asList( + new Character('\\'), + new Character('/'), + new Character(':'), + new Character('*'), + new Character('?'), + new Character('"'), + new Character('<'), + new Character('>'), + new Character('|'), + new Character('%')))); + public static final char FILENAME_CHARACTER_REPLACEMENT = '#'; + private Collection<FileSaveListener> listeners; public void registerListener(FileSaveListener listener) { @@ -23,11 +42,17 @@ } public File promptForTargetFile(Data datum) throws FileSaveException { - return promptForTargetFile((File) datum.getData()); + Object dataObject = datum.getData(); + + if (dataObject instanceof File) { + return promptForTargetFile((File) datum.getData()); + } else { + return promptForTargetFile(suggestFileName(datum)); + } } public File promptForTargetFile(File outputFile) throws FileSaveException { - return promptForTargetFile(outputFile.getAbsolutePath()); // TODO getName? + return promptForTargetFile(outputFile.getName()); } public File save(Data sourceDatum) throws FileSaveException { @@ -77,4 +102,36 @@ throw new FileSaveException(e.getMessage(), e); } } + + public String suggestFileName(Data datum) { + return replaceInvalidFilenameCharacters(getLabel(datum)); + } + + private static String getLabel(Data datum) { + Dictionary<String, Object> metadata = datum.getMetadata(); + Object labelObject = metadata.get(DataProperty.LABEL); + + if (labelObject != null) { + return labelObject.toString(); + } else { + Object shortLabelObject = metadata.get(DataProperty.SHORT_LABEL); + + if (shortLabelObject != null) { + return shortLabelObject.toString(); + } else { + return datum.toString(); + } + } + } + + private static String replaceInvalidFilenameCharacters(String fileName) { + String cleanedFilename = fileName; + + for (Character invalidCharacter : INVALID_FILENAME_CHARACTERS) { + cleanedFilename = + cleanedFilename.replace(invalidCharacter, FILENAME_CHARACTER_REPLACEMENT); + } + + return cleanedFilename; + } } \ No newline at end of file Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java 2011-03-01 20:14:29 UTC (rev 1232) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java 2011-03-02 21:54:21 UTC (rev 1233) @@ -10,6 +10,8 @@ * Then FileSaverServiceImpl extends the abstract class. */ public interface FileSaverService { + public static final String ANY_FILE_EXTENSION = "file-ext:*"; + public void registerListener(FileSaveListener listener); public void unregisterListener(FileSaveListener listener); @@ -37,4 +39,6 @@ public Data save(Converter converter, Data sourceDatum) throws FileSaveException; public Data save( Converter converter, Data sourceDatum, File targetFile) throws FileSaveException; + + public String suggestFileName(Data datum); } \ No newline at end of file Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-03-01 20:14:29 UTC (rev 1232) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-03-02 21:54:21 UTC (rev 1233) @@ -28,7 +28,7 @@ } public File open(String fileName) { - String fileExtension = getFileExtension(fileName).substring(1); + String fileExtension = getFileExtension(fileName); return open(fileName, fileExtension); } @@ -95,7 +95,7 @@ int periodPosition = filePath.lastIndexOf("."); if ((periodPosition != -1) && ((periodPosition + 1) < filePath.length())) { - return filePath.substring(periodPosition); + return filePath.substring(periodPosition + 1); } else { return ""; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-01 20:14:36
|
Revision: 1232 http://cishell.svn.sourceforge.net/cishell/?rev=1232&view=rev Author: pataphil Date: 2011-03-01 20:14:29 +0000 (Tue, 01 Mar 2011) Log Message: ----------- * Cleaned up ZipUtilities. * Reviewed by Joseph. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ZipUtilities.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/ZipUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ZipUtilities.java 2011-03-01 20:10:28 UTC (rev 1231) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/ZipUtilities.java 2011-03-01 20:14:29 UTC (rev 1232) @@ -17,6 +17,9 @@ import java.util.zip.ZipOutputStream; public class ZipUtilities { + /* 2048, as gotten from: + * http://java.sun.com/developer/technicalArticles/Programming/compression/ + */ static final int BUFFER_SIZE = 2048; public static void zipFiles(Collection<File> files, ZipOutputStream zipOut) @@ -29,7 +32,14 @@ zipOut.close(); } catch (IOException e) { throw new ZipIOException(e.getMessage(), e); + } finally { + try { + zipOut.close(); + } catch (IOException e) { + throw new ZipIOException(e.getMessage(), e); + } } + } public static void zipFiles(Collection<File> files, File targetZipFile) @@ -54,6 +64,12 @@ zipOut.close(); } catch (IOException e) { throw new ZipIOException(e.getMessage(), e); + } finally { + try { + zipOut.close(); + } catch (IOException e) { + throw new ZipIOException(e.getMessage(), e); + } } } @@ -69,6 +85,10 @@ } } + /* Again, refer to: + * http://java.sun.com/developer/technicalArticles/Programming/compression/ + * for a reference on where this solution came from. + */ public static void writeFileToZipFile(File file, String zippedName, ZipOutputStream zipOut) throws ZipIOException { try { @@ -98,10 +118,17 @@ BufferedInputStream reader = new BufferedInputStream(zipFile.getInputStream(entry)); String fileName = new File(entry.getName()).getName(); File outputFile = - FileUtilities.createTemporaryFileInDefaultTemporaryDirectory(fileName, ""); + FileUtilities.createTemporaryFileInDefaultTemporaryDirectory(fileName, "tmp"); BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(outputFile), BUFFER_SIZE); + /* TODO Could we have: + * writeFileToZipFile(BufferedInputStream in, String zippedName, ZipOutputStream zipOut) + * and then have both: + * writeFileToZipFile(File file, String zippedName, ZipOutputStream zipOut) + * and this method use that as a common utility? + * (Maybe eventually, if someone wants to do this.) + */ byte readBytes[] = new byte[BUFFER_SIZE]; int readByteCount; @@ -142,27 +169,4 @@ return CollectionUtilities.collectionEnumerationElements( entries, new ArrayList<ZipEntry>()); } - - public static void main(String[] args) { - String filePath = - "C:\\Documents and Settings\\pataphil\\Desktop\\org.cishell.utility.swt.zip"; - - try { - ZipFile zipFile = new ZipFile(filePath); - Map<String, ZipEntry> entriesByName = mapFileNamesToEntries(zipFile, false); - - int count = 0; - for (String key : entriesByName.keySet()) { - System.err.println(key + ": " + entriesByName.get(key)); - count++; - - if (count == 2) { - readFileFromZipFile(entriesByName.get(key), zipFile); - } - } - } catch (IOException e) { - System.err.println("Exception: " + e.getMessage()); - e.printStackTrace(); - } - } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-01 20:10:37
|
Revision: 1231 http://cishell.svn.sourceforge.net/cishell/?rev=1231&view=rev Author: pataphil Date: 2011-03-01 20:10:28 +0000 (Tue, 01 Mar 2011) Log Message: ----------- * Implemented the FileLoaderService and the FileSaverService. * Reviewed by Joseph. Modified Paths: -------------- trunk/core/org.cishell.framework/META-INF/MANIFEST.MF trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoadException.java trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoaderService.java trunk/core/org.cishell.reference/META-INF/MANIFEST.MF trunk/core/org.cishell.reference/OSGI-INF/fileloader.properties trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileFormatSelector.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileLoaderServiceImpl.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileSelectorRunnable.java Added Paths: ----------- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveException.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveListener.java trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java trunk/core/org.cishell.reference/OSGI-INF/filesaver.properties trunk/core/org.cishell.reference/OSGI-INF/filesaver.xml trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/DataFormatChooser.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/persistence/ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/persistence/AbstractDialog.java Removed Paths: ------------- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/AbstractDialog.java Modified: trunk/core/org.cishell.framework/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2011-03-01 20:10:28 UTC (rev 1231) @@ -11,6 +11,7 @@ org.osgi.service.prefs Export-Package: org.cishell.app.service.datamanager;version="1.0.0", org.cishell.app.service.fileloader, + org.cishell.app.service.filesaver, org.cishell.app.service.scheduler;version="1.0.0", org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoadException.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoadException.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoadException.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -14,8 +14,4 @@ public FileLoadException(String message) { super(message); } - - public FileLoadException() { - this("Algorithm canceled by user."); - } } Modified: trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoaderService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoaderService.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/fileloader/FileLoaderService.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -13,11 +13,15 @@ public void registerListener(FileLoadListener listener); public void unregisterListener(FileLoadListener listener); + /* TODO make abstract default class, template method pattern, blah blah */ + public File[] getFilesToLoadFromUser( + boolean selectSingleFile, String[] filterExtensions) throws FileLoadException; public Data[] loadFilesFromUserSelection( BundleContext bundleContext, CIShellContext ciShellContext, LogService logger, - ProgressMonitor progressMonitor) throws FileLoadException; + ProgressMonitor progressMonitor, + boolean selectSingleFile) throws FileLoadException; public Data[] loadFiles( BundleContext bundleContext, CIShellContext ciShellContext, Added: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java (rev 0) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/AbstractFileSaverService.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,80 @@ +package org.cishell.app.service.filesaver; + +import java.io.File; +import java.util.Collection; + +import org.cishell.framework.data.Data; +import org.cishell.service.conversion.ConversionException; +import org.cishell.service.conversion.Converter; + +public abstract class AbstractFileSaverService implements FileSaverService { + private Collection<FileSaveListener> listeners; + + public void registerListener(FileSaveListener listener) { + this.listeners.add(listener); + } + + public void unregisterListener(FileSaveListener listener) { + this.listeners.remove(listener); + } + + public File promptForTargetFile() throws FileSaveException { + return promptForTargetFile(""); + } + + public File promptForTargetFile(Data datum) throws FileSaveException { + return promptForTargetFile((File) datum.getData()); + } + + public File promptForTargetFile(File outputFile) throws FileSaveException { + return promptForTargetFile(outputFile.getAbsolutePath()); // TODO getName? + } + + public File save(Data sourceDatum) throws FileSaveException { + return save((File) sourceDatum.getData()); + } + + public File save(File sourceFile) throws FileSaveException { + File targetFile = promptForTargetFile(sourceFile); + saveTo(sourceFile, targetFile); + + return targetFile; + } + + public Data save(Data sourceDatum, String targetMimeType) + throws FileSaveException { + Converter converter = promptForConverter(sourceDatum, targetMimeType); + + if (converter != null) { + return save(converter, sourceDatum); + } else { + // TODO: CanceledException? + return null; + } + } + + // TODO: What to actually return here? Maybe Pair<Data, File> (LOL)? + public Data save(Converter converter, Data sourceDatum) + throws FileSaveException { + File targetFile = promptForTargetFile(sourceDatum); + + if (targetFile != null) { + return save(converter, sourceDatum, targetFile); + } else { + // TODO: CanceledException? + return null; + } + } + + public Data save( + Converter converter, Data sourceDatum, File targetFile) throws FileSaveException { + try { + Data convertedDatum = converter.convert(sourceDatum); + saveTo((File) convertedDatum.getData(), targetFile); + + return convertedDatum; + } catch (ConversionException e) { + throw new FileSaveException(e.getMessage(), e); + } + } +} \ No newline at end of file Added: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveException.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveException.java (rev 0) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveException.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,17 @@ +package org.cishell.app.service.filesaver; + +public class FileSaveException extends Exception { + private static final long serialVersionUID = 1L; + + public FileSaveException(String message, Throwable exception) { + super(message, exception); + } + + public FileSaveException(Throwable exception) { + super(exception); + } + + public FileSaveException(String message) { + super(message); + } +} Added: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveListener.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveListener.java (rev 0) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaveListener.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,7 @@ +package org.cishell.app.service.filesaver; + +import java.io.File; + +public interface FileSaveListener { + void fileSaved(File file); +} \ No newline at end of file Added: trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java (rev 0) +++ trunk/core/org.cishell.framework/src/org/cishell/app/service/filesaver/FileSaverService.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,40 @@ +package org.cishell.app.service.filesaver; + +import java.io.File; + +import org.cishell.framework.data.Data; +import org.cishell.service.conversion.Converter; + +/* TODO Push down methods with an obvious implementation in terms of the "atomic" methods + * (choose converter, choose file, perform save) into an abstract class that implements this. + * Then FileSaverServiceImpl extends the abstract class. + */ +public interface FileSaverService { + public void registerListener(FileSaveListener listener); + public void unregisterListener(FileSaveListener listener); + + public Converter promptForConverter(final Data outDatum, String targetMimeType) + throws FileSaveException; + + public File promptForTargetFile() throws FileSaveException; + public File promptForTargetFile(Data datum) throws FileSaveException; + public File promptForTargetFile(File outputFile) throws FileSaveException; + public File promptForTargetFile(String fileName) throws FileSaveException; + + /* TODO I'm seriously tempted to recommend that all methods beyond this point be called + * "save" or "saveToFile" or something, and just have a bit of very concise Javadoc that + * explains what may be prompted for? Alternatively, ask another dev about doing the null + * arguments idea. + */ + // TODO (NEW): Just Javadoc these really well? + public File save(Data sourceDatum) throws FileSaveException; + public File save(File sourceFile) throws FileSaveException; + public void saveTo(File sourceFile, File targetFile) throws FileSaveException; + + // TODO: What to actually return here? the File object for the one on disk + /* TODO sourceDatum always first, targetType/File last */ + public Data save(Data sourceDatum, String targetMimeType) throws FileSaveException; + public Data save(Converter converter, Data sourceDatum) throws FileSaveException; + public Data save( + Converter converter, Data sourceDatum, File targetFile) throws FileSaveException; +} \ No newline at end of file Modified: trunk/core/org.cishell.reference/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.reference/META-INF/MANIFEST.MF 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/META-INF/MANIFEST.MF 2011-03-01 20:10:28 UTC (rev 1231) @@ -2,8 +2,11 @@ Bundle-Name: CIShell Reference Service Implementations Bundle-SymbolicName: org.cishell.reference Bundle-Version: 1.0.0 -Import-Package: org.cishell.app.service.datamanager, +Import-Package: com.google.common.base, + com.google.common.collect, + org.cishell.app.service.datamanager, org.cishell.app.service.fileloader, + org.cishell.app.service.filesaver, org.cishell.app.service.scheduler;version="1.0.0", org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", @@ -13,12 +16,15 @@ org.cishell.service.guibuilder;version="1.0.0", org.osgi.framework, org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", org.osgi.service.log, org.osgi.service.metatype;version="1.1.0", org.osgi.service.prefs Export-Package: org.cishell.reference.app.service.algorithminvocation, org.cishell.reference.app.service.datamanager, org.cishell.reference.app.service.fileloader, + org.cishell.reference.app.service.filesaver, + org.cishell.reference.app.service.persistence, org.cishell.reference.app.service.scheduler, org.cishell.reference.service.conversion, org.cishell.reference.service.metatype @@ -27,6 +33,6 @@ org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.update.ui -Service-Component: OSGI-INF/fileloader.xml +Service-Component: OSGI-INF/fileloader.xml, OSGI-INF/filesaver.xml Bundle-RequiredExecutionEnvironment: J2SE-1.5 X-AutoStart: true Modified: trunk/core/org.cishell.reference/OSGI-INF/fileloader.properties =================================================================== --- trunk/core/org.cishell.reference/OSGI-INF/fileloader.properties 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/OSGI-INF/fileloader.properties 2011-03-01 20:10:28 UTC (rev 1231) @@ -4,7 +4,7 @@ #description=This allows users to select files from the file system and load them to Data Model window. #in_data=null #out_data=java.lang.Object -service.pid=org.cishell.reference.app.service.fileloader.FileLoadServiceImpl +service.pid=org.cishell.reference.app.service.fileloader.FileLoaderServiceImpl remoteable=true prefs_published=local receive_prefs=true Added: trunk/core/org.cishell.reference/OSGI-INF/filesaver.properties =================================================================== --- trunk/core/org.cishell.reference/OSGI-INF/filesaver.properties (rev 0) +++ trunk/core/org.cishell.reference/OSGI-INF/filesaver.properties 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,11 @@ +#menu_path=File/start +#label=Load... +#shortcut=ctrl+alt+o +#description=This allows users to select files from the file system and load them to Data Model window. +#in_data=null +#out_data=java.lang.Object +service.pid=org.cishell.reference.app.service.filesaver.FileSaverServiceImpl +remoteable=true +prefs_published=local +receive_prefs=true +#documentation_url=http://wiki.slis.indiana.edu:8080/display/ALGDOC/Data+Formats \ No newline at end of file Added: trunk/core/org.cishell.reference/OSGI-INF/filesaver.xml =================================================================== --- trunk/core/org.cishell.reference/OSGI-INF/filesaver.xml (rev 0) +++ trunk/core/org.cishell.reference/OSGI-INF/filesaver.xml 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.reference.app.service.filesaver.FileSaverServiceImpl.component" immediate="true"> + <implementation class="org.cishell.reference.app.service.filesaver.FileSaverServiceImpl"/> + <reference name="DCS" interface="org.cishell.service.conversion.DataConversionService"/> + <reference name="GBS" interface="org.cishell.service.guibuilder.GUIBuilderService"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + + <service> + <provide interface="org.cishell.app.service.filesaver.FileSaverService"/> + </service> +</component> \ No newline at end of file Deleted: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/AbstractDialog.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/AbstractDialog.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/AbstractDialog.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -1,490 +0,0 @@ -/* - * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research - * and Education in Information Visualization (http://iv.slis.indiana.edu/). - * - * Created on Feb 22, 2005 at Indiana University. - */ -package org.cishell.reference.app.service.fileloader; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - - -/** - * This class provides a DialogBox structure that can be extended to create Dialogs for CIShell. - * This framework will enforce consistency in the look and feel of Dialogs in CIShell by providing a - * standard layout of description, content, and buttons[, along with a choice of icon images - * defined as constants in this class]. An optional details section allows the Dialog designer - * to provide additional information when the details button is pressed. - * - * @author Team IVC - */ -public abstract class AbstractDialog extends Dialog { - private static final int DETAILS_HEIGHT = 75; - - public static Image INFORMATION; - public static Image WARNING; - public static Image ERROR; - public static Image QUESTION; - public static Image WORKING; - - static { - Runnable runner = new Runnable() { - public void run() { - INFORMATION = Display.getDefault().getSystemImage(SWT.ICON_INFORMATION); - WARNING = Display.getDefault().getSystemImage(SWT.ICON_WARNING); - ERROR = Display.getDefault().getSystemImage(SWT.ICON_ERROR); - QUESTION = Display.getDefault().getSystemImage(SWT.ICON_QUESTION); - WORKING = Display.getDefault().getSystemImage(SWT.ICON_WORKING); - }}; - - if (Display.getDefault().getThread() == Thread.currentThread()) { - runner.run(); - } else { - Display.getDefault().asyncExec(runner); - } - } - - - private String description = ""; - private String detailsString = ""; - private Text detailsText; - private Shell shell; - private Image image; - private boolean success; - private Composite header; - private Composite content; - private Composite buttons; - private Shell parent; - - /** - * Creates a new AbstractDialog object. - * - * @param parent the parent Shell of this AbstractDialog - * @param title the title to put in the title bar of this AbstractDialog - * @param image the Image to display to the left of the description specified - * for this AbstractDialog. This will usually be one of: - * <ul> - * <li>AbstractDialog.WARNING</li> - * <li>AbstractDialog.INFORMATION</li> - * <li>AbstractDialog.ERROR</li> - * <li>AbstractDialog.WORKING</li> - * <li>AbstractDialog.QUESTION</li> - * </ul> - */ - public AbstractDialog(Shell parent, String title, Image image) { - super(parent, 0); - setText(title); - this.image = image; - this.parent = parent; - init(); - } - - /** - * Closes this AbstractDialog. - * - * @param success true if the dialog was successful, false if it - * was cancelled by the user (or closed prematurely) - */ - public void close(boolean success){ - shell.dispose(); - this.success = success; - } - - /** - * Returns the shell used by this AbstractDialog - * - * @return the shell used by this AbstractDialog - */ - public Shell getShell(){ - return shell; - } - - /** - * Initializes this AbstractDialog. This consists of resetting all of the - * customizable components like the content area, details pane, buttons, - * and description label, and readying the dialog to be refilled with - * new content. - */ - public void init(){ - if(shell != null) - shell.dispose(); - - shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); - - if (parent != null) - shell.setImage(parent.getImage()); - - shell.setText(getText()); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - shell.setLayout(layout); - } - - /** - * Opens this AbstractDialog. - * - * @return true if this AbstractDialog was closed by clicking the 'x' in the upper right - * corner of the window, signifying a cancellation, false if the dialog is exited otherwise. - */ - public boolean open() { - if (shell.getDisplay().getThread() == Thread.currentThread()) { - doOpen(); - } else { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - doOpen(); - }}); - } - - Display display = getParent().getDisplay(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - return success; - } - - protected void doOpen() { - success = true; - - setupHeader(); - setupContent(); - setupButtons(); - - shell.pack(); - setLocation(); - shell.open(); - shell.addShellListener(new ShellAdapter(){ - public void shellClosed(ShellEvent e) { - success = false; - } - }); - } - - /* - * centers the dialog on its parents shell - */ - private void setLocation(){ - Point parentLocation = parent.getLocation(); - int parentWidth = parent.getSize().x; - int parentHeight = parent.getSize().y; - int shellWidth = shell.getSize().x; - int shellHeight = shell.getSize().y; - - int x = parentLocation.x + (parentWidth - shellWidth)/2; - int y = parentLocation.y + (parentHeight - shellHeight)/2; - shell.setLocation(x, y); - } - - /** - * Sets the Description of this AbstractDialog. This is the textField that is displayed in the - * top section of the Dialog window, giving information about the question that is being - * asked or the information that is being given. - * - * @param description the description for this AbstractDialog to use - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Sets the details textField of this AbstractDialog. This is the textField that is displayed in the lower - * section of the Dialog window when the user presses the "Details >>" button. If this String - * is null or the empty string, the details button will be disabled. - * - * @param details DOCUMENT ME! - */ - public void setDetails(String details) { - this.detailsString = details; - } - - /** - * Creates the Buttons to use in this AbstractDialog based on the given parent. These are - * the buttons that show up at the bottom of the dialog for user input, such as a - * "Yes/No" group or "Continue/Cancel" or something like that. This does not encompass all - * Buttons created in the dialog (such as those created in the content section), just those - * to display at the bottom of the dialog. - * - * @param parent the parent to be used to create the Buttons for this AbstractDialog - */ - public abstract void createDialogButtons(Composite parent); - - /** - * Creates the content section of this AbstractDialog based on the given parent. - * This section is where all of the "guts" of the AbstractDialog go, specifying the controls - * that are needed to interact with the user and provide whatever questions or information - * are needed. - * - * @param parent the parent to be used to create the Buttosn for this AbstractDialog - * - * @return the Composite that is created to display the content of this AbstractDialog - */ - public abstract Composite createContent(Composite parent); - - /* - * Sets up the header section of the dialog. This section contains the image for the - * type of dialog it is, as well as the description label - */ - private void setupHeader() { - header = new Composite(shell, SWT.NONE); - header.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - header.setLayout(layout); - - Label canvas = new Label(header, SWT.NONE); - if (image != null) { - canvas.setImage(image); - } - GridData canvasData = new GridData(); - canvasData.heightHint = image.getBounds().height; - canvas.setLayoutData(canvasData); - - Label desc = new Label(header, SWT.WRAP); - - if ((description != null) && !description.equals("")) { - desc.setText(description); - } - } - - /* - * sets up the content section of the dialog, this calls the abstract method to - * create the content that must be implemented by all subclasses - */ - private void setupContent() { - content = createContent(shell); - - if (content != null) { - content.setLayoutData(new GridData(GridData.FILL_BOTH)); - } - } - - /* - * sets up the button section in the bottom of the dialog. These buttons - * are created in the abstract method createDialogButtons(parent). In addition to - * any created buttons, a "Details >>" button is added to allow the user to see any - * details that are available in the current Dialog. - */ - private void setupButtons() { - buttons = new Composite(shell, SWT.NONE); - buttons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); - - //there are two sections, all the user stuff to the left, and - //then the details button on the far right - //User Buttons Section - createDialogButtons(buttons); - Control[] controls = buttons.getChildren(); - GridLayout buttonsLayout = new GridLayout(); - buttonsLayout.numColumns = controls.length + 1; - buttonsLayout.makeColumnsEqualWidth = true; - buttons.setLayout(buttonsLayout); - - //setup the grid data for each button for standard look - for (int i = 0; i < controls.length; i++) { - controls[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - //Details Button section - final Button details = new Button(buttons, SWT.PUSH); - details.setText("Details >>"); - details.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - details.addSelectionListener(new SelectionAdapter() { - public synchronized void widgetSelected(SelectionEvent e) { - GridData data = (GridData) detailsText.getLayoutData(); - - if (detailsText.getVisible()) { - detailsText.setText(""); - details.setText("Details >>"); - data.heightHint = 0; - data.grabExcessHorizontalSpace = false; - data.grabExcessVerticalSpace = false; - } else { - detailsText.setText(detailsString); - details.setText("Details <<"); - data.heightHint = DETAILS_HEIGHT; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - } - - detailsText.setLayoutData(data); - detailsText.setVisible(!detailsText.getVisible()); - - shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - shell.layout(); - } - }); - - setupDetails(); - details.setEnabled(detailsString != null && !detailsString.equals("")); - } - - /* - * creates the details textField box when the "Details >>" button is toggled - */ - private void setupDetails() { - detailsText = new Text(shell, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); - detailsText.setEditable(false); - detailsText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - - GridData data = new GridData(GridData.FILL_BOTH | - GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL); - data.widthHint = 400; - - detailsText.setLayoutData(data); - detailsText.setVisible(false); - } - - /** - * Open a standard error dialog with OK button - * - * @param parent the parent Shell of this dialog - * @param title the textField to display in the title bar of this dialog - * @param message the message to give in the dialog's body - * @param details the textField to put in the details pane to be visible when the - * "Details >>" button is pressed (can be null or empty, resulting - * in the "Details >>" button not being enabled) - * @return true if the dialog was exited by pressing the OK button, false - * if it was cancelled by pressing the 'x' in the title bar - */ - public static boolean openError(Shell parent, String title, String message, String details){ - return openOKDialog(parent, ERROR, title, message, details); - } - - /** - * Open a standard information dialog with OK button - * - * @param parent the parent Shell of this dialog - * @param title the textField to display in the title bar of this dialog - * @param message the message to give in the dialog's body - * @param details the textField to put in the details pane to be visible when the - * "Details >>" button is pressed (can be null or empty, resulting - * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false - * if it was cancelled by pressing the 'x' in the title bar - */ - public static boolean openInformation(Shell parent, String title, String message, String details){ - return openOKDialog(parent, INFORMATION, title, message, details); - } - - /** - * Open a standard warning dialog with OK button - * - * @param parent the parent Shell of this dialog - * @param title the textField to display in the title bar of this dialog - * @param message the message to give in the dialog's body - * @param details the textField to put in the details pane to be visible when the - * "Details >>" button is pressed (can be null or empty, resulting - * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false - * if it was cancelled by pressing the 'x' in the title bar - */ - public static boolean openWarning(Shell parent, String title, String message, String details){ - return openOKDialog(parent, WARNING, title, message, details); - } - - /** - * Open a standard question dialog with Yes/No buttons - * - * @param parent the parent Shell of this dialog - * @param title the textField to display in the title bar of this dialog - * @param message the message to give in the dialog's body - * @param details the textField to put in the details pane to be visible when the - * "Details >>" button is pressed (can be null or empty, resulting - * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false - * if it was cancelled by pressing the 'x' in the title bar or pressing the - * No button - */ - public static boolean openQuestion(Shell parent, String title, String message, String details){ - return openConfirmDenyDialog(parent, QUESTION, title, message, details, "Yes", "No"); - } - - /** - * Open a standard confirmation dialog with OK/Cancel buttons - * - * @param parent the parent Shell of this dialog - * @param title the textField to display in the title bar of this dialog - * @param message the message to give in the dialog's body - * @param details the textField to put in the details pane to be visible when the - * "Details >>" button is pressed (can be null or empty, resulting - * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false - * if it was cancelled by pressing the 'x' in the title bar or pressing - * the Cancel button - */ - public static boolean openConfirm(Shell parent, String title, String message, String details){ - return openConfirmDenyDialog(parent, QUESTION, title, message, details, "OK", "Cancel"); - } - - /* - * helper to create OK dialogs: error, warning, information - */ - private static boolean openOKDialog(Shell parent, Image image, String title, String message, String details){ - AbstractDialog okDialog = new AbstractDialog(parent, title, image){ - public void createDialogButtons(Composite parent) { - Button ok = new Button(parent, SWT.PUSH); - ok.setText("OK"); - ok.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - close(true); - } - }); - } - - public Composite createContent(Composite parent) { - return null; - } - }; - okDialog.setDescription(message); - okDialog.setDetails(details); - return okDialog.open(); - } - - /* - * helper to create confirm/deny dialogs: question, confirmation - */ - private static boolean openConfirmDenyDialog(Shell parent, Image image, String title, String message, String details, final String confirmLabel, final String denyLabel){ - AbstractDialog dialog = new AbstractDialog(parent, title, image){ - public void createDialogButtons(Composite parent) { - Button confirm = new Button(parent, SWT.PUSH); - if(confirmLabel != null) - confirm.setText(confirmLabel); - confirm.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - close(true); - } - }); - Button deny = new Button(parent, SWT.PUSH); - if(denyLabel != null) - deny.setText(denyLabel); - deny.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - close(false); - } - }); - } - - public Composite createContent(Composite parent) { - return null; - } - }; - dialog.setDescription(message); - dialog.setDetails(details); - return dialog.open(); - } -} Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileFormatSelector.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileFormatSelector.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileFormatSelector.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -3,6 +3,7 @@ import java.io.File; import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.reference.app.service.persistence.AbstractDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileLoaderServiceImpl.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileLoaderServiceImpl.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileLoaderServiceImpl.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -43,18 +43,25 @@ } } + public File[] getFilesToLoadFromUser(boolean selectSingleFile, String[] filterExtensions) + throws FileLoadException { + IWorkbenchWindow window = getFirstWorkbenchWindow(); + Display display = PlatformUI.getWorkbench().getDisplay(); + + return getFilesToLoadFromUserInternal(window, display, selectSingleFile, filterExtensions); + } + public Data[] loadFilesFromUserSelection( BundleContext bundleContext, CIShellContext ciShellContext, LogService logger, - ProgressMonitor progressMonitor) throws FileLoadException { + ProgressMonitor progressMonitor, + boolean selectSingleFile) throws FileLoadException { if ("".equals(defaultLoadDirectory)) { defaultLoadDirectory = determineDefaultLoadDirectory(); } - IWorkbenchWindow window = getFirstWorkbenchWindow(); - Display display = PlatformUI.getWorkbench().getDisplay(); - File[] files = getFilesToLoadFromUser(window, display); + File[] files = getFilesToLoadFromUser(selectSingleFile, null); if (files != null) { return loadFiles(bundleContext, ciShellContext, logger, progressMonitor, files); @@ -255,8 +262,13 @@ } } - private File[] getFilesToLoadFromUser(IWorkbenchWindow window, Display display) { - FileSelectorRunnable fileSelector = new FileSelectorRunnable(window); + private File[] getFilesToLoadFromUserInternal( + IWorkbenchWindow window, + Display display, + boolean selectSingleFile, + String[] filterExtensions) { + FileSelectorRunnable fileSelector = + new FileSelectorRunnable(window, selectSingleFile, filterExtensions); if (Thread.currentThread() != display.getThread()) { display.syncExec(fileSelector); Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileSelectorRunnable.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileSelectorRunnable.java 2011-03-01 20:09:46 UTC (rev 1230) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/fileloader/FileSelectorRunnable.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -8,11 +8,15 @@ public final class FileSelectorRunnable implements Runnable { private IWorkbenchWindow window; - + private boolean selectSingleFile; + private String[] filterExtensions; private File[] files; - public FileSelectorRunnable(IWorkbenchWindow window) { + public FileSelectorRunnable( + IWorkbenchWindow window, boolean selectSingleFile, String[] filterExtensions) { this.window = window; + this.selectSingleFile = selectSingleFile; + this.filterExtensions = filterExtensions; } public File[] getFiles() { @@ -35,7 +39,6 @@ fileDialog.open(); String path = fileDialog.getFilterPath(); String[] fileNames = fileDialog.getFileNames(); - // TODO: Ask Angela about the order here, i.e. should they be sorted alphabetically? if ((fileNames == null) || (fileNames.length == 0)) { return new File[0]; @@ -54,10 +57,24 @@ private FileDialog createFileDialog() { File currentDirectory = new File(FileLoaderServiceImpl.defaultLoadDirectory); String absolutePath = currentDirectory.getAbsolutePath(); - FileDialog fileDialog = new FileDialog(this.window.getShell(), SWT.OPEN | SWT.MULTI); + FileDialog fileDialog = + new FileDialog(this.window.getShell(), SWT.OPEN | determineSWTFileSelectFlag()); fileDialog.setFilterPath(absolutePath); + + if ((this.filterExtensions != null) && (this.filterExtensions.length > 0)) { + fileDialog.setFilterExtensions(this.filterExtensions); + } + fileDialog.setText("Select Files"); return fileDialog; } + + private int determineSWTFileSelectFlag() { + if (this.selectSingleFile) { + return SWT.SINGLE; + } else { + return SWT.MULTI; + } + } } \ No newline at end of file Added: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/DataFormatChooser.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/DataFormatChooser.java (rev 0) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/DataFormatChooser.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,338 @@ +package org.cishell.reference.app.service.filesaver; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.framework.data.Data; +import org.cishell.reference.app.service.persistence.AbstractDialog; +import org.cishell.service.conversion.Converter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.osgi.framework.ServiceReference; + +/* TODO Kill dead methods */ +public class DataFormatChooser extends AbstractDialog implements AlgorithmProperty { +// public static final Image QUESTION_ICON = +// Display.getCurrent().getSystemImage(SWT.ICON_QUESTION); + + protected Data data; + protected Converter[] converters; + private List converterListComponent; + private StyledText detailPane; + private Converter chosenConverter; + + public DataFormatChooser(Data data, Shell parent, Converter[] converters, String title) { + super(parent, title, AbstractDialog.QUESTION); + this.data = data; + this.converters = alphabetizeConverters(filterConverters(converters)); + } + + public Converter getChosenConverter() { + return this.chosenConverter; + } + + private Composite initializeGUI(Composite parent) { + Composite content = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + content.setLayout(layout); + + Group converterGroup = new Group(content, SWT.NONE); + converterGroup.setText("Pick the Output Data Type"); + converterGroup.setLayout(new FillLayout()); + GridData persisterData = new GridData(GridData.FILL_BOTH); + persisterData.widthHint = 200; + converterGroup.setLayoutData(persisterData); + + converterListComponent = + new List(converterGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE); + initializeConverterListComponent(); + converterListComponent.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent mouseEvent) { + List list = (List)mouseEvent.getSource(); + int selection = list.getSelectionIndex(); + + if (selection != -1) { + selectionMade(selection); + } + } + }); + converterListComponent.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent selectionEvent) { + List list = (List)selectionEvent.getSource(); + int selection = list.getSelectionIndex(); + + if (selection != -1) { + updateDetailPane(converters[selection]); + } + } + }); + + Group detailsGroup = new Group(content, SWT.NONE); + detailsGroup.setText("Details"); + detailsGroup.setLayout(new FillLayout()); + GridData detailsData = new GridData(GridData.FILL_BOTH); + detailsData.widthHint = 200; + detailsGroup.setLayoutData(detailsData); + + detailPane = initializeDetailPane(detailsGroup); + + // Select the first item by default. + converterListComponent.setSelection(0); + updateDetailPane(converters[0]); + + return content; + } + + /** + * Initialize the Listbox of Persisters using the stored Persister array + */ + private void initializeConverterListComponent() { + for (int ii = 0; ii < converters.length; ii++) { + if (converters[ii] != null) { + Dictionary converterProperties = converters[ii].getProperties(); + + // Get the name of the persister from the property map. + String outData = null; + + ServiceReference[] serviceReferences = converters[ii].getConverterChain(); + + if ((serviceReferences != null) && (serviceReferences.length > 0)) { + outData = (String)serviceReferences[serviceReferences.length - 1].getProperty( + AlgorithmProperty.LABEL); + } + + if (outData == null) { + outData = (String)converterProperties.get(AlgorithmProperty.LABEL); + } + + /* + * If someone was sloppy enough to not provide a name, then use the name of the + * class instead. + */ + if ((outData == null) || (outData.length() == 0)) { + outData = converters[ii].getClass().getName(); + } + + converterListComponent.add(outData); + } + } + } + + private StyledText initializeDetailPane(Group detailsGroup) { + StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL); + detailPane.setEditable(false); + detailPane.getCaret().setVisible(false); + + return detailPane; + } + + private void updateDetailPane(Converter converter) { + Dictionary converterProperties = converter.getProperties(); + Enumeration converterPropertiesKeys = converterProperties.keys(); + + detailPane.setText(""); + + while (converterPropertiesKeys.hasMoreElements()) { + Object key = converterPropertiesKeys.nextElement(); + Object value = converterProperties.get(key); + + StyleRange styleRange = new StyleRange(); + styleRange.start = detailPane.getText().length(); + detailPane.append(key + ":\n"); + styleRange.length = key.toString().length() + 1; + styleRange.fontStyle = SWT.BOLD; + detailPane.setStyleRange(styleRange); + + detailPane.append(value + "\n"); + } + } + + private Converter[] filterConverters(Converter[] allConverters) { + Map lastInDataToConverter = new HashMap(); + + for (int ii = 0; ii < allConverters.length; ii++) { + Converter converter = allConverters[ii]; + String lastInputData = getLastConverterInData(converter); + + if (lastInDataToConverter.containsKey(lastInputData)) { + Converter alreadyStoredConverter = + (Converter)lastInDataToConverter.get(lastInputData); + Converter chosenConverter = + returnPreferredConverter(converter, alreadyStoredConverter); + lastInDataToConverter.put(lastInputData, chosenConverter); + } else { + lastInDataToConverter.put(lastInputData, converter); + } + } + + return (Converter[]) lastInDataToConverter.values().toArray(new Converter[0]); + } + + private String getLastConverterInData(Converter converter) { + ServiceReference[] convChain = converter.getConverterChain(); + + if (convChain.length >= 1) { + ServiceReference lastConverter = convChain[convChain.length - 1]; + String lastInData = (String) lastConverter.getProperty("in_data"); + + return lastInData; + } else { + return ""; + } + } + + private Converter returnPreferredConverter(Converter converter1, Converter converter2) { + Dictionary converter1Properties = converter1.getProperties(); + String converter1Lossiness = (String)converter1Properties.get(CONVERSION); + int converter1Quality = determineQuality(converter1Lossiness); + + Dictionary converter2Properties = converter2.getProperties(); + String converter2Lossiness = (String)converter2Properties.get(CONVERSION); + int converter2Quality = determineQuality(converter2Lossiness); + + if (converter1Quality > converter2Quality) { + return converter1; + } else if (converter2Quality > converter1Quality) { + return converter2; + } else { + // They are tied. Look at chosenConverter chain length. + + int converter1Length = converter1.getConverterChain().length; + int converter2Length = converter2.getConverterChain().length; + + if (converter1Length > converter2Length) { + return converter2; + } else if (converter2Length > converter1Length) { + return converter1; + } else { + /* + * Both have the same lossiness and same length. + * Arbitrary pick the first. + */ + return converter1; + } + } + } + + private int determineQuality(String lossiness) { + if (lossiness == LOSSY) { + return 0; + } else if (lossiness == null) { + return 1; + } else { + return 2; + } + } + + private Converter[] alphabetizeConverters(Converter[] converters) { + Arrays.sort(converters, new CompareAlphabetically()); + + return converters; + } + + protected void selectionMade(int selectedIndex) { + try { + getShell().setVisible(false); + this.chosenConverter = converters[selectedIndex]; +// final SaveAsController saver = new SaveAsController(getShell(), ciShellContext); + close(true); +// close(saver.save(chosenConverter, data)); + } catch (Exception exception) { + throw new RuntimeException(exception); + } + } + + public void createDialogButtons(Composite parent) { + Button select = new Button(parent, SWT.PUSH); + select.setText("Select"); + select.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent selectionEvent) { + int index = converterListComponent.getSelectionIndex(); + + if (index != -1) { + selectionMade(index); + } + } + } + ); + select.setFocus(); + + Button cancel = new Button(parent, SWT.NONE); + cancel.setText("Cancel"); + cancel.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent selectionEvent) { + close(false); + } + } + ); + } + + public Composite createContent(Composite parent) { + if (converters.length == 1) { + close(true); +// final SaveAsController saver = new SaveAsController((Shell) parent, ciShellContext); +// close(saver.save(converters[0], data)); + + return parent; + } else { + return initializeGUI(parent); + } + } + + private class CompareAlphabetically implements Comparator { + public int compare(Object object1, Object object2) { + if ((object1 instanceof Converter) && (object2 instanceof Converter)) { + Converter converter1 = (Converter)object1; + String converter1Label = getLabel(converter1); + + Converter converter2 = (Converter)object2; + String converter2Label = getLabel(converter2); + + if ((converter1Label != null) && (converter2Label != null)) { + return converter1Label.compareTo(converter2Label); + } else if (converter1Label == null) { + return 1; + } else if (converter2Label == null) { + return -1; + } else { + return 0; + } + } else { + throw new IllegalArgumentException("Can only compare Converters"); + } + } + + private String getLabel(Converter converter) { + String label = ""; + ServiceReference[] serviceReferences = converter.getConverterChain(); + + if ((serviceReferences != null) && (serviceReferences.length > 0)) { + label = (String)serviceReferences[serviceReferences.length - 1].getProperty( + AlgorithmProperty.LABEL); + } + + return label; + } + } +} Added: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java (rev 0) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/FileSaverServiceImpl.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,141 @@ +package org.cishell.reference.app.service.filesaver; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; + +import org.cishell.app.service.filesaver.AbstractFileSaverService; +import org.cishell.app.service.filesaver.FileSaveException; +import org.cishell.framework.data.Data; +import org.cishell.service.conversion.Converter; +import org.cishell.service.conversion.DataConversionService; +import org.cishell.service.guibuilder.GUIBuilderService; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.osgi.service.component.ComponentContext; + +public class FileSaverServiceImpl extends AbstractFileSaverService { + public static final String SAVE_DIALOG_TITLE = "Save"; + + private DataConversionService conversionManager; + private GUIBuilderService guiBuilder; + + protected void activate(ComponentContext componentContext) { + this.conversionManager = (DataConversionService) componentContext.locateService("DCS"); + this.guiBuilder = (GUIBuilderService) componentContext.locateService("GBS"); + + } + + public Converter promptForConverter(final Data outDatum, String targetMimeType) + throws FileSaveException { + final Converter[] converters = + this.conversionManager.findConverters(outDatum, targetMimeType); + + if (converters.length == 0) { + throw new FileSaveException("No appropriate converters."); + } else if (converters.length == 1) { + // Only one possible choice in how to save data. Do it. + Converter onlyConverter = converters[0]; + + return onlyConverter; + } else { + final Shell parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); + + if (parentShell.isDisposed()) { + throw new FileSaveException( + "Can't create dialog window -- graphical environment not available."); + } + + return showDataFormatChooser(outDatum, converters, parentShell); + } + } + + private Converter showDataFormatChooser( + final Data outDatum, + final Converter[] converters, + final Shell parentShell) throws FileSaveException{ + try { + final Converter[] chosenConverter = new Converter[1]; + guiRun(new Runnable() { + public void run() { + DataFormatChooser formatChooser = new DataFormatChooser( + outDatum, parentShell, converters, SAVE_DIALOG_TITLE); + formatChooser.createContent(new Shell(parentShell)); + formatChooser.open(); + chosenConverter[0] = formatChooser.getChosenConverter(); + } + }); + + return chosenConverter[0]; + } catch (Exception e) { + throw new FileSaveException(e.getMessage(), e); + } + } + + public File promptForTargetFile(final String fileName) throws FileSaveException { + final File[] resultFile = new File[1]; + + try { + guiRun(new Runnable() { + public void run() { + SaveAsController saveAs = + new SaveAsController(FileSaverServiceImpl.this.guiBuilder); + + resultFile[0] = saveAs.open(fileName); + } + }); + + return resultFile[0]; + } catch (Throwable e) { + throw new FileSaveException(e.getMessage(), e); + } + } + + public void saveTo(File sourceFile, File targetFile) throws FileSaveException { + if ((sourceFile != null) && (targetFile != null) && sourceFile.exists()) { + copyFile(sourceFile, targetFile); + } + } + + private void guiRun(Runnable run) { + final Shell parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); + + if (Thread.currentThread() == Display.getDefault().getThread()) { + run.run(); + } else { + parentShell.getDisplay().syncExec(run); + } + } + + /* TODO: Don't use cns-utilities, use Files.copy in Guava + * This shouldn't throw FileSaveException -- too specific for a general utility. + * Catch whatever this throws then rethrow as FSE + */ + private static void copyFile(File sourceFile, File targetFile) throws FileSaveException { + try { + FileInputStream inputStream = new FileInputStream(sourceFile); + FileOutputStream outputStream = new FileOutputStream(targetFile); + + FileChannel readableChannel = inputStream.getChannel(); + FileChannel writableChannel = outputStream.getChannel(); + + writableChannel.truncate(0); + writableChannel.transferFrom( + readableChannel, 0, readableChannel.size()); + inputStream.close(); + outputStream.close(); + } catch (IOException ioException) { + String exceptionMessage = + "An error occurred when copying from the file \"" + + sourceFile.getAbsolutePath() + + "\" to the file \"" + + targetFile.getAbsolutePath() + + "\"."; + + throw new FileSaveException(exceptionMessage, ioException); // TODO Just throw IOException + } + } +} \ No newline at end of file Added: trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java (rev 0) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/app/service/filesaver/SaveAsController.java 2011-03-01 20:10:28 UTC (rev 1231) @@ -0,0 +1,115 @@ +package org.cishell.reference.app.service.filesaver; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import org.cishell.service.guibuilder.GUIBuilderService; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +public class SaveAsController { + public static final Collection<Character> INVALID_FILENAME_CHARACTERS = + Collections.unmodifiableCollection(Arrays.asList( + '\\', '/', ':', '*', '?', '"', '<', '>', '|', '%')); + public static final char FILENAME_CHARACTER_REPLACEMENT = '#'; + + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + + private static File currentDirectory; + + private GUIBuilderService guiBuilder; + + public SaveAsController(GUIBuilderService guiBuilder) { + ... [truncated message content] |
From: <pat...@us...> - 2011-03-01 20:09:52
|
Revision: 1230 http://cishell.svn.sourceforge.net/cishell/?rev=1230&view=rev Author: pataphil Date: 2011-03-01 20:09:46 +0000 (Tue, 01 Mar 2011) Log Message: ----------- * Refactored to use the File*Services. * Reviewed by Joseph. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 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/SaveDataChooser.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-03-01 20:09:46 UTC (rev 1230) @@ -6,6 +6,7 @@ Bundle-ClassPath: . Import-Package: org.cishell.app.service.datamanager, org.cishell.app.service.fileloader, + org.cishell.app.service.filesaver, org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -34,7 +34,7 @@ public Data[] execute() throws AlgorithmExecutionException { try { return this.fileLoader.loadFilesFromUserSelection( - this.bundleContext, this.ciShellContext, this.logger, this.progressMonitor); + this.bundleContext, this.ciShellContext, this.logger, this.progressMonitor, false); } catch (FileLoadException e) { throw new AlgorithmExecutionException(e.getMessage(), e); } 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 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -1,31 +1,32 @@ package org.cishell.reference.gui.persistence.save; -import org.cishell.framework.CIShellContext; +import java.io.File; + +import org.cishell.app.service.filesaver.FileSaveException; +import org.cishell.app.service.filesaver.FileSaverService; import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmCanceledException; import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; import org.cishell.service.conversion.Converter; -import org.cishell.service.conversion.DataConversionService; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; +import org.osgi.service.log.LogService; public class Save implements Algorithm { public static final String ANY_FILE_EXTENSION = "file-ext:*"; public static final String SAVE_DIALOG_TITLE = "Save"; + private Data data; - private CIShellContext ciShellContext; + private LogService logger; + private FileSaverService fileSaver; - private Shell parentShell; - - private DataConversionService conversionManager; - public Save( - Data data, CIShellContext ciShellContext, DataConversionService conversionManager) { + Data data, + LogService logger, + FileSaverService fileSaver) { this.data = data; - this.ciShellContext = ciShellContext; - - this.conversionManager = conversionManager; + + this.logger = logger; + this.fileSaver = fileSaver; } public Data[] execute() throws AlgorithmExecutionException { @@ -36,49 +37,37 @@ private void tryToSave(final Data outData, String outFormat) throws AlgorithmExecutionException { - final Converter[] converters = conversionManager.findConverters(outData, outFormat); + try { + Converter userChosenConverter = + this.fileSaver.promptForConverter(outData, outFormat); - if (converters.length == 0) { - throw new AlgorithmExecutionException("Error: Calculated an empty converter chain."); - } + if (userChosenConverter == null) { + throw new AlgorithmCanceledException( + "User canceled file saving when choosing what kind of file to save as."); + } - this.parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); + File userChosenFile = this.fileSaver.promptForTargetFile(outData); - if (this.parentShell.isDisposed()) { - throw new AlgorithmExecutionException("Attempted to use disposed parent shell."); - } - - try { - guiRun(new Runnable() { - public void run() { - if (converters.length == 1) { - // Only one possible choice in how to save data. Do it. - Converter onlyConverter = converters[0]; - FileSaver saver = new FileSaver(Save.this.parentShell, ciShellContext); - saver.save(onlyConverter, outData); - } else { - // Multiple ways to save the data. Let user choose. - SaveDataChooser saveChooser = new SaveDataChooser( - outData, - Save.this.parentShell, - converters, - SAVE_DIALOG_TITLE, - Save.this.ciShellContext); - saveChooser.createContent(new Shell(Save.this.parentShell)); - saveChooser.open(); - } - } - }); - } catch (Exception e) { + if (userChosenFile == null) { + throw new AlgorithmCanceledException( + "User canceled file saving when choosing the destination of the file."); + } + + Data outputDatum = + this.fileSaver.save(userChosenConverter, outData, userChosenFile); + + // TODO: Should we bother handling this? sure, why not. maybe algexec would be appropriate + if (outputDatum == null) { + return; + } + + String logMessage = String.format("Saved: %s", userChosenFile.getPath()); + this.logger.log(LogService.LOG_INFO, logMessage); + } catch (FileSaveException e) { + String logMessage = String.format( + "Error occurred while converting data to saved format:\n %s", e.getMessage()); + this.logger.log(LogService.LOG_ERROR, logMessage, e); throw new AlgorithmExecutionException(e.getMessage(), e); } } - - private void guiRun(Runnable run) { - if (Thread.currentThread() == Display.getDefault().getThread()) { - run.run(); - } else { - this.parentShell.getDisplay().syncExec(run); - } - } } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -42,6 +42,10 @@ * among several persisters that support the selected model, in the event * that more than one is found. */ +/* TODO + * If we make a file viewer service, remove this + * Otherwise move to File View algorithm + */ public class SaveDataChooser extends AbstractDialog implements AlgorithmProperty { public static final Image QUESTION_ICON = Display.getCurrent().getSystemImage(SWT.ICON_QUESTION); Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -2,13 +2,14 @@ import java.util.Dictionary; +import org.cishell.app.service.filesaver.FileSaverService; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.Data; -import org.cishell.service.conversion.DataConversionService; import org.osgi.service.cm.ConfigurationException; import org.osgi.service.cm.ManagedService; +import org.osgi.service.log.LogService; /** * Create a Save object @@ -20,12 +21,14 @@ public class SaveFactory implements AlgorithmFactory, ManagedService { public Algorithm createAlgorithm( Data[] data, Dictionary<String, Object> parameters, CIShellContext ciShellContext) { + // TODO Unpack data? Data inputData = data[0]; - DataConversionService conversionManager = - (DataConversionService) ciShellContext.getService( - DataConversionService.class.getName()); + LogService logger = + (LogService) ciShellContext.getService(LogService.class.getName()); + FileSaverService fileSaver = (FileSaverService) ciShellContext.getService( + FileSaverService.class.getName()); - return new Save(inputData, ciShellContext, conversionManager); + return new Save(inputData, logger, fileSaver); } @SuppressWarnings("unchecked") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-02-22 18:04:25
|
Revision: 1229 http://cishell.svn.sourceforge.net/cishell/?rev=1229&view=rev Author: jrbibers Date: 2011-02-22 18:04:19 +0000 (Tue, 22 Feb 2011) Log Message: ----------- Standardizing name of google_guava plugin on underscores. CISHELL-18 Modified Paths: -------------- trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml trunk/libs/google_guava/.project trunk/libs/google_guava/META-INF/MANIFEST.MF Modified: trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml =================================================================== --- trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2011-02-22 17:59:13 UTC (rev 1228) +++ trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2011-02-22 18:04:19 UTC (rev 1229) @@ -219,8 +219,8 @@ </antcall> <antcall target="svn.co"> <param name="target" value="plugins"/> - <param name="element.id" value="google-guava"/> - <param name="project.name" value="/libs/google-guava"/> + <param name="element.id" value="google_guava"/> + <param name="project.name" value="/libs/google_guava"/> <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/> </antcall> Modified: trunk/libs/google_guava/.project =================================================================== --- trunk/libs/google_guava/.project 2011-02-22 17:59:13 UTC (rev 1228) +++ trunk/libs/google_guava/.project 2011-02-22 18:04:19 UTC (rev 1229) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>google-guava</name> + <name>google_guava</name> <comment></comment> <projects> </projects> Modified: trunk/libs/google_guava/META-INF/MANIFEST.MF =================================================================== --- trunk/libs/google_guava/META-INF/MANIFEST.MF 2011-02-22 17:59:13 UTC (rev 1228) +++ trunk/libs/google_guava/META-INF/MANIFEST.MF 2011-02-22 18:04:19 UTC (rev 1229) @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: google-guava -Bundle-SymbolicName: google-guava +Bundle-Name: google_guava +Bundle-SymbolicName: google_guava Bundle-Version: 0.8.0 Bundle-ClassPath: guava-r08.jar Export-Package: com.google.common.annotations, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2011-02-22 17:59:19
|
Revision: 1228 http://cishell.svn.sourceforge.net/cishell/?rev=1228&view=rev Author: jrbibers Date: 2011-02-22 17:59:13 +0000 (Tue, 22 Feb 2011) Log Message: ----------- Changing hyphen to underscore. Added Paths: ----------- trunk/libs/google_guava/ Removed Paths: ------------- trunk/libs/google-guava/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |