|
@@ -0,0 +1,93 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2015 DMDirc Developers
|
|
3
|
+ *
|
|
4
|
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+ * of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+ * in the Software without restriction, including without limitation the rights
|
|
7
|
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+ * copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+ * furnished to do so, subject to the following conditions:
|
|
10
|
+ *
|
|
11
|
+ * The above copyright notice and this permission notice shall be included in
|
|
12
|
+ * all copies or substantial portions of the Software.
|
|
13
|
+ *
|
|
14
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+ * SOFTWARE.
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+package com.dmdirc.addons.ui_swing.dialogs.globalautocommand;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.addons.ui_swing.components.IconManager;
|
|
26
|
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
|
|
27
|
+import com.dmdirc.addons.ui_swing.components.validating.ValidationFactory;
|
|
28
|
+import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
|
|
29
|
+import com.dmdirc.addons.ui_swing.injection.MainWindow;
|
|
30
|
+import com.dmdirc.commandparser.auto.AutoCommand;
|
|
31
|
+import com.dmdirc.interfaces.ui.GlobalAutoCommandsDialogModel;
|
|
32
|
+
|
|
33
|
+import java.awt.Dimension;
|
|
34
|
+import java.awt.Window;
|
|
35
|
+
|
|
36
|
+import javax.inject.Inject;
|
|
37
|
+import javax.swing.JScrollPane;
|
|
38
|
+import javax.swing.JTextArea;
|
|
39
|
+
|
|
40
|
+import net.miginfocom.swing.MigLayout;
|
|
41
|
+
|
|
42
|
+/**
|
|
43
|
+ * Command to edit the global {@link AutoCommand} for the client.
|
|
44
|
+ */
|
|
45
|
+public class GlobalAutoCommandDialog extends StandardDialog {
|
|
46
|
+
|
|
47
|
+ private final GlobalAutoCommandsDialogModel model;
|
|
48
|
+ private final IconManager iconManager;
|
|
49
|
+ private JScrollPane scrollPane;
|
|
50
|
+ private JTextArea response;
|
|
51
|
+
|
|
52
|
+ /**
|
|
53
|
+ * Creates a new instance of StandardDialog.
|
|
54
|
+ *
|
|
55
|
+ * @param owner The frame that owns this dialog
|
|
56
|
+ */
|
|
57
|
+ @Inject
|
|
58
|
+ public GlobalAutoCommandDialog(@MainWindow final Window owner,
|
|
59
|
+ final GlobalAutoCommandsDialogModel model,
|
|
60
|
+ final IconManager iconManager) {
|
|
61
|
+ super(owner, ModalityType.MODELESS);
|
|
62
|
+ this.model = model;
|
|
63
|
+ this.iconManager = iconManager;
|
|
64
|
+
|
|
65
|
+ initComponents();
|
|
66
|
+ layoutComponents();
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ private void initComponents() {
|
|
70
|
+ scrollPane = new JScrollPane();
|
|
71
|
+ response = new JTextArea();
|
|
72
|
+ scrollPane.setViewportView(response);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ private void layoutComponents() {
|
|
76
|
+ setLayout(new MigLayout("fill"));
|
|
77
|
+ add(new TextLabel("These commands will be executed when the client starts."),
|
|
78
|
+ "wrap, span 2");
|
|
79
|
+ add(ValidationFactory
|
|
80
|
+ .getValidatorPanel(scrollPane, response, model.getResponseValidator(), iconManager),
|
|
81
|
+ "span 2, grow, push, wrap");
|
|
82
|
+ add(getLeftButton(), " right");
|
|
83
|
+ add(getRightButton(), "");
|
|
84
|
+ setMinimumSize(new Dimension(500, 550));
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ @Override
|
|
88
|
+ public void display() {
|
|
89
|
+ new GlobalAutoCommandController()
|
|
90
|
+ .init(this, model, response, getOkButton(), getCancelButton());
|
|
91
|
+ super.display();
|
|
92
|
+ }
|
|
93
|
+}
|