KickJava   Java API By Example, From Geeks To Geeks.

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


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  * BorderStyleEditor.java
22  *
23  * Created on October 13, 2004, 12:23 PM
24  */

25
26 package org.netbeans.modules.css.visual.ui;
27
28 import java.awt.BorderLayout JavaDoc;
29 import java.awt.FontMetrics JavaDoc;
30 import org.netbeans.modules.css.visual.model.BorderModel;
31 import org.netbeans.modules.css.visual.model.CssProperties;
32 import org.netbeans.modules.css.visual.model.CssStyleData;
33 import java.awt.Dimension JavaDoc;
34 import java.beans.PropertyChangeEvent JavaDoc;
35 import java.beans.PropertyChangeListener JavaDoc;
36 import java.awt.Component JavaDoc;
37 import java.awt.event.*;
38 import javax.swing.table.*;
39 import javax.swing.event.*;
40 import java.util.EventObject JavaDoc;
41 import javax.swing.tree.*;
42 import java.io.Serializable JavaDoc;
43 import javax.swing.*;
44 import org.openide.util.NbBundle;
45
46 /**
47  * Borders Style editor.
48  * @author Winston Prakash
49  * @version 1.0
50  */

51 public class BorderStyleEditor extends StyleEditor {
52     BorderDataTable borderDataTable = new BorderDataTable();
53     /** Creates new form FontStyleEditor */
54     public BorderStyleEditor() {
55         setName("borderStyleEditor"); //NOI18N
56
setDisplayName(NbBundle.getMessage(BorderStyleEditor.class, "BORDER_EDITOR_DISPNAME"));
57         initComponents();
58         borderPanel.add(borderDataTable, BorderLayout.CENTER);
59     }
60
61     /**
62      * Set the CSS Properties Values from the CssStyleData data structure
63      * to the GUI components.
64      */

65     protected void setCssPropertyValues(CssStyleData cssStyleData){
66         removeCssPropertyChangeListener();
67         borderDataTable.setCssPropertyValues(cssStyleData);
68         setCssPropertyChangeListener(cssStyleData);
69     }
70
71     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
72
private void initComponents() {
73         borderPanel = new javax.swing.JPanel JavaDoc();
74
75         setLayout(new java.awt.BorderLayout JavaDoc(0, 5));
76
77         borderPanel.setLayout(new java.awt.BorderLayout JavaDoc());
78
79         borderPanel.setBorder(new javax.swing.border.CompoundBorder JavaDoc(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(5, 5, 5, 5)), new javax.swing.border.EtchedBorder JavaDoc()));
80         add(borderPanel, java.awt.BorderLayout.NORTH);
81
82     }
83     // </editor-fold>//GEN-END:initComponents
84

85     class BorderDataTable extends JTable{
86         CssStyleData cssStyleData ;
87         /**
88          * Holds value of property value.
89          */

90         private String JavaDoc value;
91
92         BorderModel borderModel = new BorderModel();
93
94         JComboBox allStyleCombo;
95         BorderWidthField allWidthField;
96         ColorSelectionField allColorField;
97
98         JComboBox topStyleCombo;
99         BorderWidthField topWidthField;
100         ColorSelectionField topColorField;
101
102         JComboBox bottomStyleCombo;
103         BorderWidthField bottomWidthField;
104         ColorSelectionField bottomColorField;
105
106         JComboBox leftStyleCombo;
107         BorderWidthField leftWidthField;
108         ColorSelectionField leftColorField;
109
110         JComboBox rightStyleCombo;
111         BorderWidthField rightWidthField;
112         ColorSelectionField rightColorField;
113
114         public BorderDataTable(){
115             super(6,4);
116             setDefaultRenderer( JComponent.class, new JComponentCellRenderer() );
117             setDefaultEditor( JComponent.class, new JComponentCellEditor() );
118             FontMetrics JavaDoc fontMetrics = getFontMetrics(getFont());
119             setRowHeight((fontMetrics.getHeight() + 10) > 25 ? (fontMetrics.getHeight() + 10) : 25);
120             setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
121             setIntercellSpacing(new Dimension JavaDoc(5,5));
122             setTableHeader(null);
123             setBackground(new JPanel().getBackground());
124             initCells();
125             getColumnModel().getColumn(0).setPreferredWidth(50);
126             getColumnModel().getColumn(1).setPreferredWidth(75);
127             getColumnModel().getColumn(2).setPreferredWidth(125);
128             getColumnModel().getColumn(3).setPreferredWidth(125);
129             getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "BORDER_STYLE_TABLE_ACCESS_NAME"));
130             getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "BORDER_STYLE_TABLE_ACCESS_DESC"));
131         }
132         
133         protected void setCssPropertyValues(CssStyleData cssStyleData){
134             removeCssPropertyChangeListener();
135             
136         
137             // Set the values for the Border Style
138
String JavaDoc topStyle = cssStyleData.getProperty(CssProperties.BORDER_TOP_STYLE);
139             String JavaDoc bottomStyle = cssStyleData.getProperty(CssProperties.BORDER_BOTTOM_STYLE);
140             String JavaDoc leftStyle = cssStyleData.getProperty(CssProperties.BORDER_LEFT_STYLE);
141             String JavaDoc rightStyle = cssStyleData.getProperty(CssProperties.BORDER_RIGHT_STYLE);
142             
143              
144             if ((topStyle != null) && (bottomStyle != null) && (leftStyle != null) && (rightStyle != null) &&
145                     (topStyle.equals(bottomStyle)) && (topStyle.equals(leftStyle)) &&
146                     (topStyle.equals(rightStyle))){
147                 allStyleCombo.setSelectedItem(topStyle);
148             }else{
149                 allStyleCombo.setSelectedIndex(0);
150                 if(topStyle != null){
151                     topStyleCombo.setSelectedItem(topStyle);
152                 }else{
153                     topStyleCombo.setSelectedIndex(0);
154                 }
155                 if(bottomStyle != null){
156                     bottomStyleCombo.setSelectedItem(bottomStyle);
157                 }else{
158                     bottomStyleCombo.setSelectedIndex(0);
159                 }
160                 if(leftStyle != null){
161                     leftStyleCombo.setSelectedItem(leftStyle);
162                 }else{
163                     leftStyleCombo.setSelectedIndex(0);
164                 }
165                 if(rightStyle != null){
166                     rightStyleCombo.setSelectedItem(rightStyle);
167                 }else{
168                     rightStyleCombo.setSelectedIndex(0);
169                 }
170             }
171             
172             // Set the value for the Border Width
173
String JavaDoc topWidth = cssStyleData.getProperty(CssProperties.BORDER_TOP_WIDTH);
174             String JavaDoc bottomWidth = cssStyleData.getProperty(CssProperties.BORDER_BOTTOM_WIDTH);
175             String JavaDoc leftWidth = cssStyleData.getProperty(CssProperties.BORDER_LEFT_WIDTH);
176             String JavaDoc rightWidth = cssStyleData.getProperty(CssProperties.BORDER_RIGHT_WIDTH);
177             
178             if ((topWidth != null) && (bottomWidth != null) && (leftWidth != null) && (rightWidth != null) &&
179                     (topWidth.equals(bottomWidth)) && (topWidth.equals(leftWidth)) &&
180                     (topWidth.equals(rightWidth))){
181                 allWidthField.setWidthString(topWidth);
182             }else{
183                 allWidthField.setWidthString(null);
184                 topWidthField.setWidthString(topWidth);
185                 bottomWidthField.setWidthString(bottomWidth);
186                 leftWidthField.setWidthString(leftWidth);
187                 rightWidthField.setWidthString(rightWidth);
188             }
189             
190             // Set the value for the Border Width
191
String JavaDoc topColor = cssStyleData.getProperty(CssProperties.BORDER_TOP_COLOR);
192             String JavaDoc bottomColor = cssStyleData.getProperty(CssProperties.BORDER_BOTTOM_COLOR);
193             String JavaDoc leftColor = cssStyleData.getProperty(CssProperties.BORDER_LEFT_COLOR);
194             String JavaDoc rightColor = cssStyleData.getProperty(CssProperties.BORDER_RIGHT_COLOR);
195             
196             if ((topColor != null) && (bottomColor != null) && (leftColor != null) && (rightColor != null) &&
197                     (topColor.equals(bottomColor)) && (topColor.equals(leftColor)) &&
198                     (topColor.equals(rightColor))){
199                 allColorField.setColorString(topColor);
200             }else{
201                 allColorField.setColorString(null);
202                 topColorField.setColorString(topColor);
203                 bottomColorField.setColorString(bottomColor);
204                 leftColorField.setColorString(leftColor);
205                 rightColorField.setColorString(rightColor);
206             }
207
208             borderDataTable.validate();
209             borderDataTable.repaint();
210             setCssPropertyChangeListener(cssStyleData);
211         }
212         
213         public void initCells(){
214             JPanel colHeader1 = new JPanel();
215             //colHeader1.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_SIDE")));
216
setValueAt(colHeader1, 0, 0 );
217             JPanel colHeader2 = new JPanel();
218             colHeader2.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_STYLE")));
219             setValueAt(colHeader2, 0, 1 );
220             JPanel colHeader3 = new JPanel();
221             colHeader3.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_WIDTH")));
222             setValueAt(colHeader3, 0, 2 );
223             JPanel colHeader6 = new JPanel();
224             colHeader6.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_COLOR")));
225             setValueAt(colHeader6, 0, 3);
226             
227             JPanel rowHeader1 = new JPanel();
228             rowHeader1.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_ALL")));
229             setValueAt(rowHeader1, 1, 0 );
230             JPanel rowHeader2 = new JPanel();
231             rowHeader2.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_TOP")));
232             setValueAt(rowHeader2, 2, 0 );
233             JPanel rowHeader3 = new JPanel();
234             rowHeader3.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_BOTTOM")));
235             setValueAt(rowHeader3, 3, 0 );
236             JPanel rowHeader4 = new JPanel();
237             rowHeader4.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_LEFT")));
238             setValueAt(rowHeader4, 4, 0 );
239             JPanel rowHeader5 = new JPanel();
240             rowHeader5.add(new JLabel(NbBundle.getMessage(BorderDataTable.class, "BORDER_RIGHT")));
241             setValueAt(rowHeader5, 5, 0 );
242             
243             // All Side Style
244
allStyleCombo = new JComboBox();
245             allStyleCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_STYLE_ACCESS_NAME"));
246             allStyleCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_STYLE_ACCESS_DESC"));
247             allStyleCombo.setModel(borderModel.getStyleList());
248             allStyleCombo.addItemListener(new ItemListener() {
249                 public void itemStateChanged(ItemEvent evt) {
250                     //cssPropertyChangeSupport.firePropertyChange(CssStyleData.BORDER_STYLE, null, allStyleCombo.getSelectedItem().toString());
251
topStyleCombo.setSelectedIndex(allStyleCombo.getSelectedIndex());
252                     bottomStyleCombo.setSelectedIndex(allStyleCombo.getSelectedIndex());
253                     leftStyleCombo.setSelectedIndex(allStyleCombo.getSelectedIndex());
254                     rightStyleCombo.setSelectedIndex(allStyleCombo.getSelectedIndex());
255                 }
256             });
257             setValueAt(allStyleCombo, 1, 1);
258             
259             // All Side Width
260
allWidthField = new BorderWidthField();
261             allWidthField.setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_WIDTH_ACCESS_NAME"),
262                     NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_WIDTH_UNIT_ACCESS_NAME"));
263             allWidthField.setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_WIDTH_ACCESS_DESC"),
264                     NbBundle.getMessage(BorderDataTable.class, "ALL_SIDE_BORDER_WIDTH_UNIT_ACCESS_DESC"));
265             allWidthField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
266                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
267                     //cssPropertyChangeSupport.firePropertyChange(CssStyleData.BORDER_WIDTH, null, evt.getNewValue().toString());
268
topWidthField.setWidthString(evt.getNewValue().toString());
269                     bottomWidthField.setWidthString(evt.getNewValue().toString());
270                     leftWidthField.setWidthString(evt.getNewValue().toString());
271                     rightWidthField.setWidthString(evt.getNewValue().toString());
272                 }
273             });
274             setValueAt(allWidthField, 1, 2);
275             
276             // All Side Width
277
allColorField = new ColorSelectionField();
278             allColorField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
279                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
280                     //cssPropertyChangeSupport.firePropertyChange(CssStyleData.BORDER_COLOR, null, allColorField.getColorString());
281
topColorField.setColorString(allColorField.getColorString());
282                     bottomColorField.setColorString(allColorField.getColorString());
283                     leftColorField.setColorString(allColorField.getColorString());
284                     rightColorField.setColorString(allColorField.getColorString());
285                 }
286             });
287             setValueAt(allColorField, 1, 3);
288             
289             // Top Side Style
290
topStyleCombo = new JComboBox();
291             topStyleCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_STYLE_ACCESS_NAME"));
292             topStyleCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_STYLE_ACCESS_DESC"));
293             topStyleCombo.setModel(borderModel.getStyleList());
294             topStyleCombo.addItemListener(new ItemListener() {
295                 public void itemStateChanged(ItemEvent evt) {
296                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_TOP_STYLE, null, topStyleCombo.getSelectedItem().toString());
297                 }
298             });
299             setValueAt(topStyleCombo, 2, 1);
300             
301             // Top Side Width
302
topWidthField = new BorderWidthField();
303             topWidthField.setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_WIDTH_ACCESS_NAME"),
304                     NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_WIDTH_UNIT_ACCESS_NAME"));
305             topWidthField.setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_WIDTH_ACCESS_DESC"),
306                     NbBundle.getMessage(BorderDataTable.class, "TOP_SIDE_BORDER_WIDTH_UNIT_ACCESS_DESC"));
307             topWidthField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
308                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
309                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_TOP_WIDTH, null, evt.getNewValue().toString());
310                 }
311             });
312             setValueAt(topWidthField, 2, 2);
313             
314             // Top Side Color
315
topColorField = new ColorSelectionField();
316             topColorField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
317                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
318                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_TOP_COLOR, null, topColorField.getColorString());
319                 }
320             });
321             setValueAt(topColorField, 2, 3);
322             
323             
324             // Bottom Side Style
325
bottomStyleCombo = new JComboBox();
326             bottomStyleCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_STYLE_ACCESS_NAME"));
327             bottomStyleCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_STYLE_ACCESS_DESC"));
328             bottomStyleCombo.setModel(borderModel.getStyleList());
329             bottomStyleCombo.addItemListener(new ItemListener() {
330                 public void itemStateChanged(ItemEvent evt) {
331                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_BOTTOM_STYLE, null, bottomStyleCombo.getSelectedItem().toString());
332                 }
333             });
334             setValueAt(bottomStyleCombo, 3, 1);
335             
336             // Bottom Side Width
337
bottomWidthField = new BorderWidthField();
338             bottomWidthField.setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_WIDTH_ACCESS_NAME"),
339                     NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_WIDTH_UNIT_ACCESS_NAME"));
340             bottomWidthField.setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_WIDTH_ACCESS_DESC"),
341                     NbBundle.getMessage(BorderDataTable.class, "BOTTOM_SIDE_BORDER_WIDTH_UNIT_ACCESS_DESC"));
342             bottomWidthField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
343                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
344                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_BOTTOM_WIDTH, null, evt.getNewValue().toString());
345                 }
346             });
347             setValueAt(bottomWidthField, 3, 2);
348             
349             // Bottom Side Width
350
bottomColorField = new ColorSelectionField();
351             bottomColorField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
352                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
353                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_BOTTOM_COLOR, null, bottomColorField.getColorString());
354                 }
355             });
356             setValueAt(bottomColorField, 3, 3);
357             
358             
359             
360             
361             // Left Side Style
362
leftStyleCombo = new JComboBox( new String JavaDoc[] {});
363             leftStyleCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_STYLE_ACCESS_NAME"));
364             leftStyleCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_STYLE_ACCESS_DESC"));
365             leftStyleCombo.setModel(borderModel.getStyleList());
366             leftStyleCombo.addItemListener(new ItemListener() {
367                 public void itemStateChanged(ItemEvent evt) {
368                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_LEFT_STYLE, null, leftStyleCombo.getSelectedItem().toString());
369                 }
370             });
371             setValueAt(leftStyleCombo, 4, 1);
372             
373             // Left Side Width
374
leftWidthField = new BorderWidthField();
375             leftWidthField.setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_WIDTH_ACCESS_NAME"),
376                     NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_WIDTH_UNIT_ACCESS_NAME"));
377             leftWidthField.setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_WIDTH_ACCESS_DESC"),
378                     NbBundle.getMessage(BorderDataTable.class, "LEFT_SIDE_BORDER_WIDTH_UNIT_ACCESS_DESC"));
379             // Set the Left Side data
380

381             leftWidthField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
382                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
383                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_LEFT_WIDTH, null, evt.getNewValue().toString());
384                 }
385             });
386             setValueAt(leftWidthField, 4, 2);
387             
388             // Left Side Width
389
leftColorField = new ColorSelectionField();
390             leftColorField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
391                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
392                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_LEFT_COLOR, null, leftColorField.getColorString());
393                 }
394             });
395             setValueAt(leftColorField, 4, 3);
396             
397             
398             // Right Side Style
399
rightStyleCombo = new JComboBox();
400             rightStyleCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_STYLE_ACCESS_NAME"));
401             rightStyleCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_STYLE_ACCESS_DESC"));
402             rightStyleCombo.setModel(borderModel.getStyleList());
403             rightStyleCombo.addItemListener(new ItemListener() {
404                 public void itemStateChanged(ItemEvent evt) {
405                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_RIGHT_STYLE, null, rightStyleCombo.getSelectedItem().toString());
406                 }
407             });
408             setValueAt(rightStyleCombo, 5, 1);
409             
410             
411             // Right Side Width
412
rightWidthField = new BorderWidthField();
413             rightWidthField.setAccessibleName(NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_WIDTH_ACCESS_NAME"),
414                     NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_WIDTH_UNIT_ACCESS_NAME"));
415             rightWidthField.setAccessibleDescription(NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_WIDTH_ACCESS_DESC"),
416                     NbBundle.getMessage(BorderDataTable.class, "RIGHT_SIDE_BORDER_WIDTH_UNIT_ACCESS_DESC"));
417             rightWidthField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
418                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
419                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_RIGHT_WIDTH, null, evt.getNewValue().toString());
420                 }
421             });
422             setValueAt(rightWidthField, 5, 2);
423             
424             // Right Side Width
425
rightColorField = new ColorSelectionField();
426             rightColorField.addPropertyChangeListener(new PropertyChangeListenerImpl() {
427                 public void propertyChange(PropertyChangeEvent JavaDoc evt) {
428                     cssPropertyChangeSupport.firePropertyChange(CssProperties.BORDER_RIGHT_COLOR, null, rightColorField.getColorString());
429                 }
430             });
431             setValueAt(rightColorField, 5, 3);
432         }
433         
434         private void setAllSideBorder(){
435             
436         }
437         
438         class PropertyChangeListenerImpl implements PropertyChangeListener JavaDoc{
439             public void propertyChange(PropertyChangeEvent JavaDoc evt) {
440             }
441         }
442         
443         public TableCellRenderer getCellRenderer(int row, int column) {
444             TableColumn tableColumn = getColumnModel().getColumn(column);
445             TableCellRenderer renderer = tableColumn.getCellRenderer();
446             if (renderer == null) {
447                 Class JavaDoc c = getColumnClass(column);
448                 if( c.equals(Object JavaDoc.class) ) {
449                     Object JavaDoc o = getValueAt(row,column);
450                     if( o != null )
451                         c = getValueAt(row,column).getClass();
452                 }
453                 renderer = getDefaultRenderer(c);
454             }
455             return renderer;
456         }
457         
458         public TableCellEditor getCellEditor(int row, int column) {
459             TableColumn tableColumn = getColumnModel().getColumn(column);
460             TableCellEditor editor = tableColumn.getCellEditor();
461             if (editor == null) {
462                 Class JavaDoc c = getColumnClass(column);
463                 if( c.equals(Object JavaDoc.class) ) {
464                     Object JavaDoc o = getValueAt(row,column);
465                     if( o != null )
466                         c = getValueAt(row,column).getClass();
467                 }
468                 editor = getDefaultEditor(c);
469             }
470             return editor;
471         }
472         
473         private class JComponentCellRenderer implements TableCellRenderer {
474             public Component JavaDoc getTableCellRendererComponent(JTable table, Object JavaDoc value,
475                     boolean isSelected, boolean hasFocus, int row, int column) {
476                 JComponent comp = (JComponent)value;
477                 comp.setMinimumSize(new Dimension JavaDoc(100,25));
478                 return comp;
479             }
480         }
481         
482         private class JComponentCellEditor implements TableCellEditor, TreeCellEditor,Serializable JavaDoc {
483             
484             protected EventListenerList listenerList = new EventListenerList();
485             transient protected ChangeEvent JavaDoc changeEvent = null;
486             
487             protected JComponent editorComponent = null;
488             protected JComponent container = null; // Can be tree or table
489

490             
491             public Component JavaDoc getComponent() {
492                 return editorComponent;
493             }
494             
495             
496             public Object JavaDoc getCellEditorValue() {
497                 return editorComponent;
498             }
499             
500             public boolean isCellEditable(EventObject JavaDoc anEvent) {
501                 return true;
502             }
503             
504             public boolean shouldSelectCell(EventObject JavaDoc anEvent) {
505                 if( editorComponent != null && anEvent instanceof MouseEvent
506                         && ((MouseEvent)anEvent).getID() == MouseEvent.MOUSE_PRESSED ) {
507                     Component JavaDoc dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, 3, 3 );
508                     MouseEvent e = (MouseEvent)anEvent;
509                     MouseEvent e2 = new MouseEvent( dispatchComponent, MouseEvent.MOUSE_RELEASED,
510                             e.getWhen() + 100000, e.getModifiers(), 3, 3, e.getClickCount(),
511                             e.isPopupTrigger() );
512                     dispatchComponent.dispatchEvent(e2);
513                     e2 = new MouseEvent( dispatchComponent, MouseEvent.MOUSE_CLICKED,
514                             e.getWhen() + 100001, e.getModifiers(), 3, 3, 1,
515                             e.isPopupTrigger() );
516                     dispatchComponent.dispatchEvent(e2);
517                 }
518                 return false;
519             }
520             
521             public boolean stopCellEditing() {
522                 fireEditingStopped();
523                 return true;
524             }
525             
526             public void cancelCellEditing() {
527                 fireEditingCanceled();
528             }
529             
530             public void addCellEditorListener(CellEditorListener l) {
531                 listenerList.add(CellEditorListener.class, l);
532             }
533             
534             public void removeCellEditorListener(CellEditorListener l) {
535                 listenerList.remove(CellEditorListener.class, l);
536             }
537             
538             protected void fireEditingStopped() {
539                 Object JavaDoc[] listeners = listenerList.getListenerList();
540                 // Process the listeners last to first, notifying
541
// those that are interested in this event
542
for (int i = listeners.length-2; i>=0; i-=2) {
543                     if (listeners[i]==CellEditorListener.class) {
544                         // Lazily create the event:
545
if (changeEvent == null)
546                             changeEvent = new ChangeEvent JavaDoc(this);
547                         ((CellEditorListener)listeners[i+1]).editingStopped(changeEvent);
548                     }
549                 }
550             }
551             
552             protected void fireEditingCanceled() {
553                 // Guaranteed to return a non-null array
554
Object JavaDoc[] listeners = listenerList.getListenerList();
555                 // Process the listeners last to first, notifying
556
// those that are interested in this event
557
for (int i = listeners.length-2; i>=0; i-=2) {
558                     if (listeners[i]==CellEditorListener.class) {
559                         // Lazily create the event:
560
if (changeEvent == null)
561                             changeEvent = new ChangeEvent JavaDoc(this);
562                         ((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent);
563                     }
564                 }
565             }
566             
567             // implements javax.swing.tree.TreeCellEditor
568
public Component JavaDoc getTreeCellEditorComponent(JTree tree, Object JavaDoc value,
569                     boolean isSelected, boolean expanded, boolean leaf, int row) {
570                 String JavaDoc stringValue = tree.convertValueToText(value, isSelected,
571                         expanded, leaf, row, false);
572                 
573                 editorComponent = (JComponent)value;
574                 container = tree;
575                 return editorComponent;
576             }
577             
578             // implements javax.swing.table.TableCellEditor
579
public Component JavaDoc getTableCellEditorComponent(JTable table, Object JavaDoc value,
580                     boolean isSelected, int row, int column) {
581                 
582                 editorComponent = (JComponent)value;
583                 container = table;
584                 return editorComponent;
585             }
586             
587         }
588     }
589     
590     // Variables declaration - do not modify//GEN-BEGIN:variables
591
private javax.swing.JPanel JavaDoc borderPanel;
592     // End of variables declaration//GEN-END:variables
593

594 }
595
Popular Tags