📄 label.java
字号:
package com.cownew.uidesigner.components.label;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
import com.cownew.ctk.common.StringUtils;
import com.cownew.uidesigner.common.CodeGenUtils;
import com.cownew.uidesigner.common.ComponentUtils;
import com.cownew.uidesigner.model.Component;
public class Label extends Component
{
private static final long serialVersionUID = 1L;
public static final String TEXT = "TEXT";
private static IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
TEXT, "Text") };
private String text;
public Label()
{
super();
setText("Label");
}
public void setText(String text)
{
String oldValue = this.text;
this.text = text;
this.firePropertyChange(TEXT, oldValue, text);
}
protected String getText()
{
return text;
}
public IPropertyDescriptor[] getPropertyDescriptors()
{
IPropertyDescriptor[] sd = super.getPropertyDescriptors();
return ComponentUtils.mergePropDesc(sd, descriptors);
}
public Object getPropertyValue(Object id)
{
Object v = super.getPropertyValue(id);
if (v != null)
{
return v;
}
if (id.equals(TEXT))
{
return getText();
}
return null;
}
public void setPropertyValue(Object id, Object value)
{
super.setPropertyValue(id, value);
if (id.equals(TEXT))
{
setText((String) value);
}
}
public List<String> generateCode(String parentId)
{
List<String> list = new ArrayList<String>();
StringBuffer line1 = new StringBuffer();
line1.append("JLabel ").append(getId()).append("= new JLabel(").append(
StringUtils.doubleQuoted(getText())).append(");");
list.add(line1.toString());
StringBuffer line2 = new StringBuffer();
line2.append(getId()).append(".setBounds(").append(
CodeGenUtils.translateBounds(getBounds())).append(");");
list.add(line2.toString());
StringBuffer line3 = new StringBuffer();
line3.append(parentId).append(".add(").append(getId()).append(");");
list.add(line3.toString());
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -