commit 809dfe753dd09dfb7a468789a07039e3a8d57903 Author: xiongcz Date: Tue Jun 3 17:17:00 2025 +0800 1 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..8a7b5a7 --- /dev/null +++ b/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..b036b3e --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cn.net.connor.designtopart + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..618525c --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/cn/net/connor/plm/util/ExcelWriteTable1.java=UTF-8 +encoding//src/cn/net/connor/plm/util/ExcelWriteTable2.java=UTF-8 +encoding//src/cn/net/connor/plm/util/ExcelWriteTable3.java=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..26a02c2 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,75 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Designtopart +Bundle-SymbolicName: cn.net.connor.designtopart;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: cn.net.connor.designtopart.Activator +Eclipse-RegisterBuddy: k.util +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="12000.3.0", + com.teamcenter.rac.common;bundle-version="12000.3.0", + com.teamcenter.rac.external;bundle-version="12000.3.0", + com.teamcenter.rac.kernel;bundle-version="12000.3.0", + com.teamcenter.rac.tcapps;bundle-version="12000.3.0", + com.teamcenter.rac.ui;bundle-version="12000.3.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.3.0", + com.teamcenter.rac.util;bundle-version="12000.3.0", + k.util;bundle-version="1.0.0", + TcSoaCoreLoose;bundle-version="12000.3.0", + TcSoaCoreRac;bundle-version="12000.3.0", + TcSoaCoreTypes;bundle-version="12000.3.0", + org.apache.poi.315;bundle-version="3.15.0", + TcSoaWorkflowLoose;bundle-version="12000.3.0", + TcSoaWorkflowRac;bundle-version="12000.3.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: cn.net.connor.designtopart +Bundle-ActivationPolicy: lazy +Export-Package: cn.net.connor.designtopart, + cn.net.connor.designtopart.commands, + cn.net.connor.designtopart.designtopart, + com.connor.dfl.plm.util, + oracle.core.lmx, + oracle.core.lvf, + oracle.jdbc, + oracle.jdbc.aq, + oracle.jdbc.babelfish, + oracle.jdbc.connector, + oracle.jdbc.dcn, + oracle.jdbc.diagnostics, + oracle.jdbc.driver, + oracle.jdbc.internal, + oracle.jdbc.oci, + oracle.jdbc.oracore, + oracle.jdbc.pool, + oracle.jdbc.pooling, + oracle.jdbc.proxy, + oracle.jdbc.proxy.annotation, + oracle.jdbc.replay, + oracle.jdbc.replay.driver, + oracle.jdbc.replay.internal, + oracle.jdbc.rowset, + oracle.jdbc.util, + oracle.jdbc.xa, + oracle.jdbc.xa.client, + oracle.jpub.runtime, + oracle.net.ano, + oracle.net.aso, + oracle.net.jdbc.TNSAddress, + oracle.net.jdbc.nl, + oracle.net.jdbc.nl.mesg, + oracle.net.jndi, + oracle.net.ns, + oracle.net.nt, + oracle.net.resolver, + oracle.security.o3logon, + oracle.security.o5logon, + oracle.sql, + oracle.sql.converter +Bundle-ClassPath: ., + lib/ojdbc7.jar, + lib/core-renderer.jar, + lib/iTextAsian.jar, + lib/iTextAsianCmaps.jar, + lib/itextpdf-5.0.6.jar +Import-Package: com.teamcenter.rac.ui.common diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..e802225 --- /dev/null +++ b/README.MD @@ -0,0 +1,17 @@ +## 图纸转物料 + +> 配置首选项:Connor_Design_To_Part + +```text +需要转换Design对象类型=[-]关系名称=转换后对象类型+“|”分隔,后边为属性继承对应关系,R为版本上属性,RM为版本表单属性,I为对象上的属性,+“*”标识属性为必填+“!”为可编辑; +值:Design版本=Part版本|R.Design属性值=R.Part属性值*!;RM. Design属性值=RM.Part属性值; + +关系名称前加“-”表示将需要转换的对象版本添加到转换后的对象版本的关系下 +``` + +示例 + +```text +ItemRevision=-IMAN_reference=Part Revision|R.object_desc=R.object_desc;RM.object_desc=RM.object_desc*! +Ac5_ProductInfoRevision=IMAN_reference=Ac5_ProductInfoRevision|R.object_string=R.object_desc;R.object_name=R.object_name;RM.ac5_BearingResearchDepart=RM.ac5_BearingResearchDepart!*;RM.ac5_ByTheHost=RM.ac5_ByTheHost;RM.ac5_CAE=rm.ac5_CAE;rm.ac5_ChiefDesigner=rm.ac5_ChiefDesigner;rm.ac5_ContractSigningTime=rm.ac5_ContractSigningTime;rm.ac5_CustomerIndustry=rm.ac5_CustomerIndustry;rm.ac5_Laboratory=rm.ac5_Laboratory;rm.ac5_MainEnginePlants=rm.ac5_MainEnginePlants;rm.ac5_NumberOfUnitsInstalled=rm.ac5_NumberOfUnitsInstalled +``` \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..e86059d --- /dev/null +++ b/build.properties @@ -0,0 +1,11 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + icons/,\ + .,\ + lib/ojdbc7.jar,\ + lib/core-renderer.jar,\ + lib/iTextAsian.jar,\ + lib/iTextAsianCmaps.jar,\ + lib/itextpdf-5.0.6.jar +source.. = src/ diff --git a/icons/ojdbc7.jar b/icons/ojdbc7.jar new file mode 100644 index 0000000..811da0f Binary files /dev/null and b/icons/ojdbc7.jar differ diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/core-renderer.jar b/lib/core-renderer.jar new file mode 100644 index 0000000..871fabf Binary files /dev/null and b/lib/core-renderer.jar differ diff --git a/lib/iTextAsian.jar b/lib/iTextAsian.jar new file mode 100644 index 0000000..3fa2157 Binary files /dev/null and b/lib/iTextAsian.jar differ diff --git a/lib/iTextAsianCmaps.jar b/lib/iTextAsianCmaps.jar new file mode 100644 index 0000000..aa2b429 Binary files /dev/null and b/lib/iTextAsianCmaps.jar differ diff --git a/lib/itextpdf-5.0.6.jar b/lib/itextpdf-5.0.6.jar new file mode 100644 index 0000000..d716b4e Binary files /dev/null and b/lib/itextpdf-5.0.6.jar differ diff --git a/lib/ojdbc7.jar b/lib/ojdbc7.jar new file mode 100644 index 0000000..811da0f Binary files /dev/null and b/lib/ojdbc7.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..9edc4c7 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cn/net/connor/designtopart/Activator.java b/src/cn/net/connor/designtopart/Activator.java new file mode 100644 index 0000000..cdcb7a7 --- /dev/null +++ b/src/cn/net/connor/designtopart/Activator.java @@ -0,0 +1,44 @@ +package cn.net.connor.designtopart; + +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 = "cn.net.connor.designtopart"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + 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; + } + +} diff --git a/src/cn/net/connor/designtopart/DesigntopartLocale.java b/src/cn/net/connor/designtopart/DesigntopartLocale.java new file mode 100644 index 0000000..1642fe0 --- /dev/null +++ b/src/cn/net/connor/designtopart/DesigntopartLocale.java @@ -0,0 +1,22 @@ +package cn.net.connor.designtopart; + +import com.teamcenter.rac.util.Registry; + + +public class DesigntopartLocale { + + public static final Registry reg = Registry.getRegistry(DesigntopartLocale.class); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } else { + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java b/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java new file mode 100644 index 0000000..73b4147 --- /dev/null +++ b/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.designtopart.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.designtopart.designtopart.DesignToPartDialog; +import cn.net.connor.designtopart.designtopart.DesignToPartDialogController; +import k.KCommand; + +public class DesignToPartCommand extends KCommand { + + public DesignToPartCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new DesignToPartDialog(new DesignToPartDialogController(app))); + } + +} diff --git a/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java new file mode 100644 index 0000000..bcb263d --- /dev/null +++ b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java @@ -0,0 +1,35 @@ +package cn.net.connor.designtopart.designtopart; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import cn.net.connor.designtopart.DesigntopartLocale; +import javafx.embed.swing.JFXPanel; +import k.KDialog; +import k.KDialogController; + +@SuppressWarnings("serial") +public class DesignToPartDialog extends KDialog { + + protected DesignToPartDialogController controller; + + public DesignToPartDialog(KDialogController controller) { + super(controller); + this.controller = (DesignToPartDialogController) controller; + } + + @Override + protected void addListeners() { + } + + @Override + protected void initUI() { + this.setTitle(DesigntopartLocale.getString("designtopart")); + this.setPreferredSize(new Dimension(800, 600)); + this.setMinimumSize(new Dimension(800, 600)); + JFXPanel panel = new JFXPanel(); + panel.setScene(new DesignToPartPanel(this).getScene()); + this.add(BorderLayout.CENTER, panel); + } + +} diff --git a/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java new file mode 100644 index 0000000..defba3b --- /dev/null +++ b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java @@ -0,0 +1,72 @@ +package cn.net.connor.designtopart.designtopart; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +import cn.net.connor.designtopart.DesigntopartLocale; +import k.KDialogController; +import k.util.KUtil; + +public class DesignToPartDialogController extends KDialogController { + + public static final String PREF_TRANSFER = DesigntopartLocale.getString("DESIGNTOPART.PREF"); + protected List tableBuilders = new ArrayList(); + + public DesignToPartDialogController(AbstractAIFApplication app) { + super(app); + } + + @Override + public boolean init() throws Exception { + InterfaceAIFComponent[] targets = app.getTargetComponents(); + Map> selectedRevMap = new HashMap<>(64); + int targetCnt = KUtil.getLen(targets); + for (int i = 0; i < targetCnt; i++) { + InterfaceAIFComponent target = targets[i]; + if (!(target instanceof TCComponentItemRevision)) { + continue; + } + TCComponentItemRevision rev = (TCComponentItemRevision) target; + String type = rev.getType(); + List list; + if (selectedRevMap.containsKey(type)) { + list = selectedRevMap.get(type); + } else { + list = new ArrayList(); + selectedRevMap.put(type, list); + } + if (!list.contains(rev)) { + list.add(rev); + } + } + selectedRevMap.forEach((k, v) -> System.out.println(" = " + k + ", " + v)); + if (selectedRevMap.size() == 0) { + throw new TCException(DesigntopartLocale.getString("selectrev.INFO")); + } + // Connor_Design_To_Part + String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER); + int len = KUtil.getLen(prefVals); + int counter = 0; + for (int i = 0; i < len; i++) { + String prefVal = prefVals[i]; + TableBuilder builder = new TableBuilder(session, prefVal, selectedRevMap); + tableBuilders.add(builder); + counter += (builder.fromRevList == null ? 0 : builder.fromRevList.size()); + } + if (tableBuilders.size() == 0) { + throw new TCException(String.format(DesigntopartLocale.getString("pref.ERROR1"), PREF_TRANSFER)); + } + if (counter == 0) { + throw new TCException(DesigntopartLocale.getString("notransferdata.INFO")); + } + return true; + } + +} diff --git a/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml b/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml new file mode 100644 index 0000000..f2185a1 --- /dev/null +++ b/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml @@ -0,0 +1,48 @@ + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +