3
3
import com .intellij .openapi .project .Project ;
4
4
import com .intellij .psi .PsiDirectory ;
5
5
import com .magento .idea .magento2plugin .actions .generation .NewDataModelAction ;
6
+ import com .magento .idea .magento2plugin .actions .generation .NewMessageQueueAction ;
7
+ import com .magento .idea .magento2plugin .actions .generation .data .QueueCommunicationData ;
8
+ import com .magento .idea .magento2plugin .actions .generation .data .QueueConsumerData ;
9
+ import com .magento .idea .magento2plugin .actions .generation .data .QueuePublisherData ;
10
+ import com .magento .idea .magento2plugin .actions .generation .data .QueueTopologyData ;
6
11
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .FieldValidation ;
7
12
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .RuleRegistry ;
8
13
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AlphaWithDashRule ;
@@ -31,11 +36,13 @@ public class NewMessageQueueDialog extends AbstractDialog {
31
36
private static final String HANDLER_TYPE = "Handler Type" ;
32
37
private static final String HANDLER_METHOD = "Handler Method" ;
33
38
private static final String CONSUMER_NAME = "Consumer Name" ;
34
- private static final String MAX_MESSAGES = "Maximum Messages " ;
39
+ private static final String QUEUE_NAME = "Queue Name " ;
35
40
private static final String CONSUMER_TYPE = "Consumer Type" ;
41
+ private static final String MAX_MESSAGES = "Maximum Messages" ;
36
42
private static final String CONNECTION_NAME = "Connection Name" ;
37
43
private static final String EXCHANGE_NAME = "Exchange Name" ;
38
- private static final String QUEUE_NAME = "Queue Name" ;
44
+ private static final String BINDING_ID = "Binding ID" ;
45
+ private static final String BINDING_TOPIC = "Binding Topic" ;
39
46
40
47
/* TODO: Improve validation */
41
48
@ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
@@ -72,17 +79,25 @@ public class NewMessageQueueDialog extends AbstractDialog {
72
79
private JTextField consumerName ;
73
80
74
81
@ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
75
- message = {NotEmptyRule .MESSAGE , MAX_MESSAGES })
76
- @ FieldValidation (rule = RuleRegistry .NUMERIC ,
77
- message = {NumericRule .MESSAGE , MAX_MESSAGES })
78
- private JTextField maxMessages ;
82
+ message = {NotEmptyRule .MESSAGE , QUEUE_NAME })
83
+ @ FieldValidation (rule = RuleRegistry .ALPHA_WITH_PERIOD ,
84
+ message = {AlphaWithPeriodRule .MESSAGE , QUEUE_NAME })
85
+ @ FieldValidation (rule = RuleRegistry .LOWERCASE ,
86
+ message = {Lowercase .MESSAGE , QUEUE_NAME })
87
+ private JTextField queueName ;
79
88
80
89
@ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
81
90
message = {NotEmptyRule .MESSAGE , CONSUMER_TYPE })
82
91
@ FieldValidation (rule = RuleRegistry .PHP_CLASS ,
83
92
message = {PhpClassRule .MESSAGE , CONSUMER_TYPE })
84
93
private JTextField consumerType ;
85
94
95
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
96
+ message = {NotEmptyRule .MESSAGE , MAX_MESSAGES })
97
+ @ FieldValidation (rule = RuleRegistry .NUMERIC ,
98
+ message = {NumericRule .MESSAGE , MAX_MESSAGES })
99
+ private JTextField maxMessages ;
100
+
86
101
/* TODO: Can this be made a dropdown? */
87
102
@ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
88
103
message = {NotEmptyRule .MESSAGE , CONNECTION_NAME })
@@ -97,12 +112,15 @@ public class NewMessageQueueDialog extends AbstractDialog {
97
112
private JTextField exchangeName ;
98
113
99
114
@ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
100
- message = {NotEmptyRule .MESSAGE , QUEUE_NAME })
101
- @ FieldValidation (rule = RuleRegistry .ALPHA_WITH_PERIOD ,
102
- message = {AlphaWithPeriodRule .MESSAGE , QUEUE_NAME })
103
- @ FieldValidation (rule = RuleRegistry .LOWERCASE ,
104
- message = {Lowercase .MESSAGE , QUEUE_NAME })
105
- private JTextField queueName ;
115
+ message = {NotEmptyRule .MESSAGE , EXCHANGE_NAME })
116
+ @ FieldValidation (rule = RuleRegistry .ALPHANUMERIC_WITH_UNDERSCORE ,
117
+ message = {AlphaWithDashRule .MESSAGE , EXCHANGE_NAME })
118
+ private JTextField bindingId ;
119
+
120
+ /* TODO: New validation rule */
121
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
122
+ message = {NotEmptyRule .MESSAGE , EXCHANGE_NAME })
123
+ private JTextField bindingTopic ;
106
124
107
125
private JPanel contentPanel ;
108
126
private JButton buttonOK ;
@@ -175,14 +193,86 @@ private void onOK() {
175
193
}
176
194
177
195
private void generateCommunication () {
196
+ new QueueCommunicationGenerator (project , new QueueCommunicationData (
197
+ getTopicName (),
198
+ getHandlerName (),
199
+ getHandlerType (),
200
+ getHandlerMethod ()
201
+ )).generate (NewMessageQueueAction .ACTION_NAME , true );
178
202
}
179
203
180
204
private void generateConsumer () {
205
+ new QueueConsumerGenerator (project , new QueueConsumerData (
206
+ getConsumerName (),
207
+ getQueueName (),
208
+ getConsumerType (),
209
+ getMaxMessages (),
210
+ getConnectionName ()
211
+ )).generate (NewMessageQueueAction .ACTION_NAME , true );
181
212
}
182
213
183
214
private void generateTopology () {
215
+ new QueueTopologyGenerator (project , new QueueTopologyData (
216
+ getExchangeName (),
217
+ getBindingId (),
218
+ getBindingTopic (),
219
+ getQueueName ()
220
+ )).generate (NewMessageQueueAction .ACTION_NAME , true );
184
221
}
185
222
186
223
private void generatePublisher () {
224
+ new QueuePublisherGenerator (project , new QueuePublisherData (
225
+ getTopicName (),
226
+ getConnectionName (),
227
+ getExchangeName ()
228
+ )).generate (NewMessageQueueAction .ACTION_NAME , true );
229
+ }
230
+
231
+ public String getTopicName () {
232
+ return topicName .getText ().trim ();
233
+ }
234
+
235
+ public String getHandlerName () {
236
+ return handlerName .getText ().trim ();
237
+ }
238
+
239
+ public String getHandlerType () {
240
+ return handlerType .getText ().trim ();
241
+ }
242
+
243
+ public String getHandlerMethod () {
244
+ return handlerMethod .getText ().trim ();
245
+ }
246
+
247
+ public String getConsumerName () {
248
+ return consumerName .getText ().trim ();
249
+ }
250
+
251
+ public String getQueueName () {
252
+ return queueName .getText ().trim ();
253
+ }
254
+
255
+ public String getConsumerType () {
256
+ return consumerType .getText ().trim ();
257
+ }
258
+
259
+ public String getMaxMessages () {
260
+ return maxMessages .getText ().trim ();
261
+ }
262
+
263
+ public String getConnectionName () {
264
+ return connectionName .getText ().trim ();
265
+ }
266
+
267
+ public String getExchangeName () {
268
+ return exchangeName .getText ().trim ();
269
+ }
270
+
271
+ public String getBindingId () {
272
+ return bindingId .getText ().trim ();
273
+ }
274
+
275
+ public String getBindingTopic () {
276
+ return bindingTopic .getText ().trim ();
187
277
}
188
278
}
0 commit comments