File chooser in the property sheet [message #675523] |
Tue, 31 May 2011 18:26 |
Gregoire Messages: 3 Registered: May 2011 |
Junior Member |
|
|
Hi,
I am implementing a workflow editor and I would like to add a file chooser in the property sheet of my application.
For example, when I select a file, I can see its attributes (name, type, ...) and I would like to add its location.
For me, the easiest solution would be to have a "three dots button" on the line File location of the property sheet and when clicking on this button, it would open a file chooser window and save the selected file location in the object's attributes.
Is this possible? How could I do that in another way than enter it manually in the property field?
Thank you.
Regards,
Greg
[Updated on: Tue, 31 May 2011 18:27] Report message to a moderator
|
|
|
Re: File chooser in the property sheet [message #693825 is a reply to message #675523] |
Thu, 07 July 2011 09:20 |
Christian Schwarz Messages: 31 Registered: July 2009 |
Member |
|
|
Hi,
you can extend PropertyDescriptor and override public CellEditor createPropertyEditor(Composite parent) to return an instance of the following class.
public final class FileDialogCellEditor extends DialogCellEditor {
private final String[] filterNames;
private final String[] filterExtensions;
private final String filterPath;
private final String dialogText;
public FileDialogCellEditor(Composite parent,
String[] filterNames,
String[] filterExtensions,
String filterPath,
String dialogText) {
super(parent);
this.filterNames = filterNames;
this.filterExtensions = filterExtensions;
this.filterPath = filterPath;
this.dialogText = dialogText;
}
@Override
protected Object openDialogBox(Control cellEditorWindow) {
setErrorMessage(null);
FileDialog dialog = new FileDialog(cellEditorWindow.getShell());
dialog.setFilterExtensions(filterExtensions);
dialog.setFilterNames(filterNames);
dialog.setFilterPath(filterPath);
dialog.setText(dialogText);
String absolutePath = dialog.open();
return absolutePath;
}
}
[Updated on: Thu, 07 July 2011 09:24] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03768 seconds