zouxk 5 years ago
parent 328e4a597f
commit 0ad04b794a

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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/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/antlr-2.7.7.jar"/>
<classpathentry exported="true" kind="lib" path="axis2_lib/apache-mime4j-core-0.7.2.jar"/> <classpathentry exported="true" kind="lib" path="axis2_lib/apache-mime4j-core-0.7.2.jar"/>
@ -79,6 +80,7 @@
<classpathentry kind="lib" path="json_lib/fastjson-1.2.9-sources.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="json_lib/fastjson-1.2.9.jar"/>
<classpathentry kind="lib" path="axis2_lib/hutool-all-5.0.7.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.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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>

@ -913,4 +913,6 @@ Bundle-ClassPath: json_lib/commons-beanutils-1.7.0.jar,
json_lib/fastjson-1.2.9-javadoc.jar, json_lib/fastjson-1.2.9-javadoc.jar,
json_lib/fastjson-1.2.9-sources.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 axis2_lib/hutool-all-5.0.7.jar,
aspose/aspose-cells-18.9.jar,
db_lib/ojdbc6.jar

@ -81,4 +81,6 @@ bin.includes = META-INF/,\
json_lib/fastjson-1.2.9-javadoc.jar,\ json_lib/fastjson-1.2.9-javadoc.jar,\
json_lib/fastjson-1.2.9-sources.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 axis2_lib/hutool-all-5.0.7.jar,\
aspose/aspose-cells-18.9.jar,\
db_lib/ojdbc6.jar

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

@ -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; package cn.com.origin.autocode.handlers;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import org.eclipse.core.commands.AbstractHandler;
import com.teamcenter.rac.commands.genericsaveas.ISaveAsService; import org.eclipse.core.commands.ExecutionEvent;
import com.teamcenter.rac.common.Activator; import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.kernel.*;
import com.teamcenter.rac.ui.commands.handlers.SaveASHandler; import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.util.*; import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.util.wizard.extension.*; import com.teamcenter.rac.util.MessageBox;
import java.text.MessageFormat;
import org.apache.log4j.Logger; import cn.com.origin.autocode.saveas.ORSaveAsCommand;
import org.eclipse.core.commands.*; import cn.com.origin.autocodemanager.common.TCPreferenceUitl;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection; public class ORItemSaveAsHandler extends AbstractHandler {
import org.eclipse.jface.wizard.Wizard; @Override
import org.eclipse.jface.wizard.WizardDialog; public Object execute(ExecutionEvent arg0) throws ExecutionException {
import org.eclipse.swt.widgets.Shell; // AbstractAIFUIApplication abstractAIFUIApplication =
import org.eclipse.ui.IWorkbenchWindow; // AIFUtility.getCurrentApplication();
import org.eclipse.ui.handlers.HandlerUtil; // new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(),
// "SJ3_ZXCPPRT").open();
public class ORItemSaveAsHandler extends AbstractHandler
{ // new SaveAsCommand(AIFDesktop.getFrames()[0],
private class CreateSaveAsDialog // AIFUtility.getCurrentApplication().getTargetComponents(), true).run();
implements Runnable ORSaveAsCommand orSaveAsCommand = new ORSaveAsCommand(AIFDesktop.getFrames()[0],
{ AIFUtility.getCurrentApplication().getTargetComponents(), true);
try {
public void run() if (orSaveAsCommand != null)
{ orSaveAsCommand.executeModal();
BaseExternalWizard baseexternalwizard = getWizard(); } catch (Exception exception) {
if(baseexternalwizard != null) MessageBox.post(AIFDesktop.getFrames()[0], exception);
{ }
baseexternalwizard.setForcePreviousAndNextButtons(true); return null;
ISaveAsService isaveasservice =(ISaveAsService)OSGIUtil.getService(Activator.getDefault(), ISaveAsService.class); }
if(isaveasservice != null)
{ @Override
isaveasservice.setInput((TCComponent)m_selectedCmp); public boolean isEnabled() {
baseexternalwizard.setWindowTitle(getWizardTitle()); if (TCPreferenceUitl.isWriteExpire()) {
baseexternalwizard.setContext(new StructuredSelection(m_selectedCmp)); return false;
Shell shell = UIUtilities.getCurrentModalShell(); } else {
BaseExternalWizardDialog baseexternalwizarddialog = new BaseExternalWizardDialog(shell, baseexternalwizard); return true;
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")){
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);
}
}
}
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;
}
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 * DECOMPILATION REPORT
*
Decompiled from: C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.ui.commands_11000.2.0.jar * Decompiled from:
Total time: 29 ms * C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.ui.
Jad reported messages/errors: * commands_11000.2.0.jar Total time: 29 ms Jad reported messages/errors: Exit
Exit status: 0 * status: 0 Caught exceptions:
Caught exceptions: */
*/

@ -0,0 +1,322 @@
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);
}
}
}
}

@ -23,8 +23,11 @@ public class CNClassPropBean {
public int floatsize = 0; public int floatsize = 0;
public String formate; public String formate;
public String must = "";
public CNClassPropBean(ICSAdminClassAttribute icsAttr) { 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.icsAttr = icsAttr;
this.propID = icsAttr.getAttributeId(); this.propID = icsAttr.getAttributeId();
this.propDisName = icsAttr.getName(); this.propDisName = icsAttr.getName();
@ -58,4 +61,21 @@ public class CNClassPropBean {
return propDisName + ":"; 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);
}
}

@ -9,6 +9,7 @@ package cn.com.origin.autocode.newitem.generatcode;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -22,6 +23,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
@ -95,6 +97,8 @@ import com.teamcenter.rac.kernel.ics.ICSFormat;
import com.teamcenter.rac.kernel.ics.ICSProperty; import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.kernel.ics.ICSSearchResult; import com.teamcenter.rac.kernel.ics.ICSSearchResult;
import com.teamcenter.rac.kernel.ics.ICSView; import com.teamcenter.rac.kernel.ics.ICSView;
import com.teamcenter.rac.util.ConfirmDialog;
import com.teamcenter.rac.util.ConfirmationDialog;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PlatformHelper; import com.teamcenter.rac.util.PlatformHelper;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
@ -122,6 +126,8 @@ import cn.com.origin.autocode.xmlutil.CNPart;
import cn.com.origin.autocode.xmlutil.CNPartList; import cn.com.origin.autocode.xmlutil.CNPartList;
import cn.com.origin.autocode.xmlutil.CNProperty; import cn.com.origin.autocode.xmlutil.CNProperty;
import cn.com.origin.autocode.xmlutil.CNXmlUtil; import cn.com.origin.autocode.xmlutil.CNXmlUtil;
import cn.com.origin.autocode.xmlutil.ExcelInfoScanner;
import cn.com.origin.autocode.xmlutil.TranslateEnglish;
import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName;
import cn.com.origin.autocodemanager.common.CreateCompositeUtil; import cn.com.origin.autocodemanager.common.CreateCompositeUtil;
import cn.com.origin.autocodemanager.common.PackCodeDescInfos; import cn.com.origin.autocodemanager.common.PackCodeDescInfos;
@ -135,7 +141,8 @@ import cn.com.origin.autocodemanager.common.tree.AbstractTreeData;
import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; import cn.com.origin.autocodemanager.common.tree.TreeViewOperation;
import cn.com.origin.autocodemanager.views.listcodeview.NewItemListCodeView; import cn.com.origin.autocodemanager.views.listcodeview.NewItemListCodeView;
import cn.com.origin.autocodemanager.views.treecodeview.NewItemTreeCodeView; import cn.com.origin.autocodemanager.views.treecodeview.NewItemTreeCodeView;
import net.sf.json.JSONObject; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
public class NewCodeItemDialog extends Dialog { public class NewCodeItemDialog extends Dialog {
private Table propTable; private Table propTable;
@ -257,6 +264,11 @@ public class NewCodeItemDialog extends Dialog {
private String ys = null; private String ys = null;
private String cz = null; private String cz = null;
private String xh = null; private String xh = null;
private String nodeName;
private String rootNodeName;
private Map<String, String> classMustMap = new HashMap<String, String>();
private TCComponentItemRevision gltz;
private TCComponentItemRevision glwl;
public Text getIdLengthText() { public Text getIdLengthText() {
return idLengthText; return idLengthText;
@ -455,7 +467,7 @@ public class NewCodeItemDialog extends Dialog {
@Override @Override
public void controlResized(ControlEvent e) { public void controlResized(ControlEvent e) {
Point r = classPropComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point r = classPropComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
classSrolledComposite.setMinSize(classSrolledComposite.computeSize(r.x, r.y)); classSrolledComposite.setMinSize(classSrolledComposite.computeSize(r.x, r.y + 200));
} }
}); });
classPropTab.setControl(classCompsite); classPropTab.setControl(classCompsite);
@ -487,6 +499,19 @@ public class NewCodeItemDialog extends Dialog {
if (classID == null || classID.replace(" ", "").equals("")) { if (classID == null || classID.replace(" ", "").equals("")) {
return; return;
} }
// 获取分类属性自定义下拉选择
String uid = getPrefStr("jd_class_prop_option");
TCComponent comp = null;
try {
comp = session.stringToComponent(uid);
} catch (TCException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
TCComponentDataset op = null;
Map<Integer, String> propOption = null;
try { try {
if (session == null) { if (session == null) {
session = (TCSession) AIFUtility.getCurrentApplication().getSession(); session = (TCSession) AIFUtility.getCurrentApplication().getSession();
@ -502,6 +527,16 @@ public class NewCodeItemDialog extends Dialog {
ICSAdminClassAttribute[] icsAttrS = adminClass.getAttributes(); ICSAdminClassAttribute[] icsAttrS = adminClass.getAttributes();
if (icsAttrS != null) { if (icsAttrS != null) {
// 分类属性自定义下拉框选择项
if (comp != null) {
op = (TCComponentDataset) comp;
String temp = System.getenv("temp");
String[] types = op.getProperty("ref_names").split(",");
File optionFile = op.getFiles(types[0], temp)[0];
optionFile.deleteOnExit();
propOption = ExcelInfoScanner.getClassPropOptions(optionFile.getPath(), rootNodeName);
}
for (ICSAdminClassAttribute attr : icsAttrS) { for (ICSAdminClassAttribute attr : icsAttrS) {
if (attr.isReferenceAttribute()) { if (attr.isReferenceAttribute()) {
continue; continue;
@ -510,8 +545,23 @@ public class NewCodeItemDialog extends Dialog {
continue; continue;
} }
CNClassPropBean bean = new CNClassPropBean(attr); CNClassPropBean bean = new CNClassPropBean(attr);
// 分类属性增加自定义下拉框
if (op != null) {
String options = propOption.get(bean.propID);
System.out.println(bean.propDisName + "选项:" + options);
if (options != null && !"".equals(options)) {
bean.setUserLov(options);
}
}
// 设置分类属性必填
if (classMustMap.get(rootNodeName) != null
&& classMustMap.get(rootNodeName).contains(bean.propID + "")) {
bean.setMust(true);
}
classPropList.add(bean); classPropList.add(bean);
Label label = CreateCompositeUtil.createNewLabel(classPropComposite, bean.propDisName); Label label = CreateCompositeUtil.createNewLabel(classPropComposite, bean.propDisName + bean.must);
label.getParent().layout(); label.getParent().layout();
classLabelList.add(label); classLabelList.add(label);
Widget widget = null; Widget widget = null;
@ -641,13 +691,68 @@ public class NewCodeItemDialog extends Dialog {
generalPropLabelList.clear(); generalPropLabelList.clear();
generalPropTextList.clear(); generalPropTextList.clear();
// 对象属性多级下拉框获取配置
String uid = getPrefStr("jd2_general_muti_lov");
File mutiSetting = null;
try {
TCComponent comp = session.stringToComponent(uid);
if (comp != null) {
TCComponentDataset muti = (TCComponentDataset) comp;
String temp = System.getenv("temp");
String[] types = muti.getProperty("ref_names").split(",");
mutiSetting = muti.getFiles(types[0], temp)[0];
mutiSetting.deleteOnExit();
}
} catch (TCException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
if (this.cnpropList != null) { if (this.cnpropList != null) {
Map<String, CustomLovBean> settingMap = new HashMap<String, CustomLovBean>();
if (mutiSetting != null) {
settingMap = ExcelInfoScanner.getGeneralPropMutiLovInfo(mutiSetting.getPath(), rootNodeName);
}
for (CNProperty cnProp : this.cnpropList) { for (CNProperty cnProp : this.cnpropList) {
Label label = CreateCompositeUtil.createNewLabel(objPropComposite, Label label = CreateCompositeUtil.createNewLabel(objPropComposite,
cnProp.getIsMust() ? (cnProp.getDisplayName() + "(必填)") : cnProp.getDisplayName()); cnProp.getIsMust() ? (cnProp.getDisplayName() + "(必填)") : cnProp.getDisplayName());
generalPropLabelList.add(label); generalPropLabelList.add(label);
Widget widget = null; Widget widget = null;
if (settingMap.containsKey(cnProp.getDisplayName())) {
final CustomLovBean lovBean = settingMap.get(cnProp.getDisplayName());
final Button comb = CreateCompositeUtil.createButton(objPropComposite, cnProp.getDefaultValue(), 20,
240);
comb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Point p = objPropComposite.toDisplay(((Button) e.getSource()).getLocation());
ShowLovDialog dialog = new ShowLovDialog(objPropComposite.getShell(), SWT.NONE,
comb.getText(), comb.getData(), p, lovBean);
((Button) e.getSource()).setEnabled(false);
Object resault = dialog.open();
((Button) e.getSource()).setEnabled(true);
if (resault != null && resault instanceof LovKeyValue
&& ((LovKeyValue) resault).value != null) {
LovKeyValue kv = (LovKeyValue) resault;
((Button) e.getSource()).setData(kv.key);
((Button) e.getSource()).setText(kv.value);
System.out.println("LOV=>KEY>" + kv.key + "|VALUE=>V>" + kv.value);
} else {
((Button) e.getSource()).setData("");
((Button) e.getSource()).setText("");
System.out.println("LovKeyValue NULL");
}
}
});
widget = comb; // Combo(propTable, // SWT.NONE);
comb.setText(cnProp.getDefaultValue());
generalPropTextList.add(widget);
continue;
}
if (!cnProp.getIsLov()) { if (!cnProp.getIsLov()) {
if (cnProp.getPropertyType().toUpperCase().equals("STRING")) { if (cnProp.getPropertyType().toUpperCase().equals("STRING")) {
final Text text = CreateCompositeUtil.createNewText(objPropComposite, cnProp.getDefaultValue()); final Text text = CreateCompositeUtil.createNewText(objPropComposite, cnProp.getDefaultValue());
@ -683,7 +788,7 @@ public class NewCodeItemDialog extends Dialog {
widget = text; widget = text;
} else if (cnProp.getPropertyType().toUpperCase().equals("BOOLEAN")) { } else if (cnProp.getPropertyType().toUpperCase().equals("BOOLEAN")) {
final Combo comb = CreateCompositeUtil.createNotFillNewCombo(objPropComposite, final Combo comb = CreateCompositeUtil.createNotFillNewCombo(objPropComposite,
new String[] { "true", "false" }); // new new String[] { "true", "false", "" }); // new
comb.setText(cnProp.getDefaultValue()); // Combo(propTable, comb.setText(cnProp.getDefaultValue()); // Combo(propTable,
widget = comb; // SWT.NONE); widget = comb; // SWT.NONE);
} }
@ -728,6 +833,8 @@ public class NewCodeItemDialog extends Dialog {
((Button) e.getSource()).setText(kv.value); ((Button) e.getSource()).setText(kv.value);
System.out.println("LOV=>KEY>" + kv.key + "|VALUE=>V>" + kv.value); System.out.println("LOV=>KEY>" + kv.key + "|VALUE=>V>" + kv.value);
} else { } else {
((Button) e.getSource()).setData("");
((Button) e.getSource()).setText("");
System.out.println("LovKeyValue NULL"); System.out.println("LovKeyValue NULL");
} }
@ -736,8 +843,11 @@ public class NewCodeItemDialog extends Dialog {
widget = comb; // Combo(propTable, // SWT.NONE); widget = comb; // Combo(propTable, // SWT.NONE);
comb.setText(cnProp.getDefaultValue()); comb.setText(cnProp.getDefaultValue());
} else { } else {
final Combo comb = CreateCompositeUtil.createNotFillNewCombo(objPropComposite, String[] items = cnProp.lovDisplayValueList
cnProp.lovDisplayValueList.toArray(new String[cnProp.lovDisplayValueList.size()])); .toArray(new String[cnProp.lovDisplayValueList.size()]);
String[] newItems = Arrays.copyOf(items, items.length + 1);
newItems[newItems.length - 1] = "";
final Combo comb = CreateCompositeUtil.createNotFillNewCombo(objPropComposite, newItems);
// new // new
widget = comb; // Combo(propTable, // SWT.NONE); widget = comb; // Combo(propTable, // SWT.NONE);
comb.setText(cnProp.getDefaultValue()); comb.setText(cnProp.getDefaultValue());
@ -1023,6 +1133,7 @@ public class NewCodeItemDialog extends Dialog {
*/ */
@Override @Override
protected Control createDialogArea(Composite parent) { protected Control createDialogArea(Composite parent) {
// 获取首选项中的配置 // 获取首选项中的配置
propBeanList = JFomMethodUtil.getTcPropInfo(JFomUtil.ITEM_TYPE_PROP_MAPPING_REF, session); propBeanList = JFomMethodUtil.getTcPropInfo(JFomUtil.ITEM_TYPE_PROP_MAPPING_REF, session);
propMapping = JFomMethodUtil.getMapping(JFomUtil.FORM_TYPE_PROP_MAPPING, session); propMapping = JFomMethodUtil.getMapping(JFomUtil.FORM_TYPE_PROP_MAPPING, session);
@ -1291,6 +1402,12 @@ public class NewCodeItemDialog extends Dialog {
CreateCompositeUtil.createNewLabel(composite, "特征码长度"); CreateCompositeUtil.createNewLabel(composite, "特征码长度");
idLengthText = CreateCompositeUtil.createNewText(composite, ""); idLengthText = CreateCompositeUtil.createNewText(composite, "");
// 读取分类必填属性
String[] prefStrArray = getPrefStrArray("jd_class_prop_must");
for (String str : prefStrArray) {
classMustMap.put(str.split("/")[0], str.split("/")[1]);
}
// ===JY 2017.01.09==== // ===JY 2017.01.09====
GridLayout gridLayout2 = new GridLayout(); GridLayout gridLayout2 = new GridLayout();
gridLayout2.numColumns = 4; gridLayout2.numColumns = 4;
@ -1308,6 +1425,11 @@ public class NewCodeItemDialog extends Dialog {
nameText = CreateCompositeUtil.createNewText(composite, ""); nameText = CreateCompositeUtil.createNewText(composite, "");
// 如果选中的对象是图纸类型,名称就复制 // 如果选中的对象是图纸类型,名称就复制
TCComponent targetObject = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); TCComponent targetObject = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent();
if (targetObject == null) {
MessageBox.post("未选择目标,请选择后再进行创建", "错误", MessageBox.ERROR);
this.close();
return;
}
if (targetObject instanceof TCComponentItemRevision) { if (targetObject instanceof TCComponentItemRevision) {
TCComponentItemRevision design = (TCComponentItemRevision) targetObject; TCComponentItemRevision design = (TCComponentItemRevision) targetObject;
try { try {
@ -1321,7 +1443,7 @@ public class NewCodeItemDialog extends Dialog {
if (TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_newItem_isShowUnit)) { if (TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_newItem_isShowUnit)) {
try { try {
CreateCompositeUtil.createNewLabel(composite, "量单位"); CreateCompositeUtil.createNewLabel(composite, "基本计量单位");
TCComponentListOfValues listOfValues = TCLOVUtil.findLOVByName(session, unitLOVName); TCComponentListOfValues listOfValues = TCLOVUtil.findLOVByName(session, unitLOVName);
ListOfValuesInfo listOfValuesInfo = listOfValues.getListOfValues(); ListOfValuesInfo listOfValuesInfo = listOfValues.getListOfValues();
String[] values = listOfValuesInfo.getLOVDisplayValues(); String[] values = listOfValuesInfo.getLOVDisplayValues();
@ -1865,6 +1987,12 @@ public class NewCodeItemDialog extends Dialog {
if ((selectedData.getPackCodeNodeInfo().is_lock)) { if ((selectedData.getPackCodeNodeInfo().is_lock)) {
return; return;
} }
objPropComposite.setVisible(true);
if (selectedData.getPackCodeNodeInfo().isContainsChildren()) {
objPropComposite.setVisible(false);
return;
}
String currentNodeDesc = ""; String currentNodeDesc = "";
String currentNodeValue = ""; String currentNodeValue = "";
String name = ""; String name = "";
@ -1915,6 +2043,7 @@ public class NewCodeItemDialog extends Dialog {
} else { } else {
nameText.setText(""); nameText.setText("");
} }
getFinalPattern(); getFinalPattern();
// idText.setText(pattern); // idText.setText(pattern);
idText.setText(finalPattern); idText.setText(finalPattern);
@ -1931,6 +2060,32 @@ public class NewCodeItemDialog extends Dialog {
// = // =
// >"+msg,"INFO",MessageBox.ERROR); // >"+msg,"INFO",MessageBox.ERROR);
// 填写英文名称
try {
for (int i = 0; i < classLabelList.size(); i++) {
String text = classLabelList.get(i).getText();
System.out.println(text);
if ("英文名称:".equals(text)) {
String uid = getPrefStr("jd_chinese_to_english");
TCComponentDataset en = (TCComponentDataset) session.stringToComponent(uid);
String temp = System.getenv("temp");
String[] types = en.getProperty("ref_names").split(",");
File englishFile = en.getFiles(types[0], temp)[0];
String res = TranslateEnglish.getEnglish(englishFile.getPath(), nodeName);
System.out.println("当前选择节点中文名称:" + nodeName);
System.out.println("当前选择节点英文名称:" + res);
if (res != null) {
// Text englishText = CreateCompositeUtil.createNewText(classPropComposite,
// res);
((Text) classTextList.get(i)).setText(res);
}
}
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} }
}); });
} else if (selectedSegmentNode.getPackCodeNodeInfo().getNode_type() } else if (selectedSegmentNode.getPackCodeNodeInfo().getNode_type()
@ -2222,7 +2377,16 @@ public class NewCodeItemDialog extends Dialog {
codeDesc = codeDesc + "\n"; codeDesc = codeDesc + "\n";
} }
this.codeRemark = treeData.getPackCodeNodeInfo().getNode_desc(); this.codeRemark = treeData.getPackCodeNodeInfo().getNode_desc();
this.nodeName = treeData.getPackCodeNodeInfo().getNode_name();
System.out.println("node_name ===>" + treeData.getPackCodeNodeInfo().getNode_name());
System.out.println("node_desc ===>" + treeData.getPackCodeNodeInfo().getNode_desc()); System.out.println("node_desc ===>" + treeData.getPackCodeNodeInfo().getNode_desc());
AbstractTreeData temp = treeData;
while (temp != null) {
rootNodeName = temp.getPackCodeNodeInfo().getNode_name();
temp = temp.getParentTreeData();
}
System.out.println("rootNodeName ===>" + rootNodeName);
} }
} }
} }
@ -3125,7 +3289,6 @@ public class NewCodeItemDialog extends Dialog {
public boolean finitPropList() { public boolean finitPropList() {
for (int i = 0; i < this.cnpropList.size(); i++) { for (int i = 0; i < this.cnpropList.size(); i++) {
Widget wd = generalPropTextList.get(i); Widget wd = generalPropTextList.get(i);
if (wd instanceof Text) { if (wd instanceof Text) {
if (cnpropList.get(i).getPropertyType().toUpperCase().endsWith("STRING")) { if (cnpropList.get(i).getPropertyType().toUpperCase().endsWith("STRING")) {
@ -3152,15 +3315,20 @@ public class NewCodeItemDialog extends Dialog {
} else if (wd instanceof Combo) { } else if (wd instanceof Combo) {
if (cnpropList.get(i).getIsLov()) { if (cnpropList.get(i).getIsLov()) {
int index = ((Combo) wd).getSelectionIndex(); int index = ((Combo) wd).getSelectionIndex();
if (index != -1) { if (index != -1 && cnpropList.get(i).lovValueList.size() > index) {
cnpropList.get(i).value = cnpropList.get(i).lovValueList.get(index); cnpropList.get(i).value = cnpropList.get(i).lovValueList.get(index);
} else {
cnpropList.get(i).value = "";
} }
} else if (cnpropList.get(i).getPropertyType().toUpperCase().endsWith("BOOLEAN")) { } else if (cnpropList.get(i).getPropertyType().toUpperCase().endsWith("BOOLEAN")) {
if (!((Combo) wd).getText().replace(" ", "").equals("")) { if (!((Combo) wd).getText().replace(" ", "").equals("")) {
cnpropList.get(i).value = Boolean.parseBoolean(((Combo) wd).getText()); if (!"".equals(((Combo) wd).getText())) {
cnpropList.get(i).value = Boolean.parseBoolean(((Combo) wd).getText());
} else {
cnpropList.get(i).value = "";
}
} }
} }
@ -3259,6 +3427,7 @@ public class NewCodeItemDialog extends Dialog {
type = targetObject.getType(); type = targetObject.getType();
System.out.println("选中对象:" + targetObject + " 类型:" + type); System.out.println("选中对象:" + targetObject + " 类型:" + type);
} }
TCComponentItem newItem = (TCComponentItem) newComp;
for (int i = 0; i < generalPropLabelList.size(); i++) { for (int i = 0; i < generalPropLabelList.size(); i++) {
String text = generalPropLabelList.get(i).getText(); String text = generalPropLabelList.get(i).getText();
@ -3279,9 +3448,8 @@ public class NewCodeItemDialog extends Dialog {
flag = true; flag = true;
TCComponent cadTemplate = session.stringToComponent(uid); TCComponent cadTemplate = session.stringToComponent(uid);
TCComponentDataset cadDataset = (TCComponentDataset) cadTemplate; TCComponentDataset cadDataset = (TCComponentDataset) cadTemplate;
TCComponentItem item = (TCComponentItem) newComp; TCComponentDataset newCad = cadDataset.saveAs(newItem.getProperty("item_id"));
TCComponentDataset newCad = cadDataset.saveAs(item.getProperty("item_id")); newItem.getLatestItemRevision().add("IMAN_specification", newCad);
item.getLatestItemRevision().add("TC_Attaches", newCad);
System.out.println("cad数据集创建成功"); System.out.println("cad数据集创建成功");
// MessageBox.post("二维图框大小为\"" + rwtk + "\"的cad数据集\"" + newCad.getProperty("object_string") // MessageBox.post("二维图框大小为\"" + rwtk + "\"的cad数据集\"" + newCad.getProperty("object_string")
// + "\"创建成功", "错误", MessageBox.WARNING); // + "\"创建成功", "错误", MessageBox.WARNING);
@ -3297,7 +3465,6 @@ public class NewCodeItemDialog extends Dialog {
} }
if (ksfl != null) { if (ksfl != null) {
TCComponentItem newItem = (TCComponentItem) newComp;
TCComponentItemRevision rev = newItem.getLatestItemRevision(); TCComponentItemRevision rev = newItem.getLatestItemRevision();
TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0];
if (ksfl.equals(form.getProperty("jd2_ksfl"))) { if (ksfl.equals(form.getProperty("jd2_ksfl"))) {
@ -3315,35 +3482,38 @@ public class NewCodeItemDialog extends Dialog {
} }
if (ysjtzRev != null) { if (ysjtzRev != null) {
TCComponentItem item = (TCComponentItem) newComp;
if (ysdzbForm != null) { if (ysdzbForm != null) {
if (ysjTable != null) { if (ysjTable != null) {
// String[][] ysjTable1 = new String[ysjTable.length + 1][colNames.length]; List<String[]> ysjTableList = new ArrayList<>(Arrays.asList(ysjTable));
List<String[]> ysjTable1 = new ArrayList<String[]>(); String[] newRow = new String[] { newItem.getProperty("item_id"), cz, ys, xh };
for (String[] arr : ysjTable) { System.out.println("new row===>" + Arrays.toString(newRow));
ysjTable1.add(arr); ysjTableList.add(newRow);
}
String[] newRow = new String[] { item.getProperty("item_id"), cz, ys, xh };
ysjTable1.add(newRow);
TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames, TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames,
ysjTable1.toArray(new String[ysjTable1.size()][colNames.length])); ysjTableList.toArray(new String[ysjTableList.size()][colNames.length]));
} }
} else { } else {
TCComponentFormType formType = (TCComponentFormType) session.getTypeComponent("Form"); TCComponentFormType formType = (TCComponentFormType) session.getTypeComponent("Form");
ysdzbForm = formType.create("颜色对照表", "颜色对照表", "JD2_YSDZB"); ysdzbForm = formType.create("颜色对照表", "颜色对照表", "JD2_YSDZB");
ysjTable = new String[][] { { item.getProperty("item_id"), cz, ys, xh } }; ysjTable = new String[][] { { newItem.getProperty("item_id"), cz, ys, xh } };
System.out.println("init row===>" + Arrays.deepToString(ysjTable));
TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames, ysjTable); TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames, ysjTable);
session.getUserService().call("bs_bypass", new Object[] { true }); session.getUserService().call("bs_bypass", new Object[] { true });
ysjtzRev.add("IMAN_specification", ysdzbForm); ysjtzRev.add("IMAN_specification", ysdzbForm);
session.getUserService().call("bs_bypass", new Object[] { false }); session.getUserService().call("bs_bypass", new Object[] { false });
} }
item.getLatestItemRevision().add("TC_Is_Represented_By", ysjtzRev); newItem.getLatestItemRevision().add("TC_Is_Represented_By", ysjtzRev);
ysjtzRev.refresh(); ysjtzRev.refresh();
item.refresh(); newItem.refresh();
System.out.println("颜色件创建成功"); System.out.println("颜色件创建成功");
} }
if (gltz != null) {
newItem.getLatestItemRevision().add("TC_Is_Represented_By", gltz);
}
if (glwl != null) {
newItem.getLatestItemRevision().add("representation_for", glwl);
}
if (targetObject instanceof TCComponentFolder) { if (targetObject instanceof TCComponentFolder) {
if (newComp != null) { if (newComp != null) {
@ -4123,6 +4293,23 @@ public class NewCodeItemDialog extends Dialog {
MessageBox.post("请填写必填属性", "错误", MessageBox.ERROR); MessageBox.post("请填写必填属性", "错误", MessageBox.ERROR);
return; return;
} }
for (int i = 0; i < classPropList.size(); i++) {
CNClassPropBean bean = classPropList.get(i);
if (classMustMap.get(rootNodeName) != null
&& classMustMap.get(rootNodeName).contains(bean.propID + "")) {
String value = "";
if (bean.isLov) {
value = ((Combo) classTextList.get(i)).getText();
value = bean.lovMapping.get(value);
} else {
value = ((Text) classTextList.get(i)).getText();
}
if (value == null || "".equals(value.trim())) {
MessageBox.post("请填写必填分类属性", "错误", MessageBox.ERROR);
return;
}
}
}
// 波轮图纸分类 // 波轮图纸分类
ksfl = null; ksfl = null;
@ -4140,7 +4327,7 @@ public class NewCodeItemDialog extends Dialog {
String text = generalPropLabelList.get(i).getText(); String text = generalPropLabelList.get(i).getText();
System.out.println(text); System.out.println(text);
if (text.equals("款式分类:")) { if (text.equals("款式分类:")) {
ksfl = ((Text) generalPropTextList.get(i)).getText(); ksfl = ((Button) generalPropTextList.get(i)).getText();
break; break;
} }
} }
@ -4159,6 +4346,9 @@ public class NewCodeItemDialog extends Dialog {
// 颜色件 // 颜色件
String ysjth = null; String ysjth = null;
ysjtzRev = null;
ysdzbForm = null;
ysjTable = null;
ys = null; ys = null;
cz = null; cz = null;
xh = null; xh = null;
@ -4173,8 +4363,6 @@ public class NewCodeItemDialog extends Dialog {
} }
} }
for (int i = 0; i < classPropList.size(); i++) { for (int i = 0; i < classPropList.size(); i++) {
// System.out.println(" CLASS ID = " + integers[i] + " =" +
// vals[i]);
CNClassPropBean bean = classPropList.get(i); CNClassPropBean bean = classPropList.get(i);
System.out.println(bean.propDisName); System.out.println(bean.propDisName);
if ("颜色".equals(bean.propDisName)) { if ("颜色".equals(bean.propDisName)) {
@ -4184,7 +4372,6 @@ public class NewCodeItemDialog extends Dialog {
} else { } else {
ys = ((Text) classTextList.get(i)).getText(); ys = ((Text) classTextList.get(i)).getText();
} }
// icspro[i] = new ICSProperty(bean.propID, value);
System.out.println("颜色:" + ys); System.out.println("颜色:" + ys);
} }
if ("材质".equals(bean.propDisName)) { if ("材质".equals(bean.propDisName)) {
@ -4194,7 +4381,6 @@ public class NewCodeItemDialog extends Dialog {
} else { } else {
cz = ((Text) classTextList.get(i)).getText(); cz = ((Text) classTextList.get(i)).getText();
} }
// icspro[i] = new ICSProperty(bean.propID, value);
System.out.println("材质:" + cz); System.out.println("材质:" + cz);
} }
if ("型号".equals(bean.propDisName)) { if ("型号".equals(bean.propDisName)) {
@ -4204,15 +4390,23 @@ public class NewCodeItemDialog extends Dialog {
} else { } else {
xh = ((Text) classTextList.get(i)).getText(); xh = ((Text) classTextList.get(i)).getText();
} }
// icspro[i] = new ICSProperty(bean.propID, value);
System.out.println("型号:" + xh); System.out.println("型号:" + xh);
} }
} }
if (ysjth != null && !"".equals(ysjth.trim()) && ys == null) { if ((ysjth == null || "".equals(ysjth)) && ys != null && !"".equals(ys.trim())) {
MessageBox.post("该物料不是颜色件", "错误", MessageBox.ERROR); // int res = JOptionPane.showConfirmDialog(null, "如果该件是颜色件,请取消并填写颜色件图号", "提示",
return; // JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
int res = ConfirmDialog.prompt(this.getShell(), "提示", "如果该件是颜色件,请按否并填写颜色件图号");
System.out.println("res======>" + res);
if (res == ConfirmationDialog.YES) {
System.out.println("YES");
// do nothing
} else {
System.out.println("NO OR CANCEL");
return;
}
} }
if (ysjth != null && !"".equals(ysjth.trim())) { if (ysjth != null && !"".equals(ysjth.trim()) && ys != null && !"".equals(ys.trim())) {
TCComponent comp = null; TCComponent comp = null;
try { try {
comp = session.search("Item ID", new String[] { "零组件 ID" }, new String[] { ysjth })[0]; comp = session.search("Item ID", new String[] { "零组件 ID" }, new String[] { ysjth })[0];
@ -4230,8 +4424,8 @@ public class NewCodeItemDialog extends Dialog {
ysjTable = TCTableUtil.getTableRows(ysdzbForm, "jd2_ysdzb", colNames); ysjTable = TCTableUtil.getTableRows(ysdzbForm, "jd2_ysdzb", colNames);
for (String[] row : ysjTable) { for (String[] row : ysjTable) {
if (ys.equals(row[2])) { if (ys.equals(row[2])) {
MessageBox.post("图号为\"" + ysjth + "\"的颜色件已存在颜色\"" + ys + "\"", "错误", MessageBox.post("图号为\"" + ysjth + "\"的颜色件已存在颜色\"" + ys + "\"", "提示",
MessageBox.ERROR); MessageBox.WARNING);
return; return;
} }
} }
@ -4239,11 +4433,57 @@ public class NewCodeItemDialog extends Dialog {
} }
} }
} else { } else {
MessageBox.post("没有找到与\"" + ysjth + "\"对应的图纸信息", "错误", MessageBox.ERROR); MessageBox.post("没有找到与\"" + ysjth + "\"对应的图纸信息", "提示", MessageBox.WARNING);
return; return;
} }
} }
// 物料图纸相互关联
gltz = null;
glwl = null;
System.out.println("物料图纸相互关联");
for (int i = 0; i < generalPropLabelList.size(); i++) {
String text = generalPropLabelList.get(i).getText();
if (text.equals("图号关联:")) {
String th = ((Text) generalPropTextList.get(i)).getText();
if (StrUtil.isNotBlank(th)) {
System.out.println("图号:" + th);
try {
TCComponent[] comps = session.search("Item ID", new String[] { "零组件 ID" },
new String[] { th });
if (comps.length > 0) {
System.out.println(comps[0].getUid());
gltz = ((TCComponentItem) comps[0]).getLatestItemRevision();
} else {
MessageBox.post("图号不存在,请重新填写或清空值!", "提示", MessageBox.WARNING);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (text.equals("物料号关联:")) {
String wlh = ((Text) generalPropTextList.get(i)).getText();
if (StrUtil.isNotBlank(wlh)) {
System.out.println("物料号:" + wlh);
try {
TCComponent[] comps = session.search("Item ID", new String[] { "零组件 ID" },
new String[] { wlh });
if (comps.length > 0) {
System.out.println(comps[0].getUid());
glwl = ((TCComponentItem) comps[0]).getLatestItemRevision();
} else {
MessageBox.post("物料号不存在,请重新填写或清空值!", "提示", MessageBox.WARNING);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
TCComponentItem oldItem = tccomponentitemtype.find(getJYNewID(newID)); TCComponentItem oldItem = tccomponentitemtype.find(getJYNewID(newID));
if (oldItem != null) { if (oldItem != null) {
MessageBox.post("ID为【" + getJYNewID(newID) + "】的物料已经存在!", "INFO", MessageBox.WARNING); MessageBox.post("ID为【" + getJYNewID(newID) + "】的物料已经存在!", "INFO", MessageBox.WARNING);
@ -4509,15 +4749,15 @@ public class NewCodeItemDialog extends Dialog {
TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0];
String type = form.getProperty("jd2_wllx"); String type = form.getProperty("jd2_wllx");
TCProperty tcProperty = form.getTCProperty("jd2_wllx"); TCProperty tcProperty = form.getTCProperty("jd2_wllx");
System.out.println(tcProperty==null?"非物料":tcProperty.getLOV()); System.out.println(tcProperty == null ? "非物料" : tcProperty.getLOV());
if (tcProperty != null) { if (tcProperty != null) {
System.out.println("isLov"); System.out.println("isLov");
type = (String) form.getTCProperty("jd2_wllx").getLOV().getListOfValues().getRealValue(type); type = (String) form.getTCProperty("jd2_wllx").getLOV().getListOfValues().getRealValue(type);
}else { } else {
type="非物料"; type = "非物料";
} }
System.out.println("物料类型:" + type); System.out.println("物料类型:" + type);
property.append(item.getProperty("object_type")); property.append(item.getProperty("object_name"));
System.out.println(type); System.out.println(type);
if (type != null && !"非物料".equals(type)) { if (type != null && !"非物料".equals(type)) {
@ -4529,7 +4769,7 @@ public class NewCodeItemDialog extends Dialog {
flag = true; flag = true;
for (int j = 0; j < row[3].split(",").length; j++) { for (int j = 0; j < row[3].split(",").length; j++) {
int id = Integer.parseInt(row[3].split(",")[j]); int id = Integer.parseInt(row[3].split(",")[j]);
if (map.get(id) != null) { if (map.get(id) != null && !"".equals(map.get(id))) {
property.append("" + map.get(id)); property.append("" + map.get(id));
System.out.println(map.get(id)); System.out.println(map.get(id));
} }
@ -4542,7 +4782,7 @@ public class NewCodeItemDialog extends Dialog {
row = arr[2].split("/"); row = arr[2].split("/");
for (int j = 0; j < row[2].split(",").length; j++) { for (int j = 0; j < row[2].split(",").length; j++) {
int id = Integer.parseInt(row[2].split(",")[j]); int id = Integer.parseInt(row[2].split(",")[j]);
if (map.get(id) != null) { if (map.get(id) != null && !"".equals(map.get(id))) {
property.append("" + map.get(id)); property.append("" + map.get(id));
System.out.println(map.get(id)); System.out.println(map.get(id));
} }
@ -4554,7 +4794,7 @@ public class NewCodeItemDialog extends Dialog {
row = arr[0].split("/"); row = arr[0].split("/");
for (int j = 0; j < row[2].split(",").length; j++) { for (int j = 0; j < row[2].split(",").length; j++) {
int id = Integer.parseInt(row[2].split(",")[j]); int id = Integer.parseInt(row[2].split(",")[j]);
if (map.get(id) != null) { if (map.get(id) != null && !"".equals(map.get(id))) {
property.append("" + map.get(id)); property.append("" + map.get(id));
System.out.println(map.get(id)); System.out.println(map.get(id));
} }
@ -4564,7 +4804,7 @@ public class NewCodeItemDialog extends Dialog {
row = arr[1].split("/"); row = arr[1].split("/");
for (int j = 0; j < row[2].split(",").length; j++) { for (int j = 0; j < row[2].split(",").length; j++) {
int id = Integer.parseInt(row[2].split(",")[j]); int id = Integer.parseInt(row[2].split(",")[j]);
if (map.get(id) != null) { if (map.get(id) != null && !"".equals(map.get(id))) {
property.append("" + map.get(id)); property.append("" + map.get(id));
System.out.println(map.get(id)); System.out.println(map.get(id));
} }
@ -4582,12 +4822,17 @@ public class NewCodeItemDialog extends Dialog {
} }
public boolean sendToClassification() { public boolean sendToClassification() {
if (classPropList.size() == 0) {
System.out.println("分类属性列表size=0");
return false;
}
TCComponentItem item = (TCComponentItem) newComp; TCComponentItem item = (TCComponentItem) newComp;
try { try {
String uid = item.getLatestItemRevision().getUid(); String uid = item.getLatestItemRevision().getUid();
String cid = codeRemark.trim(); String cid = codeRemark.trim();
List<Integer> idsList = new ArrayList<Integer>(); List<Integer> idsList = new ArrayList<Integer>();
List<String> valuesList = new ArrayList<String>(); List<String> valuesList = new ArrayList<String>();
List<String> namesList = new ArrayList<String>();
for (int i = 0; i < classPropList.size(); i++) { for (int i = 0; i < classPropList.size(); i++) {
// System.out.println(" CLASS ID = " + integers[i] + " =" + // System.out.println(" CLASS ID = " + integers[i] + " =" +
// vals[i]); // vals[i]);
@ -4602,6 +4847,7 @@ public class NewCodeItemDialog extends Dialog {
// icspro[i] = new ICSProperty(bean.propID, value); // icspro[i] = new ICSProperty(bean.propID, value);
if (!"".equals(value)) { if (!"".equals(value)) {
idsList.add(bean.propID); idsList.add(bean.propID);
namesList.add(bean.propDisName);
valuesList.add(value); valuesList.add(value);
} }
@ -4614,18 +4860,18 @@ public class NewCodeItemDialog extends Dialog {
System.out.println(Arrays.toString(ids)); System.out.println(Arrays.toString(ids));
System.out.println(Arrays.toString(values)); System.out.println(Arrays.toString(values));
JSONObject obj = new JSONObject(); cn.hutool.json.JSONObject obj = JSONUtil.createObj();
obj.put("ids", ids); obj.put("ids", ids);
obj.put("values", values); obj.put("values", values);
String prop = obj.toString(); String prop = obj.toString();
prop = prop.replace("\"", "\\\""); // prop = prop.replace("\"", "\\\"");
System.out.println(prop); System.out.println(prop);
String server = getPrefStr("jd2_server_ip"); String server = getPrefStr("jd2_server_ip");
if (server == null || "".equals(server)) { if (server == null || "".equals(server)) {
MessageBox.post("未配置jd2_server_ip首选项", "错误", MessageBox.ERROR); MessageBox.post("未配置jd2_server_ip首选项", "错误", MessageBox.ERROR);
return false; return false;
} }
String url = "http://" + server + ":8080/classification"; String url = "http://" + server + ":8880/api/sendClassification";
Map<String, Object> paramMap = new HashMap<String, Object>(); Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("uid", uid); paramMap.put("uid", uid);
paramMap.put("cid", cid); paramMap.put("cid", cid);
@ -4639,6 +4885,7 @@ public class NewCodeItemDialog extends Dialog {
public void run() { public void run() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
cn.hutool.http.HttpUtil.post(URL, PARAMMAP); cn.hutool.http.HttpUtil.post(URL, PARAMMAP);
setFLFH(namesList, values);
System.out.println("success"); System.out.println("success");
} }
}).start(); }).start();
@ -4648,4 +4895,53 @@ public class NewCodeItemDialog extends Dialog {
} }
return true; return true;
} }
private void setFLFH(List<String> namesList, String[] values) {
try {
TCComponentItemRevision rev = ((TCComponentItem) newComp).getLatestItemRevision();
rev.refresh();
String[] prefArr = getPrefStrArray("jd2_custom_display_name");
String classAddress = getClassificationAddress(rev.getClassificationClass());
System.out.println("classAddress=====>" + classAddress);
for (String pref : prefArr) {
String[] className = pref.split(":")[0].split("/");
if (classAddress.contains(className[0]) && classAddress.contains(className[1])) {
String[] prefClassNamesArr = pref.split(":")[1].split(",");
System.out.println("pref class porp names=====>" + Arrays.toString(prefClassNamesArr));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < prefClassNamesArr.length; i++) {
for (int ii = 0; ii < namesList.size(); ii++) {
if (prefClassNamesArr[i].equals(namesList.get(ii)) && !"".equals(values[ii].trim())) {
builder.append(values[ii] + ",");
}
}
}
String temp = builder.toString().substring(0, builder.toString().length() - 1);
System.out.println("class porp values=====>" + temp);
session.getUserService().call("bs_bypass", new Object[] { true });
rev.lock();
rev.setProperty("jd2_flfh", temp);
rev.save();
rev.unlock();
session.getUserService().call("bs_bypass", new Object[] { false });
break;
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "首选项jd2_custom_display_name配置有误请检查\r\n" + e.getMessage(), "提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
private String getClassificationAddress(String classId) throws TCException {
ICSAdminClass clazz = session.getClassificationService().newICSAdminClass();
clazz.load(classId);
if ("ICM".equals(clazz.askClassId())) {
return "根";
}
return clazz.getName() + "=>" + getClassificationAddress(clazz.getParent());
}
} }

@ -1,6 +1,10 @@
package cn.com.origin.autocode.newitem.generatcode; package cn.com.origin.autocode.newitem.generatcode;
import java.util.List;
import org.eclipse.swt.SWT; 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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
@ -38,8 +42,9 @@ public class ShowLovDialog extends Dialog {
private String msg; private String msg;
private Point p; private Point p;
private Text text; private Text text;
private TCComponentListOfValues lov; private Object lov;
private String data; private String data;
private TreeItem selectedItem;
/** /**
* Create the dialog. * Create the dialog.
@ -47,8 +52,7 @@ public class ShowLovDialog extends Dialog {
* @param parent * @param parent
* @param style * @param style
*/ */
public ShowLovDialog(Shell parent, int style, String msg, Object data, public ShowLovDialog(Shell parent, int style, String msg, Object data, Point p, TCComponentListOfValues lov) {
Point p, TCComponentListOfValues lov) {
super(parent, style); super(parent, style);
this.msg = msg; 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. * Open the dialog.
* *
@ -103,8 +118,7 @@ public class ShowLovDialog extends Dialog {
} }
treeItem0.setText(disPlayv); treeItem0.setText(disPlayv);
treeItem0.setData(v); treeItem0.setData(v);
TCComponentListOfValues cLov = lov TCComponentListOfValues cLov = lov.getListOfFilterOfValue(v);
.getListOfFilterOfValue(v);
if (cLov != null) { if (cLov != null) {
initLovTree(treeItem0, cLov); 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. * Create contents of the dialog.
*/ */
@ -124,23 +164,42 @@ public class ShowLovDialog extends Dialog {
shell = new Shell(getParent(), getStyle()); shell = new Shell(getParent(), getStyle());
shell.setSize(335, 281); shell.setSize(335, 281);
shell.setBounds(p.x, p.y, 330, 270); shell.setBounds(p.x, p.y, 330, 270);
OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, p.x, p.y, 330, 270, OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, p.x, p.y, 330, 270, SWT.NULL);
SWT.NULL);
shell.setText(getText()); shell.setText(getText());
lovTree = new Tree(shell, SWT.BORDER); lovTree = new Tree(shell, SWT.BORDER);
lovTree.setBounds(10, 10, 304, 168); lovTree.setBounds(10, 10, 304, 168);
// initTree(); // 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() { lovTree.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) { 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) { if (event.detail == SWT.CHECK) {
text.setText(((TreeItem) event.item).getText()); text.setText(selectedItem.getText());
data = ((TreeItem) event.item).getData().toString(); data = selectedItem.getData().toString();
} else { } else {
text.setText(((TreeItem) event.item).getText()); text.setText(selectedItem.getText());
data = ((TreeItem) event.item).getData().toString(); 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,9 +209,11 @@ public class ShowLovDialog extends Dialog {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
result.value = text.getText(); if (selectedItem.getItemCount() == 0) {
result.key = data; result.value = text.getText();
shell.dispose(); result.key = data;
shell.dispose();
}
} }
}); });
btnNewButton.setBounds(38, 228, 80, 27); btnNewButton.setBounds(38, 228, 80, 27);

@ -1,10 +1,9 @@
package cn.com.origin.autocode.newitem.generatcode; package cn.com.origin.autocode.newitem.generatcode;
import java.net.URLDecoder; import java.util.List;
import java.net.URLEncoder; import java.util.Map;
import java.nio.charset.Charset;
import net.sf.json.JSONObject; import cn.com.origin.autocode.xmlutil.ExcelInfoScanner;
public class Test { public class Test {
@ -13,46 +12,20 @@ public class Test {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int[] ids = new int[] { 1003, 1042, 1005, 1004 }; Map<String, CustomLovBean> map = ExcelInfoScanner
String[] values = new String[] { "安安生生", "安安生生", "安安生生", "安安生生" }; .getGeneralPropMutiLovInfo("C:\\Users\\5rKB5bPlusD\\Desktop\\testLov.xlsx", "波轮洗衣机图纸");
JSONObject obj = new JSONObject(); // new Test().getinfo(bean);
obj.put("ids", ids);
obj.put("values", values);
String url = obj.toString();
url = url.replace("\"", "\\\"");
Charset charset_gbk = Charset.forName("gbk");
url = new String(url.getBytes(), charset_gbk);
url = URLEncoder.encode(url);
System.out.println(url);
url = URLDecoder.decode(url);
System.out.println(url);
} }
static class ClassficationBean { public void getinfo(CustomLovBean bean) {
int[] ids; if (!bean.hasChild()) {
String[] values; return;
ClassficationBean(int[] ids, String[] values) {
this.ids = ids;
this.values = values;
} }
List<CustomLovBean> list = bean.getSub();
public int[] getIds() { for (CustomLovBean clb : list) {
return ids; System.out.println(clb.displayName);
getinfo(clb);
} }
public void setIds(int[] ids) {
this.ids = ids;
}
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