From: <hu...@us...> - 2006-09-29 21:07:38
|
Revision: 228 http://svn.sourceforge.net/cishell/?rev=228&view=rev Author: huangb Date: 2006-09-29 14:07:34 -0700 (Fri, 29 Sep 2006) Log Message: ----------- use swt GUIBuilder pop-up window to display the error message instead of logging the error messages in the console view Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2006-09-29 21:04:41 UTC (rev 227) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileLoad.java 2006-09-29 21:07:34 UTC (rev 228) @@ -21,6 +21,7 @@ import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.data.Data; import org.cishell.framework.data.BasicData; +import org.cishell.service.guibuilder.GUIBuilderService; /* * @author Weixia(Bonnie) Huang (hu...@in...) @@ -28,14 +29,19 @@ public class FileLoad implements Algorithm{ private static File currentDir; + private final LogService logger; - private final BundleContext bContext; + private final GUIBuilderService guiBuilder; + + private BundleContext bContext; private CIShellContext ciContext; public FileLoad(CIShellContext ciContext, BundleContext bContext) { this.ciContext = ciContext; this.bContext = bContext; - logger = (LogService) ciContext.getService(LogService.class.getName()); + logger = (LogService) ciContext.getService(LogService.class.getName()); + guiBuilder = (GUIBuilderService)ciContext.getService(GUIBuilderService.class.getName()); + } public void selectionChanged(IAction action, ISelection selection) { @@ -47,9 +53,10 @@ // System.out.println("counter is "+counter); // ?? why getActiveWorkbenchWindow() didn't work?? Data[] returnDM; + final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); if (windows.length ==0){ - System.out.println("windows[0] is null!!"); +// System.out.println("windows[0] is null!!"); return null; } @@ -75,7 +82,7 @@ String fileName = theFile.getName() ; String extension ; if (fileName.lastIndexOf(".") != -1) - extension = fileName.substring(fileName.lastIndexOf(".")) ; + extension = fileName.substring(fileName.lastIndexOf(".")+1) ; else extension = "" ; return extension ; @@ -93,7 +100,8 @@ FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); if (currentDir == null) { - currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata" + File.separator + "anything"); + currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata"); +// currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata" + File.separator + "anything"); } dialog.setFilterPath(currentDir.getPath()); dialog.setText("Select a File"); @@ -109,8 +117,6 @@ } else { currentDir = new File(file.getPath()); } -// FileResourceDescriptor frd = new BasicFileResourceDescriptor(file); -// String fileExtension = frd.getFileExtension(); String fileExtension = getFileExtension(file); System.out.println("fileExtension = "+fileExtension); @@ -122,15 +128,16 @@ // to nocompression by default. // get all the service references of converters that can load this type of file. -// ServiceReference[] serviceRefList = bContext.getServiceReferences(null, filter); ServiceReference[] serviceRefList = bContext.getAllServiceReferences( AlgorithmFactory.class.getName(), filter); // no converters found means the file format is not supported if (serviceRefList == null || serviceRefList.length == 0){ - //log "The file format is not supported" - logger.log(LogService.LOG_INFO, "Sorry, the file format: *"+fileExtension+" is not supported so far."); + guiBuilder.showError("Unsupported File Format", "Sorry, the file format: *"+fileExtension+" is not supported so far.", + "Sorry, the file format: *"+fileExtension+" is not supported so far. \n"+ + "Please send your requests to cis...@li.... \n" + +"Thank you."); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |