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  package com.atlassian.theplugin.idea.config.serverconfig;
18  
19  import com.atlassian.theplugin.commons.cfg.CrucibleServerCfg;
20  import com.atlassian.theplugin.commons.crucible.CrucibleServerFacade;
21  import com.intellij.uiDesigner.core.GridConstraints;
22  import com.intellij.uiDesigner.core.GridLayoutManager;
23  import org.jetbrains.annotations.NotNull;
24  
25  import javax.swing.*;
26  import java.awt.*;
27  
28  
29  public class CrucibleDetailConfigForm {
30  
31  	private JPanel rootComponent;
32  
33  	private JCheckBox cbFisheye;
34  	private final transient CrucibleServerFacade crucibleServerFacade;
35  
36  	public CrucibleServerCfg getCrucibleServerCfg() {
37  		return crucibleServerCfg;
38  	}
39  
40  	private CrucibleServerCfg crucibleServerCfg;
41  
42  	public CrucibleDetailConfigForm(CrucibleServerFacade crucibleServerFacade) {
43  		this.crucibleServerFacade = crucibleServerFacade;
44  
45  		$$$setupUI$$$();
46  	}
47  
48  	public void setIsFishEyeInstance(boolean isFishEyeInstance) {
49  		cbFisheye.setSelected(isFishEyeInstance);
50  	}
51  
52  	public void setData(@NotNull final CrucibleServerCfg serverCfg) {
53  		crucibleServerCfg = serverCfg;
54  		cbFisheye.setSelected(crucibleServerCfg.isFisheyeInstance());
55  	}
56  
57  	public void saveData() {
58  		if (crucibleServerCfg == null) {
59  			return;
60  		}
61  		crucibleServerCfg.setFisheyeInstance(cbFisheye.isSelected());
62  	}
63  
64  	public JComponent getRootComponent() {
65  		return rootComponent;
66  	}
67  
68  	public void setVisible(boolean visible) {
69  		rootComponent.setVisible(visible);
70  	}
71  
72  	private void createUIComponents() {
73  	}
74  
75  	public boolean isFishEyeInstance() {
76  		return cbFisheye.isSelected();
77  	}
78  
79  	/**
80  	 * Method generated by IntelliJ IDEA GUI Designer
81  	 * >>> IMPORTANT!! <<<
82  	 * DO NOT edit this method OR call it in your code!
83  	 *
84  	 * @noinspection ALL
85  	 */
86  	private void $$$setupUI$$$() {
87  		rootComponent = new JPanel();
88  		rootComponent.setLayout(new GridBagLayout());
89  		rootComponent
90  				.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Additional Configuration"));
91  		final JPanel panel1 = new JPanel();
92  		panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
93  		GridBagConstraints gbc;
94  		gbc = new GridBagConstraints();
95  		gbc.gridx = 0;
96  		gbc.gridy = 0;
97  		gbc.weightx = 1.0;
98  		gbc.fill = GridBagConstraints.BOTH;
99  		gbc.insets = new Insets(0, 12, 12, 8);
100 		rootComponent.add(panel1, gbc);
101 		cbFisheye = new JCheckBox();
102 		cbFisheye.setText("Crucible Server Contains Fisheye Instance");
103 		panel1.add(cbFisheye, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
104 				GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED,
105 				null, null, null, 0, false));
106 		final JPanel spacer1 = new JPanel();
107 		gbc = new GridBagConstraints();
108 		gbc.gridx = 0;
109 		gbc.gridy = 1;
110 		gbc.weighty = 1.0;
111 		gbc.fill = GridBagConstraints.VERTICAL;
112 		rootComponent.add(spacer1, gbc);
113 	}
114 
115 	/**
116 	 * @noinspection ALL
117 	 */
118 	public JComponent $$$getRootComponent$$$() {
119 		return rootComponent;
120 	}
121 }