View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  
18  package com.atlassian.theplugin.idea.jira;
19  
20  import com.atlassian.theplugin.commons.UiTask;
21  import com.atlassian.theplugin.commons.UiTaskAdapter;
22  import com.atlassian.theplugin.commons.remoteapi.ServerData;
23  import com.atlassian.theplugin.commons.util.MiscUtil;
24  import com.atlassian.theplugin.configuration.JiraWorkspaceConfiguration;
25  import com.atlassian.theplugin.idea.config.GenericComboBoxItemWrapper;
26  import com.atlassian.theplugin.idea.ui.DialogWithDetails;
27  import com.atlassian.theplugin.idea.util.IdeaUiMultiTaskExecutor;
28  import com.atlassian.theplugin.jira.JIRAServerFacadeImpl;
29  import com.atlassian.theplugin.jira.api.*;
30  import com.atlassian.theplugin.jira.model.JIRAServerCache;
31  import com.atlassian.theplugin.jira.model.JIRAServerModel;
32  import com.intellij.openapi.progress.ProgressIndicator;
33  import com.intellij.openapi.progress.ProgressManager;
34  import com.intellij.openapi.progress.Task;
35  import com.intellij.openapi.project.Project;
36  import com.intellij.openapi.ui.DialogWrapper;
37  import com.intellij.openapi.ui.Messages;
38  import com.intellij.ui.ColoredListCellRenderer;
39  import com.intellij.ui.SimpleTextAttributes;
40  import com.intellij.uiDesigner.core.GridConstraints;
41  import com.intellij.uiDesigner.core.GridLayoutManager;
42  import org.apache.commons.lang.ArrayUtils;
43  import org.jetbrains.annotations.NotNull;
44  import org.jetbrains.annotations.Nullable;
45  
46  import javax.swing.*;
47  import javax.swing.event.PopupMenuListener;
48  import javax.swing.event.PopupMenuEvent;
49  import java.awt.*;
50  import java.util.ArrayList;
51  import java.util.Collection;
52  import java.util.LinkedHashSet;
53  import java.util.List;
54  
55  public class IssueCreateDialog extends DialogWrapper {
56  	private JPanel mainPanel;
57  	private JTextArea description;
58  	private JComboBox projectComboBox;
59  	private JComboBox typeComboBox;
60  	private JTextField summary;
61  	private JComboBox priorityComboBox;
62  	private JTextField assignee;
63  	private JList componentsList;
64  	private JList versionsList;
65  	private final ServerData jiraServer;
66  	private IssueListToolWindowPanel issueListToolWindowPanel;
67  	private Project project;
68  	private final JIRAServerModel model;
69  	private JiraWorkspaceConfiguration jiraConfiguration;
70  
71  	public IssueCreateDialog(@NotNull IssueListToolWindowPanel issueListToolWindowPanel,
72  			@NotNull Project project, JIRAServerModel model, ServerData server,
73  			@NotNull final JiraWorkspaceConfiguration jiraProjectCfg) {
74  		super(false);
75  		this.issueListToolWindowPanel = issueListToolWindowPanel;
76  		this.project = project;
77  		this.model = model;
78  		this.jiraConfiguration = jiraProjectCfg;
79  		$$$setupUI$$$();
80  		componentsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
81  		init();
82  		pack();
83  
84  		this.jiraServer = server;
85  		setTitle("Create JIRA Issue");
86  
87  		projectComboBox.setRenderer(new ColoredListCellRenderer() {
88  			@Override
89  			protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
90  				if (value != null) {
91  					append(((JIRAProject) value).getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
92  				}
93  			}
94  		});
95  
96  		typeComboBox.setRenderer(new ColoredListCellRenderer() {
97  			@Override
98  			protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
99  				if (value != null) {
100 					JIRAConstant type = (JIRAConstant) value;
101 					append(type.getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
102 					setIcon(CachedIconLoader.getIcon(type.getIconUrl()));
103 				}
104 			}
105 		});
106 		typeComboBox.setEnabled(false);
107 
108 		priorityComboBox.setRenderer(new ColoredListCellRenderer() {
109 			@Override
110 			protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
111 				if (value != null) {
112 					JIRAConstant priority = (JIRAConstant) value;
113 					append(priority.getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
114 					setIcon(CachedIconLoader.getIcon(priority.getIconUrl()));
115 				}
116 			}
117 		});
118 
119         projectComboBox.addPopupMenuListener(new PopupMenuListener() {
120 
121             private Object item = null;
122             public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent) {
123                 item = projectComboBox.getSelectedItem();
124             }
125 
126             public void popupMenuWillBecomeInvisible(PopupMenuEvent popupMenuEvent) {
127                 if (item != null && item != projectComboBox.getSelectedItem()) {
128                     updateProjectRelatedItems();
129                 }
130             }
131 
132             public void popupMenuCanceled(PopupMenuEvent popupMenuEvent) {
133                 item = null;
134             }
135         });
136 		getOKAction().setEnabled(false);
137 		getOKAction().putValue(Action.NAME, "Create");
138 	}
139 
140     private boolean issueTypesUpdated = false;
141     private boolean componentsUpdated = false;
142     private boolean versionsUpdated = false;
143 
144     private void updateProjectRelatedItems() {
145         JIRAProject p = (JIRAProject) projectComboBox.getSelectedItem();
146         List<UiTask> tasks = new ArrayList<UiTask>();
147         issueTypesUpdated = false;
148         componentsUpdated = false;
149         versionsUpdated = false;
150         setProjectComboBoxEnableState();
151         tasks.add(updateIssueTypes(p));
152         tasks.add(updateComponents(p));
153         tasks.add(updateVersions(p));
154         IdeaUiMultiTaskExecutor.execute(tasks, getContentPane());
155     }
156 
157     private void setProjectComboBoxEnableState() {
158         projectComboBox.setEnabled(issueTypesUpdated && componentsUpdated && versionsUpdated);
159     }
160 
161     public void initData() {
162 		List<UiTask> tasks = new ArrayList<UiTask>();
163 		tasks.add(updatePriorities());
164 		tasks.add(updateProject());
165 		IdeaUiMultiTaskExecutor.execute(tasks, getContentPane());
166 	}
167 
168 	private UiTaskAdapter updateProject() {
169 		projectComboBox.setEnabled(false);
170 		getOKAction().setEnabled(false);
171 
172 		return new UiTaskAdapter("retrieving projects", getContentPane()) {
173 			private List<JIRAProject> projects = new ArrayList<JIRAProject>();
174 
175 			public void run() throws JIRAException {
176 				projects = model.getProjects(jiraServer);
177 			}
178 
179 			public void onSuccess() {
180 				addProjects(projects);
181 			}
182 
183 			public void onError() {
184 				addProjects(projects);
185 			}
186 		};
187 	}
188 
189 	private void addProjects(List<JIRAProject> projects) {
190 		projectComboBox.removeAllItems();
191 
192 		for (JIRAProject project : projects) {
193 			if (project.getId() != JIRAServerCache.ANY_ID) {
194 				projectComboBox.addItem(project);
195 			}
196 		}
197 
198 		if (projectComboBox.getModel().getSize() > 0) {
199 
200 			boolean defaultSelected = false;
201 
202 			// select default project
203 			if (jiraConfiguration != null &&
204 					jiraConfiguration.getView().getServerDefaults().containsKey(jiraServer.getServerId())) {
205 
206 				String project = jiraConfiguration.getView().getServerDefaults().
207 						get(jiraServer.getServerId()).getProject();
208 
209 				for (int i = 0; i < projectComboBox.getItemCount(); ++i) {
210 					if (projectComboBox.getItemAt(i) instanceof JIRAProject) {
211 						if (((JIRAProject) projectComboBox.getItemAt(i)).getKey().equals(project)) {
212 							projectComboBox.setSelectedIndex(i);
213 							defaultSelected = true;
214 							break;
215 						}
216 					}
217 				}
218 			}
219 
220 			if (!defaultSelected) {
221 				projectComboBox.setSelectedIndex(0);
222 			}
223 		}
224         updateProjectRelatedItems();
225 	}
226 
227 	private UiTask updatePriorities() {
228 		priorityComboBox.setEnabled(false);
229 		getOKAction().setEnabled(false);
230 
231 		return new UiTaskAdapter("retrieving priorities", getContentPane()) {
232 			private List<JIRAConstant> priorities = new ArrayList<JIRAConstant>();
233 
234 			public void run() throws Exception {
235 				priorities = model.getPriorities(jiraServer, myPerformAction);
236 			}
237 
238 			public void onSuccess() {
239 				addIssuePriorities(priorities);
240 			}
241 
242 			public void onError() {
243 				addIssuePriorities(priorities);
244 			}
245 		};
246 	}
247 
248 	private void addIssuePriorities(List<JIRAConstant> priorieties) {
249 		priorityComboBox.removeAllItems();
250 		for (JIRAConstant constant : priorieties) {
251 			if (constant.getId() != JIRAServerCache.ANY_ID) {
252 				priorityComboBox.addItem(constant);
253 			}
254 		}
255 		if (priorityComboBox.getModel().getSize() > 0) {
256 			priorityComboBox.setSelectedIndex(priorityComboBox.getModel().getSize() / 2);
257 		}
258 		priorityComboBox.setEnabled(true);
259 	}
260 
261 	private UiTask updateIssueTypes(final JIRAProject project) {
262 		typeComboBox.setEnabled(false);
263 		getOKAction().setEnabled(false);
264 		return new UiTaskAdapter("retrieving issue types", getContentPane()) {
265 			private List<JIRAConstant> issueTypes = new ArrayList<JIRAConstant>();
266 
267 			public void run() throws Exception {
268 				issueTypes = model.getIssueTypes(jiraServer, project, true);
269 			}
270 
271 			public void onSuccess() {
272 				addIssueTypes(issueTypes);
273                 issueTypesUpdated = true;
274                 setProjectComboBoxEnableState();
275 			}
276 
277 			public void onError() {
278 				addIssueTypes(issueTypes);
279                 issueTypesUpdated = true;
280                 setProjectComboBoxEnableState();
281 			}
282 		};
283 	}
284 
285 	private UiTask updateComponents(final JIRAProject project) {
286 		componentsList.setEnabled(false);
287 		getOKAction().setEnabled(false);
288 		return new UiTaskAdapter("fetching components", getContentPane()) {
289 			private List<JIRAComponentBean> components;
290 
291 			public void run() throws Exception {
292 				components = model.getComponents(jiraServer, project, true);
293 			}
294 
295 			@Override
296 			public void onSuccess() {
297                 componentsUpdated = true;
298                 setProjectComboBoxEnableState();
299 				addComponents(components);
300 			}
301 
302             @Override
303             public void onError() {
304                 componentsUpdated = true;
305                 setProjectComboBoxEnableState();
306             }
307         };
308 	}
309 
310 	private UiTask updateVersions(final JIRAProject project) {
311 		versionsList.setEnabled(false);
312 		getOKAction().setEnabled(false);
313 		return new UiTaskAdapter("fetching versions", getContentPane()) {
314 			private List<JIRAVersionBean> versions;
315 
316 			public void run() throws Exception {
317 				versions = model.getVersions(jiraServer, project, false);
318 			}
319 
320 			@Override
321 			public void onSuccess() {
322                 versionsUpdated = true;
323                 setProjectComboBoxEnableState();
324 				addVersions(versions);
325 			}
326 
327             @Override
328             public void onError() {
329                 versionsUpdated = true;
330                 setProjectComboBoxEnableState();
331             }
332         };
333 	}
334 
335 	private void addVersions(List<JIRAVersionBean> versions) {
336 		versionsList.removeAll();
337 		final DefaultListModel listModel = new DefaultListModel();
338 		for (JIRAVersionBean version : versions) {
339 			if (version != null && version.getId() != JIRAServerCache.ANY_ID) {
340 				listModel.addElement(new VersionWrapper(version));
341 			}
342 		}
343 		versionsList.setModel(listModel);
344 		versionsList.setEnabled(true);
345 		getOKAction().setEnabled(true);
346 	}
347 
348 
349 	private void addIssueTypes(List<JIRAConstant> issueTypes) {
350 		typeComboBox.removeAllItems();
351 		for (JIRAConstant constant : issueTypes) {
352 			if (constant.getId() != JIRAServerCache.ANY_ID) {
353 				typeComboBox.addItem(constant);
354 			}
355 		}
356 		typeComboBox.setEnabled(true);
357 		getOKAction().setEnabled(true);
358 	}
359 
360 
361 	private void addComponents(Collection<JIRAComponentBean> components) {
362 		final DefaultListModel listModel = new DefaultListModel();
363 		for (JIRAComponentBean constant : components) {
364 			if (constant != null && constant.getId() != JIRAServerCache.ANY_ID) {
365 				listModel.addElement(new ComponentWrapper(constant));
366 			}
367 		}
368 		componentsList.setModel(listModel);
369 
370 		if (projectComboBox.getSelectedItem() != null && jiraConfiguration != null && jiraConfiguration.getView() != null
371 				&& jiraConfiguration.getView().getServerDefaults() != null
372 				&& jiraConfiguration.getView().getServerDefaults().containsKey(jiraServer.getServerId())) {
373 
374 			String selectedProject = ((JIRAProject) projectComboBox.getSelectedItem()).getKey();
375 
376 			String configProject = jiraConfiguration.getView().getServerDefaults().
377 					get(jiraServer.getServerId()).getProject();
378 
379 			Collection<Long> configComponents = jiraConfiguration.getView().getServerDefaults().
380 					get(jiraServer.getServerId()).getComponents();
381 
382 			// select default components for specified project
383 			if (selectedProject.equals(configProject)) {
384 
385 				ArrayList<Integer> indexesToSelect = new ArrayList<Integer>(componentsList.getModel().getSize() + 1);
386 
387 				for (int i = 0; i < componentsList.getModel().getSize(); ++i) {
388 					if (componentsList.getModel().getElementAt(i) instanceof ComponentWrapper) {
389 						ComponentWrapper wrapper = (ComponentWrapper) componentsList.getModel().getElementAt(i);
390 
391 						if (wrapper.getWrapped() != null) {
392 							JIRAComponentBean component = wrapper.getWrapped();
393 
394 							if (configComponents.contains(component.getId())) {
395 								indexesToSelect.add(i);
396 							}
397 						}
398 					}
399 				}
400 
401 				if (indexesToSelect.size() > 0) {
402 					componentsList.setSelectedIndices(ArrayUtils.toPrimitive(indexesToSelect.toArray(new Integer[0])));
403 				}
404 			}
405 		}
406 
407 		componentsList.setEnabled(true);
408 		getOKAction().setEnabled(true);
409 	}
410 
411 	private JIRAIssueBean issueProxy;
412 
413 	JIRAIssue getJIRAIssue() {
414 		return issueProxy;
415 	}
416 
417 	@Override
418 	protected void doOKAction() {
419 		issueProxy = new JIRAIssueBean();
420 		issueProxy.setSummary(summary.getText());
421 
422 		if (projectComboBox.getSelectedItem() == null) {
423 			Messages.showErrorDialog(this.getContentPane(), "Project has to be selected", "Project not defined");
424 			return;
425 		}
426 		issueProxy.setProjectKey(((JIRAProject) projectComboBox.getSelectedItem()).getKey());
427 		if (typeComboBox.getSelectedItem() == null) {
428 			Messages.showErrorDialog(this.getContentPane(), "Issue type has to be selected", "Issue type not defined");
429 			return;
430 		}
431 		issueProxy.setType(((JIRAConstant) typeComboBox.getSelectedItem()));
432 		issueProxy.setDescription(description.getText());
433 		issueProxy.setPriority(((JIRAConstant) priorityComboBox.getSelectedItem()));
434 		List<JIRAConstant> components = MiscUtil.buildArrayList();
435 		Collection<Long> selectedComponents = new LinkedHashSet<Long>();
436 		for (Object selectedObject : componentsList.getSelectedValues()) {
437 			if (selectedObject instanceof ComponentWrapper) {
438 				ComponentWrapper componentWrapper = (ComponentWrapper) selectedObject;
439 				if (componentWrapper.getWrapped().getId() == JIRAServerCache.UNKNOWN_COMPONENT_ID) {
440 					if (componentsList.getSelectedValues().length > 1) {
441 						Messages.showErrorDialog(getContentPane(), "You cannot select \"Unknown\" with a specific component.");
442 						return;
443 					}
444 				}
445 				components.add(componentWrapper.getWrapped());
446 				selectedComponents.add(componentWrapper.getWrapped().getId());
447 			}
448 		}
449 		if (versionsList.getSelectedValues().length > 0) {
450 			List<JIRAConstant> versions = new ArrayList<JIRAConstant>();
451 			for (Object ver : versionsList.getSelectedValues()) {
452 				VersionWrapper vw = (VersionWrapper) ver;
453 				versions.add(vw.getWrapped());
454 			}
455 			issueProxy.setAffectsVersions(versions);
456 		}
457 
458 		if (components.size() > 0) {
459 			issueProxy.setComponents(components);
460 		}
461 		String assignTo = assignee.getText();
462 		if (assignTo.length() > 0) {
463 			issueProxy.setAssignee(assignTo);
464 		}
465 
466 		// save selected project and components to the config
467 		if (jiraConfiguration != null && jiraConfiguration.getView() != null) {
468 			JIRAProject p = (JIRAProject) projectComboBox.getSelectedItem();
469 			jiraConfiguration.getView().addServerDefault(jiraServer.getServerId(), p.getKey(), selectedComponents);
470 		}
471 
472 		createIssueAndCloseOnSuccess();
473 	}
474 
475 	private void createIssueAndCloseOnSuccess() {
476 		Task createTask = new Task.Modal(project, "Creating Issue", false) {
477 			@Override
478 			public void run(@NotNull final ProgressIndicator indicator) {
479 				String message;
480 				try {
481 					JIRAIssue issueToCreate = getJIRAIssue();
482 					final JIRAIssue createdIssue =
483 							JIRAServerFacadeImpl.getInstance().createIssue(jiraServer, issueToCreate);
484 
485 					message = "New issue created: <a href="
486 							+ createdIssue.getIssueUrl()
487 							+ ">"
488 							+ createdIssue.getKey()
489 							+ "</a>";
490 
491 					issueListToolWindowPanel.setStatusInfoMessage(message);
492 
493 					EventQueue.invokeLater(new Runnable() {
494 						public void run() {
495 							issueListToolWindowPanel.openIssue(createdIssue);
496 							issueListToolWindowPanel.refreshIssues(true);
497 							close(0);
498 						}
499 					});
500 				} catch (final JIRAException e) {
501 					EventQueue.invokeLater(new Runnable() {
502 						public void run() {
503 							DialogWithDetails.showExceptionDialog(project, "Failed to create new issue", e);
504 						}
505 					});
506 				}
507 			}
508 
509 		};
510 
511 		ProgressManager.getInstance().run(createTask);
512 	}
513 
514 	@Override
515 	public JComponent getPreferredFocusedComponent() {
516 		return summary;
517 	}
518 
519 	@Override
520 	@Nullable
521 	protected JComponent createCenterPanel() {
522 		return mainPanel;
523 	}
524 
525 	public JPanel getRootComponent() {
526 		return mainPanel;
527 	}
528 
529 	/**
530 	 * Method generated by IntelliJ IDEA GUI Designer
531 	 * >>> IMPORTANT!! <<<
532 	 * DO NOT edit this method OR call it in your code!
533 	 *
534 	 * @noinspection ALL
535 	 */
536 	private void $$$setupUI$$$() {
537 		mainPanel = new JPanel();
538 		mainPanel.setLayout(new GridLayoutManager(9, 3, new Insets(5, 5, 5, 5), -1, -1));
539 		mainPanel.setMinimumSize(new Dimension(480, 500));
540 		final JScrollPane scrollPane1 = new JScrollPane();
541 		mainPanel.add(scrollPane1, new GridConstraints(6, 1, 2, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
542 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
543 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
544 		description = new JTextArea();
545 		description.setLineWrap(true);
546 		description.setWrapStyleWord(true);
547 		scrollPane1.setViewportView(description);
548 		final JLabel label1 = new JLabel();
549 		label1.setText("Summary:");
550 		mainPanel.add(label1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
551 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
552 		final JLabel label2 = new JLabel();
553 		label2.setText("Project:");
554 		mainPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
555 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
556 		projectComboBox = new JComboBox();
557 		mainPanel.add(projectComboBox, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST,
558 				GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
559 				GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false));
560 		summary = new JTextField();
561 		mainPanel.add(summary, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
562 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED,
563 				null, new Dimension(100, -1), null, 0, false));
564 		final JLabel label3 = new JLabel();
565 		label3.setText("Description:");
566 		mainPanel.add(label3, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE,
567 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
568 		final JLabel label4 = new JLabel();
569 		label4.setText("Assignee:");
570 		mainPanel.add(label4, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
571 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
572 		assignee = new JTextField();
573 		mainPanel.add(assignee, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
574 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED,
575 				new Dimension(50, -1), new Dimension(150, -1), null, 0, false));
576 		final JLabel label5 = new JLabel();
577 		label5.setFont(new Font(label5.getFont().getName(), label5.getFont().getStyle(), 10));
578 		label5.setHorizontalTextPosition(10);
579 		label5.setText("Warning! This field is not validated prior to sending to JIRA");
580 		mainPanel.add(label5, new GridConstraints(8, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
581 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED,
582 				null, null, null, 0, false));
583 		final JLabel label6 = new JLabel();
584 		label6.setText("Type:");
585 		mainPanel.add(label6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
586 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
587 		typeComboBox = new JComboBox();
588 		mainPanel.add(typeComboBox, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST,
589 				GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
590 				GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
591 		final JLabel label7 = new JLabel();
592 		label7.setText("Priority:");
593 		mainPanel.add(label7, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
594 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
595 		priorityComboBox = new JComboBox();
596 		mainPanel.add(priorityComboBox, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST,
597 				GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
598 				GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false));
599 		final JLabel label8 = new JLabel();
600 		label8.setText("Component/s:");
601 		mainPanel.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE,
602 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
603 		final JScrollPane scrollPane2 = new JScrollPane();
604 		mainPanel.add(scrollPane2, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
605 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED,
606 				null, null, null, 0, false));
607 		componentsList = new JList();
608 		componentsList.setToolTipText("Select Affected Components ");
609 		componentsList.setVisibleRowCount(5);
610 		scrollPane2.setViewportView(componentsList);
611 		final JLabel label9 = new JLabel();
612 		label9.setText("Affects Version/s:");
613 		mainPanel.add(label9, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE,
614 				GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
615 		final JScrollPane scrollPane3 = new JScrollPane();
616 		mainPanel.add(scrollPane3, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
617 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
618 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
619 		versionsList = new JList();
620 		versionsList.setVisibleRowCount(5);
621 		scrollPane3.setViewportView(versionsList);
622 		label1.setLabelFor(summary);
623 		label2.setLabelFor(projectComboBox);
624 		label3.setLabelFor(description);
625 		label6.setLabelFor(typeComboBox);
626 	}
627 
628 	/**
629 	 * @noinspection ALL
630 	 */
631 	public JComponent $$$getRootComponent$$$() {
632 		return mainPanel;
633 	}
634 
635     private static class ComponentWrapper extends GenericComboBoxItemWrapper<JIRAComponentBean> {
636 
637 		public ComponentWrapper(@NotNull final JIRAComponentBean wrapped) {
638 			super(wrapped);
639 		}
640 
641 		@Override
642 		public String toString() {
643 			return wrapped.getName();
644 		}
645 	}
646 
647 	private static class VersionWrapper extends GenericComboBoxItemWrapper<JIRAVersionBean> {
648 
649 		public VersionWrapper(@NotNull final JIRAVersionBean wrapped) {
650 			super(wrapped);
651 		}
652 
653 		@Override
654 		public String toString() {
655 			return wrapped.getName();
656 		}
657 	}
658 }