MCPcopy Create free account
hub / github.com/GateNLP/gate-core / FeatureMapEditorDialog

Class FeatureMapEditorDialog

src/main/java/gate/gui/FeatureMapEditorDialog.java:34–192  ·  view source on GitHub ↗

A simple editor for List values.

Source from the content-addressed store, hash-verified

32 * A simple editor for List values.
33 */
34@SuppressWarnings("serial")
35public class FeatureMapEditorDialog extends JDialog {
36
37 /**
38 * Contructs a new FeatureMapEditorDialog.
39 *
40 * @param owner the component this dialog will be centred on.
41 * @param data a feature map with the initial values. This map will
42 * not be changed, its values will be cached and if the user
43 * selects the OK option a new map with the updated contents
44 * will be returned.
45 */
46 public FeatureMapEditorDialog(Component owner, FeatureMap data) {
47 super(MainFrame.getInstance());
48 setLocationRelativeTo(owner);
49 initLocalData(data);
50 initGuiComponents();
51 initListeners();
52 }
53
54 protected void initLocalData(FeatureMap data) {
55 if(data != null) {
56 FeatureMap fm = Factory.newFeatureMap();
57 fm.putAll(data);
58 tempFMHolder.setFeatures(fm);
59 }
60 }
61
62 protected void initGuiComponents() {
63 this.setMinimumSize(new Dimension(150, 300));
64 getContentPane().setLayout(new BorderLayout());
65
66 // create the FeaturesSchemaEditor for the main body of the dialog
67 fmView = new FeaturesSchemaEditor();
68 try {
69 fmView.init();
70 }
71 catch(ResourceInstantiationException rie) {
72 // can't happen, but needs to be caught to satisfy the compiler
73 throw new GateRuntimeException("FeaturesSchemaEditor.init() threw "
74 + "ResourceInstantiationException!", rie);
75 }
76 fmView.setTarget(tempFMHolder);
77 // make sure the window is a sensible size
78 Dimension preferredSize = fmView.getPreferredSize();
79 if(preferredSize.height < 150) {
80 preferredSize.height = 150;
81 }
82 else if(preferredSize.height > 300) {
83 preferredSize.height = 300;
84 }
85 fmView.setPreferredSize(preferredSize);
86 JPanel fmViewPanel = new JPanel(new BorderLayout());
87 fmViewPanel.add(fmView, BorderLayout.CENTER);
88 fmViewPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
89
90 getContentPane().add(fmViewPanel, BorderLayout.CENTER);
91

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected