PDA

View Full Version : Browse Control setFile broken?



paulraby
04-07-2005, 11:29 AM
I'm executing the following code:

ISBrowseControl SWJMX = panel.getBrowseControl("SWJMX");
SWJMX.setFile("c:\\temp");

The code executes (I've proved that with logging) however the Browse Control (set to directory browsing mode) is not updated.

Has anyone managed to set the browser control's selected file programatically?

Paul

paulraby
04-07-2005, 02:31 PM
Information from InstallShield support:


I believe all you need to do is call refreshExtendedProperties() on the browse control after you set the file. So your code would look like:

ISBrowseControl SWJMX = panel.getBrowseControl("SWJMX");
SWJMX.setFile("c:\\temp");
SWJMX.refreshExtendedProperties();

This will refresh the browse control to use the file you have previously set.

This does indeed work - however it is not at all obvious that this is the API to call!

chrisvasa
04-08-2005, 08:42 PM
Yes calling refreshExtendedProperties will do the trick. I am using it and it works like a charm.
Chris

RussianDevil
05-31-2006, 11:39 PM
erm, I'm doing setFile with empty string ("") in an attempt to clear the contents of the field, however the previous value seems to remain in it. if i use anything other than empty string as a parameter to setFile, the desired effect is achieved. any suggestions/comments?

gamlidek
06-21-2006, 10:53 PM
Hi Greg,

2 things here:

1) Make sure you are calling:

browseControl.setFile(filePath);
browseControl.refreshExtendedProperties();
2) Make sure the variable the browse control is associated with is also getting set correctly -- might not be necessary, but it's possible knowing IS.

context.getServices().getISDatabase().setVariableValue(BROWSE_VAR, filePath);

If it's still not working for you, let me know.

/gam/

RussianDevil
06-22-2006, 12:27 AM
hi there, thanks for the suggestions. I'm pretty sure I've tried both of those approaches (together, and separately) without much luck. I'm updating control contents on-the-fly, so I'm pretty sure the variable resolving wouldn't be done by the IS internally in this case, but yeah, I have tried it.

setFile with argument that is anything but "" seems to work as expected.

gamlidek
06-22-2006, 02:55 PM
The only other thing you can try is manipulating the underlying native component, which is a JFileChooser. Here's how to get the native component:



import javax.swing.*;

...

ISBrowseControl browseControl = context.getISPanel().getBrowseControl(BROWSE_CONTROL_ID);
JFileChooser jfc = (JFileChooser)browseControl.getNativeComponent();

Let me know if you find a way to clear the browse control's text field.

cheers,

/gam/

RussianDevil
06-25-2006, 08:00 PM
JFileChooser actually expects a File, as opposed to the IS control that wants a string containing a path to the file... I've tried the JFileChooser without much luck. /ponder