View Javadoc

1   package com.explosion.utilities.preferences.editandrender.form;
2   
3   import java.awt.GridBagConstraints;
4   import java.awt.GridBagLayout;
5   import java.awt.Insets;
6   
7   import javax.swing.JLabel;
8   
9   import org.apache.log4j.LogManager;
10  import org.apache.log4j.Logger;
11  
12  import com.explosion.utilities.exception.ExceptionManagerFactory;
13  import com.explosion.utilities.preferences.Preference;
14  import com.explosion.utilities.preferences.dialogs.EditCollectionPreferenceJPanel;
15  
16  
17  /*
18   * =============================================================================
19   * 
20   * Copyright 2004 Stephen Cowx
21   * 
22   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
23   * use this file except in compliance with the License. You may obtain a copy of
24   * the License at
25   * 
26   * http://www.apache.org/licenses/LICENSE-2.0
27   * 
28   * Unless required by applicable law or agreed to in writing, software
29   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
30   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
31   * License for the specific language governing permissions and limitations under
32   * the License.
33   * 
34   * =============================================================================
35   */
36  
37  /***
38   * This class provides a way to edit and rebder collection preferences 
39   * @author Stephen Cowx
40   * @version
41   */
42  public class CollectionPreferenceEditorAndRenderer extends FormBasedPreferenceRendererAndEditor {
43  
44  	private EditCollectionPreferenceJPanel panel;
45  	private JLabel label = new JLabel();
46  	private static Logger log = LogManager.getLogger(CollectionPreferenceEditorAndRenderer.class);
47  	
48  	/***
49  	 * Constructs an instance of this class 
50  	 * @param preference
51  	 */
52  	public CollectionPreferenceEditorAndRenderer(Preference preference)
53  	{
54      	super(preference);
55  		try {
56  			init();
57  		} catch (Exception e) {
58  			ExceptionManagerFactory.getExceptionManager().manageException(e, "Exception caught while initialising collection preference editor");
59  		}
60  	}
61  	
62  	/***
63  	 * This method initialises this renderer editor combination
64  	 * @throws Exception
65  	 */
66  	public void init() throws Exception
67  	{
68  		this.setLayout(new GridBagLayout());
69  		
70  		//Initialise the layout and bits
71  		label.setText(getPreference().getLongName());
72  		panel = new EditCollectionPreferenceJPanel(getPreference());
73  		
74  		//Add all of the bits to the panel
75  		this.add(label , new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); 
76  		this.add(panel , new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
77  	}
78  	
79  		
80  }