|
From: <pat...@us...> - 2011-02-08 17:58:40
|
Revision: 1198
http://cishell.svn.sourceforge.net/cishell/?rev=1198&view=rev
Author: pataphil
Date: 2011-02-08 17:58:33 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
* Removed FileLoaderAlgorithm and things its dependents.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF
trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java
trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.properties
trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.xml
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithm.java
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithmFactory.java
Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2011-02-08 17:58:33 UTC (rev 1198)
@@ -7,6 +7,7 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Import-Package: org.cishell.app.service.datamanager;version="1.0.0",
+ org.cishell.app.service.fileloader,
org.cishell.framework;version="1.0.0",
org.cishell.framework.algorithm;version="1.0.0",
org.cishell.framework.data;version="1.0.0",
Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2011-02-08 17:58:33 UTC (rev 1198)
@@ -26,15 +26,18 @@
import org.cishell.app.service.datamanager.DataManagerListener;
import org.cishell.app.service.datamanager.DataManagerService;
+import org.cishell.app.service.fileloader.FileLoaderService;
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.CIShellContextDelegate;
import org.cishell.framework.LocalCIShellContext;
+import org.cishell.framework.ServiceReferenceDelegate;
import org.cishell.framework.algorithm.Algorithm;
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.framework.data.BasicData;
+import org.cishell.framework.algorithm.ProgressMonitor;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
import org.cishell.reference.gui.workspace.CIShellApplication;
-import org.cishell.utilities.AlgorithmUtilities;
import org.cishell.utilities.StringUtilities;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuManager;
@@ -198,6 +201,10 @@
getSite().setSelectionProvider(new DataModelSelectionProvider());
+ setupDataManagerViewForDragAndDrop(parent);
+ }
+
+ private void setupDataManagerViewForDragAndDrop(Composite parent) {
DropTarget dropTarget =
new DropTarget(parent.getParent(), DND.DROP_DEFAULT | DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { FileTransfer.getInstance() });
@@ -211,37 +218,55 @@
fileNames = (String[]) event.data;
Collection<File> flattenedFileStructure =
flattenDraggedFileStructures(fileNames);
- Collection<Data> dataForProcessing = new ArrayList<Data>();
- for (File file : flattenedFileStructure) {
- dataForProcessing.add(new BasicData(file, ""));
- }
-
- AlgorithmFactory fileLoaderFactory =
- AlgorithmUtilities.getAlgorithmFactoryByPID(
- "org.cishell.reference.gui.persistence.load.FileLoaderAlgorithm",
- Activator.context);
+ ServiceReference fileLoaderServiceReference =
+ Activator.context.getServiceReference(FileLoaderService.class.getName());
+ FileLoaderService fileLoader =
+ (FileLoaderService) Activator.context.getService(
+ fileLoaderServiceReference);
DataManagerService dataManager =
(DataManagerService) Activator.context.getService(
Activator.context.getServiceReference(
DataManagerService.class.getName()));
- try {
- Data[] inputData = fileLoaderFactory.createAlgorithm(
- dataForProcessing.toArray(new Data[0]),
- new Hashtable<String, Object>(),
- new LocalCIShellContext(Activator.context)).execute();
+ ServiceReference dataManagerServiceReference =
+ Activator.context.getServiceReference(DataManagerService.class.getName());
- for (Data inputDatum : inputData) {
- dataManager.addData(inputDatum);
+ for (File file : flattenedFileStructure) {
+ /* TODO: Eventually use the AlgorithmInvocationService for this
+ * kind of stuff?
+ */
+ ServiceReference uniqueServiceReference = new ServiceReferenceDelegate(
+ dataManagerServiceReference);
+ CIShellContext ciShellContext = new CIShellContextDelegate(
+ uniqueServiceReference, new LocalCIShellContext(Activator.context));
+ LogService uniqueLogger =
+ (LogService) ciShellContext.getService(LogService.class.getName());
+
+ try {
+ Data[] inputData = fileLoader.loadFile(
+ Activator.context,
+ ciShellContext,
+ uniqueLogger,
+ ProgressMonitor.NULL_MONITOR,
+ file);
+
+ for (Data inputDatum : inputData) {
+ inputDatum.getMetadata().put(
+ DataProperty.SERVICE_REFERENCE, uniqueServiceReference);
+ dataManager.addData(inputDatum);
+ }
+ } catch (Throwable e) {
+ String format =
+ "An error occurred when loading your files.%n" +
+ "Please include the following when reporting this:%n%s";
+ String logMessage =
+ String.format(format, StringUtilities.getStackTraceAsString(e));
+ /* TODO: This is a spot where we might need to use a different
+ * LogService object (for when we want log highlighting).
+ */
+ uniqueLogger.log(LogService.LOG_ERROR, logMessage);
}
- } catch (Throwable e) {
- String format =
- "An error occurred when loading your files.%n" +
- "Please include the following when reporting this:%n%s";
- String logMessage =
- String.format(format, StringUtilities.getStackTraceAsString(e));
- AbstractDataManagerView.this.logger.log(LogService.LOG_ERROR, logMessage);
}
}
}
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-02-08 17:58:33 UTC (rev 1198)
@@ -24,7 +24,7 @@
org.osgi.service.metatype;version="1.1.0",
org.osgi.service.prefs;version="1.1.0"
X-AutoStart: true
-Service-Component: OSGI-INF/load.xml, OSGI-INF/save.xml, OSGI-INF/view.xml, OSGI-INF/viewwith.xml, OSGI-INF/fileloader.xml
+Service-Component: OSGI-INF/load.xml, OSGI-INF/save.xml, OSGI-INF/view.xml, OSGI-INF/viewwith.xml
Require-Bundle: org.eclipse.swt,
org.eclipse.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.properties
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.properties 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.properties 2011-02-08 17:58:33 UTC (rev 1198)
@@ -1,8 +0,0 @@
-#menu_path=File/start
-label=File Loader
-description=This does the actual loading of files from the file system and loads them to Data Model window.
-in_data=null
-out_data=java.lang.Object
-service.pid=org.cishell.reference.gui.persistence.load.FileLoaderAlgorithm
-remoteable=true
-documentation_url=http://wiki.slis.indiana.edu:8080/display/ALGDOC/Data+Formats
\ No newline at end of file
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.xml
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.xml 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/fileloader.xml 2011-02-08 17:58:33 UTC (rev 1198)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component name="org.cishell.reference.gui.persistence.load.FileLoaderAlgorithm.component" immediate="false">
- <implementation class="org.cishell.reference.gui.persistence.load.FileLoaderAlgorithmFactory"/>
- <properties entry="OSGI-INF/fileloader.properties"/>
- <reference name="LOG" interface="org.osgi.service.log.LogService"/>
- <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/>
-
- <service>
- <provide interface="org.cishell.framework.algorithm.AlgorithmFactory"/>
- </service>
-</component>
\ No newline at end of file
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-02-08 17:58:33 UTC (rev 1198)
@@ -52,31 +52,6 @@
} catch (FileLoadException e) {
throw new AlgorithmExecutionException(e.getMessage(), e);
}
-// IWorkbenchWindow window = getFirstWorkbenchWindow();
-// Display display = PlatformUI.getWorkbench().getDisplay();
-// File[] files = getFilesToLoadFromUser(window, display);
-//
-// if (files != null) {
-//// try {
-// return new FileLoaderAlgorithm(
-// this.bundleContext,
-// files,
-// this.ciShellContext,
-// this.logger,
-// this.progressMonitor).execute();
-//// } catch (Throwable e) {
-//// String format =
-//// "The chosen file is not compatible with this format. " +
-//// "Check that your file is correctly formatted or try another validator. " +
-//// "The reason is: %s";
-//// String logMessage = String.format(format, e.getMessage());
-//// this.logger.log(LogService.LOG_ERROR, logMessage, e);
-////
-//// return null;
-//// }
-// } else {
-// return null;
-// }
}
public ProgressMonitor getProgressMonitor() {
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithm.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithm.java 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithm.java 2011-02-08 17:58:33 UTC (rev 1198)
@@ -1,131 +0,0 @@
-package org.cishell.reference.gui.persistence.load;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.cishell.framework.CIShellContext;
-import org.cishell.framework.algorithm.Algorithm;
-import org.cishell.framework.algorithm.AlgorithmExecutionException;
-import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.framework.algorithm.ProgressMonitor;
-import org.cishell.framework.data.Data;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-
-public class FileLoaderAlgorithm implements Algorithm {
- private BundleContext bundleContext;
- private File[] filesToLoad;
- private CIShellContext ciShellContext;
- private LogService logger;
- private ProgressMonitor progressMonitor;
-
- public FileLoaderAlgorithm(
- BundleContext bundleContext,
- File[] filesToLoad,
- CIShellContext ciShellContext,
- LogService logger,
- ProgressMonitor progressMonitor) {
- this.bundleContext = bundleContext;
- this.filesToLoad = filesToLoad;
- this.ciShellContext = ciShellContext;
- this.logger = logger;
- this.progressMonitor = progressMonitor;
- }
-
- public Data[] execute() throws AlgorithmExecutionException {
- IWorkbenchWindow window = getFirstWorkbenchWindow();
- Display display = PlatformUI.getWorkbench().getDisplay();
-
- if ((this.filesToLoad != null) && (this.filesToLoad.length != 0)) {
- Collection<Data> finalLabeledFileData = new ArrayList<Data>();
-
- for (File file : this.filesToLoad) {
- try {
- Data[] validatedFileData = validateFile(window, display, file);
- Data[] labeledFileData = labelFileData(file, validatedFileData);
-
- for (Data data : labeledFileData) {
- finalLabeledFileData.add(data);
- }
- } catch (Throwable e) {
- String format =
- "The chosen file is not compatible with this format. " +
- "Check that your file is correctly formatted or try another validator. " +
- "The reason is: %s";
- String logMessage = String.format(format, e.getMessage());
- this.logger.log(LogService.LOG_ERROR, logMessage, e);
- }
- }
-
- return finalLabeledFileData.toArray(new Data[0]);
- } else {
- return null;
- }
- }
-
- 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[] validateFile(IWorkbenchWindow window, Display display, File file)
- throws AlgorithmExecutionException {
- AlgorithmFactory validator = null;
- validator = getValidatorFromUser(window, display, file);
-
- if ((file == null) || (validator == null)) {
- String logMessage = "File loading canceled";
- this.logger.log(LogService.LOG_WARNING, logMessage);
- } else {
- try {
- return FileValidator.validateFile(
- file, validator, this.progressMonitor, this.ciShellContext, this.logger);
- } catch (AlgorithmExecutionException e) {
- if ((e.getCause() != null)
- && (e.getCause() instanceof UnsupportedEncodingException)) {
- String format =
- "This file cannot be loaded; it uses the unsupported character " +
- "encoding %s.";
- String logMessage = String.format(format, e.getCause().getMessage());
- this.logger.log(LogService.LOG_ERROR, logMessage);
- } else {
- throw e;
- }
- }
- }
-
- return new Data[0];
- }
-
- private Data[] labelFileData(File file, Data[] validatedFileData) {
- Data[] labeledFileData =
- PrettyLabeler.relabelWithFileNameHierarchy(validatedFileData, file);
-
- return labeledFileData;
- }
-
- private AlgorithmFactory getValidatorFromUser(
- IWorkbenchWindow window, Display display, File file) {
- ValidatorSelectorRunnable validatorSelector =
- new ValidatorSelectorRunnable(window, this.bundleContext, file);
-
- if (Thread.currentThread() != display.getThread()) {
- display.syncExec(validatorSelector);
- } else {
- validatorSelector.run();
- }
-
- return validatorSelector.getValidator();
- }
-}
\ No newline at end of file
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithmFactory.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithmFactory.java 2011-02-08 17:27:54 UTC (rev 1197)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoaderAlgorithmFactory.java 2011-02-08 17:58:33 UTC (rev 1198)
@@ -1,40 +0,0 @@
-package org.cishell.reference.gui.persistence.load;
-
-import java.io.File;
-import java.util.Dictionary;
-
-import org.cishell.framework.CIShellContext;
-import org.cishell.framework.algorithm.Algorithm;
-import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.framework.algorithm.ProgressMonitor;
-import org.cishell.framework.data.Data;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.log.LogService;
-
-public class FileLoaderAlgorithmFactory implements AlgorithmFactory {
- private BundleContext bundleContext;
- private LogService logger;
-
- protected void activate(ComponentContext componentContext) {
- this.bundleContext = componentContext.getBundleContext();
- this.logger = (LogService) this.bundleContext.getService(
- this.bundleContext.getServiceReference(LogService.class.getName()));
- }
-
- public Algorithm createAlgorithm(
- Data[] data, Dictionary<String, Object> parameters, CIShellContext ciShellContext) {
- File[] filesToLoad = new File[data.length];
-
- for (int ii = 0; ii < data.length; ii++) {
- filesToLoad[ii] = (File) data[ii].getData();
- }
-
- return new FileLoaderAlgorithm(
- this.bundleContext,
- filesToLoad,
- ciShellContext,
- this.logger,
- ProgressMonitor.NULL_MONITOR);
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|