KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > properties > FontSizeCellEditor


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 14.03.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.properties;
9
10
11 import org.eclipse.swt.widgets.Composite;
12
13 import com.nightlabs.rcp.property.ComboBoxCellEditor;
14 import com.nightlabs.util.FontUtil;
15
16 public class FontSizeCellEditor
17 extends ComboBoxCellEditor
18 {
19
20   public FontSizeCellEditor(Composite parent) {
21     super(parent, FontUtil.getFontSizes());
22   }
23
24   protected Object JavaDoc doGetValue()
25   {
26     return new Integer JavaDoc(items[comboBox.getSelectionIndex()]);
27   }
28   
29   protected void doSetValue(Object JavaDoc value)
30   {
31     String JavaDoc string = "";
32     
33     if (value instanceof String JavaDoc) {
34       string = (String JavaDoc) value;
35     }
36     else if (value instanceof Integer JavaDoc) {
37       string = ((Integer JavaDoc)value).toString();
38     }
39     
40     for (int i=0; i<items.length; i++) {
41       String JavaDoc s = items[i];
42       if (s.equals(string)) {
43         comboBox.select(i);
44         break;
45       }
46     }
47     
48   }
49   
50 }
51
Popular Tags