01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.him.metadata.range.swing.relatedevents;
20:
21: import java.awt.event.*;
22: import java.util.*;
23:
24: import javax.swing.*;
25:
26: import org.openharmonise.vfs.metadata.*;
27: import org.openharmonise.vfs.metadata.value.*;
28:
29: /**
30: * @author Michael Bell
31: * @version $Revision: 1.1 $
32: *
33: */
34: public class RelatedEventCertainty extends JCheckBox implements
35: ItemListener {
36:
37: private PropertyInstance m_propInst = null;
38:
39: /**
40: *
41: */
42: public RelatedEventCertainty(PropertyInstance propInst) {
43: super ();
44: m_propInst = propInst;
45: setup();
46: }
47:
48: /**
49: *
50: */
51: private void setup() {
52: List vals = m_propInst.getValues();
53: if (vals.size() > 0
54: && ((BooleanValue) vals.get(0)).getValue() == true) {
55: this .setSelected(true);
56: }
57: this .addItemListener(this );
58: }
59:
60: /* (non-Javadoc)
61: * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
62: */
63: public void itemStateChanged(ItemEvent e) {
64: List vals = m_propInst.getValues();
65: BooleanValue val = null;
66: if (vals.size() > 0) {
67: val = (BooleanValue) vals.get(0);
68: } else {
69: val = (BooleanValue) m_propInst.getNewValueInstance();
70: m_propInst.setValue(val);
71: }
72:
73: if (isSelected()) {
74: val.setValue(true);
75: } else {
76: val.setValue(false);
77: }
78: }
79:
80: /**
81: * @return
82: */
83: public boolean isMetadataValid() {
84: return true;
85: }
86:
87: }
|