first commit

main
洪丞进 2 weeks ago
commit b96f17448f

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/xml-resolver-1.2.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans-2.3.0.jar"/>
<classpathentry kind="lib" path="lib/XmlSchema-1.4.7.jar"/>
<classpathentry kind="lib" path="lib/xmpbox-2.0.11.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.connor.mbd.plm</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,111 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PLM
Bundle-SymbolicName: com.connor.mbd.plm;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.connor.mbd.plm.Activator
Bundle-Vendor: CONNOR
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime;bundle-version="3.12.0",
com.teamcenter.rac.common;bundle-version="12000.1.0",
com.teamcenter.rac.util;bundle-version="12000.1.0",
com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
TcSoaCoreRac;bundle-version="12000.1.0",
TcSoaCommon;bundle-version="12000.1.0",
com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
org.eclipse.osgi.services;bundle-version="3.5.100",
com.teamcenter.rac.kernel;bundle-version="12000.1.0",
org.apache.poi.39;bundle-version="3.9.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/dom4j-1.6.1.jar,
lib/xml-resolver-1.2.jar,
lib/xmlbeans-2.3.0.jar,
lib/XmlSchema-1.4.7.jar,
lib/xmpbox-2.0.11.jar,
.
Export-Package: com.connor.mbd.dialogs,
com.connor.mbd.handlers,
com.connor.mbd.plm,
com.connor.mdb.beans,
org.apache.ws.commons.schema,
org.apache.ws.commons.schema.constants,
org.apache.ws.commons.schema.extensions,
org.apache.ws.commons.schema.resolver,
org.apache.ws.commons.schema.tools,
org.apache.ws.commons.schema.utils,
org.apache.xml.resolver,
org.apache.xml.resolver.apps,
org.apache.xml.resolver.helpers,
org.apache.xml.resolver.readers,
org.apache.xml.resolver.tools,
org.apache.xmlbeans,
org.apache.xmlbeans.impl.common,
org.apache.xmlbeans.impl.config,
org.apache.xmlbeans.impl.inst2xsd,
org.apache.xmlbeans.impl.inst2xsd.util,
org.apache.xmlbeans.impl.jam,
org.apache.xmlbeans.impl.jam.annotation,
org.apache.xmlbeans.impl.jam.internal,
org.apache.xmlbeans.impl.jam.internal.classrefs,
org.apache.xmlbeans.impl.jam.internal.elements,
org.apache.xmlbeans.impl.jam.internal.javadoc,
org.apache.xmlbeans.impl.jam.internal.parser,
org.apache.xmlbeans.impl.jam.internal.reflect,
org.apache.xmlbeans.impl.jam.mutable,
org.apache.xmlbeans.impl.jam.provider,
org.apache.xmlbeans.impl.jam.visitor,
org.apache.xmlbeans.impl.jam.xml,
org.apache.xmlbeans.impl.piccolo.io,
org.apache.xmlbeans.impl.piccolo.util,
org.apache.xmlbeans.impl.piccolo.xml,
org.apache.xmlbeans.impl.regex,
org.apache.xmlbeans.impl.richParser,
org.apache.xmlbeans.impl.schema,
org.apache.xmlbeans.impl.soap,
org.apache.xmlbeans.impl.store,
org.apache.xmlbeans.impl.tool,
org.apache.xmlbeans.impl.util,
org.apache.xmlbeans.impl.validator,
org.apache.xmlbeans.impl.values,
org.apache.xmlbeans.impl.xb.ltgfmt,
org.apache.xmlbeans.impl.xb.ltgfmt.impl,
org.apache.xmlbeans.impl.xb.substwsdl,
org.apache.xmlbeans.impl.xb.substwsdl.impl,
org.apache.xmlbeans.impl.xb.xmlconfig,
org.apache.xmlbeans.impl.xb.xmlconfig.impl,
org.apache.xmlbeans.impl.xb.xmlschema,
org.apache.xmlbeans.impl.xb.xmlschema.impl,
org.apache.xmlbeans.impl.xb.xsdownload,
org.apache.xmlbeans.impl.xb.xsdownload.impl,
org.apache.xmlbeans.impl.xb.xsdschema,
org.apache.xmlbeans.impl.xb.xsdschema.impl,
org.apache.xmlbeans.impl.xsd2inst,
org.apache.xmlbeans.soap,
org.apache.xmlbeans.xml.stream,
org.apache.xmlbeans.xml.stream.events,
org.apache.xmlbeans.xml.stream.utils,
org.apache.xmpbox,
org.apache.xmpbox.schema,
org.apache.xmpbox.type,
org.apache.xmpbox.xml,
org.dom4j,
org.dom4j.bean,
org.dom4j.datatype,
org.dom4j.dom,
org.dom4j.dtd,
org.dom4j.io,
org.dom4j.jaxb,
org.dom4j.rule,
org.dom4j.rule.pattern,
org.dom4j.swing,
org.dom4j.tree,
org.dom4j.util,
org.dom4j.xpath,
org.dom4j.xpp,
org.w3c.dom,
repackage,
schemaorg_apache_xmlbeans.system.sXMLCONFIG,
schemaorg_apache_xmlbeans.system.sXMLLANG,
schemaorg_apache_xmlbeans.system.sXMLSCHEMA,
schemaorg_apache_xmlbeans.system.sXMLTOOLS

@ -0,0 +1,11 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
lib/dom4j-1.6.1.jar,\
lib/xml-resolver-1.2.jar,\
lib/xmlbeans-2.3.0.jar,\
lib/XmlSchema-1.4.7.jar,\
lib/xmpbox-2.0.11.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command name="批量修改成熟度" id="com.connor.mbd.commands.Modifymaturity"></command>
<command name="创建/编辑协同审查单" id="com.connor.mbd.commands.CreateGyscbdForm"></command>
<!--
<command name="协同性审查" id="com.connor.mbd.commands.Processreview"></command>
-->
<command name="协同审查查看" id="com.connor.mbd.commands.Reviewstatistical"></command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com.connor.mbd.commands.Modifymaturity"
class="com.connor.mbd.handlers.ModifymaturityHandler">
</handler>
<handler
commandId="com.connor.mbd.commands.CreateGyscbdForm"
class="com.connor.mbd.handlers.CreateGyscbdFormHandler">
</handler>
<!--
<handler
commandId="com.connor.mbd.commands.Processreview"
class="com.connor.mbd.handlers.ProcessreviewHandler">
</handler>
-->
<handler
commandId="com.connor.mbd.commands.Reviewstatistical"
class="com.connor.mbd.handlers.ReviewstatisticalHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:cust.design.pseMenu?after=additions">
<command
commandId="com.connor.mbd.commands.Modifymaturity"
mnemonic="S"
id="com.connor.MBD.PLM.modifyCommand">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.mbd.commands.Modifymaturity"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cust.MBD.gyMenu?after=additions">
<command
commandId="com.connor.mbd.commands.CreateGyscbdForm"
mnemonic="S"
id="com.connor.MBD.PLM.createGyscbdFormCommand">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.mbd.commands.CreateGyscbdForm"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<!--
<command
commandId="com.connor.mbd.commands.Processreview"
mnemonic="S"
id="com.connor.MBD.PLM.ProcessreviewCommand">
</command>
-->
<command
commandId="com.connor.mbd.commands.Reviewstatistical"
mnemonic="S"
id="com.connor.MBD.PLM.ReviewstatisticalCommand">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.mbd.commands.Reviewstatistical"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<!-- <toolbar
id="com.connor.MBD.PLM.toolbars.sampleToolbar">
</toolbar>-->
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,38 @@
package com.connor.mbd.dialogs;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
public class ColorIcon implements Icon {
private Color color;
private int width;
private int height;
public ColorIcon(Color color, int width, int height)
{
this.color = color;
this.width = width;
this.height = height;
}
public int getIconWidth()
{
return width;
}
public int getIconHeight()
{
return height;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.setColor(color);
g.fillRect(x, y, width, height);
}
}

@ -0,0 +1,590 @@
package com.connor.mbd.dialogs;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Label;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCAccessControlService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ModifymaturityDialog extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
TCSession session;
AbstractAIFUIApplication application;
InterfaceAIFComponent[] targets;
private TCAccessControlService accessService;
private Map<String, Integer> maturityMap;
private List<HashSet<String>> typeList;
private HashMap<String, ArrayList<String[]>> propsMap;
private int targetMat;
private List<String> errorList;
private boolean isrev;
public ModifymaturityDialog(InterfaceAIFComponent[] targets, boolean isrev) {
application = AIFUtility.getCurrentApplication();
session = (TCSession) AIFUtility.getCurrentApplication().getSession();
this.targets = targets;
this.isrev = isrev;
init();
}
private void init() {
propsMap = new HashMap<>();
String[] values = getPrefStrArray("CONNOR_AVIC_M2_Props", session);
if (values == null || values.length == 0) {
MessageBox.post("首选项CONNOR_AVIC_M2_Props配置不正确", "错误", MessageBox.ERROR);
return;
}
for(String s : values) {
ArrayList<String[]> list = new ArrayList<>();
String[] split = s.split("=");
for(String ss : split[1].split(";"))
list.add(ss.split("\\."));
propsMap.put(split[0], list);
}
String[] values3 = getPrefStrArray("CONNOR_AVIC_M3_Props", session);
if (values3 == null || values3.length == 0) {
MessageBox.post("首选项CONNOR_AVIC_M3_Props配置不正确", "错误", MessageBox.ERROR);
return;
}
for(String s : values3) {
ArrayList<String[]> list = new ArrayList<>();
String[] split = s.split("=");
for(String ss : split[1].split(";"))
list.add(ss.split("\\."));
propsMap.put("1"+split[0], list);
}
this.setTitle("批量设置成熟度");
this.setLayout(new BorderLayout());
JLabel nameLabel = new JLabel("成熟度:");
JComboBox<String> maturityComb = new JComboBox<>(new String[] { "M1", "M2", "M3" });
Box box = Box.createHorizontalBox();
box.setAlignmentX(Box.CENTER_ALIGNMENT);
box.add(Box.createHorizontalStrut(100));
box.add(nameLabel);
box.add(Box.createHorizontalStrut(30));
box.add(maturityComb);
box.add(Box.createHorizontalStrut(100));
JButton okButton = new JButton("确定");
JButton celButton = new JButton("取消");
Box box2 = Box.createHorizontalBox();
box2.setAlignmentX(Box.CENTER_ALIGNMENT);
box2.add(okButton);
box2.add(Box.createHorizontalStrut(30));
box2.add(celButton);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
maturityMap = new HashMap<>();
maturityMap.put("", 1);
maturityMap.put("M1", 1);
maturityMap.put("M2", 2);
maturityMap.put("M3", 3);
maturityMap.put("M4", 4);
maturityMap.put("Release", 4);
Map<Integer, String> maturityMap2 = new HashMap<>();
maturityMap2.put(1, "M1");
maturityMap2.put(2, "M2");
maturityMap2.put(3, "M3");
typeList = new ArrayList<>();
typeList.add(new HashSet<>());
typeList.add(new HashSet<>());
typeList.add(new HashSet<>());
errorList = new ArrayList<String>();
// HashSet<String> partsSet = new HashSet<>();
// HashSet<String> miliPartsSet = new HashSet<>();
// HashSet<String> miliProductSet = new HashSet<>();
// HashSet<String> partsTypeSet = new HashSet<>();
// Map<String, String> modelMap = new HashMap<>();
HashMap<TCComponent[], Integer> partsList = new HashMap<>();
initMap(errorList);
okButton.addActionListener(e -> {
try {
String maturity = maturityComb.getSelectedItem().toString();
if(maturity.isEmpty()) {
errorList.add("未选择成熟度");
return;
}
targetMat = maturityMap.get(maturity);
if(isrev)
isRevTrue(targets, partsList);
else
isDateTrue(targets, partsList);
HashSet<TCComponentBOMWindow> windows = new HashSet<>();
for (Entry<TCComponent[], Integer> entry : partsList.entrySet()) {
TCComponent[] comps = entry.getKey();
String ac5_maturity = comps[1].getProperty("ac5_maturity");
System.out.println(comps[0]+"=="+ac5_maturity+"=="+entry.getValue());
comps[1].getTCProperty("ac5_maturity").setStringValue(maturityMap2.get(entry.getValue()));
if(!isrev) {
comps[0].refresh();
TCComponentBOMWindow window = ((TCComponentBOMLine)comps[0]).window();
if(!windows.contains(window))
windows.add(window);
}
}
if(!isrev) {
for(TCComponentBOMWindow window : windows)
window.refresh();
}
if (errorList.size() > 0) {
StringBuffer sb = new StringBuffer();
for (String error : errorList) {
sb.append(error);
sb.append(System.getProperty("line.separator"));
}
JTextArea textArea = new JTextArea("设置成熟度出现错误,如下:\n" + sb.toString(), 15, 40);
textArea.setLineWrap(true);
JOptionPane.showMessageDialog(null, new JScrollPane(textArea), "错误", JOptionPane.ERROR_MESSAGE);
this.dispose();
} else {
// ((TCComponentBOMLine)targets[0]).window().refresh();
MessageBox.post(this, "设置成功!", "提示", MessageBox.INFORMATION);
this.dispose();
}
} catch (Exception e1) {
MessageBox.post(this, "错误:"+e1.getMessage(), "错误", MessageBox.ERROR);
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
System.out.println(this.getSize().getHeight() + " " + this.getSize().getWidth());
this.setVisible(false);
});
panel.add(Box.createVerticalStrut(50));
panel.add(box);
panel.add(Box.createVerticalStrut(50));
panel.add(box2);
panel.add(Box.createVerticalStrut(50));
add(panel, BorderLayout.CENTER);
this.setSize(437, 245);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
private void isDateTrue(InterfaceAIFComponent[] targets, HashMap<TCComponent[], Integer> partsList) {
try {
JProgressBar progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
WaitingDialog dia = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "提示", "正在验证数据", progressBar);
int i = 0;
progressBar.setMaximum(targets.length);
dia.setVisible(true);
accessService = session.getTCAccessControlService();
for (InterfaceAIFComponent target : targets) {
try {
i++;
progressBar.setValue(i);
TCComponentBOMLine line = (TCComponentBOMLine) target;
String type = line.getItem().getType();
boolean acl = true, need = true;
int result = 0;
TCComponentItemRevision rev = line.getItemRevision();
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
if (!typeList.get(0).contains(type) && !typeList.get(1).contains(type) && !typeList.get(2).contains(type)) {
// errorList.add(line.getItem() + "非修改成熟度类型");
AIFComponentContext[] children = line.getChildren();
if(children!=null && children.length>0) {
String model = form.getProperty("ac5_ProductModel");
int sub = isModelSame(children, partsList, model);
if(need) {
if(sub<result)
result = sub;
}
}
continue;
}
String ac5_maturity = form.getProperty("ac5_maturity");
System.out.println(line+"=="+ac5_maturity);
if(ac5_maturity.equals("-"))
continue;
int maturity = ac5_maturity.isEmpty() ? 1 : maturityMap.get(ac5_maturity);
if(ac5_maturity.equals("M4") || ac5_maturity.equals("Release")) {
// errorList.add(rev+"的成熟度为M4或者Release无法修改");
need = false;
}else if(maturity==targetMat) {
need = false;
}else {
if(!accessService.checkPrivilege(form, TCAccessControlService.WRITE)) {
errorList.add(rev + "没有修改权限");
acl = false;
}
if(ac5_maturity.isEmpty() && acl) {
form.getTCProperty("ac5_maturity").setStringValue("M1");
}
if(targetMat < maturity) {
need = false;
if(acl)
partsList.put(new TCComponent[] { line, form }, targetMat);
}else {
if(acl)
result = checkProps(rev, form);
else
result = maturity;
}
}
AIFComponentContext[] children = line.getChildren();
if(children!=null && children.length>0) {
String model = form.getProperty("ac5_ProductModel");
int sub = isModelSame(children, partsList, model);
if(need) {
if(sub < targetMat) {
errorList.add(rev + "成熟度不可修改至M"+targetMat+",因下级零件成熟度未达标");
}
if(sub<result)
result = sub;
}
}
if(need && acl && result>maturity) {
partsList.put(new TCComponent[] { line, form }, result);
}
} catch (Exception e) {
errorList.add(target+" 进行检查时出现错误:"+e.getMessage());
e.printStackTrace();
}
}
dia.dispose();
} catch (Exception e) {
errorList.add("进行检查时出现错误:"+e.getMessage());
e.printStackTrace();
}
}// ac5_maturity
private int isModelSame(AIFComponentContext[] childs, HashMap<TCComponent[], Integer> partsList, String parentModel) {
int level = targetMat;
for (AIFComponentContext child : childs) {
TCComponentBOMLine line = (TCComponentBOMLine) child.getComponent();
try {
String type = line.getItem().getType();
boolean acl = true, need = true;
int result = targetMat;
TCComponentItemRevision rev = line.getItemRevision();
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
if(!typeList.get(0).contains(type) && !typeList.get(1).contains(type) && !typeList.get(2).contains(type)) {
// errorList.add(line.getItem() + "非修改成熟度类型");
AIFComponentContext[] children = line.getChildren();
if(children!=null && children.length>0) {
String model = form.getProperty("ac5_ProductModel");
int sub = isModelSame(children, partsList, model);
if(need) {
if(sub<result)
result = sub;
}
}
continue;
}
String ac5_maturity = form.getProperty("ac5_maturity");
System.out.println(line+"=="+ac5_maturity);
if(ac5_maturity.equals("-"))
continue;
int maturity = ac5_maturity.isEmpty() ? 1 : maturityMap.get(ac5_maturity);
if(ac5_maturity.equals("M4") || ac5_maturity.equals("Release")) {
// errorList.add(rev+"的成熟度为M4或者Release无法修改");
need = false;
}else if(maturity == targetMat) {
need = false;
}else {
if(!accessService.checkPrivilege(form, TCAccessControlService.WRITE)) {
errorList.add(rev + "没有修改权限");
acl = false;
}
if(ac5_maturity.isEmpty() && acl) {
form.getTCProperty("ac5_maturity").setStringValue("M1");
}
if(targetMat < maturity) {
need = false;
if(acl)
partsList.put(new TCComponent[] { line, form }, targetMat);
}else {
if(acl)
result = checkProps(rev, form);
else
result = maturity;
}
}
AIFComponentContext[] children = line.getChildren();
if(children!=null && children.length>0) {
String model = form.getProperty("ac5_ProductModel");
int sub = isModelSame(children, partsList, model);
if(need) {
if(sub < targetMat) {
errorList.add(rev + "成熟度不可修改至M"+targetMat+",因下级零件成熟度未达标");
}
if(sub<result)
result = sub;
}
}
if(need && acl && result>maturity) {
partsList.put(new TCComponent[] { line, form }, result);
}
if(level > result)
level = result;
} catch (Exception e) {
errorList.add(line+" 进行检查时出现错误:"+e.getMessage());
level = 1;
e.printStackTrace();
}
}
// System.out.println(line + ":" + result);
return level;
}
private void isRevTrue(InterfaceAIFComponent[] targets, HashMap<TCComponent[], Integer> partsList) {
try {
JProgressBar progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
WaitingDialog dia = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "提示", "正在验证数据", progressBar);
int i = 0;
progressBar.setMaximum(targets.length);
dia.setVisible(true);
accessService = session.getTCAccessControlService();
for (InterfaceAIFComponent target : targets) {
try {
i++;
progressBar.setValue(i);
TCComponentItemRevision rev = (TCComponentItemRevision) target;
String type = rev.getItem().getType();
if (!typeList.get(0).contains(type)) {
// errorList.add(rev + "对象非零件类型");
continue;
}
boolean acl = true;
int prop = 0;
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
String ac5_maturity = form.getProperty("ac5_maturity");
System.out.println(rev+"=="+ac5_maturity);
int maturity = ac5_maturity.isEmpty() ? 1 : maturityMap.get(ac5_maturity);
if(ac5_maturity.equals("M4") || ac5_maturity.equals("Release")) {
// errorList.add(rev+"的成熟度为M4或者Release无法修改");
}else if(maturity != targetMat) {
if(!accessService.checkPrivilege(form, TCAccessControlService.WRITE)) {
errorList.add(rev + "没有修改权限");
acl = false;
}
if(ac5_maturity.isEmpty() && acl) {
form.getTCProperty("ac5_maturity").setStringValue("M1");
}
if(targetMat < maturity) {
if(acl)
partsList.put(new TCComponent[] { rev, form }, targetMat);
}else {
prop = checkProps(rev, form);
if(acl && prop>maturity) {
partsList.put(new TCComponent[] { rev, form }, prop);
}
}
}
} catch (Exception e) {
errorList.add(target+" 进行检查时出现错误:"+e.getMessage());
e.printStackTrace();
}
}
dia.dispose();
} catch (Exception e) {
errorList.add("进行检查时出现错误:"+e.getMessage());
e.printStackTrace();
}
}
@SuppressWarnings("deprecation")
public static String[] getPrefStrArray(String prefName, TCSession session) {
TCPreferenceService service = session.getPreferenceService();
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
service.getStringValues(prefName);
service.getStringValue(prefName);
if (strs == null) {
strs = new String[] { "" };
}
return strs;
}
private void initMap(List<String> errorList) {
String[] values = getPrefStrArray("AC_Modifymaturity_Type", session);
if (values == null || values.length == 0) {
errorList.add("请检查首选项是否填写");
return;
}
for (String value : values) {
String[] splitValues = value.split(":");
if (splitValues.length > 1) {
String[] types = splitValues[1].split(",");
for (String type : types) {
if (splitValues[0].equals("零件")) {
typeList.get(0).add(type);
} else if (splitValues[0].equals("部件")) {
typeList.get(1).add(type);
} else if (splitValues[0].equals("总装节点")) {
typeList.get(2).add(type);
}
}
}
}
}
private int checkProps(TCComponentItemRevision rev, TCComponent form) throws Exception {
String ac5_maturity = form.getProperty("ac5_maturity");
String type = rev.getItem().getType();
TCComponentType revType = session.getTypeService().getTypeComponent(rev.getType());//.getPropertyDescriptor(rowProp).getDisplayName()
TCComponentType formType = session.getTypeService().getTypeComponent(form.getType());
int mat2 = maturityMap.get(ac5_maturity);
int result = 1;
boolean check = true;
if(mat2==1 && targetMat!=1) {
if(typeList.get(0).contains(type) && propsMap.containsKey("1")) {
for(String[] prop : propsMap.get("1")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}
}
}else if(typeList.get(1).contains(type) && propsMap.containsKey("2")) {
for(String[] prop : propsMap.get("2")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}
}
}else if(typeList.get(2).contains(type) && propsMap.containsKey("3")) {
for(String[] prop : propsMap.get("3")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M2");
check = false;
}
}
}
if(check)
result = 2;
}
if(targetMat == 3) {
if(typeList.get(0).contains(type) && propsMap.containsKey("11")) {
for(String[] prop : propsMap.get("11")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}
}
}else if(typeList.get(1).contains(type) && propsMap.containsKey("12")) {
for(String[] prop : propsMap.get("12")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}
}
}else if(typeList.get(2).contains(type) && propsMap.containsKey("13")) {
for(String[] prop : propsMap.get("13")) {
if(prop[0].equals("rev") && rev.getProperty(prop[1]).isEmpty()) {
errorList.add(rev + "的属性["+revType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}else if(prop[0].equals("form") && form.getProperty(prop[1]).isEmpty()) {
errorList.add(form + "的属性["+formType.getPropertyDescriptor(prop[1]).getDisplayName()+"]没有填写不可升级成熟度到M3");
check = false;
}
}
}
if(check)
result = 3;
}
return result;
}
}
class WaitingDialog extends AbstractAIFDialog {
private static final long serialVersionUID = 1L;
public JPanel panel;
JProgressBar progressBar = null;
public WaitingDialog(Frame arg0, String title, String message, JProgressBar progressBar) {
super(arg0, title);
this.setModal(false);
this.progressBar = progressBar;
panel = new JPanel(new BorderLayout());
/*
* JLabel label = new JLabel(message);
* System.out.println("message:"+message);
* System.out.println("label:"+label); panel.add(label);
*/
// progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
panel.add(BorderLayout.CENTER, new Label(message));
panel.add(BorderLayout.SOUTH, progressBar);
panel.setPreferredSize(new Dimension(350, 60));
this.getContentPane().add(panel);
centerToScreen();
pack();
}
}

@ -0,0 +1,110 @@
package com.connor.mbd.dialogs;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import com.connor.mdb.beans.PictureBeans;
import com.teamcenter.rac.kernel.TCComponent;
public class MyButtonEditor extends DefaultCellEditor {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -6546334664166791132L;
private JPanel panel;
private JButton button;
private boolean okToModify;
public PictureBeans bean;
private JTable table;
private List<Integer> unableList;
private HashMap<Integer, TCComponent> tableRowRefList;
public MyButtonEditor(JTable table,boolean okToModify,List<Integer> unableList,HashMap<Integer, TCComponent> tableRowRefList)
{
// DefautlCellEditor有此构造器需要传入一个但这个不会使用到直接new一个即可。
super(new JTextField());
// 设置点击几次激活编辑。
this.setClickCountToStart(1);
this.button = new JButton("浏览/选择");
this.table = table;
this.okToModify = okToModify;
this.unableList = unableList;
this.tableRowRefList = tableRowRefList;
this.initButton();
this.initPanel();
// 添加按钮。
this.panel.add(this.button);
}
private void initButton()
{
//this.button = new JButton();
// 设置按钮的大小及位置。
this.button.setBounds(0, 0, 50, 15);
// 为按钮添加事件。这里只能添加ActionListner事件Mouse事件无效。
this.button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// 触发取消编辑的事件不会调用tableModel的setValue方法。
MyButtonEditor.this.fireEditingCanceled();
bean = new PictureBeans();
SelectpictureDialog selectpictureDialog = new SelectpictureDialog(bean,table,okToModify,tableRowRefList);
// 这里可以做其它操作。
// 可以将table传入通过getSelectedRow,getSelectColumn方法获取到当前选择的行和列及其它操作等。
selectpictureDialog.setAlwaysOnTop(true);
}
});
}
private void initPanel()
{
this.panel = new JPanel();
// panel使用绝对定位这样button就不会充满整个单元格。
this.panel.setLayout(null);
}
/**
* JPanelButton
*/
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
{
// 只为按钮赋值即可。也可以作其它操作。
//this.button.setText(value == null ? "" : String.valueOf(value));
if(unableList != null && unableList.contains(Integer.valueOf(row))){
okToModify = false;
}
return this.button;
}
/**
*
*/
@Override
public Object getCellEditorValue()
{
return this.button.getText();
}
}

@ -0,0 +1,74 @@
package com.connor.mbd.dialogs;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
public class MyButtonRender implements TableCellRenderer {
private JPanel panel;
private JButton button;
public static final DefaultTableCellRenderer DEFAULT_RENDERER
= new DefaultTableCellRenderer();
public MyButtonRender() {
this.button = new JButton("浏览/选择");
this.initButton();
this.initPanel();
// 添加按钮。
this.panel.add(this.button);
}
private void initButton() {
// this.button = new JButton();
// 设置按钮的大小及位置。
this.button.setBounds(0, 0, 50, 15);
// 在渲染器里边添加按钮的事件是不会触发的
// this.button.addActionListener(new ActionListener()
// {
//
// public void actionPerformed(ActionEvent e)
// {
// // TODO Auto-generated method stub
// }
// });
}
private void initPanel() {
this.panel = new JPanel();
// panel使用绝对定位这样button就不会充满整个单元格。
this.panel.setLayout(null);
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
// 只为按钮赋值即可。也可以作其它操作,如绘背景等。
// this.button.setText(value == null ? "" : String.valueOf(value));
if (table.getValueAt(row, 1) != null && !table.getValueAt(row, 1).equals("")) {
this.button.setContentAreaFilled(false);
table.getComponentAt(row, column).setBackground(Color.GREEN);
// DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
// .setBackground(Color.GREEN);
}else{
this.button.setContentAreaFilled(true);
}
return this.button;
}
}

@ -0,0 +1,37 @@
package com.connor.mbd.dialogs;
import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class MyCellEditor extends DefaultCellEditor {
private JTextArea textArea;
public MyCellEditor(JTextArea textArea) {
super(new JTextField());
this.textArea = textArea;
this.textArea.setLineWrap(true);
this.textArea.setWrapStyleWord(true);
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
// 只为按钮赋值即可。也可以作其它操作。
this.textArea.setText(value == null ? "" : value.toString());
return this.textArea;
}
/**
*
*/
@Override
public Object getCellEditorValue() {
return this.textArea.getText();
}
}

@ -0,0 +1,74 @@
package com.connor.mbd.dialogs;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.table.TableCellRenderer;
public class MyCellRender extends JTextArea implements TableCellRenderer {
private boolean okToModify;
List<Integer> unableList= new ArrayList<>();
List<Integer> enableList= new ArrayList<>();
public MyCellRender(boolean okToModify,List<Integer> unableList,List<Integer> enableList) {
this.okToModify = okToModify;
this.unableList = unableList;
this.enableList = enableList;
setLineWrap(true);
setWrapStyleWord(true);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
if (!okToModify) {
this.setBackground(Color.lightGray);
}else{
this.setBackground(Color.WHITE);
}
if(unableList!=null){
if(unableList.contains(Integer.valueOf(row))){
this.setBackground(Color.lightGray);
}else{
this.setBackground(Color.WHITE);
}
}
if(enableList!=null){
if(enableList.contains(Integer.valueOf(column))){
this.setBackground(Color.lightGray);
}else{
if(!this.getBackground().equals(Color.lightGray))
this.setBackground(Color.WHITE);
}
}
if(isSelected&&!this.getBackground().equals(Color.lightGray)){
this.setBackground(table.getSelectionBackground());
}
this.setBorder(null);
int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
}
if (table.getRowHeight(row) != maxPreferredHeight) // ÉÙÁËÕâÐÐÔò´¦ÀíÆ÷Ϲæ
table.setRowHeight(row, maxPreferredHeight);
setText(value == null ? "" : value.toString());
return this;
}
}

@ -0,0 +1,918 @@
package com.connor.mbd.dialogs;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.EventObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.swing.AbstractCellEditor;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.CellEditorListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableRowSorter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.connor.mdb.beans.CodeBean;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.GetCodeBean;
import com.connor.mdb.beans.MenuBean;
import com.connor.mdb.beans.MenuCodeBean;
import com.connor.mdb.beans.ParseXML;
import com.connor.mdb.beans.TableBean;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentICO;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
import com.teamcenter.rac.kernel.ics.ICSKeyLov;
import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
public class ProcessreviewDialog extends AbstractAIFDialog {
JButton plusButton;
JButton removeButton;
JButton okButton;
JButton celButton;
JButton okBut2;
JButton celBut2;
JButton chooseButton;
JTable table;
DefaultTableModel model = null;
Map<String, String> prefMap = null;
Map<String, String> parentMap = null;
Map<String, Map<String, String>> tablePropMap = null;
Map<Integer, String> propMap = null;
List<Integer> enableList = null;
List<Integer> mustList = null;
private TCComponentForm form;
private AIFComponentContext revision;
private static TCSession session;
private JScrollPane scrollPane;
private int realPropSize;
private String picProp;
private String picParentProp;
private int JCXindex = 0;
private int TJindex = 0;
private TCPreferenceService service;
// private String[] columnNames = {"序号","检查项内容","是否勾选"};
private GetCodeBean getcode;
private boolean okToModify;
private JComboBox ideaBox = new JComboBox();
// private static int serial = 1;
List<GeneralBean> generalList = new ArrayList<>();
List<TableBean> tableList = new ArrayList<>();
List<TCComponent> tableCompList = new ArrayList<>();
List<TCComponent> removeList = new ArrayList<>();
HashMap<Integer, TCComponent> tableRowRefList = new HashMap<>();
public ProcessreviewDialog(List<GeneralBean> generalList, TCComponentForm form, AIFComponentContext revisions,
TCSession session, List<TableBean> tableList, int realPropSize, boolean okToModify) {
super(false);
this.generalList = generalList;
this.form = form;
this.revision = revisions;
this.session = session;
this.tableList = tableList;
this.realPropSize = realPropSize;
this.okToModify = okToModify;
this.service = session.getPreferenceService();
String[] values = service.getStringValues("Connor_AVIC_idea_defaulValue");
if ((values == null) || (values.length == 0)) {
MessageBox.post("首选项【Connor_AVIC_idea_defaulValue】配置有误,请联系管理员!", "INFO", MessageBox.INFORMATION);
return;
}
for (int i = 0; i < values.length; i++) {
ideaBox.addItem(values[i]);
}
init();
}
private void init() {
this.setTitle("协同性审查");
this.setLayout(new BorderLayout());
plusButton = new JButton("+");
removeButton = new JButton("全部清除");
okButton = new JButton("确定");
celButton = new JButton("取消");
chooseButton = new JButton("浏览/选择");
int size = generalList.size() + realPropSize - 1;
System.out.println(size);
Object[] objs = new Object[2 + size];
objs[0] = "序号";
objs[1] = "审查图片";
enableList = new ArrayList<Integer>();
mustList = new ArrayList<Integer>();
propMap = new HashMap<>();
parentMap = new HashMap<>();
int index = 2;
for (GeneralBean bean : generalList) {
objs[index] = bean.getDisplayName();
bean.setColumNum(index);
if (!bean.isEditable()) {
enableList.add(index);
}
index++;
}
boolean picFlag = okToModify;
for (TableBean tableBean : tableList) {
List<GeneralBean> realPropList = tableBean.getPropList();
for (GeneralBean bean : realPropList) {
if (bean.getDisplayName().equals("审查图片")) {
bean.setColumNum(1);
if (!bean.isEditable()) {
picFlag = false;
}
continue;
}
objs[index] = bean.getDisplayName();
System.out.println("objs[index]============" + objs[index]);
if ("检查项".equals(bean.getDisplayName())) {
JCXindex = index;
} else if ("强制/推荐".equals(bean.getDisplayName())) {
TJindex = index;
} else if ((bean.getDisplayName()).contains("*")) {
mustList.add(index);
}
bean.setColumNum(index);
if (!bean.isEditable()) {
enableList.add(index);
}
index++;
}
}
for (Object obj : objs) {
System.out.println(obj);
}
model = new DefaultTableModel(objs, 0) {
@Override
public boolean isCellEditable(int row, int column) {
if (!okToModify && column != 1) {
return false;
}
if (column == 0) {
return false;
}
for (int i = 0; i < enableList.size(); i++) {
if (enableList.get(i).equals(column)) {
return false;
}
}
return true;
}
};
table = new JTable(model);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
initTable();
// table.addPropertyChangeListener(e -> {
// setAutoHigh(table.getSelectedRow());
// });
// table.setPreferredSize(new Dimension(500, 300));
// table.setSize(new Dimension(500, 300));
scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(800, 500));
JPanel contentPanel = new JPanel();
contentPanel.add("1.1.center.top", scrollPane);
TitledBorder border = new TitledBorder("检查项类型");
border.setTitleJustification(TitledBorder.LEFT);
border.setTitlePosition(TitledBorder.TOP);
JPanel typepanel = new JPanel(new BorderLayout());// 检查项内容界面
typepanel.setBorder(border);
typepanel.setPreferredSize(new Dimension(200, 500));
// scrollPane.setPreferredSize(new Dimension(600, 300));
getcode = new GetCodeBean(session);
MenuBean menuBean = getcode.getMenuBean("检查项类型");
JTree tree = getTree(menuBean);
tree.addMouseListener(new java.awt.event.MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (path != null) {
TreeNode node = (TreeNode) path.getLastPathComponent();
int childCount = node.getChildCount();
System.out.println("当前被选中的节点: " + node + " 子节点数量:" + childCount);
if (childCount > 0) {
} else {
int clickCount = e.getClickCount();
System.out.println("clickCount====" + clickCount);
if (clickCount == 2) {
doubleClick(node);
}
}
}
}
private void doubleClick(TreeNode treeNode) {
// TODO Auto-generated method stub
System.out.println("继续操作");
String names = getNode(treeNode, "");
CodeBean selCodeBean = getcode.getCodebean(names);
if (selCodeBean != null) {
String uid = selCodeBean.getUid();
List<List<String>> beans = getRecords(uid);
if (beans != null) {
for (int i = 0; i < beans.size(); i++) {
List<String> list = beans.get(i);
if (okToModify) {
model.addRow(new Object[model.getColumnCount()]);
model.setValueAt(model.getRowCount(), model.getRowCount() - 1, 0);
try {
for (GeneralBean bean : generalList) {
String value = form.getProperty(bean.getPropName());
model.setValueAt(value.trim(), model.getRowCount() - 1, bean.getColumNum());
}
} catch (Exception e1) {
e1.printStackTrace();
}
model.setValueAt(list.get(3), model.getRowCount() - 1, JCXindex);
model.setValueAt(list.get(4), model.getRowCount() - 1, TJindex);
} else {
MessageBox.post("当前用户无修改权限", "", MessageBox.ERROR);
}
}
} else {
MessageBox.post("excel数据配置错误,请联系管理员查看!!!", "提示", MessageBox.INFORMATION);
return;
}
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
});
JScrollPane scr1 = new JScrollPane(tree);
scr1.setPreferredSize(new Dimension(250, 250));
// 添加滚动面板到那内容面板
typepanel.add(scr1, BorderLayout.CENTER);
// jp2.setVisible(false);
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头
splitPane.setContinuousLayout(true);// 操作箭头,重绘图形
splitPane.setLeftComponent(typepanel);
splitPane.setRightComponent(contentPanel);
try {
int unableIndex = 0;
for (TableBean tableBean : tableList) {
TCProperty property = form.getTCProperty(tableBean.getPropName());
TCComponent[] tableRows = property.getReferenceValueArray();
for (TCComponent tableRow : tableRows) {
unableIndex++;
tableRowRefList.put(unableIndex - 1, (TCComponent) revision.getComponent());
}
}
} catch (TCException e2) {
e2.printStackTrace();
}
for (int j = 0; j < model.getColumnCount(); j++) {
if (j != 1) {
this.table.getColumnModel().getColumn(j)
.setCellRenderer(new MyCellRender(okToModify, null, enableList));
this.table.getColumnModel().getColumn(j).setCellEditor(new MyCellEditor(new JTextArea()));
}
}
this.table.getColumnModel().getColumn(5).setCellEditor(new DefaultCellEditor(ideaBox));
this.table.getColumnModel().getColumn(1).setCellRenderer(new MyButtonRender());
this.table.getColumnModel().getColumn(1)
.setCellEditor(new MyButtonEditor(table, picFlag, null, tableRowRefList));
plusButton.addActionListener(e -> {
if (okToModify) {
model.addRow(new Object[model.getColumnCount()]);
model.setValueAt(model.getRowCount(), model.getRowCount() - 1, 0);
try {
for (GeneralBean bean : generalList) {
String value = form.getProperty(bean.getPropName());
model.setValueAt(value, model.getRowCount() - 1, bean.getColumNum());
}
} catch (Exception e1) {
e1.printStackTrace();
}
} else {
MessageBox.post("当前用户无修改权限", "", MessageBox.ERROR);
}
// FitTableColumns(table);
});
okButton.addActionListener(e -> {
try {
if (okToModify) {
int rows = model.getRowCount();
StringBuilder mustSB = new StringBuilder();
// for (int i = 0; i < rows; i++) {
// String isMustValue = model.getValueAt(i,JCXindex)+"";
// if("".equals(isMustValue.trim())) {
// mustSB.append("序号"+(i+1));
// continue;
// }
// for (int j = 0; j < mustList.size(); j++) {
// isMustValue = (String) model.getValueAt(i,mustList.get(j));
// if("".equals(isMustValue.trim())) {
// mustSB.append("序号"+(i+1));
// break;
// }
// }
// }
for (int i = 0; i < rows; i++) {
Object val1 = this.table.getValueAt(i, this.JCXindex);
if (val1 == null) {
mustSB.append("序号" + (i + 1));
} else {
Object object = val1;
System.out.println("isMustValue1====" + object);
if (object == null || "".equals(object.toString().trim())
|| "null".equals(object.toString().trim())) {
mustSB.append("序号" + (i + 1));
} else {
for (int j = 0; j < this.mustList.size(); j++) {
val1 = this.table.getValueAt(i, ((Integer) this.mustList.get(j)).intValue());
if (val1 == null) {
mustSB.append("序号" + (i + 1));
break;
}
object = val1;
System.out.println("isMustValue2====" + object);
if (object == null || "".equals(object.toString().trim())
|| "null".equals(object.toString().trim())) {
mustSB.append("序号" + (i + 1));
break;
}
}
}
}
}
String err = mustSB.toString();
if (!("".equals(err.trim()))) {
MessageBox.post(ProcessreviewDialog.this, "请填写必填属性:: " + err + "[带*列值]!!!!", "",
MessageBox.ERROR);
return;
}
if (table.isEditing()) {
int row = table.getEditingColumn();// 那一行
int col = table.getEditingColumn(); // 那一列
TableCellEditor editor = table.getCellEditor(row, col);
editor.stopCellEditing();
}
// MessageBox.post(ProcessreviewDialog.this,"1111", "提示",
// MessageBox.INFORMATION);
for (TableBean tableBean : tableList) {
saveMethod(tableBean.getPropName(), tableBean.getPropList(), tableBean.getTableRow());
}
// MessageBox.post(ProcessreviewDialog.this,"2222", "提示",
// MessageBox.INFORMATION);
for (GeneralBean generalBean : generalList) {
for (int i = 0; i < model.getRowCount(); i++) {
if (!enableList.contains(generalBean.getColumNum())) {
String value = (String) model.getValueAt(i, generalBean.getColumNum());
form.lock();
form.setProperty(generalBean.getPropName(), value);
form.save();
form.unlock();
}
}
}
// MessageBox.post(ProcessreviewDialog.this,"3333", "提示",
// MessageBox.INFORMATION);
for (TCComponent dateSet : removeList) {
TCComponentItemRevision rev = (TCComponentItemRevision) revision.getComponent();
rev.remove("Ac5_Jctp", dateSet);
dateSet.delete();
}
removeList.clear();
MessageBox.post(ProcessreviewDialog.this, "保存成功", "", MessageBox.INFORMATION);
this.setVisible(false);
} else {
MessageBox.post(ProcessreviewDialog.this, "当前用户无修改权限", "", MessageBox.ERROR);
}
} catch (Exception e1) {
MessageBox.post(ProcessreviewDialog.this, "保存失败:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.setVisible(false);
});
removeButton.addActionListener(e -> {
if (okToModify) {
int rowCount = table.getRowCount();
System.out.println("列表总行数======" + rowCount);
for (int i = rowCount - 1; i >= 0; i--) {
System.out.println("开始删除第" + i + "行数据");
int rowNum = i;
String uid = (String) table.getValueAt(rowNum, 1);
try {
if (uid != null && !("".equals(uid.trim()))) {
TCComponentDataset dateSet = (TCComponentDataset) session.stringToComponent(uid);
if (dateSet != null)
removeList.add(dateSet);
}
} catch (Exception e1) {
e1.printStackTrace();
}
model.removeRow(rowNum);
if (tableCompList.size() >= rowNum) {
if (tableCompList.get(rowNum) != null) {
tableCompList.remove(rowNum);
}
}
}
} else {
MessageBox.post("当前用户无修改权限", "", MessageBox.ERROR);
}
});
// scrollPane.addComponentListener(new ComponentAdapter() {
// @Override
// public void componentResized(ComponentEvent e) {
// resizeTable(true);
// }
// });
JPanel center = new JPanel();
center.setLayout(new GridLayout(13, 1, 5, 5));
center.setAlignmentY(Component.TOP_ALIGNMENT);
center.setAlignmentX(Component.CENTER_ALIGNMENT);
center.add(Box.createVerticalGlue());
center.add(Box.createVerticalGlue());
center.add(Box.createVerticalGlue());
center.add(plusButton);
center.add(removeButton);
center.add(Box.createVerticalGlue());
JPanel bottom = new JPanel();
bottom.add(okButton);
bottom.add(Box.createHorizontalStrut(30));
bottom.add(celButton);
// FitTableColumns(table);
this.add(splitPane, BorderLayout.WEST);
this.add(center, BorderLayout.EAST);
this.add(bottom, BorderLayout.SOUTH);
this.pack();
this.centerToScreen();
this.setAlwaysOnTop(false);
this.showDialog();
}
// public void FitTableColumns(JTable myTable) {
// JTableHeader header = myTable.getTableHeader();
// int rowCount = myTable.getRowCount();
// Enumeration columns = myTable.getColumnModel().getColumns();
// while (columns.hasMoreElements()) {
// TableColumn column = (TableColumn) columns.nextElement();
// int col = header.getColumnModel().getColumnIndex(column.getIdentifier());
// int width = (int) myTable.getTableHeader().getDefaultRenderer()
// .getTableCellRendererComponent(myTable, column.getIdentifier(), false,
// false, -1, col)
// .getPreferredSize().getWidth();
// for (int row = 0; row < rowCount; row++) {
// int preferedWidth = (int) myTable.getCellRenderer(row, col)
// .getTableCellRendererComponent(myTable, myTable.getValueAt(row, col),
// false, false, row, col)
// .getPreferredSize().getWidth();
// width = Math.max(width, preferedWidth);
// }
// header.setResizingColumn(column); // 此行很重要
// column.setWidth(width + myTable.getIntercellSpacing().width);
// }
// }
public static TCComponentDataset createDataSet(String path) throws TCException {
TCComponentDataset dataset = null;
TCTypeService type = session.getTypeService();
TCComponentDatasetType datasettype;
datasettype = (TCComponentDatasetType) type.getTypeComponent("Dataset");
File file = new File(path);
String fileName = file.getName().substring(0, file.getName().lastIndexOf("."));
dataset = datasettype.create(fileName, "", "Image");
// create( dataset_name , dataset_desc , dataset_type)
// create(excel文件名描述类型
String p[] = new String[1];
String n[] = new String[1];
if (file.exists()) {
p[0] = file.getAbsolutePath();// excel物理路径
n[0] = "Image";// 命名的引用
System.out.println(p[0]);
((TCComponentDataset) dataset).setFiles(p, n);
} else {
System.out.println("路径下没有该文件");
}
return dataset;
}
private void setColumnSize() {
TableColumnModel colModel = table.getColumnModel();
JTableHeader header = table.getTableHeader();
for (TableBean tableBean : tableList) {
for (GeneralBean bean : tableBean.getPropList()) {
if (bean.getColumSize() > 0) {
header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
}
}
}
for (GeneralBean bean : generalList) {
if (bean.getColumSize() > 0) {
header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
}
}
}
// private void setAutoHigh(int row){
// int maxPreferredHeight = 0;
// for (int i = 0; i < table.getColumnCount(); i++) {
//// setText("" + table.getValueAt(row, i));
// if(i!=1){
// ((MyCellRender)table.getCellRenderer(row,
// i)).setSize(table.getColumnModel().getColumn(i).getWidth(), 0);
// maxPreferredHeight = Math.max(maxPreferredHeight,
// ((MyCellRender)table.getCellRenderer(row, i)).getPreferredSize().height);
// }
// }
//
// if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
// table.setRowHeight(row, maxPreferredHeight);
// }
private void initTable() {
try {
TableColumnModel colModel = table.getColumnModel();
JTableHeader header = table.getTableHeader();
for (TableBean tableBean : tableList) {
TCProperty property = form.getTCProperty(tableBean.getPropName());
TCComponent[] tableRows = property.getReferenceValueArray();
for (TCComponent tableRow : tableRows) {
model.addRow(new Object[2 + generalList.size() + realPropSize]);
tableCompList.add(tableRow);
model.setValueAt(model.getRowCount(), model.getRowCount() - 1, 0);
for (GeneralBean bean : tableBean.getPropList()) {
String value = tableRow.getProperty(bean.getPropName());
// if (bean.getColumSize() > 0) {
// header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
// colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
// }
model.setValueAt(value, model.getRowCount() - 1, bean.getColumNum());
}
}
}
for (GeneralBean bean : generalList) {
String value = form.getProperty(bean.getPropName());
// if (bean.getColumSize() > 0) {
// header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
// colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
// }
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(value, i, bean.getColumNum());
}
}
setColumnSize();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void saveMethod(String tablePropName, List<GeneralBean> beanList, String tableRow) {
try {
List<TCComponent> c = new ArrayList<TCComponent>();
TCComponent[] com = form.getTCProperty(tablePropName).getReferenceValueArray();
for (int j = 0; j < com.length; j++) {
if (tableCompList.indexOf(com[j]) != -1)
c.add(com[j]);
}
System.out.println("c的长度" + c.size());
DataManagementService service = DataManagementService
.getService((TCSession) AIFUtility.getCurrentApplication().getSession());
// CreateIn[] newIn = new
// CreateIn[model.getRowCount()-tableCompList.size()];
List<CreateIn> newInList = new ArrayList<>();
for (int i = 0; i < model.getRowCount(); i++) {
CreateIn in = new CreateIn();
Map<String, String> propMap = new HashMap<String, String>();
for (int j = 0; j < beanList.size(); j++) {
if (beanList.get(j).getColumNum() == 1) {
String path = (String) model.getValueAt(i, beanList.get(j).getColumNum());
if (path != null && !path.equals("")) {
TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(path);
if (comp == null) {
TCComponentDataset dateSet = createDataSet(path);
TCComponentItemRevision rev = (TCComponentItemRevision) revision.getComponent();
System.out.println(rev);
String uid = "";
if (dateSet != null) {
rev.add("Ac5_Jctp", dateSet);
uid = dateSet.getUid();
}
model.setValueAt(uid, i, 1);
propMap.put(beanList.get(j).getPropName(), uid);
} else {
String uid = comp.getUid();
propMap.put(beanList.get(j).getPropName(), uid);
}
} else {
propMap.put(beanList.get(j).getPropName(), "");
}
} else {
String propValue = (String) model.getValueAt(i, beanList.get(j).getColumNum());
propMap.put(beanList.get(j).getPropName(), propValue);
}
}
// System.out.println("prop:" + propMap);
if (tableCompList.size() > i && tableCompList.get(i) != null) {
tableCompList.get(i).lock();
tableCompList.get(i).setProperties(propMap);
tableCompList.get(i).save();
tableCompList.get(i).unlock();
} else {
in.data.boName = tableRow;
in.data.stringProps = propMap;
// newIn[i] = in;
newInList.add(in);
}
}
try {
CreateIn[] newIn = newInList.toArray(new CreateIn[newInList.size()]);
CreateResponse response = service.createObjects(newIn);
System.out.println(response.serviceData.sizeOfCreatedObjects());
if (response.serviceData.sizeOfCreatedObjects() > 0) {
System.out.println("创建CreateResponse");
int length = response.serviceData.sizeOfCreatedObjects();
for (int i = 0; i < length; i++) {
c.add(response.output[i].objects[0]);
tableCompList.add(response.output[i].objects[0]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
form.lock();
form.getTCProperty(tablePropName).setReferenceValueArray(c.toArray(new TCComponent[c.size()]));
form.save();
form.unlock();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void resizeTable(boolean bool) {
Dimension containerwidth = null;
if (!bool) {
// 初始化时父容器大小为首选大小实际大小为0
containerwidth = scrollPane.getPreferredSize();
} else {
// 界面显示后,如果父容器大小改变,使用实际大小而不是首选大小
containerwidth = scrollPane.getSize();
}
// 计算表格总体宽度 getTable().
int allwidth = table.getIntercellSpacing().width;
for (int j = 0; j < table.getColumnCount(); j++) {
// 计算该列中最长的宽度
int max = 0;
for (int i = 0; i < table.getRowCount(); i++) {
int width = table.getCellRenderer(i, j)
.getTableCellRendererComponent(table, table.getValueAt(i, j), false, false, i, j)
.getPreferredSize().width;
if (width > max) {
max = width;
}
}
// 计算表头的宽度
int headerwidth = table
.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table,
table.getColumnModel().getColumn(j).getIdentifier(), false, false, -1, j)
.getPreferredSize().width;
// 列宽至少应为列头宽度
max += headerwidth;
// 设置列宽
table.getColumnModel().getColumn(j).setPreferredWidth(max);
// 给表格的整体宽度赋值记得要加上单元格之间的线条宽度1个像素
allwidth += max + table.getIntercellSpacing().width;
}
allwidth += table.getIntercellSpacing().width;
// 如果表格实际宽度大小父容器的宽度,则需要我们手动适应;否则让表格自适应
if (allwidth > containerwidth.width) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
} else {
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}
}
private JTree getTree(MenuBean menuBean1) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), rootNode);
}
}
JTree tree = new JTree(rootNode);
tree.setShowsRootHandles(true);
// tree.setEditable(true);
return tree;
}
/**
*
*
* @param menuBean1
* @param rootNode
*/
private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename);
rootNode.add(node);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), node);
}
}
}
/**
* TreeNode-
*
* @param treeNode
* @param names
* @return
*/
private String getNode(TreeNode treeNode, String names) {
// TODO Auto-generated method stub
if (!names.equals("")) {
names = "&" + names;
}
names = treeNode.toString() + names;
TreeNode parent = treeNode.getParent();
if (parent != null) {
return getNode(parent, names);
}
return names;
}
/**
* excel
*
* @return tabledataVector
*/
private List<List<String>> getRecords(String uid) {
List<List<String>> allList = new ArrayList<List<String>>();
try {
TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(uid);
File file = ((TCComponentDataset) excel).getTcFiles()[0].getFmsFile();
// File file = new File("C:\\Users\\wangc\\Desktop\\新建文件夹\\测试.xlsx");
try {
FileInputStream is = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(is);
XSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getLastRowNum();
XSSFRow topRow = sheet.getRow(0);
int cells = topRow.getLastCellNum();
for (int i = 1; i < rows; i++) { // 循环打印Excel表中的内容
XSSFRow row = sheet.getRow(i);
List<String> list = new ArrayList<>();
for (int j = 0; j < cells; j++) {
XSSFCell cell = row.getCell(j);
if (cell != null) {
cell.setCellType(Cell.CELL_TYPE_STRING);
String value = cell.getStringCellValue();
if (value != null && !("".equals(value.trim()))) {
list.add(value.trim());
}
}
}
if (list.size() > 0) {
allList.add(list);
}
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return allList;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,552 @@
package com.connor.mbd.dialogs;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.GyscbdBean;
import com.connor.mdb.beans.TableBean;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
public class ReviewstatisticalDialog extends AbstractAIFDialog {
private static TCSession session;
private static Map<String, String> prefMap;
private InterfaceAIFComponent[] targets;
private static int item_id;
private static int item_name;
private static TCUserService userService;
private JScrollPane scrollPane;
Map<Integer, String> propMap = null;
List<Integer> enableList = null;
List<TCComponent> revList = null;
JButton okButton;
JButton celButton;
JButton chooseButton;
JTable table;
DefaultTableModel model = null;
List<GeneralBean> generalList = new ArrayList<>();
List<TableBean> tableList = new ArrayList<>();
List<TCComponent> tableCompList = new ArrayList<>();
List<TCComponent> removeList = new ArrayList<>();
List<Integer> unableList = new ArrayList<>();
HashMap<Integer, TCComponent> tableRowRefList = new HashMap<>();
List<GyscbdBean> gyscbdList = new ArrayList<>();
private int realPropSize;
public ReviewstatisticalDialog(TCSession session, List<GeneralBean> generalList, List<TableBean> tableList,
int realPropSize, InterfaceAIFComponent[] targets, List<GyscbdBean> gyscbdList) {
this.session = session;
this.prefMap = prefMap;
this.targets = targets;
this.generalList = generalList;
this.gyscbdList = gyscbdList;
this.tableList = tableList;
this.realPropSize = realPropSize;
revList = new ArrayList<>();
init();
}
private void init() {
this.setTitle("协同审查查看");
this.setLayout(new BorderLayout());
okButton = new JButton("确定");
celButton = new JButton("取消");
chooseButton = new JButton("浏览/选择");
// Object[] objs = new Object[]{"序号","审查图片","审查意见","设计意见","是否接受"};
int size = generalList.size() + realPropSize + gyscbdList.size() - 1;
Object[] objs = new Object[2 + size];
userService = (TCUserService) session.getUserService();
objs[0] = "序号";
objs[1] = "审查图片";
enableList = new ArrayList<Integer>();
propMap = new HashMap<>();
int index = 2;
for (GeneralBean bean : generalList) {
objs[index] = bean.getDisplayName();
bean.setColumNum(index);
if (!bean.isEditable()) {
enableList.add(index);
}
index++;
}
for (GyscbdBean bean : gyscbdList) {
objs[index] = bean.getDisplayName();
bean.setColumNum(index);
if (!bean.isEditable()) {
enableList.add(index);
}
index++;
}
boolean picFlag = true;
for (TableBean tableBean : tableList) {
List<GeneralBean> realPropList = tableBean.getPropList();
for (GeneralBean bean : realPropList) {
if (bean.getDisplayName().equals("审查图片")) {
bean.setColumNum(1);
if (!bean.isEditable()) {
picFlag = false;
}
continue;
}
objs[index] = bean.getDisplayName();
bean.setColumNum(index);
if (!bean.isEditable()) {
enableList.add(index);
}
index++;
}
}
try {
int unableIndex = 0;
for (InterfaceAIFComponent target : targets) {
TCComponentItemRevision rev = (TCComponentItemRevision) target;
TCComponent[] forms = rev.getReferenceListProperty("Ac5_GYSCBD");
for (TCComponent form : forms) {
for (TableBean tableBean : tableList) {
TCProperty property = form.getTCProperty(tableBean.getPropName());
TCComponent[] tableRows = property.getReferenceValueArray();
for (TCComponent tableRow : tableRows) {
unableIndex++;
if (!((TCComponent) target).getReferenceProperty("owning_user").equals(session.getUser())) {
unableList.add(unableIndex - 1);
}
tableRowRefList.put(unableIndex - 1, rev);
}
}
}
}
} catch (TCException e3) {
e3.printStackTrace();
}
System.out.println("unablelIist : " + unableList);
model = new DefaultTableModel(objs, 0) {
@Override
public boolean isCellEditable(int row, int column) {
if (column == 0) {
return false;
}
for (int i = 0; i < enableList.size(); i++) {
if (enableList.get(i).equals(column)) {
return false;
}
}
if (unableList.contains(Integer.valueOf(row)) && column != 1) {
return false;
}
return true;
}
};
table = new JTable(model);
table.setAutoResizeMode(table.AUTO_RESIZE_OFF);
// table.addPropertyChangeListener(e -> {
// FitTableColumns(table);
// });
// table.setSize(new Dimension(500, 300));
scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(800, 500));
for (int j = 0; j < model.getColumnCount(); j++) {
if (j != 1) {
this.table.getColumnModel().getColumn(j)
.setCellRenderer(new MyCellRender(true, unableList, enableList));
this.table.getColumnModel().getColumn(j).setCellEditor(new MyCellEditor(new JTextArea()));
}
}
this.table.getColumnModel().getColumn(1).setCellRenderer(new MyButtonRender());
this.table.getColumnModel().getColumn(1)
.setCellEditor(new MyButtonEditor(table, picFlag, unableList, tableRowRefList));
try {
initTable();
} catch (Exception e2) {
MessageBox.post(ReviewstatisticalDialog.this,"初始化失败", "", MessageBox.ERROR);
e2.printStackTrace();
return;
}
okButton.addActionListener(e -> {
try {
if (table.isEditing()) {
int row = table.getEditingColumn();// 那一行
int col = table.getEditingColumn(); // 那一列
TableCellEditor editor = table.getCellEditor(row, col);
editor.stopCellEditing();
}
userService.call("Open_by_pass", new Object[] { true });
for (InterfaceAIFComponent target : targets) {
TCComponentItemRevision rev = (TCComponentItemRevision) target;
TCComponent[] forms = rev.getReferenceListProperty("Ac5_GYSCBD");// Ac5_GYSCBD
int row_loc = model.getRowCount();
for (TCComponent form : forms) {
for (TableBean tableBean : tableList) {
saveMethod(tableBean.getPropName(), tableBean.getPropList(), tableBean.getTableRow(), form,
row_loc, rev);
}
for (GeneralBean generalBean : generalList) {
for (int i = 0; i < row_loc; i++) {
if (!unableList.contains(i) && !enableList.contains(generalBean.getColumNum())) {
String value = (String) model.getValueAt(i, generalBean.getColumNum());
if (!generalBean.getPropName().equals("item_id")
&& !generalBean.getPropName().equals("object_name")) {
rev.lock();
rev.setProperty(generalBean.getPropName(), value);
rev.save();
rev.unlock();
}
}
}
}
for (GyscbdBean gyscbdBean : gyscbdList) {
for (int i = 0; i < row_loc; i++) {
if (!unableList.contains(i) && !enableList.contains(gyscbdBean.getColumNum())) {
String value = (String) model.getValueAt(i, gyscbdBean.getColumNum());
form.lock();
form.setProperty(gyscbdBean.getPropName(), value);
form.save();
form.unlock();
}
}
}
}
}
userService.call("Open_by_pass", new Object[] { false });
MessageBox.post(ReviewstatisticalDialog.this,"保存成功", "", MessageBox.INFORMATION);
} catch (Exception e1) {
MessageBox.post(ReviewstatisticalDialog.this,"保存失败:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.setVisible(false);
});
JPanel bottom = new JPanel();
bottom.add(okButton);
bottom.add(Box.createHorizontalStrut(30));
bottom.add(celButton);
// FitTableColumns(table);
this.add(scrollPane, BorderLayout.CENTER);
this.add(bottom, BorderLayout.SOUTH);
this.pack();
this.centerToScreen();
this.setAlwaysOnTop(true);
this.showDialog();
}
private void saveMethod(String tablePropName, List<GeneralBean> beanList, String tableRow, TCComponent form,
int row_loc, TCComponent rev) {
try {
List<TCComponent> c = new ArrayList<TCComponent>();
TCComponent[] com = form.getTCProperty(tablePropName).getReferenceValueArray();
for (int j = 0; j < com.length; j++) {
if (tableCompList.indexOf(com[j]) != -1)
c.add(com[j]);
}
System.out.println("c的长度" + c.size());
DataManagementService service = DataManagementService
.getService((TCSession) AIFUtility.getCurrentApplication().getSession());
// CreateIn[] newIn = new
// CreateIn[model.getRowCount()-tableCompList.size()];
List<CreateIn> newInList = new ArrayList<>();
for (int i = 0; i < row_loc; i++) {
if (!unableList.contains(i)) {
CreateIn in = new CreateIn();
Map<String, String> propMap = new HashMap<String, String>();
for (int j = 0; j < beanList.size(); j++) {
if (beanList.get(j).getColumNum() == 1) {
String path = (String) model.getValueAt(i, beanList.get(j).getColumNum());
if (path != null && !path.equals("")) {
TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(path);
if (comp == null) {
TCComponentDataset dateSet = createDataSet(path);
String uid = "";
if (dateSet != null) {
rev.add("Ac5_Jctp", dateSet);
uid = dateSet.getUid();
}
model.setValueAt(uid, i, 1);
propMap.put(beanList.get(j).getPropName(), uid);
} else {
String uid = comp.getUid();
propMap.put(beanList.get(j).getPropName(), uid);
}
} else {
propMap.put(beanList.get(j).getPropName(), "");
}
} else {
String propValue = (String) model.getValueAt(i, beanList.get(j).getColumNum());
propMap.put(beanList.get(j).getPropName(), propValue);
}
}
// System.out.println("prop:" + propMap);
if (tableCompList.size() > i && tableCompList.get(i) != null) {
tableCompList.get(i).lock();
tableCompList.get(i).setProperties(propMap);
tableCompList.get(i).save();
tableCompList.get(i).unlock();
} else {
in.data.boName = tableRow;
in.data.stringProps = propMap;
// newIn[i] = in;
newInList.add(in);
}
}
}
try {
CreateIn[] newIn = newInList.toArray(new CreateIn[newInList.size()]);
CreateResponse response = service.createObjects(newIn);
System.out.println(response.serviceData.sizeOfCreatedObjects());
if (response.serviceData.sizeOfCreatedObjects() > 0) {
System.out.println("创建CreateResponse");
int length = response.serviceData.sizeOfCreatedObjects();
for (int i = 0; i < length; i++) {
c.add(response.output[i].objects[0]);
tableCompList.add(response.output[i].objects[0]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
form.lock();
form.getTCProperty(tablePropName).setReferenceValueArray(c.toArray(new TCComponent[c.size()]));
form.save();
form.unlock();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void initTable() throws Exception {
TableColumnModel colModel = table.getColumnModel();
JTableHeader header = table.getTableHeader();
for (InterfaceAIFComponent target : targets) {
int row_loc = model.getRowCount();
TCComponentItemRevision rev = (TCComponentItemRevision) target;
TCComponent[] forms = rev.getReferenceListProperty("Ac5_GYSCBD");
String item_id = rev.getProperty("item_id");
String object_name = rev.getProperty("object_name");
for (TCComponent form : forms) {
for (TableBean tableBean : tableList) {
TCProperty property = form.getTCProperty(tableBean.getPropName());
TCComponent[] tableRows = property.getReferenceValueArray();
for (TCComponent tableRow : tableRows) {
model.addRow(new Object[2 + generalList.size() + realPropSize + gyscbdList.size()]);
tableCompList.add(tableRow);
model.setValueAt(model.getRowCount(), model.getRowCount() - 1, 0);
for (GeneralBean bean : tableBean.getPropList()) {
String value = tableRow.getProperty(bean.getPropName());
// if (bean.getColumSize() > 0) {
// header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
// colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
// }
model.setValueAt(value, model.getRowCount() - 1, bean.getColumNum());
}
for (GyscbdBean bean : gyscbdList) {
String value = form.getProperty(bean.getPropName());
model.setValueAt(value, model.getRowCount() - 1, bean.getColumNum());
}
}
}
}
for (GeneralBean bean : generalList) {
if (model.getRowCount() == 0) {
model.addRow(new Object[2 + generalList.size() + realPropSize + gyscbdList.size()]);
}
String value = rev.getProperty(bean.getPropName());
// if (bean.getColumSize() > 0) {
// header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
// colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
// }
if (bean.getDisplayName().equals("零件图号") || bean.getDisplayName().equals("零件名称")) {
model.setValueAt(value, row_loc, bean.getColumNum());
} else {
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(value, i, bean.getColumNum());
}
}
}
}
setColumnSize();
}
private void setColumnSize() {
TableColumnModel colModel = table.getColumnModel();
JTableHeader header = table.getTableHeader();
for (TableBean tableBean : tableList) {
for (GeneralBean bean : tableBean.getPropList()) {
if (bean.getColumSize() > 0) {
header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
}
}
}
for (GeneralBean bean : generalList) {
if (bean.getColumSize() > 0) {
header.setResizingColumn(colModel.getColumn(bean.getColumNum()));
colModel.getColumn(bean.getColumNum()).setWidth(bean.getColumSize());
}
}
}
public void FitTableColumns(JTable myTable) {
JTableHeader header = myTable.getTableHeader();
int rowCount = myTable.getRowCount();
Enumeration columns = myTable.getColumnModel().getColumns();
while (columns.hasMoreElements()) {
TableColumn column = (TableColumn) columns.nextElement();
int col = header.getColumnModel().getColumnIndex(column.getIdentifier());
int width = (int) myTable.getTableHeader().getDefaultRenderer()
.getTableCellRendererComponent(myTable, column.getIdentifier(), false, false, -1, col)
.getPreferredSize().getWidth();
for (int row = 0; row < rowCount; row++) {
int preferedWidth = (int) myTable.getCellRenderer(row, col)
.getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col)
.getPreferredSize().getWidth();
width = Math.max(width, preferedWidth);
}
header.setResizingColumn(column); // 此行很重要
column.setWidth(width + myTable.getIntercellSpacing().width);
}
}
private boolean isDataIntable(String num, String name) {
for (int i = 0; i < model.getRowCount() - 1; i++) {
String table_number = (String) model.getValueAt(i, item_id);
String table_name = (String) model.getValueAt(i, item_name);
if (num.equals(table_number) || name.equals(table_name)) {
return true;
}
}
return false;
}
public static TCComponentDataset createDataSet(String path) throws TCException {
TCComponentDataset dataset = null;
TCTypeService type = session.getTypeService();
TCComponentDatasetType datasettype;
datasettype = (TCComponentDatasetType) type.getTypeComponent("Dataset");
File file = new File(path);
String fileName = file.getName().substring(0, file.getName().lastIndexOf("."));
dataset = datasettype.create(fileName, "", "Image");
// create( dataset_name , dataset_desc , dataset_type)
// create(excel文件名描述类型
String p[] = new String[1];
String n[] = new String[1];
if (file.exists()) {
p[0] = file.getAbsolutePath();// excel物理路径
n[0] = "Image";// 命名的引用
System.out.println(p[0]);
((TCComponentDataset) dataset).setFiles(p, n);
} else {
System.out.println("路径下没有该文件");
}
return dataset;
}
public void resizeTable(boolean bool) {
Dimension containerwidth = null;
if (!bool) {
// 初始化时父容器大小为首选大小实际大小为0
containerwidth = scrollPane.getPreferredSize();
} else {
// 界面显示后,如果父容器大小改变,使用实际大小而不是首选大小
containerwidth = scrollPane.getSize();
}
// 计算表格总体宽度 getTable().
int allwidth = table.getIntercellSpacing().width;
for (int j = 0; j < table.getColumnCount(); j++) {
// 计算该列中最长的宽度
int max = 0;
for (int i = 0; i < table.getRowCount(); i++) {
int width = table.getCellRenderer(i, j)
.getTableCellRendererComponent(table, table.getValueAt(i, j), false, false, i, j)
.getPreferredSize().width;
if (width > max) {
max = width;
}
}
// 计算表头的宽度
int headerwidth = table.getTableHeader()
.getDefaultRenderer().getTableCellRendererComponent(table,
table.getColumnModel().getColumn(j).getIdentifier(), false, false, -1, j)
.getPreferredSize().width;
// 列宽至少应为列头宽度
max += headerwidth;
// 设置列宽
table.getColumnModel().getColumn(j).setPreferredWidth(max);
// 给表格的整体宽度赋值记得要加上单元格之间的线条宽度1个像素
allwidth += max + table.getIntercellSpacing().width;
}
allwidth += table.getIntercellSpacing().width;
// 如果表格实际宽度大小父容器的宽度,则需要我们手动适应;否则让表格自适应
if (allwidth > containerwidth.width) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
} else {
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}
}
}

@ -0,0 +1,174 @@
package com.connor.mbd.dialogs;
import java.awt.BorderLayout;
import java.awt.Image;
import java.io.File;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileSystemView;
import com.connor.mdb.beans.PictureBeans;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class SelectpictureDialog extends JFrame {
private PictureBeans bean;
private JTextField pathField;
private JButton browseButton;
private JButton okButton;
private JButton celButton;
private JButton removeButton;
private JLabel picLabel;
private JFileChooser jfc;
private boolean okToModify;
private JTable table;
private TCComponentDataset comp = null;
private HashMap<Integer, TCComponent> tableRowRefList;
public SelectpictureDialog(PictureBeans bean, JTable table, boolean okToModify,HashMap<Integer, TCComponent> tableRowRefList) {
this.bean = bean;
this.table = table;
this.okToModify = okToModify;
this.tableRowRefList = tableRowRefList;
init();
}
private void init() {
this.setTitle("选择审查图片");
this.setLayout(new BorderLayout());
this.setSize(650, 600);
jfc = new JFileChooser();
FileSystemView fsv = FileSystemView.getFileSystemView();
String deskTop = fsv.getHomeDirectory().getPath();
jfc.setCurrentDirectory(new File(deskTop));
JPanel top = new JPanel();
top.setSize(300, 500);
pathField = new JTextField(20);
browseButton = new JButton("浏览...");
top.add(pathField);
top.add(browseButton);
JPanel center = new JPanel();
center.setLayout(new BorderLayout());
center.setBorder(BorderFactory.createTitledBorder("图片预览区"));
picLabel = new JLabel();
picLabel.setBounds(40, 50, 600, 500);
center.add(picLabel, BorderLayout.CENTER);
JPanel bottom = new JPanel();
okButton = new JButton("确定");
celButton = new JButton("取消");
removeButton = new JButton("清除");
bottom.add(okButton);
bottom.add(Box.createHorizontalStrut(30));
bottom.add(celButton);
bottom.add(Box.createHorizontalStrut(30));
bottom.add(removeButton);
this.add(top, BorderLayout.NORTH);
this.add(center, BorderLayout.CENTER);
this.add(bottom, BorderLayout.SOUTH);
System.out.println("current pic Value: " + (String) table.getValueAt(table.getSelectedRow(), 1));
if (table.getValueAt(table.getSelectedRow(), 1) != null
&& !table.getValueAt(table.getSelectedRow(), 1).equals("")) {
String text = (String) table.getValueAt(table.getSelectedRow(), 1);
TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession();
String temp = System.getenv("temp");
try {
comp = (TCComponentDataset) session.stringToComponent(text);
if (comp != null) {
String[] types = comp.getProperty("ref_names").split(",");
File optionFile = comp.getFiles(types[0], temp)[0];
optionFile.deleteOnExit();
text = optionFile.getAbsolutePath();
}
} catch (TCException e1) {
e1.printStackTrace();
}
this.pathField.setText(text);
ImageIcon image = new ImageIcon(this.pathField.getText());
image.setImage(image.getImage().getScaledInstance(600, 500, Image.SCALE_DEFAULT));
picLabel.setIcon(image);
picLabel.setHorizontalAlignment(SwingConstants.CENTER);
}
if(!okToModify){
browseButton.setEnabled(false);
removeButton.setEnabled(false);
}
browseButton.addActionListener(e -> {
getFilePath(pathField);
ImageIcon image = new ImageIcon(this.pathField.getText());
image.setImage(image.getImage().getScaledInstance(600, 500, Image.SCALE_DEFAULT));
picLabel.setIcon(image);
picLabel.setHorizontalAlignment(SwingConstants.CENTER);
});
okButton.addActionListener(e -> {
File file = new File(this.pathField.getText());
bean.setF(file);
int row = table.getSelectedRow();
if(!file.isDirectory()&&!this.pathField.getText().equals("")){
table.setValueAt(bean.getF().getAbsolutePath(), row, 1);
}else{
table.setValueAt("", row, 1);
}
this.setVisible(false);
});
celButton.addActionListener(e -> {
this.setVisible(false);
});
removeButton.addActionListener(e->{
picLabel.setIcon(null);
int row = table.getSelectedRow();
this.pathField.setText("");
table.setValueAt("", row, 1);
if(comp != null){
try {
tableRowRefList.get(row).remove("Ac5_Jctp", comp);
comp.delete();
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
this.setAlwaysOnTop(true);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
private void getFilePath(JTextField pathField) {
// jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int state = jfc.showOpenDialog(this);
if (state == 1) {
return;
} else {
File f = jfc.getSelectedFile();
pathField.setText(f.getAbsolutePath());
}
}
}

@ -0,0 +1,555 @@
package com.connor.mbd.dialogs;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableRowSorter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseListener;
import com.connor.mdb.beans.CodeBean;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.GetCodeBean;
import com.connor.mdb.beans.MenuBean;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.util.MessageBox;
public class Test {
private static int JCXindex = 0;
private static int FTindex = 3;
// private String[] columnNames = {"序号","检查项内容","是否勾选"};
private static String[] columnNames = null;
private static GetCodeBean getcode;
private static Object[][] beans;
private static DefaultTableModel model2;
private static JTable qryTable;
private static long doubleClickInterval = 300l;
public static void main(String[] args) {
JCXinit();
}
/**
*
*
* @throws TCException
*/
private static void JCXinit(){
// TODO Auto-generated method stub
JButton okBut2 = new JButton("确定");
JButton celBut2 = new JButton("取消");
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setTitle("检查项");
frame.setSize(1150, 750);
// this.setLayout(new PropertyLayout());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLayout((LayoutManager) new FlowLayout(FlowLayout.LEFT));
JPanel contentPanel = new JPanel();// 检查项内容界面
TitledBorder border = new TitledBorder("检查项类型");
border.setTitleJustification(TitledBorder.LEFT);
border.setTitlePosition(TitledBorder.TOP);
TitledBorder border2 = new TitledBorder("检查项内容");
border2.setTitleJustification(TitledBorder.LEFT);
border2.setTitlePosition(TitledBorder.TOP);
contentPanel.setBorder(border2);
JPanel typepanel = new JPanel(new BorderLayout());// 检查项内容界面
typepanel.setBorder(border);
JPanel jp2 = new JPanel();
typepanel.setPreferredSize(new Dimension(200, 620));
model2 = new DefaultTableModel() {
private static final long serialVersionUID = 6905817304437097181L;
public boolean isCellEditable(int row, int column) {
return true;
}
};
qryTable = new JTable(model2){
public String getToolTipText(MouseEvent e) {
int row=qryTable.rowAtPoint(e.getPoint());
int col=qryTable.columnAtPoint(e.getPoint());
String tiptextString=null;
if(row>-1 && col>-1){
Object value=qryTable.getValueAt(row, col);
if(null!=value && !"".equals(value))
tiptextString=value.toString();//悬浮显示单元格内容
}
return tiptextString;
}
};
// qryTable.addMouseListener(new MouseAdapter() {
// int tableRow = -1;
// public void mouseClicked(MouseEvent e){
// if(e.getButton() == MouseEvent.BUTTON3){
// // tableRow = qryTable.rowAtPoint(e.getPoint());
// tableRow = qryTable.getSelectedRow();
// qryTable.setRowSelectionInterval(tableRow, tableRow);
// int indexRow = qryTable.convertRowIndexToModel(tableRow);
// System.out.println("indexRow=============="+indexRow);
// if(tableRow >= 0){
// System.out.println("1111111111111111111");
// }
// }
// }
// });
TableRowSorter sorter = new TableRowSorter(model2);
qryTable.setRowSorter(sorter); //为JTable设置排序器
// model.setDataVector(cellData, columnNames);
qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());
JScrollPane scr2=new JScrollPane(qryTable);
scr2.setPreferredSize(new Dimension(900, 620));
// typepanel.add("1.1.center.top", scr2);
// jp2.setPreferredSize(new Dimension(350, 600));
getcode = new GetCodeBean();
MenuBean menuBean = getcode.getMenuBean("检查项类型");
JTree tree = getTree(menuBean);
tree.addMouseListener(new java.awt.event.MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if(path != null) {
TreeNode node = (TreeNode) path.getLastPathComponent();
int childCount = node.getChildCount();
System.out.println("当前被选中的节点: " + node + " 子节点数量:" + childCount);
if (childCount > 0) {
beans = null;
// refreshTable();
} else {
int clickCount = e.getClickCount();
System.out.println("clickCount===="+clickCount);
if(clickCount == 2) {
doubleClick(node);
}
}
}
}
private void doubleClick(TreeNode treeNode) {
System.out.println("继续操作");
String names = getNode(treeNode, "");
CodeBean selCodeBean = getcode.getCodebean(names);
if (selCodeBean != null) {
String uid = selCodeBean.getUid();
beans = getRecords(uid);
if(beans!=null) {
refreshTable();
}else {
MessageBox.post("excel数据配置错误,请联系管理员查看!!!", "提示", MessageBox.INFORMATION);
return;
}
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
});
// tree.addTreeSelectionListener(new TreeSelectionListener() {
// public void valueChanged(TreeSelectionEvent e) {
// DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
// int childCount = treeNode.getChildCount();
// System.out.println("当前被选中的节点: " + treeNode + " 子节点数量:" + childCount);
// if (childCount > 0) {
// beans = null;
// // refreshTable();
// } else {
// long lastTime = 0l;
// long clickTime = System.currentTimeMillis();
// System.out.println("双击间隔时间为:"+(clickTime-lastTime));
// if(clickTime-lastTime < doubleClickInterval){
// doubleClick(treeNode);
// lastTime = clickTime;
// }
// // MessageBox.post("请选择最底层节点!!!", "提示", MessageBox.INFORMATION);
// // return;
//
// }
// }
// private void doubleClick(DefaultMutableTreeNode treeNode) {
// System.out.println("继续操作");
// String names = getNode(treeNode, "");
// CodeBean selCodeBean = getcode.getCodebean(names);
// if (selCodeBean != null) {
// String uid = selCodeBean.getUid();
// beans = getRecords(uid);
// if(beans!=null) {
// refreshTable();
// }else {
// MessageBox.post("excel数据配置错误,请联系管理员查看!!!", "提示", MessageBox.INFORMATION);
// return;
// }
// }
// }
// });
JScrollPane scrollPane = new JScrollPane(tree);
scrollPane.setPreferredSize(new Dimension(250, 250));
;
// 添加滚动面板到那内容面板
typepanel.add(scrollPane, BorderLayout.CENTER);
//jp2.setVisible(false);
contentPanel.add("1.1.center.top", scr2);
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头
splitPane.setContinuousLayout(true);// 操作箭头,重绘图形
splitPane.setLeftComponent(typepanel);
splitPane.setRightComponent(contentPanel);
JPanel titlePanel = new JPanel();// 按钮界面
//
titlePanel.add("1.1.center.center", new JLabel(" "));
titlePanel.add("1.2.center.center", new JLabel(" "));
titlePanel.add("1.3.center.center", new JLabel(" "));
titlePanel.add("1.4.center.center", new JLabel(" "));
titlePanel.add("1.5.center.center", new JLabel(" "));
titlePanel.add("1.6.center.center", new JLabel(" "));
titlePanel.add("1.7.center.center", new JLabel(" "));
titlePanel.add("1.8.center.center", okBut2);
titlePanel.add("1.9.center.center", new JLabel(" "));
titlePanel.add("1.10.center.center", new JLabel(" "));
titlePanel.add("1.11.center.center", celBut2);
frame.add("North",splitPane);
frame.add("South",titlePanel);
// JPanel allPanel = new JPanel();
// allPanel.add(splitPane);
// allPanel.add(titlePanel);
// frame.add(allPanel);
// frame.getContentPane().add(allPanel);
// add("1.1.center.center", splitPane);
// add("1.1.center.center", jp1);
// add("1.2.center.center", classJpanel);
// add("2.1.center.center", button2);
// add("2.2.center.center", okBut);
// add("2.3.center.center", celBut);
okBut2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
// setVisible(false);
int row = qryTable.getRowCount();
System.out.println("row===="+row);
for (int i = 0; i < row; i++) {
Object data = (Object)qryTable.getValueAt(i, columnNames.length-1);
System.out.println(data);
if((boolean) data) {
Object JCX = (Object)qryTable.getValueAt(i, FTindex);
System.out.println("jcx===="+JCX);
// if (okToModify) {
// model.addRow(new Object[model.getColumnCount()]);
// model.setValueAt(model.getRowCount(), model.getRowCount() - 1, 0);
// try {
// for (GeneralBean bean : generalList) {
// String value = form.getProperty(bean.getPropName());
// model.setValueAt(value, model.getRowCount() - 1, bean.getColumNum());
// }
// } catch (Exception e1) {
// e1.printStackTrace();
// }
// model.setValueAt(JCX, model.getRowCount() - 1, JCXindex);
// } else {
// MessageBox.post("当前用户无修改权限", "", MessageBox.ERROR);
// }
}
}
}
});
celBut2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("取消");
int rowCount = qryTable.getRowCount();
System.out.println("列表总行数======"+rowCount);
for (int i = 0; i < rowCount; i++) {
System.out.println("开始删除第"+i+"行数据");
int rowNum = i ;
model2.removeRow(rowNum);
}
// frame.setVisible(false);
}
});
frame.setLocationRelativeTo(null);
frame.setVisible(true);
// frame.pack();
frame.setResizable(false);
}
private static JTree getTree(MenuBean menuBean1) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), rootNode);
}
}
JTree tree = new JTree(rootNode);
tree.setShowsRootHandles(true);
// tree.setEditable(true);
return tree;
}
/**
*
*
* @param menuBean1
* @param rootNode
*/
private static void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename);
rootNode.add(node);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), node);
}
}
}
/**
* TreeNode-
*
* @param treeNode
*
* @param names
*
* @return
*/
private static String getNode(TreeNode treeNode, String names) {
// TODO Auto-generated method stub
if (!names.equals("")) {
names = "&" + names;
}
names = treeNode.toString() + names;
TreeNode parent = treeNode.getParent();
if (parent != null) {
return getNode(parent, names);
}
return names;
}
/**
* excel
* @return tabledataVector
*/
private static Object[][] getRecords(String uid){
List<List<String>> allList = new ArrayList<List<String>>();
List<String> btList = new ArrayList<String>();
Object res[][] = null;
try {
// TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(uid);
// File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile();
File file = new File("C:\\Users\\wangc\\Desktop\\新建文件夹\\测试.xlsx");
try {
FileInputStream is = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(is);
XSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getLastRowNum();
XSSFRow topRow = sheet.getRow(0);
int cells = topRow.getLastCellNum();
for (int i = 0; i < cells; i++) {
XSSFCell cell = topRow.getCell(i);
if(cell!=null){
cell.setCellType(Cell.CELL_TYPE_STRING);
String value = cell.getStringCellValue();
if(value != null && !("".equals(value.trim()))) {
btList.add(value);
}
}
}
columnNames = new String[btList.size()+1];
for (int i = 0; i < btList.size(); i++) {
String bt = btList.get(i);
columnNames[i] = bt;
}
columnNames[columnNames.length-1] = "是否勾选";
for (int i = 1; i < rows; i++) { // 循环打印Excel表中的内容
XSSFRow row = sheet.getRow(i);
List<String> list=new ArrayList<>();
for (int j = 0; j < cells; j++) {
XSSFCell cell = row.getCell(j);
if(cell!=null){
cell.setCellType(Cell.CELL_TYPE_STRING);
String value = cell.getStringCellValue();
if(value != null && !("".equals(value.trim()))) {
list.add(value);
}
}
}
if(list.size() > 0) {
allList.add(list);
}
}
} catch (Exception e) {
e.printStackTrace();
}
res = new Object[allList.size()][columnNames.length];
if(allList.size() > 0) {
//封装结果集
for (int i = 0; i < allList.size() ; i++) {
List<String> list = allList.get(i);
for (int j = 0; j < list.size(); j++) {
res[i][j] = list.get(j);
}
res[i][columnNames.length-1] = new Boolean(true);
}
}else {
return null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res;
}
/**
* table
*/
private static void refreshTable() {
qryTable.removeAll();
model2.setDataVector(beans, columnNames);
// qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// 设置table内容居中
tcr.setHorizontalAlignment(SwingConstants.CENTER);// 这句和上句作用一样
qryTable.setDefaultRenderer(Object.class, tcr);
qryTable.getColumnModel().getColumn(1).setPreferredWidth(20);
for (int i = 1; i < columnNames.length-1; i++) {
qryTable.getColumnModel().getColumn(i).setPreferredWidth(120);
qryTable.getColumnModel().getColumn(i).setCellRenderer(new TableCellTextAreaRenderer());
}
qryTable.getColumnModel().getColumn(columnNames.length-1).setPreferredWidth(40);
// qryTable.getColumnModel().getColumn(0).setPreferredWidth(50);
// qryTable.getColumnModel().getColumn(1).setPreferredWidth(200);
// qryTable.getColumnModel().getColumn(2).setPreferredWidth(50);
javax.swing.table.TableColumn column = qryTable.getColumnModel().getColumn(columnNames.length-1);
column.setCellEditor(qryTable.getDefaultEditor(Boolean.class));
column.setCellRenderer(qryTable.getDefaultRenderer(Boolean.class));
// tcr.setHorizontalAlignment(JLabel.CENTER);
// qryTable.getColumnModel().getColumn(2).setCellRenderer(new TableCellRenderer(){
//
// /*(non-Javadoc)
// * 此方法用于向方法调用者返回某一单元格的渲染器(即显示数据的组建--或控件)
// * 可以为JCheckBox JComboBox JTextArea 等
// * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
// */
// @Override
// public Component getTableCellRendererComponent(JTable table,
// Object value, boolean isSelected, boolean hasFocus,
// int row, int column) {
// // 创建用于返回的渲染组件
// JCheckBox ck = new JCheckBox();
// // 使具有焦点的行对应的复选框选中
// ck.setSelected(isSelected);
// // 设置单选box.setSelected(hasFocus);
// // 使复选框在单元格内居中显示
// ck.setHorizontalAlignment((int) 0.5f);
// return ck;
// }});
}
private static class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer {
private static final long serialVersionUID = -7149062901533662226L;
public TableCellTextAreaRenderer() {
setLineWrap(true); //设置自动换行
setWrapStyleWord(true);
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if(isSelected){
//设置表格选中的那一行的颜色
setBackground(new Color(51,153,255));
setForeground(new Color(255,255,255));
}else{
setBackground(table.getBackground());
setForeground(table.getForeground());
}
// 计算当下行的最佳高度
int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
}
if (table.getRowHeight(row) != maxPreferredHeight)
table.setRowHeight(row, maxPreferredHeight);
setText(value == null ? "" : value.toString());
return this;
}
}
}

@ -0,0 +1,207 @@
package com.connor.mbd.handlers;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.mbd.dialogs.ProcessreviewDialog;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.TableBean;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.ITypeName;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentFormType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateGyscbdFormHandler extends AbstractHandler {
TCSession session;
AbstractAIFUIApplication application;
public static TCPreferenceService service;
private int realPropSize = 0;
TCComponentForm newForm;
TCComponentFormType formType;
SimpleDateFormat sdf;
String userName;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
boolean flag = false;
application = AIFUtility.getCurrentApplication();
session = (TCSession) application.getSession();
sdf = new SimpleDateFormat("yyyyMMdd");
TCComponent target = (TCComponent) application.getTargetComponent();
if(target == null){
MessageBox.post("请选择目标版本","",MessageBox.ERROR);
return null;
}
TCComponentUser user = session.getUser();
try {
if(!target.okToModify()){
MessageBox.post("当前对象无创建权限","",MessageBox.INFORMATION);
return null;
}
userName = user.getProperty("object_string");
TCComponent[] relatComps = target.getRelatedComponents("Ac5_GYSCBD");//Ac5_GYSCBD
for(TCComponent relatComp : relatComps){
if(relatComp.getProperty("object_name").startsWith(userName)){
flag = true;
newForm = (TCComponentForm) relatComp;
break;
}
}
} catch (TCException e1) {
e1.printStackTrace();
return null;
}
// if(flag){
// MessageBox.post("当前对象版本下已存在此用户创建的工艺审查表单,不可重复创建","",MessageBox.INFORMATION);
// return null;
// }
if(!flag){
Date currentDate = new Date();
try {
String formName = userName + "_" +sdf.format(currentDate) + "_协同审查单";
formType = (TCComponentFormType) session.getTypeComponent("Form");
newForm = formType.create(formName, "", "Ac5_GyscbdForm");//Ac5_GyscbdForm
} catch (TCException e) {
MessageBox.post("创建失败" + e.getMessage(),"",MessageBox.ERROR);
e.printStackTrace();
return null;
}
if(newForm == null){
System.out.println("-----创建失败-----");
return null;
}
try {
target.add("Ac5_GYSCBD", newForm);//EC_reference_item_rel
// MessageBox.post("创建完成","",MessageBox.INFORMATION);
} catch (TCException e) {
MessageBox.post("添加失败,请检查关系类型是否正确","",MessageBox.ERROR);
e.printStackTrace();
return null;
}
}
realPropSize = 0;
// if (newForm == null || !newForm.getType().equals("Ac5_GyscbdForm")) {
// MessageBox.post("请选择协同审查表单执行", "", MessageBox.ERROR);
// return null;
// }
TCComponentForm form = newForm;
String[] prefArray = getPrefStrArray("Connor_AVIC_GYSC_PropControl", session);
if (prefArray == null) {
MessageBox.post("请检查首选项配置...", "", MessageBox.ERROR);
return null;
}
// Map<String, String> prefMap = new HashMap<String, String>();
// Map<String, String> realPropMap = new HashMap<String,String>();
// Map<String, Map<String,String>> tablePropMap = new HashMap<>();
List<GeneralBean> generalList = new ArrayList<>();
List<TableBean> tableList = new ArrayList<>();
for (String prefOption : prefArray) {
String[] splitPropType = prefOption.split("=");
if (splitPropType.length == 2) {
if (splitPropType[0].equals("General")) {
String[] prefValues = splitPropType[1].split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if (edits.length > 2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
generalList.add(gBean);
} else if (splitPropType[0].contains("Table")) {
List<GeneralBean> chidList = new ArrayList<>();
TableBean tableBean = new TableBean();
int index = splitPropType[1].indexOf("(");
int index2 = splitPropType[1].indexOf(")");
int index3 = splitPropType[0].indexOf("(");
int index4 = splitPropType[0].indexOf(")");
String tableRow = splitPropType[0].substring(index3 + 1, index4);
String tableName = splitPropType[1].substring(0, index);
String tableString = splitPropType[1].substring(index + 1, index2);
String[] realProps = tableString.split(",");
for (String realProp : realProps) {
String[] prefValues = realProp.split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if (edits.length > 2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
chidList.add(gBean);
realPropSize++;
}
tableBean.setPropName(tableName);
tableBean.setPropList(chidList);
tableBean.setTableRow(tableRow);
tableList.add(tableBean);
// tablePropMap.put(tableName, realPropMap);
}
}
}
for (TableBean bean : tableList) {
System.out.println(bean);
}
// System.out.println(prefMap);
try {
new Thread() {
boolean isOkModify = form.okToModify();
public void run() {
AIFComponentContext[] revisions = null;// Ac5_GYSCBD
try {
revisions = form.whereReferencedByTypeRelation(null, new String[] { "Ac5_GYSCBD" });
} catch (TCException e) {
e.printStackTrace();
}
if (revisions != null) {
new ProcessreviewDialog(generalList, form, revisions[0], session, tableList, realPropSize,isOkModify);
} else {
MessageBox.post("未找到表单以Ac5_GYSCBD关联的版本", "", MessageBox.ERROR);
}
};
}.start();
} catch (TCException e) {
e.printStackTrace();
}
return null;
}
public static String[] getPrefStrArray(String prefName, TCSession session) {
if (service == null) {
service = session.getPreferenceService();
}
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
service.getStringValues(prefName);
service.getStringValue(prefName);
// if (strs == null) {
// strs = new String[] { "" };
// }
return strs;
}
}

@ -0,0 +1,97 @@
package com.connor.mbd.handlers;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.ITypeName;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentFormType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateGyscbdFormHandler2 extends AbstractHandler {
TCSession session;
AbstractAIFUIApplication application;
TCComponentForm newForm;
TCComponentFormType formType;
SimpleDateFormat sdf;
String userName;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
boolean flag = false;
application = AIFUtility.getCurrentApplication();
session = (TCSession) application.getSession();
sdf = new SimpleDateFormat("yyyyMMdd");
TCComponent target = (TCComponent) application.getTargetComponent();
if(target == null){
MessageBox.post("请选择目标版本","",MessageBox.ERROR);
return null;
}
TCComponentUser user = session.getUser();
try {
if(!target.okToModify()){
MessageBox.post("当前对象无创建权限","",MessageBox.INFORMATION);
return null;
}
userName = user.getProperty("object_string");
TCComponent[] relatComps = target.getRelatedComponents("Ac5_GYSCBD");//Ac5_GYSCBD
for(TCComponent relatComp : relatComps){
if(relatComp.getProperty("object_name").startsWith(userName)){
flag = true;
break;
}
}
} catch (TCException e1) {
e1.printStackTrace();
return null;
}
if(flag){
MessageBox.post("当前对象版本下已存在此用户创建的工艺审查表单,不可重复创建","",MessageBox.INFORMATION);
return null;
}
Date currentDate = new Date();
try {
String formName = userName + "_" +sdf.format(currentDate) + "_协同审查单";
formType = (TCComponentFormType) session.getTypeComponent("Form");
newForm = formType.create(formName, "", "Ac5_GyscbdForm");//Ac5_GyscbdForm
} catch (TCException e) {
MessageBox.post("创建失败" + e.getMessage(),"",MessageBox.ERROR);
e.printStackTrace();
}
if(newForm == null){
System.out.println("-----创建失败-----");
return null;
}
try {
target.add("Ac5_GYSCBD", newForm);//EC_reference_item_rel
MessageBox.post("创建完成","",MessageBox.INFORMATION);
} catch (TCException e) {
MessageBox.post("添加失败,请检查关系类型是否正确","",MessageBox.ERROR);
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,40 @@
package com.connor.mbd.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.mbd.dialogs.ModifymaturityDialog;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ModifymaturityHandler extends AbstractHandler {
TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession();
AbstractAIFUIApplication application = AIFUtility.getCurrentApplication();
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
new Thread(() -> {
InterfaceAIFComponent[] targets = AIFUtility.getCurrentApplication().getTargetComponents();
if (targets.length == 0) {
MessageBox.post("未选择对象", "", MessageBox.ERROR);
return;
}
if(targets[0] instanceof TCComponentBOMLine) {
new ModifymaturityDialog(targets, false);
}else if(targets[0] instanceof TCComponentItemRevision) {
new ModifymaturityDialog(targets, true);
}else {
MessageBox.post("请选择BOM行或零件版本对象", "", MessageBox.ERROR);
return;
}
}).start();
return null;
}
}

@ -0,0 +1,144 @@
package com.connor.mbd.handlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.osgi.service.prefs.PreferencesService;
import com.connor.mbd.dialogs.ProcessreviewDialog;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.TableBean;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ProcessreviewHandler extends AbstractHandler {
TCSession session;
AbstractAIFUIApplication application;
public static TCPreferenceService service;
private int realPropSize = 0;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
application = AIFUtility.getCurrentApplication();
session = (TCSession) application.getSession();
realPropSize = 0;
TCComponent target = (TCComponent) application.getTargetComponent();
if (target == null || !target.getType().equals("Ac5_GyscbdForm")) {
MessageBox.post("请选择协同审查表单执行", "", MessageBox.ERROR);
return null;
}
TCComponentForm form = (TCComponentForm) target;
String[] prefArray = getPrefStrArray("Connor_AVIC_GYSC_PropControl", session);
if (prefArray == null) {
MessageBox.post("请检查首选项配置...", "", MessageBox.ERROR);
return null;
}
// Map<String, String> prefMap = new HashMap<String, String>();
// Map<String, String> realPropMap = new HashMap<String,String>();
// Map<String, Map<String,String>> tablePropMap = new HashMap<>();
List<GeneralBean> generalList = new ArrayList<>();
List<TableBean> tableList = new ArrayList<>();
for (String prefOption : prefArray) {
String[] splitPropType = prefOption.split("=");
if (splitPropType.length == 2) {
if (splitPropType[0].equals("General")) {
String[] prefValues = splitPropType[1].split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if (edits.length > 2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
generalList.add(gBean);
} else if (splitPropType[0].contains("Table")) {
List<GeneralBean> chidList = new ArrayList<>();
TableBean tableBean = new TableBean();
int index = splitPropType[1].indexOf("(");
int index2 = splitPropType[1].indexOf(")");
int index3 = splitPropType[0].indexOf("(");
int index4 = splitPropType[0].indexOf(")");
String tableRow = splitPropType[0].substring(index3 + 1, index4);
String tableName = splitPropType[1].substring(0, index);
String tableString = splitPropType[1].substring(index + 1, index2);
String[] realProps = tableString.split(",");
for (String realProp : realProps) {
String[] prefValues = realProp.split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if (edits.length > 2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
chidList.add(gBean);
realPropSize++;
}
tableBean.setPropName(tableName);
tableBean.setPropList(chidList);
tableBean.setTableRow(tableRow);
tableList.add(tableBean);
// tablePropMap.put(tableName, realPropMap);
}
}
}
for (TableBean bean : tableList) {
System.out.println(bean);
}
// System.out.println(prefMap);
try {
new Thread() {
boolean isOkModify = form.okToModify();
public void run() {
AIFComponentContext[] revisions = null;// Ac5_GYSCBD
try {
revisions = form.whereReferencedByTypeRelation(null, new String[] { "Ac5_GYSCBD" });
} catch (TCException e) {
e.printStackTrace();
}
if (revisions != null) {
new ProcessreviewDialog(generalList, form, revisions[0], session, tableList, realPropSize,isOkModify);
} else {
MessageBox.post("未找到表单以Ac5_GYSCBD关联的版本", "", MessageBox.ERROR);
}
};
}.start();
} catch (TCException e) {
e.printStackTrace();
}
return null;
}
public static String[] getPrefStrArray(String prefName, TCSession session) {
if (service == null) {
service = session.getPreferenceService();
}
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
service.getStringValues(prefName);
service.getStringValue(prefName);
// if (strs == null) {
// strs = new String[] { "" };
// }
return strs;
}
}

@ -0,0 +1,153 @@
package com.connor.mbd.handlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.mbd.dialogs.ReviewstatisticalDialog;
import com.connor.mdb.beans.GeneralBean;
import com.connor.mdb.beans.GyscbdBean;
import com.connor.mdb.beans.TableBean;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ReviewstatisticalHandler extends AbstractHandler{
TCSession session;
AbstractAIFUIApplication application;
public static TCPreferenceService service;
private int realPropSize ;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
application = AIFUtility.getCurrentApplication();
session = (TCSession) application.getSession();
realPropSize = 0;
InterfaceAIFComponent[] targets = application.getTargetComponents();
if(targets == null || targets.length == 0){
MessageBox.post("请选择目标版本","",MessageBox.ERROR);
return null;
}
for(int i = 0 ; i< targets.length ; i++){
TCComponent targetComp = (TCComponent) targets[i];
if(targetComp instanceof TCComponentBOMLine){
try {
targets[i] = ((TCComponentBOMLine)targetComp).getItemRevision();
} catch (TCException e) {
e.printStackTrace();
}
continue;
}else if(targetComp instanceof TCComponentItemRevision){
continue;
}else{
MessageBox.post("请选择版本操作","",MessageBox.ERROR);
return null;
}
}
//Connor_AVIC_SHTJ_PropControl
String[] prefArray = getPrefStrArray("Connor_AVIC_SHTJ_PropControl", session);
if(prefArray == null){
MessageBox.post("请检查首选项配置...","",MessageBox.ERROR);
return null;
}
// Map<String, String> prefMap = new LinkedHashMap<String, String>();
// for(String prefOption : prefArray){
// String[] prefValues = prefOption.split(":");
// prefMap.put(prefValues[0], prefValues[1]);
// }
List<GeneralBean> generalList = new ArrayList<>();
List<TableBean> tableList = new ArrayList<>();
List<GyscbdBean> gyscbdList = new ArrayList<>();
for(String prefOption : prefArray){
String[] splitPropType = prefOption.split("=");
if(splitPropType.length == 2){
if(splitPropType[0].equals("General")){
String[] prefValues = splitPropType[1].split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if(edits.length>2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
generalList.add(gBean);
}else if(splitPropType[0].contains("Table")){
List<GeneralBean> chidList = new ArrayList<>();
TableBean tableBean = new TableBean();
int index = splitPropType[1].indexOf("(");
int index2 = splitPropType[1].indexOf(")");
int index3 = splitPropType[0].indexOf("(");
int index4 = splitPropType[0].indexOf(")");
String tableRow = splitPropType[0].substring(index3+1,index4);
String tableName = splitPropType[1].substring(0, index);
String tableString = splitPropType[1].substring(index+1,index2);
String[] realProps = tableString.split(",");
for(String realProp : realProps){
String[] prefValues = realProp.split(":");
GeneralBean gBean = new GeneralBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if(edits.length>2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
chidList.add(gBean);
realPropSize ++;
}
tableBean.setPropName(tableName);
tableBean.setPropList(chidList);
tableBean.setTableRow(tableRow);
tableList.add(tableBean);
//tablePropMap.put(tableName, realPropMap);
}else if(splitPropType[0].contains("GyscbdProp")){
String[] prefValues = splitPropType[1].split(":");
GyscbdBean gBean = new GyscbdBean();
String[] edits = prefValues[1].split(";");
gBean.setPropName(edits[0]);
gBean.setEditable(Boolean.parseBoolean(edits[1]));
if(edits.length>2)
gBean.setColumSize(Integer.valueOf(edits[2]));
gBean.setDisplayName(prefValues[0]);
gyscbdList.add(gBean);
}
}
}
new Thread(){
public void run() {
new ReviewstatisticalDialog(session,generalList,tableList,realPropSize,targets,gyscbdList);
};
}.start();
return null;
}
public static String[] getPrefStrArray(String prefName, TCSession session) {
if (service == null) {
service = session.getPreferenceService();
}
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
service.getStringValues(prefName);
service.getStringValue(prefName);
// if (strs == null) {
// strs = new String[] { "" };
// }
return strs;
}
}

@ -0,0 +1,61 @@
package com.connor.mbd.plm;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.connor.MBD.PLM"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}

@ -0,0 +1,26 @@
package com.connor.mdb.beans;
import java.util.List;
/**
*
* @author wangc
*
*/
public class CodeBean {
private String uid; //excel数据对象uid
private String name;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,51 @@
package com.connor.mdb.beans;
public class GeneralBean {
private String propName;
private String displayName;
private boolean isEditable;
private int ColumNum;
private int ColumSize;
public int getColumSize() {
return ColumSize;
}
public void setColumSize(int columSize) {
ColumSize = columSize;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public boolean isEditable() {
return isEditable;
}
public void setEditable(boolean isEditable) {
this.isEditable = isEditable;
}
public int getColumNum() {
return ColumNum;
}
public void setColumNum(int columNum) {
ColumNum = columNum;
}
@Override
public String toString() {
return "GeneralBean [propName=" + propName + ", displayName=" + displayName + ", isEditable=" + isEditable
+ ", ColumNum=" + ColumNum + "]";
}
}

@ -0,0 +1,62 @@
package com.connor.mdb.beans;
import java.io.File;
import java.util.List;
import java.util.Map;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class GetCodeBean {
private MenuCodeBean bean;
private List<CodeBean> codeBeanList;
public GetCodeBean(TCSession session){
ParseXML xml=new ParseXML();
File file=xml.getSXX("Connor_Code_Xml", session);
bean = xml.parseXMLCode(file);
}
public GetCodeBean() {
ParseXML xml=new ParseXML();
File file=new File("C:\\Users\\wangc\\Desktop\\新建文件夹\\编码规则.xml");
bean = xml.parseXMLCode(file);
// TODO Auto-generated constructor stub
}
/**
*
* @param names :&
* @return
*/
public CodeBean getCodebean(String names){
codeBeanList = bean.getCodeBeanList();
CodeBean selCodeBean=null;
for (int i = 0; i < codeBeanList.size(); i++) {
CodeBean codeBean = codeBeanList.get(i);
String codename=codeBean.getName();
if (codename.equals(names)) {
selCodeBean=codeBean;
break;
}
}
return selCodeBean;
}
/**
*
* @param name :
* @return
*/
public MenuBean getMenuBean(String name){
Map<String, MenuBean> menuMap = bean.getMenuMap();
MenuBean menuBean=null;
if (menuMap.containsKey(name)) {
menuBean = menuMap.get(name);
}else{
MessageBox.post("未找到该类型的对象配置信息,请联系管理员!","错误",MessageBox.ERROR);
}
return menuBean;
}
}

@ -0,0 +1,49 @@
package com.connor.mdb.beans;
public class GyscbdBean {
private String propName;
private String displayName;
private boolean isEditable;
private int ColumNum;
private int ColumSize;
public int getColumSize() {
return ColumSize;
}
public void setColumSize(int columSize) {
ColumSize = columSize;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public boolean isEditable() {
return isEditable;
}
public void setEditable(boolean isEditable) {
this.isEditable = isEditable;
}
public int getColumNum() {
return ColumNum;
}
public void setColumNum(int columNum) {
ColumNum = columNum;
}
@Override
public String toString() {
return "GeneralBean [propName=" + propName + ", displayName=" + displayName + ", isEditable=" + isEditable
+ ", ColumNum=" + ColumNum + "]";
}
}

@ -0,0 +1,31 @@
package com.connor.mdb.beans;
import java.util.List;
/**
*
* @author wangc
*
*/
public class MenuBean {
private String name; //뎠품꽉데츰냔
private List<MenuBean> list; //綾꽉데뚤蹶
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<MenuBean> getList() {
return list;
}
public void setList(List<MenuBean> list) {
this.list = list;
}
@Override
public String toString() {
return "{ MenuBean --" + name + " " + list + "}";
}
}

@ -0,0 +1,27 @@
package com.connor.mdb.beans;
import java.util.List;
import java.util.Map;
/**
*
* @author wangc
*
*/
public class MenuCodeBean {
private Map<String, MenuBean> menuMap; //몹섬꽉데
private List<CodeBean> codeBeanList;//긍쯤방橙
public Map<String, MenuBean> getMenuMap() {
return menuMap;
}
public void setMenuMap(Map<String, MenuBean> menuMap) {
this.menuMap = menuMap;
}
public List<CodeBean> getCodeBeanList() {
return codeBeanList;
}
public void setCodeBeanList(List<CodeBean> codeBeanList) {
this.codeBeanList = codeBeanList;
}
}

@ -0,0 +1,172 @@
package com.connor.mdb.beans;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* xml
* @author wangc
*
*/
public class ParseXML {
/**
* XML
* @param file
*/
public MenuCodeBean parseXMLCode(File file) {
MenuCodeBean bean =new MenuCodeBean();
List<CodeBean> codeList = new ArrayList<CodeBean>();
Map<String, MenuBean> menuMap =new HashMap<String, MenuBean>();
try {
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(file);
Element root = document.getRootElement();
Iterator iter = root.elementIterator("largeclass");// part标签
while (iter.hasNext()) {
MenuBean menuBean=new MenuBean();
Element recordEle = (Element) iter.next();
String type = recordEle.attributeValue("type");
String name = recordEle.attributeValue("name");
List<String> namelist = new ArrayList<>();
namelist.add(name);
List<String> codelist = new ArrayList<>();
Iterator iter2 = recordEle.elementIterator("subclass");// subclass标签
menuBean.setName(name);
menuBean.setList(new ArrayList<MenuBean>());
getCode(iter2, codeList, type, namelist, codelist,menuBean);
menuMap.put(name, menuBean);
System.out.println("-------"+menuBean);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(codeList);
bean.setCodeBeanList(codeList);
bean.setMenuMap(menuMap);
return bean;
}
/**
* xml
*
* @param iter2
* @param codeList
* @param futype
* @param namelist1
* @param codelist1
*/
private void getCode(Iterator iter2, List<CodeBean> codeList,
String futype, List<String> namelist1, List<String> codelist1,MenuBean menuBean) {
while (iter2.hasNext()) {
MenuBean zimenuBean=new MenuBean();
Element recordEle2 = (Element) iter2.next();
String type = recordEle2.attributeValue("type");
String name = recordEle2.attributeValue("name");
List<String> namelist = new ArrayList<>();
List<String> codelist = new ArrayList<>();
for (int i = 0; i < namelist1.size(); i++) {
namelist.add(namelist1.get(i));
}
for (int i = 0; i < codelist1.size(); i++) {
codelist.add(codelist1.get(i));
}
namelist.add(name);
zimenuBean.setName(name);
zimenuBean.setList(new ArrayList<MenuBean>());
List<MenuBean> list=menuBean.getList();
list.add(zimenuBean);
//System.out.println(list);
menuBean.setList(list);
if (type != null && type.toUpperCase().equals("S")) {
CodeBean codebean = new CodeBean();
Iterator iterprops = recordEle2.elementIterator("prop");
if (iterprops.hasNext()) {
Element recordEle3 = (Element) iterprops.next();
String uid = recordEle3.attributeValue("uid");
String allname = "";
for (int i = 0; i < namelist.size(); i++) {
if (i != 0) {
allname = allname + "&";
}
allname = allname + namelist.get(i);
}
codebean.setName(allname);
codebean.setUid(uid);
}
codeList.add(codebean);
} else {
Iterator iter3 = recordEle2.elementIterator("subclass");
if (iter3.hasNext()) {
getCode(iter3, codeList, futype, namelist, codelist,zimenuBean);
}
}
}
}
/**
* Uid
* @param pernaem
* @param session session
* @return
*/
public File getSXX(String pernaem,TCSession session) {
TCPreferenceService pref = session.getPreferenceService();
String puid = pref.getStringValue(pernaem);// 首选项查puid
if (puid != null) {
try {
TCComponentDataset dataset = (TCComponentDataset) session
.stringToComponent(puid);
if (dataset == null) {
return null;
}
TCComponentTcFile[] file = dataset.getTcFiles();
if (file.length == 0 || file.length != 1) {
MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING",
MessageBox.WARNING);
return null;
} else {
File fmsFile = file[0].getFmsFile();
return fmsFile;
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
MessageBox.post("未找到首选项["+pernaem+"]或首选项配置错误", "错误",
MessageBox.ERROR);
return null;
}
return null;
}
// /**
// * 单例测试
// * @param args
// */
// public static void main(String[] args) {
// // TODO Auto-generated method stub
// File file = new File("D:\\1.xml");
// File file2 = new File("D:\\2.xml");
// ParseXML t = new ParseXML();
// // t.parseXML(file);
// t.parseXMLCode(file2);
// }
}

@ -0,0 +1,17 @@
package com.connor.mdb.beans;
import java.io.File;
public class PictureBeans {
private File f ;
public File getF() {
return f;
}
public void setF(File f) {
this.f = f;
}
}

@ -0,0 +1,32 @@
package com.connor.mdb.beans;
import java.util.List;
public class TableBean {
private String propName;
private List<GeneralBean> propList;
private String tableRow;
public String getTableRow() {
return tableRow;
}
public void setTableRow(String tableRow) {
this.tableRow = tableRow;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public List<GeneralBean> getPropList() {
return propList;
}
public void setPropList(List<GeneralBean> propList) {
this.propList = propList;
}
@Override
public String toString() {
return "TableBean [propName=" + propName + ", propList=" + propList + "]";
}
}
Loading…
Cancel
Save