KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > visual > ui > StyleBuilderPanel


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 /*
21  * StyleBuilderPanel.java
22  *
23  * Created on October 12, 2004, 9:38 AM
24  */

25
26 package org.netbeans.modules.css.visual.ui;
27
28 import org.netbeans.modules.css.visual.model.CssStyleData;
29 import java.awt.BorderLayout JavaDoc;
30 import java.awt.Image JavaDoc;
31 import java.beans.PropertyChangeSupport JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34 import javax.swing.JPanel JavaDoc;
35 import org.openide.util.NbBundle;
36
37 /**
38  * Style Builder main panel
39  * @author Winston Prakash
40  * @version 1.0
41  */

42 public class StyleBuilderPanel extends JPanel JavaDoc{
43     JPanel JavaDoc currentEditor;
44     String JavaDoc currentStyle = null;
45     private PropertyChangeSupport JavaDoc propertyChangeSupport = new PropertyChangeSupport JavaDoc(this);
46
47     Image JavaDoc previewImage = null;
48
49     StyleEditorListPanel styleEditorListPanel = null;
50
51     List JavaDoc styleEditorList = new ArrayList JavaDoc();
52     String JavaDoc noPreviewLabel = NbBundle.getMessage(StyleBuilderPanel.class, "NO_PREVIEW");
53
54     /** Creates new form StyleBuilderPanel */
55     public StyleBuilderPanel() {
56         initComponents();
57         initialize();
58     }
59
60     private void initialize(){
61         styleEditorListPanel = new StyleEditorListPanel(this);
62
63         styleEditorList.add(new FontStyleEditor());
64         BackgroundStyleEditor bgStyleEditor = new BackgroundStyleEditor();
65         styleEditorList.add(bgStyleEditor);
66         styleEditorList.add(new TextBlockStyleEditor());
67         styleEditorList.add(new BorderStyleEditor());
68         styleEditorList.add(new MarginStyleEditor());
69         styleEditorList.add(new PositionStyleEditor());
70         //styleEditorList.add(new ListStyleEditor());
71
//styleEditorList.add(new OtherStyleEditor());
72

73         for(int i=0; i< styleEditorList.size(); i++){
74             StyleEditor styleEitor = (StyleEditor)styleEditorList.get(i);
75             styleEditorListPanel.addEditor(styleEitor);
76         }
77         styleEditorListPanel.setSelectedEditor((StyleEditor)styleEditorList.get(0));
78         setEditorListPanel(styleEditorListPanel);
79     }
80
81     public void setCssStyleData(final CssStyleData cssStyleData){
82         for(int i=0; i< styleEditorList.size(); i++){
83             StyleEditor styleEitor = (StyleEditor)styleEditorList.get(i);
84             styleEitor.setCssPropertyValues(cssStyleData);
85         }
86     }
87
88     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
89
private void initComponents() {
90         styleEditorSplitPane = new javax.swing.JSplitPane JavaDoc();
91         editorListPanel = new javax.swing.JPanel JavaDoc();
92         editorPanel = new javax.swing.JPanel JavaDoc();
93
94         setLayout(new java.awt.BorderLayout JavaDoc());
95
96         editorListPanel.setLayout(new java.awt.BorderLayout JavaDoc());
97
98         editorListPanel.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(3, 3, 3, 3)));
99         styleEditorSplitPane.setLeftComponent(editorListPanel);
100
101         editorPanel.setLayout(new java.awt.BorderLayout JavaDoc());
102
103         styleEditorSplitPane.setRightComponent(editorPanel);
104
105         add(styleEditorSplitPane, java.awt.BorderLayout.CENTER);
106
107     }
108     // </editor-fold>//GEN-END:initComponents
109

110     /**
111      * Set the editor List Panel
112      **/

113     public void setEditorListPanel(JPanel JavaDoc panel){
114         editorListPanel.add(panel,BorderLayout.CENTER);
115         repaint();
116     }
117
118     /**
119      * Set the Editor Panel. It is the responsibility of
120      * the editor list panel to set the editor when the
121      * corresponding editor is selected from its list
122      **/

123     public void setEditorPanel(JPanel JavaDoc panel){
124         if(currentEditor != null) {
125             editorPanel.remove(currentEditor);
126         }
127         currentEditor = panel;
128         editorPanel.add(currentEditor,BorderLayout.CENTER);
129         validate();
130         repaint();
131     }
132
133     // Variables declaration - do not modify//GEN-BEGIN:variables
134
private javax.swing.JPanel JavaDoc editorListPanel;
135     private javax.swing.JPanel JavaDoc editorPanel;
136     private javax.swing.JSplitPane JavaDoc styleEditorSplitPane;
137     // End of variables declaration//GEN-END:variables
138

139 }
140
Popular Tags