KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > CompositorPropertiesPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * CompositorPropertiesPanel.java
21  *
22  * Created on June 29, 2006, 2:32 PM
23  *
24  * To change this template, choose Tools | Template Manager
25  * and open the template in the editor.
26  */

27
28 package org.netbeans.modules.xml.schema.abe;
29
30 import java.awt.Color JavaDoc;
31 import java.awt.Font JavaDoc;
32 import java.beans.PropertyChangeEvent JavaDoc;
33 import java.beans.PropertyChangeListener JavaDoc;
34 import javax.swing.JLabel JavaDoc;
35 import org.netbeans.modules.xml.axi.Compositor;
36 import org.openide.util.NbBundle;
37
38 /**
39  *
40  * @author girix
41  */

42 public class CompositorPropertiesPanel extends ExtraPropertiesPanel{
43     private static final long serialVersionUID = 7526472295622776147L;
44     private Compositor compositor;
45     
46     //private InstanceUIContext context;
47

48     /** Creates a new instance of CompositorPropertiesPanel */
49     public CompositorPropertiesPanel(Compositor compositor, InstanceUIContext context) {
50         super(true, context);
51         this.compositor = compositor;
52         //this.context = context;
53
refreshItems();
54         
55         compositor.addPropertyChangeListener(new ModelEventMediator(this, compositor){
56             public void _propertyChange(PropertyChangeEvent JavaDoc evt) {
57                 //String prop = evt.getPropertyName();
58
//if(prop.equals(Compositor.PROP_MAXOCCURS) || prop.equals(Compositor.PROP_MINOCCURS))
59
refreshItems();
60             }
61         });
62         
63         if(compositor.getContentModel() != null){
64             compositor.getContentModel().addPropertyChangeListener(new ModelEventMediator(this, compositor.getContentModel()) {
65                 public void _propertyChange(PropertyChangeEvent JavaDoc evt) {
66                     refreshItems();
67                 }
68             });
69         }
70     }
71     
72     private void refreshItems() {
73         cleanupAll();
74         //add cardinality label
75
if(compositor.supportsCardinality()){
76             String JavaDoc str = UIUtilities.getConstraintsString(compositor.getMinOccurs(), compositor.getMaxOccurs());
77             if(str != null){
78                 JLabel JavaDoc constraints = new JLabel JavaDoc(str);//new InplaceEditableLabel(str);
79
Font JavaDoc font = constraints.getFont();
80                 font = new Font JavaDoc(font.getFontName(), Font.PLAIN,
81                         InstanceDesignConstants.PROPS_FONT_SIZE);
82                 constraints.setFont(font);
83                 constraints.setForeground(new Color JavaDoc(139, 139, 139));
84                 constraints.setToolTipText(NbBundle.getMessage(ElementPropertiesPanel.class,
85                         "TTP_COMPOSITOR_CARDINALITY"));
86                 append(constraints, true);
87             }
88         }
89         //add content model string
90
if(compositor.getContentModel() != null){
91             //add the content model label
92
JLabel JavaDoc contentModelInfoLabel = UIUtilities.getContentModelInfoLabel(compositor, false, true, context);
93             if(contentModelInfoLabel != null)
94                 append(contentModelInfoLabel, false);
95         }
96         revalidate();
97         repaint();
98         
99     }
100     
101     
102     
103 }
104
Popular Tags