View Javadoc

1   /***
2    * Created on Aug 4, 2005, Copyright UC Regents
3    */
4   package org.telscenter.pas.steps;
5   
6   import java.awt.BorderLayout;
7   import java.awt.Component;
8   import java.util.HashMap;
9   import java.util.Map;
10  import java.util.Set;
11  
12  import javax.swing.JLabel;
13  import javax.swing.JPanel;
14  import javax.swing.JScrollPane;
15  import javax.swing.JTable;
16  import javax.swing.table.DefaultTableModel;
17  import javax.swing.table.TableModel;
18  
19  import org.telscenter.pas.beans.PasStep;
20  
21  
22  /***
23   * @author turadg
24   */
25  public class UnsupportedConversion extends PasStep {
26  
27  	/***
28  	 * 
29  	 */
30  	private static final long serialVersionUID = 839637214816075064L;
31  
32  	Map<String,String> stepSettings = new HashMap<String,String>();
33  
34  	Map<String,String> stepParameters = new HashMap<String,String>();
35  
36  	public Map<String,String> getStepParameters() {
37  		return stepParameters;
38  	}
39  
40  	public void setStepParameters(Map<String,String> stepParameters) {
41  		this.stepParameters = stepParameters;
42  	}
43  
44  	public Map<String,String> getStepSettings() {
45  		return stepSettings;
46  	}
47  
48  	public void setStepSettings(Map<String,String> stepData) {
49  		this.stepSettings = stepData;
50  	}
51  
52  	public Component getComponent() {
53  		JPanel panel = new JPanel(new BorderLayout());
54  		panel.add(new JLabel("This step failed to convert from WISE-2"),
55  				BorderLayout.NORTH);
56  		TableModel stepParametersModel = mapToModel(stepParameters);
57  		panel.add(new JScrollPane(new JTable(stepParametersModel)),
58  				BorderLayout.CENTER);
59  		TableModel stepSettingsModel = mapToModel(stepSettings);
60  		panel.add(new JScrollPane(new JTable(stepSettingsModel)),
61  				BorderLayout.SOUTH);
62  		panel.validate();
63  		return panel;
64  	}
65  
66  	DefaultTableModel mapToModel(Map<String,String> hm) {
67  		DefaultTableModel dtm = new DefaultTableModel();
68  		Set<String> keySet = hm.keySet();
69  		dtm.addColumn("Key", keySet.toArray());
70  		dtm.addColumn("Value", hm.values().toArray());
71  
72  		// TODO why is this loop necessary?
73  		Object obj[] = new Object[2];
74  		for (String key : keySet) {
75  			obj[0] = key;
76  			obj[1] = hm.get(key);
77  			dtm.addRow(obj);
78  		}
79  
80  		return dtm;
81  	}
82  
83  }