commit f3403a4ab9c8d9ce88d555591cedcace042e0db8 Author: xiongcz Date: Wed Apr 30 10:52:29 2025 +0800 feat(createTempDrawings): 实现创建临时图纸功能 - 新增 CreateTempDrawingDialog 类用于创建临时图纸对话框 - 新增 CreateTempDrawingHandler 类用于处理创建临时图纸的命令 - 添加必要的资源文件和配置,如 .classpath、.project、build.properties 等 - 在 plugin.xml 中注册命令和菜单项 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fff47af --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..463c03e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# ĬϺԵļ +/shelf/ +/workspace.xml +# ڱ༭ HTTP ͻ +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d7b5d73 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..9a6ba04 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cn.net.connor.createTempDrawings + + + + + + 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.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..fb1077b --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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=enabled +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..6620f22 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: CreateTempDrawings +Bundle-SymbolicName: cn.net.connor.createTempDrawings;singleton:=true +Bundle-Version: 1.0.0 +Automatic-Module-Name: cn.net.connor.createTempDrawings +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.ui;bundle-version="3.111.0", + org.eclipse.core.runtime;bundle-version="3.15.100", + 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" +Bundle-ActivationPolicy: lazy +Export-Package: cn.net.connor.createTempDrawings.dialogs, + cn.net.connor.createTempDrawings.handlers +Bundle-ClassPath: lib/hutool-all-5.8.25.jar, + . diff --git a/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class b/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class new file mode 100644 index 0000000..f8cb1b5 Binary files /dev/null and b/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class differ diff --git a/bin/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.class b/bin/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.class new file mode 100644 index 0000000..3876170 Binary files /dev/null and b/bin/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.class differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..2807201 --- /dev/null +++ b/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + lib/hutool-all-5.8.25.jar diff --git a/lib/hutool-all-5.8.25.jar b/lib/hutool-all-5.8.25.jar new file mode 100644 index 0000000..c0d7831 Binary files /dev/null and b/lib/hutool-all-5.8.25.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..274e6e3 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java b/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java new file mode 100644 index 0000000..7fe8f38 --- /dev/null +++ b/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java @@ -0,0 +1,98 @@ +package cn.net.connor.createTempDrawings.dialogs; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.*; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.UIUtilities; + +public class CreateTempDrawingDialog extends AbstractAIFDialog implements ActionListener{ + private AbstractAIFApplication application; + private TCSession tcSession ; + private JLabel drawingObjTypeLabel;//ͼֽͱǩ + private JComboBox drawingObjTypeComboBox;//ͼֽ + private JButton okButton;//ȷϰť + + public CreateTempDrawingDialog(AbstractAIFApplication application) { + super(true); + this.application = application; + this.tcSession = (TCSession) this.application.getSession(); + } + + + + @Override + public void run() { + try { + System.out.println("ʼشʱͼֽ壡"); + initUI(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ʱͼֽ-ѡ͵Ŀ + */ + private void initUI() throws Exception { + this.setTitle("ѡͼֽ"); + this.setSize(800,600); + this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + + JPanel centerPanel = new JPanel(new PropertyLayout()); + JPanel buttomPanel = new JPanel(new FlowLayout()); + + this.drawingObjTypeLabel = new JLabel("ͼֽ "); + String[] drawingTypes = {"1", "2", "3"}; + JComboBox drawingObjTypeComboBox = new JComboBox(drawingTypes); + + + + centerPanel.add("1.3.left.top",drawingObjTypeLabel); + centerPanel.add("1.4.left.top",drawingObjTypeComboBox); + + this.okButton = new JButton("ȷ"); + buttomPanel.add(okButton); + + //ťʱ + okButton.addActionListener(this); + + // + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.CENTER); + this.add(buttomPanel, BorderLayout.SOUTH); + + //ŵĻ + UIUtilities.centerToScreen(this); + this.setVisible(true); + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Զɵķ + Object s = e.getSource(); + try { + if (e.equals(this.okButton)) { + System.out.println("ɹȷϡť"); + + + } + } catch (Exception e2) { + // TODO: handle exception + } + + + } + + + +} diff --git a/src/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.java b/src/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.java new file mode 100644 index 0000000..b8e6655 --- /dev/null +++ b/src/cn/net/connor/createTempDrawings/handlers/CreateTempDrawingHandler.java @@ -0,0 +1,67 @@ +package cn.net.connor.createTempDrawings.handlers; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.createTempDrawings.dialogs.CreateTempDrawingDialog; + +public class CreateTempDrawingHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("ʱͼֽHandler"); + int flag = 0; + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + //1.жѡжǷҪ + InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent(); + + System.out.println("ǰѡжΪ"+selectComponent.getType()); + try { + if (selectComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) selectComponent; + String selectCompType = itemRevision.getStringProperty("object_type"); + if (selectCompType.equals("SB6_SZLXDRevision") || selectCompType.equals("SB6_LSWTCLTZDRevision")) { + flag ++; + } + + }else if (selectComponent instanceof TCComponentFolder) { + flag ++; + } + + if (flag != 0) { + CreateTempDrawingDialog dialog = new CreateTempDrawingDialog(application); + + new Thread(dialog).start(); + }else { + MessageBox.post("ѡļлϵ汾ʱ⴦֪ͨ汾ִдʱͼֽܣ" , "ʾ", MessageBox.INFORMATION); + + } + + + } catch (Exception e) { + // TODO: handle exception + System.out.println("ѡж쳣"); + e.printStackTrace(); + } + + + + + + + + + + + return null; + } + +}