Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » File chooser in the property sheet
File chooser in the property sheet [message #675523] Tue, 31 May 2011 18:26 Go to next message
Gregoire  is currently offline Gregoire Friend
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 Go to previous messageGo to next message
Christian Schwarz is currently offline Christian SchwarzFriend
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

Re: File chooser in the property sheet [message #758481 is a reply to message #693825] Wed, 23 November 2011 12:27 Go to previous message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Christian,

I have tried your solution, but the Choose button does not appear in the Property Sheet in order to open the Dialog box. Could you please explain further?
Previous Topic:Scaled SWTGraphics draws
Next Topic:GEF documentation is not included on the on-line version of latest release of eclipse help.
Goto Forum:
  


Current Time: Fri Apr 26 19:33:32 GMT 2024

Powered by FUDForum. Page generated in 0.03768 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top