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: <jrb...@us...> - 2010-06-24 18:18:33
|
Revision: 1077
http://cishell.svn.sourceforge.net/cishell/?rev=1077&view=rev
Author: jrbibers
Date: 2010-06-24 18:18:27 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
Fixed tool error when using "View" or "View With..." on an item in the data manager whose label contains invalid filename characters (like "/" or "\"). The "Save" algorithm had been properly sanitizing data labels, so now we just do that same sanitization for "View" (to which "View With..." calls).
Reviewed by Russell.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-06-20 19:33:14 UTC (rev 1076)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-06-24 18:18:27 UTC (rev 1077)
@@ -278,20 +278,22 @@
String dataLabel =
(String)originalData.getMetadata().get(DataProperty.LABEL);
String dataFormat = originalData.getFormat();
- String fileName = FileUtilities.extractFileName(dataLabel);
+ String suggestedFileName = FileUtilities.extractFileName(dataLabel);
+ String cleanedSuggestedFileName =
+ FileUtilities.replaceInvalidFilenameCharacters(suggestedFileName);
String fileExtension = FileUtilities.extractExtension(dataFormat);
try {
File fileToView = FileUtilities.
createTemporaryFileInDefaultTemporaryDirectory(
- fileName, fileExtension);
+ cleanedSuggestedFileName, fileExtension);
FileUtilities.copyFile((File)originalData.getData(), fileToView);
return fileToView;
} catch (IOException temporaryFileCreationException) {
String exceptionMessage =
"An IOException occurred when creating the temporary file \"" +
- fileName + "." + fileExtension +
+ cleanedSuggestedFileName + "." + fileExtension +
"\" for viewing the data \"" + dataLabel + "\".";
throw new ConvertDataForViewingException(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-06-20 19:33:22
|
Revision: 1076
http://cishell.svn.sourceforge.net/cishell/?rev=1076&view=rev
Author: pataphil
Date: 2010-06-20 19:33:14 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
* Cleaned AlgorithmUtilities.
* Refactored implodeList, renaming it to implodeItems and changing its signature to accept a Collection instead of List (making it more generic). Subsequently added implodeList back, wrapping implodeItems, to make depedencies happy.
* Added org.cishell.utilities.mutateParameter.MetaAttributeDefinition (container for AD type (required, optional) and AD itself).
* Added ListUtilities.
* Made DefaultDictionary Java 1.5 (K, V).
* Updated reference to implodeList in various places.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayListUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/DatabaseUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/Column.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/DatabaseTable.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/ForeignKey.java
Added Paths:
-----------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/ListUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/MetaAttributeDefinition.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -20,26 +20,21 @@
// TODO: ISILoadAndCleanAlgorithmFactory should use this?
// It's copied directly from it (and cleaned up a little bit)...
public static AlgorithmFactory getAlgorithmFactoryByFilter(
- String filter, BundleContext bundleContext)
- throws AlgorithmNotFoundException {
+ String filter, BundleContext bundleContext) throws AlgorithmNotFoundException {
ServiceReference[] algorithmFactoryReferences;
-
+
try {
algorithmFactoryReferences = bundleContext.getServiceReferences(
AlgorithmFactory.class.getName(), filter);
} catch (InvalidSyntaxException invalidSyntaxException) {
throw new AlgorithmNotFoundException(invalidSyntaxException);
}
-
- if (algorithmFactoryReferences != null &&
- algorithmFactoryReferences.length != 0) {
- ServiceReference algorithmFactoryReference =
- algorithmFactoryReferences[0];
-
- AlgorithmFactory algorithmFactory =
- (AlgorithmFactory)bundleContext.getService(
- algorithmFactoryReference);
-
+
+ if (algorithmFactoryReferences != null && algorithmFactoryReferences.length != 0) {
+ ServiceReference algorithmFactoryReference = algorithmFactoryReferences[0];
+ AlgorithmFactory algorithmFactory = (AlgorithmFactory)bundleContext.getService(
+ algorithmFactoryReference);
+
return algorithmFactory;
}
else {
@@ -47,19 +42,18 @@
"algorithm that satisfied the following filter:\n" + filter);
}
}
-
+
public static AlgorithmFactory getAlgorithmFactoryByPID(
- String pid, BundleContext bundleContext)
- throws AlgorithmNotFoundException {
+ String pid, BundleContext bundleContext) throws AlgorithmNotFoundException {
String filter = "(service.pid=" + pid + ")";
-
+
return getAlgorithmFactoryByFilter(filter, bundleContext);
}
public static Data[] cloneSingletonData(Data[] data) {
- return new Data[]{ new BasicData(data[0].getMetadata(),
- data[0].getData(),
- data[0].getFormat()) };
+ return new Data[] {
+ new BasicData(data[0].getMetadata(), data[0].getData(), data[0].getFormat())
+ };
}
/**
@@ -82,29 +76,30 @@
* receiving a new data item, the Data Manager algorithm would set this new
* property to the data item's label if not set already.
*/
+ @SuppressWarnings("unchecked") // Raw Dictionary
public static String guessSourceDataFilename(Data data) {
if (data == null) {
return "";
}
-
+
Dictionary metadata = data.getMetadata();
String label = (String) metadata.get(DataProperty.LABEL);
Data parent = (Data) metadata.get(DataProperty.PARENT);
-
+
if (label != null && label.indexOf(File.separator) != -1) {
/* If fileSeparator is a single backslash,
* escape it for the split() regular expression.
*/
String escapedFileSeparator = File.separator;
+
if ("\\".equals(escapedFileSeparator)) {
escapedFileSeparator = "\\\\";
}
-
- String[] pathTokens = label.split(escapedFileSeparator);
+ String[] pathTokens = label.split(escapedFileSeparator);
String guessedFilename = pathTokens[pathTokens.length - 1];
-
int lastExtensionSeparatorIndex = guessedFilename.lastIndexOf(".");
+
if (lastExtensionSeparatorIndex != -1) {
// Part before the extension ("foo" for "foo.bar").
String guessedNameProper =
@@ -130,8 +125,7 @@
Dictionary parameters,
CIShellContext ciShellContext)
throws AlgorithmExecutionException {
- Algorithm algorithm =
- algorithmFactory.createAlgorithm(data, parameters, ciShellContext);
+ Algorithm algorithm = algorithmFactory.createAlgorithm(data, parameters, ciShellContext);
if ((progressMonitor != null) && (algorithm instanceof ProgressTrackable)) {
ProgressTrackable progressTrackable = (ProgressTrackable)algorithm;
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayListUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayListUtilities.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayListUtilities.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -79,8 +79,7 @@
List prefixList = list.subList(0, requestedPrefixSize);
if (!prefixList.isEmpty()) {
- affixes.add(
- StringUtilities.implodeList(prefixList, separator));
+ affixes.add(StringUtilities.implodeItems(prefixList, separator));
}
affixes.add(ellipsis);
@@ -91,13 +90,13 @@
list.size());
if (!suffixList.isEmpty()) {
affixes.add(
- StringUtilities.implodeList(suffixList, separator));
+ StringUtilities.implodeItems(suffixList, separator));
}
- return StringUtilities.implodeList(affixes, separator);
+ return StringUtilities.implodeItems(affixes, separator);
} else {
// Just implode the list.
- return StringUtilities.implodeList(list, separator);
+ return StringUtilities.implodeItems(list, separator);
}
}
}
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DatabaseUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DatabaseUtilities.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DatabaseUtilities.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -102,6 +102,6 @@
//TODO: Consider abstracting what you're wrapping with and making this a StringUtility.
public static String implodeAndWrap(List<String> values) {
- return "(" + StringUtilities.implodeList(values, ", ") + ")";
+ return "(" + StringUtilities.implodeItems(values, ", ") + ")";
}
}
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -4,30 +4,29 @@
import java.util.Enumeration;
import java.util.Hashtable;
-public class DefaultDictionary extends Dictionary {
- Object defaultValue;
- Dictionary wrappedDictionary;
+public class DefaultDictionary<K, V> extends Dictionary<K, V> {
+ V defaultValue;
+ Dictionary<K, V> wrappedDictionary;
- public DefaultDictionary(
- Object defaultValue, Dictionary wrappedDictionary) {
+ public DefaultDictionary(V defaultValue, Dictionary<K, V> wrappedDictionary) {
this.defaultValue = defaultValue;
this.wrappedDictionary = wrappedDictionary;
}
- public DefaultDictionary(Object defaultValue) {
- this(defaultValue, new Hashtable());
+ public DefaultDictionary(V defaultValue) {
+ this(defaultValue, new Hashtable<K, V>());
}
public Object getDefaultValue() {
return this.defaultValue;
}
- public Enumeration elements() {
+ public Enumeration<V> elements() {
return this.wrappedDictionary.elements();
}
- public Object get(Object key) {
- Object wrappedDictionaryGetResult = this.wrappedDictionary.get(key);
+ public V get(Object key) {
+ V wrappedDictionaryGetResult = this.wrappedDictionary.get(key);
if (wrappedDictionaryGetResult == null)
return this.defaultValue;
@@ -39,15 +38,15 @@
return this.wrappedDictionary.isEmpty();
}
- public Enumeration keys() {
+ public Enumeration<K> keys() {
return this.wrappedDictionary.keys();
}
- public Object put(Object key, Object value) {
+ public V put(K key, V value) {
return this.wrappedDictionary.put(key, value);
}
- public Object remove(Object key) {
+ public V remove(Object key) {
return this.wrappedDictionary.remove(key);
}
Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/ListUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ListUtilities.java (rev 0)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/ListUtilities.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -0,0 +1,18 @@
+package org.cishell.utilities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListUtilities {
+ public static<T> List<T> createAndFillList(T... contents) {
+ return fillList(new ArrayList<T>(), contents);
+ }
+
+ public static<T> List<T> fillList(List<T> list, T... contents) {
+ for (T content : contents) {
+ list.add(content);
+ }
+
+ return list;
+ }
+}
\ No newline at end of file
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -1,11 +1,14 @@
package org.cishell.utilities;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.StringTokenizer;
public class StringUtilities {
- public static String implodeStringArray(String[] stringArray,
- String separator) {
+ // TODO: Make this wrap implodeItems.
+ public static String implodeStringArray(String[] stringArray, String separator) {
final int stringArrayLength = stringArray.length;
StringBuffer workingResultString = new StringBuffer();
@@ -18,16 +21,25 @@
return workingResultString.toString();
}
-
+
+ /* TODO: This is a wrapper for implodeItems. All new/updated code should refer to implodeItems
+ * from now on.
+ */
+ @SuppressWarnings("unchecked") // Raw List.
public static String implodeList(List list, String separator) {
+ return implodeItems(list, separator);
+ }
+
+ public static<T> String implodeItems(Collection<T> items, String separator) {
StringBuffer workingResultString = new StringBuffer();
-
- final int listLength = list.size();
-
- for (int ii = 0; ii < listLength; ii++) {
- workingResultString.append(list.get(ii));
+
+ for (Iterator<T> it = items.iterator(); it.hasNext(); ) {
+// for (int ii = 0; ii < listLength; ii++) {
+// workingResultString.append(list.get(ii));
+ workingResultString.append(it.next());
- boolean isLastElement = (ii == listLength - 1);
+// boolean isLastElement = (ii == listLength - 1);
+ boolean isLastElement = !it.hasNext();
if (!isLastElement) {
workingResultString.append(separator);
}
@@ -36,9 +48,8 @@
return workingResultString.toString();
}
- public static String[] filterStringsByPattern(String[] stringsToFilter,
- String pattern) {
- ArrayList filteredStrings = new ArrayList();
+ public static String[] filterStringsByPattern(String[] stringsToFilter, String pattern) {
+ ArrayList<String> filteredStrings = new ArrayList<String>();
for (int ii = 0; ii < stringsToFilter.length; ii++) {
if (!stringsToFilter[ii].matches(pattern)) {
@@ -51,7 +62,7 @@
public static String[] filterEmptyStrings(String[] stringsToFilter) {
// TODO: This maybe should use filterStringsByPattern?
- ArrayList filteredStrings = new ArrayList();
+ ArrayList<String> filteredStrings = new ArrayList<String>();
for (int ii = 0; ii < stringsToFilter.length; ii++) {
if (!"".equals(stringsToFilter[ii])) {
@@ -147,8 +158,7 @@
return true;
}
- public static int countOccurrencesOfChar(
- CharSequence characters, char target) {
+ public static int countOccurrencesOfChar(CharSequence characters, char target) {
int count = 0;
for (int ii = 0; ii < characters.length(); ii++) {
@@ -196,7 +206,7 @@
}
public static final String[] simpleCleanStrings(String[] strings) {
- List cleanedStrings = new ArrayList();
+ List<String> cleanedStrings = new ArrayList<String>();
for (int ii = 0; ii < strings.length; ii ++) {
cleanedStrings.add(StringUtilities.simpleClean(strings[ii]));
@@ -302,17 +312,36 @@
}
public static String getNthToken(
- String originalString,
- String separator,
- int index,
- boolean trim) {
+ String originalString, String separator, int index, boolean trim) {
+ return getAllTokens(originalString, separator, trim)[index];
+ }
+ public static String[] getAllTokens(
+ String originalString, String separator, boolean trim) {
String[] tokens = originalString.split(separator);
if (trim) {
- return tokens[index].trim();
+ String[] trimmedTokens = new String[tokens.length];
+
+ for (int ii = 0; ii < tokens.length; ii++) {
+ trimmedTokens[ii] = tokens[ii].trim();
+ }
+
+ return trimmedTokens;
} else {
- return tokens[index];
+ return tokens;
}
}
+
+ public static String[] tokenizeByWhitespace(String originalString) {
+ StringTokenizer tokenizer = new StringTokenizer(originalString);
+ int tokenCount = tokenizer.countTokens();
+ String[] tokens = new String[tokenCount];
+
+ for (int ii = 0; ii < tokenCount; ii++) {
+ tokens[ii] = tokenizer.nextToken();
+ }
+
+ return tokens;
+ }
}
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/Column.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/Column.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/Column.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -13,7 +13,7 @@
public final int type;
public final int size;
- public static final Map<Integer, String> TYPE_MAP = constructTypeMap();
+ public static final Map<Integer, String> TYPE_MAP = constructTypeMap();
public static final Set<Integer> SIZED_TYPES = constructSizedTypes();
private static Map<Integer, String> constructTypeMap() { //if this ever gets derby specific, it shouldn't go here
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/DatabaseTable.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/DatabaseTable.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/DatabaseTable.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -162,7 +162,7 @@
for(String key : primaryKeys) {
keys.add(key + " = ?");
}
- return StringUtilities.implodeList(Lists.newArrayList(keys), separator);
+ return StringUtilities.implodeItems(Lists.newArrayList(keys), separator);
}
public Remover constructRemover(Connection connection) throws SQLException {
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/ForeignKey.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/ForeignKey.java 2010-06-20 19:16:46 UTC (rev 1075)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/database/ForeignKey.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -59,7 +59,7 @@
String foreignColumn = pair.foreign;
updateStatements.add(foreignColumn + " = ?");
}
- return StringUtilities.implodeList(Lists.newArrayList(updateStatements), separator);
+ return StringUtilities.implodeItems(Lists.newArrayList(updateStatements), separator);
}
public Repointer constructRepointer(Connection connection) throws SQLException {
Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/MetaAttributeDefinition.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/MetaAttributeDefinition.java (rev 0)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/MetaAttributeDefinition.java 2010-06-20 19:33:14 UTC (rev 1076)
@@ -0,0 +1,21 @@
+package org.cishell.utilities.mutateParameter;
+
+import org.osgi.service.metatype.AttributeDefinition;
+
+public class MetaAttributeDefinition {
+ private int type;
+ private AttributeDefinition attributeDefinition;
+
+ public MetaAttributeDefinition(int type, AttributeDefinition attributeDefinition) {
+ this.type = type;
+ this.attributeDefinition = attributeDefinition;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ public AttributeDefinition getAttributeDefinition() {
+ return this.attributeDefinition;
+ }
+}
\ 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...> - 2010-06-20 19:16:55
|
Revision: 1075
http://cishell.svn.sourceforge.net/cishell/?rev=1075&view=rev
Author: pataphil
Date: 2010-06-20 19:16:46 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
* Changed signature of AlgorithmFactory.createAlgorithm to specify Dictionary K, V types, updating it to Java 1.5 (as opposed to using the Java 1.4 raw Dictionary).
* If it breaks anything (which it shouldn't), I'll change it back.
Modified Paths:
--------------
trunk/core/org.cishell.framework/.classpath
trunk/core/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs
trunk/core/org.cishell.framework/META-INF/MANIFEST.MF
trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java
Modified: trunk/core/org.cishell.framework/.classpath
===================================================================
--- trunk/core/org.cishell.framework/.classpath 2010-06-16 23:00:57 UTC (rev 1074)
+++ trunk/core/org.cishell.framework/.classpath 2010-06-20 19:16:46 UTC (rev 1075)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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 kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/core/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/core/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs 2010-06-16 23:00:57 UTC (rev 1074)
+++ trunk/core/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs 2010-06-20 19:16:46 UTC (rev 1075)
@@ -1,12 +1,12 @@
-#Wed Feb 06 22:39:13 GMT 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+#Fri Jun 11 22:41:08 EDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Modified: trunk/core/org.cishell.framework/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2010-06-16 23:00:57 UTC (rev 1074)
+++ trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2010-06-20 19:16:46 UTC (rev 1075)
@@ -4,6 +4,7 @@
Bundle-SymbolicName: org.cishell.framework
Bundle-Version: 1.0.0
Bundle-Vendor: Cyberinfrastructure for Network Science Center
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework,
org.osgi.service.log,
org.osgi.service.metatype,
Modified: trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java
===================================================================
--- trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java 2010-06-16 23:00:57 UTC (rev 1074)
+++ trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java 2010-06-20 19:16:46 UTC (rev 1075)
@@ -51,7 +51,6 @@
* standard CIShell services
* @return An <code>Algorithm</code> primed for execution
*/
- public Algorithm createAlgorithm(Data[] data,
- Dictionary parameters,
- CIShellContext context);
+ public Algorithm createAlgorithm(
+ Data[] data, Dictionary<String, Object> parameters, CIShellContext context);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jrb...@us...> - 2010-06-16 23:01:04
|
Revision: 1074
http://cishell.svn.sourceforge.net/cishell/?rev=1074&view=rev
Author: jrbibers
Date: 2010-06-16 23:00:57 +0000 (Wed, 16 Jun 2010)
Log Message:
-----------
Improved UTF-8 support by:
* Tolerating byte-order marks in UTF-8 files, where they are unnecessary but harmless and standard-permissible.
* Wrapping FileReaders throughout the converters inside UnicodeReader, a CIShell utility class. This detects the character encodings UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, and UTF-32BE according to any byte-order mark at the head of the file, defaulting to UTF-8 when unclear. The multiple existing UnicodeReaders are removed.
* Specifying the preferred encoding UTF-8 on FileWriters throughout the converter set.
* Adding a friendlier error message to the File > Load algorithm when an unrecognized encoding is presented. It suggests two common fixes.
Reviewed by Russell.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
Added Paths:
-----------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/UnicodeReader.java
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 2010-06-12 01:41:40 UTC (rev 1073)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-06-16 23:00:57 UTC (rev 1074)
@@ -1,6 +1,7 @@
package org.cishell.reference.gui.persistence.load;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.util.Dictionary;
import org.cishell.framework.CIShellContext;
@@ -88,30 +89,38 @@
return fileSelector.getFile();
}
- private Data[] validateFile(IWorkbenchWindow window, Display display, File file)
- throws AlgorithmExecutionException {
+ private Data[] validateFile(IWorkbenchWindow window, Display display, File file) {
AlgorithmFactory validator = null;
- boolean shouldTryValidator = true;
- while (shouldTryValidator) {
- try {
- validator = getValidatorFromUser(window, display, file);
+ try {
+ validator = getValidatorFromUser(window, display, file);
- if ((file == null) || (validator == null)) {
- String logMessage = "File loading canceled";
- this.logger.log(LogService.LOG_WARNING, logMessage);
-
- shouldTryValidator = false;
- } else {
+ if ((file == null) || (validator == null)) {
+ String logMessage = "File loading canceled";
+ this.logger.log(LogService.LOG_WARNING, logMessage);
+ } else {
+ try {
return FileValidator.validateFile(
- file, validator, this.progressMonitor, this.ciShellContext, this.logger);
+ file, validator, this.progressMonitor, this.ciShellContext, this.logger);
+ } catch (AlgorithmExecutionException e) {
+ if (e.getCause() != null
+ && e.getCause() instanceof UnsupportedEncodingException) {
+ String logMessage =
+ "This file cannot be loaded; it uses the unsupported character encoding "
+ + e.getCause().getMessage() + ".";
+ this.logger.log(LogService.LOG_ERROR, logMessage);
+ } else {
+ throw e;
+ }
}
- } catch (Throwable e) {
- String logMessage =
- "The chosen file is not compatible with the chosen file. " +
- "Please try a different format or cancel.";
- this.logger.log(LogService.LOG_ERROR, logMessage);
}
+ } catch (Throwable e) {
+ String logMessage =
+ "The chosen file is not compatible with this format. " +
+ "Check that your file is correctly formatted or try another validator. " +
+ "The reason is: " + e.getMessage();
+ e.printStackTrace(); // TODO remove
+ this.logger.log(LogService.LOG_ERROR, logMessage);
}
return null;
Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/UnicodeReader.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/UnicodeReader.java (rev 0)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/UnicodeReader.java 2010-06-16 23:00:57 UTC (rev 1074)
@@ -0,0 +1,141 @@
+package org.cishell.utilities;
+
+/**
+ version: 1.1 / 2007-01-25
+ - changed BOM recognition ordering (longer boms first)
+
+ Original pseudocode : Thomas Weidenfeller
+ Implementation tweaked: Aki Nieminen
+
+ http://www.unicode.org/unicode/faq/utf_bom.html
+ BOMs:
+ 00 00 FE FF = UTF-32, big-endian
+ FF FE 00 00 = UTF-32, little-endian
+ EF BB BF = UTF-8,
+ FE FF = UTF-16, big-endian
+ FF FE = UTF-16, little-endian
+
+ Win2k Notepad:
+ Unicode format = UTF-16LE
+ */
+
+import java.io.*;
+
+/**
+ * Generic unicode textreader, which will use BOM mark to identify the encoding
+ * to be used. If BOM is not found then use a given default or system encoding.
+ */
+public class UnicodeReader extends Reader {
+ public static final int BOM_SIZE = 4;
+
+ private PushbackInputStream internalIn;
+ private InputStreamReader internalIn2 = null;
+ private String defaultEnc;
+
+ /**
+ * @param in
+ * inputstream to be read
+ */
+ public UnicodeReader(InputStream in) {
+ this(in, "UTF-8");
+ }
+
+ /**
+ * @param in
+ * inputstream to be read
+ * @param defaultEnc
+ * default encoding if stream does not have BOM marker. Give null
+ * to use system-level default.
+ */
+ public UnicodeReader(InputStream in, String defaultEnc) {
+ internalIn = new PushbackInputStream(in, BOM_SIZE);
+ this.defaultEnc = defaultEnc;
+ }
+
+ public String getDefaultEncoding() {
+ return defaultEnc;
+ }
+
+ /**
+ * Get stream encoding or null if stream is uninitialized. Call init() or
+ * read() method to initialize it.
+ */
+ public String getEncoding() {
+ if (internalIn2 == null) {
+ return null;
+ }
+
+ return internalIn2.getEncoding();
+ }
+
+ /**
+ * Read-ahead four bytes and check for BOM marks. Extra bytes are unread
+ * back to the stream, only BOM bytes are skipped.
+ */
+ protected void init() throws IOException {
+ if (internalIn2 != null) {
+ return;
+ }
+
+ String encoding;
+ byte bom[] = new byte[BOM_SIZE];
+ int n;
+ int unread;
+ n = internalIn.read(bom, 0, bom.length);
+
+ if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE)
+ && (bom[3] == (byte) 0xFF)) {
+ encoding = "UTF-32BE";
+ unread = n - 4;
+ System.out.println("encoding detected: " + encoding);
+ } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00)
+ && (bom[3] == (byte) 0x00)) {
+ encoding = "UTF-32LE";
+ unread = n - 4;
+ System.out.println("encoding detected: " + encoding);
+ } else if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) && (bom[2] == (byte) 0xBF)) {
+ encoding = "UTF-8";
+ unread = n - 3;
+ System.out.println("encoding detected: " + encoding);
+ } else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) {
+ encoding = "UTF-16BE";
+ unread = n - 2;
+ System.out.println("encoding detected: " + encoding);
+ } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) {
+ encoding = "UTF-16LE";
+ unread = n - 2;
+ System.out.println("encoding detected: " + encoding);
+ } else {
+ // Unicode BOM mark not found, unread all bytes
+ encoding = defaultEnc;
+ unread = n;
+ System.out.println("using default encoding: " + encoding);
+ }
+
+
+
+ if (unread > 0) {
+ internalIn.unread(bom, (n - unread), unread);
+ }
+
+ // Use given encoding
+ if (encoding == null) {
+ internalIn2 = new InputStreamReader(internalIn, "UTF-8");
+ } else {
+ internalIn2 = new InputStreamReader(internalIn, encoding);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ init();
+ internalIn2.close();
+ }
+
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ init();
+ return internalIn2.read(cbuf, off, len);
+ }
+
+}
\ 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...> - 2010-06-12 01:41:46
|
Revision: 1073
http://cishell.svn.sourceforge.net/cishell/?rev=1073&view=rev
Author: pataphil
Date: 2010-06-12 01:41:40 +0000 (Sat, 12 Jun 2010)
Log Message:
-----------
* Cleaned up MutateParameterUtilities.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2010-05-29 01:41:08 UTC (rev 1072)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2010-06-12 01:41:40 UTC (rev 1073)
@@ -3,7 +3,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashMap;
+import java.util.Map;
import org.cishell.reference.service.metatype.BasicObjectClassDefinition;
import org.cishell.utilities.mutateParameter.AttributeDefinitionTransformer;
@@ -22,112 +22,96 @@
public static AttributeDefinition formLabelAttributeDefinition(
AttributeDefinition oldAttributeDefinition, Table table)
- throws ColumnNotFoundException {
+ throws ColumnNotFoundException {
String[] validStringColumnsInTable =
TableUtilities.getValidStringColumnNamesInTable(table);
- AttributeDefinition labelAttributeDefinition =
- cloneToDropdownAttributeDefinition(oldAttributeDefinition,
- validStringColumnsInTable,
- validStringColumnsInTable);
-
+ AttributeDefinition labelAttributeDefinition = cloneToDropdownAttributeDefinition(
+ oldAttributeDefinition, validStringColumnsInTable, validStringColumnsInTable);
+
return labelAttributeDefinition;
}
public static AttributeDefinition formDateAttributeDefinition(
AttributeDefinition oldAttributeDefinition, Table table)
- throws ColumnNotFoundException {
- String[] validDateColumnsInTable =
- TableUtilities.getValidDateColumnNamesInTable(table);
+ throws ColumnNotFoundException {
+ String[] validDateColumnsInTable = TableUtilities.getValidDateColumnNamesInTable(table);
- AttributeDefinition dateAttributeDefinition =
- cloneToDropdownAttributeDefinition(oldAttributeDefinition,
- validDateColumnsInTable,
- validDateColumnsInTable);
+ AttributeDefinition dateAttributeDefinition = cloneToDropdownAttributeDefinition(
+ oldAttributeDefinition, validDateColumnsInTable, validDateColumnsInTable);
return dateAttributeDefinition;
}
public static AttributeDefinition formIntegerAttributeDefinition(
AttributeDefinition oldAttributeDefinition, Table table)
- throws ColumnNotFoundException {
+ throws ColumnNotFoundException {
String[] validIntegerColumnsInTable =
TableUtilities.getValidIntegerColumnNamesInTable(table);
- AttributeDefinition integerAttributeDefinition =
- cloneToDropdownAttributeDefinition(oldAttributeDefinition,
- validIntegerColumnsInTable,
- validIntegerColumnsInTable);
+ AttributeDefinition integerAttributeDefinition = cloneToDropdownAttributeDefinition(
+ oldAttributeDefinition, validIntegerColumnsInTable, validIntegerColumnsInTable);
return integerAttributeDefinition;
}
-
+
public static AttributeDefinition formNumberAttributeDefinition(
AttributeDefinition oldAttributeDefinition, Table table)
- throws ColumnNotFoundException {
+ throws ColumnNotFoundException {
String[] validNumberColumnsInTable =
TableUtilities.getValidNumberColumnNamesInTable(table);
- AttributeDefinition numberAttributeDefinition =
- cloneToDropdownAttributeDefinition(oldAttributeDefinition,
- validNumberColumnsInTable,
- validNumberColumnsInTable);
+ AttributeDefinition numberAttributeDefinition = cloneToDropdownAttributeDefinition(
+ oldAttributeDefinition, validNumberColumnsInTable, validNumberColumnsInTable);
return numberAttributeDefinition;
}
-
- // TODO: Change LinkedHashMap to Map?
+
public static AttributeDefinition formAttributeDefinitionFromMap(
AttributeDefinition oldAttributeDefinition,
- LinkedHashMap map,
+ Map<String, String> map,
String[] types,
String[] keysToSkip,
String[] keysToAdd) {
- String[] validNumberKeysInMap =
- MapUtilities.getValidKeysOfTypesInMap(
- map, types, keysToSkip, keysToAdd);
+ String[] validNumberKeysInMap = MapUtilities.getValidKeysOfTypesInMap(
+ map, types, keysToSkip, keysToAdd);
- AttributeDefinition numberAttributeDefinition =
- cloneToDropdownAttributeDefinition(oldAttributeDefinition,
- validNumberKeysInMap,
- validNumberKeysInMap);
+ AttributeDefinition numberAttributeDefinition = cloneToDropdownAttributeDefinition(
+ oldAttributeDefinition, validNumberKeysInMap, validNumberKeysInMap);
return numberAttributeDefinition;
}
-
+
public static AttributeDefinition cloneToDropdownAttributeDefinition(
- AttributeDefinition oldAD,
- final String[] optionLabels,
- final String[] optionValues) {
- AttributeDefinitionTransformer transformer =
- new DefaultDropdownTransformer() {
- public boolean shouldTransform(AttributeDefinition ad) {
- return true;
- }
-
- public String[] transformOptionLabels(
- String[] oldOptionLabels) {
- return optionLabels;
- }
-
- public String[] transformOptionValues(
- String[] oldOptionValues) {
- return optionValues;
- }
- };
+ AttributeDefinition oldAD, final String[] optionLabels, final String[] optionValues) {
+ AttributeDefinitionTransformer transformer = new DefaultDropdownTransformer() {
+ public boolean shouldTransform(AttributeDefinition ad) {
+ return true;
+ }
+
+ public String[] transformOptionLabels(String[] oldOptionLabels) {
+ return optionLabels;
+ }
+
+ public String[] transformOptionValues(String[] oldOptionValues) {
+ return optionValues;
+ }
+ };
return transformer.transform(oldAD);
}
+ @SuppressWarnings("unchecked") // Raw Collection
public static BasicObjectClassDefinition mutateToDropdown(
ObjectClassDefinition oldOCD,
final String parameterID,
Collection optionLabels,
Collection optionValues) {
- return mutateToDropdown(oldOCD,
- parameterID,
- (String[]) optionLabels.toArray(new String[0]),
- (String[]) optionValues.toArray(new String[0]));
+ return mutateToDropdown(
+ oldOCD,
+ parameterID,
+ (String[])optionLabels.toArray(new String[0]),
+ (String[])optionValues.toArray(new String[0]));
}
/* Convenience method for a common mutation:
@@ -139,21 +123,20 @@
final String parameterID,
final String[] optionLabels,
final String[] optionValues) {
- AttributeDefinitionTransformer dropdownTransformer =
- new DefaultDropdownTransformer() {
- public boolean shouldTransform(AttributeDefinition ad) {
- return ad.getID().equals(parameterID);
- }
-
- public String[] transformOptionLabels(
- String[] oldOptionLabels) {
- return optionLabels;
- }
- public String[] transformOptionValues(
- String[] oldOptionValues) {
- return optionValues;
- }
- };
+ AttributeDefinitionTransformer dropdownTransformer = new DefaultDropdownTransformer() {
+ public boolean shouldTransform(AttributeDefinition ad) {
+ return ad.getID().equals(parameterID);
+ }
+
+ public String[] transformOptionLabels(
+ String[] oldOptionLabels) {
+ return optionLabels;
+ }
+ public String[] transformOptionValues(
+ String[] oldOptionValues) {
+ return optionValues;
+ }
+ };
return ObjectClassDefinitionTransformer.apply(
dropdownTransformer, oldOCD, new ArrayList<String>());
@@ -163,16 +146,15 @@
ObjectClassDefinition oldOCD,
final String parameterID,
final String defaultValue) {
- AttributeDefinitionTransformer transformer =
- new DefaultDefaultValueTransformer() {
- public boolean shouldTransform(AttributeDefinition ad) {
- return ad.getID().equals(parameterID);
- }
+ AttributeDefinitionTransformer transformer = new DefaultDefaultValueTransformer() {
+ public boolean shouldTransform(AttributeDefinition ad) {
+ return ad.getID().equals(parameterID);
+ }
- public String transformDefaultValue(String[] oldDefaultValue) {
- return defaultValue;
- }
- };
+ public String transformDefaultValue(String[] oldDefaultValue) {
+ return defaultValue;
+ }
+ };
return ObjectClassDefinitionTransformer.apply(
transformer, oldOCD, new ArrayList<String>());
@@ -181,17 +163,18 @@
public static BasicObjectClassDefinition createNewParameters(
ObjectClassDefinition oldParameters) {
try {
- return
- new BasicObjectClassDefinition(oldParameters.getID(),
- oldParameters.getName(),
- oldParameters.getDescription(),
- oldParameters.getIcon(16));
+ return new BasicObjectClassDefinition(
+ oldParameters.getID(),
+ oldParameters.getName(),
+ oldParameters.getDescription(),
+ oldParameters.getIcon(16));
}
catch (IOException e) {
- return new BasicObjectClassDefinition
- (oldParameters.getID(),
- oldParameters.getName(),
- oldParameters.getDescription(), null);
+ return new BasicObjectClassDefinition(
+ oldParameters.getID(),
+ oldParameters.getName(),
+ oldParameters.getDescription(),
+ null);
}
}
}
\ 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...> - 2010-05-29 01:41:15
|
Revision: 1072
http://cishell.svn.sourceforge.net/cishell/?rev=1072&view=rev
Author: pataphil
Date: 2010-05-29 01:41:08 +0000 (Sat, 29 May 2010)
Log Message:
-----------
* Fixed a minor bug with file loading.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
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 2010-05-28 20:09:51 UTC (rev 1071)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-05-29 01:41:08 UTC (rev 1072)
@@ -45,8 +45,12 @@
IWorkbenchWindow window = getFirstWorkbenchWindow();
Display display = PlatformUI.getWorkbench().getDisplay();
File file = getFileToLoadFromUser(window, display);
-
- return validateFile(window, display, file);
+
+ if (file != null) {
+ return validateFile(window, display, file);
+ } else {
+ return null;
+ }
}
public ProgressMonitor getProgressMonitor() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-05-28 20:09:59
|
Revision: 1071
http://cishell.svn.sourceforge.net/cishell/?rev=1071&view=rev
Author: pataphil
Date: 2010-05-28 20:09:51 +0000 (Fri, 28 May 2010)
Log Message:
-----------
* File Load now operates exactly as before, only better. (The user is prompted to select a format/validator until one succeeds or File Load is canceled.)
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
Added Paths:
-----------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileSelectorRunnable.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/ValidatorSelectorRunnable.java
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java
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 2010-05-28 19:41:39 UTC (rev 1070)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-05-28 20:09:51 UTC (rev 1071)
@@ -1,7 +1,6 @@
package org.cishell.reference.gui.persistence.load;
import java.io.File;
-import java.util.Collection;
import java.util.Dictionary;
import org.cishell.framework.CIShellContext;
@@ -43,35 +42,11 @@
}
public Data[] execute() throws AlgorithmExecutionException {
- // Prepare to run load dialog in GUI thread.
-
IWorkbenchWindow window = getFirstWorkbenchWindow();
Display display = PlatformUI.getWorkbench().getDisplay();
- FileLoadUserInputRunnable userInputGetter = new FileLoadUserInputRunnable(
- window, this.bundleContext, this.ciShellContext);
+ File file = getFileToLoadFromUser(window, display);
- // Run load dialog in GUI thread.
-
- if (Thread.currentThread() != display.getThread()) {
- display.syncExec(userInputGetter);
- } else {
- userInputGetter.run();
- }
-
- // Return loaded file data.
-
- File file = userInputGetter.getFile();
- AlgorithmFactory validator = userInputGetter.getValidator();
-
- if ((file == null) || (validator == null)) {
- String logMessage = "File loading canceled";
- this.logger.log(LogService.LOG_WARNING, logMessage);
-
- return null;
- } else {
- return FileValidator.validateFile(
- file, validator, this.progressMonitor, this.ciShellContext, this.logger);
- }
+ return validateFile(window, display, file);
}
public ProgressMonitor getProgressMonitor() {
@@ -86,7 +61,7 @@
return StringUtilities.emptyStringIfNull(preferences.get(LOAD_DIRECTORY_PREFERENCE_KEY));
}
- private static IWorkbenchWindow getFirstWorkbenchWindow() throws AlgorithmExecutionException {
+ private IWorkbenchWindow getFirstWorkbenchWindow() throws AlgorithmExecutionException {
final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
if (windows.length == 0) {
@@ -96,4 +71,59 @@
return windows[0];
}
}
+
+ private File getFileToLoadFromUser(IWorkbenchWindow window, Display display) {
+ FileSelectorRunnable fileSelector = new FileSelectorRunnable(window);
+
+ if (Thread.currentThread() != display.getThread()) {
+ display.syncExec(fileSelector);
+ } else {
+ fileSelector.run();
+ }
+
+ return fileSelector.getFile();
+ }
+
+ private Data[] validateFile(IWorkbenchWindow window, Display display, File file)
+ throws AlgorithmExecutionException {
+ AlgorithmFactory validator = null;
+ boolean shouldTryValidator = true;
+
+ while (shouldTryValidator) {
+ try {
+ validator = getValidatorFromUser(window, display, file);
+
+ if ((file == null) || (validator == null)) {
+ String logMessage = "File loading canceled";
+ this.logger.log(LogService.LOG_WARNING, logMessage);
+
+ shouldTryValidator = false;
+ } else {
+ return FileValidator.validateFile(
+ file, validator, this.progressMonitor, this.ciShellContext, this.logger);
+ }
+ } catch (Throwable e) {
+ String logMessage =
+ "The chosen file is not compatible with the chosen file. " +
+ "Please try a different format or cancel.";
+ this.logger.log(LogService.LOG_ERROR, logMessage);
+ }
+ }
+
+ return null;
+ }
+
+ private AlgorithmFactory getValidatorFromUser(
+ IWorkbenchWindow window, Display display, File file) {
+ ValidatorSelectorRunnable validatorSelector =
+ new ValidatorSelectorRunnable(window, this.bundleContext, file);
+
+ if (Thread.currentThread() != display.getThread()) {
+ display.syncExec(validatorSelector);
+ } else {
+ validatorSelector.run();
+ }
+
+ return validatorSelector.getValidator();
+ }
}
\ No newline at end of file
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java 2010-05-28 19:41:39 UTC (rev 1070)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java 2010-05-28 20:09:51 UTC (rev 1071)
@@ -1,147 +0,0 @@
-package org.cishell.reference.gui.persistence.load;
-
-import java.io.File;
-
-import org.cishell.framework.CIShellContext;
-import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.utilities.FileUtilities;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public final class FileLoadUserInputRunnable implements Runnable {
- private IWorkbenchWindow window;
- private BundleContext bundleContext;
- private CIShellContext ciShellContext;
- private File file;
- private AlgorithmFactory validator;
-
- public FileLoadUserInputRunnable(
- IWorkbenchWindow window, BundleContext bundleContext, CIShellContext ciShellContext) {
- this.window = window;
- this.bundleContext = bundleContext;
- this.ciShellContext = ciShellContext;
- }
-
- public File getFile() {
- return this.file;
- }
-
- public AlgorithmFactory getValidator() {
- return this.validator;
- }
-
- public void run() {
- this.file = getFileFromUser();
-
- if (file == null) {
- return;
- } else if (this.file.isDirectory()) {
- FileLoadAlgorithm.defaultLoadDirectory = this.file.getAbsolutePath();
- } else {
- FileLoadAlgorithm.defaultLoadDirectory = this.file.getParentFile().getAbsolutePath();
- }
-
- // Validate the loaded file, "casting" it to a certain MIME type.
-
- // Extract the file's file extension.
-
- String fileExtension =
- FileUtilities.getFileExtension(this.file).toLowerCase().substring(1);
-
- // TODO split here?
-
- // Get all the validators which support this file extension...
-
- ServiceReference[] supportingValidators = getSupportingValidators(fileExtension);
-
- // If there are no supporting validators...
- if (supportingValidators.length == 0) {
- // Let the user choose from all the validators available.
-
- ServiceReference[] allValidators = getAllValidators();
-
- FileFormatSelector validatorSelector = new FileFormatSelector(
- "Load", window.getShell(), this.bundleContext, allValidators);
- validatorSelector.open();
- this.validator = validatorSelector.getValidator();
- } else if (supportingValidators.length == 1) {
- ServiceReference onlyPossibleValidator = supportingValidators[0];
- this.validator =
- (AlgorithmFactory)this.bundleContext.getService(onlyPossibleValidator);
- }
-
- if (supportingValidators.length > 1) {
- FileFormatSelector validatorSelector = new FileFormatSelector(
- "Load", window.getShell(), this.bundleContext, supportingValidators);
- validatorSelector.open();
- this.validator = validatorSelector.getValidator();
- }
- }
-
- private File getFileFromUser() {
- FileDialog fileDialog = createFileDialog();
- String fileName = fileDialog.open();
-
- if (fileName == null) {
- return null;
- } else {
- return new File(fileName);
- }
- }
-
- private FileDialog createFileDialog() {
- File currentDirectory = new File(FileLoadAlgorithm.defaultLoadDirectory);
- String absolutePath = currentDirectory.getAbsolutePath();
- FileDialog fileDialog = new FileDialog(this.window.getShell(), SWT.OPEN);
- fileDialog.setFilterPath(absolutePath);
- fileDialog.setText("Select a File");
-
- return fileDialog;
- }
-
- private ServiceReference[] getSupportingValidators(String fileExtension) {
- try {
- String validatorsQuery =
- "(& (type=validator)" +
- "(|" +
- "(in_data=file-ext:" + fileExtension + ")" +
- "(also_validates=" + fileExtension + ")" +
- "))";
-
- ServiceReference[] supportingValidators = this.bundleContext.getAllServiceReferences(
- AlgorithmFactory.class.getName(), validatorsQuery);
-
- if (supportingValidators == null) {
- return new ServiceReference[0];
- } else {
- return supportingValidators;
- }
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
-
- return new ServiceReference[]{};
- }
- }
-
- private ServiceReference[] getAllValidators() {
- try {
- String validatorsQuery = "(&(type=validator)(in_data=file-ext:*))";
- ServiceReference[] allValidators = this.bundleContext.getAllServiceReferences(
- AlgorithmFactory.class.getName(), validatorsQuery);
-
- if (allValidators == null) {
- return new ServiceReference[0];
- } else {
- return allValidators;
- }
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
-
- return new ServiceReference[0];
- }
- }
-}
\ No newline at end of file
Copied: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileSelectorRunnable.java (from rev 1068, trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java)
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileSelectorRunnable.java (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileSelectorRunnable.java 2010-05-28 20:09:51 UTC (rev 1071)
@@ -0,0 +1,54 @@
+package org.cishell.reference.gui.persistence.load;
+
+import java.io.File;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+
+public final class FileSelectorRunnable implements Runnable {
+ private IWorkbenchWindow window;
+
+ private File file;
+
+ public FileSelectorRunnable(IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ public File getFile() {
+ return this.file;
+ }
+
+ public void run() {
+ this.file = getFileFromUser();
+
+ if (this.file == null) {
+ return;
+ } else if (this.file.isDirectory()) {
+ FileLoadAlgorithm.defaultLoadDirectory = this.file.getAbsolutePath();
+ } else {
+ FileLoadAlgorithm.defaultLoadDirectory = this.file.getParentFile().getAbsolutePath();
+ }
+ }
+
+ private File getFileFromUser() {
+ FileDialog fileDialog = createFileDialog();
+ String fileName = fileDialog.open();
+
+ if (fileName == null) {
+ return null;
+ } else {
+ return new File(fileName);
+ }
+ }
+
+ private FileDialog createFileDialog() {
+ File currentDirectory = new File(FileLoadAlgorithm.defaultLoadDirectory);
+ String absolutePath = currentDirectory.getAbsolutePath();
+ FileDialog fileDialog = new FileDialog(this.window.getShell(), SWT.OPEN);
+ fileDialog.setFilterPath(absolutePath);
+ fileDialog.setText("Select a File");
+
+ return fileDialog;
+ }
+}
\ No newline at end of file
Property changes on: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileSelectorRunnable.java
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/ValidatorSelectorRunnable.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/ValidatorSelectorRunnable.java (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/ValidatorSelectorRunnable.java 2010-05-28 20:09:51 UTC (rev 1071)
@@ -0,0 +1,101 @@
+package org.cishell.reference.gui.persistence.load;
+
+import java.io.File;
+
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.utilities.FileUtilities;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+public final class ValidatorSelectorRunnable implements Runnable {
+ private IWorkbenchWindow window;
+ private BundleContext bundleContext;
+
+ private File file;
+ private AlgorithmFactory validator;
+
+ public ValidatorSelectorRunnable(
+ IWorkbenchWindow window, BundleContext bundleContext, File file) {
+ this.window = window;
+ this.bundleContext = bundleContext;
+ this.file = file;
+ }
+
+ public AlgorithmFactory getValidator() {
+ return this.validator;
+ }
+
+ public void run() {
+ String fileExtension =
+ FileUtilities.getFileExtension(this.file).toLowerCase().substring(1);
+
+ ServiceReference[] supportingValidators = getSupportingValidators(fileExtension);
+
+ // If there are no supporting validators...
+ if (supportingValidators.length == 0) {
+ // Let the user choose from all the validators available.
+
+ ServiceReference[] allValidators = getAllValidators();
+
+ FileFormatSelector validatorSelector = new FileFormatSelector(
+ "Load", window.getShell(), this.bundleContext, allValidators);
+ validatorSelector.open();
+ this.validator = validatorSelector.getValidator();
+ } else if (supportingValidators.length == 1) {
+ ServiceReference onlyPossibleValidator = supportingValidators[0];
+ this.validator =
+ (AlgorithmFactory)this.bundleContext.getService(onlyPossibleValidator);
+ }
+
+ if (supportingValidators.length > 1) {
+ FileFormatSelector validatorSelector = new FileFormatSelector(
+ "Load", window.getShell(), this.bundleContext, supportingValidators);
+ validatorSelector.open();
+ this.validator = validatorSelector.getValidator();
+ }
+ }
+
+ private ServiceReference[] getSupportingValidators(String fileExtension) {
+ try {
+ String validatorsQuery =
+ "(& (type=validator)" +
+ "(|" +
+ "(in_data=file-ext:" + fileExtension + ")" +
+ "(also_validates=" + fileExtension + ")" +
+ "))";
+
+ ServiceReference[] supportingValidators = this.bundleContext.getAllServiceReferences(
+ AlgorithmFactory.class.getName(), validatorsQuery);
+
+ if (supportingValidators == null) {
+ return new ServiceReference[0];
+ } else {
+ return supportingValidators;
+ }
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+
+ return new ServiceReference[]{};
+ }
+ }
+
+ private ServiceReference[] getAllValidators() {
+ try {
+ String validatorsQuery = "(&(type=validator)(in_data=file-ext:*))";
+ ServiceReference[] allValidators = this.bundleContext.getAllServiceReferences(
+ AlgorithmFactory.class.getName(), validatorsQuery);
+
+ if (allValidators == null) {
+ return new ServiceReference[0];
+ } else {
+ return allValidators;
+ }
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+
+ return new ServiceReference[0];
+ }
+ }
+}
\ 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...> - 2010-05-28 19:41:45
|
Revision: 1070
http://cishell.svn.sourceforge.net/cishell/?rev=1070&view=rev
Author: pataphil
Date: 2010-05-28 19:41:39 +0000 (Fri, 28 May 2010)
Log Message:
-----------
* File Load algorithm now passes ProgressMonitor to wrapped validators if they implement ProgressTrackable.
Modified Paths:
--------------
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/FileValidator.java
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 2010-05-28 19:40:20 UTC (rev 1069)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-05-28 19:41:39 UTC (rev 1070)
@@ -69,7 +69,8 @@
return null;
} else {
- return FileValidator.validateFile(file, validator, this.ciShellContext, this.logger);
+ return FileValidator.validateFile(
+ file, validator, this.progressMonitor, this.ciShellContext, this.logger);
}
}
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java 2010-05-28 19:40:20 UTC (rev 1069)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java 2010-05-28 19:41:39 UTC (rev 1070)
@@ -1,10 +1,14 @@
package org.cishell.reference.gui.persistence.load;
import java.io.File;
+import java.util.Hashtable;
import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.algorithm.ProgressMonitor;
+import org.cishell.framework.algorithm.ProgressTrackable;
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.osgi.service.log.LogService;
@@ -13,24 +17,25 @@
public static Data[] validateFile(
File file,
AlgorithmFactory validator,
+ ProgressMonitor progressMonitor,
CIShellContext ciShellContext,
LogService logger) throws AlgorithmExecutionException {
Data[] validationData =
new Data[] { new BasicData(file.getPath(), String.class.getName()) };
- Data[] validatedData = validator.createAlgorithm(
- validationData, null, ciShellContext).execute();
+ Algorithm algorithm = validator.createAlgorithm(
+ validationData, new Hashtable<String, Object>(), ciShellContext);
+ if ((progressMonitor != null) && (algorithm instanceof ProgressTrackable)) {
+ ProgressTrackable progressTrackable = (ProgressTrackable)algorithm;
+ progressTrackable.setProgressMonitor(progressMonitor);
+ }
+
+ Data[] validatedData = algorithm.execute();
+
if (validatedData != null) {
logger.log(LogService.LOG_INFO, "Loaded: " + file.getPath());
}
return validatedData;
-// } catch (AlgorithmExecutionException e) {
-// String logMessage =
-// "An error occurred while attempting to load your file " +
-// "with the format you chose.";
-// this.logger.log(LogService.LOG_ERROR, logMessage, e);
-// this.thrownException = e;
-// }
}
}
\ 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...> - 2010-05-28 19:40:27
|
Revision: 1069
http://cishell.svn.sourceforge.net/cishell/?rev=1069&view=rev
Author: pataphil
Date: 2010-05-28 19:40:20 +0000 (Fri, 28 May 2010)
Log Message:
-----------
* Altered AlgorithmUtilities.executeAlgorithm() to consider ProgressMonitor business.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-05-28 18:53:00 UTC (rev 1068)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-05-28 19:40:20 UTC (rev 1069)
@@ -7,6 +7,8 @@
import org.cishell.framework.algorithm.Algorithm;
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.algorithm.ProgressMonitor;
+import org.cishell.framework.algorithm.ProgressTrackable;
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
@@ -123,12 +125,19 @@
@SuppressWarnings("unchecked") // Dictionary<String, Object>
public static Data[] executeAlgorithm(
AlgorithmFactory algorithmFactory,
+ ProgressMonitor progressMonitor,
+ Data[] data,
Dictionary parameters,
- CIShellContext ciShellContext,
- Data[] data)
+ CIShellContext ciShellContext)
throws AlgorithmExecutionException {
Algorithm algorithm =
algorithmFactory.createAlgorithm(data, parameters, ciShellContext);
+
+ if ((progressMonitor != null) && (algorithm instanceof ProgressTrackable)) {
+ ProgressTrackable progressTrackable = (ProgressTrackable)algorithm;
+ progressTrackable.setProgressMonitor(progressMonitor);
+ }
+
Data[] result = algorithm.execute();
return result;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-05-28 18:53:09
|
Revision: 1068
http://cishell.svn.sourceforge.net/cishell/?rev=1068&view=rev
Author: pataphil
Date: 2010-05-28 18:53:00 +0000 (Fri, 28 May 2010)
Log Message:
-----------
* Refactored File Load code to not suck so bad.
* Reviewed by Joseph.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.xml
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java
Added Paths:
-----------
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/FileLoadUserInputRunnable.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml 2010-05-28 18:53:00 UTC (rev 1068)
@@ -2,7 +2,7 @@
<!-- <?xml version="1.0" encoding="ISO-8859-1" ?> -->
<menu_layout>
<top_menu name="File">
- <menu name="Load..." pid= "org.cishell.reference.gui.persistence.load.FileLoad "/>
+ <menu name="Load..." pid= "org.cishell.reference.gui.persistence.load.FileLoadAlgorithm "/>
<menu type="break"/>
<menu name="Save..." pid= "org.cishell.reference.gui.persistence.save.Save"/>
<menu type="break"/>
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 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2010-05-28 18:53:00 UTC (rev 1068)
@@ -4,7 +4,7 @@
description=This allows users to select file from the file system and load it to Data Model window
in_data=null
out_data=java.lang.Object
-service.pid=org.cishell.reference.gui.persistence.load.FileLoad
+service.pid=org.cishell.reference.gui.persistence.load.FileLoadAlgorithm
remoteable=true
prefs_published=local
receive_prefs=true
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.xml
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.xml 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.xml 2010-05-28 18:53:00 UTC (rev 1068)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<component name="org.cishell.reference.gui.persistence.load.FileLoad.component" immediate="false">
+<component name="org.cishell.reference.gui.persistence.load.FileLoadAlgorithm.component" immediate="false">
<implementation class="org.cishell.reference.gui.persistence.load.FileLoadFactory"/>
<properties entry="OSGI-INF/load.properties"/>
<reference name="LOG" interface="org.osgi.service.log.LogService"/>
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2010-05-28 18:53:00 UTC (rev 1068)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
- <OCD name="File Load" id="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local.OCD"
+ <OCD name="File Load" id="org.cishell.reference.gui.persistence.load.FileLoadAlgorithm.prefs.local.OCD"
description=" ">
<AD name="Default load directory" id="loadDir" type="String" default="directory:sampledata/"/>
</OCD>
@@ -8,8 +8,8 @@
description=" ">
<AD name="View With" id="viewWith" type="String" default=""/>
</OCD>
- <Designate pid="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local">
- <Object ocdref="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local.OCD" />
+ <Designate pid="org.cishell.reference.gui.persistence.load.FileLoadAlgorithm.prefs.local">
+ <Object ocdref="org.cishell.reference.gui.persistence.load.FileLoadAlgorithm.prefs.local.OCD" />
</Designate>
<Designate pid="org.cishell.reference.gui.persistence.viewwith.FileViewWith">
<Object ocdref="org.cishell.reference.gui.persistence.viewwith.FileViewWith.OCD" />
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -6,13 +6,7 @@
*/
package org.cishell.reference.gui.persistence.load;
-import java.io.File;
-import java.util.ArrayList;
-
-import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.framework.data.BasicData;
-import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
import org.cishell.reference.gui.common.AbstractDialog;
import org.eclipse.swt.SWT;
@@ -30,17 +24,12 @@
import org.eclipse.swt.widgets.Shell;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
public class FileFormatSelector extends AbstractDialog {
- private File selectedFile;
- private LogService logger;
- private ServiceReference[] persisterArray;
- private List persisterList;
-// private StyledText detailPane;
- private CIShellContext ciShellContext;
private BundleContext bundleContext;
- private ArrayList returnList;
+ private AlgorithmFactory validator;
+ private ServiceReference[] validatorReferences;
+ private List validatorList;
// private static final String[] DETAILS_ITEM_KEY =
// {"format_name", "supported_file_extension", "format_description" };
@@ -59,19 +48,12 @@
public FileFormatSelector(
String title,
- File selectedFile,
Shell parent,
- CIShellContext ciShellContext,
- BundleContext bundleContext,
- ServiceReference[] persisterArray,
- ArrayList returnList) {
+ BundleContext bundleContext,
+ ServiceReference[] validatorReferences) {
super(parent, title, AbstractDialog.QUESTION);
- this.ciShellContext = ciShellContext;
this.bundleContext = bundleContext;
- this.persisterArray = persisterArray;
- this.returnList = returnList;
- this.selectedFile = selectedFile;
- this.logger = (LogService)ciShellContext.getService(LogService.class.getName());
+ this.validatorReferences = validatorReferences;
// Shall this part be moved out of the code?
setDescription(
@@ -82,8 +64,12 @@
"This dialog allows the user to choose among all available " +
"formats for loading the selected data model. Choose any of the formats " +
"to continue loading the dataset.");
- }
+ }
+ public AlgorithmFactory getValidator() {
+ return this.validator;
+ }
+
private Composite initializeGUI(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
@@ -91,18 +77,18 @@
layout.numColumns = 1;
content.setLayout(layout);
- Group persisterGroup = new Group(content, SWT.NONE);
+ Group validatorGroup = new Group(content, SWT.NONE);
// Shall this label be moved out of the code?
- persisterGroup.setText("Load as...");
- persisterGroup.setLayout(new FillLayout());
- GridData persisterListGridData = new GridData(GridData.FILL_BOTH);
- persisterListGridData.widthHint = 200;
- persisterGroup.setLayoutData(persisterListGridData);
+ validatorGroup.setText("Load as...");
+ validatorGroup.setLayout(new FillLayout());
+ GridData validatorListGridData = new GridData(GridData.FILL_BOTH);
+ validatorListGridData.widthHint = 200;
+ validatorGroup.setLayoutData(validatorListGridData);
- this.persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE);
+ this.validatorList = new List(validatorGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE);
// initPersisterArray();
initializePersisterList();
- this.persisterList.addMouseListener(new MouseAdapter() {
+ this.validatorList.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent mouseEvent) {
List list = (List)mouseEvent.getSource();
int selection = list.getSelectionIndex();
@@ -113,109 +99,70 @@
}
});
- this.persisterList.addSelectionListener(new SelectionAdapter() {
+ this.validatorList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent selectionEvent) {
List list = (List)selectionEvent.getSource();
int selection = list.getSelectionIndex();
if (selection != -1) {
- // updateDetailPane(persisterArray[selection]);
+ // updateDetailPane(validatorReferences[selection]);
}
}
});
- persisterList.setSelection(0);
+ validatorList.setSelection(0);
- /* Group detailsGroup = new Group(content, SWT.NONE);
- // Shall this label be moved out of the code?
- detailsGroup.setText("Details");
- detailsGroup.setLayout(new FillLayout());
- GridData detailsGridData = new GridData(GridData.FILL_BOTH);
- detailsGridData.widthHint = 200;
- detailsGroup.setLayoutData(detailsGridData);
-
- detailPane = initDetailPane(detailsGroup);
-
- persisterList.setSelection(0);
- updateDetailPane(persisterArray[0]); */
-
return content;
}
private void initializePersisterList() {
- for (int ii = 0; ii < this.persisterArray.length; ++ii) {
- String name = (String)this.persisterArray[ii].getProperty("label");
+ for (int ii = 0; ii < this.validatorReferences.length; ++ii) {
+ String name = (String)this.validatorReferences[ii].getProperty("label");
/*
* If someone was sloppy enough to not provide a name, then use the name of the
* class instead.
*/
if (name == null || name.length() == 0) {
- name = this.persisterArray[ii].getClass().getName();
+ name = this.validatorReferences[ii].getClass().getName();
}
- this.persisterList.add(name);
+ this.validatorList.add(name);
}
}
-
- /* private StyledText initDetailPane(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(ServiceReference persister) {
-
- detailPane.setText("");
-
- for (int ii = 0; ii < DETAILS_ITEM_KEY.length; ii++){
- String val = (String)persister.getProperty(DETAILS_ITEM_KEY[ii]);
-
- StyleRange styleRange = new StyleRange();
- styleRange.start = detailPane.getText().length();
- detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[ii] + ":\n");
- styleRange.length = DETAILS_ITEM_KEY[ii].length() + 1;
- styleRange.fontStyle = SWT.BOLD;
- detailPane.setStyleRange(styleRange);
-
- detailPane.append(val + "\n");
- }
- } */
-
private void selectionMade(int selectedIndex) {
- AlgorithmFactory persister =
- (AlgorithmFactory)this.bundleContext.getService(this.persisterArray[selectedIndex]);
- Data[] data = null;
- boolean loadSuccess = false;
-
- try {
- data =
- new Data[] { new BasicData(this.selectedFile.getPath(), String.class.getName()) };
- data = persister.createAlgorithm(data, null, this.ciShellContext).execute();
- loadSuccess = true;
- } catch (Throwable exception) {
- this.logger.log(
- LogService.LOG_ERROR, "Error occurred while executing selection", exception);
- exception.printStackTrace();
- loadSuccess = false;
- }
-
- if ((data != null) && loadSuccess) {
- this.logger.log(LogService.LOG_INFO, "Loaded: " + this.selectedFile.getPath());
-
- for (int ii = 0; ii < data.length; ii++) {
- Data dataItem = data[ii];
- FileLoad.relabelWithFilename(dataItem, selectedFile);
- this.returnList.add(dataItem);
- }
-
- close(true);
- } else {
- this.logger.log(LogService.LOG_ERROR, "Unable to load with selected loader");
- }
+ this.validator =
+ (AlgorithmFactory)this.bundleContext.getService(this.validatorReferences[selectedIndex]);
+ close(true);
+// AlgorithmFactory validator =
+// (AlgorithmFactory)this.bundleContext.getService(this.persisterArray[selectedIndex]);
+// Data[] data = null;
+// boolean loadSuccess = false;
+//
+// try {
+// data =
+// new Data[] { new BasicData(this.selectedFile.getPath(), String.class.getName()) };
+// data = validator.createAlgorithm(data, null, this.ciShellContext).execute();
+// loadSuccess = true;
+// } catch (Throwable exception) {
+// this.logger.log(
+// LogService.LOG_ERROR, "Error occurred while executing selection", exception);
+// exception.printStackTrace();
+// loadSuccess = false;
+// }
+//
+// if ((data != null) && loadSuccess) {
+// this.logger.log(LogService.LOG_INFO, "Loaded: " + this.selectedFile.getPath());
+//
+// for (int ii = 0; ii < data.length; ii++) {
+// this.returnList.add(data[ii]);
+// }
+//
+// close(true);
+// } else {
+// this.logger.log(LogService.LOG_ERROR, "Unable to load with selected loader");
+// }
}
public void createDialogButtons(Composite parent) {
@@ -223,7 +170,7 @@
select.setText("Select");
select.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent selectionEvent) {
- int index = FileFormatSelector.this.persisterList.getSelectionIndex();
+ int index = FileFormatSelector.this.validatorList.getSelectionIndex();
if (index != -1) {
selectionMade(index);
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -1,302 +0,0 @@
-package org.cishell.reference.gui.persistence.load;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Dictionary;
-
-import org.cishell.framework.CIShellContext;
-import org.cishell.framework.algorithm.Algorithm;
-import org.cishell.framework.algorithm.AlgorithmExecutionException;
-import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.framework.data.BasicData;
-import org.cishell.framework.data.Data;
-import org.cishell.framework.data.DataProperty;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-public class FileLoad implements Algorithm {
-
- private final LogService logger;
-
- private BundleContext bundleContext;
- private CIShellContext ciShellContext;
- private static String defaultLoadDirectory;
-
- public FileLoad(CIShellContext ciContext, BundleContext bContext,
- Dictionary prefProperties) {
- this.ciShellContext = ciContext;
- this.bundleContext = bContext;
- logger = (LogService) ciContext.getService(LogService.class.getName());
-
- // unpack preference properties
- if (defaultLoadDirectory == null) {
-
- /*
- * get the default load directory from preferences,
- * if it has been set.
- */
- Object result = prefProperties.get("loadDir");
- if (result != null) {
- defaultLoadDirectory = (String) result;
- } else {
- defaultLoadDirectory = "";
- }
- }
- }
-
- protected static void relabelWithFilename(Data data, File file) {
- File absoluteFile;
- try {
- absoluteFile = file.getCanonicalFile();
- } catch (IOException e) {
- absoluteFile = file.getAbsoluteFile();
- }
- File parent;
- try {
- parent = absoluteFile.getParentFile().getCanonicalFile();
- } catch (IOException e) {
- parent = absoluteFile.getParentFile().getAbsoluteFile();
- }
- String prefix;
- String parentName = parent.getName();
- if(parentName.trim().length() == 0) {
- prefix = File.separator;
- } else {
- prefix = "..." + File.separator + parentName + File.separator;
- }
- data.getMetadata().put(DataProperty.LABEL, prefix + absoluteFile.getName());
- }
-
- public Data[] execute() throws AlgorithmExecutionException {
- // prepare to run load dialog in GUI thread
-
- IWorkbenchWindow window = getFirstWorkbenchWindow();
- Display display = PlatformUI.getWorkbench().getDisplay();
- FileLoadRunnable fileLoader = new FileLoadRunnable(window);
-
- // run load dialog in gui thread.
-
- if (Thread.currentThread() != display.getThread()) {
- display.syncExec(fileLoader);
- } else {
- fileLoader.run();
- }
-
- // return loaded file data
-
- Data[] loadedFileData = extractLoadedFileData(fileLoader);
- return loadedFileData;
- }
-
- final class FileLoadRunnable implements Runnable {
- boolean loadFileSuccess = false;
- IWorkbenchWindow window;
-
- // this is how we return values from the runnable
- public ArrayList loadedFiles_ReturnParameter = new ArrayList();
-
- FileLoadRunnable(IWorkbenchWindow window) {
- this.window = window;
- }
-
- /*
- * Let the user chose which file to load,
- * Let the user choose the file type (if it is ambiguous),
- * and then actually load and validate the file.
- */
- public void run() {
- try {
- // Prepare to ask the user which file to load.
-
- FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN);
- File currentDir = new File(defaultLoadDirectory);
- String absolutePath = currentDir.getAbsolutePath();
- dialog.setFilterPath(absolutePath);
- dialog.setText("Select a File");
-
- // Determine which file to load.
-
- String nameOfFileToLoad = dialog.open();
- if (nameOfFileToLoad == null) {
- return;
- }
-
- // Actually load the file.
-
- File file = new File(nameOfFileToLoad);
-
- if (file.isDirectory()) {
- defaultLoadDirectory = file.getAbsolutePath();
- } else {
- defaultLoadDirectory = file.getParentFile().getAbsolutePath();
- }
-
- //Validate the loaded file, "casting" it to a certain MIME type.
-
- // Extract the file's file extension.
-
- String fileExtension = getFileExtension(file).toLowerCase();
-
- // Get all the validators which support this file extension...
-
- ServiceReference[] supportingValidators = getSupportingValidators(fileExtension);
-
- // If there are no supporting validators...
- if (supportingValidators.length == 0) {
- // Let the user choose from all the validators available.
-
- ServiceReference[] allValidators = getAllValidators();
-
- new FileFormatSelector("Load", file, window.getShell(),
- ciShellContext, bundleContext, allValidators,
- loadedFiles_ReturnParameter).open();
- }
-
- // If there is just one supporting validator...
- if (supportingValidators.length == 1) {
- // Just use that validator to validate the file.
-
- ServiceReference onlyPossibleValidator = supportingValidators[0];
- AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext
- .getService(onlyPossibleValidator);
- Data[] outputDataAfterValidation;
- Data[] inputDataForValidation = new Data[] { new BasicData(
- file.getPath(), String.class.getName()) };
- outputDataAfterValidation = selectedValidatorExecutor
- .createAlgorithm(inputDataForValidation, null,
- ciShellContext).execute();
-
- /*
- * outputDataAfterValidation = null implies that file
- * was not loaded properly.
- */
-
- if (outputDataAfterValidation != null) {
- loadFileSuccess = true;
- logger.log(LogService.LOG_INFO, "Loaded: "
- + file.getPath());
- for (int i = 0; i < outputDataAfterValidation.length; i++) {
- Data data = outputDataAfterValidation[i];
- relabelWithFilename(data, file);
- loadedFiles_ReturnParameter.add(data);
- }
- }
- }
-
- // If there is more than one supporting validator...
- if (supportingValidators.length > 1) {
- // Let the user choose which validator they want to use.
-
- new FileFormatSelector("Load", file, window.getShell(),
- ciShellContext, bundleContext, supportingValidators,
- loadedFiles_ReturnParameter).open();
- }
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-
-
- private ServiceReference[] getSupportingValidators(String fileExtension) {
- try {
- String ldapQuery = "(& (type=validator)" +
- "(|" +
- "(in_data=file-ext:" + fileExtension + ")" +
- "(also_validates=" + fileExtension + ")" +
- "))";
-
- ServiceReference[] supportingValidators =
- bundleContext.getAllServiceReferences(
- AlgorithmFactory.class.getName(),
- ldapQuery);
-
-
- if (supportingValidators == null) {
- //(better to return a list of length zero than null)
- supportingValidators = new ServiceReference[]{};
- }
-
- return supportingValidators;
-
-
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- return new ServiceReference[]{};
- }
- }
-
- private ServiceReference[] getAllValidators() {
- try {
- ServiceReference[] allValidators =
- bundleContext.getAllServiceReferences(
- AlgorithmFactory.class.getName(),
- "(&(type=validator)(in_data=file-ext:*))");
-
- if (allValidators == null) {
- //(better to return a list of length zero than null)
- allValidators = new ServiceReference[]{};
- }
-
- return allValidators;
-
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- return new ServiceReference[]{};
- }
- }
-
- public String getFileExtension(File theFile) {
- String fileName = theFile.getName();
- String extension;
- if (fileName.lastIndexOf(".") != -1)
- extension = fileName.substring(fileName.lastIndexOf(".") + 1);
- else
- extension = "";
- return extension;
- }
- }
-
- private IWorkbenchWindow getFirstWorkbenchWindow()
- throws AlgorithmExecutionException {
- final IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
- .getWorkbenchWindows();
- if (windows.length == 0) {
- throw new AlgorithmExecutionException(
- "Cannot obtain workbench window needed to open dialog.");
- } else {
- return windows[0];
- }
- }
-
- private Data[] extractLoadedFileData(FileLoadRunnable dataUpdater)
- throws AlgorithmExecutionException {
- Data[] loadedFileData;
- try {
- if (!dataUpdater.loadedFiles_ReturnParameter.isEmpty()) {
- int size = dataUpdater.loadedFiles_ReturnParameter.size();
- loadedFileData = new Data[size];
- for (int index = 0; index < size; index++) {
- loadedFileData[index] = (Data) dataUpdater.loadedFiles_ReturnParameter
- .get(index);
- }
- return loadedFileData;
- } else {
- this.logger
- .log(LogService.LOG_WARNING, "File loading canceled");
- return new Data[0];
- }
- } catch (Throwable e2) {
- throw new AlgorithmExecutionException(e2);
- }
- }
-}
\ No newline at end of file
Copied: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java (from rev 1041, trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java)
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -0,0 +1,98 @@
+package org.cishell.reference.gui.persistence.load;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Dictionary;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmExecutionException;
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.algorithm.ProgressMonitor;
+import org.cishell.framework.algorithm.ProgressTrackable;
+import org.cishell.framework.data.Data;
+import org.cishell.utilities.StringUtilities;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class FileLoadAlgorithm implements Algorithm, ProgressTrackable {
+ public static final String LOAD_DIRECTORY_PREFERENCE_KEY = "loadDir";
+
+ public static String defaultLoadDirectory;
+
+ private final LogService logger;
+ private BundleContext bundleContext;
+ private CIShellContext ciShellContext;
+ private ProgressMonitor progressMonitor = ProgressMonitor.NULL_MONITOR;
+
+ public FileLoadAlgorithm(
+ CIShellContext ciShellContext,
+ BundleContext bundleContext,
+ Dictionary<String, Object> preferences) {
+ this.logger = (LogService)ciShellContext.getService(LogService.class.getName());
+ this.ciShellContext = ciShellContext;
+ this.bundleContext = bundleContext;
+
+ // This is not done upon declaration because the preference service may not have started.
+ if (FileLoadAlgorithm.defaultLoadDirectory == null) {
+ FileLoadAlgorithm.defaultLoadDirectory = determineDefaultLoadDirectory(preferences);
+ }
+ }
+
+ public Data[] execute() throws AlgorithmExecutionException {
+ // Prepare to run load dialog in GUI thread.
+
+ IWorkbenchWindow window = getFirstWorkbenchWindow();
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ FileLoadUserInputRunnable userInputGetter = new FileLoadUserInputRunnable(
+ window, this.bundleContext, this.ciShellContext);
+
+ // Run load dialog in GUI thread.
+
+ if (Thread.currentThread() != display.getThread()) {
+ display.syncExec(userInputGetter);
+ } else {
+ userInputGetter.run();
+ }
+
+ // Return loaded file data.
+
+ File file = userInputGetter.getFile();
+ AlgorithmFactory validator = userInputGetter.getValidator();
+
+ if ((file == null) || (validator == null)) {
+ String logMessage = "File loading canceled";
+ this.logger.log(LogService.LOG_WARNING, logMessage);
+
+ return null;
+ } else {
+ return FileValidator.validateFile(file, validator, this.ciShellContext, this.logger);
+ }
+ }
+
+ public ProgressMonitor getProgressMonitor() {
+ return this.progressMonitor;
+ }
+
+ public void setProgressMonitor(ProgressMonitor progressMonitor) {
+ this.progressMonitor = progressMonitor;
+ }
+
+ private static String determineDefaultLoadDirectory(Dictionary<String, Object> preferences) {
+ return StringUtilities.emptyStringIfNull(preferences.get(LOAD_DIRECTORY_PREFERENCE_KEY));
+ }
+
+ private static IWorkbenchWindow getFirstWorkbenchWindow() throws AlgorithmExecutionException {
+ final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+
+ if (windows.length == 0) {
+ throw new AlgorithmExecutionException(
+ "Cannot obtain workbench window needed to open dialog.");
+ } else {
+ return windows[0];
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -12,19 +12,17 @@
import org.osgi.service.cm.ManagedService;
import org.osgi.service.component.ComponentContext;
-/*
- * @author Weixia(Bonnie) Huang (hu...@in...)
- */
public class FileLoadFactory implements AlgorithmFactory, ManagedService {
- private BundleContext bcontext;
+ private BundleContext bundleContext;
private Dictionary properties = new Hashtable();
- protected void activate(ComponentContext ctxt) {
- bcontext = ctxt.getBundleContext();
+ protected void activate(ComponentContext componentContext) {
+ bundleContext = componentContext.getBundleContext();
}
- public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) {
- return new FileLoad(context, bcontext, properties);
+ public Algorithm createAlgorithm(
+ Data[] data, Dictionary parameters, CIShellContext ciShellContext) {
+ return new FileLoadAlgorithm(ciShellContext, this.bundleContext, this.properties);
}
public void updated(Dictionary properties) throws ConfigurationException {
@@ -35,18 +33,18 @@
}
// private void printPreferences(Dictionary properties) {
-// System.out.println(" Preferences are as follows for File Load:");
-// if (properties == null) {
-// System.out.println(" Dictionary is null!");
-// } else {
-// Enumeration propertiesKeys = properties.keys();
+// System.out.println(" Preferences are as follows for File Load:");
+// if (properties == null) {
+// System.out.println(" Dictionary is null!");
+// } else {
+// Enumeration propertiesKeys = properties.keys();
+//
+// while (propertiesKeys.hasMoreElements()) {
+// String propertiesKey = (String) propertiesKeys.nextElement();
//
-// while (propertiesKeys.hasMoreElements()) {
-// String propertiesKey = (String) propertiesKeys.nextElement();
-//
-// Object propertiesValue = properties.get(propertiesKey);
-// System.out.println(" " + propertiesKey + ":" + propertiesValue);
-// }
+// Object propertiesValue = properties.get(propertiesKey);
+// System.out.println(" " + propertiesKey + ":" + propertiesValue);
// }
// }
+// }
}
\ No newline at end of file
Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadUserInputRunnable.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -0,0 +1,147 @@
+package org.cishell.reference.gui.persistence.load;
+
+import java.io.File;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.utilities.FileUtilities;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+public final class FileLoadUserInputRunnable implements Runnable {
+ private IWorkbenchWindow window;
+ private BundleContext bundleContext;
+ private CIShellContext ciShellContext;
+ private File file;
+ private AlgorithmFactory validator;
+
+ public FileLoadUserInputRunnable(
+ IWorkbenchWindow window, BundleContext bundleContext, CIShellContext ciShellContext) {
+ this.window = window;
+ this.bundleContext = bundleContext;
+ this.ciShellContext = ciShellContext;
+ }
+
+ public File getFile() {
+ return this.file;
+ }
+
+ public AlgorithmFactory getValidator() {
+ return this.validator;
+ }
+
+ public void run() {
+ this.file = getFileFromUser();
+
+ if (file == null) {
+ return;
+ } else if (this.file.isDirectory()) {
+ FileLoadAlgorithm.defaultLoadDirectory = this.file.getAbsolutePath();
+ } else {
+ FileLoadAlgorithm.defaultLoadDirectory = this.file.getParentFile().getAbsolutePath();
+ }
+
+ // Validate the loaded file, "casting" it to a certain MIME type.
+
+ // Extract the file's file extension.
+
+ String fileExtension =
+ FileUtilities.getFileExtension(this.file).toLowerCase().substring(1);
+
+ // TODO split here?
+
+ // Get all the validators which support this file extension...
+
+ ServiceReference[] supportingValidators = getSupportingValidators(fileExtension);
+
+ // If there are no supporting validators...
+ if (supportingValidators.length == 0) {
+ // Let the user choose from all the validators available.
+
+ ServiceReference[] allValidators = getAllValidators();
+
+ FileFormatSelector validatorSelector = new FileFormatSelector(
+ "Load", window.getShell(), this.bundleContext, allValidators);
+ validatorSelector.open();
+ this.validator = validatorSelector.getValidator();
+ } else if (supportingValidators.length == 1) {
+ ServiceReference onlyPossibleValidator = supportingValidators[0];
+ this.validator =
+ (AlgorithmFactory)this.bundleContext.getService(onlyPossibleValidator);
+ }
+
+ if (supportingValidators.length > 1) {
+ FileFormatSelector validatorSelector = new FileFormatSelector(
+ "Load", window.getShell(), this.bundleContext, supportingValidators);
+ validatorSelector.open();
+ this.validator = validatorSelector.getValidator();
+ }
+ }
+
+ private File getFileFromUser() {
+ FileDialog fileDialog = createFileDialog();
+ String fileName = fileDialog.open();
+
+ if (fileName == null) {
+ return null;
+ } else {
+ return new File(fileName);
+ }
+ }
+
+ private FileDialog createFileDialog() {
+ File currentDirectory = new File(FileLoadAlgorithm.defaultLoadDirectory);
+ String absolutePath = currentDirectory.getAbsolutePath();
+ FileDialog fileDialog = new FileDialog(this.window.getShell(), SWT.OPEN);
+ fileDialog.setFilterPath(absolutePath);
+ fileDialog.setText("Select a File");
+
+ return fileDialog;
+ }
+
+ private ServiceReference[] getSupportingValidators(String fileExtension) {
+ try {
+ String validatorsQuery =
+ "(& (type=validator)" +
+ "(|" +
+ "(in_data=file-ext:" + fileExtension + ")" +
+ "(also_validates=" + fileExtension + ")" +
+ "))";
+
+ ServiceReference[] supportingValidators = this.bundleContext.getAllServiceReferences(
+ AlgorithmFactory.class.getName(), validatorsQuery);
+
+ if (supportingValidators == null) {
+ return new ServiceReference[0];
+ } else {
+ return supportingValidators;
+ }
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+
+ return new ServiceReference[]{};
+ }
+ }
+
+ private ServiceReference[] getAllValidators() {
+ try {
+ String validatorsQuery = "(&(type=validator)(in_data=file-ext:*))";
+ ServiceReference[] allValidators = this.bundleContext.getAllServiceReferences(
+ AlgorithmFactory.class.getName(), validatorsQuery);
+
+ if (allValidators == null) {
+ return new ServiceReference[0];
+ } else {
+ return allValidators;
+ }
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+
+ return new ServiceReference[0];
+ }
+ }
+}
\ No newline at end of file
Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileValidator.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -0,0 +1,36 @@
+package org.cishell.reference.gui.persistence.load;
+
+import java.io.File;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.AlgorithmExecutionException;
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.data.BasicData;
+import org.cishell.framework.data.Data;
+import org.osgi.service.log.LogService;
+
+public final class FileValidator {
+ public static Data[] validateFile(
+ File file,
+ AlgorithmFactory validator,
+ CIShellContext ciShellContext,
+ LogService logger) throws AlgorithmExecutionException {
+ Data[] validationData =
+ new Data[] { new BasicData(file.getPath(), String.class.getName()) };
+ Data[] validatedData = validator.createAlgorithm(
+ validationData, null, ciShellContext).execute();
+
+ if (validatedData != null) {
+ logger.log(LogService.LOG_INFO, "Loaded: " + file.getPath());
+ }
+
+ return validatedData;
+// } catch (AlgorithmExecutionException e) {
+// String logMessage =
+// "An error occurred while attempting to load your file " +
+// "with the format you chose.";
+// this.logger.log(LogService.LOG_ERROR, logMessage, e);
+// this.thrownException = e;
+// }
+ }
+}
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java 2010-05-28 18:18:24 UTC (rev 1067)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java 2010-05-28 18:53:00 UTC (rev 1068)
@@ -69,13 +69,8 @@
programCsv = Program.findProgram("csv");
}});
-
- //TODO: what the hell?
- System.err.println(definition.getID());
String[] defValStringArray = null; //doesn't actually work yet...
- //String[] myOptionLabels = new String[] {programTxt.getName(),programDoc.getName(),programHtml.getName()};
- //String[] myOptionValues = new String[] {"txt","doc","html"};
int possiblePrograms = 0;
int counter = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-05-28 18:18:30
|
Revision: 1067
http://cishell.svn.sourceforge.net/cishell/?rev=1067&view=rev
Author: pataphil
Date: 2010-05-28 18:18:24 +0000 (Fri, 28 May 2010)
Log Message:
-----------
* Added AlgorithmUtilities.executeAlgorithm().
* Basically reviewed by Joseph.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-05-26 16:41:47 UTC (rev 1066)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2010-05-28 18:18:24 UTC (rev 1067)
@@ -3,6 +3,9 @@
import java.io.File;
import java.util.Dictionary;
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
@@ -116,4 +119,18 @@
return guessSourceDataFilename(parent);
}
}
+
+ @SuppressWarnings("unchecked") // Dictionary<String, Object>
+ public static Data[] executeAlgorithm(
+ AlgorithmFactory algorithmFactory,
+ Dictionary parameters,
+ CIShellContext ciShellContext,
+ Data[] data)
+ throws AlgorithmExecutionException {
+ Algorithm algorithm =
+ algorithmFactory.createAlgorithm(data, parameters, ciShellContext);
+ Data[] result = algorithm.execute();
+
+ return result;
+ }
}
\ 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: <fu...@us...> - 2010-05-26 16:41:53
|
Revision: 1066
http://cishell.svn.sourceforge.net/cishell/?rev=1066&view=rev
Author: fugu13
Date: 2010-05-26 16:41:47 +0000 (Wed, 26 May 2010)
Log Message:
-----------
Eliminate spaces at the beginnings (and ends) of filenames for saving.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 20:32:48 UTC (rev 1065)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-05-26 16:41:47 UTC (rev 1066)
@@ -431,7 +431,7 @@
String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex);
- return fileNameWithoutExtension;
+ return fileNameWithoutExtension.trim(); //no spaces on either end
}
public static String extractFileNameWithExtension(String fileLabel) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2010-03-26 20:32:54
|
Revision: 1065
http://cishell.svn.sourceforge.net/cishell/?rev=1065&view=rev
Author: fugu13
Date: 2010-03-26 20:32:48 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
Make small change that might fix Katy's problem w/ the load paths.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-03-26 20:12:06 UTC (rev 1064)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-03-26 20:32:48 UTC (rev 1065)
@@ -1,6 +1,7 @@
package org.cishell.reference.gui.persistence.load;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Dictionary;
@@ -52,8 +53,18 @@
}
protected static void relabelWithFilename(Data data, File file) {
- File absoluteFile = file.getAbsoluteFile();
- File parent = absoluteFile.getParentFile();
+ File absoluteFile;
+ try {
+ absoluteFile = file.getCanonicalFile();
+ } catch (IOException e) {
+ absoluteFile = file.getAbsoluteFile();
+ }
+ File parent;
+ try {
+ parent = absoluteFile.getParentFile().getCanonicalFile();
+ } catch (IOException e) {
+ parent = absoluteFile.getParentFile().getAbsoluteFile();
+ }
String prefix;
String parentName = parent.getName();
if(parentName.trim().length() == 0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-03-26 20:12:13
|
Revision: 1064
http://cishell.svn.sourceforge.net/cishell/?rev=1064&view=rev
Author: pataphil
Date: 2010-03-26 20:12:06 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
* Added FileUtilities.extractFileNameWithExtension.
* Added JodaDateUtilities.
* Not reviewed.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF
trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
Added Paths:
-----------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/JodaDateUtilities.java
Modified: trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF 2010-03-26 18:08:35 UTC (rev 1063)
+++ trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF 2010-03-26 20:12:06 UTC (rev 1064)
@@ -12,6 +12,13 @@
org.cishell.framework.data,
org.cishell.reference.service.metatype,
org.cishell.service.database,
+ org.joda.time,
+ org.joda.time.base,
+ org.joda.time.chrono,
+ org.joda.time.convert,
+ org.joda.time.field,
+ org.joda.time.format,
+ org.joda.time.tz,
org.osgi.framework;version="1.4.0",
org.osgi.service.log;version="1.3.0",
org.osgi.service.metatype;version="1.1.0",
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 18:08:35 UTC (rev 1063)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 20:12:06 UTC (rev 1064)
@@ -433,4 +433,8 @@
return fileNameWithoutExtension;
}
+
+ public static String extractFileNameWithExtension(String fileLabel) {
+ return extractFileName(fileLabel) + getFileExtension(fileLabel);
+ }
}
\ No newline at end of file
Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/JodaDateUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/JodaDateUtilities.java (rev 0)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/JodaDateUtilities.java 2010-03-26 20:12:06 UTC (rev 1064)
@@ -0,0 +1,22 @@
+package org.cishell.utilities;
+
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+public class JodaDateUtilities {
+ public static String easyDateTimeFormat(String format) {
+ DateTime currentDateAndTime = new DateTime();
+ DateTimeFormatter formatter = DateTimeFormat.forPattern(format);
+
+ return formatter.print(currentDateAndTime);
+ }
+
+ public static String easyDateFormat() {
+ return easyDateTimeFormat("MMM dd, yyyy");
+ }
+
+ public static String easyDateAndTimeFormat() {
+ return easyDateTimeFormat("MMM dd, yyyy; hh:mmaa");
+ }
+}
\ 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: <fu...@us...> - 2010-03-26 18:08:41
|
Revision: 1063
http://cishell.svn.sourceforge.net/cishell/?rev=1063&view=rev
Author: fugu13
Date: 2010-03-26 18:08:35 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
Uses the ones in FileUtilities now.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2010-03-26 18:03:14 UTC (rev 1062)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2010-03-26 18:08:35 UTC (rev 1063)
@@ -1,138 +0,0 @@
-package org.cishell.reference.gui.persistence;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.osgi.service.log.LogService;
-
-public class FileUtil {
- public static final char FILENAME_CHARACTER_REPLACEMENT = '#';
-
- /* Attempt to enumerate characters which cannot be used to name a file.
- * For our purposes, this should be as aggressive as sensible.
- * This includes all such characters for modern Windows systems, plus %.
- * Please add any others.
- */
- public static final Collection INVALID_FILENAME_CHARACTERS;
- static {
- Collection s = new HashSet();
- s.add(new Character('\\'));
- s.add(new Character('/'));
- s.add(new Character(':'));
- s.add(new Character('*'));
- s.add(new Character('?'));
- s.add(new Character('"'));
- s.add(new Character('<'));
- s.add(new Character('>'));
- s.add(new Character('|'));
- s.add(new Character('%'));
- INVALID_FILENAME_CHARACTERS = Collections.unmodifiableCollection(s);
- }
-
- private static int uniqueIntForTempFile = 1;
-
- public static File getTempFile(String fileName, String extension, LogService logger) {
- File tempFile;
-
- if (fileName == null || fileName.equals("")) {
- fileName = "unknown";
- }
-
- if (extension == null || extension.equals("")) {
- extension = ".txt";
- }
-
- if (!extension.startsWith(".")) {
- extension = extension + ".";
- }
-
- String tempPath = System.getProperty("java.io.tmpdir");
- File tempDir = new File(tempPath+File.separator+"nwb");
- if(!tempDir.exists())
- tempDir.mkdir();
- try{
- tempFile = File.createTempFile(fileName, extension, tempDir);
-
- }catch (IOException e1){
- //failed with given file name and extension. Let's use a standard one.
- logger.log(LogService.LOG_WARNING, "Failed to create temp file with provided name and extension '" + fileName + extension + "'. Trying a generic name and extension instead.", e1);
- try {
- tempFile = File.createTempFile("unknown", ".txt", tempDir);
- } catch (IOException e2) {
- //looks like it doesn't even like that. We'll have to just make a file directly.
- tempFile = new File (tempPath+File.separator+"nwb"+File.separator+"unknown" + uniqueIntForTempFile + ".txt");
- uniqueIntForTempFile++;
-
- logger.log(LogService.LOG_ERROR, "Failed to create temp file twice...");
- logger.log(LogService.LOG_ERROR, "First Try... \r\n " + e1.toString());
- logger.log(LogService.LOG_ERROR, "Second Try... \r\n " + e2.toString());
- }
- }
- return tempFile;
- }
-
- public static String extractExtension(String format) {
- String extension = "";
- /* TODO: We should really have explicit piece of metadata that says what
- * the extension is, as this method is not guaranteed to yield the
- * correct extension.
- */
- if (format.startsWith("file:text/")) {
- extension = "." + format.substring("file:text/".length());
- } else if (format.startsWith("file-ext:")) {
- extension = "." + format.substring("file-ext:".length());
- }
-
- extension = extension.replace('+', '.');
-
- return extension;
- }
-
- public static String replaceInvalidFilenameCharacters(String filename) {
- String cleanedFilename = filename;
-
- for (Iterator invalidCharacters = INVALID_FILENAME_CHARACTERS.iterator();
- invalidCharacters.hasNext();) {
- char invalidCharacter = ((Character) invalidCharacters.next()).charValue();
-
- cleanedFilename =
- cleanedFilename.replace(invalidCharacter, FILENAME_CHARACTER_REPLACEMENT);
- }
-
- return cleanedFilename;
- }
-
- public static String extractFileName(String fileLabel) {
- //index variables will be -1 if index is not found.
- int descriptionEndIndex = fileLabel.lastIndexOf(":");
- int filePathEndIndex = fileLabel.lastIndexOf(File.separator);
-
- //doesn't matter if either variable is -1, since startIndex will be
- //zero and none of the string will be cut off the front.
- int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1;
-
- String fileNameWithExtension = fileLabel.substring(startIndex);
-
- //find the first character of the file name extension.
- int extensionBeginIndex = fileNameWithExtension.lastIndexOf(".");
-
- int endIndex;
-
- if (extensionBeginIndex != -1) {
- //we found a period in the file name.
- endIndex = extensionBeginIndex; //cut off everything after
- //first period.
- } else {
- //we didn't find an extension on the file name.
- endIndex = fileNameWithExtension.length(); // don't cut any off the end.
- }
-
- String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex);
-
- return fileNameWithoutExtension;
- }
-}
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2010-03-26 18:03:14 UTC (rev 1062)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2010-03-26 18:08:35 UTC (rev 1063)
@@ -13,10 +13,10 @@
import org.cishell.framework.algorithm.AlgorithmProperty;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
-import org.cishell.reference.gui.persistence.FileUtil;
import org.cishell.service.conversion.ConversionException;
import org.cishell.service.conversion.Converter;
import org.cishell.service.guibuilder.GUIBuilderService;
+import org.cishell.utilities.FileUtilities;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
@@ -118,9 +118,9 @@
dialog.setText("Choose File");
String fileLabel = (String)data.getMetadata().get(DataProperty.LABEL);
- String suggestedFileName = FileUtil.extractFileName(fileLabel);
+ String suggestedFileName = FileUtilities.extractFileName(fileLabel);
String cleanedSuggestedFileName =
- FileUtil.replaceInvalidFilenameCharacters(suggestedFileName);
+ FileUtilities.replaceInvalidFilenameCharacters(suggestedFileName);
dialog.setFileName(cleanedSuggestedFileName + "." + ext);
// if (fileLabel == null) {
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-03-26 18:03:14 UTC (rev 1062)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-03-26 18:08:35 UTC (rev 1063)
@@ -6,7 +6,6 @@
import org.cishell.framework.CIShellContext;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
-import org.cishell.reference.gui.persistence.FileUtil;
import org.cishell.reference.gui.persistence.view.core.exceptiontypes.ConvertDataForViewingException;
import org.cishell.reference.gui.persistence.view.core.exceptiontypes.FileViewingException;
import org.cishell.reference.gui.persistence.view.core.exceptiontypes.NoProgramFoundException;
@@ -251,7 +250,7 @@
FILE_EXTENSION_MIME_TYPE_PREFIX + fileExtension;
File convertedFile = convertToFile(
originalData, fileExtensionMimeType, converterManager);
- String fileName = FileUtil.extractFileName(dataLabel);
+ String fileName = FileUtilities.extractFileName(dataLabel);
return FileUtilities.createTemporaryFileCopy(
convertedFile, fileName, fileExtension);
@@ -279,8 +278,8 @@
String dataLabel =
(String)originalData.getMetadata().get(DataProperty.LABEL);
String dataFormat = originalData.getFormat();
- String fileName = FileUtil.extractFileName(dataLabel);
- String fileExtension = FileUtil.extractExtension(dataFormat);
+ String fileName = FileUtilities.extractFileName(dataLabel);
+ String fileExtension = FileUtilities.extractExtension(dataFormat);
try {
File fileToView = FileUtilities.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2010-03-26 18:03:21
|
Revision: 1062
http://cishell.svn.sourceforge.net/cishell/?rev=1062&view=rev
Author: fugu13
Date: 2010-03-26 18:03:14 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
Move some stuff here from persistence.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 16:30:23 UTC (rev 1061)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 18:03:14 UTC (rev 1062)
@@ -15,9 +15,15 @@
import java.net.URI;
import java.net.URL;
import java.nio.channels.FileChannel;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
import javax.imageio.ImageIO;
+import org.osgi.service.log.LogService;
+
public class FileUtilities {
public static final int READ_TEXT_FILE_BUFFER_SIZE = 1024;
public static final String DEFAULT_STREAM_TO_FILE_NAME = "stream_";
@@ -301,4 +307,130 @@
return directory;
}
+
+public static final char FILENAME_CHARACTER_REPLACEMENT = '#';
+
+ /* Attempt to enumerate characters which cannot be used to name a file.
+ * For our purposes, this should be as aggressive as sensible.
+ * This includes all such characters for modern Windows systems, plus %.
+ * Please add any others.
+ */
+ public static final Collection INVALID_FILENAME_CHARACTERS;
+ static {
+ Collection s = new HashSet();
+ s.add(new Character('\\'));
+ s.add(new Character('/'));
+ s.add(new Character(':'));
+ s.add(new Character('*'));
+ s.add(new Character('?'));
+ s.add(new Character('"'));
+ s.add(new Character('<'));
+ s.add(new Character('>'));
+ s.add(new Character('|'));
+ s.add(new Character('%'));
+ INVALID_FILENAME_CHARACTERS = Collections.unmodifiableCollection(s);
+ }
+
+ private static int uniqueIntForTempFile = 1;
+
+ public static File getTempFile(String fileName, String extension, LogService logger) {
+ File tempFile;
+
+ if (fileName == null || fileName.equals("")) {
+ fileName = "unknown";
+ }
+
+ if (extension == null || extension.equals("")) {
+ extension = ".txt";
+ }
+
+ if (!extension.startsWith(".")) {
+ extension = extension + ".";
+ }
+
+ String tempPath = System.getProperty("java.io.tmpdir");
+ File tempDir = new File(tempPath+File.separator+"nwb");
+ if(!tempDir.exists())
+ tempDir.mkdir();
+ try{
+ tempFile = File.createTempFile(fileName, extension, tempDir);
+
+ }catch (IOException e1){
+ //failed with given file name and extension. Let's use a standard one.
+ logger.log(LogService.LOG_WARNING, "Failed to create temp file with provided name and extension '" + fileName + extension + "'. Trying a generic name and extension instead.", e1);
+ try {
+ tempFile = File.createTempFile("unknown", ".txt", tempDir);
+ } catch (IOException e2) {
+ //looks like it doesn't even like that. We'll have to just make a file directly.
+ tempFile = new File (tempPath+File.separator+"nwb"+File.separator+"unknown" + uniqueIntForTempFile + ".txt");
+ uniqueIntForTempFile++;
+
+ logger.log(LogService.LOG_ERROR, "Failed to create temp file twice...");
+ logger.log(LogService.LOG_ERROR, "First Try... \r\n " + e1.toString());
+ logger.log(LogService.LOG_ERROR, "Second Try... \r\n " + e2.toString());
+ }
+ }
+ return tempFile;
+ }
+
+ public static String extractExtension(String format) {
+ String extension = "";
+ /* TODO: We should really have explicit piece of metadata that says what
+ * the extension is, as this method is not guaranteed to yield the
+ * correct extension.
+ */
+ if (format.startsWith("file:text/")) {
+ extension = "." + format.substring("file:text/".length());
+ } else if (format.startsWith("file-ext:")) {
+ extension = "." + format.substring("file-ext:".length());
+ }
+
+ extension = extension.replace('+', '.');
+
+ return extension;
+ }
+
+ public static String replaceInvalidFilenameCharacters(String filename) {
+ String cleanedFilename = filename;
+
+ for (Iterator invalidCharacters = INVALID_FILENAME_CHARACTERS.iterator();
+ invalidCharacters.hasNext();) {
+ char invalidCharacter = ((Character) invalidCharacters.next()).charValue();
+
+ cleanedFilename =
+ cleanedFilename.replace(invalidCharacter, FILENAME_CHARACTER_REPLACEMENT);
+ }
+
+ return cleanedFilename;
+ }
+
+ public static String extractFileName(String fileLabel) {
+ //index variables will be -1 if index is not found.
+ int descriptionEndIndex = fileLabel.lastIndexOf(":");
+ int filePathEndIndex = fileLabel.lastIndexOf(File.separator);
+
+ //doesn't matter if either variable is -1, since startIndex will be
+ //zero and none of the string will be cut off the front.
+ int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1;
+
+ String fileNameWithExtension = fileLabel.substring(startIndex);
+
+ //find the first character of the file name extension.
+ int extensionBeginIndex = fileNameWithExtension.lastIndexOf(".");
+
+ int endIndex;
+
+ if (extensionBeginIndex != -1) {
+ //we found a period in the file name.
+ endIndex = extensionBeginIndex; //cut off everything after
+ //first period.
+ } else {
+ //we didn't find an extension on the file name.
+ endIndex = fileNameWithExtension.length(); // don't cut any off the end.
+ }
+
+ String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex);
+
+ return fileNameWithoutExtension;
+ }
}
\ 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...> - 2010-03-26 16:30:29
|
Revision: 1061
http://cishell.svn.sourceforge.net/cishell/?rev=1061&view=rev
Author: jrbibers
Date: 2010-03-26 16:30:23 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
http://cns-jira.slis.indiana.edu/browse/SCISQUARED-121
Reviewed by Russell.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2010-03-26 15:32:11 UTC (rev 1060)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2010-03-26 16:30:23 UTC (rev 1061)
@@ -135,13 +135,4 @@
return fileNameWithoutExtension;
}
-
- public static void main(String[] args) {
-// String s = "Input data: CSV file: C:\\Documents and Settings\\katy\\Desktop\\NIH-Demo\\nih\\NIH-data\\NIH-NIGMS-PPBC-R01s,-FY08-Publications.csv";
- String s = "a\\b/c:d*e?f\"g<h>i|j";
-
- System.out.println(replaceInvalidFilenameCharacters(s));
-
- System.exit(0);
- }
}
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-03-26 15:32:11 UTC (rev 1060)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-03-26 16:30:23 UTC (rev 1061)
@@ -31,7 +31,7 @@
public static final String ANY_MIME_TYPE = "file:";
public static final String CSV_FILE_EXT = "file-ext:csv";
public static final String CSV_MIME_TYPE = "file:text/csv";
- public static final String TEMPORARY_CSV_FILE_NAME = "xxx-Session-";
+ public static final String TEMPORARY_CSV_FILE_NAME = "CSV-";
public static final String CSV_FILE_EXTENSION = "csv";
public static final String TXT_FILE_EXTENSION = "txt";
public static final String ANY_FILE_FORMAT_PATTERN =
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 15:32:11 UTC (rev 1060)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2010-03-26 16:30:23 UTC (rev 1061)
@@ -45,7 +45,7 @@
try {
temporaryFile =
- File.createTempFile("NWB-Session-" + temporaryFileName,
+ File.createTempFile(temporaryFileName,
"." + temporaryFileExtension,
temporaryDirectory);
}
@@ -120,7 +120,7 @@
String temporaryDirectoryPath = getDefaultTemporaryDirectory();
File temporaryImageFile =
createTemporaryFileInTemporaryDirectory(temporaryDirectoryPath,
- "nwb-temp",
+ "image-",
imageType);
// Attempt to write the image to the temporary file on disk.
@@ -140,7 +140,7 @@
String temporaryDirectoryPath = getDefaultTemporaryDirectory();
File temporaryTextFile =
createTemporaryFileInTemporaryDirectory(temporaryDirectoryPath,
- "nwb-temp",
+ "text-",
fileExtension);
FileWriter textFileWriter = new FileWriter(temporaryTextFile);
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2010-03-26 15:32:11 UTC (rev 1060)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2010-03-26 16:30:23 UTC (rev 1061)
@@ -486,7 +486,7 @@
if(!tempDir.exists())
tempDir.mkdir();
try{
- tempFile = File.createTempFile("NWB-Session-", ".nwb", tempDir);
+ tempFile = File.createTempFile("ConverterTester-", ".nwb", tempDir);
}catch (IOException e){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2010-03-26 15:32:17
|
Revision: 1060
http://cishell.svn.sourceforge.net/cishell/?rev=1060&view=rev
Author: fugu13
Date: 2010-03-26 15:32:11 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
Fix welcome text printing on OS X.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java
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 2010-03-25 22:46:11 UTC (rev 1059)
+++ trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogView.java 2010-03-26 15:32:11 UTC (rev 1060)
@@ -196,10 +196,7 @@
if (logService != null) {
try {
- String welcomeTextFilePath = CONFIGURATION_DIRECTORY +
- File.separator +
- WELCOME_TEXT_FILE_NAME;
- URL welcomeTextFileURL = new File(welcomeTextFilePath).toURL();
+ URL welcomeTextFileURL = new URL(new URL(System.getProperty("osgi.configuration.area")), WELCOME_TEXT_FILE_NAME);
Properties properties = new Properties();
properties.load(welcomeTextFileURL.openStream());
String greetingText =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2010-03-25 22:46:17
|
Revision: 1059
http://cishell.svn.sourceforge.net/cishell/?rev=1059&view=rev
Author: fugu13
Date: 2010-03-25 22:46:11 +0000 (Thu, 25 Mar 2010)
Log Message:
-----------
add TODO related to CME on startup
Modified Paths:
--------------
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java
Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2010-03-25 21:46:54 UTC (rev 1058)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2010-03-25 22:46:11 UTC (rev 1059)
@@ -60,6 +60,7 @@
System.setProperty("derby.system.home", DATABASE_DIRECTORY);
//Allow the database service to be found by other services/plugins
+ //TODO: figure out why this throws a concurrentmodificationerror on startup
databaseServiceRegistration = context.registerService(
DatabaseService.class.getName(), this, new Hashtable());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2010-03-25 21:47:00
|
Revision: 1058
http://cishell.svn.sourceforge.net/cishell/?rev=1058&view=rev
Author: fugu13
Date: 2010-03-25 21:46:54 +0000 (Thu, 25 Mar 2010)
Log Message:
-----------
File loading fixed up for demo, reviewed by Katy and Joseph.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2010-03-22 20:04:57 UTC (rev 1057)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2010-03-25 21:46:54 UTC (rev 1058)
@@ -13,6 +13,7 @@
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
+import org.cishell.framework.data.DataProperty;
import org.cishell.reference.gui.common.AbstractDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
@@ -206,7 +207,9 @@
this.logger.log(LogService.LOG_INFO, "Loaded: " + this.selectedFile.getPath());
for (int ii = 0; ii < data.length; ii++) {
- this.returnList.add(data[ii]);
+ Data dataItem = data[ii];
+ FileLoad.relabelWithFilename(dataItem, selectedFile);
+ this.returnList.add(dataItem);
}
close(true);
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-03-22 20:04:57 UTC (rev 1057)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-03-25 21:46:54 UTC (rev 1058)
@@ -10,6 +10,7 @@
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
+import org.cishell.framework.data.DataProperty;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
@@ -49,6 +50,19 @@
}
}
}
+
+ protected static void relabelWithFilename(Data data, File file) {
+ File absoluteFile = file.getAbsoluteFile();
+ File parent = absoluteFile.getParentFile();
+ String prefix;
+ String parentName = parent.getName();
+ if(parentName.trim().length() == 0) {
+ prefix = File.separator;
+ } else {
+ prefix = "..." + File.separator + parentName + File.separator;
+ }
+ data.getMetadata().put(DataProperty.LABEL, prefix + absoluteFile.getName());
+ }
public Data[] execute() throws AlgorithmExecutionException {
// prepare to run load dialog in GUI thread
@@ -158,9 +172,11 @@
loadFileSuccess = true;
logger.log(LogService.LOG_INFO, "Loaded: "
+ file.getPath());
- for (int i = 0; i < outputDataAfterValidation.length; i++)
- loadedFiles_ReturnParameter.
- add(outputDataAfterValidation[i]);
+ for (int i = 0; i < outputDataAfterValidation.length; i++) {
+ Data data = outputDataAfterValidation[i];
+ relabelWithFilename(data, file);
+ loadedFiles_ReturnParameter.add(data);
+ }
}
}
@@ -177,7 +193,9 @@
throw new RuntimeException(e);
}
}
+
+
private ServiceReference[] getSupportingValidators(String fileExtension) {
try {
String ldapQuery = "(& (type=validator)" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2010-03-22 20:05:04
|
Revision: 1057
http://cishell.svn.sourceforge.net/cishell/?rev=1057&view=rev
Author: pataphil
Date: 2010-03-22 20:04:57 +0000 (Mon, 22 Mar 2010)
Log Message:
-----------
* Mutate Parameter utilities now allow attributes to be explicitly ignored.
* Reviewed by Joseph.
Modified Paths:
--------------
trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java
trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/dropdown/DropdownMutator.java
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2010-03-19 22:38:14 UTC (rev 1056)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2010-03-22 20:04:57 UTC (rev 1057)
@@ -1,6 +1,7 @@
package org.cishell.utilities;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -154,7 +155,8 @@
}
};
- return ObjectClassDefinitionTransformer.apply(dropdownTransformer, oldOCD);
+ return ObjectClassDefinitionTransformer.apply(
+ dropdownTransformer, oldOCD, new ArrayList<String>());
}
public static BasicObjectClassDefinition mutateDefaultValue(
@@ -172,7 +174,8 @@
}
};
- return ObjectClassDefinitionTransformer.apply(transformer, oldOCD);
+ return ObjectClassDefinitionTransformer.apply(
+ transformer, oldOCD, new ArrayList<String>());
}
public static BasicObjectClassDefinition createNewParameters(
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java 2010-03-19 22:38:14 UTC (rev 1056)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java 2010-03-22 20:04:57 UTC (rev 1057)
@@ -1,6 +1,7 @@
package org.cishell.utilities.mutateParameter;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -30,7 +31,8 @@
*/
public static BasicObjectClassDefinition apply(
AttributeDefinitionTransformer transformer,
- ObjectClassDefinition oldOCD) {
+ ObjectClassDefinition oldOCD,
+ Collection<String> attributesToIgnore) {
BasicObjectClassDefinition newOCD =
MutateParameterUtilities.createNewParameters(oldOCD);
@@ -44,9 +46,10 @@
oldOCD.getAttributeDefinitions(filter);
for (int ii = 0; ii < oldADs.length; ii++) {
- newOCD.addAttributeDefinition(
- filter,
- transformer.transform(oldADs[ii]));
+ if (!attributesToIgnore.contains(oldADs[ii].getID())) {
+ newOCD.addAttributeDefinition(
+ filter, transformer.transform(oldADs[ii]));
+ }
}
}
@@ -55,14 +58,14 @@
// Convenience method for batching transformations.
public static ObjectClassDefinition transform(
- ObjectClassDefinition ocd, List transformers) {
+ ObjectClassDefinition ocd, List transformers, Collection<String> attributesToIgnore) {
ObjectClassDefinition newOCD = ocd;
for (Iterator it = transformers.iterator(); it.hasNext();) {
AttributeDefinitionTransformer transformer =
(AttributeDefinitionTransformer) it.next();
- newOCD = apply(transformer, newOCD);
+ newOCD = apply(transformer, newOCD, attributesToIgnore);
}
return newOCD;
Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/dropdown/DropdownMutator.java
===================================================================
--- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/dropdown/DropdownMutator.java 2010-03-19 22:38:14 UTC (rev 1056)
+++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/dropdown/DropdownMutator.java 2010-03-22 20:04:57 UTC (rev 1057)
@@ -2,8 +2,9 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.cishell.utilities.ArrayUtilities;
import org.cishell.utilities.mutateParameter.ObjectClassDefinitionTransformer;
@@ -19,13 +20,15 @@
*/
public class DropdownMutator {
private List transforms;
+ private Set<String> attributesToIgnore = new HashSet<String>();
public DropdownMutator() {
transforms = new ArrayList();
}
public ObjectClassDefinition mutate(ObjectClassDefinition ocd) {
- return ObjectClassDefinitionTransformer.transform(ocd, transforms);
+ return ObjectClassDefinitionTransformer.transform(
+ ocd, transforms, this.attributesToIgnore);
}
public void add(String id, List options, String defaultOption) {
@@ -36,20 +39,23 @@
add(id, options, options);
}
- public void add(String id,
- List optionLabels,
- String defaultOptionLabel,
- List optionValues,
- String defaultOptionValue) {
- add(id,
- swapToFront(optionLabels, defaultOptionLabel),
- swapToFront(optionValues, defaultOptionValue));
+ public void add(
+ String id,
+ List optionLabels,
+ String defaultOptionLabel,
+ List optionValues,
+ String defaultOptionValue) {
+ add(
+ id,
+ swapToFront(optionLabels, defaultOptionLabel),
+ swapToFront(optionValues, defaultOptionValue));
}
public void add(String id, List optionLabels, List optionValues) {
- add(id,
- (String[]) optionLabels.toArray(new String[0]),
- (String[]) optionValues.toArray(new String[0]));
+ add(
+ id,
+ (String[]) optionLabels.toArray(new String[0]),
+ (String[]) optionValues.toArray(new String[0]));
}
public void add(String id, String[] options, String defaultOption) {
@@ -60,34 +66,49 @@
add(id, options, options);
}
- public void add(final String id,
- final String[] optionLabels,
- String defaultOptionLabel,
- final String[] optionValues,
- String defaultOptionValue) {
- add(id,
+ public void add(
+ final String id,
+ final String[] optionLabels,
+ String defaultOptionLabel,
+ final String[] optionValues,
+ String defaultOptionValue) {
+ if (!shouldIgnore(id)) {
+ add(
+ id,
swapToFront(optionLabels, defaultOptionLabel),
swapToFront(optionValues, defaultOptionValue));
+ }
}
- public void add(final String id,
- final String[] optionLabels,
- final String[] optionValues) {
- transforms.add(
- new DefaultDropdownTransformer() {
- public boolean shouldTransform(AttributeDefinition ad) {
- return id.equals(ad.getID());
- }
-
- public String[] transformOptionLabels(String[] oldOptionLabels) {
- return optionLabels;
- }
-
- public String[] transformOptionValues(String[] oldOptionValues) {
- return optionValues;
- }
- });
+ public void add(
+ final String id,
+ final String[] optionLabels,
+ final String[] optionValues) {
+ if (!shouldIgnore(id)) {
+ transforms.add(
+ new DefaultDropdownTransformer() {
+ public boolean shouldTransform(AttributeDefinition ad) {
+ return id.equals(ad.getID());
+ }
+
+ public String[] transformOptionLabels(String[] oldOptionLabels) {
+ return optionLabels;
+ }
+
+ public String[] transformOptionValues(String[] oldOptionValues) {
+ return optionValues;
+ }
+ });
+ }
}
+
+ public void ignore(String id) {
+ this.attributesToIgnore.add(id);
+ }
+
+ public boolean shouldIgnore(String id) {
+ return this.attributesToIgnore.contains(id);
+ }
private static List swapToFront(List list, String target) {
String[] temp = (String[]) list.toArray(new String[]{});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2010-03-19 23:08:30
|
Revision: 1055
http://cishell.svn.sourceforge.net/cishell/?rev=1055&view=rev
Author: mwlinnem
Date: 2010-03-19 22:14:19 +0000 (Fri, 19 Mar 2010)
Log Message:
-----------
Added google collections (surely this...).
Modified Paths:
--------------
trunk/deployment/org.cishell.reference.feature/feature.xml
Modified: trunk/deployment/org.cishell.reference.feature/feature.xml
===================================================================
--- trunk/deployment/org.cishell.reference.feature/feature.xml 2010-03-19 21:56:20 UTC (rev 1054)
+++ trunk/deployment/org.cishell.reference.feature/feature.xml 2010-03-19 22:14:19 UTC (rev 1055)
@@ -128,4 +128,10 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="google_collections"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2010-03-19 22:38:21
|
Revision: 1056
http://cishell.svn.sourceforge.net/cishell/?rev=1056&view=rev
Author: mwlinnem
Date: 2010-03-19 22:38:14 +0000 (Fri, 19 Mar 2010)
Log Message:
-----------
This thing didn't need dbcp in the first place! And I had been running around trying to give it the dependencies it needed. Bleh.
Modified Paths:
--------------
trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF
Modified: trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF 2010-03-19 22:14:19 UTC (rev 1055)
+++ trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF 2010-03-19 22:38:14 UTC (rev 1056)
@@ -5,4 +5,3 @@
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.cishell.service.database
-Import-Package: org.apache.commons.dbcp
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2010-03-19 21:56:27
|
Revision: 1054
http://cishell.svn.sourceforge.net/cishell/?rev=1054&view=rev
Author: mwlinnem
Date: 2010-03-19 21:56:20 +0000 (Fri, 19 Mar 2010)
Log Message:
-----------
Added another magic line. Will this make the database feature build?
Modified Paths:
--------------
trunk/deployment/org.cishell.reference.releng/build-files/allElements.xml
Modified: trunk/deployment/org.cishell.reference.releng/build-files/allElements.xml
===================================================================
--- trunk/deployment/org.cishell.reference.releng/build-files/allElements.xml 2010-03-19 18:47:28 UTC (rev 1053)
+++ trunk/deployment/org.cishell.reference.releng/build-files/allElements.xml 2010-03-19 21:56:20 UTC (rev 1054)
@@ -57,6 +57,11 @@
<property name="zipargs" value="" />
</ant>
</target>
+ <target name="assemble.org.cishell.reference.database.feature">
+ <ant antfile="${assembleScriptName}" dir="${buildDirectory}">
+ <property name="zipargs" value="" />
+ </ant>
+ </target>
<!-- assmble targets for RCP build -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2010-03-19 18:47:34
|
Revision: 1053
http://cishell.svn.sourceforge.net/cishell/?rev=1053&view=rev
Author: mwlinnem
Date: 2010-03-19 18:47:28 +0000 (Fri, 19 Mar 2010)
Log Message:
-----------
Added database.feature to main CIShell build (surely this...)
Modified Paths:
--------------
trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml
Modified: trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml
===================================================================
--- trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2010-03-19 18:40:20 UTC (rev 1052)
+++ trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2010-03-19 18:47:28 UTC (rev 1053)
@@ -30,6 +30,12 @@
<param name="project.name" value="/deployment/org.cishell.reference.feature"/>
<param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/>
</antcall>
+ <antcall target="svn.co">
+ <param name="target" value="features"/>
+ <param name="element.id" value="org.cishell.reference.database.feature"/>
+ <param name="project.name" value="/deployment/org.cishell.reference.database.feature"/>
+ <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/>
+ </antcall>
<antcall target="svn.co">
<param name="target" value="plugins"/>
<param name="element.id" value="org.cishell.reference"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|