Skip to content

Commit

Permalink
Merge commit '4a0c6'
Browse files Browse the repository at this point in the history
Conflicts:
	ccw.core/src/java/ccw/repl/ConnectDialog.java
  • Loading branch information
laurentpetit committed Nov 15, 2012
2 parents 83f0fd8 + 4a0c6f9 commit 6d97ca4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 39 deletions.
10 changes: 9 additions & 1 deletion ccw.core/src/java/ccw/repl/Actions.java
Expand Up @@ -23,7 +23,15 @@ private Actions () {}
public static class Connect extends AbstractHandler {
public Object execute (ExecutionEvent event) throws ExecutionException {
try {
return REPLView.connect();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ConnectDialog dlg = new ConnectDialog(window.getShell());

REPLView repl = null;
if (dlg.open() == ConnectDialog.OK) {
repl = REPLView.connect(dlg.getURL());
}

return repl;
} catch (Exception e) {
throw new ExecutionException("Could not connect to repl", e);
}
Expand Down
23 changes: 6 additions & 17 deletions ccw.core/src/java/ccw/repl/ConnectDialog.java
Expand Up @@ -14,10 +14,10 @@
import org.eclipse.swt.widgets.Text;

public class ConnectDialog extends Dialog {
private Combo hosts;
private Text hosts;
private Text port;
private String host;
private int portNumber;
private String url;

public ConnectDialog(Shell parentShell) {
super(parentShell);
Expand All @@ -39,7 +39,7 @@ protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(2, false));
new Label(parent, 0).setText("Hostname");

hosts = new Combo(parent, SWT.BORDER);
hosts = new Text(parent, SWT.BORDER);
hosts.setText("127.0.0.1"); // don't know much about swt layouts yet :-(
hosts.setSelection(new Point(0, hosts.getText().length()));

Expand All @@ -58,22 +58,11 @@ public void verifyText(VerifyEvent e) {
}

protected void okPressed () {
host = hosts.getText();

try {
portNumber = Integer.parseInt(port.getText());
} catch (NumberFormatException e) {
// shouldn't happen given the keylistener above
}

url = String.format("nrepl://%s:%s", hosts.getText(), port.getText());
super.okPressed();
}

public String getHost () {
return host;
}

public int getPort () {
return portNumber;
public String getURL () {
return url;
}
}
21 changes: 0 additions & 21 deletions ccw.core/src/java/ccw/repl/REPLView.java
Expand Up @@ -341,27 +341,6 @@ public boolean configure (String url) throws Exception {
}
}

public static REPLView connect () throws Exception {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ConnectDialog dlg = new ConnectDialog(window.getShell());

REPLView repl = null;
if (dlg.open() == ConnectDialog.OK) {
// cannot find any way to create a configured/connected REPLView, and install it programmatically
String host = dlg.getHost();
int port = dlg.getPort();
if (host == null || host.length() == 0 || port < 0 || port > 65535) {
MessageDialog.openInformation(window.getShell(),
"Invalid connection info",
"You must provide a useful hostname and port number to connect to a REPL.");
} else {
repl = connect(String.format("nrepl://%s:%s", host, port));
}
}

return repl;
}

public static REPLView connect (String url) throws Exception {
return connect(url, null, null);
}
Expand Down

0 comments on commit 6d97ca4

Please sign in to comment.