田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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;
    }
    
    
}