View Javadoc

1   package com.explosion.expfmodules.wizard.standard.view;
2   
3   import java.awt.BorderLayout;
4   import java.awt.GridBagConstraints;
5   import java.awt.GridBagLayout;
6   import java.awt.Insets;
7   import java.util.Iterator;
8   import java.util.List;
9   
10  import javax.swing.JDialog;
11  import javax.swing.JEditorPane;
12  import javax.swing.JPanel;
13  import javax.swing.text.html.HTMLEditorKit;
14  
15  import com.explosion.expfmodules.wizard.StepDefinition;
16  import com.explosion.expfmodules.wizard.standard.PreferenceDataItem;
17  import com.explosion.utilities.GeneralConstants;
18  import com.explosion.utilities.preferences.Preference;
19  import com.explosion.utilities.preferences.editandrender.form.FormBasedPreferenceRendererAndEditor;
20  
21  
22  /* =============================================================================
23   *       
24   *     Copyright 2004 Stephen Cowx
25   *
26   *     Licensed under the Apache License, Version 2.0 (the "License");
27   *     you may not use this file except in compliance with the License.
28   *     You may obtain a copy of the License at
29   *
30   *     http://www.apache.org/licenses/LICENSE-2.0
31   *
32   *     Unless required by applicable law or agreed to in writing, software
33   *     distributed under the License is distributed on an "AS IS" BASIS,
34   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35   *     See the License for the specific language governing permissions and
36   *     limitations under the License.
37   * 
38   * =============================================================================
39   */
40  
41  /***
42   * @author Stephen Cowx
43   * Created on 20-Feb-2005
44   */
45  public class StandardWizardDataPanel extends StandardStepView
46  {
47      private static org.apache.log4j.Logger log = org.apache.log4j.LogManager.getLogger(WizardBasePanel.class);
48      private StepDefinition step;
49      private JDialog helpDialog;
50      
51      /***
52       * Initialises the Panel
53       * @param step
54       */
55      public void init(StepDefinition step) throws Exception
56      {
57            this.removeAll();
58            this.step = step;
59            JPanel inputPanel = new JPanel();
60            JPanel helpAndDisplayPanel = new JPanel();
61            
62            List list = step.getOrderedDataItems();
63  		  inputPanel.removeAll();
64  		  inputPanel.setLayout(new GridBagLayout());
65  		  if (list != null)
66  		  {
67  			  int xIndex = 0;
68  			  for (Iterator it = list.iterator(); it.hasNext();)
69  			  {
70  			      PreferenceDataItem item = (PreferenceDataItem) it.next();
71  			      Preference preference = item.getPreference();
72  			      if (preference.isVisible())
73  			      {
74  			        FormBasedPreferenceRendererAndEditor editor = FormBasedPreferenceRendererAndEditor.getEditorForType(preference.getType(),this.getUltimateParent(),preference, item.getAttributes());
75  			        inputPanel.add(	editor , new GridBagConstraints(0, xIndex, 1, 1, 1.0, 1.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
76  			      }
77  			      xIndex++;
78  			      log.debug("xIndex" + xIndex);
79  			  }
80  		  }
81  		          		  
82  		  JEditorPane name = new JEditorPane();
83  		  name.setEditorKit(new HTMLEditorKit());
84  	      name.setText(WizardBasePanel.FONT + step.getName());
85  		  name.setFont(GeneralConstants.DEFAULT_WINDOW_FONT);
86  		  name.setOpaque(false);
87  		  name.setEditable(false);		  
88  		  
89  		  JEditorPane notes = new JEditorPane();
90  		  notes.setEditorKit(new HTMLEditorKit());
91  		  notes.setText(WizardBasePanel.FONT + step.getNotes());
92  	      notes.setFont(GeneralConstants.DEFAULT_WINDOW_FONT);
93  	      notes.setOpaque(false);
94  		  notes.setEditable(false);
95  		  		  
96  		  helpAndDisplayPanel.removeAll();
97  		  helpAndDisplayPanel.setLayout(new BorderLayout());
98  		  helpAndDisplayPanel.add(name, BorderLayout.NORTH);
99  		  helpAndDisplayPanel.add(notes, BorderLayout.CENTER);
100 		  
101 		  this.setLayout(new BorderLayout());
102 		  this.add(helpAndDisplayPanel,BorderLayout.NORTH);
103 		  this.add(inputPanel,BorderLayout.CENTER);
104     }
105     
106 }