package com.vci.client.uif.engine.client.controls;
|
|
import java.awt.Color;
|
import java.awt.Component;
|
import java.awt.Graphics;
|
import java.awt.GridBagConstraints;
|
import java.awt.Insets;
|
|
import com.vci.client.portal.utility.PRMItem;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.uif.engine.common.IDataNode;
|
|
public abstract class AbstractCustomControl extends VCIJPanel implements ICustomControl {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = -2058786455116501248L;
|
private PRMItem pRMItem = null;
|
private boolean editable = true;
|
private IDataNode dataNode = null;
|
|
public AbstractCustomControl(){
|
super();
|
}
|
public AbstractCustomControl(PRMItem item){
|
this.pRMItem = item;
|
}
|
|
@Override
|
public PRMItem getPRMItem() {
|
return this.pRMItem;
|
}
|
|
@Override
|
public void setPRMItem(PRMItem item) {
|
this.pRMItem = item;
|
}
|
|
public GridBagConstraints getGBC(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, int padxy) {
|
return new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(padxy, padxy, padxy, padxy), padxy, padxy);
|
}
|
|
|
private Component parentCompoent = null;
|
@Override
|
public void setParentComponent(Component parentCompoent){
|
this.parentCompoent = parentCompoent;
|
}
|
@Override
|
public Component getParentComponent(){
|
return this.parentCompoent;
|
}
|
|
public boolean isEditable() {
|
return editable;
|
}
|
@Override
|
public void setEditable(boolean editable) {
|
this.editable = editable;
|
}
|
public boolean isRequired(){
|
return getPRMItem().getItemIsRequired().equals("1");
|
}
|
@Override
|
public void paint(Graphics g){
|
super.paint(g);
|
drawRequiredFlag(g);
|
}
|
|
protected void drawRequiredFlag(Graphics g){
|
if(isRequired()) {
|
int x = getWidth() - 9;
|
int y = 1;
|
g.setColor(Color.RED);
|
g.fillArc(x, y, 7, 7, 0, 360);
|
|
// int x = getWidth() - 10;
|
// int y = 10;
|
// g.setColor(Color.RED);
|
// g.drawString("*", x, y);
|
}
|
}
|
/**
|
* 返回 自定义控件关联的数据对象
|
* @return 自定义控件关联的 <code>IDataNode</code> 数据对象
|
* @author xiongchao
|
* @see com.vci.client.uif.engine.common.IDataNode
|
* @since 2015.03.16
|
*/
|
@Override
|
public IDataNode getDataNode() {
|
return dataNode;
|
}
|
/**
|
* 设置 自定义控件关联的数据对象
|
* @author xiongchao
|
* @see com.vci.client.uif.engine.common.IDataNode
|
* @since 2015.03.16
|
*/
|
@Override
|
public void setDataNode(IDataNode dataNode) {
|
this.dataNode = dataNode;
|
}
|
|
|
}
|