wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.vci.client.uif.engine.client.tableArea;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
import com.vci.client.common.objects.UserObject;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.portal.utility.DataModelFactory;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.process.QANProcessBar;
import com.vci.client.ui.process.QANProcessBarFrame;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.corba.portal.data.PLTabPage;
import com.vci.corba.portal.data.PortalVI;
 
public class TablePanelTest extends JPanel{
 
    /**
     * 
     */
    private static final long serialVersionUID = -8547626443017332324L;
 
    private void init() throws VCIException{
        
        String ip = "192.168.0.100";
        String userName = "1";
        String password = "1";
        com.vci.client.common.objects.ClientInfo client = new com.vci.client.common.objects.ClientInfo();
        client.setIp(ip);
        //登陆用户信息
        RightManagementClientDelegate delegate = new RightManagementClientDelegate();
        UserObject checkLogin = delegate.checkLoginForBS(userName, password, client);
    }
    
    private PortalVI getPortalDefination(DataModelFactory factory, String type, String context, PLTabPage currentab) throws Throwable {
         PLUILayout contextDef = factory.getContextDefination(type, context);
         if (contextDef == null) {
             return null;
         }
         PLTabPage[] tabs = factory.getTabDefinationByContextId(contextDef.plOId);
         currentab.plOId = tabs[0].plOId;
         currentab.plName = tabs[0].plName;
         PLPageDefination[] definations = factory.getPageDefinationById(tabs[0].plOId);
         PLDefination defination = UITools.getPLDefination(definations[0].plDefination);
         PortalVI tableDef = factory.getTableDefinationByTypeAndTableName(type, defination.getTemplateId());
         
         return tableDef;
    }
    
    public TablePanelTest() throws Throwable{
        
        init();
        
        TablePanel tp = new TablePanel();
        
        String type = "Model";
        String context = "ModelManagement";
 
        
        type = "staff";
        context = "staffManagement";
        
        DataModelFactory factory = new DataModelFactory();
        PLTabPage currenTab = new PLTabPage();
        PLUILayout contextDef = factory.getContextDefination(type, context);
        PLTabPage[] tabs = factory.getTabDefinationByContextId(contextDef.plOId);
        currenTab.plOId = tabs[0].plOId;
        currenTab.plName = tabs[0].plName;
        PLPageDefination[] definations = factory.getPageDefinationById(tabs[0].plOId);
        PLDefination defination = UITools.getPLDefination(definations[0].plDefination);
 
        tp.preInit(type, context);
        
        tp.setType(type);
        tp.setContext(context);
        tp.setDefination(defination);
        tp.setTabId(tabs[0].plOId);
        
        Component compt = tp.init();
        
        setLayout(new BorderLayout());
        
        add(compt, BorderLayout.CENTER);
    }
    
    /**
     * @param args
     */
    public static void main(String[] args) {
//        // TODO Auto-generated method stub
//        SwingUtilities.invokeLater(new Runnable() {
//            
//            @Override
//            public void run() {
//                // TODO Auto-generated method stub
//                try {
//                    creatAndShowGUI();
//                } catch (Throwable e) {
//                    // TODO Auto-generated catch block
//                    e.printStackTrace();
//                }
//            }
//        });
        
        String rule = "${t_oid.found}-${f_oid.notfound}";
        boolean allFieldExist = true;
        int start = rule.indexOf("${");
        int end = rule.indexOf("}");
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("t_oid.found", "");
        String defaultValue = rule;
        while(start >= 0 && end >= 0 && start < end && end < rule.length()){
            String field = rule.substring(start+2, end);
            rule = rule.substring(end+1);
            if(!map.containsKey(field)){
                allFieldExist = false;
                defaultValue = "";
                break;
            }
            start = rule.indexOf("${");
            end = rule.indexOf("}");
        }
        System.out.println(defaultValue);
        
        Pattern ptn = Pattern.compile(".*$$\\{[0-9]+\\}.*");
        String input = "{123}";
        boolean matches = ptn.matcher(input).matches();
        System.out.println(matches);
        Matcher m = ptn.matcher(input);
        int groupCount = m.groupCount();
        for(int i = 0; i < groupCount; i++){
            String group = m.group(i);
            System.out.println(group);
        }
        
        final QANProcessBarFrame frame = new QANProcessBarFrame();
        Thread t = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    frame.setContent(String.valueOf(i));
                    
                }
                frame.setProcessBarCancel(true);
            }
        };
        final QANProcessBar bar = new QANProcessBar(t, frame, frame, "", false);
        bar.setVisible(true);
        
    }
    
    private static void creatAndShowGUI() throws Throwable{
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(new TablePanelTest());
        
        f.pack();
        VCISwingUtil.setClientMainFrame(f);
        f.setVisible(true);
    }
 
}