KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * Project author: Daniel Mazurek <Daniel.Mazurek [at] nightlabs [dot] org> *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin St, Fifth Floor, *
20  * Boston, MA 02110-1301 USA *
21  * *
22  * Or get it online : *
23  * http://www.gnu.org/copyleft/lesser.html *
24  * *
25  * *
26  ******************************************************************************/

27
28 package org.nightlabs.editor2d.edit;
29
30 import java.beans.PropertyChangeEvent JavaDoc;
31
32 import org.eclipse.ui.views.properties.IPropertySource;
33
34 import org.nightlabs.editor2d.TextDrawComponent;
35 import org.nightlabs.editor2d.model.TextPropertySource;
36
37 public class TextEditPart
38 extends ShapeDrawComponentEditPart
39 {
40   public TextEditPart(TextDrawComponent text)
41   {
42     super(text);
43   }
44
45   public TextDrawComponent getTextDrawComponent() {
46     return (TextDrawComponent) getModel();
47   }
48   
49     protected void propertyChanged(PropertyChangeEvent JavaDoc evt)
50     {
51         super.propertyChanged(evt);
52         String JavaDoc propertyName = evt.getPropertyName();
53         if (propertyName.equals(TextDrawComponent.PROP_FONT)) {
54             LOGGER.debug(propertyName +" changed!");
55             refreshVisuals();
56         }
57         else if (propertyName.equals(TextDrawComponent.PROP_FONT_NAME)) {
58             LOGGER.debug(propertyName +" changed!");
59             refreshVisuals();
60         }
61         else if (propertyName.equals(TextDrawComponent.PROP_FONT_SIZE)) {
62             LOGGER.debug(propertyName +" changed!");
63             refreshVisuals();
64         }
65         else if (propertyName.equals(TextDrawComponent.PROP_TEXT)) {
66             LOGGER.debug(propertyName +" changed!");
67             refreshVisuals();
68         }
69         else if (propertyName.equals(TextDrawComponent.PROP_BOLD)) {
70             LOGGER.debug(propertyName +" changed!");
71             refreshVisuals();
72         }
73         else if (propertyName.equals(TextDrawComponent.PROP_ITALIC)) {
74             LOGGER.debug(propertyName +" changed!");
75             refreshVisuals();
76         }
77     }
78     
79   /* (non-Javadoc)
80    * @see com.ibm.itso.sal330r.gefdemo.edit.WorkflowElementEditPart#getPropertySource()
81    */

82   protected IPropertySource getPropertySource()
83   {
84     if (propertySource == null)
85     {
86       propertySource =
87         new TextPropertySource(getTextDrawComponent());
88     }
89     return propertySource;
90   }
91   
92 // public void notifyChanged(Notification notification)
93
// {
94
// int type = notification.getEventType();
95
// int featureId = notification.getFeatureID(Editor2DPackage.class);
96
//
97
// if (type == Notification.SET)
98
// {
99
// switch (featureId)
100
// {
101
// case Editor2DPackage.TEXT_DRAW_COMPONENT__ANTI_ALIASING :
102
// LOGGER.debug("TEXT_DRAW_COMPONENT__ANTI_ALIASING Notified!");
103
// refreshVisuals();
104
// break;
105
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT :
106
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT Notified!");
107
// refreshVisuals();
108
// break;
109
// case Editor2DPackage.TEXT_DRAW_COMPONENT__TEXT :
110
// LOGGER.debug("TEXT_DRAW_COMPONENT__TEXT Notified!");
111
// refreshVisuals();
112
// break;
113
// case Editor2DPackage.TEXT_DRAW_COMPONENT__BOLD :
114
// LOGGER.debug("TEXT_DRAW_COMPONENT__BOLD Notified!");
115
// refreshVisuals();
116
// break;
117
// case Editor2DPackage.TEXT_DRAW_COMPONENT__ITALIC :
118
// LOGGER.debug("TEXT_DRAW_COMPONENT__ITALIC Notified!");
119
// refreshVisuals();
120
// break;
121
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT_SIZE :
122
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT_SIZE Notified!");
123
// refreshVisuals();
124
// break;
125
// case Editor2DPackage.TEXT_DRAW_COMPONENT__FONT_NAME :
126
// LOGGER.debug("TEXT_DRAW_COMPONENT__FONT_NAME Notified!");
127
// refreshVisuals();
128
// break;
129
// }
130
// }
131
// super.notifyChanged(notification);
132
// }
133

134 // protected IFigure createFigure()
135
// {
136
// TextFigure textFigure = new TextFigure();
137
// textFigure.setAWTFont(getTextDrawComponent().getFont());
138
// textFigure.setText(getTextDrawComponent().getText());
139
// return textFigure;
140
// }
141
//
142
// protected void refreshVisuals()
143
// {
144
// super.refreshVisuals();
145
// setTextProperties();
146
// }
147
//
148
// protected void setTextProperties()
149
// {
150
// getTextFigure().setAWTFont(getTextDrawComponent().getFont());
151
// getTextFigure().setText(getTextDrawComponent().getText());
152
// }
153
//
154
// protected TextFigure getTextFigure()
155
// {
156
// return (TextFigure) getFigure();
157
// }
158

159 }
160
Popular Tags