Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] ConnectDialog woes

Hi everyone,

I took a gander at org.eclipse.ecf.example.collab and concluded that
the first thing that needs to be moved to org.eclipse.ecf.ui is the
ConnectionDialog. The code is usable for the most parts, and besides
fixing bug #149913 [1], there wasn't really much to add besides
providing "popup" error messages (like "The user name field is
empty."), disabling the 'OK' button if not all the fields were
populated, and other such minor details.

However, as I started wrapping things up, I thought about what
happened after the user clicks 'OK' and came to realize that the
question "what do I do with this connection information?" needs to be
answered. You may be thinking, well, that's easy, just create an
IContainer and call the connect(ID, IConnectContext) method. Yes,
well, that's all well and good, but then what happens? How would the
UI know that we're connecting to IRC or a Sudoku game? How would it
know what ViewPart or EditorPart to open up, if any?

The best solution I could think of at the moment is to use a listener.

ConnectionDialog dialog = new ConnectionDialog(shell);
if (dialog.open() == Dialog.OK) {
   // code to retrieve connection information, create the IContainer, etc.
   if (container != null) {
       for (int i = 0; i < listeners.size(); i++) {
           IConnectionListener icl = (IConnectionListener) listeners.get(i);
           icl.handleEvent(container, uri, username, password);
       }
   }
}

The implementation would do something like...

public void handleEvent(IContainer container, String uri, String
username, String password) {
   if (uri.startsWith("irc")) {
       // code to open views, do stuff, etc.
   } else if (uri.startsWith("xmpp")) {
       // open buddy list, etc.
   }
}

The method probably doesn't really need all those parameters, but
anyway, that's not the real problem. It's more that this could get
very ugly (who knows how many ViewParts are going to get activated?),
but this is the only decent solution I've come up with at the moment.
If anyone's got a better idea, I'm all ears.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=149913

Regards,
Rem


Back to the top