KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > metadata > range > swing > range > details > VocabularyDetails


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.range.details;
20
21 import java.awt.*;
22 import java.util.*;
23 import java.util.List JavaDoc;
24
25 import javax.swing.*;
26
27 import org.openharmonise.him.*;
28 import org.openharmonise.him.metadata.range.swing.range.*;
29 import org.openharmonise.him.swing.resourcetree.formresourcetree.*;
30 import org.openharmonise.vfs.*;
31 import org.openharmonise.vfs.metadata.*;
32 import org.openharmonise.vfs.metadata.range.*;
33 import org.openharmonise.vfs.metadata.value.*;
34 import org.openharmonise.vfs.servers.*;
35
36
37 /**
38  * @author Matthew Large
39  * @version $Revision: 1.1 $
40  *
41  */

42 public class VocabularyDetails extends AbstractRangeDetails
43 implements LayoutManager, FormResourceTreeListener {
44
45     private FormResourceTree m_tree = null;
46
47     private int m_nHeight = 400;
48     
49     private HashMap m_domainPathMapping = new HashMap();
50     
51     private RangeValue m_value = null;
52     private ValueRange m_range = null;
53
54     /**
55      * @param propInst
56      * @param sTitle
57      */

58     public VocabularyDetails(PropertyInstance propInst) {
59         super(propInst, "Vocabulary details");
60         this.setup();
61     }
62     
63     private void setup() {
64
65         this.setLayout(this);
66         
67         if(this.getPropertyInstance().getValues().size()>0) {
68             this.m_value = (RangeValue) this.getPropertyInstance().getValues().get(0);
69             this.m_range = (ValueRange) this.m_value.getRange();
70
71             if(this.m_range==null) {
72                 this.m_range = new ValueRange();
73             }
74         }
75         
76         m_tree = new FormResourceTree(false, this.m_range.getHREFs());
77         m_tree.addFormResourceTreeListener(this);
78         m_tree.setShowLeafNodes(false);
79         m_tree.setBorder(BorderFactory.createEtchedBorder());
80
81         this.add(m_tree);
82
83         String JavaDoc fontName = "Dialog";
84         int fontSize = 11;
85         Font font = new Font(fontName, Font.PLAIN, fontSize);
86
87         Server server = ServerList.getInstance().getHarmoniseServer();
88         VirtualFile vfFile =
89             server.getVFS().getVirtualFile(
90                 "/" + server.getVFS().getRootPathSegment() + "/Metadata/Values").getResource();
91         this.m_tree.addCollection(vfFile);
92     }
93
94     /* (non-Javadoc)
95      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
96      */

97     public void removeLayoutComponent(Component arg0) {
98     }
99
100     /* (non-Javadoc)
101      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
102      */

103     public void layoutContainer(Container arg0) {
104         int nHeight = 0;
105
106         this.m_tree.setSize(this.m_tree.getPreferredSize());
107         this.m_tree.setLocation(0, nHeight + 20);
108     }
109
110     /* (non-Javadoc)
111      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
112      */

113     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
114     }
115
116     /* (non-Javadoc)
117      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
118      */

119     public Dimension minimumLayoutSize(Container arg0) {
120         return this.getPreferredSize();
121     }
122
123     /* (non-Javadoc)
124      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
125      */

126     public Dimension preferredLayoutSize(Container arg0) {
127         return this.getPreferredSize();
128     }
129
130
131     /* (non-Javadoc)
132      * @see java.awt.Component#getPreferredSize()
133      */

134      public Dimension getPreferredSize() {
135         return new Dimension(this.m_tree.getPreferredSize().width, this.m_tree.getPreferredSize().height+20);
136      }
137
138     /* (non-Javadoc)
139      * @see com.simulacramedia.contentmanager.swing.resourcetree.formresourcetree.FormResourceTreeListener#pathValuesChanged(java.util.List)
140      */

141     public void pathValuesChanged(List JavaDoc pathValues) {
142         this.m_range.setHREFs(pathValues);
143         RangeValue newValue = (RangeValue) this.getPropertyInstance().getNewValueInstance();
144         newValue.setRange(this.m_range);
145         this.fireRangeDetailsChanged(newValue);
146     }
147
148 }
149
Popular Tags