Compare commits
10 Commits
3a0c0dc2c6
...
5ac81a162a
Author | SHA1 | Date |
---|---|---|
|
5ac81a162a | 2 weeks ago |
|
09c16ddb3d | 2 years ago |
![]() |
0ad04b794a | 5 years ago |
![]() |
328e4a597f | 5 years ago |
![]() |
4c095778b7 | 5 years ago |
![]() |
f14dc66e38 | 6 years ago |
![]() |
0c45340420 | 6 years ago |
![]() |
402512ed1e | 6 years ago |
![]() |
62d4db98f9 | 6 years ago |
![]() |
7f5faaf437 | 6 years ago |
@ -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,2 +0,0 @@
|
||||
/cn/
|
||||
/icons/
|
@ -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")){
|
||||
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;
|
||||
|
||||
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 {
|
||||
if (orSaveAsCommand != null)
|
||||
orSaveAsCommand.executeModal();
|
||||
} catch (Exception exception) {
|
||||
MessageBox.post(AIFDesktop.getFrames()[0], exception);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (TCPreferenceUitl.isWriteExpire()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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,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);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -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…
Reference in new issue