commit
678ec7bf8d
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
|||||||
|
<?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/swingx-1.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/cn.net.connor.std.aifrcp_13000.1.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/cn.net.connor.std.fx_13000.1.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/cn.net.connor.std.gdtex_13000.1.0.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.connor.process</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,8 @@
|
|||||||
|
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.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: Process
|
||||||
|
Bundle-SymbolicName: com.connor.process;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0
|
||||||
|
Bundle-Vendor: CONNOR
|
||||||
|
Require-Bundle: org.eclipse.ui.forms;bundle-version="3.7.400",
|
||||||
|
org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime;bundle-version="3.15.100",
|
||||||
|
com.teamcenter.rac.common;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.external;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.util;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.aifrcp;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.neva;bundle-version="2.0.0",
|
||||||
|
com.teamcenter.rac.kernel;bundle-version="12000.2.0",
|
||||||
|
TcSoaCoreRac;bundle-version="12000.2.0"
|
||||||
|
Automatic-Module-Name: com.connor.ld.process
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
|
Bundle-ClassPath: .,
|
||||||
|
lib/swingx-1.6.1.jar,
|
||||||
|
lib/cn.net.connor.std.aifrcp_13000.1.0.jar,
|
||||||
|
lib/cn.net.connor.std.fx_13000.1.0.jar,
|
||||||
|
lib/cn.net.connor.std.gdtex_13000.1.0.jar
|
||||||
|
Export-Package: cn.net.connor.std.aifrcp,
|
||||||
|
cn.net.connor.std.aifrcp.util,
|
||||||
|
cn.net.connor.std.aifrcp.xml,
|
||||||
|
cn.net.connor.std.fx,
|
||||||
|
cn.net.connor.std.gdtex,
|
||||||
|
com.connor.process.commands,
|
||||||
|
com.connor.tcm.outfile.bean,
|
||||||
|
com.connor.tcm.outfile.createMaterial,
|
||||||
|
com.connor.tcm.outfile.dbom2ebom,
|
||||||
|
com.connor.tcm.outfile.projectFolder,
|
||||||
|
com.connor.tcm.outfile.util,
|
||||||
|
org.jdesktop.swingx.table
|
||||||
@ -0,0 +1 @@
|
|||||||
|
/com/
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
output.. = bin/
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
.,\
|
||||||
|
plugin.xml,\
|
||||||
|
lib/swingx-1.6.1.jar,\
|
||||||
|
lib/cn.net.connor.std.aifrcp_13000.1.0.jar,\
|
||||||
|
lib/cn.net.connor.std.fx_13000.1.0.jar,\
|
||||||
|
lib/cn.net.connor.std.gdtex_13000.1.0.jar
|
||||||
|
source.. = src/
|
||||||
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 526 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.commands">
|
||||||
|
<category
|
||||||
|
id="com.connor.ld.process.commands.category"
|
||||||
|
name="Sample Category">
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<command name="创建物料" id="com.connor.tcm.outfile.createMaterial.CjwlCommand"/>
|
||||||
|
|
||||||
|
<command
|
||||||
|
name="DBOM转EBOM"
|
||||||
|
categoryId="com.connor.tcm.outfile.commands.category"
|
||||||
|
id="DBOMtoEBOM">
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command
|
||||||
|
name="创建项目文件夹"
|
||||||
|
categoryId="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler"
|
||||||
|
id="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler">
|
||||||
|
</command>
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.handlers">
|
||||||
|
|
||||||
|
<handler
|
||||||
|
class="com.connor.tcm.outfile.dbom2ebom.DbomTransitionToEbomHandler"
|
||||||
|
commandId="DBOMtoEBOM">
|
||||||
|
</handler>
|
||||||
|
<handler
|
||||||
|
class="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler"
|
||||||
|
commandId="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler">
|
||||||
|
</handler>
|
||||||
|
<handler commandId="com.connor.tcm.outfile.createMaterial.CjwlCommand" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.bindings">
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.menus">
|
||||||
|
|
||||||
|
<menuContribution
|
||||||
|
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
|
||||||
|
|
||||||
|
<menu
|
||||||
|
label="DBOM转EBOM"
|
||||||
|
mnemonic="M"
|
||||||
|
id="com.connor.tcm.menus.outputGYWJ">
|
||||||
|
|
||||||
|
<command commandId="DBOMtoEBOM" id="DBOMtoEBOM"></command>
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
<menu
|
||||||
|
label="力邦合信PLM功能"
|
||||||
|
mnemonic="M"
|
||||||
|
id="com.connor.tcm.menus.outputGYWJ2">
|
||||||
|
|
||||||
|
<command commandId="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler" id="com.connor.tcm.outfile.projectFolder.ProjectFolderHandler"></command>
|
||||||
|
<command commandId="com.connor.tcm.outfile.createMaterial.CjwlCommand" id="com.connor.tcm.outfile.createMaterial.CjwlCommand"></command>
|
||||||
|
</menu>
|
||||||
|
</menuContribution>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
|
||||||
|
|
||||||
|
<command commandId="com.connor.tcm.outfile.createMaterial.CjwlCommand" id="com.connor.tcm.outfile.createMaterial.CjwlCommand"></command>
|
||||||
|
|
||||||
|
</menuContribution>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
</plugin>
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.connor.process.commands;
|
||||||
|
|
||||||
|
import org.jacorb.idl.runtime.int_token;
|
||||||
|
|
||||||
|
import com.connor.tcm.outfile.createMaterial.NewProcessDialog;
|
||||||
|
import com.connor.tcm.outfile.createMaterial.NewProcessDialogController;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import cn.net.connor.std.aifrcp.KCommand;
|
||||||
|
|
||||||
|
|
||||||
|
public class NewProcessCommand extends KCommand{
|
||||||
|
|
||||||
|
public NewProcessCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||||
|
super(app, commandId, actionInfo);
|
||||||
|
System.out.println("NewProcessCommand");
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||||
|
|
||||||
|
if(targetComponent == null) {
|
||||||
|
MessageBox.post("请选择图纸", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String type = targetComponent.getType();
|
||||||
|
|
||||||
|
String[] types = session.getPreferenceService().getStringValues("LB_Design_type");
|
||||||
|
|
||||||
|
if(types == null || types.length == 0) {
|
||||||
|
MessageBox.post("请正确配置 LB_Design_type 首选项", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
boolean juedge = false;
|
||||||
|
for (int i = 0; i < types.length; i++) {
|
||||||
|
if(types[i].equals(type)) {
|
||||||
|
juedge = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!juedge) {
|
||||||
|
MessageBox.post("请选择可以使用物料创建功能的图纸版本类型", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setRunnable(new NewProcessDialog(new NewProcessDialogController(app)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.connor.tcm.outfile.bean;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author vearn
|
||||||
|
*/
|
||||||
|
public class NodeBean {
|
||||||
|
|
||||||
|
private String dbom;//对象ID
|
||||||
|
private String ebom;//对象名称
|
||||||
|
private String ebomId;//对象名称
|
||||||
|
private String ebomDesc;//物料描述
|
||||||
|
private String num;//数量
|
||||||
|
private String label;//对象名称
|
||||||
|
private String refreshStatus;//发布状态
|
||||||
|
private String parentString;//对应父节点
|
||||||
|
|
||||||
|
public String getDbom() {
|
||||||
|
return dbom;
|
||||||
|
}
|
||||||
|
public void setDbom(String dbom) {
|
||||||
|
this.dbom = dbom;
|
||||||
|
}
|
||||||
|
public String getEbom() {
|
||||||
|
return ebom;
|
||||||
|
}
|
||||||
|
public void setEbom(String ebom) {
|
||||||
|
this.ebom = ebom;
|
||||||
|
}
|
||||||
|
public String getEbomId() {
|
||||||
|
return ebomId;
|
||||||
|
}
|
||||||
|
public void setEbomId(String ebomId) {
|
||||||
|
this.ebomId = ebomId;
|
||||||
|
}
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
public String getRefreshStatus() {
|
||||||
|
return refreshStatus;
|
||||||
|
}
|
||||||
|
public void setRefreshStatus(String refreshStatus) {
|
||||||
|
this.refreshStatus = refreshStatus;
|
||||||
|
}
|
||||||
|
public String getParentString() {
|
||||||
|
return parentString;
|
||||||
|
}
|
||||||
|
public void setParentString(String parentString) {
|
||||||
|
this.parentString = parentString;
|
||||||
|
}
|
||||||
|
public String getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
public void setNum(String num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
public String getEbomDesc() {
|
||||||
|
return ebomDesc;
|
||||||
|
}
|
||||||
|
public void setEbomDesc(String ebomDesc) {
|
||||||
|
this.ebomDesc = ebomDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package com.connor.tcm.outfile.createMaterial;
|
||||||
|
|
||||||
|
import org.jacorb.idl.runtime.int_token;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import cn.net.connor.std.aifrcp.KCommand;
|
||||||
|
|
||||||
|
|
||||||
|
public class CjwlCommand extends KCommand{
|
||||||
|
|
||||||
|
public CjwlCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||||
|
super(app, commandId, actionInfo);
|
||||||
|
System.out.println("NewProcessCommand");
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||||
|
|
||||||
|
if(targetComponent == null) {
|
||||||
|
MessageBox.post("请选择图纸", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String type = targetComponent.getType();
|
||||||
|
|
||||||
|
String[] types = session.getPreferenceService().getStringValues("LB_Design_type");
|
||||||
|
|
||||||
|
if(types == null || types.length == 0) {
|
||||||
|
MessageBox.post("请正确配置 LB_Design_type 首选项", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
boolean juedge = false;
|
||||||
|
for (int i = 0; i < types.length; i++) {
|
||||||
|
if(types[i].equals(type)) {
|
||||||
|
juedge = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!juedge) {
|
||||||
|
MessageBox.post("请选择可以使用物料创建功能的图纸版本类型", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setRunnable(new NewProcessDialog(new NewProcessDialogController(app)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
package com.connor.tcm.outfile.createMaterial;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import cn.net.connor.std.aifrcp.KDialog;
|
||||||
|
import cn.net.connor.std.aifrcp.KDialogController;
|
||||||
|
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class NewProcessDialog extends KDialog {
|
||||||
|
|
||||||
|
private JButton b_ok;
|
||||||
|
private JButton b_cel;
|
||||||
|
private NewProcessDialogController controller;
|
||||||
|
|
||||||
|
public NewProcessDialog(KDialogController controller) {
|
||||||
|
super(controller);
|
||||||
|
this.controller = (NewProcessDialogController) controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCompEnabled(boolean enabled) {
|
||||||
|
b_ok.setEnabled(enabled);
|
||||||
|
b_cel.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addListeners() {
|
||||||
|
b_cel.addActionListener(e -> disposeDialog());
|
||||||
|
|
||||||
|
b_ok.addActionListener(e -> {
|
||||||
|
new Thread(() -> {
|
||||||
|
setCompEnabled(false);
|
||||||
|
try {
|
||||||
|
controller.doCreate();
|
||||||
|
disposeDialog();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
MessageBox.post(NewProcessDialog.this, ex);
|
||||||
|
} finally {
|
||||||
|
setCompEnabled(true);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initUI() {
|
||||||
|
setTitle("´´½¨ÎïÁÏ");
|
||||||
|
setPreferredSize(new Dimension(700, 600));
|
||||||
|
setMinimumSize(new Dimension(700, 600));
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
add(BorderLayout.CENTER, initItemPanel());
|
||||||
|
add(BorderLayout.SOUTH, initBtnPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Component initBtnPanel() {
|
||||||
|
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
|
||||||
|
b_ok = new JButton("È·¶¨");
|
||||||
|
b_cel = new JButton("È¡Ïû");
|
||||||
|
panel.add(b_ok);
|
||||||
|
panel.add(b_cel);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Component initItemPanel() {
|
||||||
|
List<PrefComponent> comps = controller.itemComps;
|
||||||
|
JPanel wrapper = new JPanel(new BorderLayout());
|
||||||
|
wrapper.setBorder(BorderFactory.createTitledBorder(
|
||||||
|
BorderFactory.createEmptyBorder(30, 5, 5, 5), ""));
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(4, 0, 4, 25);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.weightx = 1.0;
|
||||||
|
|
||||||
|
int rowIndex = 0;
|
||||||
|
for (PrefComponent comp : comps) {
|
||||||
|
if (comp.isInvisible()) continue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = rowIndex++;
|
||||||
|
panel.add(comp.getPanel(), gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
gbc.gridy = rowIndex;
|
||||||
|
gbc.weighty = 1.0;
|
||||||
|
panel.add(new JLabel(""), gbc);
|
||||||
|
|
||||||
|
JScrollPane scroll = new JScrollPane(panel);
|
||||||
|
scroll.setBorder(null);
|
||||||
|
wrapper.add(BorderLayout.CENTER, scroll);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.connor.tcm.outfile.createMaterial;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
|
||||||
|
public class NewProcessHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||||
|
|
||||||
|
if(targetComponent == null) {
|
||||||
|
MessageBox.post("请选择图纸", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String type = targetComponent.getType();
|
||||||
|
|
||||||
|
String[] types = session.getPreferenceService().getStringValues("LB_Design_type");
|
||||||
|
|
||||||
|
if(types == null || types.length == 0) {
|
||||||
|
MessageBox.post("请正确配置 LB_Design_type 首选项", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean juedge = false;
|
||||||
|
for (int i = 0; i < types.length; i++) {
|
||||||
|
if(types[i].equals(type)) {
|
||||||
|
juedge = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!juedge) {
|
||||||
|
MessageBox.post("请选择可以使用物料创建功能的图纸版本类型", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
new NewProcessDialog(new NewProcessDialogController(app));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.connor.tcm.outfile.createMaterial;
|
||||||
|
|
||||||
|
|
||||||
|
public class OptionItem {
|
||||||
|
private String value;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public OptionItem(String value, String description) {
|
||||||
|
this.value = value;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() { return value; }
|
||||||
|
public String getDescription() { return description; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
package com.connor.tcm.outfile.createMaterial;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOPWindowType;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||||
|
|
||||||
|
public class ProcessUtil {
|
||||||
|
|
||||||
|
public static final String PREF_DB_CONN = "Connor_DBConn_Oracle_TC";
|
||||||
|
public static DecimalFormat DF = new DecimalFormat("#.##########################################");
|
||||||
|
public static final String PREF_MEOP_ITEMTYPE = "Connor_AVIC_MEOP_Types";
|
||||||
|
public static final String PREF_MEPROCESS_ITEMTYPE = "Connor_AVIC_MEProcess_Types";
|
||||||
|
|
||||||
|
public static boolean isMEOP(TCSession session, String itemTypeName) throws Exception {
|
||||||
|
if (KUtil.isEmpty(itemTypeName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String[] types = KUtil.getPrefVals(session, PREF_MEOP_ITEMTYPE);
|
||||||
|
return KUtil.inArray(itemTypeName, types) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isMEProcess(TCSession session, String itemTypeName) throws Exception {
|
||||||
|
if (KUtil.isEmpty(itemTypeName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String[] types = KUtil.getPrefVals(session, PREF_MEPROCESS_ITEMTYPE);
|
||||||
|
return KUtil.inArray(itemTypeName, types) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void errorSWT(Shell shell, String message, String title) {
|
||||||
|
showDialog(shell, message, title, SWT.ICON_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showDialog(Shell shell, String message, String title, int type) {
|
||||||
|
org.eclipse.swt.widgets.MessageBox dialog = new org.eclipse.swt.widgets.MessageBox(shell, SWT.OK | type);
|
||||||
|
dialog.setText(title);
|
||||||
|
dialog.setMessage(message);
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void switchToPrecise(TCSession session, TCComponentItemRevision rev) throws Exception {
|
||||||
|
// 切换到精确bom
|
||||||
|
System.out.println("Switch to Precise: " + rev);
|
||||||
|
TCComponentBOPWindowType bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow");
|
||||||
|
TCComponentBOMWindow bopWindow = bopWindowType.create(null);
|
||||||
|
TCComponentBOMLine bopLine = bopWindow.setWindowTopLine(rev.getItem(), rev, null, null);
|
||||||
|
bopWindow.lock();
|
||||||
|
try {
|
||||||
|
bopLine.setPrecision(true);
|
||||||
|
bopWindow.save();
|
||||||
|
} finally {
|
||||||
|
bopWindow.unlock();
|
||||||
|
bopWindow.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.connor.tcm.outfile.dbom2ebom;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
|
||||||
|
public class DbomTransitionToEbomHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
try {
|
||||||
|
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session);
|
||||||
|
command.executeModal();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
package com.connor.tcm.outfile.dbom2ebom;
|
||||||
|
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
|
import org.jdesktop.swingx.JXTreeTable;
|
||||||
|
|
||||||
|
public class JTreeTable extends JXTreeTable {
|
||||||
|
|
||||||
|
|
||||||
|
private List<Integer> isNotEditableRow;
|
||||||
|
//CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this);
|
||||||
|
TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this);
|
||||||
|
|
||||||
|
public List<Integer> getIsNotEditableRow() {
|
||||||
|
return isNotEditableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
|
||||||
|
this.isNotEditableRow = isNotEditableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JTreeTable(JTreeTableModel testTreeTableModel) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
super(testTreeTableModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int arg0, int arg1) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return true;//super.isCellEditable(arg0, arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableCellEditor getCellEditor(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
//if(isNotEditableRow.contains(row) && column == 2)
|
||||||
|
|
||||||
|
|
||||||
|
return cellEditor;
|
||||||
|
//return super.getCellEditor(row, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToolTipText(MouseEvent e) {
|
||||||
|
int row = this.rowAtPoint(e.getPoint());
|
||||||
|
int col = this.columnAtPoint(e.getPoint());
|
||||||
|
String tiptextString = null;
|
||||||
|
if (row > -1 && col > -1) {
|
||||||
|
Object value = this.getValueAt(row, col);
|
||||||
|
if (null != value && !"".equals(value))
|
||||||
|
tiptextString = value.toString();// 技륫鞫刻데禱목코휭
|
||||||
|
}
|
||||||
|
return tiptextString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableCellRenderer getCellRenderer(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2)
|
||||||
|
{
|
||||||
|
return checkboxRenderer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return super.getCellRenderer(row, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 茶꾜죗
|
||||||
|
public void HiddenCell(int column) {
|
||||||
|
TableColumn tc = this.getTableHeader().getColumnModel()
|
||||||
|
.getColumn(column);
|
||||||
|
tc.setMaxWidth(0);
|
||||||
|
tc.setPreferredWidth(0);
|
||||||
|
tc.setWidth(0);
|
||||||
|
tc.setMinWidth(0);
|
||||||
|
this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0);
|
||||||
|
this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.connor.tcm.outfile.dbom2ebom;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
|
||||||
|
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
|
||||||
|
import org.jdesktop.swingx.treetable.TreeTableNode;
|
||||||
|
|
||||||
|
import com.connor.tcm.outfile.bean.NodeBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author vearn
|
||||||
|
*/
|
||||||
|
public class JTreeTableModel extends DefaultTreeTableModel {
|
||||||
|
|
||||||
|
private String[] _names = { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"};
|
||||||
|
|
||||||
|
|
||||||
|
private List<Integer> isNotEditableRow;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public JTreeTableModel(TreeTableNode node) {
|
||||||
|
super(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Integer> getIsNotEditableRow() {
|
||||||
|
return isNotEditableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
|
||||||
|
this.isNotEditableRow = isNotEditableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列的数量
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return _names.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表头显示的内容
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getColumnName(int column) {
|
||||||
|
return _names[column];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回在单元格中显示的Object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(Object node, int column) {
|
||||||
|
Object value = null;
|
||||||
|
if (node instanceof DefaultMutableTreeTableNode) {
|
||||||
|
DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
|
||||||
|
Object o = mutableNode.getUserObject();
|
||||||
|
if (o != null && o instanceof NodeBean) {
|
||||||
|
NodeBean bean = (NodeBean) o;
|
||||||
|
switch (column) {
|
||||||
|
case 0:
|
||||||
|
value = bean.getDbom();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
value = bean.getEbom();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value = bean.getLabel();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
value = bean.getEbomId();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
value = bean.getEbomDesc();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
value = bean.getNum();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
value = bean.getRefreshStatus();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
value = bean.getParentString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置所有单元格都不能编辑
|
||||||
|
*
|
||||||
|
* @param the node (i.e. row) for which editing is to be determined
|
||||||
|
* @param the column for which editing is to be determined
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(Object node, int column) {
|
||||||
|
//if(column == 5)
|
||||||
|
//{
|
||||||
|
return true;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package com.connor.tcm.outfile.dbom2ebom;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.EventListenerList;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
|
|
||||||
|
public class TableCellCheckboxRenderer extends JCheckBox implements
|
||||||
|
TableCellRenderer {
|
||||||
|
private List<Integer> processRows;
|
||||||
|
protected EventListenerList listenerList = new EventListenerList();
|
||||||
|
protected ChangeEvent changeEvent = new ChangeEvent(this);
|
||||||
|
//private TestTreeTableModel tableModel;
|
||||||
|
|
||||||
|
public List<Integer> getProcessRows() {
|
||||||
|
return processRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessRows(List<Integer> processRows) {
|
||||||
|
this.processRows = processRows;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableCellCheckboxRenderer(final JTreeTable table) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||||
|
boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
this.setHorizontalAlignment(SwingConstants.CENTER);// ±íÍ·±êÇ©¾çÖÐ
|
||||||
|
this.setBorderPainted(true);
|
||||||
|
|
||||||
|
if(value != null)
|
||||||
|
{
|
||||||
|
// if(value.toString().equals("1"))
|
||||||
|
// {
|
||||||
|
// if(table.getColumnName(column).equals("¸ÄÖÆ") && hasFocus)
|
||||||
|
// {
|
||||||
|
// if(table.getValueAt(row, column + 1).toString().equals("1"))
|
||||||
|
// {
|
||||||
|
// table.setValueAt(0, row, column + 1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if(table.getColumnName(column).equals("ɾ³ý") && hasFocus)
|
||||||
|
// {
|
||||||
|
// if(table.getValueAt(row, column - 1).toString().equals("1"))
|
||||||
|
// {
|
||||||
|
// table.setValueAt(0, row, column - 1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(value.toString().equals("1"))
|
||||||
|
// {
|
||||||
|
// System.out.println(value.toString().equals("1") + "====");
|
||||||
|
// }
|
||||||
|
this.setSelected(value.toString().equals("1"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setSelected(false);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.connor.tcm.outfile.dbom2ebom;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String s = "11111112-32222222-4444";
|
||||||
|
System.out.println(s.substring(0, s.indexOf("-")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,342 @@
|
|||||||
|
package com.connor.tcm.outfile.projectFolder;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import com.connor.tcm.outfile.util.MethodUtil;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.kernel.ServiceData;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFolderType;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentProject;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
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.CreateInput;
|
||||||
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
|
||||||
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
public class ProjectFolderDialog extends JFrame {
|
||||||
|
|
||||||
|
// UI 组件
|
||||||
|
private JLabel leftLabel;
|
||||||
|
private JList<String> leftList;
|
||||||
|
private JLabel rightLabel;
|
||||||
|
private JList<String> rightList;
|
||||||
|
private JTextField newFolderName;
|
||||||
|
private JButton startButton;
|
||||||
|
private JButton cancelButton;
|
||||||
|
private static TCSession session;
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
private LinkedHashMap<String, TCComponentFolder> folderUidMap = new LinkedHashMap<String, TCComponentFolder>();
|
||||||
|
private LinkedHashMap<String, TCComponentProject> projectMap = new LinkedHashMap<String, TCComponentProject>();
|
||||||
|
public ProjectFolderDialog(TCSession session,AbstractAIFApplication app) throws Exception {
|
||||||
|
this.session = session;
|
||||||
|
this.app = app;
|
||||||
|
setTitle("创建项目资料夹");
|
||||||
|
setSize(800, 500); // 放大窗口
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setLocationRelativeTo(null); // 居中显示
|
||||||
|
|
||||||
|
initUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initUI() throws Exception {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
String[] folderUid = session.getPreferenceService().getStringValues("LB_ProjectFolder_template");
|
||||||
|
for (int i = 0; i < folderUid.length; i++) {
|
||||||
|
String[] split = folderUid[i].split("=");
|
||||||
|
TCComponent uidComponent = session.stringToComponent(split[1]);
|
||||||
|
if(uidComponent instanceof TCComponentFolder) {
|
||||||
|
folderUidMap.put(split[0], (TCComponentFolder)uidComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(folderUidMap.size() == 0) {
|
||||||
|
MessageBox.post("请正确配置 LB_ProjectFolder_template 首选项", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("folderUidMap=="+folderUidMap.toString());
|
||||||
|
String userId = session.getUser().getUserId();
|
||||||
|
TCComponent[] search = session.search("基于用户的项目", new String[] { "ID" }, new String[] { userId });
|
||||||
|
System.out.println("search====="+search.length);
|
||||||
|
for (int i = 0; i < search.length; i++) {
|
||||||
|
if(search[i] instanceof TCComponentProject) {
|
||||||
|
TCComponentProject project = (TCComponentProject)search[i];
|
||||||
|
projectMap.put(project.getStringProperty("object_string"), project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(projectMap.size() == 0) {
|
||||||
|
MessageBox.post("该用户未查询到项目", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建顶部面板:左右两列并排,无空隙
|
||||||
|
JPanel topPanel = new JPanel(new GridLayout(1, 2));
|
||||||
|
//topPanel.setBorder(BorderFactory.createTitledBorder("请选择您要复制的文件夹"));
|
||||||
|
|
||||||
|
// 左侧面板
|
||||||
|
JPanel leftPanel = new JPanel(new BorderLayout());
|
||||||
|
leftLabel = new JLabel("项目文件夹");
|
||||||
|
leftLabel.setFont(new Font("宋体", Font.PLAIN, 12));
|
||||||
|
leftPanel.add(leftLabel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
|
||||||
|
DefaultListModel<String> leftModel = new DefaultListModel<>();
|
||||||
|
|
||||||
|
for (Entry<String, TCComponentFolder> tcComponent : folderUidMap.entrySet()) {
|
||||||
|
leftModel.addElement(tcComponent.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
leftList = new JList<>(leftModel);
|
||||||
|
leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
leftList.setSelectedIndex(0);
|
||||||
|
leftList.setBackground(Color.WHITE);
|
||||||
|
leftList.setSelectionBackground(Color.BLUE);
|
||||||
|
leftList.setSelectionForeground(Color.WHITE);
|
||||||
|
leftPanel.add(new JScrollPane(leftList), BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// 右侧面板
|
||||||
|
JPanel rightPanel = new JPanel(new BorderLayout());
|
||||||
|
rightLabel = new JLabel("指定到的项目");
|
||||||
|
rightLabel.setFont(new Font("宋体", Font.PLAIN, 12));
|
||||||
|
rightPanel.add(rightLabel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
|
||||||
|
DefaultListModel<String> rightModel = new DefaultListModel<>();
|
||||||
|
for (Entry<String, TCComponentProject> tcComponent : projectMap.entrySet()) {
|
||||||
|
rightModel.addElement(tcComponent.getKey());
|
||||||
|
}
|
||||||
|
rightList = new JList<>(rightModel);
|
||||||
|
rightList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
rightList.setSelectedIndex(5); // 默认选中 "PRO-00001-新项目1"
|
||||||
|
rightList.setBackground(Color.WHITE);
|
||||||
|
rightList.setSelectionBackground(Color.BLUE);
|
||||||
|
rightList.setSelectionForeground(Color.WHITE);
|
||||||
|
rightPanel.add(new JScrollPane(rightList), BorderLayout.CENTER);
|
||||||
|
|
||||||
|
topPanel.add(leftPanel);
|
||||||
|
topPanel.add(rightPanel);
|
||||||
|
|
||||||
|
add(topPanel, BorderLayout.CENTER); // 放在中心,不再有上下空白
|
||||||
|
|
||||||
|
// 底部输入框和按钮
|
||||||
|
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
|
bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
|
JLabel nameLabel = new JLabel(" 新创建文件夹名字:");
|
||||||
|
newFolderName = new JTextField("");
|
||||||
|
newFolderName.setPreferredSize(new Dimension(350, 25));
|
||||||
|
|
||||||
|
startButton = new JButton("开始复制");
|
||||||
|
cancelButton = new JButton("取 消");
|
||||||
|
|
||||||
|
bottomPanel.add(nameLabel);
|
||||||
|
bottomPanel.add(newFolderName);
|
||||||
|
bottomPanel.add(startButton);
|
||||||
|
bottomPanel.add(cancelButton);
|
||||||
|
|
||||||
|
add(bottomPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
// 添加事件监听器
|
||||||
|
startButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String selectedProject = rightList.getSelectedValue();
|
||||||
|
if (selectedProject == null) {
|
||||||
|
MessageBox.post("请先选择一个目标项目", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String selectedFolder = leftList.getSelectedValue();
|
||||||
|
if (selectedFolder == null) {
|
||||||
|
MessageBox.post("请先选择一个目标文件夹", "提示 ", MessageBox.INFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TCComponentFolder tcComponentFolder = folderUidMap.get(selectedFolder);
|
||||||
|
//TCComponentFolderType topComponentFolderType = tcComponentFolder.getTypeComponent();
|
||||||
|
try {
|
||||||
|
MethodUtil.openByPass(session);
|
||||||
|
TCComponentFolder lastTopParentFolder = null;
|
||||||
|
String text = newFolderName.getText();
|
||||||
|
if(text != null && !text.isEmpty()) {
|
||||||
|
lastTopParentFolder = tcComponentFolder.saveAs(text);
|
||||||
|
}else {
|
||||||
|
lastTopParentFolder = tcComponentFolder.saveAs(tcComponentFolder.getStringProperty("object_name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TCComponent[] relateds = lastTopParentFolder.getRelatedComponents("contents");
|
||||||
|
lastTopParentFolder.cutOperation("contents", relateds);
|
||||||
|
lastTopParentFolder.refresh();
|
||||||
|
|
||||||
|
|
||||||
|
//TCComponentFolder lastTopParentFolder = createFolderBySOA(topComponentFolderType.getTypeName(), tcComponentFolder.getStringProperty("object_name"));
|
||||||
|
createFolderStruct(tcComponentFolder,lastTopParentFolder,true);
|
||||||
|
TCComponentProject tcComponentProject = projectMap.get(selectedProject);
|
||||||
|
System.out.println("lastTopParentFolder==="+lastTopParentFolder.getUid());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tcComponentProject.assignToProject(new TCComponent[] {lastTopParentFolder});
|
||||||
|
|
||||||
|
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||||
|
if(targetComponent instanceof TCComponentFolder) {
|
||||||
|
((TCComponentFolder) targetComponent).add("contents", lastTopParentFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodUtil.closeByPass(session);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
MethodUtil.closeByPass(session);
|
||||||
|
} catch (TCException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MessageBox.post("创建成功", "提示 ", MessageBox.INFORMATION);
|
||||||
|
dispose(); // 关闭窗口
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dispose(); // 关闭窗口
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createFolderStruct(TCComponentFolder childFolder,TCComponentFolder parentFolder,boolean ifTop) throws Exception {
|
||||||
|
AIFComponentContext[] children = childFolder.getChildren();
|
||||||
|
if(ifTop) {
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
InterfaceAIFComponent component = children[i].getComponent();
|
||||||
|
if(component instanceof TCComponentFolder) {
|
||||||
|
TCComponentFolder childTcComponentFolder = (TCComponentFolder)component;
|
||||||
|
createFolderStruct(childTcComponentFolder,parentFolder,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TCComponentFolder folder = childFolder.saveAs(childFolder.getStringProperty("object_name"));
|
||||||
|
TCComponent[] relateds = folder.getRelatedComponents("contents");
|
||||||
|
folder.cutOperation("contents", relateds);
|
||||||
|
folder.refresh();
|
||||||
|
parentFolder.add("contents", folder);
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
InterfaceAIFComponent component = children[i].getComponent();
|
||||||
|
if(component instanceof TCComponentFolder) {
|
||||||
|
TCComponentFolder childTcComponentFolder = (TCComponentFolder)component;
|
||||||
|
createFolderStruct(childTcComponentFolder,folder,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// private void createFolderStruct(TCComponentFolder childFolder,TCComponentFolder parentFolder,
|
||||||
|
// TCComponentFolderType folderType,boolean ifTop) throws Exception {
|
||||||
|
// AIFComponentContext[] children = childFolder.getChildren();
|
||||||
|
// if(ifTop) {
|
||||||
|
// for (int i = 0; i < parentFolder.getChildrenCount(); i++) {
|
||||||
|
// InterfaceAIFComponent component = children[i].getComponent();
|
||||||
|
// if(component instanceof TCComponentFolder) {
|
||||||
|
// TCComponentFolder childTcComponentFolder = (TCComponentFolder)component;
|
||||||
|
// TCComponentFolderType typeComponent = childTcComponentFolder.getTypeComponent();
|
||||||
|
// createFolderStruct(childTcComponentFolder,parentFolder,typeComponent,false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// TCComponentFolder folder = createFolderBySOA(folderType.getTypeName(), childFolder.getStringProperty("object_name"));
|
||||||
|
// parentFolder.add("contents", folder);
|
||||||
|
// for (int i = 0; i < childFolder.getChildrenCount(); i++) {
|
||||||
|
// InterfaceAIFComponent component = children[i].getComponent();
|
||||||
|
// if(component instanceof TCComponentFolder) {
|
||||||
|
// TCComponentFolder childTcComponentFolder = (TCComponentFolder)component;
|
||||||
|
// TCComponentFolderType typeComponent = childTcComponentFolder.getTypeComponent();
|
||||||
|
// createFolderStruct(childTcComponentFolder,folder,typeComponent,false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public static TCComponentFolder createFolderBySOA(String folderTypeName, String folderName) throws Exception {
|
||||||
|
if (folderTypeName.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CreateInput itemInput = new CreateInput();
|
||||||
|
itemInput.boName = folderTypeName;
|
||||||
|
Map<String, String> itemPropMap = new HashMap<>();
|
||||||
|
itemPropMap.put("object_name", folderName);
|
||||||
|
itemInput.stringProps = itemPropMap;
|
||||||
|
// create info
|
||||||
|
CreateIn cI = new CreateIn();
|
||||||
|
cI.clientId = "CreateFolder";
|
||||||
|
cI.data = itemInput;
|
||||||
|
// service
|
||||||
|
DataManagementService service = DataManagementService.getService(session);
|
||||||
|
// create
|
||||||
|
CreateResponse resp = service.createObjects(new CreateIn[] { cI });
|
||||||
|
throwServiceDataError(resp.serviceData);
|
||||||
|
CreateOut[] cOs = resp.output;
|
||||||
|
if (cOs.length > 0) {
|
||||||
|
for (TCComponent s : cOs[0].objects) {
|
||||||
|
if (s instanceof TCComponentFolder) {
|
||||||
|
return (TCComponentFolder) s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void throwServiceDataError(ServiceData serviceData) throws Exception {
|
||||||
|
if (serviceData.sizeOfPartialErrors() > 0) {
|
||||||
|
StringBuilder errInfo = new StringBuilder();
|
||||||
|
for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) {
|
||||||
|
for (String msg : serviceData.getPartialError(i).getMessages()) {
|
||||||
|
errInfo.append(msg + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// System.out.println(errInfo.toString());
|
||||||
|
throw new Exception(errInfo.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.connor.tcm.outfile.projectFolder;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
|
||||||
|
public class ProjectFolderHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
try {
|
||||||
|
new ProjectFolderDialog(session,app).setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,171 @@
|
|||||||
|
package com.connor.tcm.outfile.util;
|
||||||
|
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.ComboBoxModel;
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
@SuppressWarnings({ "serial", "rawtypes", "unchecked" })
|
||||||
|
public class JAutoCompleteComboBox extends JComboBox {
|
||||||
|
private AutoCompleter completer;
|
||||||
|
private String propName;
|
||||||
|
|
||||||
|
public JAutoCompleteComboBox() {
|
||||||
|
super();
|
||||||
|
addCompleter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JAutoCompleteComboBox(ComboBoxModel cm) {
|
||||||
|
super(cm);
|
||||||
|
addCompleter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JAutoCompleteComboBox(Object[] items) {
|
||||||
|
super(items);
|
||||||
|
addCompleter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JAutoCompleteComboBox(List v) {
|
||||||
|
super((Vector) v);
|
||||||
|
addCompleter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getPropName() {
|
||||||
|
return propName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropName(String propName) {
|
||||||
|
this.propName = propName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCompleter() {
|
||||||
|
setEditable(true);
|
||||||
|
completer = new AutoCompleter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void autoComplete(String str) {
|
||||||
|
this.completer.autoComplete(str, str.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return ((JTextField) getEditor().getEditorComponent()).getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
((JTextField) getEditor().getEditorComponent()).setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsItem(String itemString) {
|
||||||
|
for (int i = 0; i < this.getModel().getSize(); i++) {
|
||||||
|
String _item = " " + this.getModel().getElementAt(i);
|
||||||
|
if (_item.equals(itemString))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"rawtypes"})
|
||||||
|
class AutoCompleter implements KeyListener, ItemListener {
|
||||||
|
|
||||||
|
private JComboBox owner = null;
|
||||||
|
private JTextField editor = null;
|
||||||
|
|
||||||
|
private ComboBoxModel model = null;
|
||||||
|
|
||||||
|
public AutoCompleter(JComboBox comboBox) {
|
||||||
|
owner = comboBox;
|
||||||
|
editor = (JTextField) comboBox.getEditor().getEditorComponent();
|
||||||
|
editor.addKeyListener(this);
|
||||||
|
model = comboBox.getModel();
|
||||||
|
owner.addItemListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
char ch = e.getKeyChar();
|
||||||
|
// if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)
|
||||||
|
// || ch == KeyEvent.VK_DELETE)
|
||||||
|
// return;
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
|
int caretPosition = editor.getCaretPosition();
|
||||||
|
String str = editor.getText();
|
||||||
|
if (str.length() == 0)
|
||||||
|
return;
|
||||||
|
autoComplete(str, caretPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "unused" })
|
||||||
|
protected void autoComplete(String strf, int caretPosition) {
|
||||||
|
Object[] opts;
|
||||||
|
opts = getMatchingOptions(strf.substring(0, caretPosition));
|
||||||
|
if (owner != null) {
|
||||||
|
model = new DefaultComboBoxModel(opts);
|
||||||
|
owner.setModel(model);
|
||||||
|
}
|
||||||
|
if (opts.length > 0) {
|
||||||
|
String str = opts[0].toString();
|
||||||
|
editor.setCaretPosition(caretPosition);
|
||||||
|
if (owner != null) {
|
||||||
|
try {
|
||||||
|
owner.showPopup();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected Object[] getMatchingOptions(String str) {
|
||||||
|
List v = new Vector();
|
||||||
|
List v1 = new Vector();
|
||||||
|
// v.add(str);
|
||||||
|
for (int k = 0; k < model.getSize(); k++) {
|
||||||
|
Object itemObj = model.getElementAt(k);
|
||||||
|
if (itemObj != null) {
|
||||||
|
String item = itemObj.toString().toLowerCase();
|
||||||
|
if (item.indexOf((str.toLowerCase())) > -1)
|
||||||
|
v.add(model.getElementAt(k));
|
||||||
|
else
|
||||||
|
v1.add(model.getElementAt(k));
|
||||||
|
} else
|
||||||
|
v1.add(model.getElementAt(k));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < v1.size(); i++) {
|
||||||
|
v.add(v1.get(i));
|
||||||
|
}
|
||||||
|
// if (v.isEmpty())
|
||||||
|
return v.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void itemStateChanged(ItemEvent event) {
|
||||||
|
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||||
|
int caretPosition = editor.getCaretPosition();
|
||||||
|
if (caretPosition != -1) {
|
||||||
|
try {
|
||||||
|
editor.moveCaretPosition(caretPosition);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue