|
@@ -34,6 +34,7 @@ import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
|
34
|
34
|
import com.dmdirc.addons.ui_swing.injection.DialogProvider;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
|
36
|
36
|
import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
|
|
37
|
+import com.dmdirc.interfaces.Connection;
|
37
|
38
|
import com.dmdirc.parser.common.ChannelJoinRequest;
|
38
|
39
|
import com.dmdirc.ui.IconManager;
|
39
|
40
|
|
|
@@ -121,12 +122,9 @@ public class ChannelMenu extends JMenu implements ActionListener,
|
121
|
122
|
public void actionPerformed(final ActionEvent e) {
|
122
|
123
|
switch (e.getActionCommand()) {
|
123
|
124
|
case "JoinChannel":
|
124
|
|
- // TODO: This can NPE on both getActiveFrame and getConnection fix me.
|
125
|
|
- new StandardInputDialog(mainFrame, Dialog.ModalityType.MODELESS, iconManager,
|
126
|
|
- "Join Channel", "Enter the name of the channel to join.",
|
127
|
|
- (String s) -> activeFrameManager.getActiveFrame().getContainer()
|
128
|
|
- .getConnection().join(new ChannelJoinRequest(s)))
|
129
|
|
- .displayOrRequestFocus();
|
|
125
|
+ new StandardInputDialog(mainFrame, Dialog.ModalityType.APPLICATION_MODAL,
|
|
126
|
+ iconManager, "Join Channel", "Enter the name of the channel to join.",
|
|
127
|
+ this::doJoinChannel).displayOrRequestFocus();
|
130
|
128
|
break;
|
131
|
129
|
case "ChannelSettings":
|
132
|
130
|
final FrameContainer activeWindow = activeFrameManager.getActiveFrame().
|
|
@@ -141,6 +139,16 @@ public class ChannelMenu extends JMenu implements ActionListener,
|
141
|
139
|
}
|
142
|
140
|
}
|
143
|
141
|
|
|
142
|
+ private void doJoinChannel(final String text) {
|
|
143
|
+ if (activeFrameManager.getActiveFrame() != null) {
|
|
144
|
+ final Connection connection = activeFrameManager.getActiveFrame()
|
|
145
|
+ .getContainer().getConnection();
|
|
146
|
+ if (connection != null) {
|
|
147
|
+ connection.join(new ChannelJoinRequest(text));
|
|
148
|
+ }
|
|
149
|
+ }
|
|
150
|
+ }
|
|
151
|
+
|
144
|
152
|
@Override
|
145
|
153
|
public final void menuSelected(final MenuEvent e) {
|
146
|
154
|
final TextFrame activeFrame = activeFrameManager.getActiveFrame();
|