From: <pat...@us...> - 2009-10-12 17:37:23
|
Revision: 959 http://cishell.svn.sourceforge.net/cishell/?rev=959&view=rev Author: pataphil Date: 2009-10-12 17:37:06 +0000 (Mon, 12 Oct 2009) Log Message: ----------- * Improved "View" functionality so CSV-compatible data types (both file-based and in-memory) are viewed in Excel after conversion. * Also significantly refactored code. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 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/FileUtil.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileViewFactory.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 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/FileViewWithFactory.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/ViewWithDataChooser.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataForViewingException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataToFileAndPrepareForViewingException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertInMemoryDataToTextFileException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/FileViewingException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/NoProgramFoundException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/PrepareTextFileForViewingException.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/UserCanceledDataViewSelectionException.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-10-12 17:37:06 UTC (rev 959) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_19"/> + <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> 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 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2009-10-12 17:37:06 UTC (rev 959) @@ -13,6 +13,7 @@ org.cishell.reference.service.metatype, org.cishell.service.conversion;version="1.0.0", org.cishell.service.guibuilder;version="1.0.0", + org.cishell.utilities, org.osgi.framework;version="1.3.0", org.osgi.service.cm;version="1.2.0", org.osgi.service.component;version="1.0.0", Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-10-12 17:37:06 UTC (rev 959) @@ -6,10 +6,9 @@ import org.osgi.service.log.LogService; public class FileUtil { - private static int uniqueIntForTempFile = 1; - public static File getTempFile(String fileName, String extension, LogService logger){ + public static File getTempFile(String fileName, String extension, LogService logger) { File tempFile; if (fileName == null || fileName.equals("")) { Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2009-10-12 17:37:06 UTC (rev 959) @@ -1,48 +1,44 @@ package org.cishell.reference.gui.persistence.save; -import java.io.File; import java.util.Dictionary; import org.cishell.framework.CIShellContext; import org.cishell.framework.LocalCIShellContext; import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.algorithm.DataValidator; import org.cishell.framework.data.Data; -import org.cishell.service.conversion.Converter; -import org.cishell.service.conversion.DataConversionService; import org.osgi.service.component.ComponentContext; -import org.osgi.service.metatype.MetaTypeProvider; /** * Create a Save object * * TODO: Should also support if we can convert to file, but have * no final file:X->file-ext:* converter. - * - * @author bmarkine * */ public class SaveFactory implements AlgorithmFactory { - private CIShellContext context; + private CIShellContext ciShellContext; /** * Create a local CIShell context - * @param ctxt The current CIShell context + * @param componentContext The current CIShell context */ - protected void activate(ComponentContext ctxt) { - context = new LocalCIShellContext(ctxt.getBundleContext()); + protected void activate(ComponentContext componentContext) { + ciShellContext = + new LocalCIShellContext(componentContext.getBundleContext()); } /** * Create a Save algorithm * @param data The data objects to save * @param parameters The parameters for the algorithm - * @param context Reference to services provided by CIShell + * @param ciShellContext Reference to services provided by CIShell * @return An instance of the Save algorithm */ - public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { - this.context = context; - return new Save(data, parameters, context); + public Algorithm createAlgorithm(Data[] data, + Dictionary parameters, + CIShellContext ciShellContext) { + this.ciShellContext = ciShellContext; + return new Save(data, parameters, ciShellContext); } } \ No newline at end of file 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-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2009-10-12 17:37:06 UTC (rev 959) @@ -1,295 +1,47 @@ package org.cishell.reference.gui.persistence.view; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; import java.util.Dictionary; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; -import org.cishell.framework.data.DataProperty; -import org.cishell.reference.gui.persistence.FileUtil; +import org.cishell.reference.gui.persistence.view.core.FileViewer; import org.cishell.service.conversion.ConversionException; -import org.cishell.service.conversion.Converter; import org.cishell.service.conversion.DataConversionService; -import org.eclipse.swt.program.Program; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.osgi.service.log.LogService; -/* - * @author Weixia(Bonnie) Huang (hu...@in...) - */ public class FileView implements Algorithm { - public static final String ANY_FILE_EXTENSION_FILTER = "file-ext:*"; - private static final String CSV_FILE_EXT = "file-ext:csv"; - private static final String CSV_MIME_TYPE = "file:text/csv"; - public static final String FILE_EXTENSION_PREFIX = "file-ext:"; - public static final String ANY_TEXT_MIME_TYPE = "file:text/"; - private Data[] data; - private CIShellContext context; + private Data[] dataToView; + private CIShellContext ciShellContext; private DataConversionService conversionManager; - private LogService logger; - private Program program; - private File tempFile; - public FileView(Data[] data, Dictionary parameters, CIShellContext context) { - this.data = data; - this.context = context; + this.dataToView = data; + this.ciShellContext = context; this.conversionManager = (DataConversionService) context .getService(DataConversionService.class.getName()); - - this.logger = (LogService) context.getService(LogService.class.getName()); } - // Show the contents of a file to the user + // Show the contents of a file to the user. public Data[] execute() throws AlgorithmExecutionException { try { - boolean lastSaveSuccessful = false; - boolean isCSVFile = false; - String format; - - // For each data item we want to view... - for (int i = 0; i < data.length; i++) { - Object theData = data[i].getData(); - format = data[i].getFormat(); - String label = (String) data[i].getMetadata().get( - DataProperty.LABEL); - - // If it is a text file... - if (theData instanceof File - || format.startsWith(ANY_TEXT_MIME_TYPE) - || format.startsWith(FILE_EXTENSION_PREFIX)) { - - // If it is a CSV text file... - if (format.startsWith(CSV_MIME_TYPE) - || format.startsWith(CSV_FILE_EXT)) { - // Prepare to open it like a CSV file - tempFile = getTempFileCSV(); - isCSVFile = true; - } else { - // Prepare to open it like a normal text file - String fileName = FileUtil.extractFileName(label); - String extension = FileUtil.extractExtension(format); - tempFile = FileUtil.getTempFile(fileName, extension, - logger); - } - - // Copy out data into the temp file we just created. - copy((File) data[i].getData(), tempFile); - lastSaveSuccessful = true; - - } else { - /* The data item is in an in-memory format, and must be - * converted to a file format before the user can see it. - */ - final Converter[] convertersCSV = - conversionManager.findConverters(data[i], CSV_FILE_EXT); - - // If the data item can be converted to a CSV file, do so. - if (convertersCSV.length == 1) { - Data newDataCSV = convertersCSV[0].convert(data[i]); - tempFile = getTempFileCSV(); - isCSVFile = true; - copy((File) newDataCSV.getData(), tempFile); - lastSaveSuccessful = true; - - } else if (convertersCSV.length > 1) { - Data newDataCSV = convertersCSV[0].convert(data[i]); - for (int j = 1; j < convertersCSV.length; j++) { - newDataCSV = convertersCSV[j].convert(newDataCSV); - } - tempFile = getTempFileCSV(); - isCSVFile = true; - copy((File) newDataCSV.getData(), tempFile); - lastSaveSuccessful = true; - } else { // it cannot be converted to a .csv - - // try to convert it to any other file format - - final Converter[] converters = - conversionManager.findConverters( - data[i], ANY_FILE_EXTENSION_FILTER); - - // if it can't be converted to any file format... - if (converters.length < 1) { - // throw an error - throw new AlgorithmExecutionException( - "No valid converters for data type: " - + data[i].getData().getClass() - .getName() - + ". Please install a plugin that will save the data type to a file"); - } else if (converters.length == 1) { // if there is only - // file format - // it can be - // converted to - // go ahead and convert the data item to that format - Data newData = converters[0].convert(data[i]); - - String fileName = FileUtil.extractFileName(label); - String extension = FileUtil - .extractExtension(newData.getFormat()); - tempFile = FileUtil.getTempFile(fileName, - extension, logger); - copy((File) newData.getData(), tempFile); - lastSaveSuccessful = true; - } else { - // there is more than one format that the data - // item could be converted to - // let the user choose - // (get some eclipse UI stuff that we need to open - // the data viewer) - - Display display; - IWorkbenchWindow[] windows; - final Shell parentShell; - - windows = PlatformUI.getWorkbench() - .getWorkbenchWindows(); - if (windows.length == 0) { - throw new AlgorithmExecutionException( - "Cannot get workbench window."); - } - parentShell = windows[0].getShell(); - display = PlatformUI.getWorkbench().getDisplay(); - - // (open the data viewer, which lets the user choose - // which format they want to see the data item in.) - - if (!parentShell.isDisposed()) { - DataViewer dataViewer = new DataViewer( - parentShell, data[i], converters); - display.syncExec(dataViewer); - lastSaveSuccessful = dataViewer.isSaved; - tempFile = dataViewer.outputFile; - } - } - } - } - - // If it's a CSV file - if (isCSVFile) {// TC181 - // prepare to open the file with the default csv program - Display.getDefault().syncExec(new Runnable() { - public void run() { - program = Program.findProgram("csv"); - } - }); - } else { - // Prepare to open it with the standard text editor. - Display.getDefault().syncExec( - new Runnable() { - public void run() { - program = Program.findProgram("txt"); - } - } - ); - } - - // If we can't find any program to open the file... - if (program == null) { - throw new AlgorithmExecutionException( - "No valid text viewer for the .txt file. " - + "The file is located at: " - + tempFile.getAbsolutePath() - + ". Unable to open default text viewer. " - + "File is located at: " - + tempFile.getAbsolutePath()); - } else { - // We found a program to open the file. Open it. - if (lastSaveSuccessful == true) { - Display.getDefault().syncExec( - new Runnable() { - public void run() { - program.execute(tempFile.getAbsolutePath()); - } - } - ); - } - } + for (int ii = 0; ii < this.dataToView.length; ii++) { + FileViewer.viewDataFile(this.dataToView[ii], + this.ciShellContext, + this.conversionManager); } return null; - } catch (ConversionException e) { + } catch (ConversionException conversionException) { + String exceptionMessage = "Error: Unable to view data:\n " + + conversionException.getMessage(); + throw new AlgorithmExecutionException( - "Error: Unable to view data:\n " + e.getMessage(), e); - } catch (Throwable e) { - throw new AlgorithmExecutionException(e); + exceptionMessage, conversionException); + } catch (Throwable thrownObject) { + throw new AlgorithmExecutionException(thrownObject); } } - - public File getTempFileCSV() { - File tempFile; - - String tempPath = System.getProperty("java.io.tmpdir"); - File tempDir = new File(tempPath + File.separator + "temp"); - if (!tempDir.exists()) - tempDir.mkdir(); - try { - tempFile = File.createTempFile("xxx-Session-", ".csv", tempDir); - - } catch (IOException e) { - logger.log(LogService.LOG_ERROR, e.toString(), e); - tempFile = new File(tempPath + File.separator + "temp" - + File.separator + "temp.csv"); - - } - return tempFile; - } - - public static boolean copy(File in, File out) - throws AlgorithmExecutionException { - try { - FileInputStream fis = new FileInputStream(in); - FileOutputStream fos = new FileOutputStream(out); - - FileChannel readableChannel = fis.getChannel(); - FileChannel writableChannel = fos.getChannel(); - - writableChannel.truncate(0); - writableChannel.transferFrom(readableChannel, 0, readableChannel - .size()); - fis.close(); - fos.close(); - return true; - } catch (IOException ioe) { - throw new AlgorithmExecutionException("IOException during copy", - ioe); - } - } - - final class DataViewer implements Runnable { - public static final String VIEW_DIALOG_TITLE = "View"; - private Shell shell; - private boolean isSaved; - private File outputFile; - private Data data; - private Converter[] converters; - - - DataViewer(Shell parentShell, Data data, Converter[] converters) { - this.shell = parentShell; - this.data = data; - this.converters = converters; - } - - - public void run() { - // Lots of persisters found, return the chooser - ViewDataChooser vdc = new ViewDataChooser( - VIEW_DIALOG_TITLE, shell, data, converters, context, logger); - vdc.open(); - isSaved = vdc.isSaved(); - outputFile = vdc.outputFile; - } - } } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileViewFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileViewFactory.java 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileViewFactory.java 2009-10-12 17:37:06 UTC (rev 959) @@ -6,14 +6,12 @@ import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.Data; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.metatype.MetaTypeProvider; -//import org.osgi.service.metatype.MetaTypeService; public class FileViewFactory implements AlgorithmFactory { - - public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { - return new FileView(data, parameters, context); + public Algorithm createAlgorithm(Data[] data, + Dictionary parameters, + CIShellContext ciShellContext) { + return new FileView(data, parameters, ciShellContext); } } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 2009-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 2009-10-12 17:37:06 UTC (rev 959) @@ -1,51 +1,50 @@ package org.cishell.reference.gui.persistence.view; -import java.io.File; - import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; -import org.cishell.framework.data.DataProperty; -import org.cishell.reference.gui.persistence.FileUtil; import org.cishell.reference.gui.persistence.save.SaveDataChooser; -import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.eclipse.swt.widgets.Shell; import org.osgi.service.log.LogService; -/* - * @author Weixia(Bonnie) Huang (hu...@in...) - * - */ +// TODO: Refactor this class. public class ViewDataChooser extends SaveDataChooser { - boolean isSaved = false; - LogService logger; - Data theData; - File outputFile; + /*private boolean isSaved = false; + private LogService logger; + private Data theData; + private File outputFile;*/ + private Converter selectedConverter = null; - public ViewDataChooser(String title, Shell parent, - Data data, Converter[] converters, CIShellContext context, LogService logger){ - super (data, parent, converters, title, context); + public ViewDataChooser(String title, + Shell parent, + Data data, + Converter[] converters, + CIShellContext ciShellContext, + LogService logger){ + super (data, parent, converters, title, ciShellContext); - this.theData = data; - this.logger = logger; + /*this.theData = data; + this.logger = logger;*/ } - + //TODO: replace this stuff with convertToFile -- specifically, just ahve this return the darn selected format. protected void selectionMade(int selectedIndex) { getShell().setVisible(false); - final Converter converter = converterArray[selectedIndex]; + this.selectedConverter = converterArray[selectedIndex]; + close(true); + /*final Converter selectedConverter = converterArray[selectedIndex]; try { - Data newData = converter.convert(theData); + Data newData = selectedConverter.convert(theData); String label = (String) newData.getMetadata().get(DataProperty.LABEL); String fileName = FileUtil.extractFileName(label); String extension = FileUtil.extractExtension(newData.getFormat()); File tempFile = FileUtil.getTempFile(fileName, extension, logger); try { - isSaved = FileView.copy((File)newData.getData(), tempFile); - } catch (AlgorithmExecutionException e) { - logger.log(LogService.LOG_ERROR, "Error copying view for view:\n " + e.getMessage(), e); + FileUtilities.copyFile((File)newData.getData(), tempFile); + isSaved = true; + } catch (FileCopyingException fileCopyingException) { + logger.log(LogService.LOG_ERROR, "Error copying view for view:\n " + fileCopyingException.getMessage(), fileCopyingException); return; } @@ -54,12 +53,18 @@ } catch (ConversionException e) { logger.log(LogService.LOG_ERROR, "Error: Unable to view data:\n " + e.getMessage(), e); return; - } + }*/ } - public boolean isSaved(){ - return isSaved; + public Converter getSelectedConverter() { + return this.selectedConverter; } - + /*public boolean isSaved(){ + return this.isSaved; + } + + public File getOutputFile() { + return this.outputFile; + }*/ } Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,488 @@ +package org.cishell.reference.gui.persistence.view.core; + +import java.io.File; +import java.io.IOException; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.data.Data; +import org.cishell.framework.data.DataProperty; +import org.cishell.reference.gui.persistence.FileUtil; +import org.cishell.reference.gui.persistence.view.ViewDataChooser; +import org.cishell.reference.gui.persistence.view.core.exceptiontypes.ConvertDataForViewingException; +import org.cishell.reference.gui.persistence.view.core.exceptiontypes.FileViewingException; +import org.cishell.reference.gui.persistence.view.core.exceptiontypes.NoProgramFoundException; +import org.cishell.reference.gui.persistence.view.core.exceptiontypes.UserCanceledDataViewSelectionException; +import org.cishell.service.conversion.ConversionException; +import org.cishell.service.conversion.Converter; +import org.cishell.service.conversion.DataConversionService; +import org.cishell.utilities.FileCopyingException; +import org.cishell.utilities.FileUtilities; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.osgi.service.log.LogService; + +public class FileViewer { + public static final String FILE_EXTENSION_MIME_TYPE_PREFIX = "file-ext:"; + public static final String ANY_FILE_EXTENSION_FILTER = "file-ext:*"; + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + public static final String ANY_MIME_TYPE = "file:"; + public static final String CSV_FILE_EXT = "file-ext:csv"; + public static final String CSV_MIME_TYPE = "file:text/csv"; + public static final String TEMPORARY_CSV_FILE_NAME = "xxx-Session-"; + public static final String CSV_FILE_EXTENSION = "csv"; + public static final String ANY_FILE_FORMAT_PATTERN = + "(file:.*)|(file-ext:.*)"; + + public static void viewDataFile(Data data, + CIShellContext ciShellContext, + DataConversionService conversionManager) + throws ConversionException, FileViewingException { + viewDataFileWithProgram(data, null, ciShellContext, conversionManager); + } + + public static void viewDataFileWithProgram( + Data data, + String customFileExtension, + CIShellContext ciShellContext, + DataConversionService converterManager) + throws FileViewingException { + FileWithExtension fileWithExtension = + convertDataForViewing(data, ciShellContext, converterManager); + viewFileWithExtension(fileWithExtension, customFileExtension); + } + + private static FileWithExtension convertDataForViewing( + Data data, + CIShellContext ciShellContext, + DataConversionService converterManager) + throws FileViewingException { + try { + String dataFormat = data.getFormat(); + + if (isCSVFormat(data)) { + /* + * The data is already a CSV file, so it just needs to + * be copied. + */ + try { + File csvFileForViewing = + FileUtilities.createTemporaryFileCopy( + (File)data.getData(), + TEMPORARY_CSV_FILE_NAME, + CSV_FILE_EXTENSION); + + return new FileWithExtension( + csvFileForViewing, CSV_FILE_EXTENSION); + } catch (FileCopyingException csvFileCopyingException) { + throw new ConvertDataForViewingException( + csvFileCopyingException); + } + } else if (dataIsCSVCompatible(data, converterManager)) { + /* + * The data is either a CSV file already or CSV-convertible. + * This needs to be handled specially so data that can be + * viewed in Excel gets viewed in Excel. + */ + File preparedFileForViewing = prepareFileForViewing( + data, CSV_FILE_EXTENSION, converterManager); + + return new FileWithExtension( + preparedFileForViewing, CSV_FILE_EXTENSION); + } else if (dataIsFile(data, dataFormat)) { + /* + * The data is already a text-based file, so it just needs to + * be copied to a temporary file for viewing in the default + * text-viewing program. + */ + return new FileWithExtension( + prepareTextFileForViewing(data), "txt"); + } else if (convertersExist( + data, ANY_FILE_EXTENSION_FILTER, converterManager)) { + /* + * The data is an another type, but it can be converted to a + * text-based file type for viewing in the default + * text-viewing program. + */ + return new FileWithExtension( + convertDataToTextFile( + data, converterManager, ciShellContext), + "txt"); + } else { + String exceptionMessage = + "No converters exist for the data \"" + + data.getMetadata().get(DataProperty.LABEL) + + "\"."; + + throw new ConvertDataForViewingException(exceptionMessage); + } + } catch (ConvertDataForViewingException + convertDataForViewingException) { + String exceptionMessage = + "There was a problem when preparing the data \"" + + data.getMetadata().get(DataProperty.LABEL) + + "\" for viewing."; + + throw new FileViewingException( + exceptionMessage, convertDataForViewingException); + } + } + + private static void viewFileWithExtension( + FileWithExtension fileWithExtension, String customFileExtension) + throws FileViewingException { + try { + final Program program = selectProgramForFileExtension( + fileWithExtension.fileExtension, customFileExtension); + + executeProgramWithFile(program, fileWithExtension.file); + } catch (NoProgramFoundException noProgramFoundException) { + String exceptionMessage = + "Could not view the file \"" + + fileWithExtension.file.getAbsolutePath() + + "\" because no viewing program could be found for it."; + + throw new FileViewingException( + exceptionMessage, noProgramFoundException); + } + } + + private static boolean isCSVFormat(Data data) { + String dataFormat = data.getFormat(); + + if (dataFormat.startsWith(CSV_MIME_TYPE) || + dataFormat.startsWith(CSV_FILE_EXT)) { + return true; + } else { + return false; + } + } + + /*private static boolean dataIsCSVCompatibleFile( + Data data, + DataConversionService converterManager) { + return convertersExist(data, CSV_FILE_EXT, converterManager); + }*/ + + private static boolean dataIsCSVCompatible( + Data data, + DataConversionService converterManager) { + if (isCSVFormat(data) || + convertersExist(data, CSV_FILE_EXT, converterManager)) { + return true; + } else { + return false; + } + } + + private static boolean dataIsFile(Data data, String dataFormat) { + if (data.getData() instanceof File || + dataFormat.startsWith(ANY_MIME_TYPE) || + dataFormat.startsWith(FILE_EXTENSION_PREFIX)) { + return true; + } else { + return false; + } + } + + private static boolean convertersExist( + Data data, + String targetFormat, + DataConversionService conversionManager) { + final Converter[] converters = + conversionManager.findConverters(data, targetFormat); + + if (converters.length > 0) { + return true; + } else { + return false; + } + } + + private static File prepareFileForViewing( + Data originalData, + String fileExtension, + DataConversionService converterManager) + throws ConvertDataForViewingException { + String dataLabel = + (String)originalData.getMetadata().get(DataProperty.LABEL); + + try { + String fileExtensionMimeType = + FILE_EXTENSION_MIME_TYPE_PREFIX + fileExtension; + File convertedFile = convertToFile( + originalData, fileExtensionMimeType, converterManager); + String fileName = FileUtil.extractFileName(dataLabel); + + return FileUtilities.createTemporaryFileCopy( + convertedFile, fileName, fileExtension); + } catch (ConversionException convertingDataToFileException) { + String exceptionMessage = + "A ConversionException occurred when converting the data \"" + + dataLabel + + "\" to " + fileExtension + "."; + + throw new ConvertDataForViewingException( + exceptionMessage, convertingDataToFileException); + } catch (FileCopyingException temporaryFileCopyingException) { + String exceptionMessage = + "A FileCopyingException occurred when converting the data \"" + + dataLabel + + "\" to " + fileExtension + "."; + + throw new ConvertDataForViewingException( + exceptionMessage, temporaryFileCopyingException); + } + } + + private static File prepareTextFileForViewing(Data originalData) + throws ConvertDataForViewingException { + String dataLabel = + (String)originalData.getMetadata().get(DataProperty.LABEL); + String dataFormat = originalData.getFormat(); + String fileName = FileUtil.extractFileName(dataLabel); + String fileExtension = FileUtil.extractExtension(dataFormat); + + try { + File fileToView = FileUtilities. + createTemporaryFileInDefaultTemporaryDirectory( + fileName, fileExtension); + FileUtilities.copyFile((File)originalData.getData(), fileToView); + + return fileToView; + } catch (IOException temporaryFileCreationException) { + String exceptionMessage = + "An IOException occurred when creating the temporary file \"" + + fileName + "." + fileExtension + + "\" for viewing the data \"" + dataLabel + "\"."; + + throw new ConvertDataForViewingException( + exceptionMessage, temporaryFileCreationException); + } catch (FileCopyingException fileCopyingException) { + throw new ConvertDataForViewingException(fileCopyingException); + } + } + + private static File convertDataToTextFile( + Data originalData, + DataConversionService converterManager, + CIShellContext ciShellContext) + throws ConvertDataForViewingException { + final Converter[] converters = converterManager.findConverters( + originalData, ANY_FILE_EXTENSION_FILTER); + + if (converters.length == 1) { + /* + * There is just one converter, so transparently do + * the conversion. + */ + try { + return convertToFile( + originalData, converters[0]); + } + catch (ConversionException + convertDataToFileAndPrepareForViewingException) { + String exceptionMessage = + "A ConversionException occurred when converting the " + + "data \"" + + originalData.getMetadata().get(DataProperty.LABEL) + + "\" to a file format."; + + throw new ConvertDataForViewingException( + exceptionMessage, + convertDataToFileAndPrepareForViewingException); + } + } else { + /* + * There are several converters available, so the user will + * need to select how the dataToView is to be converted. + */ + try { + return convertDataBasedOffUserChosenConverter( + originalData, converters, ciShellContext); + } catch (ConversionException conversionException) { + String exceptionMessage = + "A ConversionException occurred when converting the " + + "data \"" + + originalData.getMetadata().get(DataProperty.LABEL) + + "\"."; + + throw new ConvertDataForViewingException( + exceptionMessage, conversionException); + } catch (UserCanceledDataViewSelectionException + userCanceledDataViewSelectionException) { + String exceptionMessage = + "A UserCanceledDataViewSelectionException occurred " + + "when the user did not choose a converter for the " + + "data \"" + + originalData.getMetadata().get(DataProperty.LABEL) + + "\"."; + + throw new ConvertDataForViewingException( + exceptionMessage, userCanceledDataViewSelectionException); + } + } + } + + private static Program selectProgramForFileExtension( + final String fileExtension, final String customFileExtension) + throws NoProgramFoundException { + String chosenFileExtension = null; + + if ((customFileExtension == null) || customFileExtension.equals("")) { + chosenFileExtension = fileExtension; + } else { + chosenFileExtension = customFileExtension; + } + + final Program[] programHolder = new Program[1]; + + Display.getDefault().syncExec(new Runnable() { + public void run() { + programHolder[0] = + Program.findProgram(fileExtension); + } + }); + + Program program = programHolder[0]; + + if (program != null) { + return program; + } else { + String exceptionMessage = + "You do not have a valid viewer for the ." + + chosenFileExtension + + "file installed."; + + throw new NoProgramFoundException(exceptionMessage); + } + } + + private static void executeProgramWithFile(final Program program, + final File file) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + program.execute( + file.getAbsolutePath()); + } + }); + } + + private static File convertToFile(Data data, + String targetFormat, + DataConversionService conversionManager) + throws ConversionException { + if (targetFormat.matches(ANY_FILE_FORMAT_PATTERN)) { + Converter[] converters = + conversionManager.findConverters(data, targetFormat); + + return convertToFile(data, converters[0]); + } else { + String exceptionMessage = + "The target format for conversion (\"" + + targetFormat + + "\") is not valid."; + + throw new ConversionException(exceptionMessage); + } + } + + + private static File convertToFile(Data data, Converter converter) + throws ConversionException { + Data newData = converter.convert(data); + return (File)newData.getData(); + } + + private static File convertDataBasedOffUserChosenConverter( + Data originalData, + Converter[] converters, + CIShellContext ciShellContext) + throws ConversionException, + UserCanceledDataViewSelectionException { + /* + * Open the dataToView viewer, which lets the user choose + * which format he/she wants to see the data item in. + */ + DataViewer dataViewer = new DataViewer( + originalData, converters, ciShellContext); + + if (dataViewer.selectedConverter != null) { + return convertToFile(originalData, dataViewer.selectedConverter); + } else { + String exceptionMessage = + "The user cancelled the selection of a converter for the " + + "data \"" + + originalData.getMetadata().get(DataProperty.LABEL) + + "\"."; + + throw new UserCanceledDataViewSelectionException( + exceptionMessage); + } + } + + private final static class DataViewer implements Runnable { + public static final String VIEW_DIALOG_TITLE = "View"; + private Shell shellWindow; + /*private boolean isSaved; + private File outputFile;*/ + private Converter selectedConverter; + private Data data; + private Converter[] converters; + private CIShellContext ciShellContext; + private LogService logger; + + public DataViewer(Data data, + Converter[] converters, + CIShellContext ciShellContext) { + this(data, + converters, + ciShellContext, + (LogService)ciShellContext.getService( + LogService.class.getName())); + } + + public DataViewer(Data data, + Converter[] converters, + CIShellContext ciShellContext, + LogService logger) { + IWorkbenchWindow[] windows = + PlatformUI.getWorkbench().getWorkbenchWindows(); + this.shellWindow = windows[0].getShell(); + this.data = data; + this.converters = converters; + this.ciShellContext = ciShellContext; + this.logger = logger; + + Display display = PlatformUI.getWorkbench().getDisplay(); + display.syncExec(this); + } + + public void run() { + // Lots of persisters found, return the chooser. + ViewDataChooser viewDataChooser = new ViewDataChooser( + VIEW_DIALOG_TITLE, + this.shellWindow, + this.data, + this.converters, + this.ciShellContext, + this.logger); + viewDataChooser.open(); + /*isSaved = viewDataChooser.isSaved(); + outputFile = viewDataChooser.getOutputFile();*/ + this.selectedConverter = viewDataChooser.getSelectedConverter(); + } + } + + private static class FileWithExtension { + public final File file; + public final String fileExtension; + + public FileWithExtension(File file, String fileExtension) { + this.file = file; + this.fileExtension = fileExtension; + } + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataForViewingException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataForViewingException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataForViewingException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class ConvertDataForViewingException extends Exception { + private static final long serialVersionUID = 1L; + + public ConvertDataForViewingException() { + super(); + } + + public ConvertDataForViewingException(String arg0) { + super(arg0); + } + + public ConvertDataForViewingException(Throwable arg0) { + super(arg0); + } + + public ConvertDataForViewingException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataToFileAndPrepareForViewingException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataToFileAndPrepareForViewingException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertDataToFileAndPrepareForViewingException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,22 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class ConvertDataToFileAndPrepareForViewingException extends Exception { + private static final long serialVersionUID = 1L; + + public ConvertDataToFileAndPrepareForViewingException() { + super(); + } + + public ConvertDataToFileAndPrepareForViewingException(String arg0) { + super(arg0); + } + + public ConvertDataToFileAndPrepareForViewingException(Throwable arg0) { + super(arg0); + } + + public ConvertDataToFileAndPrepareForViewingException( + String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertInMemoryDataToTextFileException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertInMemoryDataToTextFileException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/ConvertInMemoryDataToTextFileException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class ConvertInMemoryDataToTextFileException extends Exception { + private static final long serialVersionUID = 1L; + + public ConvertInMemoryDataToTextFileException() { + super(); + } + + public ConvertInMemoryDataToTextFileException(String arg0) { + super(arg0); + } + + public ConvertInMemoryDataToTextFileException(Throwable arg0) { + super(arg0); + } + + public ConvertInMemoryDataToTextFileException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/FileViewingException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/FileViewingException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/FileViewingException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class FileViewingException extends Exception { + private static final long serialVersionUID = 1L; + + public FileViewingException() { + super(); + } + + public FileViewingException(String arg0) { + super(arg0); + } + + public FileViewingException(Throwable arg0) { + super(arg0); + } + + public FileViewingException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/NoProgramFoundException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/NoProgramFoundException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/NoProgramFoundException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class NoProgramFoundException extends Exception { + private static final long serialVersionUID = 1L; + + public NoProgramFoundException() { + super(); + } + + public NoProgramFoundException(String arg0) { + super(arg0); + } + + public NoProgramFoundException(Throwable arg0) { + super(arg0); + } + + public NoProgramFoundException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/PrepareTextFileForViewingException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/PrepareTextFileForViewingException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/PrepareTextFileForViewingException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class PrepareTextFileForViewingException extends Exception { + private static final long serialVersionUID = 1L; + + public PrepareTextFileForViewingException() { + super(); + } + + public PrepareTextFileForViewingException(String arg0) { + super(arg0); + } + + public PrepareTextFileForViewingException(Throwable arg0) { + super(arg0); + } + + public PrepareTextFileForViewingException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/UserCanceledDataViewSelectionException.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/UserCanceledDataViewSelectionException.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/exceptiontypes/UserCanceledDataViewSelectionException.java 2009-10-12 17:37:06 UTC (rev 959) @@ -0,0 +1,21 @@ +package org.cishell.reference.gui.persistence.view.core.exceptiontypes; + +public class UserCanceledDataViewSelectionException extends Exception { + private static final long serialVersionUID = 1L; + + public UserCanceledDataViewSelectionException() { + super(); + } + + public UserCanceledDataViewSelectionException(String arg0) { + super(arg0); + } + + public UserCanceledDataViewSelectionException(Throwable arg0) { + super(arg0); + } + + public UserCanceledDataViewSelectionException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file 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-10-12 16:29:06 UTC (rev 958) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2009-10-12 17:37:06 UTC (rev 959) @@ -26,20 +26,22 @@ * @author Felix Terkhorn (ter...@gm...), Weixia Huang (hu...@in...) */ public class FileViewWith implements Algorithm { - Data[] data; - Dictionary parameters; - CIShellContext context; - DataConversionService conversionManager; - static GUIBuilderService guiBuilder; - LogService logger; - Program program; - Program programTwo; - Program programThree; - Program programFour; //TC181 - File tempFile; + public static final String VIEW_WITH_PARAMETER_KEY = "viewWith"; + + private Data[] dataToView; + private Dictionary parameters; + private CIShellContext context; + private DataConversionService conversionManager; + private static GUIBuilderService guiBuilder; + private LogService logger; + private Program textProgram; + private Program wordProgram; + private Program webBrowserProgram; + private Program spreadsheetProgram; + private File temporaryFile; public FileViewWith(Data[] data, Dictionary parameters, CIShellContext context) { - this.data = data; + this.dataToView = data; this.parameters = parameters; this.context = context; @@ -50,150 +52,192 @@ guiBuilder = (GUIBuilderService)context.getService(GUIBuilderService.class.getName()); } + public File getTempFile(){ File tempFile; String tempPath = System.getProperty("java.io.tmpdir"); - File tempDir = new File(tempPath+File.separator+"temp"); - if(!tempDir.exists()) + File tempDir = new File(tempPath + File.separator + "temp"); + + if (!tempDir.exists()) { tempDir.mkdir(); - try{ + } + + try { tempFile = File.createTempFile("xxx-Session-", ".txt", tempDir); - }catch (IOException e){ - logger.log(LogService.LOG_ERROR, e.toString(), e); - tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.txt"); + } catch (IOException ioException) { + logger.log( + LogService.LOG_ERROR, ioException.toString(), ioException); + + String separator = File.separator; + String temporaryFileName = + tempPath + separator + "temp" + separator + "temp.txt"; + tempFile = new File(temporaryFileName); } + return tempFile; } public Data[] execute() throws AlgorithmExecutionException { - boolean lastSaveSuccessful = false; + // TODO: Refactor this code so it and FileView use the same code. + boolean temporaryFileWasCreated = false; String format; - String viewWith = (String) parameters.get("viewWith"); + String viewWithType = (String)parameters.get(VIEW_WITH_PARAMETER_KEY); Display display; IWorkbenchWindow[] windows; final Shell parentShell; windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - if (windows.length == 0){ + + if (windows.length == 0) { return null; } + parentShell = windows[0].getShell(); display = PlatformUI.getWorkbench().getDisplay(); - tempFile = getTempFile(); + temporaryFile = getTempFile(); - for (int i = 0; i < data.length; i++){ - Object theData = data[i].getData(); - format = data[i].getFormat(); + for (int ii = 0; ii < this.dataToView.length; ii++){ + Data data = this.dataToView[ii]; + Object theData = data.getData(); + format = data.getFormat(); + if (theData instanceof File || format.startsWith("file:text/") || format.startsWith("file-ext:")){ - copy((File)data[i].getData(), tempFile); - lastSaveSuccessful = true; - }else{ - final Converter[] converters = conversionManager.findConverters(data[i], "file-ext:*"); + copy((File)data.getData(), temporaryFile); + temporaryFileWasCreated = true; + } else { + final Converter[] converters = + conversionManager.findConverters(data, "file-ext:*"); - if (converters.length < 1) { - guiBuilder.showError("No Converters", - "No valid converters for data type: " + - data[i].getData().getClass().getName(), - "Please install a plugin that will save the data type to a file"); - } - else if (converters.length == 1){ - //If length=1, use the unique path to save it directly - //and bring the text editor. + if (converters.length == 1) { + /* + * If length is 1, use the unique path to save it directly + * and bring the text editor. + */ + try { - Data newData = converters[0].convert(data[i]); - copy((File)newData.getData(), tempFile); - lastSaveSuccessful = true; - } catch (ConversionException e) { - this.logger.log(LogService.LOG_WARNING, "Warning: Unable to convert to target save format (" + e.getMessage() + "). Will attempt to use other available converters.", e); + Data newData = converters[0].convert(data); + copy((File)newData.getData(), temporaryFile); + temporaryFileWasCreated = true; + } catch (ConversionException conversionException) { + String warningMessage = + "Warning: Unable to convert to target save " + + "format (" + conversionException.getMessage() + + "). Will attempt to use other " + + "available converters."; + this.logger.log(LogService.LOG_WARNING, + warningMessage, + conversionException); } - } - else { + } else if (converters.length > 1) { if (!parentShell.isDisposed()) { try { - DataViewer dataViewer = new DataViewer(parentShell, data[i], converters); - display.syncExec(dataViewer); + DataViewer dataViewer = + new DataViewer(parentShell, data, converters); + display.syncExec(dataViewer); - lastSaveSuccessful = dataViewer.isSaved; - tempFile = dataViewer.theFile; - } catch (Throwable e1) { - throw new AlgorithmExecutionException(e1); + temporaryFileWasCreated = dataViewer.isSaved; + temporaryFile = dataViewer.theFile; + } catch (Throwable thrownObject) { + throw new AlgorithmExecutionException( + thrownObject); } } } + else { + String errorMessage = + "No valid converters for data type: " + + data.getData().getClass().getName(); + String errorDetail = + "Please install a plugin that will save the " + + "data type to a file"; + guiBuilder.showError( + "No Converters", errorMessage, errorDetail); + } } - + //TODO: holy code duplication, batman! Display.getDefault().syncExec(new Runnable() { public void run() { - program = Program.findProgram("txt"); + textProgram = Program.findProgram("txt"); }}); Display.getDefault().syncExec(new Runnable() { public void run() { - programTwo = Program.findProgram("doc"); + wordProgram = Program.findProgram("doc"); }}); Display.getDefault().syncExec(new Runnable() { public void run() { - programThree = Program.findProgram("htm"); + webBrowserProgram = Program.findProgram("htm"); }}); - //TC181 + Display.getDefault().syncExec(new Runnable() { public void run() { - programFour = Program.findProgram("csv"); + spreadsheetProgram = Program.findProgram("csv"); }}); - //TC181 - if (program == null && programTwo == null && programThree == null && programThree == null) { - guiBuilder.showError("No Viewers for TXT, DOC, or HTM", - "No valid viewers for .txt, .doc, or .htm files. " + - "The file is located at: "+tempFile.getAbsolutePath(), - "Unable to open default text viewer. File is located at: "+ - tempFile.getAbsolutePath()); + if ((textProgram == null) && + (wordProgram == null) && + (webBrowserProgram == null) && + (webBrowserProgram == null)) { + String errorTitle = "No Viewers for TXT, DOC, or HTM"; + String errorMessage = + "No valid viewers for .txt, .doc, or .htm files. " + + "The file is located at: " + temporaryFile.getAbsolutePath(); + String errorDetail = + "Unable to open default text viewer. " + + "File is located at: " + + temporaryFile.getAbsolutePath(); + guiBuilder.showError( + errorTitle, errorMessage, errorDetail); } else { - if (lastSaveSuccessful == true) { - if (viewWith.equals("txt")) { + if (temporaryFileWasCreated) { + final String filePath = temporaryFile.getAbsolutePath(); + + //TODO: . . . I already said "holy code duplication batman!", didn't I? + if (viewWithType.equals("txt")) { Display.getDefault().syncExec(new Runnable() { public void run() { - program.execute(tempFile.getAbsolutePath()); - }}); - } else if (viewWith.equals("doc")) { + textProgram.execute(filePath); + } + }); + } else if (viewWithType.equals("doc")) { Display.getDefault().syncExec(new Runnable() { public void run() { - programTwo.execute(tempFile.getAbsolutePath()); - }}); - } el... [truncated message content] |
From: <jrb...@us...> - 2009-10-19 18:50:40
|
Revision: 971 http://cishell.svn.sourceforge.net/cishell/?rev=971&view=rev Author: jrbibers Date: 2009-10-19 18:50:27 +0000 (Mon, 19 Oct 2009) Log Message: ----------- The suggested filename in the file save dialog is now checked for invalid filename characters (like ? or *). Any found are replaced with a #. Suggested filenames are produced from the item's label in the data manager. Since the label may contain characters which are not valid in filenames (like a quotation mark), previously the suggested filename could have been invalid and so the file save dialog would open with no suggestion. Now the user should always get a suggested filename. Reviewed by Micah. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 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/FileUtil.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.pde.core.prefs Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-10-19 04:53:55 UTC (rev 970) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-10-19 18:50:27 UTC (rev 971) @@ -1,7 +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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> </classpath> Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.pde.core.prefs =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.pde.core.prefs 2009-10-19 04:53:55 UTC (rev 970) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.pde.core.prefs 2009-10-19 18:50:27 UTC (rev 971) @@ -1,3 +0,0 @@ -#Wed Sep 27 14:27:31 EDT 2006 -eclipse.preferences.version=1 -pluginProject.extensions=false 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 2009-10-19 04:53:55 UTC (rev 970) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2009-10-19 18:50:27 UTC (rev 971) @@ -24,3 +24,4 @@ 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.4 Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-10-19 04:53:55 UTC (rev 970) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-10-19 18:50:27 UTC (rev 971) @@ -2,10 +2,37 @@ import java.io.File; import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; import org.osgi.service.log.LogService; public class FileUtil { + public static final char FILENAME_CHARACTER_REPLACEMENT = '#'; + + /* Attempt to enumerate characters which cannot be used to name a file. + * For our purposes, this should be as aggressive as sensible. + * This includes all such characters for modern Windows systems, plus %. + * Please add any others. + */ + public static final Collection INVALID_FILENAME_CHARACTERS; + static { + Collection s = new HashSet(); + s.add(new Character('\\')); + s.add(new Character('/')); + s.add(new Character(':')); + s.add(new Character('*')); + s.add(new Character('?')); + s.add(new Character('"')); + s.add(new Character('<')); + s.add(new Character('>')); + s.add(new Character('|')); + s.add(new Character('%')); + INVALID_FILENAME_CHARACTERS = Collections.unmodifiableCollection(s); + } + private static int uniqueIntForTempFile = 1; public static File getTempFile(String fileName, String extension, LogService logger) { @@ -64,9 +91,22 @@ return extension; } - - public static String extractFileName(String fileLabel) { + + public static String replaceInvalidFilenameCharacters(String filename) { + String cleanedFilename = filename; + for (Iterator invalidCharacters = INVALID_FILENAME_CHARACTERS.iterator(); + invalidCharacters.hasNext();) { + char invalidCharacter = ((Character) invalidCharacters.next()).charValue(); + + cleanedFilename = + cleanedFilename.replace(invalidCharacter, FILENAME_CHARACTER_REPLACEMENT); + } + + return cleanedFilename; + } + + public static String extractFileName(String fileLabel) { //index variables will be -1 if index is not found. int descriptionEndIndex = fileLabel.lastIndexOf(":"); int filePathEndIndex = fileLabel.lastIndexOf(File.separator); @@ -75,9 +115,8 @@ //zero and none of the string will be cut off the front. int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1; - String fileNameWithExtension = fileLabel.substring(startIndex); + String fileNameWithExtension = fileLabel.substring(startIndex); - //find the first character of the file name extension. int extensionBeginIndex = fileNameWithExtension.lastIndexOf("."); @@ -93,8 +132,16 @@ } String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex); - - String fileName = fileNameWithoutExtension; - return fileName; + + return fileNameWithoutExtension; } + + public static void main(String[] args) { +// String s = "Input data: CSV file: C:\\Documents and Settings\\katy\\Desktop\\NIH-Demo\\nih\\NIH-data\\NIH-NIGMS-PPBC-R01s,-FY08-Publications.csv"; + String s = "a\\b/c:d*e?f\"g<h>i|j"; + + System.out.println(replaceInvalidFilenameCharacters(s)); + + System.exit(0); + } } Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2009-10-19 04:53:55 UTC (rev 970) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2009-10-19 18:50:27 UTC (rev 971) @@ -119,7 +119,9 @@ String fileLabel = (String)data.getMetadata().get(DataProperty.LABEL); String suggestedFileName = FileUtil.extractFileName(fileLabel); - dialog.setFileName(suggestedFileName + "." + ext); + String cleanedSuggestedFileName = + FileUtil.replaceInvalidFilenameCharacters(suggestedFileName); + dialog.setFileName(cleanedSuggestedFileName + "." + ext); // if (fileLabel == null) { // dialog.setFileName("*." + ext); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2010-01-04 17:30:23
|
Revision: 1004 http://cishell.svn.sourceforge.net/cishell/?rev=1004&view=rev Author: mwlinnem Date: 2010-01-04 17:30:10 +0000 (Mon, 04 Jan 2010) Log Message: ----------- Modified to show a text file with a databases schema when a user chooses to "View" a database. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2010-01-04 17:29:08 UTC (rev 1003) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2010-01-04 17:30:10 UTC (rev 1004) @@ -12,6 +12,7 @@ org.cishell.reference.service.conversion, org.cishell.reference.service.metatype, org.cishell.service.conversion;version="1.0.0", + org.cishell.service.database, org.cishell.service.guibuilder;version="1.0.0", org.cishell.utilities, org.osgi.framework;version="1.3.0", @@ -24,4 +25,4 @@ 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.4 +Bundle-RequiredExecutionEnvironment: J2SE-1.5 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 2010-01-04 17:29:08 UTC (rev 1003) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2010-01-04 17:30:10 UTC (rev 1004) @@ -33,7 +33,8 @@ try { FileViewer.viewDataFile(this.dataToView[ii], this.ciShellContext, - this.conversionManager); + this.conversionManager, + this.logger); } catch (FileViewingException fileViewingException) { String logMessage = "Error: Unable to view data \"" + Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java 2010-01-04 17:30:10 UTC (rev 1004) @@ -0,0 +1,129 @@ +package org.cishell.reference.gui.persistence.view.core; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.cishell.service.database.Database; +import org.cishell.utilities.FileUtilities; + +public class DatabaseSchemaOverviewGenerator { + + private static final String newLine = System.getProperty("line.separator"); + + public static File generateDatabaseSchemaOverview(Database db) throws Exception { + + // Setup + + Connection dbConnection = db.getConnection(); + String applicationSchemaName = db.getApplicationSchemaName(); + + StringBuffer dbOverview = new StringBuffer(); + + // Generating text + + String headerText = getHeaderText(); + dbOverview.append(headerText); + List<String> tableNames = getTableNames(dbConnection, applicationSchemaName); + for (String tableName : tableNames) { + + String tableSchemaText = getTableSchemaAsText(dbConnection, tableName, + applicationSchemaName); + String foreignKeyReferencesText = getForeignKeyReferencesAsText(dbConnection, + tableName, applicationSchemaName); + + dbOverview.append(tableSchemaText); + dbOverview.append(foreignKeyReferencesText); + dbOverview.append(newLine); + } + + // Returning text as file + + File dbOverviewFile = FileUtilities.writeTextIntoTemporaryDirectory(dbOverview.toString(), + "txt"); + return dbOverviewFile; + } + + private static String getHeaderText() { + StringBuffer headerText = new StringBuffer(); + + headerText.append("Database Tables:" + newLine); + headerText.append("********************" + newLine); + headerText.append(newLine); + headerText.append(newLine); + + return headerText.toString(); + } + + // write the table's name, and the names and types of all the columns in + // that table + private static String getTableSchemaAsText(Connection dbConnection, String tableName, + String applicationSchemaName) throws SQLException { + + StringBuffer tableSchemaAsText = new StringBuffer(); + tableSchemaAsText.append(tableName + " ("); + + ResultSet columns = dbConnection.getMetaData().getColumns(null, applicationSchemaName, + tableName, null); + while (columns.next()) { + String columnName = columns.getString("COLUMN_NAME"); + String columnType = columns.getString("TYPE_NAME"); + + tableSchemaAsText.append(" " + columnName + " " + columnType + ","); + } + tableSchemaAsText.deleteCharAt(tableSchemaAsText.length() - 1); // (delete + // final + // comma) + tableSchemaAsText.append(")" + newLine); + + return tableSchemaAsText.toString(); + } + + // write which foreign keys in the table reference which other tables + private static String getForeignKeyReferencesAsText(Connection dbConnection, String tableName, + String applicationSchemaName) throws SQLException { + StringBuffer foreignKeyReferencesAsText = new StringBuffer(); + + ResultSet foreignKeys = dbConnection.getMetaData().getImportedKeys(null, + applicationSchemaName, tableName); + while (foreignKeys.next()) { + String foreignKey = foreignKeys.getString("FKCOLUMN_NAME"); + String referencedTable = foreignKeys.getString("PKTABLE_NAME"); + String referencedTableKey = foreignKeys.getString("PKCOLUMN_NAME"); + + foreignKeyReferencesAsText.append(" " + foreignKey + " -----> " + referencedTable + + "." + referencedTableKey); + foreignKeyReferencesAsText.append(newLine); + } + return foreignKeyReferencesAsText.toString(); + } + + // ---UTIL-- + + private static List<String> getTableNames(Connection dbConnection, String defaultSchemaName) + throws SQLException { + DatabaseMetaData dbMetadata = dbConnection.getMetaData(); + ResultSet allTableNames = dbMetadata.getTables(null, defaultSchemaName, null, null); + + // Names of tables that are not system tables. + List<String> nonSystemTableNames = new ArrayList<String>(); + while (allTableNames.next()) { + String schemaName = allTableNames.getString("TABLE_SCHEM"); + if (isNonSystemSchemaName(schemaName, defaultSchemaName)) { + String tableName = allTableNames.getString("TABLE_NAME"); + nonSystemTableNames.add(tableName); + } + } + + return nonSystemTableNames; + } + + private static boolean isNonSystemSchemaName(String tableSchemaName, String defaultSchemaName) { + return tableSchemaName.indexOf(defaultSchemaName) != -1; + } +} \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-01-04 17:29:08 UTC (rev 1003) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/FileViewer.java 2010-01-04 17:30:10 UTC (rev 1004) @@ -14,6 +14,7 @@ import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.cishell.service.conversion.DataConversionService; +import org.cishell.service.database.Database; import org.cishell.utilities.FileCopyingException; import org.cishell.utilities.FileUtilities; import org.eclipse.swt.program.Program; @@ -32,35 +33,57 @@ public static final String CSV_MIME_TYPE = "file:text/csv"; public static final String TEMPORARY_CSV_FILE_NAME = "xxx-Session-"; public static final String CSV_FILE_EXTENSION = "csv"; + public static final String TXT_FILE_EXTENSION = "txt"; public static final String ANY_FILE_FORMAT_PATTERN = "(file:.*)|(file-ext:.*)"; public static void viewDataFile(Data data, CIShellContext ciShellContext, - DataConversionService conversionManager) + DataConversionService conversionManager, + LogService logger) throws FileViewingException { - viewDataFileWithProgram(data, "", ciShellContext, conversionManager); + viewDataFileWithProgram(data, "", ciShellContext, conversionManager, logger); } public static void viewDataFileWithProgram( Data data, String customFileExtension, CIShellContext ciShellContext, - DataConversionService converterManager) + DataConversionService converterManager, + LogService logger) throws FileViewingException { FileWithExtension fileWithExtension = - convertDataForViewing(data, ciShellContext, converterManager); + convertDataForViewing(data, ciShellContext, converterManager, + logger); viewFileWithExtension(fileWithExtension, customFileExtension); } private static FileWithExtension convertDataForViewing( Data data, CIShellContext ciShellContext, - DataConversionService converterManager) - throws FileViewingException { + DataConversionService converterManager, + LogService logger) throws FileViewingException { try { String dataFormat = data.getFormat(); //TODO: Add image viewing support here (shouldn't be too hard) + if (dataIsDB(data, converterManager)) { + try { + Data genericDBData = converterManager.convert(data, Database.GENERIC_DB_MIME_TYPE); + Database genericDatabase = (Database) genericDBData.getData(); + + File dbSchemaOverview = + DatabaseSchemaOverviewGenerator.generateDatabaseSchemaOverview(genericDatabase); + + return new FileWithExtension(dbSchemaOverview, TXT_FILE_EXTENSION); + } catch (ConversionException e) { + //continue attempts to view for other formats + } catch (Exception e) { + String message = "Unexpected error occurred while generating " + + "database schema overview. Attempting to view the data item" + + "by other means."; + logger.log(LogService.LOG_WARNING, message, e); + } + } if (isCSVFormat(data)) { /* * The data is already a CSV file, so it just needs to @@ -97,7 +120,7 @@ * text-viewing program. */ return new FileWithExtension( - prepareTextFileForViewing(data), "txt"); + prepareTextFileForViewing(data), TXT_FILE_EXTENSION); } else if (convertersExist( data, ANY_FILE_EXTENSION_FILTER, converterManager)) { /* @@ -176,6 +199,21 @@ } } + private static boolean dataIsDB ( + Data data, + DataConversionService converterManager) { + if (has_DB_MimeType_Prefix(data) || + convertersExist(data, Database.GENERIC_DB_MIME_TYPE, converterManager)) { + return true; + } else { + return false; + } + } + + private static boolean has_DB_MimeType_Prefix(Data data) { + return data.getFormat().startsWith(Database.DB_MIME_TYPE_PREFIX); + } + private static boolean dataIsFile(Data data, String dataFormat) { if (data.getData() instanceof File || dataFormat.startsWith(ANY_MIME_TYPE) || 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 2010-01-04 17:29:08 UTC (rev 1003) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2010-01-04 17:30:10 UTC (rev 1004) @@ -41,7 +41,8 @@ this.dataToView[ii], viewWithType, this.ciShellContext, - this.conversionManager); + this.conversionManager, + this.logger); } catch (FileViewingException fileViewingException) { String logMessage = "Error: Unable to view data \"" + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2010-09-30 14:55:50
|
Revision: 1140 http://cishell.svn.sourceforge.net/cishell/?rev=1140&view=rev Author: pataphil Date: 2010-09-30 14:55:41 +0000 (Thu, 30 Sep 2010) Log Message: ----------- * Reimplemented labeling file data items with prettier labels upon loading files. * Reviewed by Joseph. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/PrettyLabeler.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2010-09-30 14:54:33 UTC (rev 1139) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2010-09-30 14:55:41 UTC (rev 1140) @@ -15,6 +15,7 @@ org.cishell.service.database, org.cishell.service.guibuilder;version="1.0.0", org.cishell.utilities, + org.cishell.utilities.dictionary, org.osgi.framework;version="1.3.0", org.osgi.service.cm;version="1.2.0", org.osgi.service.component;version="1.0.0", Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-09-30 14:54:33 UTC (rev 1139) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2010-09-30 14:55:41 UTC (rev 1140) @@ -48,7 +48,10 @@ File file = getFileToLoadFromUser(window, display); if (file != null) { - return validateFile(window, display, file); + Data[] validatedFileData = validateFile(window, display, file); + Data[] labeledFileData = labelFileData(file, validatedFileData); + + return labeledFileData; } else { return null; } @@ -101,13 +104,14 @@ } else { try { return FileValidator.validateFile( - file, validator, this.progressMonitor, this.ciShellContext, this.logger); + file, validator, this.progressMonitor, this.ciShellContext, this.logger); } catch (AlgorithmExecutionException e) { - if (e.getCause() != null - && e.getCause() instanceof UnsupportedEncodingException) { - String logMessage = - "This file cannot be loaded; it uses the unsupported character encoding " - + e.getCause().getMessage() + "."; + 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; @@ -119,13 +123,18 @@ "The chosen file is not compatible with this format. " + "Check that your file is correctly formatted or try another validator. " + "The reason is: " + e.getMessage(); - e.printStackTrace(); // TODO remove this.logger.log(LogService.LOG_ERROR, logMessage); } return null; } + private Data[] labelFileData(File file, Data[] validatedFileData) { + Data[] labeledFileData = PrettyLabeler.relabelWithFileName(validatedFileData, file); + + return labeledFileData; + } + private AlgorithmFactory getValidatorFromUser( IWorkbenchWindow window, Display display, File file) { ValidatorSelectorRunnable validatorSelector = Added: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/PrettyLabeler.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/PrettyLabeler.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/PrettyLabeler.java 2010-09-30 14:55:41 UTC (rev 1140) @@ -0,0 +1,44 @@ +package org.cishell.reference.gui.persistence.load; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Dictionary; + +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.framework.data.DataProperty; +import org.cishell.utilities.dictionary.DictionaryUtilities; + +public class PrettyLabeler { + public static Data[] relabelWithFileName(Data[] data, File file) { + File absoluteFile = file.getAbsoluteFile(); + File parent = absoluteFile.getParentFile(); + + // TODO parent == null + + String prefix; + String parentName = parent.getName(); + if (parentName.trim().length() == 0) { + prefix = File.separator; + } else { + prefix = "..." + File.separator + parentName + File.separator; + } + + Collection<Data> newData = new ArrayList<Data>(data.length); + + /* TODO: This isn't actually correct. + * It will assign the same label to all of the data items if we ever do this. + */ + for (Data datum : data) { + Dictionary<String, Object> labeledDatumMetadata = + DictionaryUtilities.copy(datum.getMetadata()); + Data labeledDatum = + new BasicData(labeledDatumMetadata, datum.getData(), datum.getFormat()); + labeledDatumMetadata.put(DataProperty.LABEL, prefix + absoluteFile.getName()); + newData.add(labeledDatum); + } + + return newData.toArray(new Data[0]); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2011-03-01 20:09:52
|
Revision: 1230 http://cishell.svn.sourceforge.net/cishell/?rev=1230&view=rev Author: pataphil Date: 2011-03-01 20:09:46 +0000 (Tue, 01 Mar 2011) Log Message: ----------- * Refactored to use the File*Services. * Reviewed by Joseph. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2011-03-01 20:09:46 UTC (rev 1230) @@ -6,6 +6,7 @@ Bundle-ClassPath: . Import-Package: org.cishell.app.service.datamanager, org.cishell.app.service.fileloader, + org.cishell.app.service.filesaver, org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadAlgorithm.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -34,7 +34,7 @@ public Data[] execute() throws AlgorithmExecutionException { try { return this.fileLoader.loadFilesFromUserSelection( - this.bundleContext, this.ciShellContext, this.logger, this.progressMonitor); + this.bundleContext, this.ciShellContext, this.logger, this.progressMonitor, false); } catch (FileLoadException e) { throw new AlgorithmExecutionException(e.getMessage(), e); } Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -1,31 +1,32 @@ package org.cishell.reference.gui.persistence.save; -import org.cishell.framework.CIShellContext; +import java.io.File; + +import org.cishell.app.service.filesaver.FileSaveException; +import org.cishell.app.service.filesaver.FileSaverService; import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmCanceledException; import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; import org.cishell.service.conversion.Converter; -import org.cishell.service.conversion.DataConversionService; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; +import org.osgi.service.log.LogService; public class Save implements Algorithm { public static final String ANY_FILE_EXTENSION = "file-ext:*"; public static final String SAVE_DIALOG_TITLE = "Save"; + private Data data; - private CIShellContext ciShellContext; + private LogService logger; + private FileSaverService fileSaver; - private Shell parentShell; - - private DataConversionService conversionManager; - public Save( - Data data, CIShellContext ciShellContext, DataConversionService conversionManager) { + Data data, + LogService logger, + FileSaverService fileSaver) { this.data = data; - this.ciShellContext = ciShellContext; - - this.conversionManager = conversionManager; + + this.logger = logger; + this.fileSaver = fileSaver; } public Data[] execute() throws AlgorithmExecutionException { @@ -36,49 +37,37 @@ private void tryToSave(final Data outData, String outFormat) throws AlgorithmExecutionException { - final Converter[] converters = conversionManager.findConverters(outData, outFormat); + try { + Converter userChosenConverter = + this.fileSaver.promptForConverter(outData, outFormat); - if (converters.length == 0) { - throw new AlgorithmExecutionException("Error: Calculated an empty converter chain."); - } + if (userChosenConverter == null) { + throw new AlgorithmCanceledException( + "User canceled file saving when choosing what kind of file to save as."); + } - this.parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); + File userChosenFile = this.fileSaver.promptForTargetFile(outData); - if (this.parentShell.isDisposed()) { - throw new AlgorithmExecutionException("Attempted to use disposed parent shell."); - } - - try { - guiRun(new Runnable() { - public void run() { - if (converters.length == 1) { - // Only one possible choice in how to save data. Do it. - Converter onlyConverter = converters[0]; - FileSaver saver = new FileSaver(Save.this.parentShell, ciShellContext); - saver.save(onlyConverter, outData); - } else { - // Multiple ways to save the data. Let user choose. - SaveDataChooser saveChooser = new SaveDataChooser( - outData, - Save.this.parentShell, - converters, - SAVE_DIALOG_TITLE, - Save.this.ciShellContext); - saveChooser.createContent(new Shell(Save.this.parentShell)); - saveChooser.open(); - } - } - }); - } catch (Exception e) { + if (userChosenFile == null) { + throw new AlgorithmCanceledException( + "User canceled file saving when choosing the destination of the file."); + } + + Data outputDatum = + this.fileSaver.save(userChosenConverter, outData, userChosenFile); + + // TODO: Should we bother handling this? sure, why not. maybe algexec would be appropriate + if (outputDatum == null) { + return; + } + + String logMessage = String.format("Saved: %s", userChosenFile.getPath()); + this.logger.log(LogService.LOG_INFO, logMessage); + } catch (FileSaveException e) { + String logMessage = String.format( + "Error occurred while converting data to saved format:\n %s", e.getMessage()); + this.logger.log(LogService.LOG_ERROR, logMessage, e); throw new AlgorithmExecutionException(e.getMessage(), e); } } - - private void guiRun(Runnable run) { - if (Thread.currentThread() == Display.getDefault().getThread()) { - run.run(); - } else { - this.parentShell.getDisplay().syncExec(run); - } - } } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -42,6 +42,10 @@ * among several persisters that support the selected model, in the event * that more than one is found. */ +/* TODO + * If we make a file viewer service, remove this + * Otherwise move to File View algorithm + */ public class SaveDataChooser extends AbstractDialog implements AlgorithmProperty { public static final Image QUESTION_ICON = Display.getCurrent().getSystemImage(SWT.ICON_QUESTION); Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2011-02-22 18:04:19 UTC (rev 1229) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2011-03-01 20:09:46 UTC (rev 1230) @@ -2,13 +2,14 @@ import java.util.Dictionary; +import org.cishell.app.service.filesaver.FileSaverService; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.Data; -import org.cishell.service.conversion.DataConversionService; import org.osgi.service.cm.ConfigurationException; import org.osgi.service.cm.ManagedService; +import org.osgi.service.log.LogService; /** * Create a Save object @@ -20,12 +21,14 @@ public class SaveFactory implements AlgorithmFactory, ManagedService { public Algorithm createAlgorithm( Data[] data, Dictionary<String, Object> parameters, CIShellContext ciShellContext) { + // TODO Unpack data? Data inputData = data[0]; - DataConversionService conversionManager = - (DataConversionService) ciShellContext.getService( - DataConversionService.class.getName()); + LogService logger = + (LogService) ciShellContext.getService(LogService.class.getName()); + FileSaverService fileSaver = (FileSaverService) ciShellContext.getService( + FileSaverService.class.getName()); - return new Save(inputData, ciShellContext, conversionManager); + return new Save(inputData, logger, fileSaver); } @SuppressWarnings("unchecked") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2010-01-05 20:56:40
|
Revision: 1007 http://cishell.svn.sourceforge.net/cishell/?rev=1007&view=rev Author: pataphil Date: 2010-01-05 20:56:33 +0000 (Tue, 05 Jan 2010) Log Message: ----------- * Added shortcut keys to Load, Save, View, and View With operations. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/view.properties trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/viewwith.properties trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/load.properties 2010-01-05 20:56:33 UTC (rev 1007) @@ -1,6 +1,7 @@ menu_path=File/start label=Load... -description=This converter allows users to select file from the file system and load it to Data Model window +shortcut=ctrl+alt+o +description=This allows users to select file from the file system and load it to Data Model window in_data=null out_data=java.lang.Object service.pid=org.cishell.reference.gui.persistence.load.FileLoad Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.properties 2010-01-05 20:56:33 UTC (rev 1007) @@ -1,7 +1,10 @@ menu_path=File/start label=Save... +shortcut=ctrl+alt+s description=Saves data to disk in_data=java.lang.Object out_data=null service.pid=org.cishell.reference.gui.persistence.save.Save -remoteable=false +remoteable=true +prefs_published=local +receive_prefs=true \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/save.xml 2010-01-05 20:56:33 UTC (rev 1007) @@ -6,7 +6,7 @@ <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> <service> - <provide interface= - "org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface="org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface="org.osgi.service.cm.ManagedService"/> </service> </component> \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/view.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/view.properties 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/view.properties 2010-01-05 20:56:33 UTC (rev 1007) @@ -1,5 +1,6 @@ menu_path=File/additions label=View... +shortcut=ctrl+alt+v description=This algorithm does this and this... in_data=java.lang.Object out_data=null Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/viewwith.properties =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/viewwith.properties 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/viewwith.properties 2010-01-05 20:56:33 UTC (rev 1007) @@ -1,5 +1,6 @@ menu_path=File/additions label=View with... +shortcut=ctrl+alt+w description=This algorithm does this and this... in_data=java.lang.Object out_data=null Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2010-01-04 20:01:51 UTC (rev 1006) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveFactory.java 2010-01-05 20:56:33 UTC (rev 1007) @@ -7,6 +7,8 @@ import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.Data; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; import org.osgi.service.component.ComponentContext; /** @@ -16,7 +18,7 @@ * no final file:X->file-ext:* converter. * */ -public class SaveFactory implements AlgorithmFactory { +public class SaveFactory implements AlgorithmFactory, ManagedService { private CIShellContext ciShellContext; /** @@ -27,6 +29,9 @@ ciShellContext = new LocalCIShellContext(componentContext.getBundleContext()); } + + public void updated(Dictionary properties) throws ConfigurationException { + } /** * Create a Save algorithm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2010-01-05 21:19:46
|
Revision: 1008 http://cishell.svn.sourceforge.net/cishell/?rev=1008&view=rev Author: pataphil Date: 2010-01-05 21:19:39 +0000 (Tue, 05 Jan 2010) Log Message: ----------- * Removed unneeded imports. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs 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 trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.ui.prefs trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.ltk.core.refactoring.prefs Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2010-01-05 21:19:39 UTC (rev 1008) @@ -1,6 +1,6 @@ <?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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs 2010-01-05 21:19:39 UTC (rev 1008) @@ -1,12 +1,12 @@ -#Tue Jul 28 13:21:05 EDT 2009 +#Tue Jan 05 16:05:42 EST 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 +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/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.ui.prefs =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.ui.prefs (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.ui.prefs 2010-01-05 21:19:39 UTC (rev 1008) @@ -0,0 +1,3 @@ +#Tue Jan 05 16:05:42 EST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/> Added: trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.ltk.core.refactoring.prefs =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.ltk.core.refactoring.prefs (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.ltk.core.refactoring.prefs 2010-01-05 21:19:39 UTC (rev 1008) @@ -0,0 +1,3 @@ +#Tue Jan 05 16:05:42 EST 2010 +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2010-01-05 21:19:39 UTC (rev 1008) @@ -10,7 +10,6 @@ import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.BasicData; import org.cishell.framework.data.Data; -import org.cishell.service.guibuilder.GUIBuilderService; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoadFactory.java 2010-01-05 21:19:39 UTC (rev 1008) @@ -1,7 +1,6 @@ package org.cishell.reference.gui.persistence.load; import java.util.Dictionary; -import java.util.Enumeration; import java.util.Hashtable; import org.cishell.framework.CIShellContext; Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2010-01-05 21:19:39 UTC (rev 1008) @@ -1,23 +1,16 @@ package org.cishell.reference.gui.persistence.save; import java.util.Dictionary; -import java.util.Hashtable; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmExecutionException; -import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.algorithm.AlgorithmProperty; -import org.cishell.framework.data.BasicData; import org.cishell.framework.data.Data; import org.cishell.service.conversion.Converter; import org.cishell.service.conversion.DataConversionService; -import org.cishell.service.guibuilder.GUIBuilderService; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; /** * Save algorithm for persisting a data object * Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/core/DatabaseSchemaOverviewGenerator.java 2010-01-05 21:19:39 UTC (rev 1008) @@ -1,7 +1,6 @@ package org.cishell.reference.gui.persistence.view.core; import java.io.File; -import java.io.IOException; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java 2010-01-05 20:56:33 UTC (rev 1007) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWithFactory.java 2010-01-05 21:19:39 UTC (rev 1008) @@ -8,7 +8,6 @@ import org.cishell.framework.algorithm.ParameterMutator; import org.cishell.framework.data.Data; import org.cishell.reference.service.metatype.BasicAttributeDefinition; -import org.cishell.reference.service.metatype.BasicMetaTypeProvider; import org.cishell.reference.service.metatype.BasicObjectClassDefinition; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Display; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |