KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > edit > TextEditPart


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: 11.03.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.edit;
9
10 import java.beans.PropertyChangeEvent JavaDoc;
11
12 import org.eclipse.ui.views.properties.IPropertySource;
13
14 import com.nightlabs.editor2d.TextDrawComponent;
15 import com.nightlabs.editor2d.model.TextPropertySource;
16
17 public class TextEditPart
18 extends ShapeDrawComponentEditPart
19 {
20   public TextEditPart(TextDrawComponent text)
21   {
22     super(text);
23   }
24
25   public TextDrawComponent getTextDrawComponent() {
26     return (TextDrawComponent) getModel();
27   }
28   
29     protected void propertyChanged(PropertyChangeEvent JavaDoc evt)
30     {
31         super.propertyChanged(evt);
32         String JavaDoc propertyName = evt.getPropertyName();
33         if (propertyName.equals(TextDrawComponent.PROP_FONT)) {
34             LOGGER.debug(propertyName +" changed!");
35             refreshVisuals();
36         }
37         else if (propertyName.equals(TextDrawComponent.PROP_FONT_NAME)) {
38             LOGGER.debug(propertyName +" changed!");
39             refreshVisuals();
40         }
41         else if (propertyName.equals(TextDrawComponent.PROP_FONT_SIZE)) {
42             LOGGER.debug(propertyName +" changed!");
43             refreshVisuals();
44         }
45         else if (propertyName.equals(TextDrawComponent.PROP_TEXT)) {
46             LOGGER.debug(propertyName +" changed!");
47             refreshVisuals();
48         }
49         else if (propertyName.equals(TextDrawComponent.PROP_BOLD)) {
50             LOGGER.debug(propertyName +" changed!");
51             refreshVisuals();
52         }
53         else if (propertyName.equals(TextDrawComponent.PROP_ITALIC)) {
54             LOGGER.debug(propertyName +" changed!");
55             refreshVisuals();
56         }
57     }
58     
59   /* (non-Javadoc)
60    * @see com.ibm.itso.sal330r.gefdemo.edit.WorkflowElementEditPart#getPropertySource()
61    */

62   protected IPropertySource getPropertySource()
63   {
64     if (propertySource == null)
65     {
66       propertySource =
67         new TextPropertySource(getTextDrawComponent());
68     }
69     return propertySource;
70   }
71   
72 // public void notifyChanged(Notification notification)
73
// {
74
// int type = notification.getEventType();
75
// int featureId = notification.getFeatureID(Editor2DPackage.class);
76
//
77
// if (type == Notification.SET)
78
// {
79
// switch (featureId)
80
// {
81
// case Editor2DPackage.TEXT_DRAW_COMPONENT__ANTI_ALIASING :
82
// LOGGER.debug("TEXT_DRAW_COMPONENT__ANTI_ALIASING Notified!");
83
// refreshVisuals();
84
// break;
85
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT :
86
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT Notified!");
87
// refreshVisuals();
88
// break;
89
// case Editor2DPackage.TEXT_DRAW_COMPONENT__TEXT :
90
// LOGGER.debug("TEXT_DRAW_COMPONENT__TEXT Notified!");
91
// refreshVisuals();
92
// break;
93
// case Editor2DPackage.TEXT_DRAW_COMPONENT__BOLD :
94
// LOGGER.debug("TEXT_DRAW_COMPONENT__BOLD Notified!");
95
// refreshVisuals();
96
// break;
97
// case Editor2DPackage.TEXT_DRAW_COMPONENT__ITALIC :
98
// LOGGER.debug("TEXT_DRAW_COMPONENT__ITALIC Notified!");
99
// refreshVisuals();
100
// break;
101
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT_SIZE :
102
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT_SIZE Notified!");
103
// refreshVisuals();
104
// break;
105
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT_NAME :
106
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT_NAME Notified!");
107
// refreshVisuals();
108
// break;
109
// }
110
// }
111
// super.notifyChanged(notification);
112
// }
113

114 // protected IFigure createFigure()
115
// {
116
// TextFigure textFigure = new TextFigure();
117
// textFigure.setAWTFont(getTextDrawComponent().getFont());
118
// textFigure.setText(getTextDrawComponent().getText());
119
// return textFigure;
120
// }
121
//
122
// protected void refreshVisuals()
123
// {
124
// super.refreshVisuals();
125
// setTextProperties();
126
// }
127
//
128
// protected void setTextProperties()
129
// {
130
// getTextFigure().setAWTFont(getTextDrawComponent().getFont());
131
// getTextFigure().setText(getTextDrawComponent().getText());
132
// }
133
//
134
// protected TextFigure getTextFigure()
135
// {
136
// return (TextFigure) getFigure();
137
// }
138

139 }
140
Popular Tags