KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > metadata > range > swing > relatedevents > RelatedEventCertainty


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * 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 /**
31  * @author Michael Bell
32  * @version $Revision: 1.1 $
33  *
34  */

35 public class RelatedEventCertainty extends JCheckBox implements 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 && ((BooleanValue)vals.get(0)).getValue() == true) {
54             this.setSelected(true);
55         }
56         this.addItemListener(this);
57     }
58
59     /* (non-Javadoc)
60      * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
61      */

62     public void itemStateChanged(ItemEvent e) {
63         List vals = m_propInst.getValues();
64         BooleanValue val = null;
65         if(vals.size()>0) {
66             val = (BooleanValue) vals.get(0);
67         } else {
68             val = (BooleanValue)m_propInst.getNewValueInstance();
69             m_propInst.setValue(val);
70         }
71         
72         if(isSelected()) {
73             val.setValue(true);
74         } else {
75             val.setValue(false);
76         }
77     }
78
79     /**
80      * @return
81      */

82     public boolean isMetadataValid() {
83         return true;
84     }
85
86 }
87
Popular Tags