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...> - 2009-06-25 18:20:13
|
Revision: 877 http://cishell.svn.sourceforge.net/cishell/?rev=877&view=rev Author: mwlinnem Date: 2009-06-25 18:20:07 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Initial import. Added Paths: ----------- trunk/libs/Apache_Derby/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-25 18:13:38
|
Revision: 876 http://cishell.svn.sourceforge.net/cishell/?rev=876&view=rev Author: mwlinnem Date: 2009-06-25 18:13:36 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Initial import. Moved from NWB repository. Added Paths: ----------- trunk/libs/commons_dbcp/.classpath trunk/libs/commons_dbcp/.project trunk/libs/commons_dbcp/.settings/ trunk/libs/commons_dbcp/META-INF/ trunk/libs/commons_dbcp/META-INF/MANIFEST.MF trunk/libs/commons_dbcp/build.properties trunk/libs/commons_dbcp/commons-dbcp-1.2.2.jar Added: trunk/libs/commons_dbcp/.classpath =================================================================== --- trunk/libs/commons_dbcp/.classpath (rev 0) +++ trunk/libs/commons_dbcp/.classpath 2009-06-25 18:13:36 UTC (rev 876) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry exported="true" kind="lib" path="commons-dbcp-1.2.2.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: trunk/libs/commons_dbcp/.project =================================================================== --- trunk/libs/commons_dbcp/.project (rev 0) +++ trunk/libs/commons_dbcp/.project 2009-06-25 18:13:36 UTC (rev 876) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>commons_dbcp</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: trunk/libs/commons_dbcp/META-INF/MANIFEST.MF =================================================================== --- trunk/libs/commons_dbcp/META-INF/MANIFEST.MF (rev 0) +++ trunk/libs/commons_dbcp/META-INF/MANIFEST.MF 2009-06-25 18:13:36 UTC (rev 876) @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Commons_dbcp Plug-in +Bundle-SymbolicName: commons_dbcp +Bundle-Version: 1.0.0 +Bundle-ClassPath: commons-dbcp-1.2.2.jar +Bundle-Localization: plugin +Export-Package: .,org.apache.commons.dbcp,org.apache.commons.dbcp.cpdsadapter,org.apache.commons.dbcp.datasources,org.apache.commons.jocl +Import-Package: org.apache.commons.pool, + org.apache.commons.pool.impl, + org.apache.derby.impl.jdbc, + org.apache.derby.impl.jdbc.authentication, + org.apache.derby.jdbc, + org.hsqldb, + org.hsqldb.jdbc Added: trunk/libs/commons_dbcp/build.properties =================================================================== --- trunk/libs/commons_dbcp/build.properties (rev 0) +++ trunk/libs/commons_dbcp/build.properties 2009-06-25 18:13:36 UTC (rev 876) @@ -0,0 +1,2 @@ +bin.includes = META-INF/,\ + commons-dbcp-1.2.2.jar Added: trunk/libs/commons_dbcp/commons-dbcp-1.2.2.jar =================================================================== (Binary files differ) Property changes on: trunk/libs/commons_dbcp/commons-dbcp-1.2.2.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-25 18:13:00
|
Revision: 875 http://cishell.svn.sourceforge.net/cishell/?rev=875&view=rev Author: mwlinnem Date: 2009-06-25 18:12:55 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Initial import. Added Paths: ----------- trunk/libs/commons_dbcp/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-25 16:46:40
|
Revision: 874 http://cishell.svn.sourceforge.net/cishell/?rev=874&view=rev Author: mwlinnem Date: 2009-06-25 16:46:39 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Initial import. Moving this from NWB repository to CIShell repository, since it is needed by the new CIShell database stuff. Added Paths: ----------- trunk/libs/commons_pool/.classpath trunk/libs/commons_pool/.project trunk/libs/commons_pool/.settings/ trunk/libs/commons_pool/META-INF/ trunk/libs/commons_pool/META-INF/MANIFEST.MF trunk/libs/commons_pool/build.properties trunk/libs/commons_pool/commons-pool-1.3.jar Added: trunk/libs/commons_pool/.classpath =================================================================== --- trunk/libs/commons_pool/.classpath (rev 0) +++ trunk/libs/commons_pool/.classpath 2009-06-25 16:46:39 UTC (rev 874) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry exported="true" kind="lib" path="commons-pool-1.3.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: trunk/libs/commons_pool/.project =================================================================== --- trunk/libs/commons_pool/.project (rev 0) +++ trunk/libs/commons_pool/.project 2009-06-25 16:46:39 UTC (rev 874) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>commons_pool</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: trunk/libs/commons_pool/META-INF/MANIFEST.MF =================================================================== --- trunk/libs/commons_pool/META-INF/MANIFEST.MF (rev 0) +++ trunk/libs/commons_pool/META-INF/MANIFEST.MF 2009-06-25 16:46:39 UTC (rev 874) @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Commons_pool Plug-in +Bundle-SymbolicName: commons_pool +Bundle-Version: 1.0.0 +Bundle-ClassPath: commons-pool-1.3.jar +Bundle-Localization: plugin +Export-Package: org.apache.commons.pool,org.apache.commons.pool.impl Added: trunk/libs/commons_pool/build.properties =================================================================== --- trunk/libs/commons_pool/build.properties (rev 0) +++ trunk/libs/commons_pool/build.properties 2009-06-25 16:46:39 UTC (rev 874) @@ -0,0 +1,2 @@ +bin.includes = META-INF/,\ + commons-pool-1.3.jar Added: trunk/libs/commons_pool/commons-pool-1.3.jar =================================================================== (Binary files differ) Property changes on: trunk/libs/commons_pool/commons-pool-1.3.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-25 16:46:17
|
Revision: 873 http://cishell.svn.sourceforge.net/cishell/?rev=873&view=rev Author: mwlinnem Date: 2009-06-25 16:46:11 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Initial import. Moving this from NWB repository to CIShell repository, since it is needed by the new CIShell database stuff. Added Paths: ----------- trunk/libs/commons_pool/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-24 19:56:57
|
Revision: 872 http://cishell.svn.sourceforge.net/cishell/?rev=872&view=rev Author: mwlinnem Date: 2009-06-24 19:56:44 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Adding Derby to database feature (which is required by some of the other plugins). Modified Paths: -------------- trunk/deployment/org.cishell.reference.database.feature/feature.xml Modified: trunk/deployment/org.cishell.reference.database.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.database.feature/feature.xml 2009-06-20 20:02:22 UTC (rev 871) +++ trunk/deployment/org.cishell.reference.database.feature/feature.xml 2009-06-24 19:56:44 UTC (rev 872) @@ -75,4 +75,10 @@ install-size="0" version="0.0.0"/> + <plugin + id="Apache_Derby" + download-size="0" + install-size="0" + version="0.0.0"/> + </feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-06-20 20:02:27
|
Revision: 871 http://cishell.svn.sourceforge.net/cishell/?rev=871&view=rev Author: pataphil Date: 2009-06-20 20:02:22 +0000 (Sat, 20 Jun 2009) Log Message: ----------- * Now when algorithms output multiple data items, only the first one is selected in the Data Manager. * Reviewed Chintan. 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 2009-06-18 19:36:47 UTC (rev 870) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2009-06-20 20:02:22 UTC (rev 871) @@ -197,7 +197,12 @@ .getServiceReference(DataManagerService.class.getName())); if (outData.length != 0) { - dataManager.setSelectedData(outData); + for (int ii = 0; ii < outData.length; ii++) { + dataManager.addData(outData[ii]); + } + + Data[] dataToSelect = new Data[] { outData[0] }; + dataManager.setSelectedData(dataToSelect); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Bruce H. <bh...@bh...> - 2009-06-18 19:41:03
|
Bad Micah, no cookie for you! :-P Bruce On Thu, Jun 18, 2009 at 3:36 PM, <mwl...@us...> wrote: > Revision: 870 > http://cishell.svn.sourceforge.net/cishell/?rev=870&view=rev > Author: mwlinnem > Date: 2009-06-18 19:36:47 +0000 (Thu, 18 Jun 2009) > > Log Message: > ----------- > Added some plugins from the NWB repository to this feature (...). Not the > hottest move. If this works I MAY move some of those libraries into CIShell > or vice-versa. > > Modified Paths: > -------------- > trunk/deployment/org.cishell.reference.database.feature/feature.xml > > Modified: > trunk/deployment/org.cishell.reference.database.feature/feature.xml > =================================================================== > --- trunk/deployment/org.cishell.reference.database.feature/feature.xml > 2009-06-18 16:36:01 UTC (rev 869) > +++ trunk/deployment/org.cishell.reference.database.feature/feature.xml > 2009-06-18 19:36:47 UTC (rev 870) > @@ -57,4 +57,22 @@ > version="0.0.0" > unpack="false"/> > > + <plugin > + id="commons_dbcp" > + download-size="0" > + install-size="0" > + version="0.0.0"/> > + > + <plugin > + id="commons_pool" > + download-size="0" > + install-size="0" > + version="0.0.0"/> > + > + <plugin > + id="hsqldb" > + download-size="0" > + install-size="0" > + version="0.0.0"/> > + > </feature> > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > Cishell-svn mailing list > Cis...@li... > https://lists.sourceforge.net/lists/listinfo/cishell-svn > |
From: <mwl...@us...> - 2009-06-18 19:36:50
|
Revision: 870 http://cishell.svn.sourceforge.net/cishell/?rev=870&view=rev Author: mwlinnem Date: 2009-06-18 19:36:47 +0000 (Thu, 18 Jun 2009) Log Message: ----------- Added some plugins from the NWB repository to this feature (...). Not the hottest move. If this works I MAY move some of those libraries into CIShell or vice-versa. Modified Paths: -------------- trunk/deployment/org.cishell.reference.database.feature/feature.xml Modified: trunk/deployment/org.cishell.reference.database.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.database.feature/feature.xml 2009-06-18 16:36:01 UTC (rev 869) +++ trunk/deployment/org.cishell.reference.database.feature/feature.xml 2009-06-18 19:36:47 UTC (rev 870) @@ -57,4 +57,22 @@ version="0.0.0" unpack="false"/> + <plugin + id="commons_dbcp" + download-size="0" + install-size="0" + version="0.0.0"/> + + <plugin + id="commons_pool" + download-size="0" + install-size="0" + version="0.0.0"/> + + <plugin + id="hsqldb" + download-size="0" + install-size="0" + version="0.0.0"/> + </feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-18 16:36:07
|
Revision: 869 http://cishell.svn.sourceforge.net/cishell/?rev=869&view=rev Author: mwlinnem Date: 2009-06-18 16:36:01 +0000 (Thu, 18 Jun 2009) Log Message: ----------- Contents of new database feature. Added Paths: ----------- trunk/deployment/org.cishell.reference.database.feature/.project trunk/deployment/org.cishell.reference.database.feature/build.properties trunk/deployment/org.cishell.reference.database.feature/feature.xml Added: trunk/deployment/org.cishell.reference.database.feature/.project =================================================================== --- trunk/deployment/org.cishell.reference.database.feature/.project (rev 0) +++ trunk/deployment/org.cishell.reference.database.feature/.project 2009-06-18 16:36:01 UTC (rev 869) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.reference.database.feature</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.FeatureBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.FeatureNature</nature> + </natures> +</projectDescription> Added: trunk/deployment/org.cishell.reference.database.feature/build.properties =================================================================== --- trunk/deployment/org.cishell.reference.database.feature/build.properties (rev 0) +++ trunk/deployment/org.cishell.reference.database.feature/build.properties 2009-06-18 16:36:01 UTC (rev 869) @@ -0,0 +1 @@ +bin.includes = feature.xml Added: trunk/deployment/org.cishell.reference.database.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.database.feature/feature.xml (rev 0) +++ trunk/deployment/org.cishell.reference.database.feature/feature.xml 2009-06-18 16:36:01 UTC (rev 869) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="org.cishell.reference.database.feature" + label="CIShell Reference Bundles Related to Internal Database" + version="1.0.0"> + + <description url="http://cishell.org"> + CIShell Reference Bundles + </description> + + <copyright> + Copyright 2006 Indiana University + </copyright> + + <license url="http://www.apache.org/licenses/LICENSE-2.0"> + CIShell: Cyberinfrastructure Shell +Copyright 2006 Indiana University +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the specific +language governing permissions and limitations under the License. +Project Contacts: +Bruce Herr (bh...@bh...) +Weixia Huang (hu...@in...) +Shashikant Penumarthy (sp...@in...) +Dr. Katy Borner (ka...@in...) + </license> + + <url> + <update label="CIShell Update Site" url="http://cishell.org/update"/> + <discovery label="CIShell Update Site" url="http://cishell.org/update"/> + </url> + + <plugin + id="org.cishell.reference.service.database" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.cishell.service.database" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.cishell.templates.database" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + +</feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-06-18 16:35:54
|
Revision: 868 http://cishell.svn.sourceforge.net/cishell/?rev=868&view=rev Author: mwlinnem Date: 2009-06-18 16:35:32 +0000 (Thu, 18 Jun 2009) Log Message: ----------- New feature for as-of-yet not used database stuff in CIShell (is currently used in SciPolicy though). Added Paths: ----------- trunk/deployment/org.cishell.reference.database.feature/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-05-27 17:45:00
|
Revision: 867 http://cishell.svn.sourceforge.net/cishell/?rev=867&view=rev Author: mwlinnem Date: 2009-05-27 17:44:50 +0000 (Wed, 27 May 2009) Log Message: ----------- Reworked code that handles loading files for ambiguous file extensions. Reviewed by Patrick. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java Copied: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java (from rev 866, trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java) =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2009-05-27 17:44:50 UTC (rev 867) @@ -0,0 +1,219 @@ +/* + * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research + * and Education in Information Visualization (http://iv.slis.indiana.edu/). + * + * Created on Jan 24, 2005 at Indiana University. + */ +package org.cishell.reference.gui.persistence.load; + +import java.io.File; +import java.util.ArrayList; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.reference.gui.common.AbstractDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; + +/** + * + * @author Team IVC (Weixia Huang, James Ellis) + */ +public class FileFormatSelector extends AbstractDialog { + private File selectedFile; + private LogService logger; + + private ServiceReference[] persisterArray; + private List persisterList; +// private StyledText detailPane; + private CIShellContext ciShellContext; + private BundleContext bundleContext; + private ArrayList returnList; + +// private static final String[] DETAILS_ITEM_KEY = +// {"format_name", "supported_file_extension", "format_description" }; + + /* + * Other possible keys could be restorable_model_name, restorable_model_description + * */ + +// private static final String[] DETAILS_ITEM_KEY_DISPLAY_VALUE = +// {"Format name", "Supported file extension", "Format description"}; + + /* + * Other possible keys display values could be "Restorable model name", "Restorable model description" + * */ + + public FileFormatSelector(String title, File theFile, + Shell parent, CIShellContext ciContext, BundleContext bContext, + ServiceReference[] persisterArray, ArrayList returnList){ + super(parent, title, AbstractDialog.QUESTION); + this.ciShellContext = ciContext; + this.bundleContext = bContext; + this.persisterArray = persisterArray; + this.returnList = returnList; + + this.selectedFile = theFile; + + this.logger = (LogService) ciContext.getService(LogService.class.getName()); + //shall this part be moved out of the code? + setDescription("The file you have selected can be loaded" + + " using one or more of the following formats.\n" + + "Please select the format you would like to try."); + setDetails("This dialog allows the user to choose among all available " + + "formats for loading the selected data model. Choose any of the formats " + + "to continue loading the dataset."); + } + + private Composite initGUI(Composite parent) { + Composite content = new Composite(parent, SWT.NONE); + + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + content.setLayout(layout); + + Group persisterGroup = new Group(content, SWT.NONE); + //shall this label be moved out of the code? + persisterGroup.setText("Load as..."); + persisterGroup.setLayout(new FillLayout()); + GridData persisterListGridData = new GridData(GridData.FILL_BOTH); + persisterListGridData.widthHint = 200; + persisterGroup.setLayoutData(persisterListGridData); + + persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE); + // initPersisterArray(); + initPersisterList(); + persisterList.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + List list = (List)e.getSource(); + int selection = list.getSelectionIndex(); + if(selection != -1){ +// updateDetailPane(persisterArray[selection]); + } + } + }); + +// Group detailsGroup = new Group(content, SWT.NONE); +// // shall this label be moved out of the code? +// detailsGroup.setText("Details"); +// detailsGroup.setLayout(new FillLayout()); +// GridData detailsGridData = new GridData(GridData.FILL_BOTH); +// detailsGridData.widthHint = 200; +// detailsGroup.setLayoutData(detailsGridData); +// +// detailPane = initDetailPane(detailsGroup); +// +// persisterList.setSelection(0); +// updateDetailPane(persisterArray[0]); + + return content; + } + + private void initPersisterList(){ + for (int i = 0; i < persisterArray.length; ++i) { + + String name = (String)persisterArray[i].getProperty("label"); + + // if someone was sloppy enough to not provide a name, then use the + // name of the class instead. + if (name == null || name.length() == 0) + name = persisterArray[i].getClass().getName(); + persisterList.add(name); + } + } + + +// private StyledText initDetailPane(Group detailsGroup) { +// StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL); +// detailPane.setEditable(false); +// detailPane.getCaret().setVisible(false); +// return detailPane; +// } + +// private void updateDetailPane(ServiceReference persister) { +// +// detailPane.setText(""); +// for (int i=0; i<DETAILS_ITEM_KEY.length; i++){ +// String val = (String) persister.getProperty(DETAILS_ITEM_KEY[i]); +// +// StyleRange styleRange = new StyleRange(); +// styleRange.start = detailPane.getText().length(); +// detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[i] + ":\n"); +// styleRange.length = DETAILS_ITEM_KEY[i].length() + 1; +// styleRange.fontStyle = SWT.BOLD; +// detailPane.setStyleRange(styleRange); +// +// detailPane.append(val + "\n"); +// +// } +// +// } + + private void selectionMade(int selectedIndex) { + AlgorithmFactory persister =(AlgorithmFactory) bundleContext.getService(persisterArray[selectedIndex]); + Data[] dataManager = null; + boolean loadSuccess = false; + + try { + dataManager = new Data[]{new BasicData(selectedFile.getPath(),String.class.getName())}; + dataManager = persister.createAlgorithm(dataManager, null, ciShellContext).execute(); + loadSuccess = true; + } catch (Throwable e) { + this.logger.log(LogService.LOG_ERROR, "Error occurred while executing selection", e); + e.printStackTrace(); + loadSuccess = false; + } + + if (dataManager != null && loadSuccess) { + logger.log(LogService.LOG_INFO, "Loaded: "+selectedFile.getPath()); + + for(int i = 0; i<dataManager.length; i++){ + returnList.add(dataManager[i]); + } + close(true); + } else { + logger.log(LogService.LOG_ERROR, "Unable to load with selected loader"); + } + } + + public void createDialogButtons(Composite parent) { + Button select = new Button(parent, SWT.PUSH); + select.setText("Select"); + select.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + int index = persisterList.getSelectionIndex(); + if(index != -1){ + selectionMade(index); + } + } + }); + + Button cancel = new Button(parent, SWT.NONE); + cancel.setText("Cancel"); + cancel.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + close(false); + } + }); + } + + public Composite createContent(Composite parent) { + return initGUI(parent); + } +} 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 2009-04-24 22:00:50 UTC (rev 866) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2009-05-27 17:44:50 UTC (rev 867) @@ -21,29 +21,19 @@ import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; -/* - * @author Weixia(Bonnie) Huang (hu...@in...) - */ public class FileLoad implements Algorithm { private final LogService logger; - private final GUIBuilderService guiBuilder; private BundleContext bundleContext; private CIShellContext ciShellContext; private static String defaultLoadDirectory; - private final static String FILTER_EXTENSION_ALL = "*"; - private final static String FILTER_AMBIGUOUS = "&(type=validator)(format_name=*)(in_data=file-ext:*)"; - private final static String FILTER_IN_DATA = "&(type=validator)(format_name=*)"; - public FileLoad(CIShellContext ciContext, BundleContext bContext, Dictionary prefProperties) { this.ciShellContext = ciContext; this.bundleContext = bContext; logger = (LogService) ciContext.getService(LogService.class.getName()); - guiBuilder = (GUIBuilderService) ciContext - .getService(GUIBuilderService.class.getName()); // unpack preference properties if (defaultLoadDirectory == null) { @@ -75,291 +65,158 @@ final class FileLoadRunnable implements Runnable { boolean loadFileSuccess = false; IWorkbenchWindow window; + // this is how we return values from the runnable - public ArrayList selectedServicesForLoadedFileList = new ArrayList(); + public ArrayList loadedFiles_ReturnParameter = new ArrayList(); FileLoadRunnable(IWorkbenchWindow window) { this.window = window; } + /* + * Let the user chose which file to load, + * Let the user choose the file type (if it is ambiguous), + * and then actually load and validate the file. + */ public void run() { - 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"); - // } - // } - File currentDir = new File(defaultLoadDirectory); // ? good way to - // do this? - String absolutePath = currentDir.getAbsolutePath(); - String name = currentDir.getName(); - dialog.setFilterPath(absolutePath); - // dialog.setFilterPath(name); - dialog.setText("Select a File"); - String fileName = dialog.open(); - if (fileName == null) { - return; - } + try { + // Prepare to ask the user which file to load. - File file = new File(fileName); - if (file.isDirectory()) { - defaultLoadDirectory = file.getAbsolutePath(); - } else { + FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); + File currentDir = new File(defaultLoadDirectory); + String absolutePath = currentDir.getAbsolutePath(); + dialog.setFilterPath(absolutePath); + dialog.setText("Select a File"); - // File parentFile = file.getParentFile(); - // if (parentFile != null) { - defaultLoadDirectory = file.getParentFile().getAbsolutePath(); - // } - } + // Determine which file to load. - String fileExtension = getFileExtension(file).toLowerCase(); + String nameOfFileToLoad = dialog.open(); + if (nameOfFileToLoad == null) { + return; + } - /* - * This filter is used to filter out all the services which are NOT, - * 1. validators 2. validators but for output file functionality - * Hence only input file functionality validators are allowed. - */ + // Actually load the file. - try { + File file = new File(nameOfFileToLoad); - // get all the service references of validators that can load - // this type of file. + if (file.isDirectory()) { + defaultLoadDirectory = file.getAbsolutePath(); + } else { + defaultLoadDirectory = file.getParentFile().getAbsolutePath(); + } - ServiceReference[] selectedFileServiceReferences = null; + //Validate the loaded file, "casting" it to a certain MIME type. - if(fileExtension != null && fileExtension.length() > 0) { - selectedFileServiceReferences = getApplicableServiceReferences( - FILTER_IN_DATA, fileExtension); - } - - /* - * This use case is for input files selected that are, 1. - * without any file extensions 2. with file extensions that do - * not match any service "in_data" field. - */ + // Extract the file's file extension. - if ((selectedFileServiceReferences == null || selectedFileServiceReferences.length == 0)) { + String fileExtension = getFileExtension(file).toLowerCase(); - /* - * This filter is used to accept only those services which - * are, 1. type = validators and, 2. which have non-empty - * format_name and, 3. which have non-empty in_data field. - * or, 3. which have empty in_data field and non-empty - * ambiguous_extension field. This is used so that all the - * validators for output file functionality are filtered - * out. - */ + // Get all the validators which support this file extension... - ServiceReference[] potentialValidators = null; + ServiceReference[] supportingValidators = getSupportingValidators(fileExtension); - /* - * This is used to find validators that support ambiguous - * extensions for the provided file extension. There are - * good chances that the file selected does not have any - * file extension, this is handled by below case. - */ + // If there are no supporting validators... + if (supportingValidators.length == 0) { + // Let the user choose from all the validators available. - if (fileExtension != null && fileExtension.length() > 0) { + ServiceReference[] allValidators = getAllValidators(); - potentialValidators = getApplicableServiceReferences( - FILTER_AMBIGUOUS, fileExtension); - - } - - /* - * If no services are found then provide for all the - * validators list. - */ - - if (potentialValidators == null - || potentialValidators.length == 0) { - - potentialValidators = getApplicableServiceReferences( - FILTER_IN_DATA, FILTER_EXTENSION_ALL); - - } - - /* - * SelectedFileServiceSelector is used to create a GUI for - * selecting a service for the selected file from a list of - * applicable services. On selection of a service it calls - * the validator for that service. If the validator passes - * it it goes ahead and loads the file appropriately else it - * throws error message asking the user to select other - * service. - * - * This modifies the selectedServicesForLoadedFileList, - * which is the placeholder for all the verified/ applicable - * services for a selected/loaded file. - */ - - new SelectedFileServiceSelector("Load", file, window - .getShell(), ciShellContext, bundleContext, - potentialValidators, - selectedServicesForLoadedFileList).open(); + new FileFormatSelector("Load", file, window.getShell(), + ciShellContext, bundleContext, allValidators, + loadedFiles_ReturnParameter).open(); } - /* - * This use case is for input files selected that have only one - * applicable service. Special case where the file extension - * belongs to ambiguous file extension group like csv is also - * handled. In the simple case system goes ahead and loads the - * file with that service. - */ + // If there is just one supporting validator... + if (supportingValidators.length == 1) { + // Just use that validator to validate the file. + + ServiceReference onlyPossibleValidator = supportingValidators[0]; + AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext + .getService(onlyPossibleValidator); + Data[] outputDataAfterValidation; + Data[] inputDataForValidation = new Data[] { new BasicData( + file.getPath(), String.class.getName()) }; + outputDataAfterValidation = selectedValidatorExecutor + .createAlgorithm(inputDataForValidation, null, + ciShellContext).execute(); - else if (selectedFileServiceReferences.length == 1) { - /* - * To check for the files with ambiguous file extension a - * seperate list of service references is created. + * outputDataAfterValidation = null implies that file + * was not loaded properly. */ - ServiceReference[] selectedFileAmbiguousValidators = getApplicableServiceReferences( - FILTER_AMBIGUOUS, fileExtension); - - /* - * If allAmbiguousValidators is not empty then the system - * provides a dialog box to select from the available - * validators. In this case CSV, NSF & SCOPUS - */ - - if ((selectedFileAmbiguousValidators != null && selectedFileAmbiguousValidators.length > 0)) { - new SelectedFileServiceSelector("Load", file, window - .getShell(), ciShellContext, bundleContext, - selectedFileAmbiguousValidators, - selectedServicesForLoadedFileList).open(); + if (outputDataAfterValidation != null) { + loadFileSuccess = true; + logger.log(LogService.LOG_INFO, "Loaded: " + + file.getPath()); + for (int i = 0; i < outputDataAfterValidation.length; i++) + loadedFiles_ReturnParameter. + add(outputDataAfterValidation[i]); } - - /* - * If allAmbiguousValidators is not empty we go forward with - * normal work flow of loading the file with selected file - * format. - */ - - else { - - AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext - .getService(selectedFileServiceReferences[0]); - Data[] outputDataAfterValidation; - Data[] inputDataForValidation = new Data[] { new BasicData( - file.getPath(), String.class.getName()) }; - outputDataAfterValidation = selectedValidatorExecutor - .createAlgorithm(inputDataForValidation, null, - ciShellContext).execute(); - - /* - * outputDataAfterValidation = null implies that file - * was not loaded properly. - */ - - if (outputDataAfterValidation != null) { - loadFileSuccess = true; - logger.log(LogService.LOG_INFO, "Loaded: " - + file.getPath()); - for (int i = 0; i < outputDataAfterValidation.length; i++) - selectedServicesForLoadedFileList - .add(outputDataAfterValidation[i]); - } - } - } - /* - * This use case is for input files selected that have more than - * one applicable services. For e.g. ".xml" can be xgmml, - * graphml, treeml. This now triggers the - * SelectedFileServiceSelector dialog & can be used to select - * any one of the available services for that particular file - * extension. - */ + // If there is more than one supporting validator... + if (supportingValidators.length > 1) { + // Let the user choose which validator they want to use. - else if (selectedFileServiceReferences.length > 1) { - - new SelectedFileServiceSelector("Load", file, window - .getShell(), ciShellContext, bundleContext, - selectedFileServiceReferences, - selectedServicesForLoadedFileList).open(); - + new FileFormatSelector("Load", file, window.getShell(), + ciShellContext, bundleContext, supportingValidators, + loadedFiles_ReturnParameter).open(); } - /* - * Bonnie: I commented out the following functions since when - * the application failed to load an nwb file, etc, the reader - * has report the error. It does not need this second error - * display. But maybe not all file readers will generate the - * error display if a failure occurs... - */ - /* - * if (serviceRefList != null){ if(serviceRefList.length >0 && - * !loadFileSuccess){ - * guiBuilder.showError("Can Not Load The File", - * "Sorry, it's very possible that you have a wrong file format," - * + "since the file can not be loaded to the application.", - * - * "Please check Data Formats that this application can support at " - * + - * "https://nwb.slis.indiana.edu/community/?n=Algorithms.HomePage." - * + "And send your requests or report the problem to "+ - * "cis...@li.... \n"+"Thank you."); - * } - * - * } - */ } catch (Exception e) { throw new RuntimeException(e); } - - }// end run() - - /** - * @param selectedFileServiceReferencesFilter - * @param fileExtensionManipulations - * @return - * @throws InvalidSyntaxException - */ - private ServiceReference[] getApplicableServiceReferences( - String selectedFileServiceReferencesFilter, - String fileExtensionManipulations) - throws InvalidSyntaxException { - - String appliedValidatorFilter = getValidatorFilter( - selectedFileServiceReferencesFilter, - fileExtensionManipulations); - - ServiceReference[] selectedFileServiceReferences = bundleContext - .getAllServiceReferences(AlgorithmFactory.class.getName(), - appliedValidatorFilter); - - return selectedFileServiceReferences; - } - - private String getValidatorFilter( - String selectedFileServiceReferencesFilter, - String fileExtensionManipulations) { - - if (selectedFileServiceReferencesFilter.equals(FILTER_IN_DATA)) { - return "(" + selectedFileServiceReferencesFilter - + "(in_data=file-ext:" + fileExtensionManipulations - + ")" + - ")"; - - } else if (selectedFileServiceReferencesFilter.equals(FILTER_AMBIGUOUS)) { - return "(" + selectedFileServiceReferencesFilter - + "(ambiguous_extension=" + fileExtensionManipulations - + ")" + - ")"; + + private ServiceReference[] getSupportingValidators(String fileExtension) { + try { + String ldapQuery = "(& (type=validator)" + + "(|" + + "(in_data=file-ext:" + fileExtension + ")" + + "(also_validates=" + fileExtension + ")" + + "))"; + + ServiceReference[] supportingValidators = + bundleContext.getAllServiceReferences( + AlgorithmFactory.class.getName(), + ldapQuery); + + + if (supportingValidators == null) { + //(better to return a list of length zero than null) + supportingValidators = new ServiceReference[]{}; + } + + return supportingValidators; + + + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + return new ServiceReference[]{}; } - - return null; } - + + private ServiceReference[] getAllValidators() { + try { + ServiceReference[] allValidators = + bundleContext.getAllServiceReferences( + AlgorithmFactory.class.getName(), + "(&(type=validator)(in_data=file-ext:*))"); + + if (allValidators == null) { + //(better to return a list of length zero than null) + allValidators = new ServiceReference[]{}; + } + + return allValidators; + + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + return new ServiceReference[]{}; + } + } + public String getFileExtension(File theFile) { String fileName = theFile.getName(); String extension; @@ -369,7 +226,7 @@ extension = ""; return extension; } - } // end class + } private IWorkbenchWindow getFirstWorkbenchWindow() throws AlgorithmExecutionException { @@ -387,11 +244,11 @@ throws AlgorithmExecutionException { Data[] loadedFileData; try { - if (!dataUpdater.selectedServicesForLoadedFileList.isEmpty()) { - int size = dataUpdater.selectedServicesForLoadedFileList.size(); + if (!dataUpdater.loadedFiles_ReturnParameter.isEmpty()) { + int size = dataUpdater.loadedFiles_ReturnParameter.size(); loadedFileData = new Data[size]; for (int index = 0; index < size; index++) { - loadedFileData[index] = (Data) dataUpdater.selectedServicesForLoadedFileList + loadedFileData[index] = (Data) dataUpdater.loadedFiles_ReturnParameter .get(index); } return loadedFileData; Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java 2009-04-24 22:00:50 UTC (rev 866) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java 2009-05-27 17:44:50 UTC (rev 867) @@ -1,219 +0,0 @@ -/* - * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research - * and Education in Information Visualization (http://iv.slis.indiana.edu/). - * - * Created on Jan 24, 2005 at Indiana University. - */ -package org.cishell.reference.gui.persistence.load; - -import java.io.File; -import java.util.ArrayList; - -import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.data.BasicData; -import org.cishell.framework.data.Data; -import org.cishell.reference.gui.common.AbstractDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; - -/** - * - * @author Team IVC (Weixia Huang, James Ellis) - */ -public class SelectedFileServiceSelector extends AbstractDialog { - private File selectedFile; - private LogService logger; - - private ServiceReference[] persisterArray; - private List persisterList; - private StyledText detailPane; - private CIShellContext ciShellContext; - private BundleContext bundleContext; - private ArrayList returnList; - - private static final String[] DETAILS_ITEM_KEY = - {"format_name", "supported_file_extension", "format_description" }; - - /* - * Other possible keys could be restorable_model_name, restorable_model_description - * */ - - private static final String[] DETAILS_ITEM_KEY_DISPLAY_VALUE = - {"Format name", "Supported file extension", "Format description"}; - - /* - * Other possible keys display values could be "Restorable model name", "Restorable model description" - * */ - - public SelectedFileServiceSelector(String title, File theFile, - Shell parent, CIShellContext ciContext, BundleContext bContext, - ServiceReference[] persisterArray, ArrayList returnList){ - super(parent, title, AbstractDialog.QUESTION); - this.ciShellContext = ciContext; - this.bundleContext = bContext; - this.persisterArray = persisterArray; - this.returnList = returnList; - - this.selectedFile = theFile; - - this.logger = (LogService) ciContext.getService(LogService.class.getName()); - //shall this part be moved out of the code? - setDescription("The file you have selected can be loaded" - + " using the following formats.\n" - + "Please select one of them."); - setDetails("This dialog allows the user to choose among all available " + - "formats for loading the selected data model. Choose any of the formats " + - "to continue loading the dataset."); - } - - private Composite initGUI(Composite parent) { - Composite content = new Composite(parent, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - content.setLayout(layout); - - Group persisterGroup = new Group(content, SWT.NONE); - //shall this label be moved out of the code? - persisterGroup.setText("Loaded by"); - persisterGroup.setLayout(new FillLayout()); - GridData persisterListGridData = new GridData(GridData.FILL_BOTH); - persisterListGridData.widthHint = 200; - persisterGroup.setLayoutData(persisterListGridData); - - persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE); - // initPersisterArray(); - initPersisterList(); - persisterList.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - List list = (List)e.getSource(); - int selection = list.getSelectionIndex(); - if(selection != -1){ - updateDetailPane(persisterArray[selection]); - } - } - }); - - Group detailsGroup = new Group(content, SWT.NONE); - // shall this label be moved out of the code? - detailsGroup.setText("Details"); - detailsGroup.setLayout(new FillLayout()); - GridData detailsGridData = new GridData(GridData.FILL_BOTH); - detailsGridData.widthHint = 200; - detailsGroup.setLayoutData(detailsGridData); - - detailPane = initDetailPane(detailsGroup); - - persisterList.setSelection(0); - updateDetailPane(persisterArray[0]); - - return content; - } - - private void initPersisterList(){ - for (int i = 0; i < persisterArray.length; ++i) { - - String name = (String)persisterArray[i].getProperty("converter_name"); - - // if someone was sloppy enough to not provide a name, then use the - // name of the class instead. - if (name == null || name.length() == 0) - name = persisterArray[i].getClass().getName(); - persisterList.add(name); - } - } - - - private StyledText initDetailPane(Group detailsGroup) { - StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL); - detailPane.setEditable(false); - detailPane.getCaret().setVisible(false); - return detailPane; - } - - private void updateDetailPane(ServiceReference persister) { - - detailPane.setText(""); - for (int i=0; i<DETAILS_ITEM_KEY.length; i++){ - String val = (String) persister.getProperty(DETAILS_ITEM_KEY[i]); - - StyleRange styleRange = new StyleRange(); - styleRange.start = detailPane.getText().length(); - detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[i] + ":\n"); - styleRange.length = DETAILS_ITEM_KEY[i].length() + 1; - styleRange.fontStyle = SWT.BOLD; - detailPane.setStyleRange(styleRange); - - detailPane.append(val + "\n"); - - } - - } - - private void selectionMade(int selectedIndex) { - AlgorithmFactory persister =(AlgorithmFactory) bundleContext.getService(persisterArray[selectedIndex]); - Data[] dataManager = null; - boolean loadSuccess = false; - - try { - dataManager = new Data[]{new BasicData(selectedFile.getPath(),String.class.getName())}; - dataManager = persister.createAlgorithm(dataManager, null, ciShellContext).execute(); - loadSuccess = true; - } catch (Throwable e) { - this.logger.log(LogService.LOG_ERROR, "Error occurred while executing selection", e); - e.printStackTrace(); - loadSuccess = false; - } - - if (dataManager != null && loadSuccess) { - logger.log(LogService.LOG_INFO, "Loaded: "+selectedFile.getPath()); - - for(int i = 0; i<dataManager.length; i++){ - returnList.add(dataManager[i]); - } - close(true); - } else { - logger.log(LogService.LOG_ERROR, "Unable to load with selected loader"); - } - } - - public void createDialogButtons(Composite parent) { - Button select = new Button(parent, SWT.PUSH); - select.setText("Select"); - select.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - int index = persisterList.getSelectionIndex(); - if(index != -1){ - selectionMade(index); - } - } - }); - - Button cancel = new Button(parent, SWT.NONE); - cancel.setText("Cancel"); - cancel.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - close(false); - } - }); - } - - public Composite createContent(Composite parent) { - return initGUI(parent); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-04-24 22:00:54
|
Revision: 866 http://cishell.svn.sourceforge.net/cishell/?rev=866&view=rev Author: mwlinnem Date: 2009-04-24 22:00:50 +0000 (Fri, 24 Apr 2009) Log Message: ----------- 3 Things: Fixed CIShell menu to only include things really in CIShell, not things in NWB. Added a bunch of new icons from SciPolicy into CIShell as well. Made CIShell use a default icon instead of crashing and burning when it can't find an icon it wants. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml trunk/clients/gui/org.cishell.reference.gui.datamanager/build.properties trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/database.jpg trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/matrix.png trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/plot.png trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/raster_image.jpg trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/vector_image.jpg trunk/clients/gui/org.cishell.reference.gui.datamanager/unknown.png Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml 2009-03-06 23:41:41 UTC (rev 865) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/default_menu.xml 2009-04-24 22:00:50 UTC (rev 866) @@ -2,126 +2,23 @@ <!-- <?xml version="1.0" encoding="ISO-8859-1" ?> --> <menu_layout> <top_menu name="File"> - <menu name="Load..." pid= "org.cishell.reference.gui.persistence.load.FileLoad "/> - <menu name="Load CSV Files" pid= "edu.iu.nwb.preprocessing.csv.CsvAlgorithm"/> - <menu name="Directory Hierarchy Reader" pid= "edu.iu.nwb.preprocessing.prefuse.beta.directoryhierarchyreader.DirectoryHierarchyReaderAlgorithm"/> - <menu name = "Datasets" type="group"> - <menu name="Parallel Coordinates (demo) STF Dataset" pid="org.mediavirus.parvis.sampledata/pcvis_data.txt"/> - </menu> + <menu name="Load..." pid= "org.cishell.reference.gui.persistence.load.FileLoad "/> <menu type="break"/> <menu name="Save..." pid= "org.cishell.reference.gui.persistence.save.Save"/> <menu type="break"/> <menu name="View..." pid= "org.cishell.reference.gui.persistence.view.FileView"/> <menu name="View With..." pid= "org.cishell.reference.gui.persistence.viewwith.FileViewWith"/> <menu type="break"/> - <menu name = "Test" type="group"> - <menu name="Scheduler Tester" pid= "org.cishell.tests.ProgressTrackableAlgorithm.AlgorithmTest"/> - </menu> <menu type="break"/> <menu name="Exit" type="preserved"/> </top_menu> - <top_menu name="Preprocessing"> - <menu name="Random Node Deletion" pid="edu.iu.iv.errortolerance.ErrorToleranceAlgorithm"/> - <menu name="High Degree Node Deletion" pid="edu.iu.iv.attacktolerance.AttackToleranceAlgorithm"/> - <menu name="Pathfinder Network Scaling" pid="edu.iu.nwb.analysis.pathfindergraphnetworkscaling.PathfinderGraphAlgorithm"/> - <menu name="Multipartite Joining" pid="edu.iu.nwb.analysis.multipartitejoining.JoiningAlgorithm"/> - <menu type="break"/> - <menu name="Snowball Sampling (n nodes)" pid="edu.iu.nwb.analysis.sampling.snowball.SnowballAlgorithm"/> - <menu name="Node Sampling" pid="edu.iu.nwb.analysis.sampling.node.NodeAlgorithm"/> - <menu name="Edge Sampling" pid="edu.iu.nwb.analysis.sampling.edge.EdgeAlgorithm"/> - </top_menu> - <top_menu name="Modeling"> - <menu name="Random Graph" pid="edu.iu.nwb.modeling.erdosrandomgraph"/> - <menu name="Watts-Strogatz Small World" pid="edu.iu.nwb.modeling.smallworld"/> - <menu name="Barabási-Albert Scale-Free" pid="edu.iu.nwb.modeling.barabasialbert"/> - <menu type="break"/> - <menu name="Can" pid="edu.iu.iv.modeling.p2p.can.CanAlgorithm"/> - <menu name="Chord" pid="edu.iu.iv.modeling.p2p.chord.ChordAlgorithm"/> - <menu name="Hypergrid" pid="edu.id.iv.modeling.p2p.hypergrid.Hypergrid"/> - <menu name="PRU" pid="edu.iu.iv.modeling.p2p.pru.PruAlgorithm"/> - <menu type="break"/> - <menu name="TARL" pid="edu.iu.iv.modeling.tarl.TarlAlgorithm"/> - </top_menu> - <top_menu name="Analysis"> - <menu name = "Unweighted && Undirected" type="group"> - <menu name="Node Degree" pid="edu.iu.nwb.analysis.totaldegreesequence"/> - <menu name="Degree Distribution" pid="edu.iu.nwb.analysis.totaldegreedistribution"/> - <menu type="break"/> - <menu name="k-Nearest Neighbor" pid="edu.iu.nwb.analysis.undirectedknn"/> - <menu name="Watts Strogatz Clustering Coefficient" pid="edu.iu.nwb.analysis.clustering"/> - <menu name="Watts Strogatz Clustering Coefficient Over k" pid="edu.iu.nwb.analysis.clustering_vs_k"/> - <menu type="break"/> - <menu name="Diameter" pid="edu.iu.nwb.analysis.diameter"/> - <menu name="Average Shortest Path" pid="edu.iu.nwb.analysis.averageshortestpath"/> - <menu name="Shortest Path Distribution" pid="edu.iu.nwb.analysis.shortestpathdistr"/> - <menu name="Node Betweenness Centrality" pid="edu.iu.nwb.analysis.sitebetweenness"/> - <menu type="break"/> - <menu name="Connected Components" pid="edu.iu.nwb.analysis.connectedcomponents"/> - <menu name="Weak Component Clustering" pid="edu.iu.nwb.analysis.weakcomponentclustering.ClusteringAlgorithm"/> - </menu> - - <menu name = "Unweighted && Directed" type="group"> - <menu name="Node Indegree" pid="edu.iu.nwb.analysis.indegreesequence"/> - <menu name="Node Outdegree" pid="edu.iu.nwb.analysis.outdegreesequence"/> - <menu name="Indegree Distribution" pid="edu.iu.nwb.analysis.indegreedistribution"/> - <menu name="Outdegree Distribution" pid="edu.iu.nwb.analysis.outdegreedistribution"/> - <menu type="break"/> - <menu name="k-Nearest Neighbor" pid="edu.iu.nwb.analysis.directedknn"/> - <menu name="Single Node In-Out Degree Correlations" pid="edu.iu.nwb.analysis.onepointcorrelations"/> - <menu type="break"/> - <menu name="Page Rank" pid="edu.iu.nwb.analysis.pagerank"/> - </menu> - - <menu name = "Weighted and Undirected" type="group"> - </menu> - <menu name = "Weighted and Directed" type="group"> - </menu> - </top_menu> - - <top_menu name="Search"> - <menu name="Can" pid="edu.iu.iv.search.p2p.can.CanSearchAlgorithm"/> - <menu name="Chord" pid="edu.iu.iv.search.p2p.chord.ChordSearchAlgorithm"/> - <menu name="k Random-Walk" pid="edu.iu.iv.search.p2p.randomwalk.RandomWalkAlgorithm"/> - <menu name="Random Breadth First" pid="edu.iu.iv.search.p2p.bfs.BreadthFirstSearchAlgorithm"/> - </top_menu> - - <top_menu name="Clustering"> - <menu name="Weak Component Clustering" pid="edu.iu.nwb.analysis.weakcomponentclustering.ClusteringAlgorithm"/> - </top_menu> - - <top_menu name="Visualization"> - <menu name="Circular" pid="edu.iu.nwb.visualization.jungnetworklayout.JUNGCircleLayout"/> - <menu name="Specified" pid="edu.iu.nwb.visualization.prefuse.beta.specified.Specified"/> - <menu type="break"/> - <menu name="Radial Tree/Graph" pid="edu.iu.nwb.visualization.radialgraph.RadialGraph"/> - <menu name="Radial Tree/Graph with Annotation" pid="edu.iu.nwb.visualization.prefuse.beta.radialgraph.RadialGraph"/> - <menu name="Tree Map" pid="edu.iu.nwb.visualization.prefuse.beta.treemap.TreeMap"/> - <menu name="Tree View" pid="edu.iu.nwb.visualization.prefuse.beta.treeview.TreeView"/> - <menu type="break"/> - <menu name="Force Directed" pid="edu.iu.nwb.visualization.prefuse.beta.graphview.GraphView"/> - <menu name="Kamada-Kawai" pid="edu.iu.nwb.visualization.jungnetworklayout.JUNGKamadaKawaiLayout"/> - <menu name="Fruchterman-Reingold" pid="edu.iu.nwb.visualization.jungnetworklayout.JUNGFruchtermanReingoldLayout"/> - <menu name="Fruchterman-Reingold with Annotation" pid="edu.iu.nwb.visualization.prefuse.beta.fruchtermanreingold.FruchtermanReingold"/> - <menu name="Spring" pid="edu.iu.nwb.visualization.jungnetworklayout.JUNGSpringLayout"/> - <menu name="Small World" pid="edu.iu.nwb.visualization.prefuse.alpha.smallworld.app.SmallWorld"/> - <menu type="break"/> - <menu name="Parallel Coordinates (demo)" pid="org.mediavirus.parvis.ParallelCoordinatesAlgorithm"/> - </top_menu> - <top_menu name="Tools"> - <menu name="GnuPlot" pid="edu.iu.nwb.visualization.gnuplot"/> <menu name="Scheduler" pid=""/> </top_menu> <top_menu name="Help"> - <menu name="Dataset Details" pid=""/> - <menu name="Algorithm Details" pid=""/> - <menu name="Tutorials" pid=""/> - <menu type="break"/> <menu name="Update" pid=""/> <menu name="Manage Configuration" pid=""/> - <menu type="break"/> - <menu name="About Network Workbench Tool" pid=""/> </top_menu> </menu_layout> Added: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/database.jpg =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/database.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/matrix.png =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/matrix.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/plot.png =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/plot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/raster_image.jpg =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/raster_image.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/vector_image.jpg =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/icons/vector_image.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/build.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/build.properties 2009-03-06 23:41:41 UTC (rev 865) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/build.properties 2009-04-24 22:00:50 UTC (rev 866) @@ -1,4 +1,6 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - . \ No newline at end of file + .,\ + unknown.png + Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2009-03-06 23:41:41 UTC (rev 865) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2009-04-24 22:00:50 UTC (rev 866) @@ -15,6 +15,7 @@ import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -62,16 +63,16 @@ children = new ArrayList(); this.brandPluginID = brandPluginID; - matrixIcon = createImage("matrix.png", this.brandPluginID); - treeIcon = createImage("tree.png", this.brandPluginID); - networkIcon = createImage("network.png", this.brandPluginID); - unknownIcon = createImage("unknown.png", this.brandPluginID); - textIcon = createImage("text.png", this.brandPluginID); - plotIcon = createImage("plot.png", this.brandPluginID); - tableIcon = createImage("table.png", this.brandPluginID); - databaseIcon = createImage("database.jpg", this.brandPluginID); - rasterImageIcon = createImage("raster_image.jpg", this.brandPluginID); - vectorImageIcon = createImage("vector_image.jpg", this.brandPluginID); + matrixIcon = getImage("matrix.png", this.brandPluginID); + treeIcon = getImage("tree.png", this.brandPluginID); + networkIcon = getImage("network.png", this.brandPluginID); + unknownIcon = getImage("unknown.png", this.brandPluginID); + textIcon = getImage("text.png", this.brandPluginID); + plotIcon = getImage("plot.png", this.brandPluginID); + tableIcon = getImage("table.png", this.brandPluginID); + databaseIcon = getImage("database.jpg", this.brandPluginID); + rasterImageIcon = getImage("raster_image.jpg", this.brandPluginID); + vectorImageIcon = getImage("vector_image.jpg", this.brandPluginID); typeToImageMapping = new HashMap(); registerImage(DataProperty.OTHER_TYPE, unknownIcon); @@ -157,15 +158,43 @@ typeToImageMapping.put(type, image); } - public static Image createImage(String name, String brandPluginID){ - if(Platform.isRunning()){ - return AbstractUIPlugin. - imageDescriptorFromPlugin(brandPluginID, - File.separator + "icons" + File.separator + name). - createImage(); + + + public static Image getImage(String name, String brandPluginID){ + if(Platform.isRunning()) { + String imageLocation = File.separator + "icons" + File.separator + name; + ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin( + brandPluginID, + imageLocation); + if (imageDescriptor != null) { + return imageDescriptor.createImage(); + } else { + System.err.println("Could not find the icon " + + "'" + imageLocation + "'" + + "in" + + "'" + brandPluginID + "'." + + "Using the default image instead."); + return getDefaultImage(); + } + } else { - return null; + System.err.println("Could not obtain the image " + + "'" + name + "'" + + "in" + + "'" + brandPluginID + "'" + + ", since the platform was not running (?)." + + "Using the default image instead."); + return getDefaultImage(); } } + + private static final String DEFAULT_IMAGE_LOCATION = File.separator + "unknown.png"; + + private static Image getDefaultImage() { + String thisPluginID = "org.cishell.reference.gui.datamanager"; //TODO: don't hardcode this + ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin( + thisPluginID, DEFAULT_IMAGE_LOCATION); + return imageDescriptor.createImage(); + } } Added: trunk/clients/gui/org.cishell.reference.gui.datamanager/unknown.png =================================================================== (Binary files differ) Property changes on: trunk/clients/gui/org.cishell.reference.gui.datamanager/unknown.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tan...@us...> - 2009-03-06 23:42:10
|
Revision: 865 http://cishell.svn.sourceforge.net/cishell/?rev=865&view=rev Author: tankchintan Date: 2009-03-06 23:41:41 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Refactored the code for File > Load mechanism suitably. Made changes in all the input file validators to include detailed comments. Added ambiguous_extension field to all the validators that have ambgiuous_extension. for e.g. a CSV file can be a plain csv, NSF or SCOPUS. modified the codebase to handle the use cases generated by these. Code Reviewed By Micah Modified Paths: -------------- 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/SelectedFileServiceSelector.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 2009-03-04 15:54:38 UTC (rev 864) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2009-03-06 23:41:41 UTC (rev 865) @@ -17,6 +17,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; @@ -32,13 +33,17 @@ private CIShellContext ciShellContext; private static String defaultLoadDirectory; + private final static String FILTER_EXTENSION_ALL = "*"; + private final static String FILTER_AMBIGUOUS = "&(type=validator)(format_name=*)(in_data=file-ext:*)"; + private final static String FILTER_IN_DATA = "&(type=validator)(format_name=*)"; + public FileLoad(CIShellContext ciContext, BundleContext bContext, Dictionary prefProperties) { this.ciShellContext = ciContext; this.bundleContext = bContext; logger = (LogService) ciContext.getService(LogService.class.getName()); guiBuilder = (GUIBuilderService) ciContext - .getService(GUIBuilderService.class.getName()); + .getService(GUIBuilderService.class.getName()); // unpack preference properties if (defaultLoadDirectory == null) { @@ -90,32 +95,25 @@ // + "sampledata" +File.separator + "anything"); // } // } - System.err.println("defaultLoadDirectory is " - + defaultLoadDirectory); File currentDir = new File(defaultLoadDirectory); // ? good way to - // do this? + // 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()) { - System.out.println("directory"); defaultLoadDirectory = file.getAbsolutePath(); } else { // File parentFile = file.getParentFile(); // if (parentFile != null) { - System.out.println("file"); defaultLoadDirectory = file.getParentFile().getAbsolutePath(); // } } @@ -123,44 +121,71 @@ String fileExtension = getFileExtension(file).toLowerCase(); /* - * This filter is used to filter out all the services which are not, + * This filter is used to filter out all the services which are NOT, * 1. validators 2. validators but for output file functionality * Hence only input file functionality validators are allowed. */ - String preLoadValidatorFilter = "(&(type=validator)(in_data=file-ext:" - + fileExtension + "))"; try { // get all the service references of validators that can load // this type of file. - ServiceReference[] serviceReferences = bundleContext - .getAllServiceReferences(AlgorithmFactory.class - .getName(), preLoadValidatorFilter); + ServiceReference[] selectedFileServiceReferences = null; + + if(fileExtension != null && fileExtension.length() > 0) { + selectedFileServiceReferences = getApplicableServiceReferences( + FILTER_IN_DATA, fileExtension); + } + /* * This use case is for input files selected that are, 1. * without any file extensions 2. with file extensions that do * not match any service "in_data" field. */ - if (serviceReferences == null || serviceReferences.length == 0) { + if ((selectedFileServiceReferences == null || selectedFileServiceReferences.length == 0)) { /* * This filter is used to accept only those services which * are, 1. type = validators and, 2. which have non-empty * format_name and, 3. which have non-empty in_data field. - * this is used so that all the validators for output file - * functionality are filtered out. + * or, 3. which have empty in_data field and non-empty + * ambiguous_extension field. This is used so that all the + * validators for output file functionality are filtered + * out. */ - String validatorFilter = "(&(type=validator)(format_name=*)(in_data=file-ext:*))"; + ServiceReference[] potentialValidators = null; - ServiceReference[] allValidators = bundleContext - .getAllServiceReferences(AlgorithmFactory.class - .getName(), validatorFilter); + /* + * This is used to find validators that support ambiguous + * extensions for the provided file extension. There are + * good chances that the file selected does not have any + * file extension, this is handled by below case. + */ + if (fileExtension != null && fileExtension.length() > 0) { + + potentialValidators = getApplicableServiceReferences( + FILTER_AMBIGUOUS, fileExtension); + + } + /* + * If no services are found then provide for all the + * validators list. + */ + + if (potentialValidators == null + || potentialValidators.length == 0) { + + potentialValidators = getApplicableServiceReferences( + FILTER_IN_DATA, FILTER_EXTENSION_ALL); + + } + + /* * SelectedFileServiceSelector is used to create a GUI for * selecting a service for the selected file from a list of * applicable services. On selection of a service it calls @@ -176,79 +201,93 @@ new SelectedFileServiceSelector("Load", file, window .getShell(), ciShellContext, bundleContext, - allValidators, selectedServicesForLoadedFileList) - .open(); + potentialValidators, + selectedServicesForLoadedFileList).open(); } /* * This use case is for input files selected that have only one - * applicable service. In this case the system goes ahead and - * loads the file with that service. + * applicable service. Special case where the file extension + * belongs to ambiguous file extension group like csv is also + * handled. In the simple case system goes ahead and loads the + * file with that service. */ - else if (serviceReferences.length == 1) { - AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext - .getService(serviceReferences[0]); - Data[] outputDataAfterValidation; - Data[] inputDataForValidation = new Data[] { new BasicData( - file.getPath(), String.class.getName()) }; - outputDataAfterValidation = selectedValidatorExecutor - .createAlgorithm(inputDataForValidation, null, - ciShellContext).execute(); + else if (selectedFileServiceReferences.length == 1) { /* - * outputDataAfterValidation = null implies that file was - * not loaded properly. + * To check for the files with ambiguous file extension a + * seperate list of service references is created. */ - if (outputDataAfterValidation != null) { - loadFileSuccess = true; - logger.log(LogService.LOG_INFO, "Loaded: " - + file.getPath()); - for (int i = 0; i < outputDataAfterValidation.length; i++) - selectedServicesForLoadedFileList - .add(outputDataAfterValidation[i]); + ServiceReference[] selectedFileAmbiguousValidators = getApplicableServiceReferences( + FILTER_AMBIGUOUS, fileExtension); + + /* + * If allAmbiguousValidators is not empty then the system + * provides a dialog box to select from the available + * validators. In this case CSV, NSF & SCOPUS + */ + + if ((selectedFileAmbiguousValidators != null && selectedFileAmbiguousValidators.length > 0)) { + new SelectedFileServiceSelector("Load", file, window + .getShell(), ciShellContext, bundleContext, + selectedFileAmbiguousValidators, + selectedServicesForLoadedFileList).open(); } - } + /* + * If allAmbiguousValidators is not empty we go forward with + * normal work flow of loading the file with selected file + * format. + */ - /* - * This use case is for input files selected that have more than - * one applicable services. For e.g. ".xml" can be xgmml, - * graphml, treeml. TODO: Right now this is handled by going - * over all the selected services and loading the file with a - * service that did not fail the validation test. For e.g. for a - * ".xml" file which is treeml it will try out first graphml - * then treeml. This will throw error on graphml which can be - * resolved. A better approach will be to display - * SelectedFileServiceSelector with graphml, treeml & xgmml - * options. - */ + else { - else if (serviceReferences.length > 1) { - for (int index = 0; index < serviceReferences.length; index++) { + AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext + .getService(selectedFileServiceReferences[0]); Data[] outputDataAfterValidation; - AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext - .getService(serviceReferences[index]); Data[] inputDataForValidation = new Data[] { new BasicData( file.getPath(), String.class.getName()) }; outputDataAfterValidation = selectedValidatorExecutor - .createAlgorithm(inputDataForValidation, null, - ciShellContext).execute(); + .createAlgorithm(inputDataForValidation, null, + ciShellContext).execute(); + + /* + * outputDataAfterValidation = null implies that file + * was not loaded properly. + */ + if (outputDataAfterValidation != null) { loadFileSuccess = true; logger.log(LogService.LOG_INFO, "Loaded: " + file.getPath()); - for (int i = 0; i < outputDataAfterValidation.length; i++) { + for (int i = 0; i < outputDataAfterValidation.length; i++) selectedServicesForLoadedFileList - .add(outputDataAfterValidation[i]); - } - break; + .add(outputDataAfterValidation[i]); } } } + /* + * This use case is for input files selected that have more than + * one applicable services. For e.g. ".xml" can be xgmml, + * graphml, treeml. This now triggers the + * SelectedFileServiceSelector dialog & can be used to select + * any one of the available services for that particular file + * extension. + */ + + else if (selectedFileServiceReferences.length > 1) { + + new SelectedFileServiceSelector("Load", file, window + .getShell(), ciShellContext, bundleContext, + selectedFileServiceReferences, + selectedServicesForLoadedFileList).open(); + + } + /* * Bonnie: I commented out the following functions since when * the application failed to load an nwb file, etc, the reader * has report the error. It does not need this second error @@ -278,6 +317,49 @@ }// end run() + /** + * @param selectedFileServiceReferencesFilter + * @param fileExtensionManipulations + * @return + * @throws InvalidSyntaxException + */ + private ServiceReference[] getApplicableServiceReferences( + String selectedFileServiceReferencesFilter, + String fileExtensionManipulations) + throws InvalidSyntaxException { + + String appliedValidatorFilter = getValidatorFilter( + selectedFileServiceReferencesFilter, + fileExtensionManipulations); + + ServiceReference[] selectedFileServiceReferences = bundleContext + .getAllServiceReferences(AlgorithmFactory.class.getName(), + appliedValidatorFilter); + + return selectedFileServiceReferences; + + } + + private String getValidatorFilter( + String selectedFileServiceReferencesFilter, + String fileExtensionManipulations) { + + if (selectedFileServiceReferencesFilter.equals(FILTER_IN_DATA)) { + return "(" + selectedFileServiceReferencesFilter + + "(in_data=file-ext:" + fileExtensionManipulations + + ")" + + ")"; + + } else if (selectedFileServiceReferencesFilter.equals(FILTER_AMBIGUOUS)) { + return "(" + selectedFileServiceReferencesFilter + + "(ambiguous_extension=" + fileExtensionManipulations + + ")" + + ")"; + } + + return null; + } + public String getFileExtension(File theFile) { String fileName = theFile.getName(); String extension; @@ -290,9 +372,9 @@ } // end class private IWorkbenchWindow getFirstWorkbenchWindow() - throws AlgorithmExecutionException { + throws AlgorithmExecutionException { final IWorkbenchWindow[] windows = PlatformUI.getWorkbench() - .getWorkbenchWindows(); + .getWorkbenchWindows(); if (windows.length == 0) { throw new AlgorithmExecutionException( "Cannot obtain workbench window needed to open dialog."); @@ -302,7 +384,7 @@ } private Data[] extractLoadedFileData(FileLoadRunnable dataUpdater) - throws AlgorithmExecutionException { + throws AlgorithmExecutionException { Data[] loadedFileData; try { if (!dataUpdater.selectedServicesForLoadedFileList.isEmpty()) { @@ -310,12 +392,12 @@ loadedFileData = new Data[size]; for (int index = 0; index < size; index++) { loadedFileData[index] = (Data) dataUpdater.selectedServicesForLoadedFileList - .get(index); + .get(index); } return loadedFileData; } else { this.logger - .log(LogService.LOG_WARNING, "File loading canceled"); + .log(LogService.LOG_WARNING, "File loading canceled"); return new Data[0]; } } catch (Throwable e2) { Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java 2009-03-04 15:54:38 UTC (rev 864) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java 2009-03-06 23:41:41 UTC (rev 865) @@ -46,13 +46,20 @@ private BundleContext bundleContext; private ArrayList returnList; - private static final String[] details_prop_names = - {"format_name", "supported_file_extension", "format_description", - "restorable_model_name", "restorable_model_description" }; - private static final String[] details_prop_name_descriptions = - {"Format name", "Supported file extension", "Format description", - "Restorable model name", "Restorable model description" }; + private static final String[] DETAILS_ITEM_KEY = + {"format_name", "supported_file_extension", "format_description" }; + /* + * Other possible keys could be restorable_model_name, restorable_model_description + * */ + + private static final String[] DETAILS_ITEM_KEY_DISPLAY_VALUE = + {"Format name", "Supported file extension", "Format description"}; + + /* + * Other possible keys display values could be "Restorable model name", "Restorable model description" + * */ + public SelectedFileServiceSelector(String title, File theFile, Shell parent, CIShellContext ciContext, BundleContext bContext, ServiceReference[] persisterArray, ArrayList returnList){ @@ -142,13 +149,13 @@ private void updateDetailPane(ServiceReference persister) { detailPane.setText(""); - for (int i=0; i<details_prop_names.length; i++){ - String val = (String) persister.getProperty(details_prop_names[i]); + for (int i=0; i<DETAILS_ITEM_KEY.length; i++){ + String val = (String) persister.getProperty(DETAILS_ITEM_KEY[i]); StyleRange styleRange = new StyleRange(); styleRange.start = detailPane.getText().length(); - detailPane.append(details_prop_name_descriptions[i] + ":\n"); - styleRange.length = details_prop_names[i].length() + 1; + detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[i] + ":\n"); + styleRange.length = DETAILS_ITEM_KEY[i].length() + 1; styleRange.fontStyle = SWT.BOLD; detailPane.setStyleRange(styleRange); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tan...@us...> - 2009-03-04 15:54:49
|
Revision: 864 http://cishell.svn.sourceforge.net/cishell/?rev=864&view=rev Author: tankchintan Date: 2009-03-04 15:54:38 +0000 (Wed, 04 Mar 2009) Log Message: ----------- Refactored the code for File > Load mechanism suitably.Made changes in all the input file validators to include detailed comments. Fixed the non-validation issue for the ISI file format.on trying to load a file without any extension does not give an error but displays another dialog box for selecting the File Loader e.g. Bibtex, Pajek, ISI etc. Validation is performed on selected file loader throwing either ERROR or loading the file with that loader. Code Reviewed By Micah Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/LoadDataChooser.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 2009-02-20 18:58:20 UTC (rev 863) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2009-03-04 15:54:38 UTC (rev 864) @@ -24,220 +24,302 @@ * @author Weixia(Bonnie) Huang (hu...@in...) */ 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, 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 Data[] execute() throws AlgorithmExecutionException { - //prepare to run load dialog in GUI thread - - IWorkbenchWindow window = getFirstWorkbenchWindow(); - Display display = PlatformUI.getWorkbench().getDisplay(); - FileLoadRunnable fileLoader = new FileLoadRunnable (window); - - //run load dialog in gui thread. + private final LogService logger; + private final GUIBuilderService guiBuilder; - if (Thread.currentThread() != display.getThread()) { - display.syncExec(fileLoader); + private BundleContext bundleContext; + private CIShellContext ciShellContext; + private static String defaultLoadDirectory; + + public FileLoad(CIShellContext ciContext, BundleContext bContext, + Dictionary prefProperties) { + this.ciShellContext = ciContext; + this.bundleContext = bContext; + logger = (LogService) ciContext.getService(LogService.class.getName()); + guiBuilder = (GUIBuilderService) ciContext + .getService(GUIBuilderService.class.getName()); + + // unpack preference properties + if (defaultLoadDirectory == null) { + defaultLoadDirectory = (String) prefProperties.get("loadDir"); + } + } + + public Data[] execute() throws AlgorithmExecutionException { + // prepare to run load dialog in GUI thread + + IWorkbenchWindow window = getFirstWorkbenchWindow(); + Display display = PlatformUI.getWorkbench().getDisplay(); + FileLoadRunnable fileLoader = new FileLoadRunnable(window); + + // run load dialog in gui thread. + + if (Thread.currentThread() != display.getThread()) { + display.syncExec(fileLoader); } else { fileLoader.run(); } - - //return loaded file data - - Data[] loadedFileData = extractLoadedFileData(fileLoader); - return loadedFileData; - } - - final class FileLoadRunnable implements Runnable{ - boolean loadFileSuccess = false; - IWorkbenchWindow window; - //this is how we return values from the runnable - public ArrayList returnList = new ArrayList(); - - 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"); -// } -// } - 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()) { - 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+"))"; - try { - // set the properties for the resource descriptor. - // note that this relies on the fact that the compression is set - // to nocompression by default. + // return loaded file data - // get all the service references of converters that can load this type of file. - ServiceReference[] serviceRefList = bContext.getAllServiceReferences( - AlgorithmFactory.class.getName(), filter); - + Data[] loadedFileData = extractLoadedFileData(fileLoader); + return loadedFileData; + } - // no converters found means the file format is not supported - if (serviceRefList == null || serviceRefList.length == 0){ - guiBuilder.showError("Unsupported File Format", "Sorry, the file format: *."+fileExtension+" is not yet supported.", - "Sorry, the file format: *."+fileExtension+" is not yet supported. \n"+ - "Please send your requests to cis...@li.... \n" - +"Thank you."); - } - - //<filename>[.<data model type>][.<index>] - // only one persister found, so load the model - else if (serviceRefList.length == 1){ - AlgorithmFactory persister = (AlgorithmFactory)bContext.getService(serviceRefList[0]); - Data[] dm = new Data[]{new BasicData(file.getPath(), String.class.getName()) }; - dm = persister.createAlgorithm(dm, null, ciContext).execute(); - if (dm != null){ - loadFileSuccess = true; - logger.log(LogService.LOG_INFO, "Loaded: "+file.getPath()); - for (int i=0; i<dm.length; i++) - returnList.add(dm[i]); - } - - - } - - // lots of persisters found, return the chooser - else if (serviceRefList.length > 1){ -// new LoadDataChooser("Load", file, window.getShell(), -// ciContext, bContext, serviceRefList, returnList).open(); - for (int index=0; index<serviceRefList.length; index++){ - AlgorithmFactory persister = (AlgorithmFactory)bContext.getService(serviceRefList[index]); - Data[] dm = new Data[]{new BasicData(file.getPath(), String.class.getName()) }; - dm = persister.createAlgorithm(dm, null, ciContext).execute(); - if (dm != null ){ - loadFileSuccess = true; - logger.log(LogService.LOG_INFO, "Loaded: "+file.getPath()); - for (int i=0; i<dm.length; i++){ - returnList.add(dm[i]); - } - break; - } - } + final class FileLoadRunnable implements Runnable { + boolean loadFileSuccess = false; + IWorkbenchWindow window; + // this is how we return values from the runnable + public ArrayList selectedServicesForLoadedFileList = new ArrayList(); - } - /* - * Bonnie: I commented out the following functions since when - * the application failed to load an nwb file, etc, the reader - * has report the error. It does not need this second error display. - * But maybe not all file readers will generate the error display if - * a failure occurs... - */ -/* if (serviceRefList != null){ - if(serviceRefList.length >0 && !loadFileSuccess){ - guiBuilder.showError("Can Not Load The File", - "Sorry, it's very possible that you have a wrong file format," + - "since the file can not be loaded to the application.", - - "Please check Data Formats that this application can support at "+ - "https://nwb.slis.indiana.edu/community/?n=Algorithms.HomePage." + - "And send your requests or report the problem to "+ - "cis...@li.... \n"+"Thank you."); - } + 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"); + // } + // } + 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()) { + System.out.println("directory"); + defaultLoadDirectory = file.getAbsolutePath(); + } else { - }catch (Exception e){ - throw new RuntimeException(e); - } + // File parentFile = file.getParentFile(); + // if (parentFile != null) { + System.out.println("file"); + defaultLoadDirectory = file.getParentFile().getAbsolutePath(); + // } + } - }//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); - } - } + String fileExtension = getFileExtension(file).toLowerCase(); + + /* + * This filter is used to filter out all the services which are not, + * 1. validators 2. validators but for output file functionality + * Hence only input file functionality validators are allowed. + */ + + String preLoadValidatorFilter = "(&(type=validator)(in_data=file-ext:" + + fileExtension + "))"; + try { + + // get all the service references of validators that can load + // this type of file. + ServiceReference[] serviceReferences = bundleContext + .getAllServiceReferences(AlgorithmFactory.class + .getName(), preLoadValidatorFilter); + + /* + * This use case is for input files selected that are, 1. + * without any file extensions 2. with file extensions that do + * not match any service "in_data" field. + */ + + if (serviceReferences == null || serviceReferences.length == 0) { + + /* + * This filter is used to accept only those services which + * are, 1. type = validators and, 2. which have non-empty + * format_name and, 3. which have non-empty in_data field. + * this is used so that all the validators for output file + * functionality are filtered out. + */ + + String validatorFilter = "(&(type=validator)(format_name=*)(in_data=file-ext:*))"; + + ServiceReference[] allValidators = bundleContext + .getAllServiceReferences(AlgorithmFactory.class + .getName(), validatorFilter); + + /* + * SelectedFileServiceSelector is used to create a GUI for + * selecting a service for the selected file from a list of + * applicable services. On selection of a service it calls + * the validator for that service. If the validator passes + * it it goes ahead and loads the file appropriately else it + * throws error message asking the user to select other + * service. + * + * This modifies the selectedServicesForLoadedFileList, + * which is the placeholder for all the verified/ applicable + * services for a selected/loaded file. + */ + + new SelectedFileServiceSelector("Load", file, window + .getShell(), ciShellContext, bundleContext, + allValidators, selectedServicesForLoadedFileList) + .open(); + } + + /* + * This use case is for input files selected that have only one + * applicable service. In this case the system goes ahead and + * loads the file with that service. + */ + + else if (serviceReferences.length == 1) { + AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext + .getService(serviceReferences[0]); + Data[] outputDataAfterValidation; + Data[] inputDataForValidation = new Data[] { new BasicData( + file.getPath(), String.class.getName()) }; + outputDataAfterValidation = selectedValidatorExecutor + .createAlgorithm(inputDataForValidation, null, + ciShellContext).execute(); + + /* + * outputDataAfterValidation = null implies that file was + * not loaded properly. + */ + + if (outputDataAfterValidation != null) { + loadFileSuccess = true; + logger.log(LogService.LOG_INFO, "Loaded: " + + file.getPath()); + for (int i = 0; i < outputDataAfterValidation.length; i++) + selectedServicesForLoadedFileList + .add(outputDataAfterValidation[i]); + } + + } + + /* + * This use case is for input files selected that have more than + * one applicable services. For e.g. ".xml" can be xgmml, + * graphml, treeml. TODO: Right now this is handled by going + * over all the selected services and loading the file with a + * service that did not fail the validation test. For e.g. for a + * ".xml" file which is treeml it will try out first graphml + * then treeml. This will throw error on graphml which can be + * resolved. A better approach will be to display + * SelectedFileServiceSelector with graphml, treeml & xgmml + * options. + */ + + else if (serviceReferences.length > 1) { + for (int index = 0; index < serviceReferences.length; index++) { + Data[] outputDataAfterValidation; + AlgorithmFactory selectedValidatorExecutor = (AlgorithmFactory) bundleContext + .getService(serviceReferences[index]); + Data[] inputDataForValidation = new Data[] { new BasicData( + file.getPath(), String.class.getName()) }; + outputDataAfterValidation = selectedValidatorExecutor + .createAlgorithm(inputDataForValidation, null, + ciShellContext).execute(); + if (outputDataAfterValidation != null) { + loadFileSuccess = true; + logger.log(LogService.LOG_INFO, "Loaded: " + + file.getPath()); + for (int i = 0; i < outputDataAfterValidation.length; i++) { + selectedServicesForLoadedFileList + .add(outputDataAfterValidation[i]); + } + break; + } + } + + } + /* + * Bonnie: I commented out the following functions since when + * the application failed to load an nwb file, etc, the reader + * has report the error. It does not need this second error + * display. But maybe not all file readers will generate the + * error display if a failure occurs... + */ + /* + * if (serviceRefList != null){ if(serviceRefList.length >0 && + * !loadFileSuccess){ + * guiBuilder.showError("Can Not Load The File", + * "Sorry, it's very possible that you have a wrong file format," + * + "since the file can not be loaded to the application.", + * + * "Please check Data Formats that this application can support at " + * + + * "https://nwb.slis.indiana.edu/community/?n=Algorithms.HomePage." + * + "And send your requests or report the problem to "+ + * "cis...@li.... \n"+"Thank you."); + * } + * + * } + */ + + } catch (Exception e) { + throw new RuntimeException(e); + } + + }// 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.selectedServicesForLoadedFileList.isEmpty()) { + int size = dataUpdater.selectedServicesForLoadedFileList.size(); + loadedFileData = new Data[size]; + for (int index = 0; index < size; index++) { + loadedFileData[index] = (Data) dataUpdater.selectedServicesForLoadedFileList + .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 Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/LoadDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/LoadDataChooser.java 2009-02-20 18:58:20 UTC (rev 863) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/LoadDataChooser.java 2009-03-04 15:54:38 UTC (rev 864) @@ -1,208 +0,0 @@ -/* - * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research - * and Education in Information Visualization (http://iv.slis.indiana.edu/). - * - * Created on Jan 24, 2005 at Indiana University. - */ -package org.cishell.reference.gui.persistence.load; - -import java.io.File; -import java.util.ArrayList; - -import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.data.BasicData; -import org.cishell.framework.data.Data; -import org.cishell.reference.gui.common.AbstractDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; - -/** - * - * @author Team IVC (Weixia Huang, James Ellis) - */ -public class LoadDataChooser extends AbstractDialog { - private File theFile; - private LogService logger; - - private ServiceReference[] persisterArray; - private List persisterList; - private StyledText detailPane; - private CIShellContext ciContext; - private BundleContext bContext; - private ArrayList returnList; - - private static final String[] details_prop_names = - {"format_name", "supported_file_extension", "format_description", - "restorable_model_name", "restorable_model_description" }; - private static final String[] details_prop_name_descriptions = - {"Format name", "Supported file extension", "Format description", - "Restorable model name", "Restorable model description" }; - - public LoadDataChooser(String title, File theFile, - Shell parent, CIShellContext ciContext, BundleContext bContext, - ServiceReference[] persisterArray, ArrayList returnList){ - super(parent, title, AbstractDialog.QUESTION); - this.ciContext = ciContext; - this.bContext = bContext; - this.persisterArray = persisterArray; - this.returnList = returnList; - - this.theFile = theFile; - - this.logger = (LogService) ciContext.getService(LogService.class.getName()); -//shall this part be moved out of the code? - setDescription("The file you have selected can be loaded" - + " using the following formats.\n" - + "Please select one of them."); - setDetails("This dialog allows the user to choose among all available " + - "formats for loading the selected data model. Choose any of the formats " + - "to continue loading the dataset."); - } - - private Composite initGUI(Composite parent) { - Composite content = new Composite(parent, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - content.setLayout(layout); - - Group persisterGroup = new Group(content, SWT.NONE); -//shall this label be moved out of the code? - persisterGroup.setText("Loaded by"); - persisterGroup.setLayout(new FillLayout()); - GridData persisterListGridData = new GridData(GridData.FILL_BOTH); - persisterListGridData.widthHint = 200; - persisterGroup.setLayoutData(persisterListGridData); - - persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE); -// initPersisterArray(); - initPersisterList(); - persisterList.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - List list = (List)e.getSource(); - int selection = list.getSelectionIndex(); - if(selection != -1){ - updateDetailPane(persisterArray[selection]); - } - } - }); - - Group detailsGroup = new Group(content, SWT.NONE); -// shall this label be moved out of the code? - detailsGroup.setText("Details"); - detailsGroup.setLayout(new FillLayout()); - GridData detailsGridData = new GridData(GridData.FILL_BOTH); - detailsGridData.widthHint = 200; - detailsGroup.setLayoutData(detailsGridData); - - detailPane = initDetailPane(detailsGroup); - - persisterList.setSelection(0); - updateDetailPane(persisterArray[0]); - - return content; - } - - private void initPersisterList(){ - for (int i = 0; i < persisterArray.length; ++i) { - - String name = (String)persisterArray[i].getProperty("converter_name"); - - // if someone was sloppy enough to not provide a name, then use the - // name of the class instead. - if (name == null || name.length() == 0) - name = persisterArray[i].getClass().getName(); - persisterList.add(name); - } - } - - - private StyledText initDetailPane(Group detailsGroup) { - StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL); - detailPane.setEditable(false); - detailPane.getCaret().setVisible(false); - return detailPane; - } - - private void updateDetailPane(ServiceReference persister) { - - detailPane.setText(""); - for (int i=0; i<details_prop_names.length; i++){ - String val = (String) persister.getProperty(details_prop_names[i]); - - StyleRange styleRange = new StyleRange(); - styleRange.start = detailPane.getText().length(); - detailPane.append(details_prop_name_descriptions[i] + ":\n"); - styleRange.length = details_prop_names[i].length() + 1; - styleRange.fontStyle = SWT.BOLD; - detailPane.setStyleRange(styleRange); - - detailPane.append(val + "\n"); - - } - - } - - private void selectionMade(int selectedIndex) { - AlgorithmFactory persister =(AlgorithmFactory) bContext.getService(persisterArray[selectedIndex]); - Data[] dm = null; - try { - dm = new Data[]{new BasicData(theFile.getPath(),String.class.getName())}; - dm = persister.createAlgorithm(dm, null, ciContext).execute(); - } catch (Throwable e) { - this.logger.log(LogService.LOG_ERROR, "Error occurred while executing selection", e); - e.printStackTrace(); - } - - if (dm != null) { - logger.log(LogService.LOG_INFO, "Loaded: "+theFile.getPath()); - - for(int i = 0; i<dm.length; i++){ - returnList.add(dm[i]); - } - close(true); - } else { - logger.log(LogService.LOG_ERROR, "Unable to load with selected loader"); - } - } - - public void createDialogButtons(Composite parent) { - Button select = new Button(parent, SWT.PUSH); - select.setText("Select"); - select.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - int index = persisterList.getSelectionIndex(); - if(index != -1){ - selectionMade(index); - } - } - }); - - Button cancel = new Button(parent, SWT.NONE); - cancel.setText("Cancel"); - cancel.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - close(false); - } - }); - } - - public Composite createContent(Composite parent) { - return initGUI(parent); - } -} Copied: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java (from rev 863, trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/LoadDataChooser.java) =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java 2009-03-04 15:54:38 UTC (rev 864) @@ -0,0 +1,212 @@ +/* + * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research + * and Education in Information Visualization (http://iv.slis.indiana.edu/). + * + * Created on Jan 24, 2005 at Indiana University. + */ +package org.cishell.reference.gui.persistence.load; + +import java.io.File; +import java.util.ArrayList; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.reference.gui.common.AbstractDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; + +/** + * + * @author Team IVC (Weixia Huang, James Ellis) + */ +public class SelectedFileServiceSelector extends AbstractDialog { + private File selectedFile; + private LogService logger; + + private ServiceReference[] persisterArray; + private List persisterList; + private StyledText detailPane; + private CIShellContext ciShellContext; + private BundleContext bundleContext; + private ArrayList returnList; + + private static final String[] details_prop_names = + {"format_name", "supported_file_extension", "format_description", + "restorable_model_name", "restorable_model_description" }; + private static final String[] details_prop_name_descriptions = + {"Format name", "Supported file extension", "Format description", + "Restorable model name", "Restorable model description" }; + + public SelectedFileServiceSelector(String title, File theFile, + Shell parent, CIShellContext ciContext, BundleContext bContext, + ServiceReference[] persisterArray, ArrayList returnList){ + super(parent, title, AbstractDialog.QUESTION); + this.ciShellContext = ciContext; + this.bundleContext = bContext; + this.persisterArray = persisterArray; + this.returnList = returnList; + + this.selectedFile = theFile; + + this.logger = (LogService) ciContext.getService(LogService.class.getName()); + //shall this part be moved out of the code? + setDescription("The file you have selected can be loaded" + + " using the following formats.\n" + + "Please select one of them."); + setDetails("This dialog allows the user to choose among all available " + + "formats for loading the selected data model. Choose any of the formats " + + "to continue loading the dataset."); + } + + private Composite initGUI(Composite parent) { + Composite content = new Composite(parent, SWT.NONE); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + content.setLayout(layout); + + Group persisterGroup = new Group(content, SWT.NONE); + //shall this label be moved out of the code? + persisterGroup.setText("Loaded by"); + persisterGroup.setLayout(new FillLayout()); + GridData persisterListGridData = new GridData(GridData.FILL_BOTH); + persisterListGridData.widthHint = 200; + persisterGroup.setLayoutData(persisterListGridData); + + persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE); + // initPersisterArray(); + initPersisterList(); + persisterList.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + List list = (List)e.getSource(); + int selection = list.getSelectionIndex(); + if(selection != -1){ + updateDetailPane(persisterArray[selection]); + } + } + }); + + Group detailsGroup = new Group(content, SWT.NONE); + // shall this label be moved out of the code? + detailsGroup.setText("Details"); + detailsGroup.setLayout(new FillLayout()); + GridData detailsGridData = new GridData(GridData.FILL_BOTH); + detailsGridData.widthHint = 200; + detailsGroup.setLayoutData(detailsGridData); + + detailPane = initDetailPane(detailsGroup); + + persisterList.setSelection(0); + updateDetailPane(persisterArray[0]); + + return content; + } + + private void initPersisterList(){ + for (int i = 0; i < persisterArray.length; ++i) { + + String name = (String)persisterArray[i].getProperty("converter_name"); + + // if someone was sloppy enough to not provide a name, then use the + // name of the class instead. + if (name == null || name.length() == 0) + name = persisterArray[i].getClass().getName(); + persisterList.add(name); + } + } + + + private StyledText initDetailPane(Group detailsGroup) { + StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL); + detailPane.setEditable(false); + detailPane.getCaret().setVisible(false); + return detailPane; + } + + private void updateDetailPane(ServiceReference persister) { + + detailPane.setText(""); + for (int i=0; i<details_prop_names.length; i++){ + String val = (String) persister.getProperty(details_prop_names[i]); + + StyleRange styleRange = new StyleRange(); + styleRange.start = detailPane.getText().length(); + detailPane.append(details_prop_name_descriptions[i] + ":\n"); + styleRange.length = details_prop_names[i].length() + 1; + styleRange.fontStyle = SWT.BOLD; + detailPane.setStyleRange(styleRange); + + detailPane.append(val + "\n"); + + } + + } + + private void selectionMade(int selectedIndex) { + AlgorithmFactory persister =(AlgorithmFactory) bundleContext.getService(persisterArray[selectedIndex]); + Data[] dataManager = null; + boolean loadSuccess = false; + + try { + dataManager = new Data[]{new BasicData(selectedFile.getPath(),String.class.getName())}; + dataManager = persister.createAlgorithm(dataManager, null, ciShellContext).execute(); + loadSuccess = true; + } catch (Throwable e) { + this.logger.log(LogService.LOG_ERROR, "Error occurred while executing selection", e); + e.printStackTrace(); + loadSuccess = false; + } + + if (dataManager != null && loadSuccess) { + logger.log(LogService.LOG_INFO, "Loaded: "+selectedFile.getPath()); + + for(int i = 0; i<dataManager.length; i++){ + returnList.add(dataManager[i]); + } + close(true); + } else { + logger.log(LogService.LOG_ERROR, "Unable to load with selected loader"); + } + } + + public void createDialogButtons(Composite parent) { + Button select = new Button(parent, SWT.PUSH); + select.setText("Select"); + select.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + int index = persisterList.getSelectionIndex(); + if(index != -1){ + selectionMade(index); + } + } + }); + + Button cancel = new Button(parent, SWT.NONE); + cancel.setText("Cancel"); + cancel.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + close(false); + } + }); + } + + public Composite createContent(Composite parent) { + return initGUI(parent); + } +} Property changes on: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/SelectedFileServiceSelector.java ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tan...@us...> - 2009-02-20 18:58:30
|
Revision: 863 http://cishell.svn.sourceforge.net/cishell/?rev=863&view=rev Author: tankchintan Date: 2009-02-20 18:58:20 +0000 (Fri, 20 Feb 2009) Log Message: ----------- changed log file naming convention. Reviewed By : Micah, Russell Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogToFile.java Modified: trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogToFile.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogToFile.java 2009-02-20 18:25:45 UTC (rev 862) +++ trunk/clients/gui/org.cishell.reference.gui.log/src/org/cishell/reference/gui/log/LogToFile.java 2009-02-20 18:58:20 UTC (rev 863) @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.logging.FileHandler; import java.util.logging.Level; @@ -20,19 +21,18 @@ */ public class LogToFile implements LogListener { //default log directory - private static String default_log_dir = + private static final String DEFAULT_LOG_DIR = System.getProperty("user.dir") + File.separator + "logs"; - private static String prefix_file_name = "user"; + private static final String FILE_NAME_PREFIX = "user"; private File currentDir; private Logger logger; //Specify the default size of each log file - private int limit = 100000; // 100 kb + private static final int LIMIT = 100000; // 100 kb - //Specify the default numbers of log files - private int max_Number_Of_LogFiles = 10; + private static final int MAX_NUM_LOG_FILES = 10; /** * Constructor @@ -45,11 +45,11 @@ if (currentDir != null){ boolean append = true; String logFileName = currentDir+File.separator+ - generateUniqueFile(prefix_file_name)+ + generateUniqueFile(FILE_NAME_PREFIX)+ ".%g.log"; FileHandler handler = new FileHandler(logFileName, - limit, max_Number_Of_LogFiles, append); + LIMIT, MAX_NUM_LOG_FILES, append); handler.setFormatter(new SimpleFormatter()); @@ -109,17 +109,17 @@ private static File getLogDirectory(){ //later, we should get the log directory from preference service - File logDir = new File(default_log_dir); + File logDir = new File(DEFAULT_LOG_DIR); if (!logDir.exists() || !logDir.isDirectory()){ try{ if (logDir.mkdir()){ return logDir; } else { - return new File (default_log_dir); + return new File (DEFAULT_LOG_DIR); } }catch (Exception e){ e.printStackTrace(); - return new File (default_log_dir); + return new File (DEFAULT_LOG_DIR); } }else @@ -130,27 +130,22 @@ /* * create log file with given name plus unique timestamp */ - private String generateUniqueFile(String prefixFN) { - - Calendar now = Calendar.getInstance(); - String month = (now.get(Calendar.MONTH) + 1) + ""; //zero based - - if (month.length() == 1) { - month = "0" + month; - } - - String day = now.get(Calendar.DAY_OF_MONTH) + ""; - - if (day.length() == 1) { - day = "0" + day; - } - - String year = now.get(Calendar.YEAR) + ""; + private String generateUniqueFile(String fileNamePrefix) { - String timestamp = "-" + month + "-" + day + "-" + year + "-"+ - System.currentTimeMillis(); - return prefixFN+timestamp; +/* + * We can set any date time format we want. + * For the legend on different formats check http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html +*/ +/* TODO Make sure that 2 files with same filename are not generated. + * Current granularity is set at till milliseconds. +*/ + + String dateFormat = "MM-dd-yyyy-hh-mm-a-SSS"; + Calendar currentTemporalSnapshot = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + String timestamp = "-" + simpleDateFormat.format(currentTemporalSnapshot.getTime()); + return fileNamePrefix + timestamp; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-02-20 18:25:52
|
Revision: 862 http://cishell.svn.sourceforge.net/cishell/?rev=862&view=rev Author: pataphil Date: 2009-02-20 18:25:45 +0000 (Fri, 20 Feb 2009) Log Message: ----------- * Changed AlgorithmWrapper to "fail" upon the target algorithm's mutateParameters failing. * Cleaned up code a little bit. 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 2009-02-20 17:54:54 UTC (rev 861) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2009-02-20 18:25:45 UTC (rev 862) @@ -77,42 +77,74 @@ * @see org.cishell.framework.algorithm.Algorithm#execute() */ public Data[] execute() { - AlgorithmFactory factory = getAlgorithmFactory(bContext, ref); - if (factory == null) return null; - String pid = (String) ref.getProperty(Constants.SERVICE_PID); + try { + AlgorithmFactory factory = getAlgorithmFactory(bContext, ref); + + if (factory == null) + return null; + + String pid = (String)ref.getProperty(Constants.SERVICE_PID); - // convert input data to the correct format - boolean conversionSuccessful = tryConvertingDataToRequiredFormat(data, converters); - if (!conversionSuccessful) return null; - boolean inputIsValid = testDataValidityIfPossible(factory, data); - if (!inputIsValid) return null; + // Convert input data to the correct format. + boolean conversionSuccessful = + tryConvertingDataToRequiredFormat(data, converters); + + if (!conversionSuccessful) + return null; + + boolean inputIsValid = testDataValidityIfPossible(factory, data); + + if (!inputIsValid) + return null; - // create algorithm parameters - String metatype_pid = getMetaTypeID(ref); + // Create algorithm parameters. + String metatype_pid = getMetaTypeID(ref); - MetaTypeProvider provider = getPossiblyMutatedMetaTypeProvider(metatype_pid, pid, factory); - Dictionary parameters = getUserEnteredParameters(metatype_pid, provider); + MetaTypeProvider provider = + getPossiblyMutatedMetaTypeProvider(metatype_pid, pid, factory); + + Dictionary parameters = + getUserEnteredParameters(metatype_pid, provider); - // check to see if the user cancelled the operation - if (parameters == null) return null; + // Check to see if the user cancelled the operation. + if (parameters == null) + return null; - printParameters(metatype_pid, provider, parameters); + printParameters(metatype_pid, provider, parameters); - // create the algorithm - algorithm = createAlgorithm(factory, data, parameters, ciContext); - if (algorithm == null) return null; - trackAlgorithmIfPossible(algorithm); + // Create the algorithm. + algorithm = createAlgorithm(factory, data, parameters, ciContext); + + if (algorithm == null) + return null; + + trackAlgorithmIfPossible(algorithm); - // execute the algorithm - Data[] outData = tryExecutingAlgorithm(algorithm); - if (outData == null) return null; + // Execute the algorithm. + Data[] outData = tryExecutingAlgorithm(algorithm); + + if (outData == null) + return null; - // process and return the algorithm's output - doParentage(outData); - outData = removeNullData(outData); - addDataToDataManager(outData); + // Process and return the algorithm's output. + doParentage(outData); + outData = removeNullData(outData); + addDataToDataManager(outData); - return outData; + return outData; + } + catch (Exception e) { + GUIBuilderService builder = (GUIBuilderService)ciContext.getService + (GUIBuilderService.class.getName()); + + String errorMessage = "An error occurred while preparing to run the " + + "algorithm \"" + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; + + builder.showError("Error!", errorMessage, e); + log(LogService.LOG_ERROR, errorMessage, e); + } + + return null; } protected AlgorithmFactory getAlgorithmFactory(BundleContext bContext, ServiceReference ref) { @@ -259,12 +291,6 @@ } } catch (IllegalArgumentException e) { log(LogService.LOG_DEBUG, pid + " has an invalid metatype id: " + metatypePID, e); - } catch (Exception e) { - GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); - String errorMessage = "An error occurred while preparing to run the algorithm " - + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; - builder.showError("Error!", errorMessage, e); - log(LogService.LOG_ERROR, errorMessage, e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-02-20 17:54:58
|
Revision: 861 http://cishell.svn.sourceforge.net/cishell/?rev=861&view=rev Author: pataphil Date: 2009-02-20 17:54:54 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Now passes actual exceptions to logged exceptions. (This should've been committed long ago.) Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2009-02-19 16:44:58 UTC (rev 860) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2009-02-20 17:54:54 UTC (rev 861) @@ -237,7 +237,7 @@ tempFile = File.createTempFile("xxx-Session-", ".csv", tempDir); }catch (IOException e){ - logger.log(LogService.LOG_ERROR, e.toString()); + logger.log(LogService.LOG_ERROR, e.toString(), e); tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.csv"); } Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2009-02-19 16:44:58 UTC (rev 860) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2009-02-20 17:54:54 UTC (rev 861) @@ -61,7 +61,7 @@ tempFile = File.createTempFile("xxx-Session-", ".txt", tempDir); }catch (IOException e){ - logger.log(LogService.LOG_ERROR, e.toString()); + logger.log(LogService.LOG_ERROR, e.toString(), e); tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.txt"); } @@ -111,7 +111,7 @@ copy((File)newData.getData(), tempFile); lastSaveSuccessful = true; } catch (ConversionException e) { - this.logger.log(LogService.LOG_WARNING, "Error while converting to target save format. Will attempt to use other available converters."); + this.logger.log(LogService.LOG_WARNING, "Error while converting to target save format. Will attempt to use other available converters.", e); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-02-19 16:46:31
|
Revision: 860 http://cishell.svn.sourceforge.net/cishell/?rev=860&view=rev Author: mwlinnem Date: 2009-02-19 16:44:58 +0000 (Thu, 19 Feb 2009) Log Message: ----------- Minor cleanup. Modified Paths: -------------- 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/FileLoadFactory.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 2009-01-26 20:40:11 UTC (rev 859) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2009-02-19 16:44:58 UTC (rev 860) @@ -135,7 +135,6 @@ "Sorry, the file format: *."+fileExtension+" is not yet supported. \n"+ "Please send your requests to cis...@li.... \n" +"Thank you."); - } //<filename>[.<data model type>][.<index>] Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2009-01-26 20:40:11 UTC (rev 859) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2009-02-19 16:44:58 UTC (rev 860) @@ -1,6 +1,5 @@ package org.cishell.reference.gui.persistence.load; -//standard java import java.util.Dictionary; import java.util.Enumeration; import java.util.Hashtable; @@ -34,7 +33,7 @@ printPreferences(properties); } - private void printPreferences(Dictionary 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!"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-01-26 20:40:24
|
Revision: 859 http://cishell.svn.sourceforge.net/cishell/?rev=859&view=rev Author: mwlinnem Date: 2009-01-26 20:40:11 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Added new icons for database, vector image, and raster image. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2009-01-26 20:39:46 UTC (rev 858) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2009-01-26 20:40:11 UTC (rev 859) @@ -39,6 +39,9 @@ private Image textIcon; private Image plotIcon; private Image tableIcon; + private Image databaseIcon; + private Image rasterImageIcon; + private Image vectorImageIcon; private Map typeToImageMapping; @@ -59,13 +62,16 @@ children = new ArrayList(); this.brandPluginID = brandPluginID; - matrixIcon = createImage("matrix.png", this.brandPluginID); - treeIcon = createImage("tree.png", this.brandPluginID); - networkIcon = createImage("network.png", this.brandPluginID); - unknownIcon = createImage("unknown.png", this.brandPluginID); - textIcon = createImage("text.png", this.brandPluginID); - plotIcon = createImage("plot.png", this.brandPluginID); - tableIcon = createImage("table.png", this.brandPluginID); + matrixIcon = createImage("matrix.png", this.brandPluginID); + treeIcon = createImage("tree.png", this.brandPluginID); + networkIcon = createImage("network.png", this.brandPluginID); + unknownIcon = createImage("unknown.png", this.brandPluginID); + textIcon = createImage("text.png", this.brandPluginID); + plotIcon = createImage("plot.png", this.brandPluginID); + tableIcon = createImage("table.png", this.brandPluginID); + databaseIcon = createImage("database.jpg", this.brandPluginID); + rasterImageIcon = createImage("raster_image.jpg", this.brandPluginID); + vectorImageIcon = createImage("vector_image.jpg", this.brandPluginID); typeToImageMapping = new HashMap(); registerImage(DataProperty.OTHER_TYPE, unknownIcon); @@ -83,6 +89,9 @@ registerImage(DataProperty.TEXT_TYPE, textIcon); registerImage(DataProperty.PLOT_TYPE, plotIcon); registerImage(DataProperty.TABLE_TYPE, tableIcon); + registerImage(DataProperty.DATABASE_TYPE, databaseIcon); + registerImage(DataProperty.RASTER_IMAGE_TYPE, rasterImageIcon); + registerImage(DataProperty.VECTOR_IMAGE_TYPE, vectorImageIcon); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-01-26 20:39:48
|
Revision: 858 http://cishell.svn.sourceforge.net/cishell/?rev=858&view=rev Author: mwlinnem Date: 2009-01-26 20:39:46 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Added new icons for database, vector image, and raster image. Modified Paths: -------------- trunk/core/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java Modified: trunk/core/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java 2009-01-26 18:51:50 UTC (rev 857) +++ trunk/core/org.cishell.framework/src/org/cishell/framework/data/DataProperty.java 2009-01-26 20:39:46 UTC (rev 858) @@ -82,9 +82,12 @@ /** Says this data model is abstractly a data plot */ public static String PLOT_TYPE = "Plot"; + /** Says this data model is abstractly a database */ + public static String DATABASE_TYPE = "Database"; + /** Says this data model is a PostScript file */ - public static String POST_SCRIPT_TYPE = "PostScript"; + public static String VECTOR_IMAGE_TYPE = "Vector Image"; /** Says this data model is a JPEG object */ - public static String IMAGE_OBJECT_TYPE = "Image Object"; + public static String RASTER_IMAGE_TYPE = "Raster Image"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-01-26 18:51:55
|
Revision: 857 http://cishell.svn.sourceforge.net/cishell/?rev=857&view=rev Author: mwlinnem Date: 2009-01-26 18:51:50 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Made a few changes based on Patrick's review. Modified Paths: -------------- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java =================================================================== --- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-01-26 18:31:07 UTC (rev 856) +++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-01-26 18:51:50 UTC (rev 857) @@ -40,6 +40,7 @@ "org.apache.derby.jdbc.EmbeddedDriver"; private static final String DERBY_PROTOCOL = "jdbc:derby:"; private static final String DEFAULT_CREATE_CONNECTION_STRING = ";create=true"; + private static final String DEFAULT_SHUTDOWN_CONNECTION_STRING =";shutdown=true"; private static final String DEFAULT_DB_NAME = "cishell_database"; //where the database exists on the filesystem (relative to the application root directory) @@ -80,7 +81,9 @@ //try to clean out the database and shut it down. try { removeAllNonSystemDatabaseTables(); - DriverManager.getConnection("jdbc:derby:;shutdown=true"); + String shutdownDatabaseCommand = + DERBY_PROTOCOL + DEFAULT_SHUTDOWN_CONNECTION_STRING; + DriverManager.getConnection(shutdownDatabaseCommand); } catch (Exception e) { String message = "An unexpected exception occurred while shutting down the internal database." + @@ -122,6 +125,7 @@ removeTables.executeBatch(); } + //TODO: It could be that we should give everyone different datasources instead of the same one private PoolingDataSource getDataSource() throws DatabaseCreationException { @@ -129,7 +133,8 @@ return poolingDataSource; } - //lazy-load the pooling data source + //lazy-load the pooling data source (implicitly creates the initial database connection) + //TODO: Make it more clear where database connection is initially established private void initializePoolingDataSource() throws DatabaseCreationException { if (this.poolingDataSource != null) { return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-01-26 18:31:16
|
Revision: 856 http://cishell.svn.sourceforge.net/cishell/?rev=856&view=rev Author: mwlinnem Date: 2009-01-26 18:31:07 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Major code cleanup. Improved error handling. Modified Paths: -------------- trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF Added Paths: ----------- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java Removed Paths: ------------- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java Modified: trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF 2009-01-24 19:34:25 UTC (rev 855) +++ trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF 2009-01-26 18:31:07 UTC (rev 856) @@ -4,7 +4,7 @@ Bundle-SymbolicName: org.cishell.reference.service.database Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: J2SE-1.4 -Bundle-Activator: org.cishell.reference.service.database.DatabaseServiceImpl +Bundle-Activator: org.cishell.reference.service.database.DerbyDatabaseService X-AutoStart: true Import-Package: org.apache.commons.dbcp, org.apache.commons.pool, Deleted: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java =================================================================== --- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java 2009-01-24 19:34:25 UTC (rev 855) +++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java 2009-01-26 18:31:07 UTC (rev 856) @@ -1,183 +0,0 @@ -package org.cishell.reference.service.database; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Hashtable; - -import javax.sql.DataSource; - -import org.apache.commons.dbcp.ConnectionFactory; -import org.apache.commons.dbcp.DriverManagerConnectionFactory; -import org.apache.commons.dbcp.PoolableConnectionFactory; -import org.apache.commons.dbcp.PoolingDataSource; -import org.apache.commons.pool.KeyedObjectPoolFactory; -import org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory; -import org.apache.commons.pool.impl.GenericObjectPool; -import org.cishell.service.database.DataSourceWithID; -import org.cishell.service.database.DatabaseCreationException; -import org.cishell.service.database.DatabaseService; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - - - -public class DatabaseServiceImpl implements DatabaseService, BundleActivator { - /* TODO: These variables should be abstracted out in a Preferences page at some - point (I guess). - */ - private static final String DEFAULT_DRIVER_NAME = - "org.apache.derby.jdbc.EmbeddedDriver"; - private static final String DEFAULT_PROTOCOL = "jdbc:derby:"; - private static final String DEFAULT_CREATE_CONNECTION_STRING = ";create=true"; - private static final String DEFAULT_DB_NAME = "ultra_sasquatch"; - - //db name must be unique per running instance of the same NWB installation, otherwise they will overlap - private static int dbNameCounter = 0; - - private ServiceRegistration databaseServiceRegistration; - - private PoolingDataSource poolingDataSource = null; - // TODO: Needed? I just want to make sure nothing goes wrong for now. - private DataSourceWithID myDataSource = null; - - private String driver; - - public void start(BundleContext context) throws Exception { - this.driver = DEFAULT_DRIVER_NAME; - - System.err.println("starting!"); - - // Register me as a service! (This doesn't work?) - databaseServiceRegistration = context.registerService - (DatabaseService.class.getName(), this, new Hashtable()); - - ServiceReference ref = context.getServiceReference(DatabaseService.class.getName()); - if (ref == null) { - System.out.println("REEEEEEEEEEEEEEEEEEEEEEEFFFFFFF IS NUUUUUUUULLLLLLL!!@!(@!(!)!"); - } - DatabaseService dbService = (DatabaseService) context.getService(ref); - if (dbService == null) { - System.out.println("DEEEBEESEERVICE IS NUUUUL!L!@L!@!@!@@!@!@L..1"); - } else { - - } - - // Get MY data source! It's mine, and you can't have it! - try { - myDataSource = createDatabase(); - } - catch (DatabaseCreationException e) { - System.err.println(":'( " + e.getMessage()); - throw e; - } - - System.err.println("meep?"); - cleanOutDatabaseTables(); - } - - private void cleanOutDatabaseTables() throws Exception { - //TODO: We need to be cleaning up and starting the DB correctly - //TODO: Clean this up - DataSource ds = getDataSource(); - Connection c = ds.getConnection(); - DatabaseMetaData dmd = c.getMetaData(); - ResultSet tableNames = dmd.getTables(null, null, null, null); - while (tableNames.next()) { - for (int ii = 1; ii <= tableNames.getMetaData().getColumnCount(); ii++) { - String tableContents = tableNames.getString(ii); - System.out.print(tableContents + ", "); - } - if (tableNames.getString(2).indexOf("APP") != -1) { - System.out.println("MAGOOT!"); - Statement s = c.createStatement(); - System.out.println(tableNames.getString(3)); - System.out.println(s.executeUpdate("DROP TABLE APP." + tableNames.getString(3))); - - } - System.out.println(""); - } - } - - public void stop(BundleContext context) throws Exception { - cleanOutDatabaseTables(); - try { - DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } catch (Exception e) { - - } - } - - // If one hasn't been created yet, create a connection pool and return it. - private PoolingDataSource getDataSource() throws DatabaseCreationException - { - if (poolingDataSource != null) - return poolingDataSource; - - try { - System.err.println("Loading driver"); - // This loads the database driver. - Class.forName(DEFAULT_DRIVER_NAME); - - // We can use this later to check acceptsUrl for better error reporting. - // Driver jdbcDriver = (Driver) Class.forName(driver).newInstance(); - - //TODO: It may exist from before, actually. Fix this. - String newDatabaseName = - DEFAULT_DB_NAME; - String newDatabaseConnectionURL = DEFAULT_PROTOCOL + - newDatabaseName + - DEFAULT_CREATE_CONNECTION_STRING; - - System.err.println("connection url: " + newDatabaseConnectionURL); - - // This connection factory actually uses the loaded database driver to - // generate connections. - ConnectionFactory connectionFactory = new DriverManagerConnectionFactory - (newDatabaseConnectionURL, null, null); - - // This is a generic object pool. It must be linked to a poolable - // object factory (PoolableObjectFactory), which the new - // PoolableConnectionFactory below is. - GenericObjectPool connectionPool = new GenericObjectPool(); - - // Not sure what this does? - KeyedObjectPoolFactory stmtPool = new GenericKeyedObjectPoolFactory(null); - - // This is a poolable object factory (PoolableObjectFactory) used to - // create connections for an object pool. It is the glue between the - // connection factory and the object pool. - // It links itself up to the connect pool inside its constructor, which - // is why it's not assigned to a variable out here. - new PoolableConnectionFactory(connectionFactory, connectionPool, stmtPool, null, false, true); - - // Finally, create the connection pool. - poolingDataSource = new PoolingDataSource(connectionPool); - - // TODO: Remove this? - // Make sure we can get a connection from the connection pool. - try { - poolingDataSource.getConnection().close(); - } - catch (SQLException e) { - throw new DatabaseCreationException - ("Could not properly initiate database.", e); - } - } - catch (ClassNotFoundException e) { - throw new DatabaseCreationException - ("Database driver (" + driver + ") could not be found", e); - } - - return poolingDataSource; - } - - public DataSourceWithID createDatabase() throws DatabaseCreationException { - return new DataSourceWithIDImpl(getDataSource()); - } -} Copied: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java (from rev 853, trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java) =================================================================== --- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java (rev 0) +++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-01-26 18:31:07 UTC (rev 856) @@ -0,0 +1,163 @@ +package org.cishell.reference.service.database; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Hashtable; + +import javax.sql.DataSource; + +import org.apache.commons.dbcp.ConnectionFactory; +import org.apache.commons.dbcp.DriverManagerConnectionFactory; +import org.apache.commons.dbcp.PoolableConnectionFactory; +import org.apache.commons.dbcp.PoolingDataSource; +import org.apache.commons.pool.KeyedObjectPoolFactory; +import org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory; +import org.apache.commons.pool.impl.GenericObjectPool; +import org.cishell.service.database.DataSourceWithID; +import org.cishell.service.database.DatabaseCreationException; +import org.cishell.service.database.DatabaseService; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + + + +public class DerbyDatabaseService implements DatabaseService, BundleActivator { + + /* + * Variables used to connect to the internal derby database + * + * TODO: Eventually support connecting databases other than derby, + * and connecting to databases other than our internal one + * (maybe not by modifying this class directly though). + */ + private static final String DERBY_DRIVER_NAME = + "org.apache.derby.jdbc.EmbeddedDriver"; + private static final String DERBY_PROTOCOL = "jdbc:derby:"; + private static final String DEFAULT_CREATE_CONNECTION_STRING = ";create=true"; + private static final String DEFAULT_DB_NAME = "cishell_database"; + + //where the database exists on the filesystem (relative to the application root directory) + private static final String DATABASE_DIRECTORY = "database/"; + + //(new connections to the database will come from a pool of connections, improving performance) + private PoolingDataSource poolingDataSource = null; + + //hold on to our service registration so we can unregister when this plugin stops. + private ServiceRegistration databaseServiceRegistration; + + public void start(BundleContext context) throws Exception { + + /* + * Tell Derby to look for an existing database or create a new database + * in the default directory (within our application's directory) + */ + System.setProperty("derby.system.home", DATABASE_DIRECTORY); + + /* + * Make sure we don't have any leftover cruft in the db from previous sessions. + * This is our second chance, if the database wasn't properly cleaned out + * in the stop() method on application exit. + * TODO: If we ever implement some kind of persistence we may not want to do this so bluntly + */ + removeAllNonSystemDatabaseTables(); + + //allow the database service to be found by other services/plugins + databaseServiceRegistration = context.registerService + (DatabaseService.class.getName(), this, new Hashtable()); + + } + + public void stop(BundleContext context) { + //disallow the database service to be found by other services/plugins + this.databaseServiceRegistration.unregister(); + + //try to clean out the database and shut it down. + try { + removeAllNonSystemDatabaseTables(); + DriverManager.getConnection("jdbc:derby:;shutdown=true"); + } catch (Exception e) { + String message = + "An unexpected exception occurred while shutting down the internal database." + + "Aborting database shutdown process." + + "Database may not be left in a valid state (but it will probably be okay)."; + throw new RuntimeException(message, e); + } + } + + //Return a link to a "database" that cannot interfere with other "databases" in the system. + //TODO: May need to refactor to improve the terminology used surrounding this functionality. + public DataSourceWithID createDatabase() throws DatabaseCreationException { + return new DataSourceWithIDImpl(getDataSource()); + } + + + private static final int SCHEMA_NAME_INDEX = 2; + private static final int TABLE_NAME_INDEX = 3; + private static final String NONSYSTEM_SCHEMA_NAME = "APP"; + + private void removeAllNonSystemDatabaseTables() throws Exception { + + DataSource db = getDataSource(); + Connection dbConnection = db.getConnection(); + DatabaseMetaData dbMetadata = dbConnection.getMetaData(); + ResultSet allTableNames = dbMetadata.getTables(null, null, null, null); + + Statement removeTables = dbConnection.createStatement(); + + while (allTableNames.next()) { + if (allTableNames.getString(SCHEMA_NAME_INDEX).indexOf(NONSYSTEM_SCHEMA_NAME) != -1) { + String removeTableSQL = + "DROP TABLE " + + NONSYSTEM_SCHEMA_NAME + "." + allTableNames.getString(TABLE_NAME_INDEX); + removeTables.addBatch(removeTableSQL); + } + } + + removeTables.executeBatch(); + } + + //TODO: It could be that we should give everyone different datasources instead of the same one + private PoolingDataSource getDataSource() throws DatabaseCreationException + { + if (this.poolingDataSource == null) { initializePoolingDataSource(); }; + return poolingDataSource; + } + + //lazy-load the pooling data source + private void initializePoolingDataSource() throws DatabaseCreationException { + if (this.poolingDataSource != null) { + return; + } + + try { + //Load the database driver + Class.forName(DERBY_DRIVER_NAME); + + /* + * TODO:We can use this later to check acceptsUrl for better error reporting. + * Driver jdbcDriver = (Driver) Class.forName(driver).newInstance(); + */ + String newDatabaseConnectionURL = DERBY_PROTOCOL + + DEFAULT_DB_NAME + + DEFAULT_CREATE_CONNECTION_STRING; + + ConnectionFactory connectionFactory = new DriverManagerConnectionFactory + (newDatabaseConnectionURL, null, null); + GenericObjectPool connectionPool = new GenericObjectPool(); + KeyedObjectPoolFactory stmtPool = new GenericKeyedObjectPoolFactory(null); + //(side-effects the connection-pool so it gets its connections from the connection factory (I think)) + new PoolableConnectionFactory(connectionFactory, connectionPool, stmtPool, null, false, true); + this.poolingDataSource = new PoolingDataSource(connectionPool); + } + catch (ClassNotFoundException e) { + throw new DatabaseCreationException + ("Database driver '" + DERBY_DRIVER_NAME + "' could not be found", e); + } + } +} Property changes on: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-01-24 19:34:28
|
Revision: 855 http://cishell.svn.sourceforge.net/cishell/?rev=855&view=rev Author: pataphil Date: 2009-01-24 19:34:25 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Initial commit. Added Paths: ----------- trunk/templates/org.cishell.templates.database/.classpath trunk/templates/org.cishell.templates.database/.project trunk/templates/org.cishell.templates.database/.settings/ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs trunk/templates/org.cishell.templates.database/META-INF/ trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF trunk/templates/org.cishell.templates.database/build.properties trunk/templates/org.cishell.templates.database/src/ trunk/templates/org.cishell.templates.database/src/org/ trunk/templates/org.cishell.templates.database/src/org/cishell/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java Added: trunk/templates/org.cishell.templates.database/.classpath =================================================================== --- trunk/templates/org.cishell.templates.database/.classpath (rev 0) +++ trunk/templates/org.cishell.templates.database/.classpath 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: trunk/templates/org.cishell.templates.database/.project =================================================================== --- trunk/templates/org.cishell.templates.database/.project (rev 0) +++ trunk/templates/org.cishell.templates.database/.project 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.templates.database</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,7 @@ +#Thu Jan 15 13:52:40 EST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 Added: trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs =================================================================== --- trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs (rev 0) +++ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,4 @@ +#Thu Jan 15 13:52:40 EST 2009 +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false Added: trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF =================================================================== --- trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF (rev 0) +++ trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.cishell.templates.database +Bundle-SymbolicName: org.cishell.templates.database;singleton:=true +Bundle-Version: 1.0.0 +X-AutoStart: true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +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.database, + org.osgi.framework;version="1.3.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" +Bundle-Activator: org.cishell.templates.database.Activator +Export-Package: org.cishell.templates.database Added: trunk/templates/org.cishell.templates.database/build.properties =================================================================== --- trunk/templates/org.cishell.templates.database/build.properties (rev 0) +++ trunk/templates/org.cishell.templates.database/build.properties 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,20 @@ +package org.cishell.templates.database; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } +} Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,134 @@ +package org.cishell.templates.database; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Dictionary; + +import javax.sql.DataSource; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.service.database.DatabaseCreationException; +import org.cishell.service.database.DatabaseService; + +public abstract class SQLExecutionAlgorithm implements Algorithm { + protected Data[] data; + protected Dictionary parameters; + protected CIShellContext context; + + protected DatabaseService databaseService; + + public SQLExecutionAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + this.data = data; + this.parameters = parameters; + this.context = context; + + this.databaseService = (DatabaseService)context.getService(DatabaseService.class.getName()); + } + + // TODO: Update the output to have proper contents. (Since we're only using one + // database now, the ACTUAL (wrapped DataSource) should be the same, but new + // DataSourceWithIDs should be created as the output.) + public Data[] execute() throws AlgorithmExecutionException { + System.err.println("this.databaseService: " + this.databaseService); + // Unpack the in-data as a data source. + DataSource dataSource = (DataSource)this.data[0].getData(); + // Open a connection with the data source so we can perform SQL on the + // data source. + Connection dataSourceConnection = null; + // The statement is what will actually execute our SQL. + Statement sqlStatement = null; + + try { + dataSourceConnection = dataSource.getConnection(); + sqlStatement = dataSourceConnection.createStatement(); + } + catch (SQLException e) { + throw new AlgorithmExecutionException(e); + } + + String sqlStatementString = null; + + // Attempt to form our SQL query and update. + try { + sqlStatementString = formSQL(); + } + catch (SQLFormationException sqlFormationException) { + throw new AlgorithmExecutionException(sqlFormationException); + } + + // Success at this point (with forming the SQL), so execute it if it is not + // empty. + if (!sqlStatement.equals("")) { + try { + // If execute returns true, there is at least one result set. So, + // let's get those and turn them into data sources for our out-data + // YAY! + if (sqlStatement.execute(sqlStatementString)) { + // Used to store the list of + // result-sets-converted-to-new-databases that we're working on. + ArrayList resultSetsConvertedToNewDatabases = new ArrayList(); + + do { + // Get the current result set. + ResultSet resultSet = sqlStatement.getResultSet(); + + // Construct the new database out of the result set. + + DataSource newDatabase = null; + + /* try { + newDatabase = null; + // this.databaseService.createDatabase(resultSet); + } + catch (DatabaseCreationException e) { + throw new AlgorithmExecutionException(e); + } */ + + // Wrap the new database. + Data newDatabaseData = createOutDataFromDataSource(newDatabase); + + // Add the new out-data entry to our working list. + resultSetsConvertedToNewDatabases.add(newDatabaseData); + } + while (sqlStatement.getMoreResults()); + + // Convert the ArrayList to a Data[]. + Data[] finalResultSetsConvertedToNewDatabasesData = + new Data[resultSetsConvertedToNewDatabases.size()]; + + finalResultSetsConvertedToNewDatabasesData = + (Data[])resultSetsConvertedToNewDatabases.toArray + (finalResultSetsConvertedToNewDatabasesData); + + return manipulateFinalOutData + (finalResultSetsConvertedToNewDatabasesData); + } + } + catch (SQLException sqlException) { + throw new AlgorithmExecutionException(sqlException); + } + } + + // + return null; + } + + public String formSQL() throws SQLFormationException { + return ""; + } + + public Data createOutDataFromDataSource(DataSource dataSource) { + return new BasicData(dataSource, dataSource.getClass().getName()); + } + + public Data[] manipulateFinalOutData(Data[] outData) { + return outData; + } +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,24 @@ +package org.cishell.templates.database; + +public class SQLFormationException extends Exception { + + private static final long serialVersionUID = 1L; + + //Constructors from Exception superclass + + public SQLFormationException() { + super(); + } + + public SQLFormationException(String arg0) { + super(arg0); + } + + public SQLFormationException(Throwable arg0) { + super(arg0); + } + + public SQLFormationException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-01-24 19:34:12
|
Revision: 854 http://cishell.svn.sourceforge.net/cishell/?rev=854&view=rev Author: pataphil Date: 2009-01-24 19:34:07 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Initial import. Added Paths: ----------- trunk/templates/org.cishell.templates.database/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |