package floobits;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.List;

public class SelectOwner extends DialogWrapper {
    private JPanel jPanel;
    private RunLater runLater;
    private String owner;

    public static void build(final List<String> title, final RunLater runLater) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
                SelectOwner SelectOwner = new SelectOwner(title, runLater);
                SelectOwner.createCenterPanel();
                SelectOwner.show();
            }
        });
    }

    @Nullable
    @Override
    protected JComponent createCenterPanel() {
        return jPanel;
    }

    protected SelectOwner(List<String> title, RunLater runLater) {
        super(true);
        jPanel = new JPanel();
        this.runLater = runLater;
        init();
        this.setTitle("Select Workspace Owner");

        final JComboBox orgList = new JComboBox(title.toArray());
        // petList.setSelectedIndex(4);
        orgList.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                owner = (String)orgList.getSelectedItem();
            }
        });

        JLabel jLabel = new JLabel();
        jLabel.setText("Select the owner for the workspace:");
        jPanel.add(jLabel);
        jPanel.add(orgList);
    }

    @Override
    public void doCancelAction() {
        super.doCancelAction();
        // runLater.run(false);
    }

    @Override
    protected void doOKAction() {
        super.doOKAction();
        runLater.run(owner);
    }
}

@@ -257,16 +257,57 @@
 wing.*;%0A
+import com.intellij.openapi.ui.ComboBox;%0A
 import j
@@ -321,16 +321,16 @@
 l.List;%0A
-
 %0Apublic 
@@ -445,20 +445,25 @@
 ate 
-String owner
+JComboBox orgList
 ;%0A%0A 
@@ -1200,48 +1200,33 @@
     
-final JComboBox orgList = new JComboBox(
+Object%5B%5D organizations = 
 titl
@@ -1236,17 +1236,16 @@
 oArray()
-)
 ;%0A      
@@ -1250,226 +1250,112 @@
     
-// petList.setSelectedIndex(4);%0A        orgList.addActionListener(new ActionListener() %7B%0A            @Override%0A            public void actionPerformed(ActionEvent actionEvent) %7B%0A                owner = (String)
+orgList = new ComboBox(organizations, 200);%0A        if (organizations.length %3E 0) %7B%0A            
 orgList.
 getS
@@ -1350,17 +1350,17 @@
 orgList.
-g
+s
 etSelect
@@ -1366,12 +1366,14 @@
 tedI
-tem(
+ndex(0
 );%0A 
@@ -1379,34 +1379,17 @@
         
- 
-   %7D%0A        %7D);%0A
+%7D
 %0A       
@@ -1631,40 +1631,8 @@
 ();%0A
-        // runLater.run(false);%0A
     
@@ -1722,26 +1722,114 @@
     
-runLater.run(owner
+if(orgList == null) %7B%0A            return;%0A        %7D%0A        runLater.run((String)orgList.getSelectedItem()
 );%0A 

FIx dialog null owner bug. Closes #3.