Compare commits

...

10 Commits

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="accountSettings">
<option name="activeRegion" value="us-east-1" />
<option name="recentlyUsedRegions">
<list>
<option value="us-east-1" />
</list>
</option>
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/cn.com.origin.autocode/src/cn/com/origin/autocode/AutoCodePerspective.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/cn.com.origin.autocode/src/cn/com/origin/autocode/handlers/AutoCodeNewItemHandler.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/cn.com.origin.autocode/src/cn/com/origin/autocode/newitem/generatcode/NewCodeItemDialog.java" charset="GBK" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ASMSmaliIdeaPluginConfiguration">
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/autocode.iml" filepath="$PROJECT_DIR$/.idea/autocode.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>autocode</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="db_lib/ojdbc6.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/activation-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/antlr-2.7.7.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/apache-mime4j-core-0.7.2.jar"/>
@ -44,7 +45,7 @@
<classpathentry exported="true" kind="lib" path="axis2_lib/jalopy-1.5rc3.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxb-api-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxb-impl-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxb-xjc-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxb-xjc-2.1.7.jar" sourcepath="C:/Users/5RKB5B~1/AppData/Local/Temp/.org.sf.feeling.decompiler1576806100550/source/jaxb-xjc-2.1.7-sources.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxen-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jaxws-tools-2.1.3.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/jettison-1.0-RC2.jar"/>
@ -78,6 +79,8 @@
<classpathentry kind="lib" path="json_lib/fastjson-1.2.9-javadoc.jar"/>
<classpathentry kind="lib" path="json_lib/fastjson-1.2.9-sources.jar"/>
<classpathentry kind="lib" path="json_lib/fastjson-1.2.9.jar"/>
<classpathentry kind="lib" path="axis2_lib/hutool-all-5.0.7.jar"/>
<classpathentry kind="lib" path="aspose/aspose-cells-18.9.jar"/>
<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"/>

@ -28,7 +28,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.111.0",
org.eclipse.osgi.services;bundle-version="3.7.100",
org.eclipse.osgi.util;bundle-version="3.5.100"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: .,
antlr,
antlr.ASdebug,
@ -912,13 +912,7 @@ Bundle-ClassPath: json_lib/commons-beanutils-1.7.0.jar,
axis2_lib/XmlSchema-1.4.7.jar,
json_lib/fastjson-1.2.9-javadoc.jar,
json_lib/fastjson-1.2.9-sources.jar,
json_lib/fastjson-1.2.9.jar
Import-Package: com.alibaba.fastjson,
com.alibaba.fastjson.annotation,
com.alibaba.fastjson.asm,
com.alibaba.fastjson.parser,
com.alibaba.fastjson.parser.deserializer,
com.alibaba.fastjson.serializer,
com.alibaba.fastjson.support.jaxrs,
com.alibaba.fastjson.support.spring,
com.alibaba.fastjson.util
json_lib/fastjson-1.2.9.jar,
axis2_lib/hutool-all-5.0.7.jar,
aspose/aspose-cells-18.9.jar,
db_lib/ojdbc6.jar

@ -80,4 +80,7 @@ bin.includes = META-INF/,\
axis2_lib/XmlSchema-1.4.7.jar,\
json_lib/fastjson-1.2.9-javadoc.jar,\
json_lib/fastjson-1.2.9-sources.jar,\
json_lib/fastjson-1.2.9.jar
json_lib/fastjson-1.2.9.jar,\
axis2_lib/hutool-all-5.0.7.jar,\
aspose/aspose-cells-18.9.jar,\
db_lib/ojdbc6.jar

@ -125,6 +125,7 @@
</command>
<!--
<command commandId="org.eclipse.ui.file.saveAs"
label="通过编码另存">
<visibleWhen>
@ -140,7 +141,7 @@
</and>
</visibleWhen>
</command>
<!--
<command commandId="cn.com.origin.autocode.handlers.ORItemSaveAsHandler"
label="通过编码另存">
<visibleWhen>
@ -157,6 +158,13 @@
</visibleWhen>
</command>
-->
<command commandId="cn.com.origin.autocode.handlers.SaveAsByCodeHandler"
label="通过编码另存">
<visibleWhen>
true
</visibleWhen>
</command>
<!--
<command commandId="cn.com.origin.autocode.handlers.NewItemTestHandler"
label="测试创建item">
@ -202,14 +210,14 @@
label="新建文档/设计模型"
id="com.connor.jifeng.plm.menus.sampleCommand.shujufafang.JF3_SJFFJL_YFB">
</command>
<!-->
<!--
<command
commandId="cn.com.origin.autocode.handlers.ORItemSaveAsHandler"
mnemonic="S"
label="通过编码另存"
id="com.connor.jifeng.plm.menus.sampleCommand.shujufafang2.JF3_JJRWS_XG">
</command>
<!-->
-->
</menuContribution>
</extension>
@ -234,6 +242,9 @@
<command id="cn.com.origin.autocode.handlers.AutoCodeNewItemFilterTypeHandler"
name="cn.com.origin.autocode.handlers.AutoCodeNewItemFilterTypeHandler">
</command>
<command id="cn.com.origin.autocode.handlers.SaveAsByCodeHandler"
name="cn.com.origin.autocode.handlers.SaveAsByCodeHandler">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
@ -263,6 +274,10 @@
class="cn.com.origin.autocode.handlers.AutoCodeNewItemFilterTypeHandler">
</handler>
<handler
commandId="cn.com.origin.autocode.handlers.SaveAsByCodeHandler"
class="cn.com.origin.autocode.handlers.SaveAsByCodeHandler">
</handler>
</extension>
<!--AutoCodeGroupView views-->

@ -14,6 +14,7 @@ import cn.com.origin.autocodemanager.common.TCPreferenceUitl;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class AutoCodeNewItemHandler extends AbstractHandler {
private String origin_newItemDialogType = "origin_newItemDialogType";
@ -25,8 +26,6 @@ public class AutoCodeNewItemHandler extends AbstractHandler {
new Thread() {
public void run() {
ORNewItemCommand command = new ORNewItemCommand(AIFDesktop.getActiveDesktop().getFrame(), AIFUtility.getCurrentApplication());
// ExcelTemplate Item
// ORNewItemCommand command = new ORNewItemCommand(AIFDesktop.getActiveDesktop().getFrame(), AIFUtility.getCurrentApplication(),"DMTemplate");
try {
command.executeModal();
} catch (Exception e) {
@ -36,6 +35,7 @@ public class AutoCodeNewItemHandler extends AbstractHandler {
}.start();
} else {
new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell()).open();
}
return null;
}

@ -0,0 +1,42 @@
package cn.com.origin.autocode.handlers;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import javax.swing.JOptionPane;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import cn.hutool.db.ds.simple.SimpleDataSource;
public class DBUtil {
public static DataSource getDataSource(TCSession session) {
Map<String, String> settingMap = getDbSetting(session);
String str = settingMap.get("url") + settingMap.get("user") + settingMap.get("pass");
DataSource dataSource = new SimpleDataSource(settingMap.get("url"), settingMap.get("user"),
settingMap.get("pass"));
return dataSource;
}
private static Map<String, String> getDbSetting(TCSession session) {
Map<String, String> settingMap = null;
TCPreferenceService service = ((TCSession) AIFUtility.getCurrentApplication().getSession())
.getPreferenceService();
String[] dbSettings = service.getStringValues("jd2_db_settings");
if (dbSettings.length != 3) {
JOptionPane.showMessageDialog(null, "jd2_db_settings数据库连接配置错误", "错误", JOptionPane.ERROR);
} else {
settingMap = new HashMap<String, String>();
for (String s : dbSettings) {
settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length()));
}
}
return settingMap;
}
}

@ -1,193 +1,52 @@
package cn.com.origin.autocode.handlers;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.commands.genericsaveas.ISaveAsService;
import com.teamcenter.rac.common.Activator;
import com.teamcenter.rac.kernel.*;
import com.teamcenter.rac.ui.commands.handlers.SaveASHandler;
import com.teamcenter.rac.util.*;
import com.teamcenter.rac.util.wizard.extension.*;
import java.text.MessageFormat;
import org.apache.log4j.Logger;
import org.eclipse.core.commands.*;
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.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
public class ORItemSaveAsHandler extends AbstractHandler
{
private class CreateSaveAsDialog
implements Runnable
{
public void run()
{
BaseExternalWizard baseexternalwizard = getWizard();
if(baseexternalwizard != null)
{
baseexternalwizard.setForcePreviousAndNextButtons(true);
ISaveAsService isaveasservice =(ISaveAsService)OSGIUtil.getService(Activator.getDefault(), ISaveAsService.class);
if(isaveasservice != null)
{
isaveasservice.setInput((TCComponent)m_selectedCmp);
baseexternalwizard.setWindowTitle(getWizardTitle());
baseexternalwizard.setContext(new StructuredSelection(m_selectedCmp));
Shell shell = UIUtilities.getCurrentModalShell();
BaseExternalWizardDialog baseexternalwizarddialog = new BaseExternalWizardDialog(shell, baseexternalwizard);
baseexternalwizarddialog.create();
ORItemSaveAsHandler.readDisplayParameters(baseexternalwizard, baseexternalwizarddialog);
Shell shell1 = baseexternalwizarddialog.getShell();
UIUtilities.setCurrentModalShell(shell1);
baseexternalwizarddialog.open();
UIUtilities.setCurrentModalShell(shell);
} else
{
MessageBox.post(m_shell, Messages.getString("saveAsServiceNotAvailble.MEG"), Messages.getString("saveAs.TITLE"), 4);
}
}
}
private final Shell m_shell;
final ORItemSaveAsHandler this$0;
private CreateSaveAsDialog(Shell shell)
{
super();
this$0 = ORItemSaveAsHandler.this;
m_shell = shell;
}
CreateSaveAsDialog(Shell shell, CreateSaveAsDialog createsaveasdialog)
{
this(shell);
}
}
public ORItemSaveAsHandler()
{
}
public Object execute(ExecutionEvent executionevent)
throws ExecutionException
{
ISelection iselection = HandlerUtil.getCurrentSelection(executionevent);
if(iselection instanceof StructuredSelection)
{
StructuredSelection structuredselection = (StructuredSelection)iselection;
if(structuredselection.size() != 1)
{
MessageBox.post(HandlerUtil.getActiveWorkbenchWindow(executionevent).getShell(), Messages.getString("toomanyObjects.MSG"), Messages.getString("saveAs.TITLE"), 4);
} else
{
m_selectedCmp = (InterfaceAIFComponent)AdapterUtil.getAdapter(iselection, InterfaceAIFComponent.class);
if(m_selectedCmp.getType().endsWith("HX3_WLRevision")){
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.util.MessageBox;
import cn.com.origin.autocode.saveas.ORSaveAsCommand;
import cn.com.origin.autocodemanager.common.TCPreferenceUitl;
public class ORItemSaveAsHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// AbstractAIFUIApplication abstractAIFUIApplication =
// AIFUtility.getCurrentApplication();
// new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(),
// "SJ3_ZXCPPRT").open();
// new SaveAsCommand(AIFDesktop.getFrames()[0],
// AIFUtility.getCurrentApplication().getTargetComponents(), true).run();
ORSaveAsCommand orSaveAsCommand = new ORSaveAsCommand(AIFDesktop.getFrames()[0],
AIFUtility.getCurrentApplication().getTargetComponents(), true);
try {
m_selectedCmp =((TCComponentItemRevision)m_selectedCmp).getItem();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(m_selectedCmp instanceof TCComponent)
{
Object aobj[] = {
((TCComponent)m_selectedCmp).toDisplayString()
};
m_selectedCmp = getUnderlyingComponent((TCComponent)m_selectedCmp);
if(m_selectedCmp != null)
{
Shell shell = HandlerUtil.getActiveShell(executionevent);
if(shell != null)
{
CreateSaveAsDialog createsaveasdialog = new CreateSaveAsDialog(shell, null);
createsaveasdialog.run();
}
} else
{
MessageBox.post(HandlerUtil.getActiveWorkbenchWindow(executionevent).getShell(), MessageFormat.format(Messages.getString("saveAsNotSupported.MESSAGE"), aobj), Messages.getString("saveAs.TITLE"), 1);
}
} else
{
MessageBox.post(HandlerUtil.getActiveWorkbenchWindow(executionevent).getShell(), Messages.getString("invalidSelection.MESSAGE"), Messages.getString("saveAs.TITLE"), 1);
}
}
if (orSaveAsCommand != null)
orSaveAsCommand.executeModal();
} catch (Exception exception) {
MessageBox.post(AIFDesktop.getFrames()[0], exception);
}
return null;
}
protected static void readDisplayParameters(Wizard wizard, WizardDialog wizarddialog)
{
String s = "DialogParameters";
String s1 = wizard.getClass().getName();
if(Cookie.exists(s, true))
try
{
int i = 0;
int j = 0;
int k = 0;
int l = 0;
Cookie cookie = Cookie.getCookie(s, true);
i = cookie.getNumber((new StringBuilder(String.valueOf(s1))).append(".x").toString());
j = cookie.getNumber((new StringBuilder(String.valueOf(s1))).append(".y").toString());
k = cookie.getNumber((new StringBuilder(String.valueOf(s1))).append(".w").toString());
l = cookie.getNumber((new StringBuilder(String.valueOf(s1))).append(".h").toString());
if(k > 0 && l > 0)
wizarddialog.getShell().setBounds(i, j, k, l);
}
catch(Exception _ex) { }
}
protected BaseExternalWizard getWizard()
{
String s = "com.teamcenter.rac.ui.commands.saveas.SaveAsWizard";
return WizardExtensionHelper.getWizard(s);
}
protected String getWizardTitle()
{
String s = null;
if(m_selectedCmp instanceof TCComponent)
{
Object aobj[] = {
((TCComponent)m_selectedCmp).getTypeComponent().getDisplayType()
};
s = MessageFormat.format(Messages.getString("saveAswizard.TITLE"), aobj);
}
return s;
@Override
public boolean isEnabled() {
if (TCPreferenceUitl.isWriteExpire()) {
return false;
} else {
return true;
}
private TCComponent getUnderlyingComponent(TCComponent tccomponent)
{
try
{
if(tccomponent.isRuntimeType())
return tccomponent.getUnderlyingComponent().isRuntimeType() ? null : tccomponent.getUnderlyingComponent();
}
catch(TCException tcexception)
{
Logger.getLogger(SaveASHandler.class).error(tcexception.getLocalizedMessage(), tcexception);
}
return tccomponent;
}
private InterfaceAIFComponent m_selectedCmp;
}
/*
DECOMPILATION REPORT
Decompiled from: C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.ui.commands_11000.2.0.jar
Total time: 29 ms
Jad reported messages/errors:
Exit status: 0
Caught exceptions:
* DECOMPILATION REPORT
*
* Decompiled from:
* C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.ui.
* commands_11000.2.0.jar Total time: 29 ms Jad reported messages/errors: Exit
* status: 0 Caught exceptions:
*/

@ -0,0 +1,325 @@
package cn.com.origin.autocode.handlers;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AIFPortal;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import cn.com.origin.autocodemanager.common.operations.GetCodeNumber;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
public class SaveAsByCodeHandler extends AbstractHandler {
public TCComponentFolder select = null;
TCComponentFolder selectOld = null;
private JTextField text;
private JScrollPane jsp;
private JPanel root;
private JDialog dialog;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
// TODO Auto-generated method stub
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
TCPreferenceService service = session.getPreferenceService();
File selectFile = new File(System.getenv("temp") + File.separator + "select_folder_"
+ session.getUser().getUid() + ".txt");
selectFile.createNewFile();
// String uid = service.getStringValue("jd2_folder_select");
BufferedReader reader = new BufferedReader(new FileReader(selectFile));
String uid = reader.readLine();
reader.close();
if (StrUtil.isNotBlank(uid)) {
selectOld = (TCComponentFolder) session.stringToComponent(uid);
}
TCComponent comp = (TCComponent) app.getTargetComponent();
if (comp == null) {
JOptionPane.showMessageDialog(null, "没有选择目标", "提示", JOptionPane.WARNING_MESSAGE);
return;
}
System.out.println("type=====>" + comp.getType());
TCComponentItemRevision latestRev = null;
if (comp instanceof TCComponentItem) {
latestRev = ((TCComponentItem) comp).getLatestItemRevision();
} else if (comp instanceof TCComponentItemRevision) {
latestRev = (TCComponentItemRevision) comp;
} else {
JOptionPane.showMessageDialog(null, "目标对象类型" + comp.getType() + "不支持", "提示",
JOptionPane.WARNING_MESSAGE);
return;
}
String newItemId = null;
String itemId = latestRev.getProperty("item_id");
List<Entity> res = Db.use(DBUtil.getDataSource(session)).query(
"SELECT * FROM PCD9_CLASSIFICATIONCODENODE pc LEFT JOIN PCD9_TREEANDLISTCODENODE pt ON pc.PCD9_SEGMENT = pt.PUID");
String type = latestRev.getItem().getProperty("object_type");
System.out.println("类型===>" + type);
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
for (Entity entity : res) {
if (itemId.startsWith(entity.getStr("PCD9_NODE_VALUE"))
&& type.equals(entity.getStr("PCD9_NODE_NAME"))) {
String patternCode = entity.getStr("PCD9_NODE_VALUE");
int codeLength = entity.getInt("PCD9_CODE_LENGTH");
int startIndex = entity.getInt("PCD9_SEQ_BEGIN_VALUE");
int endIndex = entity.getInt("PCD9_SEQ_MAX_VALUE");
do {
newItemId = new GetCodeNumber().getCodeNumber(patternCode, codeLength, startIndex,
endIndex, 1, "");
new GetCodeNumber().delete_recycleID(newItemId);
} while (itemType.find(newItemId) != null);
break;
}
}
if (newItemId == null) {
JOptionPane.showMessageDialog(null, "没有找到对应的编码信息", "提示", JOptionPane.WARNING_MESSAGE);
return;
}
dialog = new JDialog();
dialog.setTitle("选择目录");
dialog.setAlwaysOnTop(true);
dialog.setAutoRequestFocus(true);
dialog.setResizable(true);
root = new JPanel();
root.setLayout(null);
root.setPreferredSize(new Dimension(300, 400));
JLabel label1 = new JLabel("加载需要一点时间,请等待");
jsp = new JScrollPane(label1);
jsp.setBounds(0, 0, 300, 300);
JLabel label = new JLabel("已选择");
label.setBounds(20, 310, 60, 25);
text = new JTextField();
if (selectOld != null) {
text.setText(selectOld.getProperty("object_name"));
}
text.setEditable(false);
text.setBounds(100, 310, 180, 25);
JButton ok = new JButton("确定");
ok.addActionListener(doOK(dialog, session, latestRev, newItemId));
ok.setBounds(40, 350, 100, 25);
JButton cancel = new JButton("取消");
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dialog.dispose();
}
});
cancel.setBounds(160, 350, 100, 25);
root.add(jsp);
root.add(label);
root.add(text);
root.add(ok);
root.add(cancel);
dialog.add(root);
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
initMenu(session);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.getMessage(), "错误 ", JOptionPane.ERROR_MESSAGE);
}
}
};
new Thread(runnable).start();
return null;
}
private void initMenu(TCSession session) throws Exception, TCException {
TCComponent[] home = session.search("General...", new String[] { "类型", "所有权用户" },
new String[] { "Home 文件夹", session.getUser().getProperty("object_string") });
JTree tree = getTree((TCComponentFolder) home[0]);
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
// TODO Auto-generated method stub
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getNewLeadSelectionPath()
.getLastPathComponent();
select = (TCComponentFolder) node.getUserObject();
text.setText(node.toString());
root.revalidate();
root.repaint();
}
});
root.remove(jsp);
jsp = new JScrollPane(tree);
jsp.setBounds(0, 0, 300, 300);
root.add(jsp);
root.revalidate();
root.repaint();
dialog.pack();
}
private ActionListener doOK(JDialog dialog, TCSession session, TCComponentItemRevision latestRev, String newItemId)
throws TCException {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
TCComponentItem newItem = null;
try {
session.getUserService().call("bs_bypass", new Object[] { true });
newItem = latestRev.saveAsItem(newItemId, null);
if (selectOld != null && select == null) {
selectOld.add("contents", newItem);
} else if (select != null) {
select.add("contents", newItem);
File selectFile = new File(System.getenv("temp") + File.separator + "select_folder_"
+ session.getUser().getUid() + ".txt");
selectFile.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(selectFile));
writer.write(select.getUid());
writer.close();
// TCPreferenceService service = session.getPreferenceService();
// service.setStringValue("jd2_folder_select", select.getUid());
} else {
return;
}
} catch (TCException | IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
final TCComponentItem clipContent = newItem;
Transferable transferable = new Transferable() {
@Override
public boolean isDataFlavorSupported(DataFlavor paramDataFlavor) {
// TODO Auto-generated method stub
return true;
}
@Override
public DataFlavor[] getTransferDataFlavors() {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getTransferData(DataFlavor paramDataFlavor)
throws UnsupportedFlavorException, IOException {
// TODO Auto-generated method stub
Vector<TCComponent> components = new Vector<TCComponent>();
components.add(clipContent);
return components;
}
};
AIFPortal.getClipboard().setContents(transferable, null);
try {
session.getUserService().call("bs_bypass", new Object[] { false });
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
dialog.dispose();
JOptionPane.showMessageDialog(null, "另存为成功", "提示", JOptionPane.WARNING_MESSAGE);
}
};
}
private JTree getTree(TCComponentFolder folder) {
DefaultMutableTreeNode root;
try {
root = new DefaultMutableTreeNode(folder.getProperty("object_name"));
root.setUserObject(folder);
DefaultMutableTreeNode parent = root;
DefaultTreeModel treeModel = new DefaultTreeModel(root);
initTree(folder, parent, treeModel);
JTree tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
cellRenderer.setTextNonSelectionColor(Color.black);
cellRenderer.setTextSelectionColor(Color.blue);
return tree;
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new JTree();
}
private void initTree(TCComponentFolder folder, DefaultMutableTreeNode parent, DefaultTreeModel treeModel)
throws TCException {
TCComponent[] comps = folder.getRelatedComponents("contents");
if (comps.length == 0) {
return;
}
for (TCComponent comp : comps) {
if (comp instanceof TCComponentFolder) {
DefaultMutableTreeNode temp = new DefaultMutableTreeNode(comp.getProperty("object_name"));
temp.setUserObject(comp);
treeModel.insertNodeInto(temp, parent, parent.getChildCount());
initTree((TCComponentFolder) comp, temp, treeModel);
}
}
}
}

@ -0,0 +1,78 @@
package cn.com.origin.autocode.jfom.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
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.CreateResponse;
public class TCTableUtil {
public static String[][] getTableRows(TCComponentForm form, String prop, String[] colNames) {
try {
TCProperty tcProperty = form.getTCProperty(prop);
TCComponent[] components = tcProperty.getReferenceValueArray();
String[][] res = new String[components.length][colNames.length];
for (int i = 0; i < components.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) {
res[i][ii] = components[i].getPropertyDisplayableValue(colNames[ii]);
}
}
return res;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static boolean setTableRows(TCComponentForm form, String prop, String refName, String[] colNames,
String[][] rows) {
List<TCComponent> list = new ArrayList<TCComponent>();
DataManagementService service = DataManagementService
.getService((TCSession) AIFUtility.getCurrentApplication().getSession());
CreateIn ci = new CreateIn();
ci.data.boName = refName;
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < rows.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) {
map.put(colNames[ii], rows[i][ii]);
}
System.out.println(map.size());
ci.data.stringProps = map;
try {
CreateResponse response = service.createObjects(new CreateIn[] { ci });
System.out.println("CreateResponse size:" + response.serviceData.sizeOfCreatedObjects());
if (response.serviceData.sizeOfCreatedObjects() > 0) {
list.add(response.output[0].objects[0]);
} else {
String str = String.join(",", response.serviceData.getPartialError(0).getMessages());
System.out.println(str);
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
form.getTCProperty(prop).setReferenceValueArray(list.toArray(new TCComponent[list.size()]));
System.out.println("±£´ætable³É¹¦");
return true;
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}

@ -23,8 +23,11 @@ public class CNClassPropBean {
public int floatsize = 0;
public String formate;
public String must = "";
public CNClassPropBean(ICSAdminClassAttribute icsAttr) {
// System.out.println("attr id :"+icsAttr.getAttributeId()+" attr naem :"+icsAttr.getName());
// System.out.println("attr id :"+icsAttr.getAttributeId()+" attr naem
// :"+icsAttr.getName());
this.icsAttr = icsAttr;
this.propID = icsAttr.getAttributeId();
this.propDisName = icsAttr.getName();
@ -58,4 +61,21 @@ public class CNClassPropBean {
return propDisName + ":";
}
public void setUserLov(String options) {
this.isLov = true;
lovMapping = new HashMap<>();
keyList = new ArrayList<>();
String[] arr = options.split(",");
for (String key : arr) {
lovMapping.put(key, key);
keyList.add(key);
}
lovMapping.put("", "");
keyList.add("");
}
public void setMust(boolean isMust) {
this.must = isMust ? "(±ØÌî)" : "";
}
}

@ -0,0 +1,38 @@
package cn.com.origin.autocode.newitem.generatcode;
import java.util.ArrayList;
import java.util.List;
public class CustomLovBean {
private List<CustomLovBean> sub = new ArrayList<CustomLovBean>();
public String displayName = "";
public CustomLovBean(String displayName) {
super();
this.displayName = displayName;
}
public CustomLovBean(String displayName, String[] subArray) {
super();
this.displayName = displayName;
translateArrayToSub(subArray);
}
public void translateArrayToSub(String[] subArray) {
for (int i = 0; i < subArray.length; i++) {
sub.add(new CustomLovBean(subArray[i]));
}
}
public List<CustomLovBean> getSub() {
return sub;
}
public boolean hasChild() {
return sub.size() != 0;
}
public void addSub(CustomLovBean clb) {
sub.add(clb);
}
}

@ -1,6 +1,10 @@
package cn.com.origin.autocode.newitem.generatcode;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
@ -38,8 +42,9 @@ public class ShowLovDialog extends Dialog {
private String msg;
private Point p;
private Text text;
private TCComponentListOfValues lov;
private Object lov;
private String data;
private TreeItem selectedItem;
/**
* Create the dialog.
@ -47,8 +52,7 @@ public class ShowLovDialog extends Dialog {
* @param parent
* @param style
*/
public ShowLovDialog(Shell parent, int style, String msg, Object data,
Point p, TCComponentListOfValues lov) {
public ShowLovDialog(Shell parent, int style, String msg, Object data, Point p, TCComponentListOfValues lov) {
super(parent, style);
this.msg = msg;
@ -59,6 +63,17 @@ public class ShowLovDialog extends Dialog {
}
}
public ShowLovDialog(Shell parent, int style, String msg, Object data, Point p, CustomLovBean customLov) {
super(parent, style);
this.msg = msg;
this.p = p;
this.lov = customLov;
if (data != null) {
this.data = data.toString();
}
}
/**
* Open the dialog.
*
@ -103,8 +118,7 @@ public class ShowLovDialog extends Dialog {
}
treeItem0.setText(disPlayv);
treeItem0.setData(v);
TCComponentListOfValues cLov = lov
.getListOfFilterOfValue(v);
TCComponentListOfValues cLov = lov.getListOfFilterOfValue(v);
if (cLov != null) {
initLovTree(treeItem0, cLov);
}
@ -117,6 +131,32 @@ public class ShowLovDialog extends Dialog {
}
private void initLovTree(Widget lovTree, CustomLovBean lov) {
if (lov != null) {
List<CustomLovBean> subs = lov.getSub();
for (CustomLovBean clb : subs) {
String disPlayv = clb.displayName;
if (msg != null && disPlayv.equals(msg)) {
data = disPlayv;
}
TreeItem treeItem0 = null;
if (lovTree instanceof Tree) {
treeItem0 = new TreeItem((Tree) lovTree, 0);
} else {
treeItem0 = new TreeItem((TreeItem) lovTree, 0);
}
treeItem0.setText(disPlayv);
treeItem0.setData(disPlayv);
if (clb.hasChild()) {
initLovTree(treeItem0, clb);
}
}
}
}
/**
* Create contents of the dialog.
*/
@ -124,23 +164,42 @@ public class ShowLovDialog extends Dialog {
shell = new Shell(getParent(), getStyle());
shell.setSize(335, 281);
shell.setBounds(p.x, p.y, 330, 270);
OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, p.x, p.y, 330, 270,
SWT.NULL);
OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, p.x, p.y, 330, 270, SWT.NULL);
shell.setText(getText());
lovTree = new Tree(shell, SWT.BORDER);
lovTree.setBounds(10, 10, 304, 168);
// initTree();
initLovTree(lovTree, this.lov);
if (lov instanceof CustomLovBean) {
initLovTree(lovTree, (CustomLovBean) this.lov);
} else {
initLovTree(lovTree, (TCComponentListOfValues) this.lov);
}
lovTree.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
selectedItem = (TreeItem) event.item;
System.out.println(selectedItem.getParent() == null ? "not Parent" : "yes Parent");
System.out.println(selectedItem.getParentItem() == null ? "not ParentItem" : "yes ParentItem");
System.out.println("selectedItem.getItemCount()====>" + selectedItem.getItemCount());
if (event.detail == SWT.CHECK) {
text.setText(((TreeItem) event.item).getText());
data = ((TreeItem) event.item).getData().toString();
text.setText(selectedItem.getText());
data = selectedItem.getData().toString();
} else {
text.setText(((TreeItem) event.item).getText());
data = ((TreeItem) event.item).getData().toString();
text.setText(selectedItem.getText());
data = selectedItem.getData().toString();
}
}
});
lovTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if (selectedItem.getItemCount() == 0) {
result.value = text.getText();
result.key = data;
shell.dispose();
}
}
});
@ -150,10 +209,12 @@ public class ShowLovDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
if (selectedItem.getItemCount() == 0) {
result.value = text.getText();
result.key = data;
shell.dispose();
}
}
});
btnNewButton.setBounds(38, 228, 80, 27);
btnNewButton.setText("È·¶¨");

@ -1,13 +1,9 @@
package cn.com.origin.autocode.newitem.generatcode;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import org.apache.james.mime4j.codec.EncoderUtil;
import com.alibaba.fastjson.JSON;
import net.sf.json.JSONObject;
import cn.com.origin.autocode.xmlutil.ExcelInfoScanner;
public class Test {
@ -16,46 +12,20 @@ public class Test {
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] ids = new int[] { 1006 };
String[] values = new String[] { "ZF01" };
ClassficationBean cfb = new ClassficationBean(ids, values);
// String str = com.alibaba.fastjson.JSONObject.toJSONString(cfb);
JSONObject obj = new JSONObject();
obj.put("ids", ids);
obj.put("values", values);
String url = EncoderUtil.encodeAddressDisplayName(JSON.toJSONString(cfb));
url = url.substring(1, url.length() - 1);
url = URLEncoder.encode(url);
url = "http://localhost:8080/classification?prop=" + url;
System.out.println(url);
System.out.println(URLDecoder.decode(url));
}
static class ClassficationBean {
int[] ids;
String[] values;
ClassficationBean(int[] ids, String[] values) {
this.ids = ids;
this.values = values;
Map<String, CustomLovBean> map = ExcelInfoScanner
.getGeneralPropMutiLovInfo("C:\\Users\\5rKB5bPlusD\\Desktop\\testLov.xlsx", "波轮洗衣机图纸");
// new Test().getinfo(bean);
}
public int[] getIds() {
return ids;
public void getinfo(CustomLovBean bean) {
if (!bean.hasChild()) {
return;
}
public void setIds(int[] ids) {
this.ids = ids;
List<CustomLovBean> list = bean.getSub();
for (CustomLovBean clb : list) {
System.out.println(clb.displayName);
getinfo(clb);
}
public String[] getValues() {
return values;
}
public void setValues(String[] values) {
this.values = values;
}
}
}

@ -0,0 +1,99 @@
package cn.com.origin.autocode.xmlutil;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.aspose.cells.Cells;
import com.aspose.cells.License;
import com.aspose.cells.Workbook;
import com.aspose.cells.WorksheetCollection;
import cn.com.origin.autocode.newitem.generatcode.CustomLovBean;
public class ExcelInfoScanner {
public static Map<Integer, String> getClassPropOptions(String path, String nodeName) {
Map<Integer, String> res = new HashMap<Integer, String>();
try {
getLicense();
Workbook excel = new Workbook(path);
WorksheetCollection wc = excel.getWorksheets();
Cells cells = wc.get(0).getCells();
for (int i = 0; i <= cells.getMaxDataRow(); i++) {
if (cells.get(i, 0).getStringValue().equals(nodeName)) {
res.put(cells.get(i, 1).getIntValue(), cells.get(i, 2).getStringValue());
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res;
}
public static Map<String, CustomLovBean> getGeneralPropMutiLovInfo(String path, String nodeName) {
Map<String, CustomLovBean> map = new HashMap<String, CustomLovBean>();
try {
getLicense();
Workbook excel = new Workbook(path);
WorksheetCollection wc = excel.getWorksheets();
Cells cells = wc.get(0).getCells();
for (int i = 0; i <= cells.getMaxDataRow(); i++) {
CustomLovBean customLov = new CustomLovBean("Ñ¡Ôñ");
if (cells.get(i, 0).getStringValue().equals(nodeName)) {
getLovSubInfo(customLov, cells, i, 2);
map.put(cells.get(i, 1).getStringValue(), customLov);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return map;
}
private static int getLovSubInfo(CustomLovBean customLov, Cells cells, int rowIndex, int columnIndex) {
int oldIndex = rowIndex;
int offset = 0;
do {
CustomLovBean clb = new CustomLovBean(cells.get(rowIndex, columnIndex).getStringValue());
System.out.println(clb.displayName);
customLov.addSub(clb);
if (!"".equals(cells.get(rowIndex, columnIndex + 1).getStringValue())) {
offset = getLovSubInfo(clb, cells, rowIndex, columnIndex + 1);
}
// System.out.println(offset);
// System.out.println(rowIndex);
rowIndex = rowIndex + offset + 1;
offset = 0;
// System.out.println(rowIndex);
} while (!"".equals(cells.get(rowIndex, columnIndex).getStringValue())
&& "".equals(cells.get(rowIndex, columnIndex - 1).getStringValue()));
return rowIndex - oldIndex - 1;
}
public static boolean getLicense() throws Exception {
boolean result = false;
try {
InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml");
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
is.close();
} catch (Exception e) {
e.printStackTrace(System.out);
throw e;
}
return result;
}
public static void main(String[] args) {
Map<Integer, String> res = ExcelInfoScanner.getClassPropOptions("C:\\Users\\5rKB5bPlusD\\Desktop\\zh_cn.xlsx",
"ÎïÁÏ");
for (Entry<Integer, String> entry : res.entrySet()) {
System.out.println(entry.getKey() + "," + entry.getValue());
}
}
}

@ -0,0 +1,49 @@
package cn.com.origin.autocode.xmlutil;
import java.io.InputStream;
import com.aspose.cells.Cells;
import com.aspose.cells.License;
import com.aspose.cells.Workbook;
import com.aspose.cells.WorksheetCollection;
public class TranslateEnglish {
public static String getEnglish(String path, String value) {
try {
getLicense();
Workbook excel = new Workbook(path);
WorksheetCollection wc = excel.getWorksheets();
Cells cells = wc.get(0).getCells();
for (int i = 0; i <= cells.getMaxDataRow(); i++) {
if (cells.get(i, 0).getStringValue().equals(value)) {
return cells.get(i, 1).getStringValue();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static boolean getLicense() throws Exception {
boolean result = false;
try {
InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml");
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
is.close();
} catch (Exception e) {
e.printStackTrace(System.out);
throw e;
}
return result;
}
public static void main(String[] args) {
String res = TranslateEnglish.getEnglish("C:\\Users\\5rKB5bPlusD\\Desktop\\zh_cn.xlsx", "ÎïÁÏ");
System.out.println("½á¹û£º" + res);
}
}
Loading…
Cancel
Save