Revision: 548 http://cishell.svn.sourceforge.net/cishell/?rev=548&view=rev Author: huangb Date: 2007-10-16 12:30:41 -0700 (Tue, 16 Oct 2007) Log Message: ----------- Add currentValue (static object) to hold previously selected file/directory. However there's a drawback. When multiple algorithms use this GUI builder, the selection will show up cross those multiple algorithms. Currently we can't support preserving the previous selection for each algorithm separately. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java 2007-10-05 14:17:09 UTC (rev 547) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java 2007-10-16 19:30:41 UTC (rev 548) @@ -26,6 +26,7 @@ public class FileComponent extends StringComponent { protected Button browse; + private static Object currentValue; public FileComponent() { this(false, 2); @@ -38,7 +39,7 @@ public Control createGUI(Composite parent, int style) { super.createGUI(parent, style); //creates the text component - Object data = text.getLayoutData(); + Object data = text.getLayoutData(); if (data != null && data instanceof GridData) { GridData gd = (GridData) data; gd.horizontalSpan--; //make room for the browse button @@ -46,10 +47,12 @@ browse = new Button(parent, SWT.PUSH); browse.setText("Browse"); + //when click "Browse", here is the listener browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String fileName = getFile(text.getText()); - + //remember this new file/directory selection + currentValue = fileName; if (fileName != null) { text.setText(fileName); update(); @@ -97,7 +100,17 @@ public void setValue(Object value) { if (value != null && value.toString().equals(getKeyword())) { - value = System.getProperty("user.home"); + +// value = System.getProperty("user.home"); + + //by default, point to NWB or CIShell application installation directory + if (currentValue == null) { + value = System.getProperty("osgi.install.area").replace("file:/",""); + currentValue = value; + } + else + value = currentValue; + } super.setValue(value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |