From 5791b7d3740d6366441e96a5b511f69c33d77e1d Mon Sep 17 00:00:00 2001
From: 5rKB5bPlusD <5rKB5bPlusD@192.168.0.102>
Date: Thu, 28 Nov 2019 00:01:26 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=89=E5=BE=B7PLM=E8=8F=9C=E5=8D=95?=
=?UTF-8?q?=E5=BC=80=E5=8F=91=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
com.connor.jd.plm/.classpath | 7 +
com.connor.jd.plm/.project | 28 +
.../.settings/org.eclipse.jdt.core.prefs | 13 +
com.connor.jd.plm/META-INF/MANIFEST.MF | 16 +
com.connor.jd.plm/build.properties | 6 +
com.connor.jd.plm/icons/sample.png | Bin 0 -> 332 bytes
com.connor.jd.plm/icons/sample@2x.png | Bin 0 -> 526 bytes
com.connor.jd.plm/plugin.xml | 486 ++++++++++++++++++
.../com/jdproject/handlers/SampleHandler.java | 316 ++++++++++++
.../handlers/createProjectHandler.java | 316 ++++++++++++
10 files changed, 1188 insertions(+)
create mode 100644 com.connor.jd.plm/.classpath
create mode 100644 com.connor.jd.plm/.project
create mode 100644 com.connor.jd.plm/.settings/org.eclipse.jdt.core.prefs
create mode 100644 com.connor.jd.plm/META-INF/MANIFEST.MF
create mode 100644 com.connor.jd.plm/build.properties
create mode 100644 com.connor.jd.plm/icons/sample.png
create mode 100644 com.connor.jd.plm/icons/sample@2x.png
create mode 100644 com.connor.jd.plm/plugin.xml
create mode 100644 com.connor.jd.plm/src/com/jdproject/handlers/SampleHandler.java
create mode 100644 com.connor.jd.plm/src/com/jdproject/handlers/createProjectHandler.java
diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath
new file mode 100644
index 0000000..b862a29
--- /dev/null
+++ b/com.connor.jd.plm/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/com.connor.jd.plm/.project b/com.connor.jd.plm/.project
new file mode 100644
index 0000000..5bf3bb0
--- /dev/null
+++ b/com.connor.jd.plm/.project
@@ -0,0 +1,28 @@
+
+
+ com.connor.jd.plm
+
+
+
+
+
+ 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/com.connor.jd.plm/.settings/org.eclipse.jdt.core.prefs b/com.connor.jd.plm/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5caa538
--- /dev/null
+++ b/com.connor.jd.plm/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,13 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+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
diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7f362a3
--- /dev/null
+++ b/com.connor.jd.plm/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JDProject
+Bundle-SymbolicName: com.connor.jd.plm;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ com.teamcenter.rac.common;bundle-version="12000.1.0",
+ com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
+ com.teamcenter.rac.util;bundle-version="12000.1.0",
+ com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
+ com.teamcenter.rac.tcapps;bundle-version="12000.1.0",
+ com.teamcenter.rac.kernel;bundle-version="12000.1.0",
+ org.eclipse.core.runtime;bundle-version="3.12.0"
+Automatic-Module-Name: JDProject
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: com.jdproject.handlers
diff --git a/com.connor.jd.plm/build.properties b/com.connor.jd.plm/build.properties
new file mode 100644
index 0000000..4b8162a
--- /dev/null
+++ b/com.connor.jd.plm/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
diff --git a/com.connor.jd.plm/icons/sample.png b/com.connor.jd.plm/icons/sample.png
new file mode 100644
index 0000000000000000000000000000000000000000..02c4b79e10986d56bda97051eb0da2e9119c97f5
GIT binary patch
literal 332
zcmV-S0ki&zP)o}PQ;SW4Q?|D@o|!n4bZ+dmjHl(fFnOU>N3Hz|3`e^PLI_Tklq
z9dEUPF8GjIQ2+RLZpDrNq~L=3C%1s!j|YcCWZ+aA5&{s6WBjJ7phjchl+7dD
zK%??C5t{FV)M8Cck-?KSfC{eT(i|B$Wp$+QOcA_!0hFXcX&$6FDqzZKU<%z0%uwCY
e0aKi5l4}7X=XWJ6VmxR70000{ZT)6VX-X|e!skhH1SmmK(Q+8xOk9EsoDx9;%V9VIujLL74J^=XMJoq9
z1|@9VK_4(VhK80y5@pbo6ckI-X8va_ZhIdO!f9Fi&L*dB`%g;@wBtO?KClDIJKpgF
zIsXR&gB_67@QMe>IbYQF_DWvOz5n#UMXhhIg6u>s=Yd5ht>Yhtu@=)Y0h1l*%f
Qr~m)}07*qoM6N<$f|JJHQ2+n{
literal 0
HcmV?d00001
diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml
new file mode 100644
index 0000000..b7c1a7a
--- /dev/null
+++ b/com.connor.jd.plm/plugin.xml
@@ -0,0 +1,486 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.connor.jd.plm/src/com/jdproject/handlers/SampleHandler.java b/com.connor.jd.plm/src/com/jdproject/handlers/SampleHandler.java
new file mode 100644
index 0000000..df43322
--- /dev/null
+++ b/com.connor.jd.plm/src/com/jdproject/handlers/SampleHandler.java
@@ -0,0 +1,316 @@
+package com.jdproject.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+//import com.connor.jk.plm.report.SqlUtil;
+import com.teamcenter.rac.aif.AIFDesktop;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.aifrcp.SelectionHelper;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.TCTypeService;
+import com.teamcenter.rac.services.ISessionService;
+import com.teamcenter.rac.ui.commands.Messages;
+import com.teamcenter.rac.ui.commands.RACUICommandsActivator;
+import com.teamcenter.rac.ui.commands.create.bo.NewBOModel;
+import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard;
+import com.teamcenter.rac.util.OSGIUtil;
+import com.teamcenter.rac.util.SWTUIUtilities;
+import com.teamcenter.rac.util.UIUtilities;
+import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog;
+import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper;
+
+public class SampleHandler extends AbstractHandler implements IExecutableExtension {
+ private TCSession session;
+ private String name;
+ private AbstractAIFApplication app;
+ private String opType = "";
+ protected InterfaceAIFComponent selectedCmps[];
+ protected ISelection m_currentSelection;
+ protected String wizardId;
+ protected WizardDialog dialog;
+ TCComponentBOMWindow window = null;
+ // private static HashMap map;
+
+ /**
+ * @deprecated Field session is deprecated
+ */
+ @Deprecated
+ protected NewBOModel m_boModel;
+
+ @Override
+ public Object execute(ExecutionEvent executionevent) throws ExecutionException {
+ System.out.println("ʼִ-----------");
+ app = AIFUtility.getCurrentApplication();
+ TCComponent comp = (TCComponent) app.getTargetComponent();
+
+ session = (TCSession) app.getSession();
+
+// TCComponentUser user=session.getUser();
+// try {
+// TCComponent person=user.getReferenceProperty("person");
+// System.out.println(person.getProperty("PA6"));
+// if(person.getProperty("PA6").equals("")) {
+// System.out.println("1");
+// }else if(person.getProperty("PA6")==null) {
+// System.out.println("2");
+// }
+// } catch (TCException e1) {
+// // TODO Auto-generated catch block
+// e1.printStackTrace();
+// }
+//
+//
+// if(true) {
+// return null;
+// }
+
+ // folderļͲܽ
+// if (comp instanceof TCComponentFolder) {
+// System.out.println(comp.getType());
+// if (comp.getType().equals("Hxc8XMWJJ")) {
+// MessageBox.post("ѡļ½Ŀ", "", MessageBox.INFORMATION);
+// return null;
+// }
+// } else {
+// MessageBox.post("ѡļ½Ŀ", "", MessageBox.INFORMATION);
+// return null;
+//
+// }
+
+ opType = executionevent.getCommand().getId();
+ if (executionevent == null)
+ throw new IllegalArgumentException("Event can't be null");
+
+ boolean flag = false;
+ if (executionevent.getParameters() != null && executionevent.getParameters().containsKey("selection")) {
+ Object obj = executionevent.getParameters().get("selection");
+ if (obj instanceof InterfaceAIFComponent[]) {
+ selectedCmps = (InterfaceAIFComponent[]) obj;
+ m_currentSelection = new StructuredSelection(selectedCmps);
+ flag = true;
+ }
+ }
+ if (!flag) {
+ m_currentSelection = HandlerUtil.getCurrentSelection(executionevent);
+ selectedCmps = SelectionHelper.getTargetComponents(m_currentSelection);
+ }
+ m_boModel = getBOModel();
+ launchWizard(executionevent);
+ return null;
+ }
+
+ /*
+ * private void createItem(TCComponent comp) { try {
+ *
+ * if (opType .equals("")) { TCComponentItemType itemType =
+ * (TCComponentItemType) session.getTypeComponent(opType); // create:
+ * ID汾͡ơλ TCComponentItem item = itemType.create(itemType.getNewID(),
+ * itemType.getNewRev(null), opType, name + "", "", null);
+ *
+ * comp.add("contents", item); MessageBox.post(name + "ɹ", "ɹ",
+ * MessageBox.INFORMATION); } } catch (TCException e) { // TODO Auto-generated
+ * catch block e.printStackTrace(); } }
+ */
+
+ private class CreateNewBOSWTDialog implements Runnable {
+
+ @Override
+ public void run() {
+ NewBOWizard newbowizard = (NewBOWizard) getWizard();
+ if (newbowizard == null)
+ newbowizard = new NewBOWizard(wizardId);
+ newbowizard.setBOModel(m_boModel);
+ newbowizard.setWindowTitle(getWizardTitle());
+ newbowizard.setRevisionFlag(m_boModel.getRevisionFlag());
+ newbowizard.setDefaultType(m_type);
+ Shell shell = UIUtilities.getCurrentModalShell();
+ dialog = new BaseExternalWizardDialog(m_shell, newbowizard);
+ dialog.create();
+ newbowizard.retrievePersistedDialogSettings(dialog);
+ newbowizard.setWizardDialog(dialog);
+ UIUtilities.setCurrentModalShell(dialog.getShell());
+ dialog.open();
+ dialog = null;
+
+// InterfaceAIFComponent[] compS = m_boModel.getTargetArray();
+//
+// if (compS != null && compS.length != 0) {
+// System.out.println(" length =" + compS.length);
+// if (compS[0] instanceof TCComponentItem) {
+//
+// System.out.println("ITEM");
+// } else if (compS[0] instanceof TCComponentFolder) {
+//
+// System.out.println("FOLDER");
+// }
+// TCComponent compT = (TCComponent) compS[0];
+// try {
+// System.out.println("object_name =>" + compT.getStringProperty("object_name"));
+// } catch (TCException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// } else {
+// System.out.println(" null ");
+// }
+//
+// System.out.println("=====>");
+// List contextList = m_boModel.getCompContext();
+// if (contextList != null) {
+// for (AIFComponentContext context : contextList) {
+// InterfaceAIFComponent comp = context.getComponent();
+// try {
+// System.out.println(">" + ((TCComponent) comp).getStringProperty("object_name"));
+// } catch (TCException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
+//
+// }
+// System.out.println("=====>");
+// m_boModel = null;
+//
+// UIUtilities.setCurrentModalShell(shell);
+//
+// System.out.println("dialog ==> " + opType + " | " + m_type);
+ }
+
+ private final Shell m_shell;
+ private final String m_type;
+ final SampleHandler this$0;
+
+ private CreateNewBOSWTDialog(Shell shell, String s) {
+ super();
+ this$0 = SampleHandler.this;
+
+ m_shell = shell;
+ m_type = s;
+ }
+
+ CreateNewBOSWTDialog(Shell shell, String s, CreateNewBOSWTDialog createnewboswtdialog) {
+ this(shell, s);
+ }
+
+ }
+
+ @Override
+ public void setInitializationData(IConfigurationElement iconfigurationelement, String s, Object obj)
+ throws CoreException {
+ }
+
+ protected NewBOModel getBOModel() {
+ if (m_boModel == null)
+ m_boModel = new NewBOModel(this);
+ return m_boModel;
+ }
+
+ public Wizard getWizard() {
+ if (wizardId == null || wizardId.length() == 0)
+ wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard";
+ return WizardExtensionHelper.getWizard(wizardId);
+ }
+
+ public String getWizardTitle() {
+ return Messages.getString("wizard.TITLE");
+ }
+
+ public void launchWizard() {
+ launchWizard(null);
+ }
+
+ public void launchWizard(ExecutionEvent executionevent) {
+ String s = this.opType;
+ initWizardModel(executionevent);
+ // if (executionevent != null)
+ // s = (String) executionevent.getParameters().get("objectType");
+ AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
+ Shell shell = aifdesktop.getShell();
+ if (shell != null)
+ SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, s, null));
+ System.out.println("999999999999999");
+ }
+
+ protected void initWizardModel(ExecutionEvent executionevent) {
+ boolean flag = false;
+ Object obj = null;
+ ISessionService isessionservice = (ISessionService) OSGIUtil.getService(RACUICommandsActivator.getDefault(),
+ com.teamcenter.rac.services.ISessionService.class);
+ try {
+ session = (TCSession) isessionservice.getSession(com.teamcenter.rac.kernel.TCSession.class.getName());
+ } catch (Exception _ex) {
+ session = (TCSession) AIFUtility.getDefaultSession();
+ }
+ m_boModel.setSession(session);
+ m_boModel.reInitializeTransientData();
+ m_boModel.setFrame(AIFUtility.getActiveDesktop());
+ if (executionevent != null) {
+ if (executionevent.getParameters().containsKey("revisionFlag"))
+ flag = ((Boolean) executionevent.getParameters().get("revisionFlag")).booleanValue();
+ if (executionevent.getParameters().containsKey("pasteRelation")) {
+ String s = (String) executionevent.getParameters().get("pasteRelation");
+ if (s != null) {
+ String as[] = null;
+ as = s.split(",");
+ m_boModel.setRelType(as[0]);
+ m_boModel.setPreAssignedRelType(as);
+ }
+ }
+ if (executionevent.getParameters().containsKey("parentComponents")) {
+ InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent
+ .getParameters().get("parentComponents");
+ m_boModel.setTargetArray(ainterfaceaifcomponent);
+ } else {
+ m_boModel.setTargetArray(selectedCmps);
+ }
+ } else {
+ m_boModel.setTargetArray(selectedCmps);
+ }
+ m_boModel.setRevisionFlag(flag);
+ AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
+ Shell shell = aifdesktop.getShell();
+ m_boModel.setShell(shell);
+ m_boModel.setCurrentSelection(m_currentSelection);
+ }
+
+ protected void readDisplayParameters(NewBOWizard newbowizard, WizardDialog wizarddialog) {
+ newbowizard.retrievePersistedDialogSettings(wizarddialog);
+ }
+
+ public TCComponentBOMLine getTopLineByRev(TCComponentItemRevision rev) {// öbomline
+ TCComponentBOMLine line = null;
+
+ try {
+ TCTypeService service = session.getTypeService();
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
+ window = winType.create(null);
+ line = window.setWindowTopLine(rev.getItem(), rev, null, null);
+// window.close();//رգᵼBOMռãBOMİ汾ɾTC
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+
+ return line;
+ }
+}
diff --git a/com.connor.jd.plm/src/com/jdproject/handlers/createProjectHandler.java b/com.connor.jd.plm/src/com/jdproject/handlers/createProjectHandler.java
new file mode 100644
index 0000000..ac0425a
--- /dev/null
+++ b/com.connor.jd.plm/src/com/jdproject/handlers/createProjectHandler.java
@@ -0,0 +1,316 @@
+package com.jdproject.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+//import com.connor.jk.plm.report.SqlUtil;
+import com.teamcenter.rac.aif.AIFDesktop;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.aifrcp.SelectionHelper;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.TCTypeService;
+import com.teamcenter.rac.services.ISessionService;
+import com.teamcenter.rac.ui.commands.Messages;
+import com.teamcenter.rac.ui.commands.RACUICommandsActivator;
+import com.teamcenter.rac.ui.commands.create.bo.NewBOModel;
+import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard;
+import com.teamcenter.rac.util.OSGIUtil;
+import com.teamcenter.rac.util.SWTUIUtilities;
+import com.teamcenter.rac.util.UIUtilities;
+import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog;
+import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper;
+
+public class createProjectHandler extends AbstractHandler implements IExecutableExtension {
+ private TCSession session;
+ private String name;
+ private AbstractAIFApplication app;
+ private String opType = "";
+ protected InterfaceAIFComponent selectedCmps[];
+ protected ISelection m_currentSelection;
+ protected String wizardId;
+ protected WizardDialog dialog;
+ TCComponentBOMWindow window = null;
+ // private static HashMap map;
+
+ /**
+ * @deprecated Field session is deprecated
+ */
+ @Deprecated
+ protected NewBOModel m_boModel;
+
+ @Override
+ public Object execute(ExecutionEvent executionevent) throws ExecutionException {
+ System.out.println("ʼִ-----------");
+ app = AIFUtility.getCurrentApplication();
+ TCComponent comp = (TCComponent) app.getTargetComponent();
+
+ session = (TCSession) app.getSession();
+
+// TCComponentUser user=session.getUser();
+// try {
+// TCComponent person=user.getReferenceProperty("person");
+// System.out.println(person.getProperty("PA6"));
+// if(person.getProperty("PA6").equals("")) {
+// System.out.println("1");
+// }else if(person.getProperty("PA6")==null) {
+// System.out.println("2");
+// }
+// } catch (TCException e1) {
+// // TODO Auto-generated catch block
+// e1.printStackTrace();
+// }
+//
+//
+// if(true) {
+// return null;
+// }
+
+ // folderļͲܽ
+// if (comp instanceof TCComponentFolder) {
+// System.out.println(comp.getType());
+// if (comp.getType().equals("Hxc8XMWJJ")) {
+// MessageBox.post("ѡļ½Ŀ", "", MessageBox.INFORMATION);
+// return null;
+// }
+// } else {
+// MessageBox.post("ѡļ½Ŀ", "", MessageBox.INFORMATION);
+// return null;
+//
+// }
+
+ opType = executionevent.getCommand().getId();
+ if (executionevent == null)
+ throw new IllegalArgumentException("Event can't be null");
+
+ boolean flag = false;
+ if (executionevent.getParameters() != null && executionevent.getParameters().containsKey("selection")) {
+ Object obj = executionevent.getParameters().get("selection");
+ if (obj instanceof InterfaceAIFComponent[]) {
+ selectedCmps = (InterfaceAIFComponent[]) obj;
+ m_currentSelection = new StructuredSelection(selectedCmps);
+ flag = true;
+ }
+ }
+ if (!flag) {
+ m_currentSelection = HandlerUtil.getCurrentSelection(executionevent);
+ selectedCmps = SelectionHelper.getTargetComponents(m_currentSelection);
+ }
+ m_boModel = getBOModel();
+ launchWizard(executionevent);
+ return null;
+ }
+
+ /*
+ * private void createItem(TCComponent comp) { try {
+ *
+ * if (opType .equals("")) { TCComponentItemType itemType =
+ * (TCComponentItemType) session.getTypeComponent(opType); // create:
+ * ID汾͡ơλ TCComponentItem item = itemType.create(itemType.getNewID(),
+ * itemType.getNewRev(null), opType, name + "", "", null);
+ *
+ * comp.add("contents", item); MessageBox.post(name + "ɹ", "ɹ",
+ * MessageBox.INFORMATION); } } catch (TCException e) { // TODO Auto-generated
+ * catch block e.printStackTrace(); } }
+ */
+
+ private class CreateNewBOSWTDialog implements Runnable {
+
+ @Override
+ public void run() {
+ NewBOWizard newbowizard = (NewBOWizard) getWizard();
+ if (newbowizard == null)
+ newbowizard = new NewBOWizard(wizardId);
+ newbowizard.setBOModel(m_boModel);
+ newbowizard.setWindowTitle(getWizardTitle());
+ newbowizard.setRevisionFlag(m_boModel.getRevisionFlag());
+ newbowizard.setDefaultType(m_type);
+ Shell shell = UIUtilities.getCurrentModalShell();
+ dialog = new BaseExternalWizardDialog(m_shell, newbowizard);
+ dialog.create();
+ newbowizard.retrievePersistedDialogSettings(dialog);
+ newbowizard.setWizardDialog(dialog);
+ UIUtilities.setCurrentModalShell(dialog.getShell());
+ dialog.open();
+ dialog = null;
+
+// InterfaceAIFComponent[] compS = m_boModel.getTargetArray();
+//
+// if (compS != null && compS.length != 0) {
+// System.out.println(" length =" + compS.length);
+// if (compS[0] instanceof TCComponentItem) {
+//
+// System.out.println("ITEM");
+// } else if (compS[0] instanceof TCComponentFolder) {
+//
+// System.out.println("FOLDER");
+// }
+// TCComponent compT = (TCComponent) compS[0];
+// try {
+// System.out.println("object_name =>" + compT.getStringProperty("object_name"));
+// } catch (TCException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// } else {
+// System.out.println(" null ");
+// }
+//
+// System.out.println("=====>");
+// List contextList = m_boModel.getCompContext();
+// if (contextList != null) {
+// for (AIFComponentContext context : contextList) {
+// InterfaceAIFComponent comp = context.getComponent();
+// try {
+// System.out.println(">" + ((TCComponent) comp).getStringProperty("object_name"));
+// } catch (TCException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
+//
+// }
+// System.out.println("=====>");
+// m_boModel = null;
+//
+// UIUtilities.setCurrentModalShell(shell);
+//
+// System.out.println("dialog ==> " + opType + " | " + m_type);
+ }
+
+ private final Shell m_shell;
+ private final String m_type;
+ final createProjectHandler this$0;
+
+ private CreateNewBOSWTDialog(Shell shell, String s) {
+ super();
+ this$0 = createProjectHandler.this;
+
+ m_shell = shell;
+ m_type = s;
+ }
+
+ CreateNewBOSWTDialog(Shell shell, String s, CreateNewBOSWTDialog createnewboswtdialog) {
+ this(shell, s);
+ }
+
+ }
+
+ @Override
+ public void setInitializationData(IConfigurationElement iconfigurationelement, String s, Object obj)
+ throws CoreException {
+ }
+
+ protected NewBOModel getBOModel() {
+ if (m_boModel == null)
+ m_boModel = new NewBOModel(this);
+ return m_boModel;
+ }
+
+ public Wizard getWizard() {
+ if (wizardId == null || wizardId.length() == 0)
+ wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard";
+ return WizardExtensionHelper.getWizard(wizardId);
+ }
+
+ public String getWizardTitle() {
+ return Messages.getString("wizard.TITLE");
+ }
+
+ public void launchWizard() {
+ launchWizard(null);
+ }
+
+ public void launchWizard(ExecutionEvent executionevent) {
+ String s = this.opType;
+ initWizardModel(executionevent);
+ // if (executionevent != null)
+ // s = (String) executionevent.getParameters().get("objectType");
+ AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
+ Shell shell = aifdesktop.getShell();
+ if (shell != null)
+ SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, s, null));
+ System.out.println("999999999999999");
+ }
+
+ protected void initWizardModel(ExecutionEvent executionevent) {
+ boolean flag = false;
+ Object obj = null;
+ ISessionService isessionservice = (ISessionService) OSGIUtil.getService(RACUICommandsActivator.getDefault(),
+ com.teamcenter.rac.services.ISessionService.class);
+ try {
+ session = (TCSession) isessionservice.getSession(com.teamcenter.rac.kernel.TCSession.class.getName());
+ } catch (Exception _ex) {
+ session = (TCSession) AIFUtility.getDefaultSession();
+ }
+ m_boModel.setSession(session);
+ m_boModel.reInitializeTransientData();
+ m_boModel.setFrame(AIFUtility.getActiveDesktop());
+ if (executionevent != null) {
+ if (executionevent.getParameters().containsKey("revisionFlag"))
+ flag = ((Boolean) executionevent.getParameters().get("revisionFlag")).booleanValue();
+ if (executionevent.getParameters().containsKey("pasteRelation")) {
+ String s = (String) executionevent.getParameters().get("pasteRelation");
+ if (s != null) {
+ String as[] = null;
+ as = s.split(",");
+ m_boModel.setRelType(as[0]);
+ m_boModel.setPreAssignedRelType(as);
+ }
+ }
+ if (executionevent.getParameters().containsKey("parentComponents")) {
+ InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent
+ .getParameters().get("parentComponents");
+ m_boModel.setTargetArray(ainterfaceaifcomponent);
+ } else {
+ m_boModel.setTargetArray(selectedCmps);
+ }
+ } else {
+ m_boModel.setTargetArray(selectedCmps);
+ }
+ m_boModel.setRevisionFlag(flag);
+ AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
+ Shell shell = aifdesktop.getShell();
+ m_boModel.setShell(shell);
+ m_boModel.setCurrentSelection(m_currentSelection);
+ }
+
+ protected void readDisplayParameters(NewBOWizard newbowizard, WizardDialog wizarddialog) {
+ newbowizard.retrievePersistedDialogSettings(wizarddialog);
+ }
+
+ public TCComponentBOMLine getTopLineByRev(TCComponentItemRevision rev) {// öbomline
+ TCComponentBOMLine line = null;
+
+ try {
+ TCTypeService service = session.getTypeService();
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
+ window = winType.create(null);
+ line = window.setWindowTopLine(rev.getItem(), rev, null, null);
+// window.close();//رգᵼBOMռãBOMİ汾ɾTC
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+
+ return line;
+ }
+}