You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
|
Sep
(46) |
Oct
(102) |
Nov
(10) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(3) |
Mar
(14) |
Apr
(9) |
May
(12) |
Jun
(4) |
Jul
(40) |
Aug
(60) |
Sep
(38) |
Oct
(2) |
Nov
(1) |
Dec
(42) |
2008 |
Jan
(23) |
Feb
(29) |
Mar
(107) |
Apr
(27) |
May
(3) |
Jun
(1) |
Jul
(15) |
Aug
(7) |
Sep
(19) |
Oct
|
Nov
(2) |
Dec
|
2009 |
Jan
(36) |
Feb
(4) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(15) |
Jul
(30) |
Aug
(32) |
Sep
(11) |
Oct
(21) |
Nov
(12) |
Dec
(15) |
2010 |
Jan
(29) |
Feb
(9) |
Mar
(25) |
Apr
|
May
(7) |
Jun
(5) |
Jul
(21) |
Aug
(32) |
Sep
(10) |
Oct
(8) |
Nov
(29) |
Dec
(8) |
2011 |
Jan
(9) |
Feb
(35) |
Mar
(11) |
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(30) |
2012 |
Jan
(5) |
Feb
(7) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <hu...@us...> - 2008-09-04 14:41:53
|
Revision: 802 http://cishell.svn.sourceforge.net/cishell/?rev=802&view=rev Author: huangb Date: 2008-09-04 14:41:47 +0000 (Thu, 04 Sep 2008) Log Message: ----------- another fix to make sure the menu shows up properly on some Windows and Mac machines Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-29 17:07:43 UTC (rev 801) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-09-04 14:41:47 UTC (rev 802) @@ -122,8 +122,29 @@ bContext.addServiceListener(listener, filter); preprocessServiceBundles(); String app_location = System.getProperty("osgi.configuration.area"); - String fullpath = app_location.substring(6)+ DEFAULT_MENU_FILE_NAME; - if (new File(fullpath).exists()){ + /* + * This is a temporary fix. A bit complex to explain the observation + * I got so far. On Windows XP + * app_location = file:/C:/Documents and Settings/huangb/Desktop/ + * nwb-sept4/nwb/configuration/ + * If I didn't trim "file:/", on some windows machines + * new File(fileFullpath).exists() will return false, and + * initializaMenu() will be invoked. When initializaMenu() is invoked, + * not all required top menus will show up. So either Bruce code + * or Tim's fix has some problems. Can not append top menu such as + * Tools-->Scheduler if Tools is not specified in the XML + * If pass trimed file path C:/Documents and Settings/huangb/Desktop/ + * nwb-sept4/nwb/configuration/ to createMenuFromXML, on some machines, + * URL = C:/Documents and Settings/huangb/Desktop/nwb-sept4/nwb/configuration/ + * is a bad one, and can not create a document builder instance and the + * DOM representation of the XML file. + * + * This piece of code needs to be reviewed and refactored!!! + */ + System.out.println(">>>app_location = "+app_location); + String fileFullpath = app_location.substring(6)+ DEFAULT_MENU_FILE_NAME; + String fullpath = app_location+ DEFAULT_MENU_FILE_NAME; + if (new File(fileFullpath).exists() || new File(fullpath).exists()){ createMenuFromXML(fullpath); processLeftServiceBundles(); }else{ @@ -177,7 +198,8 @@ private void createMenuFromXML(String menuFilePath) throws InvalidSyntaxException{ parseXmlFile(menuFilePath); //get the root elememt - Element docEle = dom.getDocumentElement(); + Element docEle = dom.getDocumentElement(); + //get a nodelist of the top menu elements NodeList topMenuList = docEle.getElementsByTagName(TAG_TOP_MENU); if(topMenuList != null && topMenuList.getLength() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hu...@us...> - 2008-08-29 17:07:45
|
Revision: 801 http://cishell.svn.sourceforge.net/cishell/?rev=801&view=rev Author: huangb Date: 2008-08-29 17:07:43 +0000 (Fri, 29 Aug 2008) Log Message: ----------- use the new plot icon Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2008-08-22 21:11:42 UTC (rev 800) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/DataGUIItem.java 2008-08-29 17:07:43 UTC (rev 801) @@ -63,7 +63,7 @@ networkIcon = createImage("network.png", this.brandPluginID); unknownIcon = createImage("unknown.png", this.brandPluginID); textIcon = createImage("text.png", this.brandPluginID); - plotIcon = createImage("grace.png", this.brandPluginID); + plotIcon = createImage("plot.png", this.brandPluginID); typeToImageMapping = new HashMap(); registerImage(DataProperty.OTHER_TYPE, unknownIcon); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hu...@us...> - 2008-08-22 21:11:44
|
Revision: 800 http://cishell.svn.sourceforge.net/cishell/?rev=800&view=rev Author: huangb Date: 2008-08-22 21:11:42 +0000 (Fri, 22 Aug 2008) Log Message: ----------- Fix the bug that the menu didn't show up in most windows machines. Use URI to get a file path seems not work. Switch back to feed a String with the full file path to validate file location. Also System.getProperty("osgi.configuration.area") return the nwb application location starting with "file:/C:/...", have to trim first six letters. However, some Windows machine does work fine such as Bonnie's laptop. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-15 19:00:54 UTC (rev 799) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-22 21:11:42 UTC (rev 800) @@ -121,9 +121,10 @@ listener = new ContextListener(); bContext.addServiceListener(listener, filter); preprocessServiceBundles(); - URI fullpath=URI.create(System.getProperty("osgi.configuration.area") + DEFAULT_MENU_FILE_NAME); + String app_location = System.getProperty("osgi.configuration.area"); + String fullpath = app_location.substring(6)+ DEFAULT_MENU_FILE_NAME; if (new File(fullpath).exists()){ - createMenuFromXML(fullpath.toString()); + createMenuFromXML(fullpath); processLeftServiceBundles(); }else{ initializeMenu(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-08-15 19:01:00
|
Revision: 799 http://cishell.svn.sourceforge.net/cishell/?rev=799&view=rev Author: mwlinnem Date: 2008-08-15 19:00:54 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Files opened with "View..." will now have a name based on their label in the DataManager, and should usually have the correct extension (.nwb, or .net, or whatever), instead of always being .txt Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java Added: 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 (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2008-08-15 19:00:54 UTC (rev 799) @@ -0,0 +1,99 @@ +package org.cishell.reference.gui.persistence; + +import java.io.File; +import java.io.IOException; + +import org.osgi.service.log.LogService; + +public class FileUtil { + + private static int uniqueIntForTempFile = 1; + + public static File getTempFile(String fileName, String extension, LogService logger){ + File tempFile; + + if (fileName == null || fileName.equals("")) { + fileName = "unknown"; + } + + if (extension == null || extension.equals("")) { + extension = ".txt"; + } + + if (!extension.startsWith(".")) { + extension = extension + "."; + } + + String tempPath = System.getProperty("java.io.tmpdir"); + File tempDir = new File(tempPath+File.separator+"nwb"); + if(!tempDir.exists()) + tempDir.mkdir(); + try{ + tempFile = File.createTempFile(fileName, extension, tempDir); + + }catch (IOException e1){ + //failed with given file name and extension. Let's use a standard one. + logger.log(LogService.LOG_WARNING, "Failed to create temp file with provided name and extension '" + fileName + extension + "'. Trying a generic name and extension instead.", e1); + try { + tempFile = File.createTempFile("unknown", ".txt", tempDir); + } catch (IOException e2) { + //looks like it doesn't even like that. We'll have to just make a file directly. + tempFile = new File (tempPath+File.separator+"nwb"+File.separator+"unknown" + uniqueIntForTempFile + ".txt"); + uniqueIntForTempFile++; + + logger.log(LogService.LOG_ERROR, "Failed to create temp file twice..."); + logger.log(LogService.LOG_ERROR, "First Try... \r\n " + e1.toString()); + logger.log(LogService.LOG_ERROR, "Second Try... \r\n " + e2.toString()); + } + } + return tempFile; + } + + public static String extractExtension(String format) { + String extension = ""; + //TODO: We should really have explicit piece of metadata that says what the extension is, + //TODO: as this method is not guaranteed to yield the correct extension + if (format.startsWith("file:text/")) { + extension = "." + format.substring("file:text/".length()); + } else if (format.startsWith("file-ext:")) { + extension = "." + format.substring("file-ext:".length()); + } + + extension = extension.replace('+', '.'); + + return extension; + } + + public static String extractFileName(String fileLabel) { + + //index variables will be -1 if index is not found. + int descriptionEndIndex = fileLabel.lastIndexOf(":"); + int filePathEndIndex = fileLabel.lastIndexOf(File.separator); + + //doesn't matter if either variable is -1, since startIndex will be + //zero and none of the string will be cut off the front. + int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1; + + String fileNameWithExtension = fileLabel.substring(startIndex); + + + //find the first character of the file name extension. + int extensionBeginIndex = fileNameWithExtension.lastIndexOf("."); + + int endIndex; + + if (extensionBeginIndex != -1) { + //we found a period in the file name. + endIndex = extensionBeginIndex; //cut off everything after + //first period. + } else { + //we didn't find an extension on the file name. + endIndex = fileNameWithExtension.length(); // don't cut any off the end. + } + + String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex); + + String fileName = fileNameWithoutExtension; + return fileName; + } +} Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2008-08-13 17:14:47 UTC (rev 798) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2008-08-15 19:00:54 UTC (rev 799) @@ -13,6 +13,7 @@ import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; +import org.cishell.reference.gui.persistence.FileUtil; import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.cishell.service.guibuilder.GUIBuilderService; @@ -112,7 +113,7 @@ dialog.setText("Choose File"); String fileLabel = (String)data.getMetadata().get(DataProperty.LABEL); - String suggestedFileName = getFileName(fileLabel); + String suggestedFileName = FileUtil.extractFileName(fileLabel); dialog.setFileName(suggestedFileName + "." + ext); // if (fileLabel == null) { @@ -185,36 +186,5 @@ } } - private String getFileName(String fileLabel) { - - //index variables will be -1 if index is not found. - int descriptionEndIndex = fileLabel.lastIndexOf(":"); - int filePathEndIndex = fileLabel.lastIndexOf(File.separator); - - //doesn't matter if either variable is -1, since startIndex will be - //zero and none of the string will be cut off the front. - int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1; - - String fileNameWithExtension = fileLabel.substring(startIndex); - - - //find the first character of the file name extension. - int extensionBeginIndex = fileNameWithExtension.lastIndexOf("."); - - int endIndex; - - if (extensionBeginIndex != -1) { - //we found a period in the file name. - endIndex = extensionBeginIndex; //cut off everything after - //first period. - } else { - //we didn't find an extension on the file name. - endIndex = fileNameWithExtension.length(); // don't cut any off the end. - } - - String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex); - - String fileName = fileNameWithoutExtension; - return fileName; - } + } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2008-08-13 17:14:47 UTC (rev 798) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2008-08-15 19:00:54 UTC (rev 799) @@ -11,10 +11,11 @@ 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.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.cishell.service.conversion.DataConversionService; -import org.cishell.service.guibuilder.GUIBuilderService; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -45,87 +46,55 @@ logger = (LogService)context.getService(LogService.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()) - tempDir.mkdir(); - try{ - tempFile = File.createTempFile("xxx-Session-", ".txt", tempDir); - - }catch (IOException e){ - logger.log(LogService.LOG_ERROR, e.toString()); - tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.txt"); - } - return tempFile; - } - - public File getTempFileCSV(){ //TC181 - 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()); - tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.csv"); - - } - return tempFile; - } - + //show the contents of a file to the user public Data[] execute() throws AlgorithmExecutionException { try { boolean lastSaveSuccessful = false; - boolean isCSVFile = false;//TC181 + boolean isCSVFile = false; String format; - Display display; - IWorkbenchWindow[] windows; - final Shell parentShell; + //tempFile = getTempFile(); TC181 - windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - if (windows.length == 0){ - throw new AlgorithmExecutionException("Cannot get workbench window."); - } - parentShell = windows[0].getShell(); - display = PlatformUI.getWorkbench().getDisplay(); - //tempFile = getTempFile(); TC181 + //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("file:text/") || format.startsWith("file-ext:")){ + //if it is a csv text file... if (format.startsWith("file:text/csv") || format.startsWith("file-ext:csv")) { + //prepare to open it like a csv file tempFile = getTempFileCSV(); isCSVFile = true; } - else - { - tempFile = getTempFile(); + else //it is just a regular text file + { + //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{ + }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], "file-ext:csv"); - //logger.log(LogService.LOG_ERROR, "convertersCSV's length = " + convertersCSV.length); + + //if the data item can be converted to a csv file ... do it. if (convertersCSV.length == 1) { Data newDataCSV = convertersCSV[0].convert(data[i]); @@ -146,41 +115,69 @@ isCSVFile = true; copy((File)newDataCSV.getData(), tempFile); lastSaveSuccessful = true; - } - else{ + } else { //it cannot be converted to a .csv + + //try to convert it to any other file format + final Converter[] converters = conversionManager.findConverters(data[i], "file-ext:*"); + //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 length=1, use the unique path to save it directly - //and bring the text editor. - Data newData = converters[0].convert(data[i]); - tempFile = getTempFile(); + 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 { + 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.theFile; + 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 - { + }else + {//it's any other file + //prepare to open it with the standard text editor. Display.getDefault().syncExec(new Runnable() { public void run() { program = Program.findProgram("txt"); @@ -201,14 +198,18 @@ } */ + + //if we can't find any program to open the file... if (program == null) { + //throw an error 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 { + else {//we found a program to open the file + //open it, for real. if (lastSaveSuccessful == true) { Display.getDefault().syncExec(new Runnable() { public void run() { @@ -216,9 +217,6 @@ }}); } } - - - } return null; } catch (ConversionException e1) { @@ -228,6 +226,24 @@ } } + public File getTempFileCSV(){ //TC181 + 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()); + 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); @@ -250,8 +266,8 @@ final class DataViewer implements Runnable { Shell shell; boolean isSaved; + File outputFile; Data theData; - File theFile = getTempFile(); Converter[] theConverters; DataViewer (Shell parentShell, Data data, Converter[] converters){ @@ -262,10 +278,11 @@ public void run() { // lots of persisters found, return the chooser - ViewDataChooser vdc = new ViewDataChooser("View", theFile, shell, - theData, theConverters, context); + ViewDataChooser vdc = new ViewDataChooser("View", shell, + theData, theConverters, context, logger); vdc.open(); isSaved = vdc.isSaved(); + outputFile = vdc.outputFile; } } 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 2008-08-13 17:14:47 UTC (rev 798) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 2008-08-15 19:00:54 UTC (rev 799) @@ -4,25 +4,29 @@ 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.save.SaveDataChooser; import org.cishell.service.conversion.Converter; import org.eclipse.swt.widgets.Shell; +import org.osgi.service.log.LogService; /* * @author Weixia(Bonnie) Huang (hu...@in...) * */ public class ViewDataChooser extends SaveDataChooser { - private File tempFile; boolean isSaved = false; + LogService logger; Data theData; + File outputFile; - public ViewDataChooser(String title, File tempFile, Shell parent, - Data data, Converter[] converters, CIShellContext context){ + public ViewDataChooser(String title, Shell parent, + Data data, Converter[] converters, CIShellContext context, LogService logger){ super (data, parent, converters, title, context); - this.tempFile = tempFile; this.theData = data; + this.logger = logger; } protected void selectionMade(int selectedIndex){ @@ -30,7 +34,12 @@ getShell().setVisible(false); final Converter converter = converterArray[selectedIndex]; Data newData = converter.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); isSaved = FileView.copy((File)newData.getData(), tempFile); + outputFile = tempFile; close(true); } catch (Exception e) { throw new RuntimeException(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-08-13 17:14:53
|
Revision: 798 http://cishell.svn.sourceforge.net/cishell/?rev=798&view=rev Author: mwlinnem Date: 2008-08-13 17:14:47 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Minor change to error message. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-13 17:09:07 UTC (rev 797) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-13 17:14:47 UTC (rev 798) @@ -313,7 +313,7 @@ getLog().log(LogService.LOG_DEBUG, "Oops! Network Workbench tried to place an algorithm with the id '" + pid + "' on the menu, but the algorithm could not be found."); getLog().log(LogService.LOG_DEBUG, "If you see this error, please contact nwb...@go..., or post a ticket on our bug tracker at " + - "http://cns-trac.slis.indiana.edu/trac/nwb. "); + "http://cns-trac.slis.indiana.edu/trac/nwb ."); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-08-13 17:09:14
|
Revision: 797 http://cishell.svn.sourceforge.net/cishell/?rev=797&view=rev Author: mwlinnem Date: 2008-08-13 17:09:07 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Improved the error message for when an algorithm specified in the menu.xml file cannot be found. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-05 18:19:56 UTC (rev 796) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-13 17:09:07 UTC (rev 797) @@ -311,8 +311,9 @@ else{ //otherwise log the error getLog().log(LogService.LOG_DEBUG, - "Can not find an algorithm package associated with Menu: " - +menuName+" and pid: " +pid+ ". Skip to show it on the menu."); + "Oops! Network Workbench tried to place an algorithm with the id '" + pid + "' on the menu, but the algorithm could not be found."); + getLog().log(LogService.LOG_DEBUG, "If you see this error, please contact nwb...@go..., or post a ticket on our bug tracker at " + + "http://cns-trac.slis.indiana.edu/trac/nwb. "); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-08-05 18:20:02
|
Revision: 796 http://cishell.svn.sourceforge.net/cishell/?rev=796&view=rev Author: mwlinnem Date: 2008-08-05 18:19:56 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Now handles error case for when AlgorithmFactory cannot be created. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-08-01 18:19:19 UTC (rev 795) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-08-05 18:19:56 UTC (rev 796) @@ -52,241 +52,251 @@ import org.osgi.service.metatype.MetaTypeService; import org.osgi.service.metatype.ObjectClassDefinition; - public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable { - protected ServiceReference ref; - protected BundleContext bContext; - protected CIShellContext ciContext; - protected Data[] originalData; - protected Data[] data; - protected Converter[][] converters; - protected ProgressMonitor progressMonitor; - protected Algorithm algorithm; - - public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, - CIShellContext ciContext, Data[] originalData, Data[] data, - Converter[][] converters) { - this.ref = ref; - this.bContext = bContext; - this.ciContext = ciContext; - this.originalData = originalData; - this.data = data; - this.converters = converters; - this.progressMonitor = null; - } + protected ServiceReference ref; + protected BundleContext bContext; + protected CIShellContext ciContext; + protected Data[] originalData; + protected Data[] data; + protected Converter[][] converters; + protected ProgressMonitor progressMonitor; + protected Algorithm algorithm; - /** - * @see org.cishell.framework.algorithm.Algorithm#execute() - */ - public Data[] execute() { - AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref); - String pid = (String)ref.getProperty(Constants.SERVICE_PID); - - // convert input data to the correct format - boolean conversionSuccessful = tryConvertingDataToRequiredFormat(data, converters); - if (!conversionSuccessful) return null; - boolean inputIsValid = testDataValidityIfPossible(factory, data); - if (!inputIsValid) return null; - - // create algorithm parameters - String metatype_pid = getMetaTypeID(ref); - - MetaTypeProvider provider = getPossiblyMutatedMetaTypeProvider(metatype_pid, pid, factory); - Dictionary parameters = getUserEnteredParameters(metatype_pid, provider); - - // check to see if the user cancelled the operation - if(parameters == null) return null; - - printParameters(metatype_pid, provider, parameters); - - // create the algorithm - algorithm = createAlgorithm(factory, data, parameters, ciContext); - if (algorithm == null) return null; - trackAlgorithmIfPossible(algorithm); - - // execute the algorithm - Data[] outData = tryExecutingAlgorithm(algorithm); - if (outData == null) return null; - - // process and return the algorithm's output - doParentage(outData); - outData = removeNullData(outData); - addDataToDataManager(outData); + public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, + Data[] originalData, Data[] data, Converter[][] converters) { + this.ref = ref; + this.bContext = bContext; + this.ciContext = ciContext; + this.originalData = originalData; + this.data = data; + this.converters = converters; + this.progressMonitor = null; + } - return outData; - } - - protected Algorithm createAlgorithm(AlgorithmFactory factory, Data[] data, Dictionary parameters, CIShellContext ciContext) { - try { - return factory.createAlgorithm(data, parameters, ciContext); - } catch (Exception e) { - String errorMessage = "Unexpected error occurred while creating algorithm " + - " \""+ref.getProperty(AlgorithmProperty.LABEL)+".\""; - GUIBuilderService builder = (GUIBuilderService) - ciContext.getService(GUIBuilderService.class.getName()); - builder.showError("Error!", errorMessage, e); - log(LogService.LOG_ERROR, errorMessage, e); - return null; - } - } - - protected Data[] removeNullData(Data[] outData) { - if (outData != null) { - List goodData = new ArrayList(); - for (int i=0; i < outData.length; i++) { - if (outData[i] != null) { - goodData.add(outData[i]); - } - } - - outData = (Data[]) goodData.toArray(new Data[0]); - } - - return outData; - } - - protected void addDataToDataManager(Data[] outData) { - if (outData != null) { - DataManagerService dataManager = (DataManagerService) - bContext.getService(bContext.getServiceReference( - DataManagerService.class.getName())); - - if (outData.length != 0) { - dataManager.setSelectedData(outData); - } - } - } - - protected Data[] tryExecutingAlgorithm(Algorithm algorithm) { - Data[] outData = null; - try { - outData = algorithm.execute(); - } catch (AlgorithmExecutionException e) { - log(LogService.LOG_ERROR, - "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+ - "\" had an error while executing: "+e.getMessage()); - } catch (RuntimeException e) { - GUIBuilderService builder = (GUIBuilderService) - ciContext.getService(GUIBuilderService.class.getName()); - - builder.showError("Error!", "An unexpected exception occurred while " - +"executing \""+ref.getProperty(AlgorithmProperty.LABEL)+".\"", e); - } - - return outData; - } - - protected boolean tryConvertingDataToRequiredFormat(Data[] data, Converter[][] converters) { - for (int i=0; i < data.length; i++) { - if (converters[i] != null) { - try { - data[i] = converters[i][0].convert(data[i]); - } catch (ConversionException e) { - log(LogService.LOG_ERROR,"The conversion of data to give" + - " the algorithm failed for this reason: "+e.getMessage(), e); - return false; - } + /** + * @see org.cishell.framework.algorithm.Algorithm#execute() + */ + public Data[] execute() { + AlgorithmFactory factory = getAlgorithmFactory(bContext, ref); + if (factory == null) return null; + String pid = (String) ref.getProperty(Constants.SERVICE_PID); - if (data[i] == null && i < (data.length - 1)) { - log(LogService.LOG_ERROR, "The converter: " + - converters[i].getClass().getName() + - " returned a null result where data was expected when" + - " converting the data to give the algorithm."); - return false; - } - converters[i] = null; - } - } - - return true; - } - - protected boolean testDataValidityIfPossible(AlgorithmFactory factory, Data[] data) { - if (factory instanceof DataValidator) { - String validation = ((DataValidator) factory).validate(data); - - if (validation != null && validation.length() > 0) { - String label = (String) ref.getProperty(LABEL); - if (label == null) { - label = "Algorithm"; - } - - log(LogService.LOG_ERROR,"INVALID DATA: The data given to \""+label+"\" is incompatible for this reason: "+validation); - return false; - } - } - - return true; - } - - protected String getMetaTypeID(ServiceReference ref) { - String pid = (String)ref.getProperty(Constants.SERVICE_PID); - String metatype_pid = (String) ref.getProperty(PARAMETERS_PID); - - if (metatype_pid == null) { - metatype_pid = pid; - } - - return metatype_pid; - } - - protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatypePID, String pid, AlgorithmFactory factory) { - MetaTypeProvider provider = null; - MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); - if (metaTypeService != null) { - provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); - } + // convert input data to the correct format + boolean conversionSuccessful = tryConvertingDataToRequiredFormat(data, converters); + if (!conversionSuccessful) return null; + boolean inputIsValid = testDataValidityIfPossible(factory, data); + if (!inputIsValid) return null; - if (factory instanceof ParameterMutator && provider != null) { - try { - ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatypePID, null); - if (ocd == null) logNullOCDWarning(pid, metatypePID); - ocd = ((ParameterMutator) factory).mutateParameters(data, ocd); - if (ocd != null) { - provider = new BasicMetaTypeProvider(ocd); - } - } catch (IllegalArgumentException e) { - log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatypePID); - } catch (Exception e) { - GUIBuilderService builder = (GUIBuilderService) - ciContext.getService(GUIBuilderService.class.getName()); - String errorMessage = "An error occurred while preparing to run the algorithm " - +ref.getProperty(AlgorithmProperty.LABEL)+".\""; - builder.showError("Error!", errorMessage, e); - log(LogService.LOG_ERROR, errorMessage, e); - } - } - - if (provider != null) { - provider = wrapProvider(ref, provider); - } - - return provider; - } - - protected void trackAlgorithmIfPossible(Algorithm algorithm) { - if (progressMonitor != null && algorithm instanceof ProgressTrackable) { - ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor); - } - } - - protected Dictionary getUserEnteredParameters(String metatype_pid, MetaTypeProvider provider) { - Dictionary parameters = new Hashtable(); - if (provider != null) { - GUIBuilderService builder = (GUIBuilderService) - ciContext.getService(GUIBuilderService.class.getName()); - - parameters = builder.createGUIandWait(metatype_pid, provider); - } - - return parameters; - } - + // create algorithm parameters + String metatype_pid = getMetaTypeID(ref); + + MetaTypeProvider provider = getPossiblyMutatedMetaTypeProvider(metatype_pid, pid, factory); + Dictionary parameters = getUserEnteredParameters(metatype_pid, provider); + + // check to see if the user cancelled the operation + if (parameters == null) return null; + + printParameters(metatype_pid, provider, parameters); + + // create the algorithm + algorithm = createAlgorithm(factory, data, parameters, ciContext); + if (algorithm == null) return null; + trackAlgorithmIfPossible(algorithm); + + // execute the algorithm + Data[] outData = tryExecutingAlgorithm(algorithm); + if (outData == null) return null; + + // process and return the algorithm's output + doParentage(outData); + outData = removeNullData(outData); + addDataToDataManager(outData); + + return outData; + } + + protected AlgorithmFactory getAlgorithmFactory(BundleContext bContext, ServiceReference ref) { + AlgorithmFactory algorithmFactory = (AlgorithmFactory) bContext.getService(ref); + if (algorithmFactory == null) { + String errorMessage = "Could not create AlgorithmFactory for the algorithm " + "\"" + + ref.getProperty(AlgorithmProperty.LABEL) + "\"."; + String details = "The algorithm's pid was \"" + ref.getProperty(Constants.SERVICE_PID) + + "\" (potentially useful for debugging purposes)."; + GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + builder.showError("Error!", errorMessage, details); + log(LogService.LOG_ERROR, errorMessage); + } + + return algorithmFactory; + } + + protected Algorithm createAlgorithm(AlgorithmFactory factory, Data[] data, Dictionary parameters, + CIShellContext ciContext) { + try { + return factory.createAlgorithm(data, parameters, ciContext); + } catch (Exception e) { + String errorMessage = "Unexpected error occurred while creating algorithm " + " \"" + + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; + GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + builder.showError("Error!", errorMessage, e); + log(LogService.LOG_ERROR, errorMessage, e); + return null; + } + } + + protected Data[] removeNullData(Data[] outData) { + if (outData != null) { + List goodData = new ArrayList(); + for (int i = 0; i < outData.length; i++) { + if (outData[i] != null) { + goodData.add(outData[i]); + } + } + + outData = (Data[]) goodData.toArray(new Data[0]); + } + + return outData; + } + + protected void addDataToDataManager(Data[] outData) { + if (outData != null) { + DataManagerService dataManager = (DataManagerService) bContext.getService(bContext + .getServiceReference(DataManagerService.class.getName())); + + if (outData.length != 0) { + dataManager.setSelectedData(outData); + } + } + } + + protected Data[] tryExecutingAlgorithm(Algorithm algorithm) { + Data[] outData = null; + try { + outData = algorithm.execute(); + } catch (AlgorithmExecutionException e) { + log(LogService.LOG_ERROR, "The Algorithm: \"" + ref.getProperty(AlgorithmProperty.LABEL) + + "\" had an error while executing: " + e.getMessage()); + } catch (RuntimeException e) { + GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + + builder.showError("Error!", "An unexpected exception occurred while " + "executing \"" + + ref.getProperty(AlgorithmProperty.LABEL) + ".\"", e); + } + + return outData; + } + + protected boolean tryConvertingDataToRequiredFormat(Data[] data, Converter[][] converters) { + for (int i = 0; i < data.length; i++) { + if (converters[i] != null) { + try { + data[i] = converters[i][0].convert(data[i]); + } catch (ConversionException e) { + log(LogService.LOG_ERROR, "The conversion of data to give" + + " the algorithm failed for this reason: " + e.getMessage(), e); + return false; + } + + if (data[i] == null && i < (data.length - 1)) { + log(LogService.LOG_ERROR, "The converter: " + converters[i].getClass().getName() + + " returned a null result where data was expected when" + + " converting the data to give the algorithm."); + return false; + } + converters[i] = null; + } + } + + return true; + } + + protected boolean testDataValidityIfPossible(AlgorithmFactory factory, Data[] data) { + if (factory instanceof DataValidator) { + String validation = ((DataValidator) factory).validate(data); + + if (validation != null && validation.length() > 0) { + String label = (String) ref.getProperty(LABEL); + if (label == null) { + label = "Algorithm"; + } + + log(LogService.LOG_ERROR, "INVALID DATA: The data given to \"" + label + + "\" is incompatible for this reason: " + validation); + return false; + } + } + + return true; + } + + protected String getMetaTypeID(ServiceReference ref) { + String pid = (String) ref.getProperty(Constants.SERVICE_PID); + String metatype_pid = (String) ref.getProperty(PARAMETERS_PID); + + if (metatype_pid == null) { + metatype_pid = pid; + } + + return metatype_pid; + } + + protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatypePID, String pid, + AlgorithmFactory factory) { + MetaTypeProvider provider = null; + MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); + if (metaTypeService != null) { + provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); + } + + if (factory instanceof ParameterMutator && provider != null) { + try { + ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatypePID, null); + if (ocd == null) logNullOCDWarning(pid, metatypePID); + ocd = ((ParameterMutator) factory).mutateParameters(data, ocd); + if (ocd != null) { + provider = new BasicMetaTypeProvider(ocd); + } + } catch (IllegalArgumentException e) { + log(LogService.LOG_DEBUG, pid + " has an invalid metatype id: " + metatypePID); + } catch (Exception e) { + GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + String errorMessage = "An error occurred while preparing to run the algorithm " + + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; + builder.showError("Error!", errorMessage, e); + log(LogService.LOG_ERROR, errorMessage, e); + } + } + + if (provider != null) { + provider = wrapProvider(ref, provider); + } + + return provider; + } + + protected void trackAlgorithmIfPossible(Algorithm algorithm) { + if (progressMonitor != null && algorithm instanceof ProgressTrackable) { + ((ProgressTrackable) algorithm).setProgressMonitor(progressMonitor); + } + } + + protected Dictionary getUserEnteredParameters(String metatype_pid, MetaTypeProvider provider) { + Dictionary parameters = new Hashtable(); + if (provider != null) { + GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + + parameters = builder.createGUIandWait(metatype_pid, provider); + } + + return parameters; + } + // wrap the provider to provide special functionality, such as overriding default values of attributes through // preferences. protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) { ConfigurationAdmin ca = getConfigurationAdmin(); - + if (ca != null && hasParamDefaultPreferences(algRef)) { String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID); String paramOverrideConfPID = standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX; @@ -304,7 +314,7 @@ return unwrappedProvider; } - + protected boolean hasParamDefaultPreferences(ServiceReference algRef) { String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); if (prefsToPublish == null) { @@ -313,147 +323,141 @@ return prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE); } - - protected void log(int logLevel, String message) { - LogService log = (LogService) ciContext.getService(LogService.class.getName()); - if (log != null) { - log.log(logLevel, message); - } else { - System.out.println(message); - } - } - protected void log(int logLevel, String message, Throwable exception) { - LogService log = (LogService) ciContext.getService(LogService.class.getName()); - if (log != null) { - log.log(logLevel, message, exception); - } else { - System.out.println(message); - exception.printStackTrace(); - } - } - - protected void printParameters(String metatype_pid, MetaTypeProvider provider, Dictionary parameters) { - LogService logger = getLogService(); - Map idToLabelMap = setupIdToLabelMap(metatype_pid, provider); - - if (logger != null && !parameters.isEmpty()) { - //adjust to log all input parameters in one block - StringBuffer inputParams = new StringBuffer("\n"+"Input Parameters:"); - - for (Enumeration e = parameters.keys(); e - .hasMoreElements();) { - String key = (String) e.nextElement(); - Object value = parameters.get(key); - - key = (String) idToLabelMap.get(key); - inputParams.append("\n"+key+": "+value); - - } - logger.log(LogService.LOG_INFO, inputParams.toString()); - } - } - - protected Map setupIdToLabelMap(String metatype_pid, MetaTypeProvider provider) { - Map idToLabelMap = new HashMap(); - if (provider != null) { - ObjectClassDefinition ocd = null; - try { - ocd = provider.getObjectClassDefinition(metatype_pid, null); - - if (ocd != null) { - AttributeDefinition[] attr = - ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - - for (int i=0; i < attr.length; i++) { - String id = attr[i].getID(); - String label = attr[i].getName(); - - idToLabelMap.put(id, label); - } - } - } catch (IllegalArgumentException e) {} - } - - return idToLabelMap; - } - - //only does anything if parentage=default so far... - protected void doParentage(Data[] outData) { - //make sure the parent set is the original Data and not the - //converted data... - if (outData != null && data != null && originalData != null - && originalData.length == data.length) { - for (int i=0; i < outData.length; i++) { - if (outData[i] != null) { - Object parent = outData[i].getMetadata().get(DataProperty.PARENT); - - if (parent != null) { - for (int j=0; j < data.length; j++) { - if (parent == data[j]) { - outData[i].getMetadata().put(DataProperty.PARENT, - originalData[j]); - break; - } - } - } - } - } - } - - //check and act on parentage settings - String parentage = (String)ref.getProperty("parentage"); - if (parentage != null) { - parentage = parentage.trim(); - if (parentage.equalsIgnoreCase("default")) { - if (originalData != null && originalData.length > 0 && originalData[0] != null) { - - for (int i=0; i < outData.length; i++) { - //if they don't have a parent set already then we set one - if (outData[i] != null && - outData[i].getMetadata().get(DataProperty.PARENT) == null) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); - } - } - } - } - } - } - + protected void log(int logLevel, String message) { + LogService log = (LogService) ciContext.getService(LogService.class.getName()); + if (log != null) { + log.log(logLevel, message); + } else { + System.out.println(message); + } + } + + protected void log(int logLevel, String message, Throwable exception) { + LogService log = (LogService) ciContext.getService(LogService.class.getName()); + if (log != null) { + log.log(logLevel, message, exception); + } else { + System.out.println(message); + exception.printStackTrace(); + } + } + + protected void printParameters(String metatype_pid, MetaTypeProvider provider, Dictionary parameters) { + LogService logger = getLogService(); + Map idToLabelMap = setupIdToLabelMap(metatype_pid, provider); + + if (logger != null && !parameters.isEmpty()) { + // adjust to log all input parameters in one block + StringBuffer inputParams = new StringBuffer("\n" + "Input Parameters:"); + + for (Enumeration e = parameters.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + Object value = parameters.get(key); + + key = (String) idToLabelMap.get(key); + inputParams.append("\n" + key + ": " + value); + + } + logger.log(LogService.LOG_INFO, inputParams.toString()); + } + } + + protected Map setupIdToLabelMap(String metatype_pid, MetaTypeProvider provider) { + Map idToLabelMap = new HashMap(); + if (provider != null) { + ObjectClassDefinition ocd = null; + try { + ocd = provider.getObjectClassDefinition(metatype_pid, null); + + if (ocd != null) { + AttributeDefinition[] attr = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); + + for (int i = 0; i < attr.length; i++) { + String id = attr[i].getID(); + String label = attr[i].getName(); + + idToLabelMap.put(id, label); + } + } + } catch (IllegalArgumentException e) { + } + } + + return idToLabelMap; + } + + // only does anything if parentage=default so far... + protected void doParentage(Data[] outData) { + // make sure the parent set is the original Data and not the + // converted data... + if (outData != null && data != null && originalData != null && originalData.length == data.length) { + for (int i = 0; i < outData.length; i++) { + if (outData[i] != null) { + Object parent = outData[i].getMetadata().get(DataProperty.PARENT); + + if (parent != null) { + for (int j = 0; j < data.length; j++) { + if (parent == data[j]) { + outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]); + break; + } + } + } + } + } + } + + // check and act on parentage settings + String parentage = (String) ref.getProperty("parentage"); + if (parentage != null) { + parentage = parentage.trim(); + if (parentage.equalsIgnoreCase("default")) { + if (originalData != null && originalData.length > 0 && originalData[0] != null) { + + for (int i = 0; i < outData.length; i++) { + // if they don't have a parent set already then we set one + if (outData[i] != null && outData[i].getMetadata().get(DataProperty.PARENT) == null) { + outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); + } + } + } + } + } + } + private LogService getLogService() { ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName()); LogService log = null; - + if (serviceReference != null) { - log = (LogService) bContext.getService( - bContext.getServiceReference(LogService.class.getName())); + log = (LogService) bContext.getService(bContext.getServiceReference(LogService.class.getName())); } - + return log; } - + private ConfigurationAdmin getConfigurationAdmin() { ServiceReference serviceReference = bContext.getServiceReference(ConfigurationAdmin.class.getName()); ConfigurationAdmin ca = null; - + if (serviceReference != null) { - ca = (ConfigurationAdmin) bContext.getService( - bContext.getServiceReference(ConfigurationAdmin.class.getName())); + ca = (ConfigurationAdmin) bContext.getService(bContext.getServiceReference(ConfigurationAdmin.class + .getName())); } - + return ca; } - + private void logNullOCDWarning(String pid, String metatype_pid) { - this.log(LogService.LOG_WARNING, - "Warning: could not get object class definition '" + metatype_pid + "' from the algorithm '" + pid + "'"); + this.log(LogService.LOG_WARNING, "Warning: could not get object class definition '" + metatype_pid + + "' from the algorithm '" + pid + "'"); } public ProgressMonitor getProgressMonitor() { if (algorithm instanceof ProgressTrackable) { return progressMonitor; - } - else { + } else { return null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hu...@us...> - 2008-08-01 18:19:27
|
Revision: 795 http://cishell.svn.sourceforge.net/cishell/?rev=795&view=rev Author: huangb Date: 2008-08-01 18:19:19 +0000 (Fri, 01 Aug 2008) Log Message: ----------- stick to Java 1.4.2 APIs, otherwise the compilation will fail. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-07-30 17:33:06 UTC (rev 794) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-08-01 18:19:19 UTC (rev 795) @@ -289,14 +289,14 @@ pidToServiceReferenceMap.remove(pid.toLowerCase().trim()); AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); String menuLabel = (String)ref.getProperty(LABEL); - if(menuName!= null && !menuName.isEmpty()){ + if(menuName!= null && menuName.trim().length()>0){ //use the name specified in the xml to overwrite the label action.setText(menuName); action.setId(getItemID(ref)); parentMenuBar.add(action); } else{ - if (menuLabel!= null && !menuLabel.isEmpty()){ + if (menuLabel!= null && menuLabel.trim().length()>0){ action.setText(menuLabel); action.setId(getItemID(ref)); parentMenuBar.add(action); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 794 http://cishell.svn.sourceforge.net/cishell/?rev=794&view=rev Author: mwlinnem Date: 2008-07-30 17:33:06 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Added explanatory comment. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2008-07-30 16:56:25 UTC (rev 793) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2008-07-30 17:33:06 UTC (rev 794) @@ -58,6 +58,10 @@ } public boolean performFinish() { + + //prepare all the files necessary to call the 3-argument version of performFinish, which executes + //each of the templates we provided in the "createTemplateSections()" method above. + final IProject project = template.getProjectHandle(); final IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 793 http://cishell.svn.sourceforge.net/cishell/?rev=793&view=rev Author: mwlinnem Date: 2008-07-30 16:56:25 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Added explanatory comment. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2008-07-30 16:35:18 UTC (rev 792) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2008-07-30 16:56:25 UTC (rev 793) @@ -92,6 +92,8 @@ e.printStackTrace(); } + //display the README file to the user in Eclipse + final IFile file = template.getProjectHandle().getFile("README.txt"); final IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); final IWorkbenchPage page = ww.getActivePage(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-30 16:35:25
|
Revision: 792 http://cishell.svn.sourceforge.net/cishell/?rev=792&view=rev Author: mwlinnem Date: 2008-07-30 16:35:18 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Added necessary files to template. Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ant.sh trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml Removed Paths: ------------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/sample_algorithm/ Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ant.sh =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ant.sh (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ant.sh 2008-07-30 16:35:18 UTC (rev 792) @@ -0,0 +1,3 @@ +#!/bin/sh + +ANT_HOME=$PWD lib/ant-bin/ant $@ Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml 2008-07-30 16:35:18 UTC (rev 792) @@ -0,0 +1,56 @@ +<!-- This file in almost all cases will not need edited --> +<project name="Static Executable Integration Template" basedir="." default="compile"> + <property file="manifest.properties"/> + + <property name="repository.dir" value="${basedir}"/> + <property name="build.dir" value="${repository.dir}/build"/> + <property name="lib.dir" value="${repository.dir}/lib"/> + <property name="out.dir" value="${build.dir}/out"/> + <property name="global.properties" value="${repository.dir}/manifest.properties"/> + <property name="gui.file" value="${repository.dir}/gui.xml"/> + <property name="dest.gui.file" value="${out.dir}/OSGI-INF/metatype/METADATA.XML"/> + <property name="l10n.dir" value="${repository.dir}/l10n" /> + <property name="dest.l10n.dir" value="${out.dir}/OSGI-INF/l10n"/> + <property name="template.file" value="${lib.dir}/component.xml"/> + + <target name="compile" depends="copy.files" + description="Compile an OSGi Bundle of the Static Executable"> + + <createManifest basedir="${out.dir}" + baseproperties="${global.properties}" + template="${template.file}"/> + + <copy file="${gui.file}" tofile="${dest.gui.file}" failonerror="false"/> + + <copy todir="${dest.l10n.dir}"> + <fileset dir="${l10n.dir}"/> + </copy> + + <jar destfile="${build.dir}/${Bundle-SymbolicName}_${Bundle-Version}.jar" + basedir="${out.dir}" manifest="${out.dir}/META-INF/MANIFEST.MF"/> + </target> + + <target name="copy.files" description="Copying files" depends="tasks.init"> + <copy todir="${out.dir}"> + <fileset dir="${repository.dir}"> + <include name="**/*"/> + <exclude name="${lib.dir},${build.dir},${l10n.dir}"/> + <exclude name="l10n/**/*"/> + <exclude name="build/**/*"/> + <exclude name="lib/**/*"/> + <exclude name="src/**/*"/> + <exclude name="*"/> + </fileset> + </copy> + </target> + + <target name="tasks.init" description="Initialize TaskDefinitions"> + <taskdef name="createManifest" + classname="org.cishell.templates.staticexecutable.StaticExecutableIntegrationTask" + classpath="${lib.dir}/cishell_templates.jar"/> + </target> + + <target name="clean" description="Clean build directory"> + <delete dir="${build.dir}"/> + </target> +</project> \ 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: <hu...@us...> - 2008-07-29 21:35:29
|
Revision: 791 http://cishell.svn.sourceforge.net/cishell/?rev=791&view=rev Author: huangb Date: 2008-07-29 21:35:26 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Make the following fix. 1. If there's no default_menu.xml under {nwb_installation_dir}/configuration, the tool should not crash and should display all plug-ins that have been specified menu_path and label in the properties files. Note: in this case, there's no control of the order of top menu and submenus. It completely depends on which plug-in has been loaded first when the tool starts up every time. 2. If there's a default_menu.xml under {nwb_installation_dir}/configuration, use it for constructing the layout of the top menu and submenus. However, there's a preference about what name/label should show up on the menu. 2.1)If an alg's properties file has specified the label, and the corresponding name in the default_menu xml file (share the same pid) is not specified or blank, use the label specified in the properties file. If the name in the xml is not blank, use the name to overwrite the label. If both the label in the properties file and the name in the xml file are blank, this is an error that need to be fixed. 2.2)If an alg didn't specified in the xml file, use the menu_path and label in the properties file to add this alg to the menu. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-07-25 21:00:08 UTC (rev 790) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-07-29 21:35:26 UTC (rev 791) @@ -14,9 +14,12 @@ package org.cishell.reference.gui.menumanager.menu; import java.io.IOException; +import java.io.File; import java.util.HashMap; import java.util.Map; +import java.net.URI; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -63,9 +66,21 @@ /* * This map holds a pid as a key and the corresponding - * ServiceReference as a value. + * ServiceReference as a value. It is built when + * preprocessServiceBundles() is invoked. Then the entries + * are gradually removed when the pids are specified in + * the defaul_menu.xml. If any entries are left, in + * processLeftServiceBundles(), those plug-ins that have + * specified the menu_path and label but are not listed in + * default_menu.xml will be added on to the menu. */ private Map pidToServiceReferenceMap; + /* + * This is the exactly same copy of pidToServiceReferenceMap. + * Since some plug-ins could display on menu more than once, it + * provides a map between a pid and a ref while in pidToServiceReferenceMap + * that pid has been removed. + */ private Map pidToServiceReferenceMapCopy; private Document dom; private static String DEFAULT_MENU_FILE_NAME = "default_menu.xml"; @@ -106,11 +121,15 @@ listener = new ContextListener(); bContext.addServiceListener(listener, filter); preprocessServiceBundles(); - createMenuFromXML(); - processLeftServiceBundles(); + URI fullpath=URI.create(System.getProperty("osgi.configuration.area") + DEFAULT_MENU_FILE_NAME); + if (new File(fullpath).exists()){ + createMenuFromXML(fullpath.toString()); + processLeftServiceBundles(); + }else{ + initializeMenu(); + } Display.getDefault().asyncExec(updateAction); -// initializeMenu(); } catch (InvalidSyntaxException e) { getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e); } @@ -118,9 +137,10 @@ /* * This method scans all service bundles. If a bundle specifies - * menu_path, get service.pid of this bundle (key), let the service + * menu_path and label, get service.pid of this bundle (key), let the service * reference as the value, and put key/value pair * to pidToServiceReferenceMap for further processing. + * */ private void preprocessServiceBundles() throws InvalidSyntaxException{ ServiceReference[] refs = bContext.getAllServiceReferences( @@ -128,6 +148,7 @@ if (refs != null){ for (int i=0; i < refs.length; i++) { String path = (String)refs[i].getProperty(MENU_PATH); + String label = (String)refs[i].getProperty(LABEL); if (path == null){ continue; } @@ -144,9 +165,16 @@ * check if the pid exists in pidToServiceReferenceMap. If so, get the action and add to the parent menu * If not, ignore this menu. At the end of each top menu or subgroup menu or before help menu, * add "additions" so that new algorithms can be added on later + * + * What is the reasonable logic? + * If a plug-in has been specified in the default_menu.xml, always use that menu layout + * If a plug-in has not been specified in the default_menu.xml, use the menu_path + * specified in the properties file. + * If a plug-in specifies a label in the properties file, always use it. + * */ - private void createMenuFromXML() throws InvalidSyntaxException{ - parseXmlFile(); + private void createMenuFromXML(String menuFilePath) throws InvalidSyntaxException{ + parseXmlFile(menuFilePath); //get the root elememt Element docEle = dom.getDocumentElement(); //get a nodelist of the top menu elements @@ -249,7 +277,6 @@ private void processAMenuNode(Element menuNode, MenuManager parentMenuBar ){ String menuName = menuNode.getAttribute(ATTR_NAME); String pid = menuNode.getAttribute(ATTR_PID); - //System.out.println(">>>pid="+pid); if (pid == null || pid.length()==0){ //check if the name is one of the preserved one //if so add the default action @@ -261,9 +288,25 @@ get(pid.toLowerCase().trim()); pidToServiceReferenceMap.remove(pid.toLowerCase().trim()); AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); - action.setId(getItemID(ref)); - action.setText(menuName); - parentMenuBar.add(action); + String menuLabel = (String)ref.getProperty(LABEL); + if(menuName!= null && !menuName.isEmpty()){ + //use the name specified in the xml to overwrite the label + action.setText(menuName); + action.setId(getItemID(ref)); + parentMenuBar.add(action); + } + else{ + if (menuLabel!= null && !menuLabel.isEmpty()){ + action.setText(menuLabel); + action.setId(getItemID(ref)); + parentMenuBar.add(action); + } + else { + //this is a problem -- no label is specified in the plug-in's properties file + //and no name is specified in the xml file. + } + } + } else{ //otherwise log the error @@ -274,7 +317,7 @@ } } - private void parseXmlFile(){ + private void parseXmlFile(String menuFilePath){ //get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setCoalescing(true); @@ -282,9 +325,8 @@ //Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder(); - //parse using builder to get DOM representation of the XML file - String fullpath=System.getProperty("osgi.configuration.area") + DEFAULT_MENU_FILE_NAME; - dom = db.parse(fullpath); + //parse using builder to get DOM representation of the XML file + dom = db.parse(menuFilePath); // printElementAttributes(dom); }catch(ParserConfigurationException pce) { @@ -311,7 +353,7 @@ } } -/* + private void initializeMenu() throws InvalidSyntaxException{ ServiceReference[] refs = bContext.getAllServiceReferences( AlgorithmFactory.class.getName(), null); @@ -323,7 +365,7 @@ } } -*/ + private class ContextListener implements ServiceListener { public void serviceChanged(ServiceEvent event) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-25 21:00:12
|
Revision: 790 http://cishell.svn.sourceforge.net/cishell/?rev=790&view=rev Author: mwlinnem Date: 2008-07-25 21:00:08 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Fixed bug in assigning parents that can cause infinite loop. This bug has been around since Oct 2006! Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-07-25 20:39:33 UTC (rev 789) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-07-25 21:00:08 UTC (rev 790) @@ -389,7 +389,7 @@ Object parent = outData[i].getMetadata().get(DataProperty.PARENT); if (parent != null) { - for (int j=0; j < data.length; i++) { + for (int j=0; j < data.length; j++) { if (parent == data[j]) { outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-25 20:39:35
|
Revision: 789 http://cishell.svn.sourceforge.net/cishell/?rev=789&view=rev Author: mwlinnem Date: 2008-07-25 20:39:33 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Small renaming refactor. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-07-24 16:23:24 UTC (rev 788) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-07-25 20:39:33 UTC (rev 789) @@ -230,7 +230,7 @@ return metatype_pid; } - protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatype_pid, String pid, AlgorithmFactory factory) { + protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatypePID, String pid, AlgorithmFactory factory) { MetaTypeProvider provider = null; MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); if (metaTypeService != null) { @@ -239,14 +239,14 @@ if (factory instanceof ParameterMutator && provider != null) { try { - ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatype_pid, null); - if (ocd == null) logNullOCDWarning(pid, metatype_pid); + ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatypePID, null); + if (ocd == null) logNullOCDWarning(pid, metatypePID); ocd = ((ParameterMutator) factory).mutateParameters(data, ocd); if (ocd != null) { provider = new BasicMetaTypeProvider(ocd); } } catch (IllegalArgumentException e) { - log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatype_pid); + log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatypePID); } catch (Exception e) { GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2008-07-24 16:23:26
|
Revision: 788 http://cishell.svn.sourceforge.net/cishell/?rev=788&view=rev Author: fugu13 Date: 2008-07-24 16:23:24 +0000 (Thu, 24 Jul 2008) Log Message: ----------- Fix View With (without an OCD, it never had a chance to mutate one). Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2008-07-08 21:30:47 UTC (rev 787) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/OSGI-INF/metatype/METADATA.XML 2008-07-24 16:23:24 UTC (rev 788) @@ -1,10 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> <OCD name="File Load" id="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local.OCD" - description=""> + description=" "> <AD name="Default load directory" id="loadDir" type="String" default="directory:sampledata/"/> </OCD> + <OCD name="View With" id="org.cishell.reference.gui.persistence.viewwith.FileViewWith.OCD" + description=" "> + <AD name="View With" id="viewWith" type="String" default=""/> + </OCD> <Designate pid="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local"> <Object ocdref="org.cishell.reference.gui.persistence.load.FileLoad.prefs.local.OCD" /> </Designate> + <Designate pid="org.cishell.reference.gui.persistence.viewwith.FileViewWith"> + <Object ocdref="org.cishell.reference.gui.persistence.viewwith.FileViewWith.OCD" /> + </Designate> </metatype:MetaData> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 21:31:59
|
Revision: 787 http://cishell.svn.sourceforge.net/cishell/?rev=787&view=rev Author: mwlinnem Date: 2008-07-08 14:30:47 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Damned new version of Eclipse made me not include the new file. Added Paths: ----------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithm.java Added: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithm.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithm.java (rev 0) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithm.java 2008-07-08 21:30:47 UTC (rev 787) @@ -0,0 +1,80 @@ +package org.cishell.templates.staticexecutable; + +import java.io.IOException; +import java.net.URL; +import java.util.Dictionary; +import java.util.Properties; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; +import org.cishell.framework.algorithm.ProgressMonitor; +import org.cishell.framework.algorithm.ProgressTrackable; +import org.cishell.framework.data.Data; +import org.osgi.framework.BundleContext; +import org.osgi.service.log.LogService; + +public class StaticExecutableAlgorithm implements Algorithm, ProgressTrackable { + + + Data[] data; + Dictionary parameters; + CIShellContext context; + LogService logger; + + private BundleContext bContext; + private String algName; + + private ProgressMonitor monitor; + + public StaticExecutableAlgorithm(Data[] data, Dictionary parameters, CIShellContext context, BundleContext bContext, String algName) + { + this.data = data; + this.parameters = parameters; + this.context = context; + this.bContext = bContext; + this.algName = algName; + + logger = (LogService)context.getService(LogService.class.getName()); + } + + public Data[] execute() throws AlgorithmExecutionException { + try { + //prepare to run the static executable + + Properties serviceProps = getProperties("/"+algName+"/service.properties"); + Properties configProps = getProperties("/"+algName+"/config.properties"); + + serviceProps.putAll(configProps); + serviceProps.put("Algorithm-Directory", algName); + + StaticExecutableRunner runner = + new StaticExecutableRunner(bContext, context, serviceProps, parameters, data, monitor, algName); + + //run it! + return runner.execute(); + + } catch (IOException e) { + throw new AlgorithmExecutionException(e.getMessage(), e); + } + } + + private Properties getProperties(String entry) throws IOException { + URL url = bContext.getBundle().getEntry(entry); + Properties props = null; + + if (url != null) { + props = new Properties(); + props.load(url.openStream()); + } + return props; + } + + public ProgressMonitor getProgressMonitor() { + return this.monitor; + } + + public void setProgressMonitor(ProgressMonitor monitor) { + this.monitor = monitor; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 21:24:01
|
Revision: 786 http://cishell.svn.sourceforge.net/cishell/?rev=786&view=rev Author: mwlinnem Date: 2008-07-08 14:23:28 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Medium sized refactoring. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 18:50:58 UTC (rev 785) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 21:23:28 UTC (rev 786) @@ -31,13 +31,7 @@ MetaTypeProvider provider; public StaticExecutableAlgorithmFactory() {} - - //pretty sure this isn't used by anything, but I fear deleting it. - public StaticExecutableAlgorithmFactory(String algName, BundleContext bContext) { - this.algName = algName; - this.bContext = bContext; - } - + protected void activate(ComponentContext ctxt) { bContext = ctxt.getBundleContext(); algName = (String)ctxt.getProperties().get("Algorithm-Directory"); @@ -61,4 +55,11 @@ public MetaTypeProvider createParameters(Data[] data) { return provider; } + + //pretty sure this isn't used by anything, but I fear deleting it. + public StaticExecutableAlgorithmFactory(String algName, BundleContext bContext) { + this.algName = algName; + this.bContext = bContext; + } + } Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2008-07-08 18:50:58 UTC (rev 785) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2008-07-08 21:23:28 UTC (rev 786) @@ -15,18 +15,25 @@ import java.io.EOFException; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; import java.util.ArrayList; import java.util.Arrays; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; @@ -45,124 +52,140 @@ * @author Bruce Herr (bh...@bh...) */ public class StaticExecutableRunner implements Algorithm { - protected final String tempDir; + private String ALGORITHM; + private String ALGORITHM_MACOSX_PPC; + private String MACOSX; + private String ALGORITHM_WIN32; + private String WIN32; + private String ALGORITHM_LINUX_X86; + private String LINUX; + private String ALGORITHM_DEFAULT; + + protected final String algDirPath; + protected final String tempDirPath; protected final Data[] data; protected Dictionary parameters; protected Properties props; protected CIShellContext ciContext; protected ProgressMonitor monitor; + protected BundleContext bContext; + protected String algName; - public StaticExecutableRunner(BundleContext bContext, - CIShellContext ciContext, Properties props, Dictionary parameters, - Data[] data, ProgressMonitor monitor) throws IOException { + public StaticExecutableRunner(BundleContext bContext, CIShellContext ciContext, Properties props, + Dictionary parameters, Data[] data, ProgressMonitor monitor, String algName) throws IOException { + + // assign normal member-variables + + this.bContext = bContext; this.ciContext = ciContext; this.props = props; this.parameters = parameters; this.data = data; this.monitor = monitor; - if (monitor == null) - this.monitor = ProgressMonitor.NULL_MONITOR; - if (data == null) - data = new Data[0]; - if (parameters == null) - parameters = new Hashtable(); + this.algName = algName; - tempDir = makeTempDirectory(); + // determine directory paths for each platform, based on algName + + ALGORITHM = algName + "/"; + ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; + MACOSX = "macosx"; + ALGORITHM_WIN32 = ALGORITHM + "win32/"; + WIN32 = "win32"; + ALGORITHM_LINUX_X86 = ALGORITHM + "linux.x86/"; + LINUX = "linux"; + ALGORITHM_DEFAULT = ALGORITHM + "default/"; + + // if a constructor variable was null, use a null object version of it if possible + + if (monitor == null) this.monitor = ProgressMonitor.NULL_MONITOR; + if (data == null) data = new Data[0]; + if (parameters == null) parameters = new Hashtable(); + + // make a temporary directory to run the executable in + + tempDirPath = makeTempDirectory(); + + algDirPath = tempDirPath + File.separator + props.getProperty("Algorithm-Directory") + File.separator; + } /** * @see org.cishell.framework.algorithm.Algorithm#execute() */ public Data[] execute() throws AlgorithmExecutionException { - String algDir = tempDir + File.separator - + props.getProperty("Algorithm-Directory") + File.separator; + copyFilesUsedByExecutableIntoDir(getTempDirectory()); + makeDirExecutable(algDirPath); + + String[] commandLineArguments = createCommandLineArguments(algDirPath, data, parameters); + + File[] rawOutput = executeProgram(commandLineArguments, algDirPath); - chmod(algDir); - File[] output = execute(getTemplate(algDir), algDir); - - return toData(output); + return formatAsData(rawOutput); } - protected Data[] toData(File[] files) { - String outData = (String) props.get(AlgorithmProperty.OUT_DATA); + private void copyFilesUsedByExecutableIntoDir(File dir) throws AlgorithmExecutionException { + try { + Enumeration e = bContext.getBundle().getEntryPaths("/" + algName); - // if out data is null then it returns no data - if (("" + outData).trim().equalsIgnoreCase(AlgorithmProperty.NULL_DATA)) { - return null; - } + Set entries = new HashSet(); - String[] formats = outData.split(","); + while (e != null && e.hasMoreElements()) { + String entryPath = (String) e.nextElement(); + // logger.log(LogService.LOG_DEBUG, "entry: " + entryPath + "\n\n"); + if (entryPath.endsWith("/")) { + entries.add(entryPath); + } + } - Map nameToFileMap = new HashMap(); - for (int i = 0; i < files.length; i++) { - nameToFileMap.put(files[i].getName(), files[i]); - } + dir = new File(dir.getPath() + File.separator + algName); + dir.mkdirs(); - Data[] data = null; - if (formats.length > files.length) { - data = new Data[formats.length]; - } else { - data = new Data[files.length]; - } + String os = bContext.getProperty("osgi.os"); + String arch = bContext.getProperty("osgi.arch"); - for (int i = 0; i < data.length; i++) { - String file = props.getProperty("outFile[" + i + "]", null); + String path = null; - if (i < formats.length) { - File f = (File) nameToFileMap.remove(file); + // take the default, if there + if (entries.contains(ALGORITHM_DEFAULT)) { + String default_path = ALGORITHM_DEFAULT; + // logger.log(LogService.LOG_DEBUG, "base path: "+default_path+ + // "\n\t"+dir.getAbsolutePath() + "\n\n"); + copyDir(dir, default_path, 0); + } - if (f != null) { - data[i] = new BasicData(f, formats[i]); + // but override with platform idiosyncracies + if (os.equals(WIN32) && entries.contains(ALGORITHM_WIN32)) { + path = ALGORITHM_WIN32; + } else if (os.equals(MACOSX) && entries.contains(ALGORITHM_MACOSX_PPC)) { + path = ALGORITHM_MACOSX_PPC; + } else if (os.equals(LINUX) && entries.contains(ALGORITHM_LINUX_X86)) { + path = ALGORITHM_LINUX_X86; + } - String label = props.getProperty( - "outFile[" + i + "].label", f.getName()); - data[i].getMetadata().put(DataProperty.LABEL, label); + String platform_path = ALGORITHM + os + "." + arch + "/"; + // and always override anything with an exact match + if (entries.contains(platform_path)) { + path = platform_path; + } - String type = props.getProperty("outFile[" + i + "].type", - DataProperty.OTHER_TYPE); - type = type.trim(); - if (type.equalsIgnoreCase(DataProperty.MATRIX_TYPE)) { - type = DataProperty.MATRIX_TYPE; - } else if (type.equalsIgnoreCase(DataProperty.NETWORK_TYPE)) { - type = DataProperty.NETWORK_TYPE; - } else if (type.equalsIgnoreCase(DataProperty.TREE_TYPE)) { - type = DataProperty.TREE_TYPE; - } else if (type.equalsIgnoreCase(DataProperty.TEXT_TYPE)) { - type = DataProperty.TEXT_TYPE; - } else if (type.equalsIgnoreCase(DataProperty.PLOT_TYPE)) { - type = DataProperty.PLOT_TYPE; - } else if (type.equalsIgnoreCase(DataProperty.TABLE_TYPE)) { - type = DataProperty.TABLE_TYPE; - }else { - type = DataProperty.OTHER_TYPE; - } - - data[i].getMetadata().put(DataProperty.TYPE, type); - } + if (path == null) { + throw new AlgorithmExecutionException("Unable to find compatible executable"); } else { - Iterator iter = nameToFileMap.values().iterator(); - while (iter.hasNext()) { - File f = (File) iter.next(); - - data[i] = new BasicData(f, "file:text/plain"); - data[i].getMetadata().put(DataProperty.LABEL, f.getName()); - - i++; - } - break; + // logger.log(LogService.LOG_DEBUG, "base path: "+path+ + // "\n\t"+dir.getAbsolutePath() + "\n\n"); + copyDir(dir, path, 0); } + } catch (IOException e) { + throw new AlgorithmExecutionException(e.getMessage(), e); } - - return data; } - protected void chmod(String baseDir) throws AlgorithmExecutionException { + protected void makeDirExecutable(String baseDir) throws AlgorithmExecutionException { // FIXME: Surely java has a way to do this!!!! if (new File("/bin/chmod").exists()) { try { String executable = baseDir + props.getProperty("executable"); - Runtime.getRuntime().exec("/bin/chmod +x " + executable) - .waitFor(); + Runtime.getRuntime().exec("/bin/chmod +x " + executable).waitFor(); } catch (IOException e) { throw new AlgorithmExecutionException(e); } catch (InterruptedException e) { @@ -171,31 +194,36 @@ } } - protected File[] execute(String[] cmdarray, String baseDir) - throws AlgorithmExecutionException { - File dir = new File(baseDir); - String[] beforeFiles = dir.list(); + protected File[] executeProgram(String[] cmdarray, String baseDirPath) throws AlgorithmExecutionException { + //remember which files were in the directory before we ran the program + File baseDir = new File(baseDirPath); + String[] beforeFiles = baseDir.list(); + //create and run the executing process Process process = null; try { - process = Runtime.getRuntime().exec(cmdarray, null, - new File(baseDir)); + process = Runtime.getRuntime().exec(cmdarray, null, new File(baseDirPath)); process.getOutputStream().close(); } catch (IOException e1) { - throw new AlgorithmExecutionException(e1.getMessage(),e1); + throw new AlgorithmExecutionException(e1.getMessage(), e1); } + + //monitor the process, printing its stdout and stderr to console monitor.start(ProgressMonitor.CANCELLABLE, -1); - + InputStream in = process.getInputStream(); StringBuffer in_buffer = new StringBuffer(); - + InputStream err = process.getErrorStream(); StringBuffer err_buffer = new StringBuffer(); Integer exitValue = null; boolean killedOnPurpose = false; + //while the process is still running... while (!killedOnPurpose && exitValue == null) { + //print its output, and watch to see if it has finished/died. + in_buffer = logStream(LogService.LOG_INFO, in, in_buffer); err_buffer = logStream(LogService.LOG_ERROR, err, err_buffer); @@ -223,13 +251,15 @@ // if the process failed unexpectedly... if (process.exitValue() != 0 && !killedOnPurpose) { - throw new AlgorithmExecutionException( - "Algorithm exited unexpectedly (exit value: "+process.exitValue()+ - "). Please check the console window for any error messages."); + throw new AlgorithmExecutionException("Algorithm exited unexpectedly (exit value: " + process.exitValue() + + "). Please check the console window for any error messages."); } - // get the files output from the process - String[] afterFiles = dir.list(); + //look at the files in the directory now, and compare to before we ran the program. + //any file that is in the directory now, but wasn't before, is an output file. + //return all the output files. + + String[] afterFiles = baseDir.list(); Arrays.sort(beforeFiles); Arrays.sort(afterFiles); @@ -239,41 +269,111 @@ int beforeIndex = 0; int afterIndex = 0; - while (beforeIndex < beforeFiles.length - && afterIndex < afterFiles.length) { + while (beforeIndex < beforeFiles.length && afterIndex < afterFiles.length) { if (beforeFiles[beforeIndex].equals(afterFiles[afterIndex])) { beforeIndex++; afterIndex++; } else { - outputs.add(new File(baseDir + afterFiles[afterIndex])); + outputs.add(new File(baseDirPath + afterFiles[afterIndex])); afterIndex++; } } // get any remaining new files while (afterIndex < afterFiles.length) { - outputs.add(new File(baseDir + afterFiles[afterIndex])); + outputs.add(new File(baseDirPath + afterFiles[afterIndex])); afterIndex++; } return (File[]) outputs.toArray(new File[] {}); } - protected StringBuffer logStream(int logLevel, InputStream is, - StringBuffer buffer) throws AlgorithmExecutionException { + protected Data[] formatAsData(File[] files) { + String outData = (String) props.get(AlgorithmProperty.OUT_DATA); + + // if out data is null then it returns no data + if (("" + outData).trim().equalsIgnoreCase(AlgorithmProperty.NULL_DATA)) { + return null; + } + + String[] formats = outData.split(","); + + Map nameToFileMap = new HashMap(); + for (int i = 0; i < files.length; i++) { + nameToFileMap.put(files[i].getName(), files[i]); + } + + Data[] data = null; + if (formats.length > files.length) { + data = new Data[formats.length]; + } else { + data = new Data[files.length]; + } + + for (int i = 0; i < data.length; i++) { + String file = props.getProperty("outFile[" + i + "]", null); + + if (i < formats.length) { + File f = (File) nameToFileMap.remove(file); + + if (f != null) { + data[i] = new BasicData(f, formats[i]); + + String label = props.getProperty("outFile[" + i + "].label", f.getName()); + data[i].getMetadata().put(DataProperty.LABEL, label); + + String type = props.getProperty("outFile[" + i + "].type", DataProperty.OTHER_TYPE); + type = type.trim(); + if (type.equalsIgnoreCase(DataProperty.MATRIX_TYPE)) { + type = DataProperty.MATRIX_TYPE; + } else if (type.equalsIgnoreCase(DataProperty.NETWORK_TYPE)) { + type = DataProperty.NETWORK_TYPE; + } else if (type.equalsIgnoreCase(DataProperty.TREE_TYPE)) { + type = DataProperty.TREE_TYPE; + } else if (type.equalsIgnoreCase(DataProperty.TEXT_TYPE)) { + type = DataProperty.TEXT_TYPE; + } else if (type.equalsIgnoreCase(DataProperty.PLOT_TYPE)) { + type = DataProperty.PLOT_TYPE; + } else if (type.equalsIgnoreCase(DataProperty.TABLE_TYPE)) { + type = DataProperty.TABLE_TYPE; + } else { + type = DataProperty.OTHER_TYPE; + } + + data[i].getMetadata().put(DataProperty.TYPE, type); + } + } else { + Iterator iter = nameToFileMap.values().iterator(); + while (iter.hasNext()) { + File f = (File) iter.next(); + + data[i] = new BasicData(f, "file:text/plain"); + data[i].getMetadata().put(DataProperty.LABEL, f.getName()); + + i++; + } + break; + } + } + + return data; + } + + protected StringBuffer logStream(int logLevel, InputStream is, StringBuffer buffer) + throws AlgorithmExecutionException { try { int available = is.available(); if (available > 0) { byte[] b = new byte[available]; is.read(b); buffer.append(new String(b)); - + buffer = log(logLevel, buffer); } } catch (EOFException e) { - //normal operation + // normal operation } catch (IOException e) { - throw new AlgorithmExecutionException("Error when processing the algorithm's screen output",e); + throw new AlgorithmExecutionException("Error when processing the algorithm's screen output", e); } return buffer; @@ -281,8 +381,7 @@ protected StringBuffer log(int logLevel, StringBuffer buffer) { if (buffer.indexOf("\n") != -1) { // any new newlines to output? - LogService log = (LogService) ciContext.getService(LogService.class - .getName()); + LogService log = (LogService) ciContext.getService(LogService.class.getName()); int lastGoodIndex = 0; int fromIndex = 0; @@ -294,14 +393,14 @@ String message = buffer.substring(fromIndex, toIndex); if (log == null) { - // This will probably never come up, but if it does + // This will probably never come up, but if it does // we'll still get some output. System.out.println(message); } else { log.log(logLevel, message); } - fromIndex = toIndex+1; - lastGoodIndex = toIndex+1; + fromIndex = toIndex + 1; + lastGoodIndex = toIndex + 1; } else { fromIndex = -1; } @@ -315,12 +414,12 @@ return buffer; } - protected String[] getTemplate(String algDir) { + protected String[] createCommandLineArguments(String algDir, Data[] data, Dictionary parameters) { String template = "" + props.getProperty("template"); String[] cmdarray = template.split("\\s"); for (int i = 0; i < cmdarray.length; i++) { - cmdarray[i] = substiteVars(cmdarray[i]); + cmdarray[i] = substituteVars(cmdarray[i], data, parameters); } // TODO: Expanded later to support .cmd and other extensions @@ -334,9 +433,11 @@ return cmdarray; } - protected String substiteVars(String str) { - str = str.replaceAll("\\$\\{executable\\}", props - .getProperty("executable")); + // replaces place-holder variables in the template with the actual arguments the executable needs to work. + // (real names of files instead of inFile[i], for instance) + // (also, real values like "6" or "dog" instead of placeholders for parameters) + protected String substituteVars(String str, Data[] data, Dictionary parameters) { + str = str.replaceAll("\\$\\{executable\\}", props.getProperty("executable")); for (int i = 0; i < data.length; i++) { String file = ((File) data[i].getData()).getAbsolutePath(); @@ -356,8 +457,7 @@ String key = (String) i.nextElement(); Object value = parameters.get(key); - if (value == null) - value = ""; + if (value == null) value = ""; str = str.replaceAll("\\$\\{" + key + "\\}", value.toString()); } @@ -366,17 +466,63 @@ } public File getTempDirectory() { - return new File(tempDir); + return new File(tempDirPath); } protected String makeTempDirectory() throws IOException { File sessionDir = Activator.getTempDirectory(); - File dir = File.createTempFile("StaticExecutableRunner-", "", - sessionDir); + File dir = File.createTempFile("StaticExecutableRunner-", "", sessionDir); dir.delete(); dir.mkdirs(); return dir.getAbsolutePath(); } + + private void copyDir(File dir, String dirPath, int depth) throws IOException { + Enumeration e = bContext.getBundle().getEntryPaths(dirPath); + + // dirPath = dirPath.replace('/', File.separatorChar); + + while (e != null && e.hasMoreElements()) { + String path = (String) e.nextElement(); + + if (path.endsWith("/")) { + String dirName = getName(path); + + File subDirectory = new File(dir.getPath() + File.separator + dirName); + subDirectory.mkdirs(); + // logger.log(LogService.LOG_DEBUG, "path: " + depth + " "+path+ + // "\n\t"+subDirectory.getAbsolutePath() + "\n\n"); + copyDir(subDirectory, path, depth + 1); + } else { + copyFile(dir, path); + } + } + } + + private void copyFile(File dir, String path) throws IOException { + URL entry = bContext.getBundle().getEntry(path); + + // path = path.replace('/', File.separatorChar); + String file = getName(path); + FileOutputStream outStream = new FileOutputStream(dir.getPath() + File.separator + file); + + ReadableByteChannel in = Channels.newChannel(entry.openStream()); + FileChannel out = outStream.getChannel(); + out.transferFrom(in, 0, Integer.MAX_VALUE); + + in.close(); + out.close(); + } + + private String getName(String path) { + if (path.lastIndexOf('/') == path.length() - 1) { + path = path.substring(0, path.length() - 1); + } + + path = path.substring(path.lastIndexOf('/') + 1, path.length()); + + return path; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 18:51:35
|
Revision: 785 http://cishell.svn.sourceforge.net/cishell/?rev=785&view=rev Author: mwlinnem Date: 2008-07-08 11:50:58 -0700 (Tue, 08 Jul 2008) Log Message: ----------- A little refactoring. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 18:00:25 UTC (rev 784) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 18:50:58 UTC (rev 785) @@ -13,29 +13,14 @@ * ***************************************************************************/ package org.cishell.templates.staticexecutable; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; import java.util.Dictionary; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; -import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.algorithm.ProgressMonitor; -import org.cishell.framework.algorithm.ProgressTrackable; import org.cishell.framework.data.Data; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.osgi.service.log.LogService; import org.osgi.service.metatype.MetaTypeProvider; import org.osgi.service.metatype.MetaTypeService; @@ -47,6 +32,7 @@ public StaticExecutableAlgorithmFactory() {} + //pretty sure this isn't used by anything, but I fear deleting it. public StaticExecutableAlgorithmFactory(String algName, BundleContext bContext) { this.algName = algName; this.bContext = bContext; @@ -69,183 +55,10 @@ } public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { - return new StaticExecutableAlgorithm(data, parameters, context); + return new StaticExecutableAlgorithm(data, parameters, context, this.bContext, this.algName); } public MetaTypeProvider createParameters(Data[] data) { return provider; } - - private class StaticExecutableAlgorithm implements Algorithm, ProgressTrackable { - private String ALGORITHM; - private String ALGORITHM_MACOSX_PPC; - private String MACOSX; - private String ALGORITHM_WIN32; - private String WIN32; - private String ALGORITHM_LINUX_X86; - private String LINUX; - private String ALGORITHM_DEFAULT; - Data[] data; - Dictionary parameters; - CIShellContext context; - LogService logger; - - private ProgressMonitor monitor; - - public StaticExecutableAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) - { - this.data = data; - this.parameters = parameters; - this.context = context; - logger = (LogService)context.getService(LogService.class.getName()); - - ALGORITHM = algName + "/"; - ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; - MACOSX = "macosx"; - ALGORITHM_WIN32 = ALGORITHM + "win32/"; - WIN32 = "win32"; - ALGORITHM_LINUX_X86 = ALGORITHM + "linux.x86/"; - LINUX = "linux"; - ALGORITHM_DEFAULT = ALGORITHM + "default/"; - } - - public Data[] execute() throws AlgorithmExecutionException { - try { - Properties serviceProps = getProperties("/"+algName+"/service.properties"); - Properties configProps = getProperties("/"+algName+"/config.properties"); - - serviceProps.putAll(configProps); - serviceProps.put("Algorithm-Directory", algName); - - StaticExecutableRunner runner = - new StaticExecutableRunner(bContext, context, serviceProps, parameters, data, monitor); - - copyFiles(runner.getTempDirectory()); - - return runner.execute(); - } catch (IOException e) { - throw new AlgorithmExecutionException(e.getMessage(), e); - } - } - - private void copyFiles(File dir) throws IOException, AlgorithmExecutionException { - Enumeration e = bContext.getBundle().getEntryPaths("/"+algName); - - Set entries = new HashSet(); - - while(e != null && e.hasMoreElements()) { - String entryPath = (String) e.nextElement(); - //logger.log(LogService.LOG_DEBUG, "entry: " + entryPath + "\n\n"); - if(entryPath.endsWith("/")) { - entries.add(entryPath); - } - } - - dir = new File(dir.getPath() + File.separator + algName); - dir.mkdirs(); - - String os = bContext.getProperty("osgi.os"); - String arch = bContext.getProperty("osgi.arch"); - - String path = null; - - //take the default, if there - if(entries.contains(ALGORITHM_DEFAULT)) { - String default_path = ALGORITHM_DEFAULT; - //logger.log(LogService.LOG_DEBUG, "base path: "+default_path+ - // "\n\t"+dir.getAbsolutePath() + "\n\n"); - copyDir(dir, default_path, 0); - } - - //but override with platform idiosyncracies - if(os.equals(WIN32) && entries.contains(ALGORITHM_WIN32)) { - path = ALGORITHM_WIN32; - } else if(os.equals(MACOSX) && entries.contains(ALGORITHM_MACOSX_PPC)) { - path = ALGORITHM_MACOSX_PPC; - } else if(os.equals(LINUX) && entries.contains(ALGORITHM_LINUX_X86)) { - path = ALGORITHM_LINUX_X86; - } - - String platform_path = ALGORITHM + os + "." + arch + "/"; - //and always override anything with an exact match - if(entries.contains(platform_path)) { - path = platform_path; - } - - if (path == null) { - throw new AlgorithmExecutionException("Unable to find compatible executable"); - } else { - //logger.log(LogService.LOG_DEBUG, "base path: "+path+ - // "\n\t"+dir.getAbsolutePath() + "\n\n"); - copyDir(dir, path, 0); - } - } - - private void copyDir(File dir, String dirPath, int depth) throws IOException { - Enumeration e = bContext.getBundle().getEntryPaths(dirPath); - - //dirPath = dirPath.replace('/', File.separatorChar); - - while (e != null && e.hasMoreElements()) { - String path = (String)e.nextElement(); - - if (path.endsWith("/")) { - String dirName = getName(path); - - File subDirectory = new File(dir.getPath() + File.separator + dirName); - subDirectory.mkdirs(); - //logger.log(LogService.LOG_DEBUG, "path: " + depth + " "+path+ - // "\n\t"+subDirectory.getAbsolutePath() + "\n\n"); - copyDir(subDirectory, path, depth + 1); - } else { - copyFile(dir, path); - } - } - } - - private void copyFile(File dir, String path) throws IOException { - URL entry = bContext.getBundle().getEntry(path); - - //path = path.replace('/', File.separatorChar); - String file = getName(path); - FileOutputStream outStream = new FileOutputStream(dir.getPath() + File.separator + file); - - ReadableByteChannel in = Channels.newChannel(entry.openStream()); - FileChannel out = outStream.getChannel(); - out.transferFrom(in, 0, Integer.MAX_VALUE); - - in.close(); - out.close(); - } - - private String getName(String path) { - if (path.lastIndexOf('/') == path.length()-1) { - path = path.substring(0, path.length()-1); - } - - path = path.substring(path.lastIndexOf('/')+1, - path.length()); - - return path; - } - - private Properties getProperties(String entry) throws IOException { - URL url = bContext.getBundle().getEntry(entry); - Properties props = null; - - if (url != null) { - props = new Properties(); - props.load(url.openStream()); - } - return props; - } - - public ProgressMonitor getProgressMonitor() { - return this.monitor; - } - - public void setProgressMonitor(ProgressMonitor monitor) { - this.monitor = monitor; - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 18:01:03
|
Revision: 784 http://cishell.svn.sourceforge.net/cishell/?rev=784&view=rev Author: mwlinnem Date: 2008-07-08 11:00:25 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Typo fix. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-07-08 17:55:50 UTC (rev 783) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-07-08 18:00:25 UTC (rev 784) @@ -120,7 +120,7 @@ * This method scans all service bundles. If a bundle specifies * menu_path, get service.pid of this bundle (key), let the service * reference as the value, and put key/value pair - * to pidToServiceReferenceMap for further process. + * to pidToServiceReferenceMap for further processing. */ private void preprocessServiceBundles() throws InvalidSyntaxException{ ServiceReference[] refs = bContext.getAllServiceReferences( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 17:56:09
|
Revision: 783 http://cishell.svn.sourceforge.net/cishell/?rev=783&view=rev Author: mwlinnem Date: 2008-07-08 10:55:50 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Testing. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:50:51 UTC (rev 782) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:55:50 UTC (rev 783) @@ -109,6 +109,8 @@ private LogService log; public AbstractDataManagerView(String brandPluginID) { + + this.brandPluginID = brandPluginID; dataToDataGUIItemMap = new HashMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 17:51:51
|
Revision: 782 http://cishell.svn.sourceforge.net/cishell/?rev=782&view=rev Author: mwlinnem Date: 2008-07-08 10:50:51 -0700 (Tue, 08 Jul 2008) Log Message: ----------- More testing. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:47:55 UTC (rev 781) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:50:51 UTC (rev 782) @@ -109,7 +109,6 @@ private LogService log; public AbstractDataManagerView(String brandPluginID) { - this.brandPluginID = brandPluginID; dataToDataGUIItemMap = new HashMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 17:49:59
|
Revision: 781 http://cishell.svn.sourceforge.net/cishell/?rev=781&view=rev Author: mwlinnem Date: 2008-07-08 10:47:55 -0700 (Tue, 08 Jul 2008) Log Message: ----------- test. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:44:42 UTC (rev 780) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:47:55 UTC (rev 781) @@ -109,6 +109,7 @@ private LogService log; public AbstractDataManagerView(String brandPluginID) { + this.brandPluginID = brandPluginID; dataToDataGUIItemMap = new HashMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 17:45:43
|
Revision: 780 http://cishell.svn.sourceforge.net/cishell/?rev=780&view=rev Author: mwlinnem Date: 2008-07-08 10:44:42 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Testing CiShell commit. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-06-11 15:41:49 UTC (rev 779) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-07-08 17:44:42 UTC (rev 780) @@ -109,7 +109,6 @@ private LogService log; public AbstractDataManagerView(String brandPluginID) { - this.brandPluginID = brandPluginID; dataToDataGUIItemMap = new HashMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-06-11 15:45:00
|
Revision: 779 http://cishell.svn.sourceforge.net/cishell/?rev=779&view=rev Author: mwlinnem Date: 2008-06-11 08:41:49 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Changed error handling so more informative message is shown. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2008-05-09 14:14:22 UTC (rev 778) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/META-INF/MANIFEST.MF 2008-06-11 15:41:49 UTC (rev 779) @@ -10,7 +10,9 @@ org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", + org.cishell.reference.gui.datamanager, org.cishell.reference.gui.workspace, + org.cishell.service.guibuilder;version="1.0.0", org.osgi.service.log;version="1.3.0" Export-Package: org.cishell.reference.gui.datamanager Bundle-ActivationPolicy: lazy Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-05-09 14:14:22 UTC (rev 778) +++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2008-06-11 15:41:49 UTC (rev 779) @@ -502,14 +502,16 @@ }catch (AlgorithmExecutionException aee) { if (log != null) { log.log(LogService.LOG_ERROR, - "org.cishell.framework.algorithm.AlgorithmExecutionException", + aee.getMessage(), aee); + aee.printStackTrace(); } else { log = Activator.getLogService(); log.log(LogService.LOG_ERROR, "org.cishell.framework.algorithm.AlgorithmExecutionException", aee); + aee.printStackTrace(); } } } @@ -528,16 +530,17 @@ algorithm.execute(); }catch (AlgorithmExecutionException aee) { if (log != null) { - log.log(LogService.LOG_ERROR, - "org.cishell.framework.algorithm.AlgorithmExecutionException", + log.log(LogService.LOG_ERROR, + aee.getMessage(), aee); } else { log = Activator.getLogService(); - log.log(LogService.LOG_ERROR, - "org.cishell.framework.algorithm.AlgorithmExecutionException", + log.log(LogService.LOG_ERROR, + aee.getMessage(), aee); } + aee.printStackTrace(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-05-09 14:15:59
|
Revision: 778 http://cishell.svn.sourceforge.net/cishell/?rev=778&view=rev Author: mwlinnem Date: 2008-05-09 07:14:22 -0700 (Fri, 09 May 2008) Log Message: ----------- Removed System.out.printlns Modified Paths: -------------- trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/BasicTree.java Modified: trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java =================================================================== --- trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java 2008-05-09 13:50:16 UTC (rev 777) +++ trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java 2008-05-09 14:14:22 UTC (rev 778) @@ -74,15 +74,12 @@ } private String getParamPrefOCDID(ServiceReference prefHolder) { - System.out.println(" Getting param pref OCD ID for " + prefHolder.getProperty("service.pid")); String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETERS_PID); if ( paramPrefOCDID != null) { - System.out.println(" RETURN override: " + paramPrefOCDID); return paramPrefOCDID; } else { //no names defined. Use default names. String defaultParamPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + UserPrefsProperty.PARAM_PREFS_OCD_SUFFIX; - System.out.println(" RETURN default: " + defaultParamPrefOCDID); return defaultParamPrefOCDID; } } Modified: trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java =================================================================== --- trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java 2008-05-09 13:50:16 UTC (rev 777) +++ trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java 2008-05-09 14:14:22 UTC (rev 778) @@ -43,7 +43,6 @@ //for each service that purports to hold preference information... for (int ii = 0; ii < prefReferences.length; ii++) { ServiceReference prefReference = prefReferences[ii]; - System.out.println("Processing " + prefReference.getProperty("service.pid")); //get all preference pages from this service by type, and save them by type PrefPage[] localPrefPages = null; @@ -63,7 +62,6 @@ PrefPage[] paramPrefPages = null; if (isTurnedOn(prefReference,UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE)) { - System.out.println(" Attempting to publish param default prefs for " + prefReference.getProperty("service.pid")); paramPrefPages = getParamPrefPages(prefReference); initializeConfigurations(paramPrefPages); this.allParamPrefPages.addAll(Arrays.asList(paramPrefPages)); Modified: trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/BasicTree.java =================================================================== --- trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/BasicTree.java 2008-05-09 13:50:16 UTC (rev 777) +++ trunk/core/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/BasicTree.java 2008-05-09 14:14:22 UTC (rev 778) @@ -28,7 +28,6 @@ } public void addEdge(Object parent, Object child) { - System.out.println("Adding edge from " + parent + " to " + child); parentToChildren.put(parent, child); childToParent.put(child, parent); } @@ -36,10 +35,8 @@ public List getChildren(Object node) { List children = parentToChildren.get(node); if (children == null) { - System.out.println("Getting empty children list"); return new ArrayList(); } else { - System.out.println("Getting children list of size "+ children.size()); return children; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |