Reputation: 1
I'm fairly new to eclipse and I'm trying to write a simple RCP application to automatically generate configuration files for routers etc.
I have a wizard which gathers the required information (such as IP address) and then updates a model with the users input. When the wizard finishes it triggers the model to write out the file.
On my last wizard page I prompt the user to save the file and have a "Browse" button which launches a command that displays a 'save' FileDialog. The command is called when the button is clicked:
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e){
IHandlerService handlerService = (IHandlerService) (PlatformUI.getWorkbench().getService(IHandlerService.class));
try {
filename = (String) handlerService.executeCommand("ie.btireland.cm.config.projectFileAs", null);
path.setText(filename);
setPageComplete(true);
}catch(Exception E){ // handle error }
}
});
Everything works ok however I wish to pass a String object to the command so it can use it on FileDialog.setFileName()
when I create the dialog. My goal is for the suggested file name to be already populated when the FileDialog window appears.
I've been around the block searching for an answer and I just can't work it out. As the command is only referenced by its ID I can't work out how to pass a variable to it.
I gave up in the end and I now write the string out to a temporary file which I read in the command handler, but obviously that is a crazy solution. Surely there must be a simpler way?
Any help would be most appreciated,
Cathal.
Upvotes: 0
Views: 1215
Reputation: 2357
You are looking for parameterized commands as described in this wiki and this article. The former concentrates on the programmatic invocation, while the latter provides a thorough explanation of the declarative side of parameterized commands.
Upvotes: 1