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: <mwl...@us...> - 2008-04-02 17:39:01
|
Revision: 752
http://cishell.svn.sourceforge.net/cishell/?rev=752&view=rev
Author: mwlinnem
Date: 2008-04-02 10:38:56 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Added warning about differences in FileDialog behavior on different platforms.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
Modified: branches/user_prefs/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2008-04-02 17:34:20 UTC (rev 751)
+++ branches/user_prefs/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2008-04-02 17:38:56 UTC (rev 752)
@@ -107,6 +107,13 @@
public void run (){
+ //WARNING: Verified that file dialog has different behavior on different platforms.
+ //On linux (gtk?), providing a filterPath that doesn't end in a directory causes the FileDialog to
+ //default to the filterPath of the directory cishell was started from (not the directory the executable is necessarily in!)
+ //However, the same code works as intended on Windows.
+
+ //This code works on Linux, but still hasn't been tested on Windows.
+
FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN);
if (currentDir == null) {
currentDir = new File(System.getProperty("osgi.install.area").replace("file:","")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-04-02 17:34:23
|
Revision: 751
http://cishell.svn.sourceforge.net/cishell/?rev=751&view=rev
Author: mwlinnem
Date: 2008-04-02 10:34:20 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Added Paths:
-----------
branches/user_prefs/org.cishell.reference.gui.persistence/
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/
Copied: branches/user_prefs/org.cishell.reference.gui.persistence (from rev 750, trunk/clients/gui/org.cishell.reference.gui.persistence)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-04-02 15:34:13
|
Revision: 750
http://cishell.svn.sourceforge.net/cishell/?rev=750&view=rev
Author: mwlinnem
Date: 2008-04-02 08:34:10 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Fixed bug in converting data to format required by an algorithm.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-04-02 15:04:25 UTC (rev 749)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-04-02 15:34:10 UTC (rev 750)
@@ -25,6 +25,7 @@
import org.cishell.app.service.datamanager.DataManagerService;
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.AlgorithmProperty;
import org.cishell.framework.algorithm.DataValidator;
@@ -86,8 +87,11 @@
public Data[] execute() {
try {
// prepare to run the algorithm
-
+ if (convertableData.length > 0) System.err.println("Convertable Data 0 in AlgorithmWrapper" + convertableData[0]);
+ else System.err.println("No Conv 0!");
Data[] data = convertDataToRequiredFormat(this.convertableData, this.converters);
+ if (data.length > 0) System.err.println("Data 0 in AlgorithmWrapper humph:" + data[0]);
+ else System.err.println("No Normal 0!");
AlgorithmFactory algFactory = (AlgorithmFactory) bContext.getService(algFactoryRef);
boolean inputIsValid = testDataValidityIfPossible(algFactory, data);
if (!inputIsValid) return null;
@@ -106,10 +110,14 @@
// execute the algorithm
Data[] rawOutData = algorithm.execute();
+ if (rawOutData.length > 0) System.err.println("rawOutData 0 in AlgorithmWrapper:" + rawOutData[0]);
+ else System.err.println("No Raw 0!");
// return the algorithm's output
Data[] processedOutData = processOutData(rawOutData);
+ if (processedOutData.length > 0) System.err.println("processedOutData 0 in AlgorithmWrapper:" + processedOutData[0]);
+ else System.err.println("No Processed 0!");
return processedOutData;
} catch (Throwable e) {
@@ -128,17 +136,15 @@
public void setProgressMonitor(ProgressMonitor monitor) {
progressMonitor = monitor;
}
-
- protected Data[] convertDataToRequiredFormat(Data[] providedData, Converter[][] converters) throws Exception {
+
+ protected Data[] convertDataToRequiredFormat(Data[] data, Converter[][] converters) throws Exception {
// convert data into the in_data format of the algorithm we are trying to run
- Data[] readyData = new Data[providedData.length];
-
- for (int i = 0; i < providedData.length; i++) {
+ for (int i = 0; i < data.length; i++) {
if (converters[i] != null) {
// WARNING: arbitrarily chooses first converter out of a list of possible converters
- readyData[i] = converters[i][0].convert(providedData[i]);
-
- if (readyData[i] == null && i < (readyData.length - 1)) {
+ data[i] = converters[i][0].convert(data[i]);
+ System.out.println("readyData " + i + ": " + data[i]);
+ if (data[i] == null && i < (data.length - 1)) {
Exception e = new Exception("The converter " + converters[i].getClass().getName()
+ " returned a null result where data was expected.");
throw e;
@@ -147,7 +153,7 @@
}
}
- return readyData;
+ return data;
}
protected boolean testDataValidityIfPossible(AlgorithmFactory algFactory, Data[] dataInQuestion) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bh...@us...> - 2008-04-02 15:04:43
|
Revision: 749
http://cishell.svn.sourceforge.net/cishell/?rev=749&view=rev
Author: bh2
Date: 2008-04-02 08:04:25 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
updated the validator text to adhere to our decision on how validators should work:
return same Data (w/ diff format) for valid
return null (and log problems) if invalid
and throw an exception on non-format related problems (IOException, etc)
Modified Paths:
--------------
trunk/core/org.cishell.docs/src/specification/tex/algorithmtypes.tex
Modified: trunk/core/org.cishell.docs/src/specification/tex/algorithmtypes.tex
===================================================================
--- trunk/core/org.cishell.docs/src/specification/tex/algorithmtypes.tex 2008-03-31 19:42:39 UTC (rev 748)
+++ trunk/core/org.cishell.docs/src/specification/tex/algorithmtypes.tex 2008-04-02 15:04:25 UTC (rev 749)
@@ -180,14 +180,17 @@
\begin{itemize}
\item The algorithm must be a conformant \class{AlgorithmFactory}
implementation and properly registered as a service.
+ \item The algorithm's service metadata must contain an ``in\_data''
+ and ``out\_data'' with only one data item each with one containing a
+ ``file:\textit{mime/type}'' format and the other a
+ ``file-ext:\textit{file-extension}'' depending on the direction of
+ validation. See section \ref{dataSpec} for data format details.
\item The algorithm must take in a single \class{Data} item and validate the
item producing a single \class{Data} item (with the same data, but changed
- format) or throw an exception if the file being validated is not of the right
- type. This must be reflected in the algorithm's service metadata where
- ``in\_data'' and ``out\_data'' have only one data item each with one
- containing a ``file:\textit{mime/type}'' format and the other a
- ``file-ext:\textit{file-extension}'' depending on the direction of validation.
- See section \ref{dataSpec} for data format details.
+ format) if the file is of the right type. If not, then the algorithm should
+ log (using the CIShellContext-provided \class{LogService}) what the problem
+ was and must return null. If a problem occurs that is unrelated to the
+ file's format, then an \class{AlgorithmExecutionException} should be thrown.
\item The algorithm must not alter the data. Its only purpose is to validate
the proposed incoming or outgoing file.
\item The algorithm's service metadata must contain a valid ``service.pid''.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-31 19:43:10
|
Revision: 748
http://cishell.svn.sourceforge.net/cishell/?rev=748&view=rev
Author: mwlinnem
Date: 2008-03-31 12:42:39 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
Added preference service functionality and fixed default directory for file loading on linux. Will test to see if it works on Windows as well.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.properties
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.xml
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java
Added Paths:
-----------
trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/
Copied: trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence (from rev 745, trunk/clients/gui/org.cishell.reference.gui.persistence)
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2008-03-31 19:42:39 UTC (rev 748)
@@ -13,6 +13,7 @@
org.cishell.service.conversion;version="1.0.0",
org.cishell.service.guibuilder;version="1.0.0",
org.osgi.framework;version="1.3.0",
+ org.osgi.service.cm;version="1.2.0",
org.osgi.service.component;version="1.0.0",
org.osgi.service.log;version="1.3.0",
org.osgi.service.metatype;version="1.1.0",
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.properties
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2008-03-31 19:42:39 UTC (rev 748)
@@ -5,3 +5,5 @@
out_data=java.lang.Object
service.pid=org.cishell.reference.gui.persistence.load.FileLoad
remoteable=true
+prefs_published=local
+receive_prefs=true
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.xml
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.xml 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/load.xml 2008-03-31 19:42:39 UTC (rev 748)
@@ -8,5 +8,7 @@
<service>
<provide interface=
"org.cishell.framework.algorithm.AlgorithmFactory"/>
+ <provide interface=
+ "org.osgi.service.cm.ManagedService"/>
</service>
</component>
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2008-03-31 19:42:39 UTC (rev 748)
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
- <OCD name="FileView" id="org.cishell.reference.gui.persistence.view.FileView.OCD"
+ <OCD name="File Load" id="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local.OCD"
description="">
+ <AD name="Default load directory" id="loadDir" type="String" default="directory:sampledata/"/>
</OCD>
- <Designate pid="org.cishell.reference.gui.persistence.view.FileView">
- <Object ocdref="org.cishell.reference.gui.persistence.view.FileView.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>
-</metatype:MetaData>
+</metatype:MetaData>
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/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 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2008-03-31 19:42:39 UTC (rev 748)
@@ -2,6 +2,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Dictionary;
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.Algorithm;
@@ -10,8 +11,6 @@
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.cishell.service.guibuilder.GUIBuilderService;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
@@ -24,113 +23,98 @@
/*
* @author Weixia(Bonnie) Huang (hu...@in...)
*/
-public class FileLoad implements Algorithm{
-
- private static File currentDir;
-
+public class FileLoad implements Algorithm {
+
private final LogService logger;
private final GUIBuilderService guiBuilder;
private BundleContext bContext;
private CIShellContext ciContext;
+ private static String defaultLoadDirectory;
- public FileLoad(CIShellContext ciContext, BundleContext bContext) {
+ public FileLoad(CIShellContext ciContext, BundleContext bContext, Dictionary prefProperties) {
this.ciContext = ciContext;
this.bContext = bContext;
logger = (LogService) ciContext.getService(LogService.class.getName());
guiBuilder = (GUIBuilderService)ciContext.getService(GUIBuilderService.class.getName());
-
+
+ //unpack preference properties
+ if (defaultLoadDirectory == null) {
+ defaultLoadDirectory = (String) prefProperties.get("loadDir");
+ }
}
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
public Data[] execute() throws AlgorithmExecutionException {
- try {
-// int counter = PlatformUI.getWorkbench().getWorkbenchWindowCount();
-// System.out.println("counter is "+counter);
-// ?? why getActiveWorkbenchWindow() didn't work??
- Data[] returnDM;
+ //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.
- final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
- if (windows.length ==0){
- throw new AlgorithmExecutionException("Cannot obtain workbench window needed to open dialog.");
- }
-
- Display display = PlatformUI.getWorkbench().getDisplay();
- DataUpdater dataUpdater = new DataUpdater (windows[0]);
-
if (Thread.currentThread() != display.getThread()) {
- display.syncExec(dataUpdater);
+ display.syncExec(fileLoader);
} else {
- dataUpdater.run();
+ fileLoader.run();
}
- if (!dataUpdater.returnList.isEmpty()){
- int size = dataUpdater.returnList.size();
- returnDM = new Data[size];
- for(int index=0; index<size; index++){
- returnDM[index]=(Data)dataUpdater.returnList.get(index);
- }
- return returnDM;
- }
- else {
- this.logger.log(LogService.LOG_WARNING, "File loading canceled");
- return new Data[0];
- }
- } catch (AlgorithmExecutionException e1) {
- throw e1;
- } catch (Throwable e2) {
- throw new AlgorithmExecutionException(e2);
- }
+ //return loaded file data
+
+ Data[] loadedFileData = extractLoadedFileData(fileLoader);
+ return loadedFileData;
}
- public static String getFileExtension(File theFile) {
- String fileName = theFile.getName() ;
- String extension ;
- if (fileName.lastIndexOf(".") != -1)
- extension = fileName.substring(fileName.lastIndexOf(".")+1) ;
- else
- extension = "" ;
- return extension ;
- }
-
- final class DataUpdater implements Runnable{
+ final class FileLoadRunnable implements Runnable{
boolean loadFileSuccess = false;
IWorkbenchWindow window;
- ArrayList returnList = new ArrayList();
+ //this is how we return values from the runnable
+ public ArrayList returnList = new ArrayList();
- DataUpdater (IWorkbenchWindow window){
+ FileLoadRunnable (IWorkbenchWindow window){
this.window = window;
- }
+ }
public void run (){
-
- FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN);
- if (currentDir == null) {
- currentDir = new File(System.getProperty("osgi.install.area").replace("file:","")
- + "sampledata");
-
- if (!currentDir.exists()) {
- currentDir = new File(System.getProperty("osgi.install.area").replace("file:","")
- + "sampledata" +File.separator + "anything");
- }
- }
- dialog.setFilterPath(currentDir.getPath());
+ FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN);
+// if (currentDir == null) {
+// currentDir = new File(System.getProperty("osgi.install.area").replace("file:","")
+// + "sampledata");
+//
+// if (!currentDir.exists()) {
+// currentDir = new File(System.getProperty("osgi.install.area").replace("file:","")
+// + "sampledata" +File.separator + "anything");
+// }
+// }
+ System.err.println("defaultLoadDirectory is " + defaultLoadDirectory);
+ File currentDir = new File(defaultLoadDirectory); //? good way to do this?
+ String absolutePath = currentDir.getAbsolutePath();
+ System.err.println("absolutePath:" + absolutePath);
+ String name = currentDir.getName();
+ System.err.println("name:" + name);
+ dialog.setFilterPath(absolutePath);
+ // dialog.setFilterPath(name);
dialog.setText("Select a File");
String fileName = dialog.open();
+ System.out.println("Resulting file name!:" + fileName);
if (fileName == null) {
return;
}
- File file = new File(fileName);
-
- if (file.isDirectory()) {
- currentDir = new File(file + File.separator + "anything");
- } else {
- currentDir = new File(file.getParent() + File.separator + "anything");
- }
+
+ File file = new File(fileName);
+ if (file.isDirectory()) {
+ System.out.println("directory");
+ defaultLoadDirectory = file.getAbsolutePath();
+ } else {
+
+ // File parentFile = file.getParentFile();
+ // if (parentFile != null) {
+ System.out.println("file");
+ defaultLoadDirectory = file.getParentFile().getAbsolutePath();
+ // }
+ }
String fileExtension = getFileExtension(file).toLowerCase();
String filter = "(&(type=validator)(in_data=file-ext:"+fileExtension+"))";
@@ -217,7 +201,44 @@
}
}//end run()
+
+ 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 ;
+ }
} //end class
-
-
+
+ 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.returnList.isEmpty()){
+ int size = dataUpdater.returnList.size();
+ loadedFileData = new Data[size];
+ for(int index=0; index<size; index++){
+ loadedFileData[index]=(Data)dataUpdater.returnList.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
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/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 2008-03-28 20:59:27 UTC (rev 745)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2008-03-31 19:42:39 UTC (rev 748)
@@ -2,29 +2,51 @@
//standard java
import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
-//osgi
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.metatype.MetaTypeProvider;
-
-//cishell
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.Algorithm;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.Data;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.component.ComponentContext;
/*
* @author Weixia(Bonnie) Huang (hu...@in...)
*/
-public class FileLoadFactory implements AlgorithmFactory {
+public class FileLoadFactory implements AlgorithmFactory, ManagedService {
private BundleContext bcontext;
+ private Dictionary properties = new Hashtable();
protected void activate(ComponentContext ctxt) {
bcontext = ctxt.getBundleContext();
}
public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) {
- return new FileLoad(context, bcontext);
+ return new FileLoad(context, bcontext, properties);
}
+
+ public void updated(Dictionary properties) throws ConfigurationException {
+ this.properties = properties;
+ printPreferences(properties);
+ }
+
+ 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();
+
+ while (propertiesKeys.hasMoreElements()) {
+ String propertiesKey = (String) propertiesKeys.nextElement();
+
+ Object propertiesValue = properties.get(propertiesKey);
+ System.out.println(" " + propertiesKey + ":" + propertiesValue);
+ }
+ }
+ }
}
\ 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: <mwl...@us...> - 2008-03-31 16:52:03
|
Revision: 747
http://cishell.svn.sourceforge.net/cishell/?rev=747&view=rev
Author: mwlinnem
Date: 2008-03-31 09:51:59 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
Removed import.
Added Paths:
-----------
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java
Removed Paths:
-------------
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java
Deleted: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-03-29 19:15:23 UTC (rev 746)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-03-31 16:51:59 UTC (rev 747)
@@ -1,34 +0,0 @@
-package org.cishell.reference.gui.menumanager.menu.metatypewrapper;
-
-import java.util.Dictionary;
-
-import org.osgi.service.log.LogService;
-import org.osgi.service.metatype.MetaTypeProvider;
-import org.osgi.service.metatype.ObjectClassDefinition;
-
-public class ParamMetaTypeProvider implements MetaTypeProvider {
-
- private MetaTypeProvider realMTP;
-
- private Dictionary defaultOverrider;
-
- public ParamMetaTypeProvider(MetaTypeProvider realMTP, Dictionary defaultOverrider) {
- this.realMTP = realMTP;
- this.defaultOverrider = defaultOverrider;
- }
-
- public String[] getLocales() {
- return this.realMTP.getLocales();
- }
-
- public ObjectClassDefinition getObjectClassDefinition(String id,
- String locale) {
- ObjectClassDefinition ocd = realMTP.getObjectClassDefinition(id, locale);
- if (ocd != null) {
- return new ParamOCD(realMTP.getObjectClassDefinition(id, locale), defaultOverrider);
- } else {
- return null;
- }
- }
-
-}
Added: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java (rev 0)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-03-31 16:51:59 UTC (rev 747)
@@ -0,0 +1,33 @@
+package org.cishell.reference.gui.menumanager.menu.metatypewrapper;
+
+import java.util.Dictionary;
+
+import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.ObjectClassDefinition;
+
+public class ParamMetaTypeProvider implements MetaTypeProvider {
+
+ private MetaTypeProvider realMTP;
+
+ private Dictionary defaultOverrider;
+
+ public ParamMetaTypeProvider(MetaTypeProvider realMTP, Dictionary defaultOverrider) {
+ this.realMTP = realMTP;
+ this.defaultOverrider = defaultOverrider;
+ }
+
+ public String[] getLocales() {
+ return this.realMTP.getLocales();
+ }
+
+ public ObjectClassDefinition getObjectClassDefinition(String id,
+ String locale) {
+ ObjectClassDefinition ocd = realMTP.getObjectClassDefinition(id, locale);
+ if (ocd != null) {
+ return new ParamOCD(realMTP.getObjectClassDefinition(id, locale), defaultOverrider);
+ } else {
+ return null;
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-29 19:15:51
|
Revision: 746
http://cishell.svn.sourceforge.net/cishell/?rev=746&view=rev
Author: mwlinnem
Date: 2008-03-29 12:15:23 -0700 (Sat, 29 Mar 2008)
Log Message:
-----------
Fixed typo.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-28 20:59:27 UTC (rev 745)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-29 19:15:23 UTC (rev 746)
@@ -155,7 +155,7 @@
Data datum = (Data) dataSet.get(j);
if (datum != null) {
- if (isAsignableFrom(inData[i], datum)) {
+ if (isAssignableFrom(inData[i], datum)) {
dataSet.remove(j);
data[i] = datum;
converters[i] = null;
@@ -190,7 +190,7 @@
setEnabled(data != null); //&& isValid());
}
- private boolean isAsignableFrom(String type, Data datum) {
+ private boolean isAssignableFrom(String type, Data datum) {
Object data = datum.getData();
boolean assignable = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 20:59:29
|
Revision: 745
http://cishell.svn.sourceforge.net/cishell/?rev=745&view=rev
Author: mwlinnem
Date: 2008-03-28 13:59:27 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Fixed bug where we accidentally assumed an algorithm factory was a data validator.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-28 20:55:35 UTC (rev 744)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-28 20:59:27 UTC (rev 745)
@@ -151,19 +151,24 @@
}
protected boolean testDataValidityIfPossible(AlgorithmFactory algFactory, Data[] dataInQuestion) {
- String validation = ((DataValidator) algFactory).validate(dataInQuestion);
+ if (algFactory instanceof DataValidator) {
+ String validation = ((DataValidator) algFactory).validate(dataInQuestion);
- if (validation != null && validation.length() > 0) {
- String label = (String) algFactoryRef.getProperty(LABEL);
- if (label == null) {
- label = "Algorithm";
+ if (validation != null && validation.length() > 0) {
+ String label = (String) algFactoryRef.getProperty(LABEL);
+ if (label == null) {
+ label = "Algorithm";
+ }
+
+ builder.showError("Invalid Data", "The data given to \"" + label + "\" is incompatible for this reason: "
+ + validation, (String) null);
+ return false;
}
-
- builder.showError("Invalid Data", "The data given to \"" + label + "\" is incompatible for this reason: "
- + validation, (String) null);
- return false;
- }
- return true;
+ return true;
+ } else {
+ //counts as valid if there is no validator available.
+ return true;
+ }
}
protected MetaTypeProvider obtainParameterSetupInfo(AlgorithmFactory algFactory, Data[] data) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 20:55:38
|
Revision: 744
http://cishell.svn.sourceforge.net/cishell/?rev=744&view=rev
Author: mwlinnem
Date: 2008-03-28 13:55:35 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Fixed bizarre issue causing import statement to not function.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-28 20:44:24 UTC (rev 743)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-28 20:55:35 UTC (rev 744)
@@ -19,4 +19,4 @@
org.cishell.service.guibuilder;version="1.0.0",
org.osgi.service.cm;version="1.2.0",
org.osgi.service.log;version="1.3.0",
- org.osgi.service.metatype;version="1.1.0",
+ org.osgi.service.metatype;version="1.1.0"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 20:44:26
|
Revision: 743
http://cishell.svn.sourceforge.net/cishell/?rev=743&view=rev
Author: mwlinnem
Date: 2008-03-28 13:44:24 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Updated prefs admin for CISHell 1.0 Compatibility.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF
branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java
branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java
branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java
Modified: branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF 2008-03-28 20:39:23 UTC (rev 742)
+++ branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF 2008-03-28 20:44:24 UTC (rev 743)
@@ -7,7 +7,7 @@
Import-Package: org.cishell.framework,
org.cishell.framework.algorithm,
org.cishell.framework.data,
- org.cishell.framework.preference,
+ org.cishell.framework.userprefs,
org.cishell.reference.service.metatype,
org.osgi.framework;version="1.3.0",
org.osgi.service.cm;version="1.2.0",
Modified: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java
===================================================================
--- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java 2008-03-28 20:39:23 UTC (rev 742)
+++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java 2008-03-28 20:44:24 UTC (rev 743)
@@ -6,7 +6,7 @@
import java.util.Enumeration;
import java.util.List;
-import org.cishell.framework.preference.PreferenceProperty;
+import org.cishell.framework.userprefs.UserPrefsProperty;
import org.cishell.reference.prefs.admin.PrefAdmin;
import org.cishell.reference.prefs.admin.PrefPage;
import org.cishell.reference.prefs.admin.PrefsByService;
@@ -147,8 +147,8 @@
try {
for (int ii = 0; ii < this.prefHolderReferences.size(); ii++) {
ServiceReference prefHolder = (ServiceReference) this.prefHolderReferences.get(ii);
- if (prefHolder.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY) != null &&
- prefHolder.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY).equals("true")) {
+ if (prefHolder.getProperty(UserPrefsProperty.RECEIVE_PREFS_KEY) != null &&
+ prefHolder.getProperty(UserPrefsProperty.RECEIVE_PREFS_KEY).equals("true")) {
Configuration localPrefConf = ca.getConfiguration((String) prefHolder.getProperty(Constants.SERVICE_PID));
try {
localPrefConf.update();
@@ -163,8 +163,8 @@
}
private boolean isFromGlobalConf(String pid) {
- return (pid.substring(0, pid.length() - 1).endsWith(PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX)
- || pid.endsWith(PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX));
+ return (pid.substring(0, pid.length() - 1).endsWith(UserPrefsProperty.GLOBAL_PREFS_CONF_SUFFIX)
+ || pid.endsWith(UserPrefsProperty.GLOBAL_PREFS_CONF_SUFFIX));
}
Modified: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java
===================================================================
--- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java 2008-03-28 20:39:23 UTC (rev 742)
+++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java 2008-03-28 20:44:24 UTC (rev 743)
@@ -7,7 +7,7 @@
import java.util.List;
import org.cishell.framework.algorithm.AlgorithmProperty;
-import org.cishell.framework.preference.PreferenceProperty;
+import org.cishell.framework.userprefs.UserPrefsProperty;
import org.cishell.reference.prefs.admin.PreferenceOCD;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
@@ -22,7 +22,7 @@
//NOTE: methods that get configuration objects don't really need the ObjectClassDefinitions. We just use them (hackishly) to know how many configuration objects we should get
//Since, there are possibly an infinite number of Configuration objects for a service, we need the ObjectClassDefinitions to tell us when to stop trying to grab configuration objects
//(If we try to grab one that didn't previously exist, it will just make an empty one, sometimes we want this behaviour and sometimes we don't).
-public class PrefInfoGrabber implements PreferenceProperty, AlgorithmProperty {
+public class PrefInfoGrabber implements UserPrefsProperty, AlgorithmProperty {
private LogService log;
private MetaTypeService mts;
@@ -50,38 +50,38 @@
}
private String getLocalPrefOCDID(ServiceReference prefHolder) {
- String localPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.LOCAL_PREF_PID);
+ String localPrefOCDID = (String) prefHolder.getProperty(UserPrefsProperty.LOCAL_PREFS_PID);
if (localPrefOCDID != null) {
return localPrefOCDID;
} else {
//no name defined. Use default name.
String defaultLocalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID)
- + PreferenceProperty.LOCAL_PREFS_OCD_SUFFIX;
+ + UserPrefsProperty.LOCAL_PREFS_OCD_SUFFIX;
return defaultLocalPrefOCDID;
}
}
private String getGlobalPrefOCDID(ServiceReference prefHolder) {
- String globalPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.GLOBAL_PREF_PID);
+ String globalPrefOCDID = (String) prefHolder.getProperty(UserPrefsProperty.GLOBAL_PREFS_PID);
if (globalPrefOCDID != null) {
return globalPrefOCDID;
} else {
//no names defined. Use default names.
String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID)
- + PreferenceProperty.GLOBAL_PREFS_OCD_SUFFIX;
+ + UserPrefsProperty.GLOBAL_PREFS_OCD_SUFFIX;
return defaultGlobalPrefOCDID;
}
}
private String getParamPrefOCDID(ServiceReference prefHolder) {
System.out.println(" Getting param pref OCD ID for " + prefHolder.getProperty("service.pid"));
- String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETER_PID);
+ String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETERS_PID);
if ( paramPrefOCDID != null) {
System.out.println(" RETURN override: " + paramPrefOCDID);
return paramPrefOCDID;
} else {
//no names defined. Use default names.
- String defaultParamPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.PARAM_PREFS_OCD_SUFFIX;
+ String defaultParamPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + UserPrefsProperty.PARAM_PREFS_OCD_SUFFIX;
System.out.println(" RETURN default: " + defaultParamPrefOCDID);
return defaultParamPrefOCDID;
}
@@ -199,23 +199,23 @@
}
private String getGlobalPrefConfID(ServiceReference prefHolder) {
- String globalPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.GLOBAL_PREF_PID);
+ String globalPrefOCDID = (String) prefHolder.getProperty(UserPrefsProperty.GLOBAL_PREFS_PID);
if (globalPrefOCDID != null) {
return globalPrefOCDID;
} else {
//no names defined. Use default names.
- String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX;
+ String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + UserPrefsProperty.GLOBAL_PREFS_CONF_SUFFIX;
return defaultGlobalPrefOCDID;
}
}
private String getParamPrefConfID(ServiceReference prefHolder) {
- String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETER_PID);
+ String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETERS_PID);
if ( paramPrefOCDID != null) {
return paramPrefOCDID;
} else {
//no names defined. Use default names.
- String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.PARAM_PREFS_CONF_SUFFIX;
+ String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX;
return defaultGlobalPrefOCDID;
}
}
Modified: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java
===================================================================
--- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java 2008-03-28 20:39:23 UTC (rev 742)
+++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java 2008-03-28 20:44:24 UTC (rev 743)
@@ -7,7 +7,7 @@
import java.util.Hashtable;
import java.util.List;
-import org.cishell.framework.preference.PreferenceProperty;
+import org.cishell.framework.userprefs.UserPrefsProperty;
import org.cishell.reference.prefs.admin.PrefPage;
import org.cishell.reference.prefs.admin.PreferenceAD;
import org.cishell.reference.prefs.admin.PreferenceOCD;
@@ -47,7 +47,7 @@
//get all preference pages from this service by type, and save them by type
PrefPage[] localPrefPages = null;
- if(isTurnedOn(prefReference, PreferenceProperty.PUBLISH_LOCAL_PREF_VALUE)) {
+ if(isTurnedOn(prefReference, UserPrefsProperty.PUBLISH_LOCAL_PREFS_VALUE)) {
localPrefPages = getLocalPrefPages(prefReference);
initializeConfigurations(localPrefPages);
this.allLocalPrefPages.addAll(Arrays.asList(localPrefPages));
@@ -55,14 +55,14 @@
}
PrefPage[] globalPrefPages = null;
- if (isTurnedOn(prefReference, PreferenceProperty.PUBLISH_GLOBAL_PREF_VALUE)) {
+ if (isTurnedOn(prefReference, UserPrefsProperty.PUBLISH_GLOBAL_PREFS_VALUE)) {
globalPrefPages = getGlobalPrefPages(prefReference);
initializeConfigurations(globalPrefPages);
this.allGlobalPrefPages.addAll(Arrays.asList(globalPrefPages));
}
PrefPage[] paramPrefPages = null;
- if (isTurnedOn(prefReference,PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE)) {
+ if (isTurnedOn(prefReference,UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE)) {
System.out.println(" Attempting to publish param default prefs for " + prefReference.getProperty("service.pid"));
paramPrefPages = getParamPrefPages(prefReference);
initializeConfigurations(paramPrefPages);
@@ -76,7 +76,7 @@
//make sure that preferences are sent to this service if it wants to see them.
- if (isTurnedOn(prefReference, PreferenceProperty.RECEIVE_PREFS_KEY)) {
+ if (isTurnedOn(prefReference, UserPrefsProperty.RECEIVE_PREFS_KEY)) {
prefInfoGrabber.ensurePrefsCanBeSentTo(prefReference);
}
}
@@ -158,7 +158,7 @@
}
- prefDict.put(PreferenceProperty.BUNDLE_VERSION_KEY, getCurrentBundleVersion(prefPage));
+ prefDict.put(UserPrefsProperty.BUNDLE_VERSION_KEY, getCurrentBundleVersion(prefPage));
try {
prefConf.update(prefDict);
@@ -189,13 +189,13 @@
//only supports 3 publish keys and receive_prefs key
private boolean isTurnedOn(ServiceReference prefReference, String processingKey) {
- if (processingKey.equals(PreferenceProperty.RECEIVE_PREFS_KEY)) {
- String receivePrefsValue = (String) prefReference.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY);
+ if (processingKey.equals(UserPrefsProperty.RECEIVE_PREFS_KEY)) {
+ String receivePrefsValue = (String) prefReference.getProperty(UserPrefsProperty.RECEIVE_PREFS_KEY);
return receivePrefsValue != null && receivePrefsValue.equals("true");
} else {
- String unparsedPublishedPrefsValues = (String) prefReference.getProperty(PreferenceProperty.PREFS_PUBLISHED_KEY);
+ String unparsedPublishedPrefsValues = (String) prefReference.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY);
if (unparsedPublishedPrefsValues == null) {
- if (processingKey ==PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE) {
+ if (processingKey ==UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE) {
return true;
} else {
return false;
@@ -210,7 +210,7 @@
}
//makes it so parameter prefs are published by default
- if (publishedPrefsValues.length == 0 && processingKey ==PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE) {
+ if (publishedPrefsValues.length == 0 && processingKey ==UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE) {
return true;
}
@@ -236,7 +236,7 @@
private String getCurrentBundleVersion(PrefPage prefPage) {
Bundle b = prefPage.getServiceReference().getBundle();
- String currentBundleVersion = (String) b.getHeaders().get(PreferenceProperty.BUNDLE_VERSION_KEY);
+ String currentBundleVersion = (String) b.getHeaders().get(UserPrefsProperty.BUNDLE_VERSION_KEY);
return currentBundleVersion;
}
@@ -246,13 +246,13 @@
return null;
}
//no namespace in front of bundle version
- String bundleVersionForLocalsAndParams = (String) prefDict.get(PreferenceProperty.BUNDLE_VERSION_KEY);
+ String bundleVersionForLocalsAndParams = (String) prefDict.get(UserPrefsProperty.BUNDLE_VERSION_KEY);
if (bundleVersionForLocalsAndParams != null) {
return bundleVersionForLocalsAndParams;
} else {
//try global kind, with namespace in front
String servicePID = (String) prefPage.getServiceReference().getProperty(Constants.SERVICE_PID);
- String bundleVersionForGlobals = (String) prefDict.get(servicePID + "." + PreferenceProperty.BUNDLE_VERSION_KEY);
+ String bundleVersionForGlobals = (String) prefDict.get(servicePID + "." + UserPrefsProperty.BUNDLE_VERSION_KEY);
if (bundleVersionForGlobals != null) {
return bundleVersionForGlobals;
@@ -275,7 +275,7 @@
}
private void warnIfReceivePrefsIsNotOn(ServiceReference prefHolder) {
- if (! isTurnedOn(prefHolder, PreferenceProperty.RECEIVE_PREFS_KEY)) {
+ if (! isTurnedOn(prefHolder, UserPrefsProperty.RECEIVE_PREFS_KEY)) {
String servicePID = (String) prefHolder.getProperty(Constants.SERVICE_PID);
log.log(LogService.LOG_WARNING, "Algorithm Developer Error: \r\n" +
"The algorithm " + servicePID + " has published local preferences without requested to receive preferences. \r\n" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 20:39:33
|
Revision: 742
http://cishell.svn.sourceforge.net/cishell/?rev=742&view=rev
Author: mwlinnem
Date: 2008-03-28 13:39:23 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Removed pointless AD in metadata.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML
Modified: branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML 2008-03-28 20:30:10 UTC (rev 741)
+++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML 2008-03-28 20:39:23 UTC (rev 742)
@@ -2,7 +2,6 @@
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
<OCD name="Preferences" id="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm.OCD"
description="Lets you view and edit CIShell preferences ">
- <AD name="what" id="ever" type="String" default="work"/>
</OCD>
<Designate pid="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm">
<Object ocdref="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm.OCD" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 20:30:26
|
Revision: 741
http://cishell.svn.sourceforge.net/cishell/?rev=741&view=rev
Author: mwlinnem
Date: 2008-03-28 13:30:10 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Result of merge between CIShell 1.0 updated org.cishell.framework and the preference changes.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-28 16:51:07 UTC (rev 740)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-28 20:30:10 UTC (rev 741)
@@ -2,21 +2,21 @@
Bundle-ManifestVersion: 2
Bundle-Name: Menu Manager Plug-in
Bundle-SymbolicName: org.cishell.reference.gui.menumanager;singleton:=true
-Bundle-Version: 0.6.0
+Bundle-Version: 1.0.0
Bundle-Activator: org.cishell.reference.gui.menumanager.Activator
-Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Eclipse-LazyStart: true
-Import-Package: org.cishell.app.service.datamanager,
- org.cishell.app.service.scheduler,
- org.cishell.framework,
- org.cishell.framework.algorithm,
- org.cishell.framework.data,
- org.cishell.framework.preference,
+Import-Package: org.cishell.app.service.datamanager;version="1.0.0",
+ org.cishell.app.service.scheduler;version="1.0.0",
+ org.cishell.framework;version="1.0.0",
+ org.cishell.framework.algorithm;version="1.0.0",
+ org.cishell.framework.data;version="1.0.0",
+ org.cishell.framework.userprefs;version="1.0.0",
org.cishell.reference.gui.workspace,
- org.cishell.service.conversion,
- org.cishell.service.guibuilder,
+ org.cishell.reference.service.metatype,
+ org.cishell.service.conversion;version="1.0.0",
+ org.cishell.service.guibuilder;version="1.0.0",
org.osgi.service.cm;version="1.2.0",
org.osgi.service.log;version="1.3.0",
- org.osgi.service.metatype;version="1.1.0"
+ org.osgi.service.metatype;version="1.1.0",
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-28 16:51:07 UTC (rev 740)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-28 20:30:10 UTC (rev 741)
@@ -12,6 +12,7 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@@ -24,7 +25,7 @@
// The shared instance
private static Activator plugin;
- private static final int DELAY_TIME = 500;
+ private static BundleContext context;
MenuAdapter menuAdapter;
@@ -41,14 +42,16 @@
public void start(BundleContext context) throws Exception {
super.start(context);
+ Activator.context = context;
+
while (getWorkbench() == null) {
- Thread.sleep(DELAY_TIME);
+ Thread.sleep(500);
}
IWorkbenchWindow[] windows = getWorkbench().getWorkbenchWindows();
while (windows.length == 0) {
- Thread.sleep(DELAY_TIME);
+ Thread.sleep(500);
windows = getWorkbench().getWorkbenchWindows();
}
@@ -79,6 +82,16 @@
super.stop(context);
}
+
+ public static Object getService(String service_pid) {
+ ServiceReference ref = context.getServiceReference(service_pid);
+
+ if (ref != null) {
+ return context.getService(ref);
+ } else {
+ return null;
+ }
+ }
/**
* Returns the shared instance
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-28 16:51:07 UTC (rev 740)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-28 20:30:10 UTC (rev 741)
@@ -77,8 +77,6 @@
dataSelected(dataManager.getSelectedData());
}
-
-
public void run() {
//hmm... should probably change this.. maybe use the scheduler...
new Thread("Menu Item Runner") {
@@ -97,13 +95,9 @@
bContext.getService(bContext.getServiceReference(
SchedulerService.class.getName()));
-
printAlgorithmInformation();
-
-
-
-
- scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters, ca), ref);
+
+ scheduler.schedule(new AlgorithmWrapper(ref, ciContext, bContext, originalData, data, converters, ca), ref);
} catch (Throwable e) {
e.printStackTrace();
}
@@ -113,33 +107,31 @@
//adjust to log the whole acknowledgement in one block
LogService logger = (LogService) ciContext.getService(LogService.class.getName());
StringBuffer acknowledgement = new StringBuffer();
- String label = (String)ref.getProperty("label");
+ String label = (String)ref.getProperty(LABEL);
if (label != null){
- acknowledgement.append("..........\n"+
- label+" was selected.\n");
+ acknowledgement.append("..........\n"+label+" was selected.\n");
}
- String authors = (String)ref.getProperty("authors");
+ String authors = (String)ref.getProperty(AUTHORS);
if (authors != null)
acknowledgement.append("Author(s): "+authors+"\n");
- String implementers = (String)ref.getProperty("implementers");
+ String implementers = (String)ref.getProperty(IMPLEMENTERS);
if (implementers != null)
acknowledgement.append("Implementer(s): "+implementers+"\n");
- String integrators = (String)ref.getProperty("integrators");
+ String integrators = (String)ref.getProperty(INTEGRATORS);
if (integrators != null)
acknowledgement.append("Integrator(s): "+integrators+"\n");
- String reference = (String)ref.getProperty("reference");
- String reference_url = (String)ref.getProperty("reference_url");
+ String reference = (String)ref.getProperty(REFERENCE);
+ String reference_url = (String)ref.getProperty(REFERENCE_URL);
if (reference != null && reference_url != null )
acknowledgement.append("Reference: "+reference+
" ("+reference_url+")\n");
else if (reference != null && reference_url == null )
acknowledgement.append("Reference: "+reference+"\n");
- String docu = (String)ref.getProperty("docu");
+ String docu = (String)ref.getProperty(DOCUMENTATION_URL);
if (docu != null)
- acknowledgement.append("Docu: "+docu+"\n");
+ acknowledgement.append("Documentation: "+docu+"\n");
if(acknowledgement.length()>1)
- logger.log(LogService.LOG_INFO, acknowledgement.toString());
-
+ logger.log(LogService.LOG_INFO, acknowledgement.toString());
}
public void dataSelected(Data[] selectedData) {
@@ -198,34 +190,6 @@
setEnabled(data != null); //&& isValid());
}
- //This method will be disabled until we can find a better solution
- //for extra validation beyond input/output checking
-/* private boolean isValid() {
- String valid = null;
- String[] classes = (String[]) ref.getProperty(Constants.OBJECTCLASS);
-
- if (classes != null && data != null) {
- for (int i=0; i < classes.length; i++) {
- if (classes[i].equals(DataValidator.class.getName())) {
- DataValidator validator = (DataValidator) bContext.getService(ref);
-
- //FIXME: Could cause concurrency problems...
- for (int j=0; j < data.length; j++) {
- if (converters[j] != null && converters[j].length > 0) {
- //does not work for large inputs...
- data[j] = converters[j][0].convert(data[j]);
- converters[j] = null;
- }
- }
-
- valid = validator.validate(data);
- }
- }
- }
-
- return valid == null || valid.length() == 0;
- }
-*/
private boolean isAsignableFrom(String type, Data datum) {
Object data = datum.getData();
boolean assignable = false;
@@ -252,6 +216,4 @@
public ServiceReference getServiceReference(){
return ref;
}
-
-
}
\ No newline at end of file
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-28 16:51:07 UTC (rev 740)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-28 20:30:10 UTC (rev 741)
@@ -28,12 +28,15 @@
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.algorithm.AlgorithmProperty;
import org.cishell.framework.algorithm.DataValidator;
+import org.cishell.framework.algorithm.ParameterMutator;
import org.cishell.framework.algorithm.ProgressMonitor;
import org.cishell.framework.algorithm.ProgressTrackable;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
-import org.cishell.framework.preference.PreferenceProperty;
+import org.cishell.framework.userprefs.UserPrefsProperty;
+import org.cishell.reference.gui.menumanager.Activator;
import org.cishell.reference.gui.menumanager.menu.metatypewrapper.ParamMetaTypeProvider;
+import org.cishell.reference.service.metatype.BasicMetaTypeProvider;
import org.cishell.service.conversion.Converter;
import org.cishell.service.guibuilder.GUIBuilderService;
import org.osgi.framework.BundleContext;
@@ -44,290 +47,344 @@
import org.osgi.service.log.LogService;
import org.osgi.service.metatype.AttributeDefinition;
import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.MetaTypeService;
import org.osgi.service.metatype.ObjectClassDefinition;
-
public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable {
- protected ServiceReference ref;
- protected BundleContext bContext;
- protected CIShellContext ciContext;
- protected Data[] originalData;
- protected Data[] data;
- protected Converter[][] converters;
- protected Dictionary parameters;
- protected Map idToLabelMap;
- protected MetaTypeProvider provider;
- protected ProgressMonitor progressMonitor;
- protected Algorithm algorithm;
-
- protected ConfigurationAdmin ca;
-
- //ConfigurationAdmin may be null
- public AlgorithmWrapper(ServiceReference ref, BundleContext bContext,
- CIShellContext ciContext, Data[] originalData, Data[] data,
- Converter[][] converters, ConfigurationAdmin ca) {
- this.ref = ref;
- this.bContext = bContext;
- this.ciContext = ciContext;
- this.originalData = originalData;
- this.data = data;
- this.converters = converters;
-
- this.ca = ca;
+ protected ServiceReference algFactoryRef;
+ protected BundleContext bContext;
+ protected CIShellContext ciContext;
+ protected Data[] originalData;
+ protected Data[] convertableData;
+ protected Converter[][] converters;
+ protected ProgressMonitor progressMonitor;
- this.idToLabelMap = new HashMap();
- this.progressMonitor = null;
-
-
- }
+ protected ConfigurationAdmin ca;
+ protected GUIBuilderService builder;
+ protected DataManagerService dataManager;
- /**
- * @see org.cishell.framework.algorithm.Algorithm#execute()
- */
- public Data[] execute() {
- try {
- for (int i=0; i < data.length; i++) {
- if (converters[i] != null) {
- data[i] = converters[i][0].convert(data[i]);
-
- if (data[i] == null && i < (data.length - 1)) {
- Exception e =
- new Exception("The converter " +
- converters[i].getClass().getName() +
- " returned a null result where data was expected.");
- throw e;
- }
- converters[i] = null;
- }
- }
-
- GUIBuilderService builder = (GUIBuilderService)
- ciContext.getService(GUIBuilderService.class.getName());
-
- AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref);
-
- if (factory instanceof DataValidator) {
- String validation = ((DataValidator) factory).validate(data);
-
- if (validation != null && validation.length() > 0) {
- String label = (String) ref.getProperty(LABEL);
- if (label == null) {
- label = "Algorithm";
- }
-
- builder.showError("Invalid Data", "The data given to \""+label+"\" is incompatible for this reason: "+validation , (String) null);
- return null;
- }
- }
-
- this.provider = factory.createParameters(data);
- if (this.provider != null) {
- this.provider = wrapProvider(this.ref, this.provider);
- }
- String pid = determineParameterPID(ref, provider);
-
- this.parameters = new Hashtable();
- if (provider != null) {
- this.parameters = builder.createGUIandWait(pid, provider);
- }
+ // ConfigurationAdmin may be null
+ public AlgorithmWrapper(ServiceReference ref, CIShellContext ciContext, BundleContext bContext,
+ Data[] originalData, Data[] data, Converter[][] converters, ConfigurationAdmin ca) {
+ this.algFactoryRef = ref;
+ this.bContext = bContext;
+ this.ciContext = ciContext;
+ this.originalData = originalData;
+ this.convertableData = data;
+ this.converters = converters;
- if(this.parameters == null) {
- return new Data[0];
- }
-
- algorithm = factory.createAlgorithm(data, parameters, ciContext);
-
- printParameters();
-
- if (progressMonitor != null && algorithm instanceof ProgressTrackable) {
- ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor);
- }
-
- Data[] outData = algorithm.execute();
-
- if (outData != null) {
- DataManagerService dataManager = (DataManagerService)
- bContext.getService(bContext.getServiceReference(
- DataManagerService.class.getName()));
-
- doParentage(outData);
-
- List goodData = new ArrayList();
- for (int i=0; i < outData.length; i++) {
- if (outData[i] != null) {
- goodData.add(outData[i]);
- }
- }
-
- outData = (Data[]) goodData.toArray(new Data[0]);
-
- if (outData.length != 0) {
- dataManager.setSelectedData(outData);
- }
- }
-
- return outData;
- } catch (Throwable e) {
- GUIBuilderService guiBuilder = (GUIBuilderService)
- ciContext.getService(GUIBuilderService.class.getName());
- guiBuilder.showError("Error!",
- "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+
- "\" had an error while executing.", e);
-
- return new Data[0];
- }
- }
-
- //wrap the provider to provide special functionality, such as overriding default values of attributes through preferences.
- protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) {
- if (ca != null && hasParamDefaultPreferences(algRef)) {
- String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID);
- String paramOverrideConfPID = standardServicePID + PreferenceProperty.PARAM_PREFS_CONF_SUFFIX;
- try {
- Configuration defaultParamValueOverrider = ca.getConfiguration(paramOverrideConfPID, null);
- Dictionary defaultParamOverriderDict = defaultParamValueOverrider.getProperties();
- MetaTypeProvider wrappedProvider = new ParamMetaTypeProvider(unwrappedProvider, defaultParamOverriderDict);
- return wrappedProvider;
- } catch (IOException e) {
- return unwrappedProvider;
- }
- } else {
- }
-
- return unwrappedProvider;
- }
-
- protected String determineParameterPID(ServiceReference ref, MetaTypeProvider provider) {
- String overridePID = (String) ref.getProperty(AlgorithmProperty.PARAMETER_PID);
- if (overridePID != null) {
- return overridePID;
- } else {
- return (String) ref.getProperty(Constants.SERVICE_PID);
- }
- }
-
- protected void printParameters() {
- LogService logger = getLogService();
- setupIdToLabelMap();
-
- if (logger != null) {
- if (!this.parameters.isEmpty()) {
- //adjust to log all input parameters in one block
- StringBuffer inputParams = new StringBuffer("\n"+"Input Parameters:");
-
- for (Enumeration e = this.parameters.keys(); e
- .hasMoreElements();) {
- String key = (String) e.nextElement();
- Object value = this.parameters.get(key);
-
- key = (String) idToLabelMap.get(key);
- inputParams.append("\n"+key+": "+value);
-
- }
- logger.log(LogService.LOG_INFO, inputParams.toString());
- }
- }
- }
-
- protected void setupIdToLabelMap() {
- if (provider != null) {
- ObjectClassDefinition ocd = null;
- try {
- String pid = (String) ref.getProperty(Constants.SERVICE_PID);
- ocd = provider.getObjectClassDefinition(pid, null);
-
- if (ocd != null) {
- AttributeDefinition[] attr =
- ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
-
- for (int i=0; i < attr.length; i++) {
- String id = attr[i].getID();
- String label = attr[i].getName();
-
- idToLabelMap.put(id, label);
- }
- }
- } catch (IllegalArgumentException e) {}
- }
- }
-
- //only does anything if parentage=default so far...
- protected void doParentage(Data[] outData) {
- //make sure the parent set is the original Data and not the
- //converted data...
- if (outData != null && data != null && originalData != null
- && originalData.length == data.length) {
- for (int i=0; i < outData.length; i++) {
- if (outData[i] != null) {
- Object parent = outData[i].getMetaData().get(DataProperty.PARENT);
-
- if (parent != null) {
- for (int j=0; j < data.length; i++) {
- if (parent == data[j]) {
- outData[i].getMetaData().put(DataProperty.PARENT,
- originalData[j]);
- break;
- }
- }
- }
- }
- }
- }
-
- //check and act on parentage settings
- String parentage = (String)ref.getProperty("parentage");
- if (parentage != null) {
- parentage = parentage.trim();
- if (parentage.equalsIgnoreCase("default")) {
- if (originalData != null && originalData.length > 0 && originalData[0] != null) {
-
- for (int i=0; i < outData.length; i++) {
- //if they don't have a parent set already then we set one
- if (outData[i] != null &&
- outData[i].getMetaData().get(DataProperty.PARENT) == null) {
- outData[i].getMetaData().put(DataProperty.PARENT, originalData[0]);
- }
- }
- }
- }
- }
- }
-
- private LogService getLogService() {
- ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName());
- LogService log = null;
-
- if (serviceReference != null) {
- log = (LogService) bContext.getService(
- bContext.getServiceReference(LogService.class.getName()));
+ this.ca = ca;
+ this.progressMonitor = null;
+ this.builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName());
+ this.dataManager = (DataManagerService) bContext.getService(bContext
+ .getServiceReference(DataManagerService.class.getName()));
+ }
+
+ /**
+ * @see org.cishell.framework.algorithm.Algorithm#execute()
+ */
+ public Data[] execute() {
+ try {
+ // prepare to run the algorithm
+
+ Data[] data = convertDataToRequiredFormat(this.convertableData, this.converters);
+ AlgorithmFactory algFactory = (AlgorithmFactory) bContext.getService(algFactoryRef);
+ boolean inputIsValid = testDataValidityIfPossible(algFactory, data);
+ if (!inputIsValid) return null;
+
+ // create algorithm parameters
+
+ MetaTypeProvider parameterSetupInfo = obtainParameterSetupInfo(algFactory, data);
+ Dictionary parameters = createParameters(parameterSetupInfo);
+ printParameters(parameters, parameterSetupInfo);
+
+ // create the algorithm
+
+ Algorithm algorithm = algFactory.createAlgorithm(data, parameters, ciContext);
+ trackAlgorithmProgressIfPossible(algorithm);
+
+ // execute the algorithm
+
+ Data[] rawOutData = algorithm.execute();
+
+ // return the algorithm's output
+
+ Data[] processedOutData = processOutData(rawOutData);
+ return processedOutData;
+
+ } catch (Throwable e) {
+ // show any errors to the user
+
+ showGenericExecutionError(e);
+ return new Data[0];
}
-
- return log;
}
+ // should return null if algorithm is not progress trackable
public ProgressMonitor getProgressMonitor() {
+ return progressMonitor;
+ }
+
+ public void setProgressMonitor(ProgressMonitor monitor) {
+ progressMonitor = monitor;
+ }
+
+ protected Data[] convertDataToRequiredFormat(Data[] providedData, Converter[][] converters) throws Exception {
+ // convert data into the in_data format of the algorithm we are trying to run
+ Data[] readyData = new Data[providedData.length];
+
+ for (int i = 0; i < providedData.length; i++) {
+ if (converters[i] != null) {
+ // WARNING: arbitrarily chooses first converter out of a list of possible converters
+ readyData[i] = converters[i][0].convert(providedData[i]);
+
+ if (readyData[i] == null && i < (readyData.length - 1)) {
+ Exception e = new Exception("The converter " + converters[i].getClass().getName()
+ + " returned a null result where data was expected.");
+ throw e;
+ }
+ converters[i] = null;
+ }
+ }
+
+ return readyData;
+ }
+
+ protected boolean testDataValidityIfPossible(AlgorithmFactory algFactory, Data[] dataInQuestion) {
+ String validation = ((DataValidator) algFactory).validate(dataInQuestion);
+
+ if (validation != null && validation.length() > 0) {
+ String label = (String) algFactoryRef.getProperty(LABEL);
+ if (label == null) {
+ label = "Algorithm";
+ }
+
+ builder.showError("Invalid Data", "The data given to \"" + label + "\" is incompatible for this reason: "
+ + validation, (String) null);
+ return false;
+ }
+ return true;
+ }
+
+ protected MetaTypeProvider obtainParameterSetupInfo(AlgorithmFactory algFactory, Data[] data) {
+
+ MetaTypeProvider provider = null;
+
+ // first, get the standard parameter setup info for the algorithm factory.
+
+ MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName());
+ if (metaTypeService != null) {
+ provider = metaTypeService.getMetaTypeInformation(algFactoryRef.getBundle());
+ }
+
+ // if the algorithm factory wants to mutate the parameter setup info, allow it to.
+ if (algFactory instanceof ParameterMutator && provider != null) {
+ String parameterPID = determineParameterPID(algFactoryRef, provider);
+ try {
+ ObjectClassDefinition ocd = provider.getObjectClassDefinition(parameterPID, null);
+
+ ocd = ((ParameterMutator) algFactory).mutateParameters(data, ocd);
+
+ if (ocd != null) {
+ provider = new BasicMetaTypeProvider(ocd);
+ }
+ } catch (IllegalArgumentException e) {
+ LogService logger = getLogService();
+ logger.log(LogService.LOG_DEBUG, algFactoryRef.getProperty(Constants.SERVICE_PID)
+ + " has an invalid metatype parameter id: " + parameterPID);
+ }
+ }
+
+ // wrap the parameter setup info so that default parameter values
+ // specified in the user preference service are filled in.
+
+ if (provider != null) {
+ provider = wrapProvider(this.algFactoryRef, provider);
+ }
+
+ return provider;
+ }
+
+ protected Dictionary createParameters(MetaTypeProvider parameterSetupInfo) {
+ // ask the user to specify the values for algorithm's parameters
+ String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo);
+ Dictionary parameters = new Hashtable();
+ if (parameterSetupInfo != null) {
+ parameters = builder.createGUIandWait(parameterPID, parameterSetupInfo);
+ }
+ return parameters;
+ }
+
+ protected void printParameters(Dictionary parameters, MetaTypeProvider parameterSetupInfo) {
+ LogService logger = getLogService();
+ Map idToLabelMap = createIdToLabelMap(parameterSetupInfo);
+
+ if (logger != null) {
+ if (parameters.isEmpty()) {
+ // adjust to log all input parameters in one block
+ StringBuffer inputParams = new StringBuffer("\n" + "Input Parameters:");
+
+ for (Enumeration e = parameters.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ Object value = parameters.get(key);
+
+ key = (String) idToLabelMap.get(key);
+ inputParams.append("\n" + key + ": " + value);
+
+ }
+ logger.log(LogService.LOG_INFO, inputParams.toString());
+ }
+ }
+ }
+
+ protected void trackAlgorithmProgressIfPossible(Algorithm algorithm) {
if (algorithm instanceof ProgressTrackable) {
- return progressMonitor;
+ ((ProgressTrackable) algorithm).setProgressMonitor(progressMonitor);
}
- else {
+ }
+
+ protected Data[] processOutData(Data[] rawOutData) {
+ if (rawOutData != null) {
+ doParentage(rawOutData);
+ List goodData = new ArrayList();
+ for (int i = 0; i < rawOutData.length; i++) {
+ if (rawOutData[i] != null) {
+ goodData.add(rawOutData[i]);
+ }
+ }
+
+ Data[] processedOutData = (Data[]) goodData.toArray(new Data[goodData.size()]);
+ if (rawOutData.length != 0) {
+ dataManager.setSelectedData(rawOutData);
+ }
+
+ return processedOutData;
+ } else {
return null;
}
}
- public void setProgressMonitor(ProgressMonitor monitor) {
- progressMonitor = monitor;
+ // wrap the provider to provide special functionality, such as overriding default values of attributes through
+ // preferences.
+ protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) {
+ if (ca != null && hasParamDefaultPreferences(algRef)) {
+ String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID);
+ String paramOverrideConfPID = standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX;
+ try {
+ Configuration defaultParamValueOverrider = ca.getConfiguration(paramOverrideConfPID, null);
+ Dictionary defaultParamOverriderDict = defaultParamValueOverrider.getProperties();
+ MetaTypeProvider wrappedProvider = new ParamMetaTypeProvider(unwrappedProvider,
+ defaultParamOverriderDict);
+ return wrappedProvider;
+ } catch (IOException e) {
+ return unwrappedProvider;
+ }
+ } else {
+ }
+
+ return unwrappedProvider;
}
-
- private boolean hasParamDefaultPreferences(ServiceReference algRef) {
- String prefsToPublish = (String) algRef.getProperty(PreferenceProperty.PREFS_PUBLISHED_KEY);
+
+ protected String determineParameterPID(ServiceReference ref, MetaTypeProvider provider) {
+ String overridePID = (String) ref.getProperty(AlgorithmProperty.PARAMETERS_PID);
+ if (overridePID != null) {
+ return overridePID;
+ } else {
+ return (String) ref.getProperty(Constants.SERVICE_PID);
+ }
+ }
+
+ protected Map createIdToLabelMap(MetaTypeProvider parameterSetupInfo) {
+ Map idToLabelMap = new HashMap();
+ if (parameterSetupInfo != null) {
+ ObjectClassDefinition ocd = null;
+ try {
+ String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo);
+ ocd = parameterSetupInfo.getObjectClassDefinition(parameterPID, null);
+
+ if (ocd != null) {
+ AttributeDefinition[] attr = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
+
+ for (int i = 0; i < attr.length; i++) {
+ String id = attr[i].getID();
+ String label = attr[i].getName();
+
+ idToLabelMap.put(id, label);
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ return idToLabelMap;
+ }
+
+ // only does anything if parentage=default so far...
+ protected void doParentage(Data[] outData) {
+ // make sure the parent set is the original Data and not the
+ // converted data...
+ if (outData != null && convertableData != null && originalData != null
+ && originalData.length == convertableData.length) {
+ for (int i = 0; i < outData.length; i++) {
+ if (outData[i] != null) {
+ Object parent = outData[i].getMetadata().get(DataProperty.PARENT);
+
+ if (parent != null) {
+ for (int j = 0; j < convertableData.length; i++) {
+ if (parent == convertableData[j]) {
+ outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // check and act on parentage settings
+ String parentage = (String) algFactoryRef.getProperty("parentage");
+ if (parentage != null) {
+ parentage = parentage.trim();
+ if (parentage.equalsIgnoreCase("default")) {
+ if (originalData != null && originalData.length > 0 && originalData[0] != null) {
+
+ for (int i = 0; i < outData.length; i++) {
+ // if they don't have a parent set already then we set one
+ if (outData[i] != null && outData[i].getMetadata().get(DataProperty.PARENT) == null) {
+ outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected LogService getLogService() {
+ ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName());
+ LogService log = null;
+
+ if (serviceReference != null) {
+ log = (LogService) bContext.getService(bContext.getServiceReference(LogService.class.getName()));
+ }
+
+ return log;
+ }
+
+ protected boolean hasParamDefaultPreferences(ServiceReference algRef) {
+ String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY);
if (prefsToPublish == null) {
return true;
}
-
- if (prefsToPublish.contains(PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE)) {
+
+ if (prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE)) {
return true;
} else {
return false;
}
}
+
+ protected void showGenericExecutionError(Throwable e) {
+ builder.showError("Error!", "The Algorithm: \"" + algFactoryRef.getProperty(AlgorithmProperty.LABEL)
+ + "\" had an error while executing.", e);
+ }
}
Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java
===================================================================
--- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-03-28 16:51:07 UTC (rev 740)
+++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-03-28 20:30:10 UTC (rev 741)
@@ -13,7 +13,6 @@
* ***************************************************************************/
package org.cishell.reference.gui.menumanager.menu;
-//Java
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -53,12 +52,6 @@
import org.xml.sax.SAXException;
-/*
- * Bonnie's comments:
- * weird, why implements AlgorithmProperty? It does not define any abstract interface.
- * Micah's comment, several millenia later:
- * It's so you can say things like "== LOSSLESS" as oppose to "== AlgorithmProperty.LOSSLESS".
- */
public class MenuAdapter implements AlgorithmProperty {
private IMenuManager menuBar;
private Shell shell;
@@ -121,7 +114,7 @@
// initializeMenu();
} catch (InvalidSyntaxException e) {
- getLog().log(LogService.LOG_ERROR, "Invalid Syntax", e);
+ getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e);
}
attemptToObtainConfigurationAdmin(bContext);
@@ -163,7 +156,6 @@
}
}
}
-
}
/*
* Parse default_menu.xml file. For each menu node, get the value of the attribut "pid"
@@ -187,7 +179,6 @@
private void processTopMenu (Element topMenuNode){
MenuManager topMenuBar = null;
-
/*
* The File and Help menus are created in ApplicationActionBarAdvisor.java
@@ -237,7 +228,7 @@
processSubMenu(el, groupMenuBar);
}
else if (menu_type.equalsIgnoreCase(PRESERVED_BREAK)){
- //It seems that Framework automatially takes care of issues
+ //It seems that Framework automatically takes care of issues
//such as double separators, a separator at the top or bottom
parentMenuBar.add(new Separator());
}
@@ -276,10 +267,10 @@
private void processAMenuNode(Element menuNode, MenuManager parentMenuBar ){
String menuName = menuNode.getAttribute(ATTR_NAME);
String pid = menuNode.getAttribute(ATTR_PID);
+ //System.out.println(">>>pid="+pid);
if (pid == null || pid.length()==0){
//check if the name is one of the preserved one
//if so add the default action
-
}
else{
//check if the pid has registered in pidToServiceReferenceMap
@@ -295,7 +286,7 @@
}
else{
//otherwise log the error
- getLog().log(LogService.LOG_WARNING,
+ getLog().log(LogService.LOG_DEBUG,
"Can not find an algorithm package associated with Menu: "
+menuName+" and pid: " +pid+ ". Skip to show it on the menu.");
}
@@ -386,19 +377,15 @@
menu = targetMenu.findMenuUsingPath(items[i]);
if (menu == null && items[i] != null) {
- menu = targetMenu.findMenuUsingPath(items[i].toLowerCase());
-
+ menu = targetMenu.findMenuUsingPath(items[i].toLowerCase());
}
- if (menu == null) {
-
+ if (menu == null) {
menu = createMenu(items[i],items[i]);
targetMenu.appendToGroup(ADDITIONS_GROUP, menu);
}
targetMenu = menu;
-
-
}
group = items[items.length-1];
@@ -416,8 +403,8 @@
Display.getDefault().asyncExec(updateAction);
} else {
-// getLog().log(LogService.LOG_WARNING,
-// "Bad menu path for Algorithm: " + ref.getProperty(LABEL));
+ getLog().log(LogService.LOG_DEBUG,
+ "Bad menu path for Algorithm: " + ref.getProperty(LABEL));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 16:51:14
|
Revision: 740
http://cishell.svn.sourceforge.net/cishell/?rev=740&view=rev
Author: mwlinnem
Date: 2008-03-28 09:51:07 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Result of merge between CIShell 1.0 updated org.cishell.framework and the preference changes.
Modified Paths:
--------------
branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF
branches/user_prefs/org.cishell.framework/javadoc.xml
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerListener.java
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerService.java
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerListener.java
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerService.java
branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/CIShellContext.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/LocalCIShellContext.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/Algorithm.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/DataValidator.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressMonitor.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressTrackable.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/BasicData.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/Data.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/overview.html
branches/user_prefs/org.cishell.framework/src/org/cishell/service/conversion/Converter.java
branches/user_prefs/org.cishell.framework/src/org/cishell/service/conversion/DataConversionService.java
branches/user_prefs/org.cishell.framework/src/org/cishell/service/conversion/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/service/guibuilder/GUI.java
branches/user_prefs/org.cishell.framework/src/org/cishell/service/guibuilder/GUIBuilderService.java
branches/user_prefs/org.cishell.framework/src/org/cishell/service/guibuilder/SelectionListener.java
branches/user_prefs/org.cishell.framework/src/org/cishell/service/guibuilder/package.html
Added Paths:
-----------
branches/user_prefs/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmExecutionException.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/package.html
branches/user_prefs/org.cishell.framework/src/org/cishell/service/conversion/ConversionException.java
Removed Paths:
-------------
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/preference/
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java
branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/package.html
Copied: branches/user_prefs/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs (from rev 739, trunk/core/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- branches/user_prefs/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ branches/user_prefs/org.cishell.framework/.settings/org.eclipse.jdt.core.prefs 2008-03-28 16:51:07 UTC (rev 740)
@@ -0,0 +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
Modified: branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF 2008-03-28 16:51:07 UTC (rev 740)
@@ -1,19 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: CIShell Framework API
+Bundle-Name: CIShell Platform API
Bundle-SymbolicName: org.cishell.framework
-Bundle-Version: 0.3.0
-Bundle-Vendor: Bruce Herr
+Bundle-Version: 1.0.0
+Bundle-Vendor: Cyberinfrastructure for Network Science Center
Import-Package: org.osgi.framework,
org.osgi.service.log,
org.osgi.service.metatype,
org.osgi.service.prefs
-Export-Package: org.cishell.app.service.datamanager,
- org.cishell.app.service.scheduler,
- org.cishell.framework,
- org.cishell.framework.algorithm,
- org.cishell.framework.data,
- org.cishell.framework.preference,
- org.cishell.service.conversion,
- org.cishell.service.guibuilder
-Eclipse-LazyStart: true
+Export-Package: org.cishell.app.service.datamanager;version="1.0.0",
+ org.cishell.app.service.scheduler;version="1.0.0",
+ org.cishell.framework;version="1.0.0",
+ org.cishell.framework.algorithm;version="1.0.0",
+ org.cishell.framework.data;version="1.0.0",
+ org.cishell.framework.userprefs;version="1.0.0",
+ org.cishell.service.conversion;version="1.0.0",
+ org.cishell.service.guibuilder;version="1.0.0"
+Bundle-ActivationPolicy: lazy
Modified: branches/user_prefs/org.cishell.framework/javadoc.xml
===================================================================
--- branches/user_prefs/org.cishell.framework/javadoc.xml 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/javadoc.xml 2008-03-28 16:51:07 UTC (rev 740)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="javadoc">
- <property name="version" value="0.5.0" />
+ <property name="version" value="1.0" />
<target name="javadoc">
<javadoc destdir="bin/doc"
access="public"
@@ -14,7 +14,7 @@
version="true"
nodeprecatedlist="false"
nodeprecated="false"
- packagenames="org.cishell.framework.data,org.cishell.service.guibuilder,org.cishell.app.service.scheduler,org.cishell.framework,org.cishell.app.service.datamanager,org.cishell.framework.algorithm,org.cishell.service.conversion"
+ packagenames="org.cishell.framework.data,org.cishell.framework.userprefs,org.cishell.service.guibuilder,org.cishell.app.service.scheduler,org.cishell.framework,org.cishell.app.service.datamanager,org.cishell.framework.algorithm,org.cishell.service.conversion"
sourcepath="src"
classpath="lib/osgi.core.jar:lib/osgi.compendium.jar"
overview="src/org/cishell/overview.html"
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerListener.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerListener.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerListener.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -17,7 +17,7 @@
/**
- * A listener that is notified of changes in the {@link DataManagerService}.
+ * A listener that is notified of changes in the {@link DataManagerService}
*
* @author Bruce Herr (bh...@bh...)
*/
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerService.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerService.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/DataManagerService.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -16,14 +16,14 @@
import org.cishell.framework.data.Data;
/**
- * A service for managing loaded {@link Data}s.
+ * A service for managing loaded {@link Data} objects.
* {@link DataManagerListener}s may be registered to be notified of changes
- * in the model manager.
+ * in the data manager.
*
- * Clients are encouraged to use this service for managing the models they have
- * loaded into memory. Algorithm writers are encouraged not to use this service
- * as it is not guaranteed to be available like the standard CIShell services
- * are.
+ * Application developers are encouraged to use this service for managing the
+ * models they have loaded into memory. Algorithm developers are encouraged not
+ * to use this service as it is not guaranteed to be available like the standard
+ * CIShell services are.
*
* @author Bruce Herr (bh...@bh...)
*/
@@ -81,7 +81,6 @@
*/
public void removeDataManagerListener(DataManagerListener listener);
-
/**
* Returns the label for a stored Data object
*
@@ -95,7 +94,7 @@
* to change the label so that it is unique.
*
* @param data The Data
- * @param label The new label for the data model.
+ * @param label The new label for the data model
*/
public void setLabel(Data data, String label);
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/package.html
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/package.html 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/datamanager/package.html 2008-03-28 16:51:07 UTC (rev 740)
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>org.cishell.framework.datamodel Package-level Javadoc</title>
+ <title>org.cishell.app.service.datamanager Package-level Javadoc</title>
<!--
/* ****************************************************************************
* CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
@@ -19,9 +19,12 @@
* ***************************************************************************/
-->
</head>
-<body>Provides the specification for the CIShell data manager service.
+<body>Provides interfaces for the CIShell Data Manager Service.
<h2>Package Specification</h2>
-This package specifies the API related to the data manager service.
+The API related to the Data Manager Service.
+@see <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+CIShell Specification 1.0</a>
+
</body>
</html>
\ No newline at end of file
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerListener.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerListener.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerListener.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -45,7 +45,7 @@
/**
* Notification that an already scheduled Algorithm has been unscheduled
- * and will therefore not be run.
+ * and will therefore not be run
*
* @param algorithm The scheduled Algorithm that was unscheduled
*/
@@ -62,8 +62,8 @@
* Notification that an Algorithm has finished executing
*
* @param algorithm The scheduled Algorithm
- * @param createdData The Data(s) it returned, or <code>null</code> if
- * it returned <code>null</code>
+ * @param createdData The {@link Data} array it returned, or
+ * <code>null</code> if it returned <code>null</code>
*/
public void algorithmFinished(Algorithm algorithm, Data[] createdData);
@@ -86,7 +86,7 @@
/**
* Notification that the scheduler's schedule of Algorithms to be run has
- * been cleared.
+ * been cleared
*/
public void schedulerCleared();
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerService.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerService.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/SchedulerService.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -23,9 +23,10 @@
* A service for scheduling {@link Algorithm}s to be run.
* {@link SchedulerListener}s may be registered to be notified of events.
*
- * Clients are encouraged to use this service for scheduling Algorithms to be
- * run. Algorithm writers are encouraged not to use this service as it is not
- * guaranteed to be available like the standard CIShell services are.
+ * Application Developers are encouraged to use this service for scheduling
+ * Algorithms to be run. Algorithm developers are encouraged not to use this
+ * service as it is not guaranteed to be available like the standard CIShell
+ * services are.
*
* @author Bruce Herr (bh...@bh...)
*/
@@ -88,7 +89,7 @@
public boolean unschedule(Algorithm algorithm);
/**
- * Adds a listener to be notified of events happening in the scheduler.
+ * Adds a listener to be notified of events happening in the scheduler
*
* @param listener The listener to be added
*/
@@ -137,11 +138,10 @@
*
* @param algorithm The Algorithm
* @return The scheduled time for the Algorithm to run or <code>null</code>
- * if the Algorithm is not scheduled or has completed execution.
+ * if the Algorithm is not scheduled or has completed execution
*/
public Calendar getScheduledTime(Algorithm algorithm);
-
/**
* Returns an Algorithm's associated ServiceReference if one was provided
* when the Algorithm was scheduled
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/package.html
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/package.html 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/app/service/scheduler/package.html 2008-03-28 16:51:07 UTC (rev 740)
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>org.cishell.framework.datamodel Package-level Javadoc</title>
+ <title>org.cishell.app.service.scheduler Package-level Javadoc</title>
<!--
/* ****************************************************************************
* CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
@@ -19,9 +19,12 @@
* ***************************************************************************/
-->
</head>
-<body>Provides the specification for the CIShell scheduler service.
+<body>Provides interfaces for the CIShell Scheduler Service.
<h2>Package Specification</h2>
-This package specifies the API related to the scheduler service.
+The API related to the Scheduler Service.
+@see <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+CIShell Specification 1.0</a>
+
</body>
</html>
\ No newline at end of file
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/CIShellContext.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/CIShellContext.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/CIShellContext.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -21,7 +21,7 @@
/**
* The context by which algorithms in the framework can gain access to standard
* CIShell services. An instantiated CIShellContext must provide access to at
- * least the default services (as of this specification, the OSGi
+ * least the default services (as of the 1.0 specification, the OSGi
* {@link LogService}, the OSGi {@link PreferencesService}, the
* CIShell defined {@link DataConversionService}, and the CIShell defined
* {@link GUIBuilderService}). Other services may be made available through
@@ -32,7 +32,7 @@
public interface CIShellContext {
/**
- * Contains an array of the strings to access the default services
+ * Contains an array of the valid strings corresponding to the default services
*/
public static final String[] DEFAULT_SERVICES =
new String[] { LogService.class.getName(),
@@ -44,10 +44,10 @@
* Locates and returns a standard service given the service name. The
* service name is generally the full class name of the service interface.
* For example, <code>LogService</code>'s string is
- * <code>org.osgi.service.log.LogService</code>
+ * <code>org.osgi.service.log.LogService</code>.
*
* @param service A string (usually the associated interface's full
- * class name) that specifies the service to retrieve.
+ * class name) that specifies the service to retrieve
* @return An instantiated version of the service requested
*/
public Object getService(String service);
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/LocalCIShellContext.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/LocalCIShellContext.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/LocalCIShellContext.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -20,7 +20,7 @@
* A simple implementation of {@link CIShellContext} that pulls the
* CIShell services from the provided {@link BundleContext} that all OSGi
* bundles receive on activation. This was included in the standard API since
- * it will be used frequently by CIShell Client writers.
+ * it will be used frequently by CIShell application developers.
*
* This implementation only returns standard services or the service strings
* given to it in its constructor.
@@ -36,7 +36,7 @@
* <code>BundleContext</code>
*
* @param bContext The <code>BundleContext</code> to use to find
- * the registered standard services.
+ * the registered standard services
*/
public LocalCIShellContext(BundleContext bContext) {
this(bContext, DEFAULT_SERVICES);
@@ -44,13 +44,13 @@
/**
* Initializes the CIShell context with a custom set of standard services.
- * Only the standard services provided will be allowed to be gotten from
+ * Only the service in the array will be allowed to be retrieved from
* this <code>CIShellContext</code>.
*
* @param bContext The <code>BundleContext</code> to use to find
- * registered standard services.
+ * registered standard services
* @param standardServices An array of strings specifying the services that
- * are allowed to be gotten from this class.
+ * are allowed to be retrieved from this class
*/
public LocalCIShellContext(BundleContext bContext, String[] standardServices) {
this.bContext = bContext;
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/Algorithm.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/Algorithm.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/Algorithm.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -13,33 +13,28 @@
* ***************************************************************************/
package org.cishell.framework.algorithm;
-import org.cishell.framework.CIShellContext;
import org.cishell.framework.data.Data;
/**
- * In CIShell, an algorithm can be basically any arbitrary code
- * execution cycle. What happens when the execute method is run is entirely
- * up to the Algorithm writer. Some algorithms may be primed with a Data array
- * that it analyzes and returns a derivitive Data array or it may convert from
- * one Data array to another or not take in any Data array and based on some
- * given parameters create an entirely new Data array.
+ * A class which executes some arbitrary code and optionally returns any data
+ * produced. What happens when the execute method is run is entirely
+ * up to the Algorithm developer. Algorithms should be primed with whatever data
+ * is needed, usually by its associated {@link AlgorithmFactory}, before
+ * execution. This allows an Algorithm to be set up, then scheduled for later
+ * execution.
*
- * Algorithms are typically also given a {@link CIShellContext} by which they
- * can gain access to standard services like logging, preferences, and gui
- * creation. If an algorithm only uses these standard services and does not pop
- * up any graphical gui (aside from using the GUIBuilderService) then this
- * Algorithm may be safely run remotely.
- *
* @author Bruce Herr (bh...@bh...)
*/
public interface Algorithm {
/**
- * Executes and optionally returns a Data array. Algorithms are usually
- * primed ahead of time with all the necessary data needed. This allows
- * an Algorithm to be set up, then scheduled for later execution.
+ * Executes and optionally returns a Data array
*
- * @return A Data array that was created or <code>null</code>
+ * @return A Data array that was created. <code>null</code> is ONLY acceptable
+ * when the algorithms out_data is null.
+ * @throws AlgorithmExecutionException An exception has occured while executing
+ * the algorithm. This exception should have a user-comprehendable message if
+ * at all possible.
*/
- public Data[] execute();
+ public Data[] execute() throws AlgorithmExecutionException;
}
Copied: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmExecutionException.java (from rev 739, trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmExecutionException.java)
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmExecutionException.java (rev 0)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmExecutionException.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -0,0 +1,36 @@
+/* ****************************************************************************
+ * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Apache License v2.0 which accompanies
+ * this distribution, and is available at:
+ * http://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Created on Feb 8, 2008 at Indiana University.
+ *
+ * Contributors:
+ * Indiana University - Initial API
+ * ***************************************************************************/
+package org.cishell.framework.algorithm;
+
+/**
+ * An exception which is thrown when an error occurs in the process of executing
+ * an {@link Algorithm}
+ *
+ * @author Bruce Herr (bh...@bh...)
+ */
+public class AlgorithmExecutionException extends Exception {
+ private static final long serialVersionUID = 9017277008277139930L;
+
+ public AlgorithmExecutionException(String message, Throwable exception) {
+ super(message, exception);
+ }
+
+ public AlgorithmExecutionException(Throwable exception) {
+ super(exception);
+ }
+
+ public AlgorithmExecutionException(String message) {
+ super(message);
+ }
+}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmFactory.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -17,45 +17,37 @@
import org.cishell.framework.CIShellContext;
import org.cishell.framework.data.Data;
-import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.MetaTypeService;
/**
- * A class for creating {@link Algorithm}s. This class provides the parameters
- * needed by an <code>Algorithm</code> on demand and when given correct data,
- * will create an <code>Algorithm</code> that can be executed. An algorithm
- * writer who wishes to be usable by CIShell clients must create an
- * implementation of this interface and register it (along with some standard
- * meta-data about the algorithm, defined in the {@link AlgorithmProperty}
- * class) in the OSGi service registry.
+ * A service interface for creating {@link Algorithm}s to be executed.
+ * An algorithm developer must create an implementation of this interface and
+ * register it (along with some standard metadata about the algorithm, defined
+ * in the {@link AlgorithmProperty} class) in the OSGi service registry.
+ * If the algorithm requires input in addition to the raw data provided, a
+ * {@link MetaTypeProvider} must be published to OSGi's {@link MetaTypeService}
+ * (usually through a METADATA.XML file in the algorithm's bundle).
*
+ * See the <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+ * CIShell Specification 1.0</a> for documentation on the full requirements for
+ * algorithm creation.
+ *
* @author Bruce Herr (bh...@bh...)
*/
public interface AlgorithmFactory {
+
/**
- * Creates a set of parameter definitions that define what parameters are
- * needed in order to run its associated Algorithm.
+ * Creates an {@link Algorithm} to be executed
*
- * @param data An optional argument, the Data array that will be given to
- * this class to create an Algorithm with the createAlgorithm
- * method. Clients that don't know the Data array that is going
- * to be used ahead of time can give a <code>null</code> value.
- * @return An OSGi {@link MetaTypeProvider} that defines the parameters
- * needed by the Algorithm this class creates. May be
- * <code>null</code> if no parameters are needed.
- */
- public MetaTypeProvider createParameters(Data[] data);
-
- /**
- * Creates an {@link Algorithm} to be executed.
- *
* @param data The data to be given to the Algorithm to process.
* Some Algorithms may ignore this value. The order and
* type of data given are specified in the service
* dictionary (the 'in_data' key) when registered as a
* service in OSGi.
* @param parameters A set of key-value pairs that were created based on
- * the parameters given by the createParameters method.
- * @param context The context by which an Algorithm can gain access to
+ * the associated input specification published to the
+ * {@link MetaTypeService}
+ * @param context The context by which the Algorithm can gain access to
* standard CIShell services
* @return An <code>Algorithm</code> primed for execution
*/
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -15,29 +15,50 @@
/**
* A standard set of properties and values used for creating a service
- * Dictionary that is provided when registering an AlgorithmFactory with the
- * OSGi service registry.
+ * metadata Dictionary that is provided when registering an
+ * {@link AlgorithmFactory} with the OSGi service registry.
*
+ * See the <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+ * CIShell Specification 1.0</a> for documentation on each property.
+ *
* @author Bruce Herr (bh...@bh...)
*/
public interface AlgorithmProperty {
public static final String IN_DATA = "in_data";
public static final String OUT_DATA = "out_data";
public static final String NULL_DATA = "null";
- public static final String CONVERSION = "conversion";
- public static final String LOSSY = "lossy";
- public static final String LOSSLESS = "lossless";
- public static final String MENU_PATH = "menu_path";
+
+ public static final String PARAMETERS_PID = "parameters_pid";
+
+ public static final String PARENTAGE = "parentage";
+ public static final String DEFAULT_PARENTAGE="default";
+
+ public static final String ALGORITHM_TYPE = "type";
+ public static final String TYPE_CONVERTER = "converter";
+ public static final String TYPE_VALIDATOR = "validator";
+ public static final String TYPE_DATASET = "dataset";
+
+ public static final String REMOTEABLE = "remoteable";
+ public static final String REMOTE = "remote";
+
public static final String LABEL = "label";
public static final String DESCRIPTION = "description";
+
+ public static final String MENU_PATH = "menu_path";
public static final String ADDITIONS_GROUP = "additions";
public static final String START_GROUP = "start";
public static final String END_GROUP = "end";
- public static final String REMOTEABLE = "remoteable";
- public static final String REMOTE = "remote";
- public static final String ALGORITHM_TYPE = "type";
- public static final String TYPE_CONVERTER = "converter";
- public static final String TYPE_ALGORITHM = "algorithm";
- public static final String TYPE_DATASET = "dataset";
- public static final String PARAMETER_PID = "parameter_pid";
+
+ public static final String CONVERSION = "conversion";
+ public static final String LOSSY = "lossy";
+ public static final String LOSSLESS = "lossless";
+
+ public static final String AUTHORS = "authors";
+ public static final String IMPLEMENTERS = "implementers";
+ public static final String INTEGRATORS = "integrators";
+
+ public static final String DOCUMENTATION_URL = "documentation_url";
+ public static final String REFERENCE = "reference";
+ public static final String REFERENCE_URL = "reference_url";
+ public static final String WRITTEN_IN = "written_in";
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/DataValidator.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/DataValidator.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/DataValidator.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -24,10 +24,6 @@
* make additional checks. For example, if an algorithm only worked on
* symmetric matrices, this interface would check the data ahead of time
* to ensure that the given matrix was in fact a symmetric matrix.
- * <br />
- * In order for CIShell clients to fully recognize this additional validation
- * method, an algorithm writer must register this interface in addition to the
- * algorithm interface when registering their service.
*
* @author Bruce Herr (bh...@bh...)
*/
Copied: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java (from rev 739, trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java)
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java (rev 0)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ParameterMutator.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -0,0 +1,46 @@
+/* ****************************************************************************
+ * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Apache License v2.0 which accompanies
+ * this distribution, and is available at:
+ * http://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Created on Mar 7, 2008 at Indiana University.
+ *
+ * Contributors:
+ * Indiana University -
+ * ***************************************************************************/
+package org.cishell.framework.algorithm;
+
+import org.cishell.framework.data.Data;
+import org.osgi.service.metatype.AttributeDefinition;
+import org.osgi.service.metatype.ObjectClassDefinition;
+
+/**
+ * An additional interface an {@link AlgorithmFactory} can implement that allows
+ * for adding, modifying, or removing input parameters before being shown to the
+ * end-user for input. This interface is often implemented by algorithms that
+ * wish to customize the user interface based on the actual input data.
+ *
+ * @author Bruce Herr (bh...@bh...)
+ */
+public interface ParameterMutator {
+
+ /**
+ * Adds, modifies, or removes {@link Algorithm} parameters
+ * ({@link AttributeDefinition}s) from a given {@link ObjectClassDefinition}
+ * returning either the same (if no changes are made) input or a new,
+ * mutated version of the input
+ *
+ * @param data An optional argument, the Data array that will be given to
+ * this class to create an Algorithm with the createAlgorithm
+ * method. Applications that don't know the Data array that is going
+ * to be used ahead of time can give a <code>null</code> value.
+ * @param parameters A set of AttributeDefinitions which define the
+ * algorithm's input parameters
+ * @return An OSGi {@link ObjectClassDefinition} that defines the parameters
+ * needed by the Algorithm this class creates
+ */
+ public ObjectClassDefinition mutateParameters(Data[] data, ObjectClassDefinition parameters);
+}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressMonitor.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressMonitor.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressMonitor.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -16,9 +16,9 @@
/**
* A class to monitor the progress of an algorithm. It allows for notification
* of progress, notification of cancellation, notification of pausing, and
- * description of current work during execution. These methods are generally
- * only called by the algorithm with the CIShell client providing the progress
- * monitor implementation.
+ * description of current work during execution. Except for the setter methods,
+ * the methods are generally only called by the algorithm with the CIShell
+ * application providing the progress monitor implementation.
*
* @author Bruce Herr (bh...@bh...)
*/
@@ -59,14 +59,14 @@
/**
* Notifies the start of execution of the algorithm in addition to
- * revealing how many work units will be used.
+ * revealing how many work units will be used
*
- * @param capabilities An ORed int that tells the monitor what the
+ * @param capabilities An OR'ed int that tells the monitor what the
* algorithm is capable of with respect to the
- * monitor. The ORed values are taken from the int
+ * monitor. The OR'ed values are taken from the int
* constants specified in this interface.
- * @param totalWorkUnits The number of work units, may be -1 if the
- * algorithm does not provide progress information.
+ * @param totalWorkUnits The number of work units, -1 if the
+ * algorithm does not provide progress information
*/
public void start(int capabilities, int totalWorkUnits);
@@ -74,19 +74,19 @@
* Notifies that a certain number of units of work has been completed
*
* @param work The number of units of work completed
- * since last notification.
+ * since last notification
*/
public void worked(int work);
/**
- * The algorithm is finished executing.
+ * The algorithm is finished executing
*/
public void done();
/**
* Sets or clears a flag for cancellation of this algorithm's execution.
- * An algorithm writer can ignore or clear this flag if it cannot stop
- * midstream. This is one of the methods that can be called by someone
+ * An algorithm developer can ignore or clear this flag if it cannot stop
+ * midstream. This is one of the methods that can be called by something
* other than the algorithm.
*
* @param value Set or clear the cancellation request
@@ -104,8 +104,8 @@
/**
* Sets or clears a flag for pausing of this algorithm's execution. An
- * algorithm writer can ignore or clear this flag if it cannot pause
- * midstream. This is one of the methods that can be called by someone
+ * algorithm developer can ignore or clear this flag if it cannot pause
+ * midstream. This is one of the methods that can be called by something
* other than the algorithm.
*
* @param value Set or clear the pause request
@@ -123,7 +123,7 @@
/**
* Method to describe what the algorithm is currently doing for the benefit
- * of the users of the algorithm as it progresses during execution.
+ * of the users of the algorithm as it progresses during execution
*
* @param currentWork A short description of the current work the algorithm
* is doing
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressTrackable.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressTrackable.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/ProgressTrackable.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -38,10 +38,10 @@
/**
* Returns the progress monitor currently in use, or <code>null</code> if
- * no monitor has been set.
+ * no monitor has been set
*
* @return The current progress monitor, or <code>null</code> if there
- * isn't one set.
+ * isn't one set
*/
public ProgressMonitor getProgressMonitor();
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/package.html
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/package.html 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/package.html 2008-03-28 16:51:07 UTC (rev 740)
@@ -19,12 +19,12 @@
* ***************************************************************************/
-->
</head>
-<body>Provides interfaces required for creating CIShell compatible algorithms.
+<body>Provides interfaces required for creating CIShell algorithms.
<h2>Package Specification</h2>
-This package specifies the API related to creation of CIShell compatible
-algorithms.
+The API related to creation of CIShell algorithms.
-TODO: Describe here how an algorithm is integrated into OSGi.
+@see <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+CIShell Specification 1.0</a>
</body>
</html>
\ No newline at end of file
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/BasicData.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/BasicData.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/BasicData.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -29,7 +29,7 @@
private String format;
/**
- * Creates a Data object with the given data and an empty meta-data
+ * Creates a Data object with the given data and an empty metadata
* {@link Dictionary}
*
* @param data The data being wrapped
@@ -39,9 +39,9 @@
}
/**
- * Creates a Data object with the given data and meta-data {@link Dictionary}
+ * Creates a Data object with the given data and metadata {@link Dictionary}
*
- * @param properties The meta-data about the data
+ * @param properties The metadata about the data
* @param data The data being wrapped
*/
public BasicData(Dictionary properties, Object data, String format) {
@@ -58,9 +58,9 @@
}
/**
- * @see org.cishell.framework.data.Data#getMetaData()
+ * @see org.cishell.framework.data.Data#getMetadata()
*/
- public Dictionary getMetaData() {
+ public Dictionary getMetadata() {
return properties;
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/Data.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/Data.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/Data.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -17,40 +17,37 @@
import java.util.Dictionary;
/**
- * A class that encapsulates data and its meta-data. This class is used to pass
- * data between algorithms and is what algorithms optionally create when executed.
+ * A class that contains data, its format, and its metadata. This class is used
+ * to pass data between algorithms and is what algorithms optionally create when
+ * executed.
*
* @author Bruce Herr (bh...@bh...)
*/
public interface Data {
/**
- * Returns the meta-data associated with the data stored in this Data object.
- * Some standard keys are in the {@link DataProperty} interface.
+ * Returns the metadata associated with the data stored in this Data object.
+ * Standard keys and values are in the {@link DataProperty} interface.
*
- * @return The data's meta-data
+ * @return The data's metadata
*/
- public Dictionary getMetaData();
+ public Dictionary getMetadata();
/**
- * Returns the data stored in this Data object.
+ * Returns the data stored in this Data object
*
- * @return The data (a java object)
+ * @return The data (a Java object)
*/
public Object getData();
/**
- * Get the format of the encapsulated data. If the data is a {@link File},
+ * Returns the format of the encapsulated data. If the data is a {@link File},
* then this method returns what MIME type it is with "file:" prepended
- * (eg. file:text/plain). Otherwise, the string returned should be the java
+ * (eg. file:text/plain). Otherwise, the string returned should be the Java
* class it represents. For algorithms this format should be the same as
* their OUT_DATA property.
*
* @return The main format of the data
*/
public String getFormat();
-
- //TODO: Consider these methods for inclusion in Data
- //public String getUID(); //may be better for specifying parent datamodels
- //public Object getDataAsFormat(String format);
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -15,8 +15,8 @@
/**
- * Standard property keys to use when creating meta-data for a
- * {@link Data} object.
+ * Standard property keys and values to use when creating metadata for a
+ * {@link Data} object
*
* @author Bruce Herr (bh...@bh...)
*/
@@ -28,16 +28,23 @@
public static final String LABEL = "Label";
/**
+ * A short label to give the Data object for shorter displays. It is
+ * recommended to keep the string length below 20 characters. This will often
+ * be used for recommended file names when saving the data to disk. The type
+ * associated with this property is of type {@link String}.
+ */
+ public static final String SHORT_LABEL = "Short_Label";
+
+ /**
* The parent Data object of the Data object. This is used when a Data object
* is derived from another Data object to show the hierarchical relationship
- * between them. This property can be null, signifying that the Data object
+ * between them. This property can be null, signifying that the Data object
* was not derived from any other Data object, such as when loading a new Data
* object from a file. The type associated with this property is of type
- * {@link Data}
+ * {@link Data}.
*/
public static final String PARENT = "Parent";
- //TODO: should we consider removing this/changing it?
/**
* The general type of the Data object. Various standard types are created as
* constants with name *_TYPE from this class. These can be used, or new
@@ -49,7 +56,7 @@
/**
* Flag to determine if the Data object has been modified and not saved since
* the modification. This is used to do things like notify the user before
- * they exit that a modified Data object exists and see if they want to save
+ * they exit that a modified Data object exists and ask if they want to save
* it. The type associated with this property is of type {@link Boolean}.
*/
public static final String MODIFIED = "Modified";
@@ -59,6 +66,9 @@
/** Says this data model is abstractly a network */
public static String NETWORK_TYPE = "Network";
+
+ /** Says this data model is abstractly a table */
+ public static String TABLE_TYPE = "Table";
/** Says this data model is abstractly a tree */
public static String TREE_TYPE = "Tree";
@@ -66,9 +76,9 @@
/** Says this data model is abstractly an unknown type */
public static String OTHER_TYPE = "Unknown";
- /** a plain text file */
+ /** Says this data model is abstractly a plain text file */
public static String TEXT_TYPE = "Text";
- /** a file can be fed to xmgrace */
- public static String GRACE_TYPE = "Grace";
+ /** Says this data model is abstractly a data plot */
+ public static String PLOT_TYPE = "Plot";
}
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/package.html
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/package.html 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/data/package.html 2008-03-28 16:51:07 UTC (rev 740)
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>org.cishell.framework.datamodel Package-level Javadoc</title>
+ <title>org.cishell.framework.data Package-level Javadoc</title>
<!--
/* ****************************************************************************
* CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
@@ -21,9 +21,10 @@
</head>
<body>Provides interfaces required for creating Data objects.
<h2>Package Specification</h2>
-This package specifies the API related to creation of Data objects.
+The API related to creation of Data objects.
-TODO: Describe here what a Data object is, how it is used, and why it is used.
+@see <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+CIShell Specification 1.0</a>
</body>
</html>
\ No newline at end of file
Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/package.html
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/package.html 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/package.html 2008-03-28 16:51:07 UTC (rev 740)
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>org.cishell.framework.algorithm Package-level Javadoc</title>
+ <title>org.cishell.framework Package-level Javadoc</title>
<!--
/* ****************************************************************************
* CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
@@ -19,11 +19,12 @@
* ***************************************************************************/
-->
</head>
-<body>The base package of the CIShell framework specification.
+<body>The core package for the CIShell platform API.
<h2>Package Specification</h2>
-This package is the root package for the CIShell framework specification
+The core package for the CIShell platform API
-TODO: Talk about the framework and give links.
+@see <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+CIShell Specification 1.0</a>
</body>
</html>
\ No newline at end of file
Copied: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs (from rev 739, trunk/core/org.cishell.framework/src/org/cishell/framework/userprefs)
Deleted: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java
===================================================================
--- trunk/core/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java 2008-03-28 16:40:44 UTC (rev 739)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -1,112 +0,0 @@
-/* ****************************************************************************
- * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Apache License v2.0 which accompanies
- * this distribution, and is available at:
- * http://www.apache.org/licenses/LICENSE-2.0.html
- *
- * Created on Feb 8, 2008 at Indiana University.
- *
- * Contributors:
- * Indiana University -
- * ***************************************************************************/
-package org.cishell.framework.userprefs;
-
-/**
- * A standard set of properties and values to be placed in a service's
- * metadata Dictionary when registering a service with the OSGi service registry
- * for the purpose of publishing and receiving user-adjustable preferences.
- *
- * See the <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
- * CIShell Specification 1.0</a> for information on publishing user-adjustable
- * preferences.
- */
-public interface UserPrefsProperty {
-
- /**
- * The suffix to add to the service's PID for generating a local preferences
- * PID when using the standard naming convention
- */
- public static final String LOCAL_PREFS_OCD_SUFFIX = ".prefs.local";
-
- /**
- * The suffix to add to the service's PID for generating a global preferences
- * PID when using the standard naming convention
- */
- public static final String GLOBAL_PREFS_OCD_SUFFIX = ".prefs.global";
-
- /**
- * The suffix to add to the service's PID for an {@link Algorithm}'s
- * user-entered input parameters PID when using the standard naming convention
- */
- public static final String PARAM_PREFS_OCD_SUFFIX = "";
-
- /**
- * The key for specifying a local preferences PID.
- * Only use this when not following the standard naming convention.
- */
- public static final String LOCAL_PREFS_PID = "local_prefs_pid";
-
- /**
- * The key for specifying a global preferences PID.
- * Only use this when not following the standard naming convention.
- */
- public static final String GLOBAL_PREFS_PID = "global_prefs_pid";
-
-
-
- /**
- * The key for specifying what types of preferences are published
- */
- public static final String PREFS_PUBLISHED_KEY = "prefs_published";
-
- /**
- * The value for specifying that local preferences are to be published
- */
- public static final String PUBLISH_LOCAL_PREFS_VALUE = "local";
-
- /**
- * The value for specifying that global preferences are to be published
- */
- public static final String PUBLISH_GLOBAL_PREFS_VALUE = "global";
-
- /**
- * The value for specifying that an {@link Algorithm}'s user-entered input
- * parameter defaults may be adjusted by the user
- */
- public static final String PUBLISH_PARAM_DEFAULT_PREFS_VALUE = "param-defaults";
-
- /**
- * The key for declaring a need to receive preferences. "true" and "false"
- * are the possible associated values.
- */
- public static final String RECEIVE_PREFS_KEY = "receive_prefs";
-
-
-
- /**
- * The suffix to add to the service's PID for getting the local preferences
- * directly from the ConfigurationAdmin (not recommended)
- */
- public static final String LOCAL_PREFS_CONF_SUFFIX = "";
-
- /**
- * The suffix to add to the service's PID for getting the global preferences
- * directly from the ConfigurationAdmin (not recommended)
- */
- public static final String GLOBAL_PREFS_CONF_SUFFIX = GLOBAL_PREFS_OCD_SUFFIX;
-
- /**
- * The suffix to add to the service's PID for getting an {@link Algorithm}'s
- * user-entered input parameter defaults that have been user-adjusted directly
- * from the ConfigurationAdmin (not recommended)
- */
- public static final String PARAM_PREFS_CONF_SUFFIX = ".prefs.params";
-
- /**
- * A key set in each configuration object which states the Bundle-Version of
- * the service when it was last updated
- */
- public static final String BUNDLE_VERSION_KEY = "Bundle-Version";
-}
Copied: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java (from rev 739, trunk/core/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java)
===================================================================
--- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java (rev 0)
+++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/userprefs/UserPrefsProperty.java 2008-03-28 16:51:07 UTC (rev 740)
@@ -0,0 +1,112 @@
+/* ****************************************************************************
+ * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Apache License v2.0 which accompanies
+ * this distribution, and is available at:
+ * http://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Created on Feb 8, 2008 at Indiana University.
+ *
+ * Contributors:
+ * Indiana University -
+ * ***************************************************************************/
+package org.cishell.framework.userprefs;
+
+/**
+ * A standard set of properties and values to be placed in a service's
+ * metadata Dictionary when registering a service with the OSGi service registry
+ * for the purpose of publishing and receiving user-adjustable preferences.
+ *
+ * See the <a href="http://cishell.org/dev/docs/spec/cishell-spec-1.0.pdf">
+ * CIShell Specification 1.0</a> for information on publishing user-adjustable
+ * preferences.
+ */
+public interface UserPrefsProperty {
+
+ /**
+ * The suffix to add to the service's PID for generating a local preferences
+ * PID when using the standard naming convention
+ */
+ public static final String LOCAL_PREFS_OCD_SUFFIX = ".prefs.local";
+
+ /**
+ * The suffix to add to the service's PID for generating a global preferences
+ * PID when using the standard naming convention
+ */
+ public static final String GLOBAL_PREFS_OCD_SUFFIX = ".prefs.global";
+
+ /**
+ * The suffix to add to the service's PID for an {@link Algorithm}'s
+ * user-entered input parameters PID when using the standard naming convention
+ */
+ public static final String PARAM_PREFS_OCD_SUFFIX = "";
+
+ /**
+ * The key for specifying a local preferences PID.
+ * Only use this when not following the standard naming convention.
+ */
+ public static final String LOCAL_PREFS_PID = "local_prefs_pid";
+
+ /**
+ * The key for specifying a global preferences PID.
+ * Only use this when not following the standard naming convention.
+ */
+ public static final String GLOBAL_PREFS_PID = "global_prefs_pid";
+
+
+
+ /**
+ * The key for specifying what types of preferences are published
+ */
+ public static final String PREFS_PUBLISHED_KEY = "prefs_published";
+
+ /**
+ * The value for specifying that local preferences are to be published
+ */
+ public static final String PUBLISH_LOCAL_PREFS_VALUE = "local";
+
+ /**
+ * The value for specifying that global preferences are to be published
+ */
+ public static final String PUBLISH_GLOBAL_PREFS_VALUE = "global";
+
+ /**
+ * The value for specifying that an {@link Algorithm}'s user-entered input
+ * parameter defaults may be adjusted by the user
+ */
+ public static final String PUBLISH_PARAM_DEFAULT_PREFS_VALUE = "param-defaults";
+
+ /**
+ * The key for declaring a need to receive preferences. "true" and "false"
+ * are the possible associated values.
+ */
+ public static final String RECEIVE_PREFS_KEY = "receive_prefs";
+
+
+
+ /**
+ * The suffix to add to the service's PID for get...
[truncated message content] |
|
From: <mwl...@us...> - 2008-03-28 16:40:48
|
Revision: 739
http://cishell.svn.sourceforge.net/cishell/?rev=739&view=rev
Author: mwlinnem
Date: 2008-03-28 09:40:44 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Removed warning.
Modified Paths:
--------------
branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF
Modified: branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF 2008-03-28 16:15:26 UTC (rev 738)
+++ branches/user_prefs/org.cishell.framework/META-INF/MANIFEST.MF 2008-03-28 16:40:44 UTC (rev 739)
@@ -4,7 +4,6 @@
Bundle-SymbolicName: org.cishell.framework
Bundle-Version: 0.3.0
Bundle-Vendor: Bruce Herr
-Bundle-Localization: plugin
Import-Package: org.osgi.framework,
org.osgi.service.log,
org.osgi.service.metatype,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-28 16:15:51
|
Revision: 738
http://cishell.svn.sourceforge.net/cishell/?rev=738&view=rev
Author: mwlinnem
Date: 2008-03-28 09:15:26 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Branched for user prefs. Added startup for configuration admin and our pref admin.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
Added Paths:
-----------
branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/
Copied: branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell (from rev 674, trunk/clients/gui/org.cishell.reference.gui.brand.cishell)
Modified: branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-21 16:30:04 UTC (rev 674)
+++ branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-28 16:15:26 UTC (rev 738)
@@ -2,5 +2,5 @@
osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell
eclipse.product=org.cishell.reference.gui.brand.cishell.cishell
-osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start,org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start
-osgi.bundles.defaultStartLevel=4
+org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.cishell.reference.prefs.admin@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start
+osgi.bundles.defaultStartLevel=4
\ 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: <mwl...@us...> - 2008-03-28 16:14:07
|
Revision: 737
http://cishell.svn.sourceforge.net/cishell/?rev=737&view=rev
Author: mwlinnem
Date: 2008-03-28 09:13:31 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Branched for user prefs. Added startup for configuration admin and our pref admin.
Modified Paths:
--------------
branches/user_prefs/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
Added Paths:
-----------
branches/user_prefs/org.cishell.reference.gui.brand.cishell/
Copied: branches/user_prefs/org.cishell.reference.gui.brand.cishell (from rev 674, trunk/clients/gui/org.cishell.reference.gui.brand.cishell)
Modified: branches/user_prefs/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-21 16:30:04 UTC (rev 674)
+++ branches/user_prefs/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-28 16:13:31 UTC (rev 737)
@@ -2,5 +2,5 @@
osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell
eclipse.product=org.cishell.reference.gui.brand.cishell.cishell
-osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start,org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start
-osgi.bundles.defaultStartLevel=4
+org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.cishell.reference.prefs.admin@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start
+osgi.bundles.defaultStartLevel=4
\ 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: <mwl...@us...> - 2008-03-28 16:07:09
|
Revision: 736
http://cishell.svn.sourceforge.net/cishell/?rev=736&view=rev
Author: mwlinnem
Date: 2008-03-28 09:06:52 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Branched for user prefs. Added startup for configuration admin and our pref admin.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
Added Paths:
-----------
trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/
Copied: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell (from rev 674, trunk/clients/gui/org.cishell.reference.gui.brand.cishell)
Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-21 16:30:04 UTC (rev 674)
+++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-03-28 16:06:52 UTC (rev 736)
@@ -3,4 +3,4 @@
osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell
eclipse.product=org.cishell.reference.gui.brand.cishell.cishell
osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start,org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start
-osgi.bundles.defaultStartLevel=4
+osgi.bundles.defaultStartLevel=4
\ 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: <mwl...@us...> - 2008-03-27 21:25:40
|
Revision: 735
http://cishell.svn.sourceforge.net/cishell/?rev=735&view=rev
Author: mwlinnem
Date: 2008-03-27 14:25:36 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
If there is no way to save something such that it goes through a validator as it is saved, we now try to save it anyway.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml 2008-03-27 21:06:14 UTC (rev 734)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml 2008-03-27 21:25:36 UTC (rev 735)
@@ -8,7 +8,5 @@
<service>
<provide interface=
"org.cishell.framework.algorithm.AlgorithmFactory"/>
- <provide interface=
- "org.cishell.framework.algorithm.DataValidator"/>
</service>
</component>
\ No newline at end of file
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 2008-03-27 21:06:14 UTC (rev 734)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2008-03-27 21:25:36 UTC (rev 735)
@@ -88,8 +88,11 @@
public boolean save(Converter converter, Data data) {
String outDataStr = (String)converter.getProperties().get(AlgorithmProperty.OUT_DATA);
- String ext = outDataStr.substring(outDataStr.indexOf(':')+1);
-
+ String ext = "";
+ if (outDataStr.startsWith("file-ext:")) {
+ ext = outDataStr.substring(outDataStr.indexOf(':')+1);
+ }
+
if ((""+ext).startsWith(".")) {
ext = ext.substring(1);
}
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-03-27 21:06:14 UTC (rev 734)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-03-27 21:25:36 UTC (rev 735)
@@ -1,6 +1,5 @@
package org.cishell.reference.gui.persistence.save;
-import java.io.File;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -9,6 +8,7 @@
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.algorithm.AlgorithmProperty;
+import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.cishell.service.conversion.Converter;
import org.cishell.service.conversion.DataConversionService;
@@ -17,6 +17,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
/**
* Save algorithm for persisting a data object
*
@@ -30,6 +31,7 @@
private GUIBuilderService guiBuilder;
private DataConversionService conversionManager;
+ private LogService log;
/**
* Sets up default services for the algorithm
@@ -46,6 +48,7 @@
this.conversionManager = (DataConversionService) context.getService(
DataConversionService.class.getName());
+ this.log = (LogService) context.getService(LogService.class.getName());
this.guiBuilder = (GUIBuilderService)context.getService(GUIBuilderService.class.getName());
}
@@ -55,45 +58,87 @@
* @return Null for this algorithm
*/
public Data[] execute() throws AlgorithmExecutionException {
- try {
- //This only checks the first Data in the array
- final Converter[] converters = conversionManager.findConverters(data[0], "file-ext:*");
+ //NOTE: A "converter" here is actually a converter path
+ //starting with the format for the data we want to save
+ //and ending in a output format
+ Data dataToSave = data[0];
- if (converters.length < 1 && !(data[0].getData() instanceof File)) {
- guiBuilder.showError("No Converters",
- "No valid converters for data type: " +
- data[0].getFormat(),
- "Please install a plugin that will save the data type to a file");
- } else {
- parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell();
-
- if (!parentShell.isDisposed()) {
- guiRun(new Runnable() {
- public void run() {
- if (converters.length == 0) {
- FileSaver saver = new FileSaver(parentShell, context);
- saver.save(new NoConversionConverter(), data[0]);
- } else if (converters.length == 1) {
- final FileSaver saver = new FileSaver(parentShell, context);
- saver.save(converters[0], data[0]);
- } else {
- SaveDataChooser sdc = new SaveDataChooser(data[0],
- parentShell, converters,
- "Save",
- context);
- sdc.createContent(new Shell(parentShell));
- sdc.open();
- }
- }});
+ //first, try to save the normal way, which is using validators to validate the output.
+ String saveThroughValidators = "file-ext:*";
+ Object firstAttemptResult = tryToSave(dataToSave, saveThroughValidators);
+ if (firstAttemptResult instanceof Boolean) {
+ boolean succeeded = ((Boolean) firstAttemptResult).booleanValue();
+ if (succeeded) {
+ System.out.println("Success");
+ return null; //FILE SAVED SUCCESSFULLY. DONE.
+ } else {
+ System.out.println("No converter");
+ this.log.log(LogService.LOG_WARNING, "No converters found that can save file through a validator." +
+ " Attempting to save without validating.");
}
+ } else { //result instanceof Exception
+ Exception reasonForFailure = (Exception) firstAttemptResult;
+ this.log.log(LogService.LOG_WARNING, "Exception occurred while attempting to save" +
+ " file using a validator. Attempting to save without validating.");
+ System.out.println("Exception");
}
- return null;
- } catch (Throwable e) {
- throw new AlgorithmExecutionException(e);
+
+ System.out.println("Trying without validators");
+
+ //if saving with validators didn't work, try to save it without using validators
+ String saveWithoutValidators = "file:*";
+ Object secondAttemptResult = tryToSave(dataToSave, saveWithoutValidators);
+ if (secondAttemptResult instanceof Boolean) {
+ boolean succeeded = ((Boolean) secondAttemptResult).booleanValue();
+ if (succeeded) {
+ return null; //FILE SAVED SUCCESSFULLY. DONE.
+ } else {
+ throw new AlgorithmExecutionException("No converters found that could save file. Save failed");
+ }
+ } else { //result instanceof Exception
+ Exception reasonForFailure2 = (Exception) secondAttemptResult;
+ throw new AlgorithmExecutionException("Exception occurred while attempting to save", reasonForFailure2);
+ }
+ }
+
+ //returns True if save was successful
+ //return False if there are no converter chains available to save to the given format
+ //return an Exception if an exception occurred while attempting to save
+ private Object tryToSave(final Data dataToSave, String formatToSaveTo) {
+ final Converter[] converters = conversionManager.findConverters(dataToSave, formatToSaveTo);
+ if (converters.length == 0) {return new Boolean(false);};
+
+ parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell();
+ if (parentShell.isDisposed()) {return makeParentShellDisposedException();};
+
+ try {
+ guiRun(new Runnable() {
+ public void run() {
+ if (converters.length == 1){
+ //only one possible choice in how to save data. Just do it.
+ Converter onlyConverter = converters[0];
+ final FileSaver saver = new FileSaver(parentShell, context);
+ saver.save(onlyConverter, dataToSave);
+ } else { //converters.length > 1
+ //multiple ways to save the data. Let user choose.
+ SaveDataChooser saveChooser = new SaveDataChooser(dataToSave,
+ parentShell, converters, "Save", context);
+ saveChooser.createContent(new Shell(parentShell));
+ saveChooser.open();
+ }
+ }});
+ } catch (Exception e) {
+ return e;
+ }
+
+ return new Boolean(true);
}
- }
- private void guiRun(Runnable run) {
+ private AlgorithmExecutionException makeParentShellDisposedException() {
+ return new AlgorithmExecutionException("Attempted to use disposed parent shell");
+ }
+
+ private void guiRun(Runnable run) {
if (Thread.currentThread() == Display.getDefault().getThread()) {
run.run();
} else {
@@ -121,4 +166,8 @@
return props;
}
}
+
+ private Data removeExtension(Data data) {
+ return new BasicData(data.getMetadata(), data, "");
+ }
}
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2008-03-27 21:06:14 UTC (rev 734)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2008-03-27 21:25:36 UTC (rev 735)
@@ -17,7 +17,6 @@
import org.cishell.framework.algorithm.AlgorithmProperty;
import org.cishell.framework.data.Data;
import org.cishell.reference.gui.common.AbstractDialog;
-import org.cishell.service.conversion.ConversionException;
import org.cishell.service.conversion.Converter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2008-03-27 21:06:14 UTC (rev 734)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2008-03-27 21:25:36 UTC (rev 735)
@@ -23,7 +23,7 @@
* @author bmarkine
*
*/
-public class SaveFactory implements AlgorithmFactory, DataValidator {
+public class SaveFactory implements AlgorithmFactory {
private CIShellContext context;
/**
@@ -45,26 +45,4 @@
this.context = context;
return new Save(data, parameters, context);
}
-
- /**
- * Validate the SaveFactory can handle the incoming file type
- * @param data The data to save
- * @return empty string on success
- */
- public String validate(Data[] data) {
- DataConversionService conversionManager = (DataConversionService) context.getService(
- DataConversionService.class.getName());
-
- //Fix me
- //Bonnie:why only check data[0]? An user can select multiple objects from data manager.
- Converter[] converters = conversionManager.findConverters(data[0], "file-ext:*");
- if (converters.length == 0 && !(data[0].getData() instanceof File)) {
- return "No valid converters from " +
- data[0].getData().getClass().getName() + " to any file extension";
- }
- else {
- return "";
- }
- }
-
}
\ 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: <mwl...@us...> - 2008-03-27 21:06:52
|
Revision: 734
http://cishell.svn.sourceforge.net/cishell/?rev=734&view=rev
Author: mwlinnem
Date: 2008-03-27 14:06:14 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
Made algorithms claiming to be converters that weren't say they are not converters.
Modified Paths:
--------------
trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmA.properties
trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmB.properties
Modified: trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmA.properties
===================================================================
--- trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmA.properties 2008-03-27 19:12:31 UTC (rev 733)
+++ trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmA.properties 2008-03-27 21:06:14 UTC (rev 734)
@@ -4,5 +4,4 @@
in_data=null
out_data=java.lang.String
service.pid=org.cishell.tests.conversion1.algA
-remoteable=true
-type=converter
\ No newline at end of file
+remoteable=true
\ No newline at end of file
Modified: trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmB.properties
===================================================================
--- trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmB.properties 2008-03-27 19:12:31 UTC (rev 733)
+++ trunk/examples/org.cishell.tests.conversion1/OSGI-INF/algorithmB.properties 2008-03-27 21:06:14 UTC (rev 734)
@@ -5,5 +5,3 @@
out_data=java.lang.Integer
service.pid=org.cishell.tests.conversion1.algB
remoteable=true
-type=converter
-conversion=lossless
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fu...@us...> - 2008-03-27 19:12:36
|
Revision: 733
http://cishell.svn.sourceforge.net/cishell/?rev=733&view=rev
Author: fugu13
Date: 2008-03-27 12:12:31 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
File saving should work now.
Modified Paths:
--------------
trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java
Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java
===================================================================
--- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java 2008-03-27 19:06:37 UTC (rev 732)
+++ trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java 2008-03-27 19:12:31 UTC (rev 733)
@@ -169,7 +169,7 @@
//System.out.println("Converter:"+converters.length+":"+ inFormat + "->" + format + "->" + outFormat);
if (!formats.contains(format)) {
- String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+")" +
+ String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_VALIDATOR+")" +
"(!("+REMOTE+"=*))" +
"("+IN_DATA+"="+format+")" +
"("+OUT_DATA+"="+outFormat+"))";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bh...@us...> - 2008-03-27 19:06:44
|
Revision: 732
http://cishell.svn.sourceforge.net/cishell/?rev=732&view=rev
Author: bh2
Date: 2008-03-27 12:06:37 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
stopped using guibuilder in Static Executable Runner. now using just the logger and throwing AEEs.
Modified Paths:
--------------
trunk/templates/org.cishell.templates/META-INF/MANIFEST.MF
trunk/templates/org.cishell.templates/src/org/cishell/templates/dataset/DatasetFactory.java
trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
Modified: trunk/templates/org.cishell.templates/META-INF/MANIFEST.MF
===================================================================
--- trunk/templates/org.cishell.templates/META-INF/MANIFEST.MF 2008-03-27 18:59:44 UTC (rev 731)
+++ trunk/templates/org.cishell.templates/META-INF/MANIFEST.MF 2008-03-27 19:06:37 UTC (rev 732)
@@ -7,7 +7,6 @@
Import-Package: org.cishell.framework;version="1.0.0",
org.cishell.framework.algorithm;version="1.0.0",
org.cishell.framework.data;version="1.0.0",
- org.cishell.service.guibuilder;version="1.0.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.component;version="1.0.0",
org.osgi.service.log;version="1.3.0",
Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/dataset/DatasetFactory.java
===================================================================
--- trunk/templates/org.cishell.templates/src/org/cishell/templates/dataset/DatasetFactory.java 2008-03-27 18:59:44 UTC (rev 731)
+++ trunk/templates/org.cishell.templates/src/org/cishell/templates/dataset/DatasetFactory.java 2008-03-27 19:06:37 UTC (rev 732)
@@ -24,6 +24,7 @@
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;
@@ -84,15 +85,14 @@
this.ciContext = ciContext;
}
- public Data[] execute() {
+ public Data[] execute() throws AlgorithmExecutionException {
try {
Data data = new BasicData(getDataset(),format);
data.getMetadata().put(DataProperty.LABEL, label);
return new Data[]{data};
} catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
+ throw new AlgorithmExecutionException(e);
}
}
}
Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
===================================================================
--- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2008-03-27 18:59:44 UTC (rev 731)
+++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2008-03-27 19:06:37 UTC (rev 732)
@@ -36,7 +36,6 @@
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
-import org.cishell.service.guibuilder.GUIBuilderService;
import org.cishell.templates.Activator;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
@@ -47,7 +46,6 @@
*/
public class StaticExecutableRunner implements Algorithm {
protected final String tempDir;
- protected final GUIBuilderService guiBuilder;
protected final Data[] data;
protected Dictionary parameters;
protected Properties props;
@@ -69,8 +67,6 @@
if (parameters == null)
parameters = new Hashtable();
- guiBuilder = (GUIBuilderService) ciContext
- .getService(GUIBuilderService.class.getName());
tempDir = makeTempDirectory();
}
@@ -227,12 +223,9 @@
// if the process failed unexpectedly...
if (process.exitValue() != 0 && !killedOnPurpose) {
- // display the error message using gui builder
- guiBuilder.showError(
- "Algorithm Could Not Finish Execution",
- "Sorry, the algorithm could not finish execution.",
- "Please check the console window for the error log messages and report the bug.\n"
- + "Thank you.");
+ throw new AlgorithmExecutionException(
+ "Algorithm exited unexpectedly (exit value: "+process.exitValue()+
+ "). Please check the console window for any error messages.");
}
// get the files output from the process
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hu...@us...> - 2008-03-27 18:59:49
|
Revision: 731
http://cishell.svn.sourceforge.net/cishell/?rev=731&view=rev
Author: huangb
Date: 2008-03-27 11:59:44 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
change filter from type=converter to type=validator
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 2008-03-27 18:46:00 UTC (rev 730)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2008-03-27 18:59:44 UTC (rev 731)
@@ -133,7 +133,7 @@
}
String fileExtension = getFileExtension(file).toLowerCase();
- String filter = "(&(type=converter)(in_data=file-ext:"+fileExtension+"))";
+ String filter = "(&(type=validator)(in_data=file-ext:"+fileExtension+"))";
try {
// set the properties for the resource descriptor.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bh...@us...> - 2008-03-27 18:46:04
|
Revision: 730
http://cishell.svn.sourceforge.net/cishell/?rev=730&view=rev
Author: bh2
Date: 2008-03-27 11:46:00 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
used log service instead of gui builder in the case where a data validator doesn't like a given set of data.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-27 18:35:36 UTC (rev 729)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-27 18:46:00 UTC (rev 730)
@@ -114,7 +114,7 @@
label = "Algorithm";
}
- builder.showError("Invalid Data", "The data given to \""+label+"\" is incompatible for this reason: "+validation , (String) null);
+ log(LogService.LOG_ERROR,"INVALID DATA: The data given to \""+label+"\" is incompatible for this reason: "+validation);
return null;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bh...@us...> - 2008-03-27 18:35:41
|
Revision: 729
http://cishell.svn.sourceforge.net/cishell/?rev=729&view=rev
Author: bh2
Date: 2008-03-27 11:35:36 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
Updated menumanager, cleaning up a bit, and better handling exceptions.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-27 17:46:12 UTC (rev 728)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-27 18:35:36 UTC (rev 729)
@@ -72,8 +72,6 @@
dataSelected(dataManager.getSelectedData());
}
-
-
public void run() {
//hmm... should probably change this.. maybe use the scheduler...
new Thread("Menu Item Runner") {
@@ -92,13 +90,9 @@
bContext.getService(bContext.getServiceReference(
SchedulerService.class.getName()));
-
printAlgorithmInformation();
-
-
-
-
- scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters), ref);
+
+ scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters), ref);
} catch (Throwable e) {
e.printStackTrace();
}
@@ -110,10 +104,9 @@
StringBuffer acknowledgement = new StringBuffer();
String label = (String)ref.getProperty(LABEL);
if (label != null){
- acknowledgement.append("..........\n"+
- label+" was selected.\n");
+ acknowledgement.append("..........\n"+label+" was selected.\n");
}
- String authors = (String)ref.getProperty("authors");
+ String authors = (String)ref.getProperty(AUTHORS);
if (authors != null)
acknowledgement.append("Author(s): "+authors+"\n");
String implementers = (String)ref.getProperty(IMPLEMENTERS);
@@ -133,8 +126,7 @@
if (docu != null)
acknowledgement.append("Documentation: "+docu+"\n");
if(acknowledgement.length()>1)
- logger.log(LogService.LOG_INFO, acknowledgement.toString());
-
+ logger.log(LogService.LOG_INFO, acknowledgement.toString());
}
public void dataSelected(Data[] selectedData) {
@@ -193,34 +185,6 @@
setEnabled(data != null); //&& isValid());
}
- //This method will be disabled until we can find a better solution
- //for extra validation beyond input/output checking
-/* private boolean isValid() {
- String valid = null;
- String[] classes = (String[]) ref.getProperty(Constants.OBJECTCLASS);
-
- if (classes != null && data != null) {
- for (int i=0; i < classes.length; i++) {
- if (classes[i].equals(DataValidator.class.getName())) {
- DataValidator validator = (DataValidator) bContext.getService(ref);
-
- //FIXME: Could cause concurrency problems...
- for (int j=0; j < data.length; j++) {
- if (converters[j] != null && converters[j].length > 0) {
- //does not work for large inputs...
- data[j] = converters[j][0].convert(data[j]);
- converters[j] = null;
- }
- }
-
- valid = validator.validate(data);
- }
- }
- }
-
- return valid == null || valid.length() == 0;
- }
-*/
private boolean isAsignableFrom(String type, Data datum) {
Object data = datum.getData();
boolean assignable = false;
@@ -247,6 +211,4 @@
public ServiceReference getServiceReference(){
return ref;
}
-
-
}
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-27 17:46:12 UTC (rev 728)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-27 18:35:36 UTC (rev 729)
@@ -24,6 +24,7 @@
import org.cishell.app.service.datamanager.DataManagerService;
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.AlgorithmProperty;
import org.cishell.framework.algorithm.DataValidator;
@@ -34,6 +35,7 @@
import org.cishell.framework.data.DataProperty;
import org.cishell.reference.gui.menumanager.Activator;
import org.cishell.reference.service.metatype.BasicMetaTypeProvider;
+import org.cishell.service.conversion.ConversionException;
import org.cishell.service.conversion.Converter;
import org.cishell.service.guibuilder.GUIBuilderService;
import org.osgi.framework.BundleContext;
@@ -70,128 +72,133 @@
this.converters = converters;
this.idToLabelMap = new HashMap();
- this.progressMonitor = null;
-
-
+ this.progressMonitor = null;
}
/**
* @see org.cishell.framework.algorithm.Algorithm#execute()
*/
public Data[] execute() {
- try {
- for (int i=0; i < data.length; i++) {
- if (converters[i] != null) {
- data[i] = converters[i][0].convert(data[i]);
-
- if (data[i] == null && i < (data.length - 1)) {
- Exception e =
- new Exception("The converter " +
- converters[i].getClass().getName() +
- " returned a null result where data was expected.");
- throw e;
- }
- converters[i] = null;
- }
- }
-
- GUIBuilderService builder = (GUIBuilderService)
- ciContext.getService(GUIBuilderService.class.getName());
-
- AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref);
-
- if (factory instanceof DataValidator) {
- String validation = ((DataValidator) factory).validate(data);
-
- if (validation != null && validation.length() > 0) {
- String label = (String) ref.getProperty(LABEL);
- if (label == null) {
- label = "Algorithm";
- }
-
- builder.showError("Invalid Data", "The data given to \""+label+"\" is incompatible for this reason: "+validation , (String) null);
+ for (int i=0; i < data.length; i++) {
+ if (converters[i] != null) {
+ try {
+ data[i] = converters[i][0].convert(data[i]);
+ } catch (ConversionException e) {
+ log(LogService.LOG_ERROR,"The conversion of data to give" +
+ " the algorithm failed for this reason: "+e.getMessage(), e);
return null;
}
- }
-
- String pid = (String)ref.getProperty(Constants.SERVICE_PID);
-
- String metatype_pid = (String) ref.getProperty(PARAMETERS_PID);
- if (metatype_pid == null) {
- metatype_pid = pid;
- }
- this.provider = null;
-
- MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName());
- if (metaTypeService != null) {
- provider = metaTypeService.getMetaTypeInformation(ref.getBundle());
+ if (data[i] == null && i < (data.length - 1)) {
+ log(LogService.LOG_ERROR, "The converter: " +
+ converters[i].getClass().getName() +
+ " returned a null result where data was expected when" +
+ " converting the data to give the algorithm.");
+ return null;
+ }
+ converters[i] = null;
}
+ }
+
+ GUIBuilderService builder = (GUIBuilderService)
+ ciContext.getService(GUIBuilderService.class.getName());
+
+ AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref);
+
+ if (factory instanceof DataValidator) {
+ String validation = ((DataValidator) factory).validate(data);
+
+ if (validation != null && validation.length() > 0) {
+ String label = (String) ref.getProperty(LABEL);
+ if (label == null) {
+ label = "Algorithm";
+ }
+
+ builder.showError("Invalid Data", "The data given to \""+label+"\" is incompatible for this reason: "+validation , (String) null);
+ return null;
+ }
+ }
+
+ String pid = (String)ref.getProperty(Constants.SERVICE_PID);
+
+ String metatype_pid = (String) ref.getProperty(PARAMETERS_PID);
+ if (metatype_pid == null) {
+ metatype_pid = pid;
+ }
- if (factory instanceof ParameterMutator && provider != null) {
- try {
- ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatype_pid, null);
-
- ocd = ((ParameterMutator) factory).mutateParameters(data, ocd);
-
- if (ocd != null) {
- provider = new BasicMetaTypeProvider(ocd);
- }
- } catch (IllegalArgumentException e) {
- log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatype_pid);
+ this.provider = null;
+
+ MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName());
+ if (metaTypeService != null) {
+ provider = metaTypeService.getMetaTypeInformation(ref.getBundle());
+ }
+
+ if (factory instanceof ParameterMutator && provider != null) {
+ try {
+ ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatype_pid, null);
+
+ ocd = ((ParameterMutator) factory).mutateParameters(data, ocd);
+
+ if (ocd != null) {
+ provider = new BasicMetaTypeProvider(ocd);
}
- }
+ } catch (IllegalArgumentException e) {
+ log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatype_pid);
+ }
+ }
+
+ this.parameters = new Hashtable();
+ if (provider != null) {
+ this.parameters = builder.createGUIandWait(metatype_pid, provider);
+ }
+
+ //check to see if the user cancelled the operation
+ if(this.parameters == null) {
+ return null;
+ }
+
+ algorithm = factory.createAlgorithm(data, parameters, ciContext);
+
+ printParameters();
+
+ if (progressMonitor != null && algorithm instanceof ProgressTrackable) {
+ ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor);
+ }
+
+ Data[] outData = null;
+ try {
+ outData = algorithm.execute();
+ } catch (AlgorithmExecutionException e) {
+ log(LogService.LOG_ERROR,
+ "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+
+ "\" had an error while executing: "+e.getMessage());
+ } catch (RuntimeException e) {
+ builder.showError("Error!", "An unexpected exception occurred while "
+ +"executing \""+ref.getProperty(AlgorithmProperty.LABEL)+".\"", e);
+ }
+
+ if (outData != null) {
+ DataManagerService dataManager = (DataManagerService)
+ bContext.getService(bContext.getServiceReference(
+ DataManagerService.class.getName()));
- this.parameters = new Hashtable();
- if (provider != null) {
- this.parameters = builder.createGUIandWait(pid, provider);
- }
+ doParentage(outData);
- if(this.parameters == null) {
- return new Data[0];
+ List goodData = new ArrayList();
+ for (int i=0; i < outData.length; i++) {
+ if (outData[i] != null) {
+ goodData.add(outData[i]);
+ }
}
- algorithm = factory.createAlgorithm(data, parameters, ciContext);
+ outData = (Data[]) goodData.toArray(new Data[0]);
- printParameters();
-
- if (progressMonitor != null && algorithm instanceof ProgressTrackable) {
- ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor);
+ if (outData.length != 0) {
+ dataManager.setSelectedData(outData);
}
-
- Data[] outData = algorithm.execute();
-
- if (outData != null) {
- DataManagerService dataManager = (DataManagerService)
- bContext.getService(bContext.getServiceReference(
- DataManagerService.class.getName()));
-
- doParentage(outData);
-
- List goodData = new ArrayList();
- for (int i=0; i < outData.length; i++) {
- if (outData[i] != null) {
- goodData.add(outData[i]);
- }
- }
-
- outData = (Data[]) goodData.toArray(new Data[0]);
-
- if (outData.length != 0) {
- dataManager.setSelectedData(outData);
- }
- }
-
- return outData;
- } catch (Throwable e) {
- GUIBuilderService guiBuilder = (GUIBuilderService)
- ciContext.getService(GUIBuilderService.class.getName());
- guiBuilder.showError("Error!",
- "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+
- "\" had an error while executing.", e);
-
- return new Data[0];
}
+
+ return outData;
}
protected void log(int logLevel, String message) {
@@ -202,6 +209,16 @@
System.out.println(message);
}
}
+
+ protected void log(int logLevel, String message, Throwable exception) {
+ LogService log = (LogService) Activator.getService(LogService.class.getName());
+ if (log != null) {
+ log.log(logLevel, message, exception);
+ } else {
+ System.out.println(message);
+ exception.printStackTrace();
+ }
+ }
protected void printParameters() {
LogService logger = getLogService();
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-03-27 17:46:12 UTC (rev 728)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-03-27 18:35:36 UTC (rev 729)
@@ -13,7 +13,6 @@
* ***************************************************************************/
package org.cishell.reference.gui.menumanager.menu;
-//Java
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -52,10 +51,6 @@
import org.xml.sax.SAXException;
-/*
- * Bonnie's comments:
- * weird, why implements AlgorithmProperty? It does not define any abstract interface.
- */
public class MenuAdapter implements AlgorithmProperty {
private IMenuManager menuBar;
private Shell shell;
@@ -137,13 +132,11 @@
}
else{
String pid = (String)refs[i].getProperty(PRESERVED_SERVICE_PID);
-// System.out.println("pid="+pid);
pidToServiceReferenceMap.put(pid.toLowerCase().trim(), refs[i]);
pidToServiceReferenceMapCopy.put(pid.toLowerCase().trim(), refs[i]);
}
}
}
-
}
/*
* Parse default_menu.xml file. For each menu node, get the value of the attribut "pid"
@@ -167,7 +160,6 @@
private void processTopMenu (Element topMenuNode){
MenuManager topMenuBar = null;
-
/*
* The File and Help menus are created in ApplicationActionBarAdvisor.java
@@ -217,7 +209,7 @@
processSubMenu(el, groupMenuBar);
}
else if (menu_type.equalsIgnoreCase(PRESERVED_BREAK)){
- //It seems that Framework automatially takes care of issues
+ //It seems that Framework automatically takes care of issues
//such as double separators, a separator at the top or bottom
parentMenuBar.add(new Separator());
}
@@ -260,7 +252,6 @@
if (pid == null || pid.length()==0){
//check if the name is one of the preserved one
//if so add the default action
-
}
else{
//check if the pid has registered in pidToServiceReferenceMap
@@ -292,7 +283,6 @@
//parse using builder to get DOM representation of the XML file
String fullpath=System.getProperty("osgi.configuration.area") + DEFAULT_MENU_FILE_NAME;
-// System.out.println(">>parse file: "+fullpath);
dom = db.parse(fullpath);
// printElementAttributes(dom);
@@ -338,7 +328,6 @@
public void serviceChanged(ServiceEvent event) {
switch (event.getType()) {
case ServiceEvent.REGISTERED:
-// System.out.println(">>>receive ServiceEvent.Registered");
makeMenuItem(event.getServiceReference());
break;
case ServiceEvent.UNREGISTERING:
@@ -367,19 +356,15 @@
menu = targetMenu.findMenuUsingPath(items[i]);
if (menu == null && items[i] != null) {
- menu = targetMenu.findMenuUsingPath(items[i].toLowerCase());
-
+ menu = targetMenu.findMenuUsingPath(items[i].toLowerCase());
}
- if (menu == null) {
-
+ if (menu == null) {
menu = createMenu(items[i],items[i]);
targetMenu.appendToGroup(ADDITIONS_GROUP, menu);
}
targetMenu = menu;
-
-
}
group = items[items.length-1];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mwl...@us...> - 2008-03-27 17:47:22
|
Revision: 728
http://cishell.svn.sourceforge.net/cishell/?rev=728&view=rev
Author: mwlinnem
Date: 2008-03-27 10:46:12 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
Refactored disgusting inline anonymous class.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
Added Paths:
-----------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2008-03-27 15:38:15 UTC (rev 727)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2008-03-27 17:46:12 UTC (rev 728)
@@ -4,7 +4,6 @@
Bundle-SymbolicName: org.cishell.reference.gui.persistence;singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: .
-Bundle-Localization: plugin
Import-Package: org.cishell.app.service.datamanager,
org.cishell.framework;version="1.0.0",
org.cishell.framework.algorithm;version="1.0.0",
Deleted: 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 2008-03-27 15:38:15 UTC (rev 727)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2008-03-27 17:46:12 UTC (rev 728)
@@ -1,217 +0,0 @@
-/*
- * Created on Aug 19, 2004
- */
-package org.cishell.reference.gui.persistence.save;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileChannel;
-
-import org.cishell.framework.CIShellContext;
-import org.cishell.framework.algorithm.AlgorithmProperty;
-import org.cishell.framework.data.Data;
-import org.cishell.framework.data.DataProperty;
-import org.cishell.service.conversion.ConversionException;
-import org.cishell.service.conversion.Converter;
-import org.cishell.service.guibuilder.GUIBuilderService;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.osgi.service.log.LogService;
-
-/**
- * Persist the file to disk for the user
- *
- * @author Team
- */
-public class FileSaver {
- private static File currentDir;
-
- private Shell parent;
-
- private GUIBuilderService guiBuilder;
- private LogService log;
-
-
- /**
- * Initializes services to output messages
- *
- * @param parent
- * @param context
- */
- public FileSaver(Shell parent, CIShellContext context){
- this.parent = parent;
- this.guiBuilder = (GUIBuilderService)context.getService(GUIBuilderService.class.getName());
- this.log = (LogService) context.getService(LogService.class.getName());
- }
-
- /**
- * File exists, so make sure the user wants to overwrite
- * @param file The file to possibly overwrite
- * @return Whether or not the user decides to overwrite
- */
- private boolean confirmFileOverwrite(File file) {
- String message = "The file:\n" + file.getPath()
- + "\nalready exists. Are you sure you want to overwrite it?";
- return guiBuilder.showConfirm("File Overwrite", message, "");
- }
-
- /**
- * Checks for a valid file destination
- *
- * @param file to save to
- * @return True on valid file save
- */
- private boolean isSaveFileValid(File file) {
- boolean valid = false;
- if (file.isDirectory()) {
- String message = "Destination cannot be a directory. Please choose a file";
- guiBuilder.showError("Invalid Destination", message, "");
- valid = false;
- } else if (file.exists()) {
- valid = confirmFileOverwrite(file);
- }
- else
- valid = true ;
- return valid;
- }
-
- /**
- * Given a converter, save the data
- *
- * @param converter Saves the data to a file
- * @param data Data object to save
- * @return Whether or not the save was successful
- */
- public boolean save(Converter converter, Data data) {
- String outDataStr = (String)converter.getProperties().get(AlgorithmProperty.OUT_DATA);
-
- String ext = outDataStr.substring(outDataStr.indexOf(':')+1);
-
- if ((""+ext).startsWith(".")) {
- ext = ext.substring(1);
- }
-
- FileDialog dialog = new FileDialog(parent, SWT.SAVE);
-
- if (currentDir == null) {
- currentDir = new File(System.getProperty("user.home") + File.separator + "anything");
- }
- dialog.setFilterPath(currentDir.getPath());
-
-
- if (ext != null && !ext.equals("*")) {
- dialog.setFilterExtensions(new String[]{"*." + ext});
- }
-
- dialog.setText("Choose File");
-
- String fileLabel = (String)data.getMetadata().get(DataProperty.LABEL);
- String suggestedFileName = getFileName(fileLabel);
- dialog.setFileName(suggestedFileName + "." + ext);
-
-// if (fileLabel == null) {
-// dialog.setFileName("*." + ext);
-// } else {
-// dialog.setFileName(fileLabel + '.' + ext);
-// }
-
- boolean done = false;
-
- while (!done) {
- String fileName = dialog.open();
- if (fileName != null) {
- File selectedFile = new File(fileName);
- if (!isSaveFileValid(selectedFile))
- continue;
- if (ext != null && ext.length() != 0)
- if (!selectedFile.getPath().endsWith(ext) && !ext.equals("*"))
- selectedFile = new File(selectedFile.getPath()+'.'+ ext);
- try {
- Data newData = converter.convert(data);
-
-
- copy((File)newData.getData(), selectedFile);
-
- if (selectedFile.isDirectory()) {
- currentDir = new File(selectedFile + File.separator + "anything");
- } else {
- currentDir = new File(selectedFile.getParent() + File.separator + "anything");
- }
-
- done = true;
- } catch (ConversionException e1) {
- this.log.log(LogService.LOG_ERROR, "Error occurred while converting data to saved format.", e1);
- return false;
- }
- log.log(LogService.LOG_INFO, "Saved: " + selectedFile.getPath());
- } else {
- done = true;
- return false;
- }
- }
- return true;
- }
-
- /**
- * Converter puts it into a temporary directory, this copies it over
- *
- * @param in The temp file to copy
- * @param out Destination to copy to
- * @return True on successful copy, false otherwise
- */
- private boolean copy(File in, File out) {
- try {
- FileInputStream fis = new FileInputStream(in);
- FileOutputStream fos = new FileOutputStream(out);
-
- FileChannel readableChannel = fis.getChannel();
- FileChannel writableChannel = fos.getChannel();
-
- writableChannel.truncate(0);
- writableChannel.transferFrom(readableChannel, 0, readableChannel.size());
- fis.close();
- fos.close();
- return true;
- }
- catch (IOException ioe) {
- guiBuilder.showError("Copy Error", "IOException during copy", ioe.getMessage());
- return false;
- }
- }
-
- private String getFileName(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);
-
- String fileName = fileNameWithoutExtension;
- return fileName;
- }
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2008-03-27 17:46:12 UTC (rev 728)
@@ -0,0 +1,217 @@
+/*
+ * Created on Aug 19, 2004
+ */
+package org.cishell.reference.gui.persistence.save;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.AlgorithmProperty;
+import org.cishell.framework.data.Data;
+import org.cishell.framework.data.DataProperty;
+import org.cishell.service.conversion.ConversionException;
+import org.cishell.service.conversion.Converter;
+import org.cishell.service.guibuilder.GUIBuilderService;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.osgi.service.log.LogService;
+
+/**
+ * Persist the file to disk for the user
+ *
+ * @author Team
+ */
+public class FileSaver {
+ private static File currentDir;
+
+ private Shell parent;
+
+ private GUIBuilderService guiBuilder;
+ private LogService log;
+
+
+ /**
+ * Initializes services to output messages
+ *
+ * @param parent
+ * @param context
+ */
+ public FileSaver(Shell parent, CIShellContext context){
+ this.parent = parent;
+ this.guiBuilder = (GUIBuilderService)context.getService(GUIBuilderService.class.getName());
+ this.log = (LogService) context.getService(LogService.class.getName());
+ }
+
+ /**
+ * File exists, so make sure the user wants to overwrite
+ * @param file The file to possibly overwrite
+ * @return Whether or not the user decides to overwrite
+ */
+ private boolean confirmFileOverwrite(File file) {
+ String message = "The file:\n" + file.getPath()
+ + "\nalready exists. Are you sure you want to overwrite it?";
+ return guiBuilder.showConfirm("File Overwrite", message, "");
+ }
+
+ /**
+ * Checks for a valid file destination
+ *
+ * @param file to save to
+ * @return True on valid file save
+ */
+ private boolean isSaveFileValid(File file) {
+ boolean valid = false;
+ if (file.isDirectory()) {
+ String message = "Destination cannot be a directory. Please choose a file";
+ guiBuilder.showError("Invalid Destination", message, "");
+ valid = false;
+ } else if (file.exists()) {
+ valid = confirmFileOverwrite(file);
+ }
+ else
+ valid = true ;
+ return valid;
+ }
+
+ /**
+ * Given a converter, save the data
+ *
+ * @param converter Saves the data to a file
+ * @param data Data object to save
+ * @return Whether or not the save was successful
+ */
+ public boolean save(Converter converter, Data data) {
+ String outDataStr = (String)converter.getProperties().get(AlgorithmProperty.OUT_DATA);
+
+ String ext = outDataStr.substring(outDataStr.indexOf(':')+1);
+
+ if ((""+ext).startsWith(".")) {
+ ext = ext.substring(1);
+ }
+
+ FileDialog dialog = new FileDialog(parent, SWT.SAVE);
+
+ if (currentDir == null) {
+ currentDir = new File(System.getProperty("user.home") + File.separator + "anything");
+ }
+ dialog.setFilterPath(currentDir.getPath());
+
+
+ if (ext != null && !ext.equals("*")) {
+ dialog.setFilterExtensions(new String[]{"*." + ext});
+ }
+
+ dialog.setText("Choose File");
+
+ String fileLabel = (String)data.getMetadata().get(DataProperty.LABEL);
+ String suggestedFileName = getFileName(fileLabel);
+ dialog.setFileName(suggestedFileName + "." + ext);
+
+// if (fileLabel == null) {
+// dialog.setFileName("*." + ext);
+// } else {
+// dialog.setFileName(fileLabel + '.' + ext);
+// }
+
+ boolean done = false;
+
+ while (!done) {
+ String fileName = dialog.open();
+ if (fileName != null) {
+ File selectedFile = new File(fileName);
+ if (!isSaveFileValid(selectedFile))
+ continue;
+ if (ext != null && ext.length() != 0)
+ if (!selectedFile.getPath().endsWith(ext) && !ext.equals("*"))
+ selectedFile = new File(selectedFile.getPath()+'.'+ ext);
+ try {
+ Data newData = converter.convert(data);
+
+
+ copy((File)newData.getData(), selectedFile);
+
+ if (selectedFile.isDirectory()) {
+ currentDir = new File(selectedFile + File.separator + "anything");
+ } else {
+ currentDir = new File(selectedFile.getParent() + File.separator + "anything");
+ }
+
+ done = true;
+ } catch (ConversionException e1) {
+ this.log.log(LogService.LOG_ERROR, "Error occurred while converting data to saved format.", e1);
+ return false;
+ }
+ log.log(LogService.LOG_INFO, "Saved: " + selectedFile.getPath());
+ } else {
+ done = true;
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Converter puts it into a temporary directory, this copies it over
+ *
+ * @param in The temp file to copy
+ * @param out Destination to copy to
+ * @return True on successful copy, false otherwise
+ */
+ private boolean copy(File in, File out) {
+ try {
+ FileInputStream fis = new FileInputStream(in);
+ FileOutputStream fos = new FileOutputStream(out);
+
+ FileChannel readableChannel = fis.getChannel();
+ FileChannel writableChannel = fos.getChannel();
+
+ writableChannel.truncate(0);
+ writableChannel.transferFrom(readableChannel, 0, readableChannel.size());
+ fis.close();
+ fos.close();
+ return true;
+ }
+ catch (IOException ioe) {
+ guiBuilder.showError("Copy Error", "IOException during copy", ioe.getMessage());
+ return false;
+ }
+ }
+
+ private String getFileName(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);
+
+ String fileName = fileNameWithoutExtension;
+ return fileName;
+ }
+}
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-03-27 15:38:15 UTC (rev 727)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-03-27 17:46:12 UTC (rev 728)
@@ -17,7 +17,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.ServiceReference;
-
/**
* Save algorithm for persisting a data object
*
@@ -72,26 +71,8 @@
guiRun(new Runnable() {
public void run() {
if (converters.length == 0) {
- final FileSaver saver = new FileSaver(parentShell, context);
- saver.save(new Converter(){
- Dictionary props = new Hashtable();
-
- public Data convert(Data data) {
- return data;
- }
-
- public AlgorithmFactory getAlgorithmFactory() {
- return null;
- }
-
- public ServiceReference[] getConverterChain() {
- return null;
- }
-
- public Dictionary getProperties() {
- props.put(AlgorithmProperty.OUT_DATA, "file:*");
- return props;
- }}, data[0]);
+ FileSaver saver = new FileSaver(parentShell, context);
+ saver.save(new NoConversionConverter(), data[0]);
} else if (converters.length == 1) {
final FileSaver saver = new FileSaver(parentShell, context);
saver.save(converters[0], data[0]);
@@ -119,4 +100,25 @@
parentShell.getDisplay().syncExec(run);
}
}
+
+ private class NoConversionConverter implements Converter {
+ Dictionary props = new Hashtable();
+
+ public Data convert(Data data) {
+ return data;
+ }
+
+ public AlgorithmFactory getAlgorithmFactory() {
+ return null;
+ }
+
+ public ServiceReference[] getConverterChain() {
+ return null;
+ }
+
+ public Dictionary getProperties() {
+ props.put(AlgorithmProperty.OUT_DATA, "file:*");
+ return props;
+ }
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|