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
|
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.
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.
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
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.
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,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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -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 table的dataVector
|
||||||
|
*/
|
||||||
|
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…
Reference in new issue