0

I'm writing an Eclipseplugin, which has to create a new project. This works so far, but i need to copy an external file into the projectfolder. I intend to have a 'Browse' button on one of my WizardPages, which opens a filedialog, where the user can browse to the file and after closing the dialog i can use the path to this file for various actions. My problem is that the dialog window never opens. Right now i'm trying it that way (snippet from my wizardpage):

    public void createControl(Composite composite) {
        this.container = new Composite(composite, SWT.NONE);
        GridLayout layout = new GridLayout();
        this.container.setLayout(layout);
        layout.numColumns = 2;

        Button browseButton = new Button(this.container, SWT.PUSH);
        browseButton.setText("Browse");
        browseButton.addSelectionListener(new SelectionListener() {

           @Override
           public void widgetDefaultSelected(SelectionEvent arg0) {

              FileDialog fileDialog = new FileDialog(DataPage.this.container.getShell(), SWT.OPEN);         
              fileDialog.setText("JZOS created File");
              String path = fileDialog.open();
              DataPage.this.setJzosCreatedName(path);

        }
    });

I tried several implementations, that i have seen in examples and tutorials but nothing did work. I'm assuming a problem with the Shell that i give to the filedialog. I tried to open a new Shell within the widgetDefaultSelected function but it didn't work either. Any Suggestions?

Metalzwerg
  • 23
  • 1
  • 7

1 Answers1

0

You should be using the widgetSelected method of SelectionListener not widgetDefaultSelected

greg-449
  • 109,219
  • 232
  • 102
  • 145