commit 09e156098a9426b82777c13fda9083b9b12a60bc Author: 李冬阳 Date: Mon Jan 15 11:43:21 2024 +0800 代码上传 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..560f526 --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..70fe4c0 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cn.com.origin.autocodemanager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a76ae05 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,50 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Autocodemanager Plug-in +Bundle-SymbolicName: cn.com.origin.autocodemanager;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: cn.com.origin.autocodemanager.Activator +Require-Bundle: org.eclipse.ui;bundle-version="3.8.0", + org.eclipse.core.runtime;bundle-version="3.8.0", + com.teamcenter.rac.tcapps;bundle-version="10000.1.0", + TcSoaClient;bundle-version="10000.1.0", + TcSoaCoreRac;bundle-version="10000.1.0", + TcSoaCoreTypes;bundle-version="10000.1.0", + org.eclipse.ui.forms;bundle-version="3.5.200", + org.eclipse.core.expressions;bundle-version="3.4.400", + com.teamcenter.rac.common;bundle-version="10000.1.0", + com.teamcenter.rac.aifrcp;bundle-version="10000.1.0", + com.teamcenter.rac.kernel;bundle-version="10000.1.0", + com.teamcenter.rac.util;bundle-version="10000.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Export-Package: cn.com.origin.autocodemanager, + cn.com.origin.autocodemanager.common, + cn.com.origin.autocodemanager.common.dialog, + cn.com.origin.autocodemanager.common.encrypt, + cn.com.origin.autocodemanager.common.operations, + cn.com.origin.autocodemanager.common.progress, + cn.com.origin.autocodemanager.common.tree, + cn.com.origin.autocodemanager.common.treetable, + cn.com.origin.autocodemanager.export, + cn.com.origin.autocodemanager.handlers, + cn.com.origin.autocodemanager.imports, + cn.com.origin.autocodemanager.views, + cn.com.origin.autocodemanager.views.codestyleview, + cn.com.origin.autocodemanager.views.codeview, + cn.com.origin.autocodemanager.views.listcodeview, + cn.com.origin.autocodemanager.views.testview, + cn.com.origin.autocodemanager.views.treecodeview, + jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.common, + jxl.common.log, + jxl.demo, + jxl.format, + jxl.read.biff, + jxl.write, + jxl.write.biff +Bundle-ClassPath: jxl.jar, + . +Bundle-ActivationPolicy: lazy diff --git a/ant/.svn/README.txt b/ant/.svn/README.txt new file mode 100644 index 0000000..271a8ce --- /dev/null +++ b/ant/.svn/README.txt @@ -0,0 +1,2 @@ +This is a Subversion working copy administrative directory. +Visit http://subversion.tigris.org/ for more information. diff --git a/ant/.svn/dir-wcprops b/ant/.svn/dir-wcprops new file mode 100644 index 0000000..0fed885 --- /dev/null +++ b/ant/.svn/dir-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 68 +/svn/projects/!svn/ver/380/Dicastal8.1/com.teamcenter.rac.tcapps/ant +END diff --git a/ant/.svn/empty-file b/ant/.svn/empty-file new file mode 100644 index 0000000..e69de29 diff --git a/ant/.svn/entries b/ant/.svn/entries new file mode 100644 index 0000000..de2a58e --- /dev/null +++ b/ant/.svn/entries @@ -0,0 +1,21 @@ + + + + + diff --git a/ant/.svn/format b/ant/.svn/format new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/ant/.svn/format @@ -0,0 +1 @@ +4 diff --git a/ant/.svn/text-base/build.xml.svn-base b/ant/.svn/text-base/build.xml.svn-base new file mode 100644 index 0000000..b01e5d8 --- /dev/null +++ b/ant/.svn/text-base/build.xml.svn-base @@ -0,0 +1,90 @@ + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ant/.svn/wcprops/build.xml.svn-work b/ant/.svn/wcprops/build.xml.svn-work new file mode 100644 index 0000000..2eaac6b --- /dev/null +++ b/ant/.svn/wcprops/build.xml.svn-work @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/projects/!svn/ver/380/Dicastal8.1/com.teamcenter.rac.tcapps/ant/build.xml +END diff --git a/ant/build.xml b/ant/build.xml new file mode 100644 index 0000000..19b5bd6 --- /dev/null +++ b/ant/build.xml @@ -0,0 +1,57 @@ + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..89997e4 --- /dev/null +++ b/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = classes/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + jxl.jar diff --git a/classes/cn/com/origin/autocodemanager/Activator.class b/classes/cn/com/origin/autocodemanager/Activator.class new file mode 100644 index 0000000..3b3bebf Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/Activator.class differ diff --git a/classes/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.class b/classes/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.class new file mode 100644 index 0000000..5433f7f Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.class b/classes/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.class new file mode 100644 index 0000000..a6d231c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/AutoCodeConstants.class b/classes/cn/com/origin/autocodemanager/common/AutoCodeConstants.class new file mode 100644 index 0000000..1def54b Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/AutoCodeConstants.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.class b/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.class new file mode 100644 index 0000000..63c7c03 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.class b/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.class new file mode 100644 index 0000000..bcc3a1b Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.class b/classes/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.class new file mode 100644 index 0000000..7b48929 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/BusinessType.class b/classes/cn/com/origin/autocodemanager/common/BusinessType.class new file mode 100644 index 0000000..4d8eade Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/BusinessType.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/CacheImage.class b/classes/cn/com/origin/autocodemanager/common/CacheImage.class new file mode 100644 index 0000000..460d4c0 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/CacheImage.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil$1.class b/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil$1.class new file mode 100644 index 0000000..60a7db9 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil.class b/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil.class new file mode 100644 index 0000000..49fe848 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/CreateCompositeUtil.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/GetChoosePath.class b/classes/cn/com/origin/autocodemanager/common/GetChoosePath.class new file mode 100644 index 0000000..351d5cc Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/GetChoosePath.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.class b/classes/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.class new file mode 100644 index 0000000..497cb08 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/PackCodeDescInfos.class b/classes/cn/com/origin/autocodemanager/common/PackCodeDescInfos.class new file mode 100644 index 0000000..97c87c2 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/PackCodeDescInfos.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/TCLOVUtil.class b/classes/cn/com/origin/autocodemanager/common/TCLOVUtil.class new file mode 100644 index 0000000..d80917b Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/TCLOVUtil.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/TCPreferenceUitl.class b/classes/cn/com/origin/autocodemanager/common/TCPreferenceUitl.class new file mode 100644 index 0000000..83e258c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/TCPreferenceUitl.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/TCQueryUtil.class b/classes/cn/com/origin/autocodemanager/common/TCQueryUtil.class new file mode 100644 index 0000000..c31b1c0 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/TCQueryUtil.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.class b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.class new file mode 100644 index 0000000..f13cbe4 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$1.class b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$1.class new file mode 100644 index 0000000..2a28460 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$2.class b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$2.class new file mode 100644 index 0000000..e138fbe Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.class b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.class new file mode 100644 index 0000000..43fd386 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.class b/classes/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.class new file mode 100644 index 0000000..d3e4565 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/operations/ExcelOperation.class b/classes/cn/com/origin/autocodemanager/common/operations/ExcelOperation.class new file mode 100644 index 0000000..b03d8be Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/operations/ExcelOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.class b/classes/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.class new file mode 100644 index 0000000..3f2807b Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.class b/classes/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.class new file mode 100644 index 0000000..acdbd3e Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.class b/classes/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.class new file mode 100644 index 0000000..67ac247 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/operations/ViewControlOperation.class b/classes/cn/com/origin/autocodemanager/common/operations/ViewControlOperation.class new file mode 100644 index 0000000..8555ffa Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/operations/ViewControlOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1$1.class b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1$1.class new file mode 100644 index 0000000..7048d68 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1.class b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1.class new file mode 100644 index 0000000..c50a814 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar.class b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar.class new file mode 100644 index 0000000..7dc8cfd Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ExpandProgressBar.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar$1.class b/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar$1.class new file mode 100644 index 0000000..cc780da Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar.class b/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar.class new file mode 100644 index 0000000..d581996 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ImportORExportProgressBar.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarEvent.class b/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarEvent.class new file mode 100644 index 0000000..4ac1853 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarEvent.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarListener.class b/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarListener.class new file mode 100644 index 0000000..d49e003 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/progress/ProgressBarListener.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$1.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$1.class new file mode 100644 index 0000000..564785f Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$2.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$2.class new file mode 100644 index 0000000..c5714c2 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView.class new file mode 100644 index 0000000..29f8c3e Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractCreateTreeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeData.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeData.class new file mode 100644 index 0000000..42a2f61 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeData.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$AddChildrenNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$AddChildrenNodeAction.class new file mode 100644 index 0000000..4c6a50d Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$AddChildrenNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$CopyCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$CopyCodeNodeAction.class new file mode 100644 index 0000000..756b26f Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$CopyCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$EidtCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$EidtCodeNodeAction.class new file mode 100644 index 0000000..ef6a2ce Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$EidtCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$LockCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$LockCodeNodeAction.class new file mode 100644 index 0000000..b84520c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$LockCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$RemoveCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$RemoveCodeNodeAction.class new file mode 100644 index 0000000..894271a Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$RemoveCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$UnLockCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$UnLockCodeNodeAction.class new file mode 100644 index 0000000..8281b8a Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction$UnLockCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.class b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.class new file mode 100644 index 0000000..2f8949a Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.class b/classes/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.class new file mode 100644 index 0000000..8e9311a Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.class b/classes/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.class new file mode 100644 index 0000000..58d9a9d Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.class b/classes/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.class new file mode 100644 index 0000000..f12e513 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.class b/classes/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.class new file mode 100644 index 0000000..dafb963 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.class b/classes/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.class new file mode 100644 index 0000000..49e9f92 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.class b/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.class new file mode 100644 index 0000000..be9c698 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.class differ diff --git a/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.class b/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.class new file mode 100644 index 0000000..9331993 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.class differ diff --git a/classes/cn/com/origin/autocodemanager/export/ExportNodeOperation.class b/classes/cn/com/origin/autocodemanager/export/ExportNodeOperation.class new file mode 100644 index 0000000..80c3312 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/export/ExportNodeOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.class b/classes/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.class new file mode 100644 index 0000000..56ff41f Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.class b/classes/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.class new file mode 100644 index 0000000..1226f0c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.class b/classes/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.class new file mode 100644 index 0000000..d6106f3 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.class b/classes/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.class new file mode 100644 index 0000000..6befade Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.class b/classes/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.class new file mode 100644 index 0000000..7a39f67 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.class b/classes/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.class new file mode 100644 index 0000000..d6ad487 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.class b/classes/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.class new file mode 100644 index 0000000..f3dae86 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.class differ diff --git a/classes/cn/com/origin/autocodemanager/imports/ImportNodeOperation.class b/classes/cn/com/origin/autocodemanager/imports/ImportNodeOperation.class new file mode 100644 index 0000000..9dbb1a2 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/imports/ImportNodeOperation.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.class b/classes/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.class new file mode 100644 index 0000000..0163cdd Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.class b/classes/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.class new file mode 100644 index 0000000..bbe34a5 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/AutoCodeTestView.class b/classes/cn/com/origin/autocodemanager/views/AutoCodeTestView.class new file mode 100644 index 0000000..124f1e6 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/AutoCodeTestView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.class b/classes/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.class new file mode 100644 index 0000000..802bd85 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.class b/classes/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.class new file mode 100644 index 0000000..ac8e619 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog$1.class b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog$1.class new file mode 100644 index 0000000..9b929fe Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.class b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.class new file mode 100644 index 0000000..6791bd3 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction$NewCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction$NewCodeNodeAction.class new file mode 100644 index 0000000..d571b50 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction$NewCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.class b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.class new file mode 100644 index 0000000..f2c1840 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.class b/classes/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.class new file mode 100644 index 0000000..5d5e5f9 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$1.class b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$1.class new file mode 100644 index 0000000..f949d89 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$2.class b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$2.class new file mode 100644 index 0000000..75298d9 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$3.class b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$3.class new file mode 100644 index 0000000..5b4be37 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView$3.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.class b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.class new file mode 100644 index 0000000..12516dd Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.class b/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.class new file mode 100644 index 0000000..314a8c7 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.class b/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.class new file mode 100644 index 0000000..67db847 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$CancelDefaultSelectedAction.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$CancelDefaultSelectedAction.class new file mode 100644 index 0000000..fbf060c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$CancelDefaultSelectedAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeAction.class new file mode 100644 index 0000000..a40299a Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeValueAction.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeValueAction.class new file mode 100644 index 0000000..6ce1475 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$NewCodeNodeValueAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$SetDefaultSelectedAction.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$SetDefaultSelectedAction.class new file mode 100644 index 0000000..3ccef2c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction$SetDefaultSelectedAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.class new file mode 100644 index 0000000..b2187ce Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$1.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$1.class new file mode 100644 index 0000000..0125d45 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$2.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$2.class new file mode 100644 index 0000000..0babbe5 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$3.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$3.class new file mode 100644 index 0000000..9cd3783 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView$3.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.class new file mode 100644 index 0000000..bfd46ed Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$1.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$1.class new file mode 100644 index 0000000..0ea9b79 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$2.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$2.class new file mode 100644 index 0000000..965b7b7 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.class new file mode 100644 index 0000000..008f217 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.class new file mode 100644 index 0000000..d602ee3 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.class b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.class new file mode 100644 index 0000000..27e3b92 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$1.class b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$1.class new file mode 100644 index 0000000..3786212 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$2.class b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$2.class new file mode 100644 index 0000000..f4e2ede Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$3.class b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$3.class new file mode 100644 index 0000000..25b38f7 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1$3.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1.class b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1.class new file mode 100644 index 0000000..ae50367 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.class b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.class new file mode 100644 index 0000000..a45eae0 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction$NewCodeNodeAction.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction$NewCodeNodeAction.class new file mode 100644 index 0000000..3628f9c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction$NewCodeNodeAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.class new file mode 100644 index 0000000..76fcccd Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView$1.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView$1.class new file mode 100644 index 0000000..d58f5fc Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.class new file mode 100644 index 0000000..094a84e Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$1.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$1.class new file mode 100644 index 0000000..760435b Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$1.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$2.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$2.class new file mode 100644 index 0000000..ab0fec2 Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView$2.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.class new file mode 100644 index 0000000..d7560ec Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.class differ diff --git a/classes/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.class b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.class new file mode 100644 index 0000000..b215c1c Binary files /dev/null and b/classes/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.class differ diff --git a/classes/icons/add.png b/classes/icons/add.png new file mode 100644 index 0000000..bc58bd7 Binary files /dev/null and b/classes/icons/add.png differ diff --git a/classes/icons/addgroup_16.png b/classes/icons/addgroup_16.png new file mode 100644 index 0000000..71b9d47 Binary files /dev/null and b/classes/icons/addgroup_16.png differ diff --git a/classes/icons/addnode_16.png b/classes/icons/addnode_16.png new file mode 100644 index 0000000..d84fdfd Binary files /dev/null and b/classes/icons/addnode_16.png differ diff --git a/classes/icons/adduser_16.png b/classes/icons/adduser_16.png new file mode 100644 index 0000000..b184734 Binary files /dev/null and b/classes/icons/adduser_16.png differ diff --git a/classes/icons/addvalue_16.png b/classes/icons/addvalue_16.png new file mode 100644 index 0000000..3cf9bd3 Binary files /dev/null and b/classes/icons/addvalue_16.png differ diff --git a/classes/icons/autocode_16.png b/classes/icons/autocode_16.png new file mode 100644 index 0000000..44938f5 Binary files /dev/null and b/classes/icons/autocode_16.png differ diff --git a/classes/icons/autocode_24.png b/classes/icons/autocode_24.png new file mode 100644 index 0000000..2ac939f Binary files /dev/null and b/classes/icons/autocode_24.png differ diff --git a/classes/icons/autocode_32.png b/classes/icons/autocode_32.png new file mode 100644 index 0000000..528106c Binary files /dev/null and b/classes/icons/autocode_32.png differ diff --git a/classes/icons/classficationcode_16.png b/classes/icons/classficationcode_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/classes/icons/classficationcode_16.png differ diff --git a/classes/icons/close_16.png b/classes/icons/close_16.png new file mode 100644 index 0000000..9935027 Binary files /dev/null and b/classes/icons/close_16.png differ diff --git a/classes/icons/code2_16.png b/classes/icons/code2_16.png new file mode 100644 index 0000000..242a122 Binary files /dev/null and b/classes/icons/code2_16.png differ diff --git a/classes/icons/code_16.png b/classes/icons/code_16.png new file mode 100644 index 0000000..c1757aa Binary files /dev/null and b/classes/icons/code_16.png differ diff --git a/classes/icons/codenode_16.png b/classes/icons/codenode_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/classes/icons/codenode_16.png differ diff --git a/classes/icons/delete_16.png b/classes/icons/delete_16.png new file mode 100644 index 0000000..dc602bc Binary files /dev/null and b/classes/icons/delete_16.png differ diff --git a/classes/icons/down_16.png b/classes/icons/down_16.png new file mode 100644 index 0000000..35ef44f Binary files /dev/null and b/classes/icons/down_16.png differ diff --git a/classes/icons/edit_16.png b/classes/icons/edit_16.png new file mode 100644 index 0000000..d133306 Binary files /dev/null and b/classes/icons/edit_16.png differ diff --git a/classes/icons/exceltemplate_16.png b/classes/icons/exceltemplate_16.png new file mode 100644 index 0000000..d0f4a26 Binary files /dev/null and b/classes/icons/exceltemplate_16.png differ diff --git a/classes/icons/exceltemplate_32.png b/classes/icons/exceltemplate_32.png new file mode 100644 index 0000000..f961043 Binary files /dev/null and b/classes/icons/exceltemplate_32.png differ diff --git a/classes/icons/export_16.png b/classes/icons/export_16.png new file mode 100644 index 0000000..baa7c0f Binary files /dev/null and b/classes/icons/export_16.png differ diff --git a/classes/icons/exporttoexcel_16.png b/classes/icons/exporttoexcel_16.png new file mode 100644 index 0000000..9cc4cd1 Binary files /dev/null and b/classes/icons/exporttoexcel_16.png differ diff --git a/classes/icons/exporttoexcel_24.png b/classes/icons/exporttoexcel_24.png new file mode 100644 index 0000000..4ec0c15 Binary files /dev/null and b/classes/icons/exporttoexcel_24.png differ diff --git a/classes/icons/folder_16.png b/classes/icons/folder_16.png new file mode 100644 index 0000000..e7499ce Binary files /dev/null and b/classes/icons/folder_16.png differ diff --git a/classes/icons/grant_16.png b/classes/icons/grant_16.png new file mode 100644 index 0000000..f7a63ad Binary files /dev/null and b/classes/icons/grant_16.png differ diff --git a/classes/icons/group_16.png b/classes/icons/group_16.png new file mode 100644 index 0000000..71a4bfb Binary files /dev/null and b/classes/icons/group_16.png differ diff --git a/classes/icons/home_data.png b/classes/icons/home_data.png new file mode 100644 index 0000000..2e436a7 Binary files /dev/null and b/classes/icons/home_data.png differ diff --git a/classes/icons/import_16.png b/classes/icons/import_16.png new file mode 100644 index 0000000..e3213a6 Binary files /dev/null and b/classes/icons/import_16.png differ diff --git a/classes/icons/importhistory_16.png b/classes/icons/importhistory_16.png new file mode 100644 index 0000000..57a85f8 Binary files /dev/null and b/classes/icons/importhistory_16.png differ diff --git a/classes/icons/item_16.png b/classes/icons/item_16.png new file mode 100644 index 0000000..6ff9793 Binary files /dev/null and b/classes/icons/item_16.png differ diff --git a/classes/icons/linkageNode_16.png b/classes/icons/linkageNode_16.png new file mode 100644 index 0000000..2bf5ddd Binary files /dev/null and b/classes/icons/linkageNode_16.png differ diff --git a/classes/icons/linkage_16.png b/classes/icons/linkage_16.png new file mode 100644 index 0000000..3d6c823 Binary files /dev/null and b/classes/icons/linkage_16.png differ diff --git a/classes/icons/list_16.png b/classes/icons/list_16.png new file mode 100644 index 0000000..8c83db0 Binary files /dev/null and b/classes/icons/list_16.png differ diff --git a/classes/icons/listproperty_16.png b/classes/icons/listproperty_16.png new file mode 100644 index 0000000..eccc1f1 Binary files /dev/null and b/classes/icons/listproperty_16.png differ diff --git a/classes/icons/listvalue_16.png b/classes/icons/listvalue_16.png new file mode 100644 index 0000000..ead21d5 Binary files /dev/null and b/classes/icons/listvalue_16.png differ diff --git a/classes/icons/lock_16.png b/classes/icons/lock_16.png new file mode 100644 index 0000000..197232e Binary files /dev/null and b/classes/icons/lock_16.png differ diff --git a/classes/icons/newclassfication_16.png b/classes/icons/newclassfication_16.png new file mode 100644 index 0000000..3c91d1c Binary files /dev/null and b/classes/icons/newclassfication_16.png differ diff --git a/classes/icons/newcodetreenode_16.png b/classes/icons/newcodetreenode_16.png new file mode 100644 index 0000000..92353fc Binary files /dev/null and b/classes/icons/newcodetreenode_16.png differ diff --git a/classes/icons/newlistproperty_16.png b/classes/icons/newlistproperty_16.png new file mode 100644 index 0000000..8c83db0 Binary files /dev/null and b/classes/icons/newlistproperty_16.png differ diff --git a/classes/icons/newlistvalue_16.png b/classes/icons/newlistvalue_16.png new file mode 100644 index 0000000..3cd33d0 Binary files /dev/null and b/classes/icons/newlistvalue_16.png differ diff --git a/classes/icons/ok_16.png b/classes/icons/ok_16.png new file mode 100644 index 0000000..380ce66 Binary files /dev/null and b/classes/icons/ok_16.png differ diff --git a/classes/icons/organization_16.png b/classes/icons/organization_16.png new file mode 100644 index 0000000..88d3093 Binary files /dev/null and b/classes/icons/organization_16.png differ diff --git a/classes/icons/person_16.png b/classes/icons/person_16.png new file mode 100644 index 0000000..fa412c8 Binary files /dev/null and b/classes/icons/person_16.png differ diff --git a/classes/icons/remove_16.png b/classes/icons/remove_16.png new file mode 100644 index 0000000..4ff8845 Binary files /dev/null and b/classes/icons/remove_16.png differ diff --git a/classes/icons/role_16.png b/classes/icons/role_16.png new file mode 100644 index 0000000..78c754d Binary files /dev/null and b/classes/icons/role_16.png differ diff --git a/classes/icons/seq_16.png b/classes/icons/seq_16.png new file mode 100644 index 0000000..fad4c83 Binary files /dev/null and b/classes/icons/seq_16.png differ diff --git a/classes/icons/tree_16.png b/classes/icons/tree_16.png new file mode 100644 index 0000000..6d82492 Binary files /dev/null and b/classes/icons/tree_16.png differ diff --git a/classes/icons/treenode_16.png b/classes/icons/treenode_16.png new file mode 100644 index 0000000..822f6d0 Binary files /dev/null and b/classes/icons/treenode_16.png differ diff --git a/classes/icons/unlock_16.png b/classes/icons/unlock_16.png new file mode 100644 index 0000000..fbf2acc Binary files /dev/null and b/classes/icons/unlock_16.png differ diff --git a/classes/icons/up_16.png b/classes/icons/up_16.png new file mode 100644 index 0000000..96d82de Binary files /dev/null and b/classes/icons/up_16.png differ diff --git a/jxl.jar b/jxl.jar new file mode 100644 index 0000000..4a1fc64 Binary files /dev/null and b/jxl.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..8d825fd --- /dev/null +++ b/plugin.xml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/dsds.exsd b/schema/dsds.exsd new file mode 100644 index 0000000..298620c --- /dev/null +++ b/schema/dsds.exsd @@ -0,0 +1,84 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/src/cn/com/origin/autocodemanager/Activator.java b/src/cn/com/origin/autocodemanager/Activator.java new file mode 100644 index 0000000..ade7222 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/Activator.java @@ -0,0 +1,52 @@ +package cn.com.origin.autocodemanager; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.com.origin.autocodemanager.AutoCodeManagerPerspective"; + + // The shared instance + private static Activator plugin; + + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/src/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.java b/src/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.java new file mode 100644 index 0000000..2257c62 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/AutoCodeManagerPerspective.java @@ -0,0 +1,44 @@ +package cn.com.origin.autocodemanager; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; + +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.IsShowAutocodeManagerPerspective; + +import com.teamcenter.rac.aifrcp.perspective.AbstractRACPerspective; +import com.teamcenter.rac.util.MessageBox; + +public class AutoCodeManagerPerspective extends AbstractRACPerspective { + /** The perspective ID */ + + public static final String ID = "cn.com.origin.autocodemanager.AutoCodeManagerPerspective"; + + @Override + public void createInitialLayout(IPageLayout layout) { + layout.setEditorAreaVisible(false); + layout.setFixed(false); + String editorArea = layout.getEditorArea(); + if (new IsShowAutocodeManagerPerspective().getValue()) { + layout.addStandaloneView(AutoCodeManangerConstants.AutoCodeManagerView_ID, true, IPageLayout.LEFT, 0.24f, editorArea); + IFolderLayout middleFolder = layout.createFolder("ͼ", IPageLayout.LEFT, 0.68f, editorArea); + + middleFolder.addView(AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID); + middleFolder.addView(AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); + + middleFolder.addView(AutoCodeManangerConstants.AutoCodeTestView_ID); + + layout.getViewLayout(AutoCodeManangerConstants.AutoCodeManagerView_ID).setCloseable(false); + layout.getViewLayout(AutoCodeManangerConstants.AutoCodeManagerView_ID).setMoveable(false); + + layout.getViewLayout(AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID).setCloseable(false); + layout.getViewLayout(AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID).setMoveable(false); + +// layout.getViewLayout(AutoCodeManangerConstants.AutoCodeTestView_ID).setCloseable(false); + layout.getViewLayout(AutoCodeManangerConstants.AutoCodeTestView_ID).setMoveable(false); + } else { + MessageBox.post("ûȨ!", "INFO", MessageBox.WARNING); + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.java b/src/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.java new file mode 100644 index 0000000..320c867 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/AbstractTreeViewPart.java @@ -0,0 +1,31 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.common; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; + +public class AbstractTreeViewPart extends ViewPart { + public AbstractCreateTreeView createView; + + public AbstractTreeViewPart() { + super(); + } + + @Override + public void createPartControl(Composite parent) { + } + + @Override + public void setFocus() { + + } + + public AbstractCreateTreeView getCreateView() { + return createView; + } +} diff --git a/src/cn/com/origin/autocodemanager/common/AutoCodeConstants.java b/src/cn/com/origin/autocodemanager/common/AutoCodeConstants.java new file mode 100644 index 0000000..82e38d3 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/AutoCodeConstants.java @@ -0,0 +1,32 @@ +package cn.com.origin.autocodemanager.common; + +public interface AutoCodeConstants { + // AutoCode + public static final String AutoCode_APPLICATION_ID = "cn.com.origin.autocode"; + + public static final String AutoCodeCodeView_ID = "cn.com.origin.autocode.views.AutoCodeView"; + public static final String AutoCodeCodeView_Name = ""; + + public static final String AutoCodeItemTypeView_ID = "cn.com.origin.autocode.views.AutoCodeItemTypeView"; + public static final String AutoCodeItemTypeView_Name = ""; + + public static final String AutoCodeGroupView_ID = "cn.com.origin.autocode.views.AutoCodeGroupView"; + public static final String AutoCodeGroupView_Name = "Աָ"; + + public static final String AutoCodeSegmentView_ID = "cn.com.origin.autocodemanager.views.AutoCodeSegmentView"; + public static final String AutoCodeSegmentView_Name = ""; + + + + public static final String as1[] = { "Item" ,"Part","Design"};// +// public static final String as2[] = { "Part", "Design", "PSSignal", "PSConnection", "Schedule", "ScheduleTask", "Architecture", "AllocationMap", "CAEItem", "CAEBCItem", "CAEConnItem", "CAELoadItem", "MEOP", "MEProcess", "MEWorkarea", "MEContext", "MEGenericBOP", "MEProductBOP", +// "Vendor", "BidPackage", "SwDesignComp", "PhysicalPart", "ChangeItem", "ParmDef", "ParmDefBCD", "ParmDefBitDef", "ParmDefBool", "ParmDefDate", "ParmDefDbl", "ParmDefHex", "ParmDefInt", "ParmDefSED", "ParmDefStr", "ParmGrpVal", "CalParm", "ParmGrpDef" }; + + // public static final String as1[] = { "Item", "Drawing" };"Part", "Design", + public static final String as2[] = { "EngChange", "PSSignal", "PSConnection", "Schedule", "ScheduleTask", "Architecture", "AllocationMap", "CAEItem", "CAEBCItem", "CAEConnItem", "CAELoadItem", "MEOP", "MEProcess", "MEWorkarea", "MEContext", "MEGenericBOP", "MEProductBOP", + "Vendor", "BidPackage", "SwDesignComp", "PhysicalPart", "ChangeItem", "ParmDef", "ParmDefBCD", "ParmDefBitDef", "ParmDefBool", "ParmDefDate", "ParmDefDbl", "ParmDefHex", "ParmDefInt", "ParmDefSED", "ParmDefStr", "ParmGrpVal", "CalParm", "ParmGrpDef" }; + + // public static final String startWithTypes[]={"SJ3_"}; +// public static final String startWithTypes[] = {}; + +} diff --git a/src/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.java b/src/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.java new file mode 100644 index 0000000..f1fc696 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/AutoCodeManagerImageKey.java @@ -0,0 +1,43 @@ +package cn.com.origin.autocodemanager.common; + +public interface AutoCodeManagerImageKey { + public static final String ICONSPATH = "icons/"; + public static final String HOME_IMAGE = ICONSPATH + "home_data.png"; + + public static final String CODE_IMAGE = ICONSPATH + "code_16.png"; + public static final String CODEGROUP_IMAGE = ICONSPATH + "folder_16.png"; + + public static final String NODEVALUE_IMAGE = ICONSPATH + "nodevalue_16.png"; + public static final String CODENODE_IMAGE = ICONSPATH + "codenode_16.png"; + + public static final String TREE_IMAGE = ICONSPATH + "tree_16.png"; + public static final String TREENODE_IMAGE = ICONSPATH + "treenode_16.png"; + + public static final String LIST_IMAGE = ICONSPATH + "list_16.png"; + public static final String LISTNODE_IMAGE = ICONSPATH + "listproperty_16.png"; + public static final String LISTVALUE_IMAGE = ICONSPATH + "listvalue_16.png"; + + public static final String OK_IMAGE = ICONSPATH + "ok_16.png"; + public static final String CLOSE_IMAGE = ICONSPATH + "close_16.png"; + + public static final String IMPORT_IMAGE = ICONSPATH + "import_16.png"; + public static final String EXPORT_IMAGE = ICONSPATH + "export_16.png"; + + public static final String ORGANIZATION_IMAGE = ICONSPATH + "organization_16.png"; + public static final String GROUP_IMAGE = ICONSPATH + "group_16.png"; + public static final String ROLE_IMAGE = ICONSPATH + "role_16.png"; + public static final String PERSON_IMAGE = ICONSPATH + "person_16.png"; + + public static final String ITEM_IMAGE = ICONSPATH + "item_16.png"; + + public static final String LOCK_IMAGE = ICONSPATH + "lock_16.png"; + public static final String UNLOCK_IMAGE = ICONSPATH + "unlock_16.png"; + + public static final String EDIT_IMAGE = ICONSPATH + "edit_16.png"; + public static final String REMOVE_IMAGE = ICONSPATH + "remove_16.png"; + public static final String DELETE_IMAGE = ICONSPATH + "delete_16.png"; + + public static final String SEQ_IMAGE = ICONSPATH + "seq_16.png"; + public static final String ADD_IMAGE = ICONSPATH + "add.png"; + +} diff --git a/src/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.java b/src/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.java new file mode 100644 index 0000000..4901ef9 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/AutoCodeManagerPropertyName.java @@ -0,0 +1,152 @@ +package cn.com.origin.autocodemanager.common; + +public interface AutoCodeManagerPropertyName { + // Cd9_TreeAndListCodeNode + public final static String TreeAndListCodeNode_isContainsChildren = "isContainsChildren" ;// Ƿӽڵ + public final static String TreeAndListCodeNode_uid = "uid" ;// uid + public final static String TreeAndListCodeNode_node_index = "cd9_node_index"; // Integer ڵ + public final static String TreeAndListCodeNode_node_type = "cd9_node_type";// String ڵ + public final static String TreeAndListCodeNode_node_name = "cd9_node_name";// String ڵ + public final static String TreeAndListCodeNode_node_value = "cd9_node_value"; // String ڵֵ + public final static String TreeAndListCodeNode_node_desc = "cd9_node_desc"; // String ڵ + public final static String TreeAndListCodeNode_code_style = "cd9_code_style"; // String ʽ + public final static String TreeAndListCodeNode_code_length = "cd9_code_length"; // int 볤 + public final static String TreeAndListCodeNode_is_root = "cd9_is_root";// boolean ǷǸڵ + public final static String TreeAndListCodeNode_rule_node = "cd9_rule_node";// boolean ǷǸڵ + public final static String TreeAndListCodeNode_reference_nodes = "cd9_reference_nodes"; // õĽڵ + + public final static String TreeAndListCodeNode_is_lock = "cd9_is_lock";// boolean Ƿ + public final static String TreeAndListCodeNode_create_date = "cd9_create_date";// Date + public final static String TreeAndListCodeNode_last_revise_date = "cd9_last_revise_date";// Date ޸ + public final static String TreeAndListCodeNode_create_user = "cd9_create_user";// TypeReference + public final static String TreeAndListCodeNode_last_revise_user = "cd9_last_revise_user";// TypeReference ޸ + + public final static String TreeAndListCodeNode_seq_begin_value = "cd9_seq_begin_value"; // Integer ˮʼֵ + public final static String TreeAndListCodeNode_seq_max_value = "cd9_seq_max_value"; // Integer ˮֵ + public final static String TreeAndListCodeNode_seq_length = "cd9_seq_length"; // Integer ˮ볤 + public final static String TreeAndListCodeNode_isDefaultSelected = "cd9_isDefaultSelected"; // boolean ǷΪĬѡУб + + String[] searchTreeAndListCodeNodePropNames = { + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, + AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, + AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, + + AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, + AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, + AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, + + AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, + AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, + + AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, + AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, + AutoCodeManagerPropertyName.TreeAndListCodeNode_isContainsChildren + }; + + String[] searchSegmentPropNames = { + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, + AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, + AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, + AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, + AutoCodeManagerPropertyName.TreeAndListCodeNode_isContainsChildren + }; + + // Cd9_CodeRelation + public final static String CodeRelation_parent_node = "cd9_parent_nodes"; // TypeReference ڵ + public final static String CodeRelation_current_node = "cd9_current_node"; // TypeReference ǰڵ + public final static String CodeRelation_children_nodes = "cd9_children_nodes"; // TypeReference ӽڵ + + public final static String CodeRelation_create_date = "cd9_create_date";// Date + public final static String CodeRelation_create_user = "cd9_create_user";// TypeReference + + // Cd9_ClassificationCodeNode + public final static String ClassificationCodeNode_node_index = "cd9_node_index"; // Integer ڵ + public final static String ClassificationCodeNode_node_name = "cd9_node_name";// String ڵ + public final static String ClassificationCodeNode_segment = "cd9_segment";// String + public final static String ClassificationCodeNode_create_date = "cd9_create_date";// Date + public final static String ClassificationCodeNode_last_revise_date = "cd9_last_revise_date";// Date ޸ + public final static String ClassificationCodeNode_create_user = "cd9_create_user";// TypeReference + public final static String ClassificationCodeNode_last_revise_user = "cd9_last_revise_user";// TypeReference ޸ + public final static String ClassificationCodeNode_grant_users = "cd9_grant_users";// TypeReference Ȩû + public final static String ClassificationCodeNode_grant_roles = "cd9_grant_roles";// TypeReference Ȩɫ + public final static String ClassificationCodeNode_grant_groups = "cd9_grant_groups";// TypeReference Ȩ + + // type + public final static String ItemName = "item"; + public final static String RootNodeName = "root"; + public final static String TreeName = "tree"; + public final static String ListName = "list"; + public final static String CodeGroupName = "codeGroup"; + public final static String TreeNodeName = "treeNode"; + public final static String ListPropertyNodeName = "listPropertyNode"; + public final static String ListPropertyValueNodeName = "listPropertyValueNode"; + + public final static String ComponentName = "component"; + public final static String OrganizationName = "organization"; + public final static String SegmentName = "segment"; + public final static String GroupName = "group"; + public final static String RoleName = "role"; + public final static String UserName = "user"; + public final static String LockName = "lock"; + public final static String AddChildrenTreeNodeName = "AddChildrenTreeNode"; + public final static String AddTreeNodeName = "AddTreeNode"; + public final static String AddRuleRootNodeName = "AddRuleRootNode"; + public final static String AddRuleGroupNodeName = "AddRuleGroupNode"; + + // Item + public final static String Item_Desc = "object_desc"; + public final static String Item_generateID = "cd9_generateID"; + public final static String Item_codeDesc = "cd9_codeDesc"; + public final static String Item_isLock = "cd9_isLock"; + public final static String Item_codePattern = "cd9_codePattern"; + public final static String Item_codeRuleName = "cd9_codeRuleName"; + public final static String Item_codeID = "cd9_codeID"; + public final static String Item_codeStyle = "cd9_codeStyle"; + public final static String Item_uom_tag = "uom_tag"; + + + + // Item Revision + public final static String ItemRevision_isLock = "cd9_isLock"; + + // codeStyle + public final static String Code_seq = "[L]"; + public final static String Code_pattern = "[T]"; + public final static String Code_year2 = "[YY]"; + public final static String Code_year4 = "[YYYY]"; + public final static String Code_mouth2 = "[MM]"; + public final static String Code_mouth1 = "[M]"; + public final static String Code_date2 = "[DD]"; + public final static String Code_date1 = "[D]"; + public final static String Code_class = "[C]"; + + // Cd9_CodeCounter + public final static String CodeCounter_index = "cd9_index"; + public final static String CodeCounter_name = "cd9_name"; + public final static String CodeCounter_recycleID = "cd9_recycleID"; + public final static String CodeCounter_isUsed = "cd9_isUsed"; + public final static String CodeCounter_createDate = "cd9_createDate"; + public final static String CodeCounter_createUser = "cd9_createUser"; + public final static String CodeCounter_last_revise_date = "cd9_last_revise_date";// Date ޸ + public final static String CodeCounter_last_revise_user = "cd9_last_revise_user"; + + // Cd9_CodeNextID + public final static String Counter_name = "cd9_name"; + public final static String Counter_nextID = "cd9_nextID"; + + // йص뵼 + public final static String CodeClassfication = "CodeClassfication"; + public final static String CodeTree = "CodeTree"; + public final static String CodeListName = "CodeListName"; + public final static String CodeListValue = "CodeListValue"; + +// public final static String[] TreeAndListCodeNode_Titles = { "", "", "", "ֵ", "ע", "ʽ", "볤", "ˮʼֵ", "ˮֵ", "ǷΪڵ", "Ƿ", "", "޸", "", "޸" }; + + public final static String[] TreeAndListCodeNode_Titles = { "", "", "", "ֵ", "ע", "ǷΪĬֵ", "ʽ", "볤", "ˮʼֵ", "ˮֵ", "ǷΪڵ", "Ƿ", "", "޸", "", "޸" }; + public final static String[] ClassificationCodeNode_Titles = { "", "", "", "ֵ", "ע", "ʽ", "ǷΪڵ", "Ƿ", "", "޸", "", "޸" }; + public final static String[] CodeSequence_Titles = { "", "", "ʼֵ", "ֵ", "", "", "", "Ƿ", "", "޸", "", "޸" }; + +} diff --git a/src/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.java b/src/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.java new file mode 100644 index 0000000..b8ca404 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/AutoCodeManangerConstants.java @@ -0,0 +1,34 @@ +package cn.com.origin.autocodemanager.common; + +/** + * @author river + * + */ +public interface AutoCodeManangerConstants { + // autocodemannager + public static final String AutoCodeMananger_APPLICATION_ID = "cn.com.origin.autocodemanager"; + public static final String AutoCodeManagerView_ID = "cn.com.origin.autocodemanager.views.AutoCodeSegmentView"; + public static final String AutoCodeManagerView_Name = ""; + public static final String AutoCodeManagerTreeCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView"; + public static final String AutoCodeManagerTreeCodeView_Name = ""; + public static final String AutoCodeManagerListCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeListCodeView"; + public static final String AutoCodeManagerListCodeView_Name = "б"; + +// public static final String AutoCodeTreeCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView"; +// public static final String AutoCodeTreeCodeView_Name = ""; + +// public static final String AutoCodeListCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeListCodeView"; +// public static final String AutoCodeListCodeView_Name = "б"; + + + public static final String AutoCodeManangerShowNoneView_Name = ""; + public static final String AutoCodeManangerShowNoneView_ID = "cn.com.origin.autocodemanager.views.ShowNoneView"; + + public static final String AutoCodeStyleView_ID = "cn.com.origin.autocodemanager.views.AutoCodeStyleView"; + public static final String AutoCodeStyleView_Name = "ʽ"; + + public static final String AutoCodeManagerGroupView_ID = "cn.com.origin.autocodemanager.views.AutoCodeGroupView"; + public static final String AutoCodeTestView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTestView"; + public static final String AutoCodeTestView_Name = "֤"; + +} \ No newline at end of file diff --git a/src/cn/com/origin/autocodemanager/common/BusinessType.java b/src/cn/com/origin/autocodemanager/common/BusinessType.java new file mode 100644 index 0000000..7a531b1 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/BusinessType.java @@ -0,0 +1,218 @@ +package cn.com.origin.autocodemanager.common; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import javax.swing.ImageIcon; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.common.create.DisplayTypeInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentGroupMemberType; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class BusinessType { + private TCSession session; + protected Map typeToIcon; + private String origin_codeNeedLoadItemStartWords = "origin_codeNeedLoadItemStartWords"; + private String origin_codeNeedLoadItemTypes = "origin_codeNeedLoadItemTypes"; + + public BusinessType(TCSession session) { + this.session = session; + } + + public void getItemTypes(String rootType) { + com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput abaseclassinput[] = new com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput[1]; + abaseclassinput[0] = new com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput(); + abaseclassinput[0].baseClass = rootType; + try { + HashMap hashmap = (HashMap) TCUtilities.getDisplayableTypeNamesWithDisplayInfo(session, abaseclassinput); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public Map getTypes(String rootType, String exclusionTypes[]) { + HashMap hashmap = new HashMap(); + com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput abaseclassinput[] = new com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput[1]; + abaseclassinput[0] = new com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput(); + abaseclassinput[0].baseClass = rootType; + // abaseclassinput[0].exclusionTypes = exclusionTypes; + // TCUtilities.getDisplayTypeInfoFromTypeNames(tcsession, as) + try { + hashmap = (HashMap) TCUtilities.getDisplayableTypeNamesWithDisplayInfo(session, abaseclassinput); + + Set key = hashmap.keySet(); + Iterator it = key.iterator(); + Set value = hashmap.entrySet(); + Iterator it2 = value.iterator(); + } catch (TCException e) { + e.printStackTrace(); + } + return hashmap; + } + + /** + * + * ȡϵͳû + * + * @return + * @throws TCException + */ + public TCComponent[] getGroup() throws TCException { + return ((TCComponentGroupType) session.getTypeComponent("Group")).extent(); + } + + /** + * ȡṹ + * + * @return + * @throws TCException + */ + public TCComponent[] getRootGroups() throws TCException { + return ((TCComponentGroupType) session.getTypeComponent("Group")).getRootGroups(); + } + + /** + * ȡϵͳԱ + * + * @return + * @throws TCException + */ + public TCComponent[] getGroupaArrayList() throws TCException { + + TCComponent[] tccomponentGroups = null; + TCComponentGroupMemberType groupMember = (TCComponentGroupMemberType) session.getTypeComponent("GroupMember"); + tccomponentGroups = groupMember.extent(); + if (tccomponentGroups != null && tccomponentGroups.length > 0) { + for (int i = 0; i < tccomponentGroups.length; i++) { + TCComponentGroupMember tccomponentGroupMembers = (TCComponentGroupMember) tccomponentGroups[i]; + TCComponentGroup group = tccomponentGroupMembers.getGroup(); + } + } + return tccomponentGroups; + } + + public TCComponent[] getGroupRoles(TCComponentGroup componentGroup) { + if (componentGroup == null) { + return null; + } + TCComponent[] components = null; + try { + components = componentGroup.getRolesAndGroups(); + } catch (TCException e) { + e.printStackTrace(); + } + return components; + } + + public TCComponent[] getRoleUsers(TCComponentGroup componentGroup, TCComponentRole role) { + if ((componentGroup == null) || (role == null)) { + return null; + } + + TCComponent[] components = null; + try { + components = role.getUsers(componentGroup); + } catch (TCException e) { + e.printStackTrace(); + } + return components; + } + + public ImageIcon getSelectedTypeIcon(String s) { + ImageIcon imageicon = null; + if (typeToIcon == null) + typeToIcon = new HashMap(0); + imageicon = (ImageIcon) typeToIcon.get(s); + return imageicon; + } + + public Map loadTypes(String s1[], String s2[]) { + Map map = buildInput(s1, s2); + Map newHashMap = new HashMap(); + long time11 = System.nanoTime(); + //Map hashMap = TCUtilities.loadSubClassesTypesAndIcons(session, map); +// 20130913 mod + Map hashMap = TCUtilities.loadSubTypesAndIcons(session, map); + long time12 = System.nanoTime(); + System.out.println("ʱ(ms) " + (time12 - time11) / 1000000); + if (hashMap != null && hashMap.size() > 0) { + Set entry = hashMap.entrySet(); + Object entryValue[] = entry.toArray(); + Set key = hashMap.keySet(); + Object keyValue[] = key.toArray(); + for (int m = 0; m < keyValue.length; m++) { + DisplayTypeInfo displaytypeinfo = (DisplayTypeInfo) keyValue[m]; + String typeName = displaytypeinfo.getTypeName(); + // String[] startWithTypes = AutoCodeConstants.startWithTypes; + String[] needLoadItemTypes = TCPreferenceUitl.getPreference(session, TCPreferenceService.TC_preference_site, origin_codeNeedLoadItemTypes); + String[] startWithTypes = TCPreferenceUitl.getPreference(session, TCPreferenceService.TC_preference_site, origin_codeNeedLoadItemStartWords); + if (needLoadItemTypes.length > 0) { + for (int i = 0; i < needLoadItemTypes.length; i++) { + if (typeName.equals(needLoadItemTypes[i].trim())) { + if (!newHashMap.containsKey(keyValue[m])) { + newHashMap.put(keyValue[m], hashMap.get(keyValue[m])); + } + } else { + continue; + } + } + } else { + if (startWithTypes.length > 0) { + for (int i = 0; i < startWithTypes.length; i++) { + // System.out.println("startWithTypes[i].trim()=================" + startWithTypes[i].trim()); + if (startWithTypes[i].trim().length() > 0) { + if (typeName.startsWith(startWithTypes[i].trim())) { + if (!newHashMap.containsKey(keyValue[m])) { + newHashMap.put(keyValue[m], hashMap.get(keyValue[m])); + } + } else { + continue; + } + } + } + } else { + newHashMap.put(keyValue[m], hashMap.get(keyValue[m])); + } + } + } + } + return newHashMap; + } + + private Map buildInput(String s[], String ss[]) { + HashMap hashmap = null; + String as[] = s; + if (as != null && as.length > 0) { + hashmap = new HashMap(as.length); + String as1[] = as; + int i = as1.length; + for (int j = 0; j < i; j++) { + String s1 = as1[j]; + if (s1 == null || s1.trim().length() <= 0) + continue; + String as2[] = ss; + ArrayList arraylist = new ArrayList(0); + if (as2 != null && as2.length > 0) { + String as3[] = as2; + int k = as3.length; + for (int l = 0; l < k; l++) { + String s3 = as3[l]; + if (s3 != null && s3.trim().length() > 0) + arraylist.add(s3.trim()); + } + } + hashmap.put(s1, arraylist); + } + } + return hashmap; + } +} diff --git a/src/cn/com/origin/autocodemanager/common/CacheImage.java b/src/cn/com/origin/autocodemanager/common/CacheImage.java new file mode 100644 index 0000000..637dc0d --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/CacheImage.java @@ -0,0 +1,120 @@ +package cn.com.origin.autocodemanager.common; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.DirectColorModel; +import java.awt.image.ImageObserver; +import java.awt.image.WritableRaster; +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.swing.ImageIcon; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class CacheImage { + private final Map imageMap = new HashMap(); + + private static CacheImage INSTANCE; + + private CacheImage() { + } + + // ģʽCacheImageʵ + public static CacheImage getINSTANCE() { + if (INSTANCE == null) + INSTANCE = new CacheImage(); + return INSTANCE; + } + + // ͼ + public Image getImage(String applicationID,String imageName) { + if (imageName == null) + return null; + Image image = (Image) imageMap.get(imageName); + if (image == null) { + image =AbstractUIPlugin.imageDescriptorFromPlugin( + applicationID,imageName).createImage(); + imageMap.put(imageName, image); + } + + return image; + } + + // ͼ + public Image getImageIco(URL url,String imageName) { + if (imageName == null) + return null; + Image image = (Image) imageMap.get(imageName); + if (image == null) { + ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); + image =imageDescriptor.createImage(); + imageMap.put(imageName, image); + } + + return image; + } + + // ͷͼԴ + public void dispose() { + Iterator iterator = imageMap.values().iterator(); + while (iterator.hasNext()) + ((Image) iterator.next()).dispose(); + imageMap.clear(); + } + + /** + * change ImageIcon to BufferedImage + * @param icon + * @return + */ + public static BufferedImage getBufferedImage(ImageIcon icon){ + int width = icon.getIconWidth(); + int height = icon.getIconHeight(); + ImageObserver observer = icon.getImageObserver(); + BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics gc = bufferedImage.createGraphics(); + gc.drawImage(icon.getImage(), 0, 0, observer); + return bufferedImage; + } + + /** + * change BufferedImage to ImageData + * @param bufferedImage + * @return + */ + public static ImageData getImageData(BufferedImage bufferedImage){ + DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel(); + PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel + .getBlueMask()); + ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel + .getPixelSize(), palette); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[3]; + for (int y = 0; y < data.height; y++) { + for (int x = 0; x < data.width; x++) { + raster.getPixel(x, y, pixelArray); + int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2])); + data.setPixel(x, y, pixel); + } + } + return data; + } + + + public void testSwingToSwtImage() + { + ImageIcon icon = new ImageIcon("C:\\temp\\freshwind.jpg"); + BufferedImage bufferedImage = getBufferedImage(icon); + ImageData data = getImageData(bufferedImage); + Image image = new Image(null, data); + + } +} \ No newline at end of file diff --git a/src/cn/com/origin/autocodemanager/common/CreateCompositeUtil.java b/src/cn/com/origin/autocodemanager/common/CreateCompositeUtil.java new file mode 100644 index 0000000..4ae46ec --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/CreateCompositeUtil.java @@ -0,0 +1,279 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common; + +import java.util.Date; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DateTime; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; + +public class CreateCompositeUtil { + + public static Group createCompositeGroup(Composite parent, String title) { + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + GridData gridData = new GridData(); + gridData.verticalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = true; + gridData.verticalSpan = 1; + gridData.horizontalAlignment = GridData.FILL; + Group codeTreeGroup = new Group(parent, SWT.NONE); + codeTreeGroup.setText(title); + codeTreeGroup.setLayout(gridLayout); + codeTreeGroup.setLayoutData(gridData); + return codeTreeGroup; + } + + public static Label createLabel(Composite composite, String text, + int heightLength, int widthLength) { + Label newLabel = new Label(composite, SWT.NONE); + // Label newLabel = toolkit.createLabel(composite, text); + newLabel.setText(text); + GridData gridData = new GridData(); + gridData.heightHint = heightLength; + gridData.widthHint = widthLength; + newLabel.setLayoutData(gridData); + newLabel.setVisible(true); + return newLabel; + } + + public static Label createSeparator(Composite composite, String text, + int heightLength, int widthLength) { + // Label separator = toolkit.createLabel(composite, ""); + Label separator = new Label(composite, SWT.NONE); + separator.setText(""); + GridData gridData1 = new GridData(); + gridData1.heightHint = heightLength; + gridData1.widthHint = widthLength; + separator.setLayoutData(gridData1); + separator.setVisible(true); + return separator; + } + + public static Combo createNotFillNewCombo(Composite parent, String[] items) { + Combo newCombo = new Combo(parent, SWT.BORDER|SWT.READ_ONLY); + newCombo.setLayoutData(getNotFillNewGridData()); + newCombo.setItems(items); + + + return newCombo; + } + + // public static Combo createNotFillNewCombo(Table parent, String[] items) { + // Combo newCombo = new Combo(parent, SWT.BORDER); + // newCombo.setLayoutData(getNotFillNewGridData()); + // newCombo.setItems(items); + // return newCombo; + // } + + public static GridData getNotFillNewGridData() { + GridData gridData = new GridData(); + gridData.verticalAlignment = GridData.FILL; + return gridData; + } + + public static Text createText(Composite composite, String text, + int heightLength, int widthLength) { + // Text newText = toolkit.createText(composite, ""); + Text newText = new Text(composite, SWT.BORDER); + newText.setText(text); + + GridData gridData1 = new GridData(); + gridData1.heightHint = heightLength; + gridData1.widthHint = widthLength; + newText.setLayoutData(gridData1); + newText.setVisible(true); + return newText; + } + + public static Combo createCombo(Composite composite, String[] items, + int heightLength, int widthLength) { + Combo newCombo = new Combo(composite, 8); + GridData gridData = new GridData(); + gridData.heightHint = heightLength; + gridData.widthHint = widthLength; + newCombo.setLayoutData(gridData); + if ((items != null) && (items.length > 0)) { + newCombo.setItems(items); + } + newCombo.setVisible(true); + return newCombo; + } + + public static Combo createNewCombo(Composite composite, int heightLength, + int widthLength) { + Combo newCombo = new Combo(composite, 8); + GridData gridData = new GridData(); + gridData.heightHint = heightLength; + gridData.widthHint = widthLength; + newCombo.setLayoutData(gridData); + newCombo.setVisible(true); + return newCombo; + } + + public static Button createButton(Composite composite, String text, + int heightLength, int widthLength) { + // Button newButton = toolkit.createButton(composite, text, 8); + Button newButton = new Button(composite, SWT.NONE); + GridData gridData1 = new GridData(); + gridData1.heightHint = heightLength; + gridData1.widthHint = widthLength; + newButton.setLayoutData(gridData1); + newButton.setVisible(true); + return newButton; + } + + public static Text createTextArea(Composite composite, String text, + int heightLength, int widthLength) { + Text newTextArea = new Text(composite, SWT.MULTI | SWT.WRAP + | SWT.V_SCROLL | SWT.BORDER); + GridData gridData1 = new GridData(); + gridData1.heightHint = heightLength; + gridData1.widthHint = widthLength; + newTextArea.setLayoutData(gridData1); + newTextArea.setVisible(true); + return newTextArea; + } + + public static Text createNewTextArea(Composite parent, String initValue) { + Text newText = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL + | SWT.BORDER); + newText.setLayoutData(getNewGridData()); + newText.setText(initValue); + return newText; + } + + public static DateTime createDateButton(Composite composite, Date date, + int heightLength, int widthLength) { + DateTime newCombo = new DateTime(composite, SWT.MULTI | SWT.WRAP + | SWT.V_SCROLL | SWT.BORDER); + GridData gridData = new GridData(); + gridData.heightHint = heightLength; + gridData.widthHint = widthLength; + newCombo.setLayoutData(gridData); + if (date != null) { + newCombo.setData(date); + } + newCombo.setVisible(true); + return newCombo; + } + + public static GridData getNewGridData() { + GridData gridData = new GridData(); + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = false; + gridData.verticalAlignment = GridData.FILL; + return gridData; + } + + + + public static Text createNewText(Composite parent, String initValue) { + Text newText = new Text(parent, SWT.BORDER); + newText.setLayoutData(getNewGridData()); + newText.setText(initValue); + return newText; + } + + + + public static Button createNewCheckBox(Composite parent, String title) { + Button newButton = new Button(parent, SWT.CHECK); + newButton.setLayoutData(getNewGridData()); + newButton.setText(title); + return newButton; + } + + public static Combo createNewCombo(Composite parent, String[] items) { + Combo newCombo = new Combo(parent, SWT.BORDER); + newCombo.setLayoutData(getNewGridData()); + newCombo.setItems(items); + return newCombo; + } + + public static Combo createNewCombo(Composite parent) { + Combo newCombo = new Combo(parent, SWT.BORDER); + newCombo.setLayoutData(getNewGridData()); + return newCombo; + } + + public static Button createNewButton(Composite composite, String text) { + // Button newButton = toolkit.createButton(composite, text, 8); + Button newButton = new Button(composite, SWT.BUTTON1 | SWT.BORDER + | SWT.COLOR_BLUE); + GridData gridData1 = new GridData(); + gridData1.heightHint = 40; + gridData1.widthHint = 100; + newButton.setLayoutData(gridData1); + newButton.setText(text); + newButton.setVisible(true); + return newButton; + } + + public static Label createNewLabel(Composite parent, String title) { + Label label = new Label(parent, SWT.NONE); + label.setText(title + ""); + return label; + } + + public static Label createNewWhiteLabel(Composite parent, String title) { + Label label = new Label(parent, SWT.NONE); + label.setText(title + ""); + label.setBackground(Display.getCurrent() + .getSystemColor(SWT.COLOR_WHITE)); + return label; + } + + /*** + * ̷Ҫչ + * + * @param composite + * @param text + * @param heightLength + * @param widthLength + * @return + */ + public static Table createNewTable(Composite composite, String text, + int heightLength, int widthLength) { + final Table table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION); + + // Text newTextArea = new Text(composite, SWT.MULTI | SWT.WRAP | + // SWT.V_SCROLL | SWT.BORDER); + GridData gridData1 = new GridData(); + // gridData1.heightHint = heightLength; + // gridData1.widthHint = widthLength; + // gridData1.horizontalAlignment = SWT.FILL; + // gridData1.grabExcessHorizontalSpace = true; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = SWT.FILL; + table.addListener(SWT.MeasureItem, new Listener() { // һSWT.MeasureItemÿҪԪݵĴСʱͻᱻá + public void handleEvent(Event event) { + event.width = table.getGridLineWidth(); // ÿ + event.height = (int) Math.floor(event.gc + .getFontMetrics().getHeight() * 2); // ø߶Ϊ߶ȵ1.5 + } + }); + table.setLayoutData(gridData1); + table.setLinesVisible(true); + table.setVisible(true); + return table; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/GetChoosePath.java b/src/cn/com/origin/autocodemanager/common/GetChoosePath.java new file mode 100644 index 0000000..c2ec942 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/GetChoosePath.java @@ -0,0 +1,106 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: GetChoosePath.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2009-11-23 tyl õûѡ· +#============================================================================= + */ + +package cn.com.origin.autocodemanager.common; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; + +import javax.swing.JFileChooser; + +public class GetChoosePath { + private String title; + + public GetChoosePath(String title) { + this.title = title; + } + + /** + * getChoosePath:õûѡ· + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public File getChooseFile() { +// List choosePath = new ArrayList(); + String tempPath = System.getProperty("java.io.tmpdir"); + File tempFile = new File(tempPath + "\\importjobshop.txt"); + JFileChooser jfc = null; + if (!tempFile.exists()) { + try { + tempFile.createNewFile(); + jfc = new JFileChooser(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + if (tempFile.exists()) { + BufferedReader in; + try { + in = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile))); + String line; + try { + line = in.readLine(); + if ((line != null) && (line.length() > 0)) { + File file = new File(line); + if (file.exists()) { + jfc = new JFileChooser(file); + } else { + jfc = new JFileChooser(); + } + } else { + jfc = new JFileChooser(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + } + } + jfc.setFileSelectionMode(JFileChooser.CUSTOM_DIALOG); + jfc.setInheritsPopupMenu(true); + jfc.setDialogTitle(title); + jfc.setMultiSelectionEnabled(true); + + int openOrCancel = jfc.showSaveDialog(null); + File file = null; + if (openOrCancel == 0) { + try { + BufferedWriter output; + output = new BufferedWriter(new FileWriter(tempFile)); + output.write(jfc.getSelectedFile().getAbsolutePath()); + output.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + // File[] files = jfc.getSelectedFiles(); + // for (int i = 0; i < files.length; i++) { + // choosePath.add(files[i].getAbsolutePath()); + // } + file = jfc.getSelectedFile(); + } + // return choosePath; + return file; + } +} diff --git a/src/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.java b/src/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.java new file mode 100644 index 0000000..9d79683 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/IsShowAutocodeManagerPerspective.java @@ -0,0 +1,61 @@ +package cn.com.origin.autocodemanager.common; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class IsShowAutocodeManagerPerspective { + + //ֻڴѡõûȨ + private String showAutocodeManagerUserOptionName = "origin_showAutocodeManagerUsers"; + + public IsShowAutocodeManagerPerspective() { + + } + /** + * ͨ鵱ǰûǷȨ޲ + * @return + */ + public boolean getValue() { + boolean flag = false; + try { + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + String userID = session.getUser().getUserId(); + flag = isExist(userID, showAutocodeManagerUserOptionName); + } catch (TCException e) { + e.printStackTrace(); + } + return flag; + } + /** + * ûǷѡƥ + * @param value + * @param optionName + * @return + */ + public boolean isExist(String value, String optionName) { + boolean flag = false; + try { + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCPreferenceService preferenceService = session.getPreferenceService(); + String preferenceValues[] = preferenceService.getStringArray(TCPreferenceService.TC_preference_site, optionName); + if (preferenceValues != null && preferenceValues.length > 0) { + for (int i = 0; i < preferenceValues.length; i++) { + // System.out.println("preferenceValues===========" + + // preferenceValues[i]); + if (preferenceValues[i].trim().equalsIgnoreCase(value)) { + flag = true; + return flag; + } + } + } else { + flag = true; + return flag; + } + } catch (Exception e) { + e.printStackTrace(); + } + return flag; + } +} diff --git a/src/cn/com/origin/autocodemanager/common/PackCodeDescInfos.java b/src/cn/com/origin/autocodemanager/common/PackCodeDescInfos.java new file mode 100644 index 0000000..487a5c2 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/PackCodeDescInfos.java @@ -0,0 +1,125 @@ +package cn.com.origin.autocodemanager.common; + +import javax.swing.JTextField; + +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +import com.teamcenter.rac.util.iTextField; + +public class PackCodeDescInfos { + + private String generateID; + private String idDesc; + private String idjl; + private String codetz; + private AbstractTreeData selectedSegmentNode; + private String codeStyle; + + private iTextField idValueIText; + private iTextField revValueIText; + private iTextField nameValueIText; + + private JTextField idValueJText; + private JTextField revValueJText; + private JTextField nameValueJText; + + public PackCodeDescInfos() { + } + + public String getGenerateID() { + return generateID; + } + + public void setGenerateID(String generateID) { + this.generateID = generateID; + } + + public String getIdDesc() { + return idDesc; + } + + public void setIdDesc(String idDesc) { + this.idDesc = idDesc; + } + + public String getIdjl() { + return idjl; + } + + public void setIdjl(String idjl) { + this.idjl = idjl; + } + + public String getCodetz() { + return codetz; + } + + public void setCodetz(String codetz) { + this.codetz = codetz; + } + + public AbstractTreeData getSelectedSegmentNode() { + return selectedSegmentNode; + } + + public void setSelectedSegmentNode(AbstractTreeData selectedSegmentNode) { + this.selectedSegmentNode = selectedSegmentNode; + } + + public String getCodeStyle() { + return codeStyle; + } + + public void setCodeStyle(String codeStyle) { + this.codeStyle = codeStyle; + } + + public iTextField getIdValueIText() { + return idValueIText; + } + + public void setIdValueIText(iTextField idValueIText) { + this.idValueIText = idValueIText; + } + + public iTextField getRevValueIText() { + return revValueIText; + } + + public void setRevValueIText(iTextField revValueIText) { + this.revValueIText = revValueIText; + } + + public iTextField getNameValueIText() { + return nameValueIText; + } + + public void setNameValueIText(iTextField nameValueIText) { + this.nameValueIText = nameValueIText; + } + + public JTextField getIdValueJText() { + return idValueJText; + } + + public void setIdValueJText(JTextField idValueJText) { + this.idValueJText = idValueJText; + } + + public JTextField getRevValueJText() { + return revValueJText; + } + + public void setRevValueJText(JTextField revValueJText) { + this.revValueJText = revValueJText; + } + + public JTextField getNameValueJText() { + return nameValueJText; + } + + public void setNameValueJText(JTextField nameValueJText) { + this.nameValueJText = nameValueJText; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/TCLOVUtil.java b/src/cn/com/origin/autocodemanager/common/TCLOVUtil.java new file mode 100644 index 0000000..9750c10 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/TCLOVUtil.java @@ -0,0 +1,26 @@ +package cn.com.origin.autocodemanager.common; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class TCLOVUtil { + + + public static TCComponentListOfValues findLOVByName(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession.getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) + tccomponentlistofvalues = atccomponentlistofvalues[0]; + else + tccomponentlistofvalues = null; + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return tccomponentlistofvalues; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/TCPreferenceUitl.java b/src/cn/com/origin/autocodemanager/common/TCPreferenceUitl.java new file mode 100644 index 0000000..e539570 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/TCPreferenceUitl.java @@ -0,0 +1,134 @@ +package cn.com.origin.autocodemanager.common; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +import cn.com.origin.autocodemanager.common.encrypt.EncryptOperations; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class TCPreferenceUitl { + + public String getEnv(String name) { + String str = ""; + Iterator it = System.getenv().entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + // logger.info("entry-" + entry.getKey() + ":" + entry.getValue()); + if (entry.getKey().toString().equals(name)) { + str = entry.getValue() + ""; + if (!str.endsWith("\\")) { + str = str + "\\"; + } + break; + } + } + return str; + } + + /** + * @param tcsession + * @param preferenceName + * @param isSelectName + * @return + */ + public static boolean isSelectExsitToTCPreferenceValues(TCSession tcsession, String preferenceName, String isSelectName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String preferenceValues[] = preferenceService.getStringArray(TCPreferenceService.TC_preference_site, preferenceName); + if (preferenceValues == null) { + return false; + } + if (preferenceValues != null && preferenceValues.length > 0) { + for (int i = 0; i < preferenceValues.length; i++) { + // System.out.println(preferenceValues[i]); + if (preferenceValues[i].trim().equals(isSelectName)) { + flag = true; + return flag; + } + } + } + return flag; + } + + private static boolean isWriteExpire = false; + + public static synchronized boolean isWriteExpire() { + return isWriteExpire; + } + + public static synchronized void setWriteExpire(boolean isWriteExpire) { + TCPreferenceUitl.isWriteExpire = isWriteExpire; + } + + public static boolean isTrueTCPreferenceValue(TCSession tcsession, String preferenceName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(TCPreferenceService.TC_preference_site, preferenceName); + if (value == null) { + return false; + } + if (value.equalsIgnoreCase("true")) { + flag = true; + } + return flag; + } + + public static String getTCPreferenceValue(TCSession tcsession, String preferenceName) { + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(TCPreferenceService.TC_preference_all, preferenceName); + return value; + } + + public static String[] getListPreference(TCSession session, int scope, String pid) { + try { + String options[] = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static HashMap getPreferenceHashMap(TCSession pSession, int pScope, String pid) { + HashMap hm = new HashMap(); + Vector preferencekeyNames = new Vector(); + try { + String options[] = getPreference(pSession, pScope, pid); + if (options == null) { + return hm; + } + if (options == null || options.length == 0) + return null; + String key = ""; + String value = ""; + for (int i = 0; i < options.length; i++) + if (options[i].indexOf("=") > 0) { + key = options[i].substring(0, options[i].indexOf("=")); + value = options[i].substring(options[i].indexOf("=") + 1); + hm.put(key, value); + preferencekeyNames.add(key); + } else { + hm.put((new StringBuilder()).append(i).toString(), options[i]); + } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return hm; + } + + public static String[] getPreference(TCSession session, int scope, String pid) { + try { + String options[] = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cn/com/origin/autocodemanager/common/TCQueryUtil.java b/src/cn/com/origin/autocodemanager/common/TCQueryUtil.java new file mode 100644 index 0000000..aed0165 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/TCQueryUtil.java @@ -0,0 +1,50 @@ +package cn.com.origin.autocodemanager.common; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; + +public class TCQueryUtil { + + public static InterfaceAIFComponent[] searchComponentsCollection(TCSession session, String searchName, String[] keys, String[] values) { + // Ϣ + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find(searchName); + if (query == null) { + // MessageBox.post("뽨ѯ" + searchName + "!", "INFO", MessageBox.INFORMATION); + return result; + } + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + } + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + // MessageBox.post("ͨѯ" + searchName + "ѯ.", "INFO", MessageBox.ERROR); + e.printStackTrace(); + } + return result; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.java b/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.java new file mode 100644 index 0000000..1272f37 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeDialog.java @@ -0,0 +1,375 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.common.dialog; + +import java.util.HashMap; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import cn.com.origin.autocodemanager.common.AutoCodeConstants; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; +import cn.com.origin.autocodemanager.views.AutoCodeSegmentView; +import cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class AbstractCodeDialog extends Dialog { + public AbstractCreateTreeView createView; + public AbstractTreeData selectedTreeData; + public TCComponent selectedComponent; + public String title; + public boolean isEdit; + public TreeAndListCodeOperation treeAndListCodeOperation; + public TreeViewOperation treeViewOperation; + public Text nodeDescriptionText; + public Text nodeNameText; + public Text nodeValueText; + public Text codeStyleText; + public Text codeLengthText; + public Combo typeCombo; + public TCSession session; + public AutoCodeListCodeView codeListView; + public AutoCodeSegmentView codeSegmentView; + public AutoCodeTreeCodeView codeTreeView; + public Text seqBeginText; + public Text seqMaxText; + public Text seqStepText; + public Text seqExcludeStrText; + + public AbstractCodeDialog(Shell parentShell, AbstractCreateTreeView createView, String title, boolean isEdit) { + super(parentShell); + this.createView = createView; + this.title = title; + this.isEdit = isEdit; + initParams(); + this.selectedTreeData = treeViewOperation.getSelectedTreeNode(createView.treeViewer); + if (selectedTreeData != null) { + this.selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + } + } + + public void initParams() { + this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + this.treeViewOperation = new TreeViewOperation(); + codeListView = (AutoCodeListCodeView) createView.viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); + codeSegmentView = (AutoCodeSegmentView) createView.viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + codeTreeView = (AutoCodeTreeCodeView) createView.viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID); + } + + public AbstractCodeDialog(Shell parentShell, AbstractCreateTreeView createView, String title) { + super(parentShell); + this.title = title; + this.createView = createView; + this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + + return container; + } + + public void initNewCodeComposite(Composite composite) { + + } + + public String getSeqLength() { + String maxValue = getTextValue(seqMaxText); + if ((!maxValue.equalsIgnoreCase("0")) && (maxValue.trim().length() > 0)) { + return String.valueOf(maxValue.trim().length()); + } else { + return "0"; + } + } + + public void saveNewCodeNode(AbstractTreeData parentTreeData, TCComponent updateComponent, TreeViewer treeViewer, String type, boolean isRoot) { + HashMap hashMap = new HashMap(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + try { + if (isEdit) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, getTextValue(nodeNameText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, getTextValue(nodeValueText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, getTextValue(codeStyleText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, getTextValue(codeLengthText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, getTextValue(nodeDescriptionText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, ""); + + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, getTextValue(seqBeginText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, getSeqLength()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, getTextValue(seqMaxText)); + if (updateComponent != null) { + treeAndListCodeOperation.updateTreeORListNode(updateComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + treeViewer.refresh(selectedTreeData); + } + } else { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_index, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, getTextValue(nodeNameText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, getTextValue(nodeValueText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, type); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, getTextValue(codeStyleText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, getTextValue(codeLengthText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, ""); + + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, getTextValue(nodeDescriptionText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, String.valueOf(isRoot)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "false"); + + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, getTextValue(seqBeginText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, getSeqLength()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, getTextValue(seqMaxText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, ""); + + TCComponent ruleComponent = null; + if (!isRoot) { + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + if (segmentTreeData != null) { + ruleComponent = segmentTreeData.getPackCodeNodeInfo().getNodeComponent(); + } + } + TCComponent newComponent = new TreeAndListCodeOperation().createNewTreeORListNode(ruleComponent, parentTreeData, hashMap); + if (newComponent == null) { + return; + } + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(newComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + AbstractTreeData treeData = new AbstractTreeData(parentTreeData, packCodeNodeInfo); + treeViewOperation.addExistCodeNode(treeViewer, parentTreeData, treeData); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public String getTextValue(Text text) { + if (text != null) { + return text.getText().trim(); + } else { + return ""; + } + } + + public void createSeqComposite(Composite parent) { + Composite composite = new Composite(parent, 0); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.grabExcessHorizontalSpace = true; + gridData1.verticalSpan = 20; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = GridData.FILL; + composite.setLayoutData(gridData1); + composite.setLayout(gridLayout1); + initSeqPropertyComposite(composite); + try { + if (selectedTreeData != null) { + TCComponent selectedComp = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + selectedComp.refresh(); + if (selectedComp != null) { + selectedComp.refresh(); + String seqProperty[] = { AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value }; + String[] seqValues = selectedComp.getProperties(seqProperty); + setTextValue(seqBeginText, seqValues[0]); + setTextValue(seqMaxText, seqValues[1]); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void initSeqPropertyComposite(Composite parent) { + Composite seqComposite = new Composite(parent, SWT.NONE); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.grabExcessHorizontalSpace = true; + gridData1.verticalSpan = 20; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = GridData.FILL; + + seqComposite.setLayoutData(gridData1); + seqComposite.setLayout(gridLayout1); + createNewLabel(seqComposite, "ʼֵ"); + seqBeginText = createNewText(seqComposite, "1"); + createNewLabel(seqComposite, "ֵ"); + seqMaxText = createNewText(seqComposite, "9"); + } + + public void createNodeComposite(Composite parent) { + Composite composite = new Composite(parent, 0); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.grabExcessHorizontalSpace = true; + gridData1.verticalSpan = 20; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = GridData.FILL; + composite.setLayoutData(gridData1); + composite.setLayout(gridLayout1); + initNewCodeComposite(composite); + try { + if (selectedTreeData != null) { + TCComponent selectedComp = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(selectedComp, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + if (selectedComp != null) { + selectedComp.refresh(); + String seqProperty[] = { AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value }; + + String[] seqValues = selectedComp.getProperties(seqProperty); + setTextValue(codeStyleText, packCodeNodeInfo.getCode_style()); + setTextValue(codeLengthText, seqValues[0]); + + setTextValue(nodeNameText, packCodeNodeInfo.getNode_name()); + setTextValue(nodeValueText, packCodeNodeInfo.getNode_value()); + setTextValue(nodeDescriptionText, packCodeNodeInfo.getNode_desc()); + + setTextValue(seqBeginText, seqValues[1]); + setTextValue(seqMaxText, seqValues[2]); + if (typeCombo != null) { + if (packCodeNodeInfo.getNode_type().equals(AutoCodeManagerPropertyName.ListName)) { + typeCombo.setText("б"); + } else { + typeCombo.setText(""); + } + if (isEdit) { + typeCombo.setEnabled(false); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } catch (ServiceException e) { + e.printStackTrace(); + } + } + + public void setTextValue(Text text, String value) { + if (text != null) { + text.setText(value); + } + } + + public GridData getNewGridData() { + GridData gridData = new GridData(); + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = false; + gridData.verticalAlignment = GridData.FILL; + return gridData; + } + + public Group createCompositeGroup(Composite parent, String title) { + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + GridData gridData = new GridData(); + gridData.verticalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = true; + gridData.verticalSpan = 1; + gridData.horizontalAlignment = GridData.FILL; + Group codeTreeGroup = new Group(parent, SWT.NONE); + codeTreeGroup.setText(title); + codeTreeGroup.setLayout(gridLayout); + codeTreeGroup.setLayoutData(gridData); + return codeTreeGroup; + } + + public Text createNewText(Composite parent, String initValue) { + Text newText = new Text(parent, SWT.BORDER); + newText.setLayoutData(getNewGridData()); + newText.setText(initValue); + return newText; + } + + public Button createNewCheckBox(Composite parent, String title) { + Button newButton = new Button(parent, SWT.CHECK); + newButton.setLayoutData(getNewGridData()); + newButton.setText(title); + return newButton; + } + + public Combo createNewCombo(Composite parent, String[] items) { + Combo newCombo = new Combo(parent, SWT.BORDER); + newCombo.setLayoutData(getNewGridData()); + newCombo.setItems(items); + return newCombo; + } + + public Label createNewLabel(Composite parent, String title) { + Label label = new Label(parent, SWT.NONE); + label.setText(title + ""); + return label; + } + + public void postMesssageBox(String info) { + MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK); + mb.setText("INFO"); + mb.setMessage(info); + mb.open(); + } + + // Իť + @Override + protected void createButtonsForButtonBar(final Composite parent) { + createButton(parent, IDialogConstants.OK_ID, "ȷ", true); + createButton(parent, IDialogConstants.CANCEL_ID, "ر", false); + getButton(IDialogConstants.OK_ID).setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.OK_IMAGE)); + getButton(IDialogConstants.CANCEL_ID).setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CLOSE_IMAGE)); + } + + @Override + public boolean close() { + return super.close(); + } + + @Override + protected Point getInitialSize() { + return new Point(230, 150); + } +} diff --git a/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.java b/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.java new file mode 100644 index 0000000..47769e6 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/dialog/AbstractCodeSegmentDialog.java @@ -0,0 +1,184 @@ +/** + * @author tyl + * @Action ini + * 2011-4-1 + */ +package cn.com.origin.autocodemanager.common.dialog; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; +import cn.com.origin.autocodemanager.common.AutoCodeConstants; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.progress.ExpandProgressBar; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.ORTreeContentProvider; +import cn.com.origin.autocodemanager.common.tree.ORTreeLabelProvider; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.AutoCodeSegmentView; + +public class AbstractCodeSegmentDialog extends Dialog { + public TreeViewer treeViewer; + public Tree tree; + public AbstractCreateTreeView abstractTreeView; + public AbstractCreateTreeView createView; + public String title; + public TreeViewOperation treeViewOperation; + public int selected = 0; + public String action; + public AutoCodeSegmentView codeSegmentView; + public TreeAndListCodeOperation treeAndListCodeOperation; + + public AbstractCodeSegmentDialog(Shell parentShell, AbstractCreateTreeView createView, String title) { + super(parentShell); + this.createView = createView; + this.title = title; + initParams(); + codeSegmentView = (AutoCodeSegmentView) createView.viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + } + + public AbstractCodeSegmentDialog(Shell parentShell, AbstractCreateTreeView createView, String title, String action) { + super(parentShell); + this.createView = createView; + this.title = title; + initParams(); + this.action = action; + codeSegmentView = (AutoCodeSegmentView) createView.viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + } + + public AbstractCodeSegmentDialog(Shell parentShell, String title) { + super(parentShell); + this.title = title; + initParams(); + } + +private void initParams() +{ + this.treeViewOperation = new TreeViewOperation(); + this.treeAndListCodeOperation=new TreeAndListCodeOperation(); + +} + + public void createBottomComposite(Composite parent) { + } + + public void createTreeComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + FillLayout gridLayout1 = new FillLayout(); + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.grabExcessHorizontalSpace = true; + gridData1.verticalSpan = 20; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = GridData.FILL; + composite.setLayoutData(gridData1); + composite.setLayout(gridLayout1); + createTree(composite, ""); + } + + public void initTree(String rootName) { + treeViewer.setLabelProvider(new ORTreeLabelProvider()); + treeViewer.setContentProvider(new ORTreeContentProvider()); + AbstractTreeData treeData = new AbstractTreeData(null, null, rootName, AutoCodeManagerPropertyName.SegmentName, false); + treeViewer.setInput((new Object[] { treeData })); + addRightKeyAction(); + } + + public void createTree(Composite parent, String rootName) { + Composite composite = parent; + treeViewer = new TreeViewer(composite, SWT.BORDER); + tree = treeViewer.getTree(); + initTree(rootName); + + treeViewer.expandToLevel(1); + tree.addTreeListener(new TreeListener() { + public void treeCollapsed(TreeEvent treeEvent) { + } + public void treeExpanded(TreeEvent treeEvent) { + if (selected <= 1) { + selected++; + } + AbstractTreeData codeData = (AbstractTreeData) treeEvent.item.getData(); + if (codeData == null) { + return; + } + try { + expandNode(codeData); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (selected <= 1) { + selected++; + } + AbstractTreeData selectedData = (AbstractTreeData) e.item.getData(); + if (selectedData == null) { + return; + } + if (selectedData.getParentTreeData() == null) { + expandNode(selectedData); + } + } + }); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView#addRightKeyAction() + */ + public void addRightKeyAction() {} + public void expandNode(AbstractTreeData codeData) { + if (selected == 1) { + return; + } + AbstractTreeData[] codeDatas = new AbstractTreeData[] { codeData }; + if (codeData == null) { + return; + } + if (codeData.isChildrenLoader()) { + codeDatas = codeData.getChildrenDatas(); + } + ExpandProgressBar expandProgressBar = new ExpandProgressBar(Display.getDefault().getActiveShell(), "ڴ", this, codeDatas); + try { + expandProgressBar.expand(); + } catch (Exception e) { + e.printStackTrace(); + } + } + /* + * (non-Javadoc) + * + * @see cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView#createOrgAutoCodeNodeChildren(cn.com.origin.autocodemanager.common.tree.AbstractTreeData[]) + */ +// + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) throws Exception {} + + // öԻ򴰿ڱͼ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CODENODE_IMAGE)); + } +} diff --git a/src/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.java b/src/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.java new file mode 100644 index 0000000..aea04f0 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/encrypt/EncryptOperations.java @@ -0,0 +1,18 @@ +package cn.com.origin.autocodemanager.common.encrypt; + +public class EncryptOperations { + + private static boolean isLicenseExpire = true; + + public static synchronized boolean isLicenseExpire() { + return isLicenseExpire; + } + + public static synchronized void setLicenseExpire(boolean isLicenseExpire) { + EncryptOperations.isLicenseExpire = isLicenseExpire; + } + + public EncryptOperations() { + // TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + } +} diff --git a/src/cn/com/origin/autocodemanager/common/operations/ExcelOperation.java b/src/cn/com/origin/autocodemanager/common/operations/ExcelOperation.java new file mode 100644 index 0000000..8913fd6 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/operations/ExcelOperation.java @@ -0,0 +1,145 @@ +package cn.com.origin.autocodemanager.common.operations; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import jxl.Cell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Colour; +import jxl.format.Pattern; +import jxl.format.UnderlineStyle; +import jxl.read.biff.BiffException; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +/** + * @author wangjj Excelȡ + * + */ +public class ExcelOperation { + + public ExcelOperation() { + + } + + public static ArrayList> readExcel(File fileExcel, int startRow, String headTiles[]) throws BiffException, IOException { + ArrayList> arrayList = new ArrayList>(); + if (fileExcel != null) { + Workbook workBook = Workbook.getWorkbook(fileExcel); + Sheet sheet = workBook.getSheet(0); + if (headTiles != null && headTiles.length > 0) { + for (int i = startRow; i < sheet.getRows(); i++) { + HashMap hashMap = new HashMap(); + for (int k = 0; k < headTiles.length; k++) { +// System.out.println(headTiles + "[" + k + "]=" + headTiles[k]); + if (sheet.findCell(headTiles[k]) != null) { + Cell cell = sheet.getCell(sheet.findCell(headTiles[k]).getColumn(), i); +// System.out.println("cell================" + cell); + if (cell != null) { + hashMap.put(headTiles[k], cell.getContents()); + } + } + } + // System.out.println(hashMap); + arrayList.add(hashMap); + } + } + workBook.close(); + } else { + // System.out.println("EXCELļΪ"); + } + return arrayList; + } + + public static void writeExcel(String sheettile, File fileExcel, Object[] cloumnNames, ArrayList arrayList) throws IOException { + WritableWorkbook wbook = Workbook.createWorkbook(fileExcel); + wbook.createSheet(sheettile, 0); + WritableSheet writableSheet = wbook.getSheet(0); + Object[] titles = cloumnNames; + WritableFont font = new WritableFont(WritableFont.COURIER, 9, WritableFont.BOLD, false, UnderlineStyle.SINGLE_ACCOUNTING, jxl.format.Colour.BLUE); + WritableCellFormat wcfFC = new WritableCellFormat(font); // õԪʽ,ɫ. + try { + // wcfFC.setBackground(Colour.CORAL, Pattern.SOLID); // õԪɫ + wcfFC.setBackground(Colour.WHITE, Pattern.SOLID); // + wcfFC.setAlignment(Alignment.CENTRE); + for (int i = 0; i < titles.length; i++) { + Label l = new Label(i, 0, (String) titles[i]); + l.setCellFormat(wcfFC); // õԪʽ/ʽ + writableSheet.setColumnView(i, 12); + writableSheet.addCell(l); + } + if (arrayList != null && arrayList.size() > 0) { + for (int n = 0; n < arrayList.size(); n++) { + HashMap hashMap = (HashMap) arrayList.get(n); + if (cloumnNames != null && cloumnNames.length > 0) { + for (int k = 0; k < titles.length; k++) { + String str = (String) hashMap.get(titles[k]); + Label labelValue = new Label(k, n + 1, str); + writableSheet.addCell(labelValue); + } + } + } + } + wbook.write(); // дexcelļ. + wbook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + if (fileExcel.exists()) { + openFile(fileExcel.getAbsolutePath()); + } + } + + public static void openFile(String targetFile) { + File file = new File(targetFile); + if (file.exists()) { + Boolean value = false; + value = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "INFO", "ļѾɣǷ򿪣"); + if (value) { + try { + Runtime runtime = Runtime.getRuntime(); + runtime.exec("cmd /c start exit &&\"" + targetFile + "\" "); + // String as1[] = { "cmd.exe", "/c", "start", targetFile }; + // runtime.exec(as1); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static boolean isInteger(String value) { + try { + Integer.parseInt(value); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + public static boolean isDouble(String value) { + try { + Double.parseDouble(value); + if (value.contains(".")) + return true; + return false; + } catch (NumberFormatException e) { + return false; + } + } + + public static boolean isNumber(String value) { + return isInteger(value) || isDouble(value); + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.java b/src/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.java new file mode 100644 index 0000000..321617b --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/operations/GetCodeNumber.java @@ -0,0 +1,78 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common.operations; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class GetCodeNumber { + + private TCUserService userService; + + public GetCodeNumber() { + try { + userService = (TCUserService) ((TCSession) AIFUtility.getCurrentApplication().getSession()).getUserService(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + public void delete_recycleID(String itemID) { + // Object[] params = { counterName, itemID }; + if ((itemID == null) || (itemID.length() == 0)) { + return; + } + itemID = itemID.replace(" ", "").trim(); + Object[] params = { itemID }; + try { + userService.call("delete_recycleID", params); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @param patternCode + * @param codeLength + * @param startIndex + * @param endIndex + * @param increaseStep + * @return + * @throws ServiceException + */ + public String getCodeNumber(String patternCode, int codeLength, int startIndex, int maxValue, int increaseStep, String excludeStr) throws ServiceException { + if (maxValue == startIndex) { + return String.valueOf(maxValue); + } + if (startIndex < 1) { + startIndex = 1; + } + if (maxValue < startIndex) { + return String.valueOf(startIndex); + } + codeLength = String.valueOf(maxValue).length(); + Object[] params = { patternCode.replace(" ", "").trim(), codeLength, startIndex, maxValue, increaseStep, excludeStr }; +// System.out.println("patternCode===========" + patternCode); +// System.out.println("codeLength===========" + codeLength); +// System.out.println("startIndex===========" + startIndex); +// System.out.println("endIndex===========" + maxValue); +// System.out.println("increaseStep===========" + increaseStep); +// System.out.println("excludeStr===========" + excludeStr); + try { + String str = ""; + str = (String) userService.call("queryPartNo", params); + return str; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.java b/src/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.java new file mode 100644 index 0000000..cec59eb --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/operations/PackCodeNodeInfo.java @@ -0,0 +1,124 @@ +package cn.com.origin.autocodemanager.common.operations; + + +import com.teamcenter.rac.kernel.TCComponent; + +public class PackCodeNodeInfo { + private TCComponent nodeComponent; + private String realTypeName; + + private String node_name = ""; + private String node_type = ""; + public String node_value = ""; + public String node_desc = ""; + public String code_style = ""; + public String rule_node = ""; + // boolean + public boolean is_root=false; + public boolean is_lock=false; + public boolean isDefaultSelected=false; + public boolean isContainsChildren=false; + // date + public String create_date = ""; + public String last_revise_date = ""; + // user + public String create_user = ""; + public String last_revise_user = ""; + public TCComponent getNodeComponent() { + return nodeComponent; + } + public void setNodeComponent(TCComponent nodeComponent) { + this.nodeComponent = nodeComponent; + } + public String getRealTypeName() { + return realTypeName; + } + public void setRealTypeName(String realTypeName) { + this.realTypeName = realTypeName; + } + public String getNode_name() { + return node_name; + } + public void setNode_name(String node_name) { + this.node_name = node_name; + } + public String getNode_type() { + return node_type; + } + public void setNode_type(String node_type) { + this.node_type = node_type; + } + public String getNode_value() { + return node_value; + } + public void setNode_value(String node_value) { + this.node_value = node_value; + } + public String getNode_desc() { + return node_desc; + } + public void setNode_desc(String node_desc) { + this.node_desc = node_desc; + } + public String getCode_style() { + return code_style; + } + public void setCode_style(String code_style) { + this.code_style = code_style; + } + public String getRule_node() { + return rule_node; + } + public void setRule_node(String rule_node) { + this.rule_node = rule_node; + } + public boolean isIs_root() { + return is_root; + } + public void setIs_root(boolean is_root) { + this.is_root = is_root; + } + public boolean isIs_lock() { + return is_lock; + } + public void setIs_lock(boolean is_lock) { + this.is_lock = is_lock; + } + public boolean isDefaultSelected() { + return isDefaultSelected; + } + public void setDefaultSelected(boolean isDefaultSelected) { + this.isDefaultSelected = isDefaultSelected; + } + public boolean isContainsChildren() { + return isContainsChildren; + } + public void setContainsChildren(boolean isContainsChildren) { + this.isContainsChildren = isContainsChildren; + } + public String getCreate_date() { + return create_date; + } + public void setCreate_date(String create_date) { + this.create_date = create_date; + } + public String getLast_revise_date() { + return last_revise_date; + } + public void setLast_revise_date(String last_revise_date) { + this.last_revise_date = last_revise_date; + } + public String getCreate_user() { + return create_user; + } + public void setCreate_user(String create_user) { + this.create_user = create_user; + } + public String getLast_revise_user() { + return last_revise_user; + } + public void setLast_revise_user(String last_revise_user) { + this.last_revise_user = last_revise_user; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.java b/src/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.java new file mode 100644 index 0000000..f20b643 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/operations/TreeAndListCodeOperation.java @@ -0,0 +1,780 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common.operations; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class TreeAndListCodeOperation { + private TCUserService userService; + private TCSession session = null; + + public TreeAndListCodeOperation() { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + try { + userService = (TCUserService) session.getUserService(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public int isDateExpire() { + int isDateExpire = 1; + Object[] params = {}; + try { + isDateExpire = (Integer) userService.call("isExpire", params); +// System.out.println("isDateExpire=-=========" + isDateExpire); + } catch (TCException e) { + e.printStackTrace(); + } + return isDateExpire; + } + + public void addNodeReferenceComponents(TCComponent component, TCComponent referenceComponent) { + if ((component == null) || (referenceComponent == null)) { + return; + } + try { + TCComponent[] components = getNodeReferenceComponents(component); + if (components != null) { + for (int i = 0; i < components.length; i++) { + if (components[i].equals(referenceComponent)) { + return; + } + } + } + component.add(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, referenceComponent); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void removeNodeReferenceComponents(TCComponent component, TCComponent referenceComponent) { + if ((component == null) || (referenceComponent == null)) { + return; + } + TCComponent[] components = getNodeReferenceComponents(component); + try { + if (components != null) { + for (int i = 0; i < components.length; i++) { + if (components[i].equals(referenceComponent)) { + component.remove(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, referenceComponent); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public TCComponent[] getNodeReferenceComponents(TCComponent component) { + if ((component == null)) { + return null; + } + TCComponent[] components = null; + try { + components = component.getTCProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes).getReferenceValueArray(); + } catch (TCException e) { + e.printStackTrace(); + } + return components; + } + + public TCComponent createNewTreeORListNode(TCComponent ruleNode, AbstractTreeData parentData, HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + System.out.println("i am in createNewTreeORListNode propNames[i]="+propNames[i]+" propValues[i]="+propValues[i]); + } + Object[] params = { propNames, propValues }; + try { + TCComponent newTCcomponent = (TCComponent) userService.call("createNewTreeOrListNode", params); + if (newTCcomponent == null) { + return null; + } + if (!newTCcomponent.getProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type).equals(AutoCodeManagerPropertyName.CodeGroupName)) { + if (ruleNode == null) { + newTCcomponent.setReferenceProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, newTCcomponent); + } else { + newTCcomponent.setReferenceProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, ruleNode); + newTCcomponent.getTCProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes).setReferenceValueArray(new TCComponent[] { ruleNode }); + } + } + return newTCcomponent; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public TCComponent updateTreeORListNode(TCComponent component, HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { component, propNames, propValues }; + try { + TCComponent updateTCcomponent = (TCComponent) userService.call("updateTreeORListNode", params); + return updateTCcomponent; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + + public boolean deleteTreeORListNode(AbstractTreeData segmentTreeData, AbstractTreeData deleteTreeData) throws ServiceException, TCException { + return deleteTreeRelations(segmentTreeData, deleteTreeData); + } + + public boolean deleteTreeRelations(AbstractTreeData segmentTreeData, AbstractTreeData deleteTreeData) { + TCComponent segmentComponent = null; + TCComponent deleteComponent = null; + boolean isContinueDelete = true; + if ((deleteTreeData != null) && (deleteTreeData.getPackCodeNodeInfo().getNodeComponent() != null)) { + deleteComponent = deleteTreeData.getPackCodeNodeInfo().getNodeComponent(); + } else { + isContinueDelete = false; + return isContinueDelete; + } + if ((segmentTreeData != null) && (segmentTreeData.getPackCodeNodeInfo().getNodeComponent() != null)) { + segmentComponent = segmentTreeData.getPackCodeNodeInfo().getNodeComponent(); + } + TCComponent[] referenceNode = getNodeReferenceComponents(deleteComponent); + if (referenceNode != null) { + if (referenceNode.length > 1) { + MessageBox.post(deleteTreeData.getPackCodeNodeInfo().getNode_name() + "Ѿʹòɾ", "INFO", MessageBox.WARNING); + isContinueDelete = false; + return isContinueDelete; + } + } + String parentStr = ""; + isContinueDelete = deleteChildrenRelations(getParentStr(deleteTreeData, parentStr), deleteTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(), null, isContinueDelete); + if (isContinueDelete) { + if (segmentComponent != null) { + removeNodeReferenceComponents(deleteComponent, segmentComponent); + } + try { + TCComponent ruleComponent = deleteComponent.getReferenceProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node); + if ((deleteTreeData.getPackCodeNodeInfo().is_root) || (deleteTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.CodeGroupName))) { + updateClassificationAfterDeleteSegment(deleteComponent); + updateTreeRelationAfterDelete(deleteComponent); + deleteTreeData(deleteComponent); + } else { + if ((segmentComponent != null) && (ruleComponent != null) && (ruleComponent.equals(segmentComponent))) { + updateTreeRelationAfterDelete(deleteComponent); + deleteTreeData(deleteComponent); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + if (isContinueDelete) { + MessageBox.post("ɾɹ", "INFO", MessageBox.WARNING); + } + return isContinueDelete; + } + + public void removeTreeORListNode(AbstractTreeData segmentTreeData, AbstractTreeData deleteTreeData) throws ServiceException, TCException { + removeTreeRelations(segmentTreeData, deleteTreeData); + updateTreeRelation(deleteTreeData); + removeNodeReferenceComponents(deleteTreeData.getPackCodeNodeInfo().getNodeComponent(), segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + } + + public void updateTreeRelation(AbstractTreeData deleteTreeData) { + if ((deleteTreeData != null) && (deleteTreeData.getPackCodeNodeInfo().getNodeComponent() != null)) { + String currentStr = ""; + String parentStr = ""; + parentStr = getParentStr(deleteTreeData.getParentTreeData(), parentStr); + String childrenStr = deleteTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(); + if ((deleteTreeData.getParentTreeData() != null) && (deleteTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent() != null)) { + currentStr = deleteTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent().getUid(); + } else { + currentStr = ""; + } + Object[] params = { parentStr, currentStr, childrenStr }; + try { + userService.call("removeTreeRelation", params); + } catch (TCException e) { + e.printStackTrace(); + return; + } + } + } + + public void removeTreeRelations(AbstractTreeData segmentTreeData, AbstractTreeData deleteTreeData) { + String parentStr = ""; + removeChildrenRelations(getParentStr(deleteTreeData, parentStr), deleteTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(), segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + } + + private void removeChildrenRelations(String parentStr, String currentStr, TCComponent segmentComponent) { + try { + TCComponent[] tccomponents = null; + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr.trim()); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, currentStr.trim()); + tccomponents = searchTreeORListNodes(hashMap); + if (tccomponents == null) { + return; + } + for (int i = 0; i < tccomponents.length; i++) { + String parentStr2 = parentStr + "," + currentStr; + if (parentStr2.trim().startsWith(",")) { + parentStr2 = parentStr2.substring(1); + } + if (isRuleRootNode(tccomponents[i])) { + segmentComponent = tccomponents[i]; + updateClassificationAfterDeleteSegment(segmentComponent); + } + removeChildrenRelations(parentStr2, tccomponents[i].getUid().trim(), segmentComponent); + deleteCodeRelations(hashMap); + removeNodeReferenceComponents(tccomponents[i], segmentComponent); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void updateClassificationAfterDeleteSegment(TCComponent deleteComponent) { + if (deleteComponent != null) { + Object[] params = { deleteComponent.getUid() }; + try { + userService.call("updateClassificationAfterDeleteSegment", params); + } catch (TCException e) { + e.printStackTrace(); + return; + } + } + } + + public boolean isRuleRootNode(TCComponent component) { + if (component == null) { + return false; + } + try { + if ((component.getLogicalProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root))) { + return true; + } + } catch (TCException e) { + e.printStackTrace(); + } + return false; + } + + public void deleteTreeData(TCComponent deleteComponent) { + if (deleteComponent == null) { + return; + } + try { + deleteComponent.getTCProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes).setReferenceValueArray(null); + deleteComponent.getTCProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node).setReferenceValue(null); + deleteComponent.delete(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private boolean deleteChildrenRelations(String parentStr, String currentStr, TCComponent segmentComponent, boolean isContinueDelete) { + try { + if (!isContinueDelete) { + return false; + } + TCComponent[] tccomponents = null; + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr.trim()); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, currentStr.trim()); + tccomponents = searchTreeORListNodes(hashMap); + if (tccomponents == null) { + return false; + } + for (int i = 0; i < tccomponents.length; i++) { + TCComponent[] referenceNode = getNodeReferenceComponents(tccomponents[i]); + if (referenceNode != null) { + if (referenceNode.length > 1) { + tccomponents[i].refresh(); + MessageBox.post(tccomponents[i].getProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name) + "Ѿɾ", "INFO", MessageBox.WARNING); + return false; + } + } + } + for (int i = 0; i < tccomponents.length; i++) { + String parentStr2 = parentStr + "," + currentStr; + if (parentStr2.trim().startsWith(",")) { + parentStr2 = parentStr2.substring(1); + } + if (isRuleRootNode(tccomponents[i])) { + segmentComponent = tccomponents[i]; + } + isContinueDelete = deleteChildrenRelations(parentStr2, tccomponents[i].getUid().trim(), segmentComponent, isContinueDelete); + if (isContinueDelete) { + removeNodeReferenceComponents(tccomponents[i], segmentComponent); + try { + TCComponent ruleComponent = tccomponents[i].getReferenceProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node); + tccomponents[i].refresh(); + if ((isRuleRootNode(tccomponents[i])) || (tccomponents[i].getProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type).equals(AutoCodeManagerPropertyName.CodeGroupName))) { + updateClassificationAfterDeleteSegment(tccomponents[i]); + updateTreeRelationAfterDelete(tccomponents[i]); + deleteTreeData(tccomponents[i]); + } else { + if ((segmentComponent != null) && (ruleComponent != null) && (ruleComponent.equals(segmentComponent))) { + updateTreeRelationAfterDelete(tccomponents[i]); + deleteTreeData(tccomponents[i]); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + } + if (isContinueDelete) { + deleteCodeRelations(hashMap); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + return isContinueDelete; + } + + private void updateTreeRelationAfterDelete(TCComponent deleteComponent) { + Object[] params = { deleteComponent.getUid() }; + try { + System.out.println("removeTreeRelationAfterDelete hashMap=== "+deleteComponent); + userService.call("removeTreeRelationAfterDelete", params); + } catch (TCException e) { + e.printStackTrace(); + return; + } + } + + public void deleteCodeRelations(HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + System.out.println("deleteCodeRelations hashMap=== "+hashMap); + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { propNames, propValues }; + try { + userService.call("deleteCodeRelations", params); + return; + } catch (TCException e) { + e.printStackTrace(); + return; + } + } + + public TCComponent[] searchParentTreeOrListNodes(HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { propNames, propValues }; + try { + TCComponent[] searchTCcomponents = (TCComponent[]) userService.call("searchParentTreeOrListNodes", params); + return searchTCcomponents; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + + public boolean isContainsChildrenNodes(HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { propNames, propValues }; + try { + String value = (String) userService.call("isContainsChildrenNodes", params); + if (value.trim().equals("true")) { + return true; + } + } catch (TCException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public TCComponent updateCodeRelation(TCComponent component, HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { component, propNames, propValues }; + try { + TCComponent updateTCcomponent = (TCComponent) userService.call("updateCodeRelation", params); + return updateTCcomponent; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + + public TCComponent updateChildrenCodeRelation(String parentStr, String currentStr, String childrenStr) { + try { + String[] propNames1 = new String[] { AutoCodeManagerPropertyName.CodeRelation_parent_node, AutoCodeManagerPropertyName.CodeRelation_current_node }; + String[] propValues1 = new String[] { parentStr, currentStr }; + Object[] params1 = { propNames1, propValues1 }; + + TCComponent[] existComponent = (TCComponent[]) userService.call("searchCodeRelation", params1); + if (existComponent.length > 0) { + for (int i = 0; i < existComponent.length; i++) { + try { + String[] propNames2 = new String[] { AutoCodeManagerPropertyName.CodeRelation_parent_node, AutoCodeManagerPropertyName.CodeRelation_current_node, AutoCodeManagerPropertyName.CodeRelation_children_nodes, AutoCodeManagerPropertyName.CodeRelation_create_date, + AutoCodeManagerPropertyName.CodeRelation_create_user }; + String[] propValues2 = new String[] { parentStr, currentStr, childrenStr, "", "" }; + + Object[] params2 = { existComponent[i], propNames2, propValues2 }; + TCComponent updateTCcomponent = (TCComponent) userService.call("updateCodeRelation", params2); + return updateTCcomponent; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + } + } catch (TCException e) { + e.printStackTrace(); + return null; + } + return null; + } + + public TCComponent createNewCodeRelation(AbstractTreeData currentData, TCComponent childrenComponent) { + try { + String currentDatas = ""; + String childrenDatas = ""; + childrenDatas = getChildrenData(currentData, childrenDatas, childrenComponent); + String parentStr = ""; + parentStr = getParentStr(currentData, parentStr); + if (currentData != null) { + if (currentData.getPackCodeNodeInfo().getNodeComponent() != null) { + currentDatas = currentData.getPackCodeNodeInfo().getNodeComponent().getUid(); + } else { + currentDatas = ""; + } + } else { + currentDatas = ""; + } + System.out.println("createNewCodeRelation::existComponent::parentStr===="+parentStr); + System.out.println("createNewCodeRelation::existComponent::currentDatas===="+currentDatas); + + String[] propNames1 = new String[] { AutoCodeManagerPropertyName.CodeRelation_parent_node, AutoCodeManagerPropertyName.CodeRelation_current_node }; + String[] propValues1 = new String[] { parentStr, currentDatas }; + Object[] params1 = { propNames1, propValues1 }; + TCComponent[] existComponent = (TCComponent[]) userService.call("searchCodeRelation", params1); + System.out.println("createNewCodeRelation::::existComponent===="+existComponent); + if (existComponent.length > 0) { + for (int i = 0; i < existComponent.length; i++) { + try { + System.out.println("createNewCodeRelation::::existComponent.length===="+existComponent.length); + + String[] propNames2 = new String[] { AutoCodeManagerPropertyName.CodeRelation_parent_node, AutoCodeManagerPropertyName.CodeRelation_current_node, AutoCodeManagerPropertyName.CodeRelation_children_nodes, AutoCodeManagerPropertyName.CodeRelation_create_date, + AutoCodeManagerPropertyName.CodeRelation_create_user }; + String[] propValues2 = new String[] { parentStr, currentDatas, childrenDatas, "", "" }; + Object[] params2 = { existComponent[i], propNames2, propValues2 }; + + TCComponent updateTCcomponent = (TCComponent) userService.call("updateCodeRelation", params2); + return updateTCcomponent; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + } else { + System.out.println("createNewCodeRelation::::createNewCodeRelation===="); + String[] propNames3 = new String[] { AutoCodeManagerPropertyName.CodeRelation_parent_node, AutoCodeManagerPropertyName.CodeRelation_current_node, AutoCodeManagerPropertyName.CodeRelation_children_nodes, AutoCodeManagerPropertyName.CodeRelation_create_date, + AutoCodeManagerPropertyName.CodeRelation_create_user }; + String[] propValues3 = new String[] { parentStr, currentDatas, childrenDatas, "", "" }; + System.out.println("parentStr===="+parentStr); + System.out.println("currentDatas===="+currentDatas); + System.out.println("childrenDatas===="+childrenDatas); + Object[] params3 = { propNames3, propValues3 }; + TCComponent newTCcomponent = (TCComponent) userService.call("createNewCodeRelation", params3); + return newTCcomponent; + } + } catch (TCException e) { + e.printStackTrace(); + return null; + } + return null; + } + + public String getParentStr(AbstractTreeData treeData, String parentStr) { + System.out.println("i am in getParentStr == "+parentStr); + + if (treeData != null) { + AbstractTreeData parentData = treeData.getParentTreeData(); + if ((parentData != null) && ((parentData.getPackCodeNodeInfo().getNodeComponent() != null))) { + System.out.println("parentData.getPackCodeNodeInfo() "+parentData.getPackCodeNodeInfo().getNode_name()); + if(parentData.getPackCodeNodeInfo().getNodeComponent()!=null){ + System.out.println("i am not null"); + } + if (parentStr.length() > 0) { + parentStr = parentData.getPackCodeNodeInfo().getNodeComponent().getUid() + "," + parentStr; + } else { + parentStr = parentData.getPackCodeNodeInfo().getNodeComponent().getUid(); + } + parentStr = getParentStr(parentData, parentStr); + System.out.println("parentStr AAA === "+parentStr); + } + }else{ + System.out.println(" treeDtae =null"); + } + if (parentStr.toString().endsWith(",")) { + parentStr = parentStr.substring(0, parentStr.length() - 1).toString(); + } + return parentStr; + } + + private String getChildrenData(AbstractTreeData treeData, String str, TCComponent childrenComponent) { + boolean isLoader = false; + if (treeData != null) { + AbstractTreeData[] childrenData = treeData.getChildrenDatas(); + if ((childrenData != null) && (childrenData.length > 0)) { + for (int i = 0; i < childrenData.length; i++) { + if (childrenData[i].getPackCodeNodeInfo().getNodeComponent() != null) { + if (childrenComponent.equals(childrenData[i].getPackCodeNodeInfo().getNodeComponent())) { + isLoader = true; + } + str = str + childrenData[i].getPackCodeNodeInfo().getNodeComponent().getUid(); + str = str + ","; + } + } + } + } + if (!isLoader) { + if (childrenComponent != null) { + str = str + childrenComponent.getUid(); + } + } + if (str.endsWith(",")) { + str = str.substring(0, str.length() - 1).toString(); + } + return str; + } + + public TCComponent[] searchTreeORListNodes(HashMap hashMap) throws ServiceException, TCException { + String[] propNames = new String[hashMap.size()]; + String[] propValues = new String[hashMap.size()]; + Set set = hashMap.keySet(); + Iterator it = set.iterator(); + for (int i = 0; i < hashMap.size(); i++) { + propNames[i] = (String) it.next(); + propValues[i] = (String) hashMap.get(propNames[i]); + } + Object[] params = { propNames, propValues }; + try { + TCComponent[] searchTCcomponents = (TCComponent[]) userService.call("searchTreeORListNodes", params); + // System.out.println("��ѯ���Ϊ�? + searchTCcomponents.length + "��"); + return searchTCcomponents; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + public PackCodeNodeInfo getTreeAndListStringValue(TCComponent component, String[] returnPropertyNames) throws ServiceException, TCException { + PackCodeNodeInfo packCodeNodeInfo = new PackCodeNodeInfo(); + try { + Object[] params = { component, returnPropertyNames }; + System.out.println("=================="); + String returnValues = (String) userService.call("getTreeAndListStringValue", params); + System.out.println("1111111111111111111111111"); + String[] values = returnValues.split("&&"); + if ((values != null) && (values.length > 0)) { + if (returnPropertyNames.equals(AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames)) { + packCodeNodeInfo.setNodeComponent(component); + packCodeNodeInfo.setNode_name(getStringValue(values[0])); + packCodeNodeInfo.setNode_type(getStringValue(values[1])); + packCodeNodeInfo.setNode_value(getStringValue(values[2])); + packCodeNodeInfo.setNode_desc(getStringValue(values[3])); + packCodeNodeInfo.setCode_style(getStringValue(values[4])); + packCodeNodeInfo.setRule_node(getStringValue(values[5])); + if (values[6].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_root(true); + } + if (values[7].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_lock(true); + } + if (values[8].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setDefaultSelected(true); + } + packCodeNodeInfo.setCreate_date(getStringValue(values[9])); + packCodeNodeInfo.setLast_revise_date(getStringValue(values[10])); + packCodeNodeInfo.setCreate_user(getStringValue(values[11])); + packCodeNodeInfo.setLast_revise_user(getStringValue(values[12])); + if (values[13].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setContainsChildren(true); + } + } else { + packCodeNodeInfo.setNodeComponent(component); + packCodeNodeInfo.setNode_name(getStringValue(values[0])); + packCodeNodeInfo.setNode_type(getStringValue(values[1])); + if (values[2].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_root(true); + } + if (values[3].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_lock(true); + } + if (values[4].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setContainsChildren(true); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return packCodeNodeInfo; + } + + private List getTreeORListNodeInfos(TCComponent[] searchTCcomponents, String parentString, String[] returnPropertyNames) { + List packCodeNodeInfos = new ArrayList(); + try { + if (searchTCcomponents != null && searchTCcomponents.length > 0) { + String[] stringValues = getTreeAndListStringValues(searchTCcomponents, returnPropertyNames, parentString); + System.out.println("stringPropNames====1111=========== "+stringValues); +// System.out.println("stringPropNames====1111=========== "+stringValues.length); + + if (stringValues == null) { + return null; + } + for (int i = 0; i < stringValues.length; i++) { + String[] values = stringValues[i].split("&&"); + PackCodeNodeInfo packCodeNodeInfo = new PackCodeNodeInfo(); + if ((values != null) && (values.length > 0)) { + if (returnPropertyNames.equals(AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames)) { + packCodeNodeInfo.setNodeComponent(searchTCcomponents[i]); + packCodeNodeInfo.setNode_name(getStringValue(values[0])); + packCodeNodeInfo.setNode_type(getStringValue(values[1])); + packCodeNodeInfo.setNode_value(getStringValue(values[2])); + packCodeNodeInfo.setNode_desc(getStringValue(values[3])); + packCodeNodeInfo.setCode_style(getStringValue(values[4])); + packCodeNodeInfo.setRule_node(getStringValue(values[5])); + if (values[6].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_root(true); + } + if (values[7].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_lock(true); + } + if (values[8].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setDefaultSelected(true); + } + packCodeNodeInfo.setCreate_date(getStringValue(values[9])); + packCodeNodeInfo.setLast_revise_date(getStringValue(values[10])); + packCodeNodeInfo.setCreate_user(getStringValue(values[11])); + packCodeNodeInfo.setLast_revise_user(getStringValue(values[12])); + if (values[13].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setContainsChildren(true); + } + } else { + packCodeNodeInfo.setNodeComponent(searchTCcomponents[i]); + packCodeNodeInfo.setNode_name(getStringValue(values[0])); + packCodeNodeInfo.setNode_type(getStringValue(values[1])); + if (values[2].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_root(true); + } + if (values[3].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setIs_lock(true); + } + if (values[4].equalsIgnoreCase("yes")) { + packCodeNodeInfo.setContainsChildren(true); + } + } + packCodeNodeInfos.add(packCodeNodeInfo); + } + } + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + return packCodeNodeInfos; + } + + public List searchTreeORListNodeInfos(HashMap hashMap, String parentString, String[] returnPropertyNames) throws ServiceException, TCException { + List packCodeNodeInfos = new ArrayList(); + try { + TCComponent[] searchTCcomponents = searchTreeORListNodes(hashMap); + System.out.println("parentString ========================>"+parentString); + packCodeNodeInfos = getTreeORListNodeInfos(searchTCcomponents, parentString, returnPropertyNames); + return packCodeNodeInfos; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + + private String getStringValue(String value) { + if ((value == null) || (value.equalsIgnoreCase("null"))) { + return ""; + } else { + return value; + } + } + + public String[] getTreeAndListStringValues(TCComponent[] components, String[] stringPropNames, String parentString) throws ServiceException, TCException { + Object[] params = { components, stringPropNames, parentString }; + try { +// for(int i=0;i(); + if (childrenAutoCodeNodeData != null && childrenAutoCodeNodeData.length > 0) { + for (int i = 0; i < childrenAutoCodeNodeData.length; i++) { + // vectorChildren.add(childrenAutoCodeNodeData[i]); + } + } + } + + public void addChildrenNode(AbstractTreeData childrenNode) { + if (childrenNode == null) { + return; + } + AbstractTreeData[] childrenNodes = this.childrenTreeData; + int childrenLength = 1; + if (childrenNodes != null) { + childrenLength = childrenLength + childrenNodes.length; + } + AbstractTreeData[] childrenNodes2 = new AbstractTreeData[childrenLength]; + for (int i = 0; i < childrenLength - 1; i++) { + childrenNodes2[i] = childrenNodes[i]; + } + childrenNodes2[childrenLength - 1] = childrenNode; + this.setTreeAutoCodeNodeChildren(childrenNodes2); + } + + public Image getImage() { + return image; + } + + /** + * @return the childrenDatas + */ + public AbstractTreeData[] getChildrenDatas() { + return childrenDatas; + } + + /** + * @param childrenDatas + * the childrenDatas to set + */ + public void setChildrenDatas(AbstractTreeData[] childrenDatas) { + this.childrenDatas = childrenDatas; + } + + /** + * @return the childrenTreeData + */ + public AbstractTreeData[] getChildrenTreeData() { + return childrenTreeData; + } + + /** + * @param image + * the image to set + */ + public void setImage(Image image) { + this.image = image; + } + + /** + * @return the parentTreeData + */ + public AbstractTreeData getParentTreeData() { + return parentTreeData; + } + + /** + * @param parentTreeData + * the parentTreeData to set + */ + public void setParentTreeData(AbstractTreeData parentTreeData) { + this.parentTreeData = parentTreeData; + } + + /** + * @return the isChildrenLoader + */ + public boolean isChildrenLoader() { + return isChildrenLoader; + } + + /** + * @param isChildrenLoader + * the isChildrenLoader to set + */ + public void setChildrenLoader(boolean isChildrenLoader) { + this.isChildrenLoader = isChildrenLoader; + } + + public PackCodeNodeInfo getPackCodeNodeInfo() { + return packCodeNodeInfo; + } + + public void setPackCodeNodeInfo(PackCodeNodeInfo packCodeNodeInfo) { + this.packCodeNodeInfo = packCodeNodeInfo; + if (packCodeNodeInfo.is_lock) { + this.image = getImageByType(AutoCodeManagerPropertyName.LockName); + } else { + this.image = getImageByType(packCodeNodeInfo.getNode_type()); + } + } + + public void setChildrenTreeData(AbstractTreeData[] childrenTreeData) { + this.childrenTreeData = childrenTreeData; + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.java b/src/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.java new file mode 100644 index 0000000..668ae15 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/tree/AbstractTreeViewRightKeyAction.java @@ -0,0 +1,352 @@ +/** + * @author tyl + * @Action ini + * 2011-3-16 + */ +package cn.com.origin.autocodemanager.common.tree; + +import java.util.HashMap; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.actions.ActionGroup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import cn.com.origin.autocodemanager.common.AutoCodeConstants; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; +import cn.com.origin.autocodemanager.views.AutoCodeSegmentView; +import cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView; +import cn.com.origin.autocodemanager.views.codeview.CodeSegmentDialog; +import cn.com.origin.autocodemanager.views.codeview.CopyCodeNodeDialog; +import cn.com.origin.autocodemanager.views.codeview.NewCodeNodeDialog; +import cn.com.origin.autocodemanager.views.listcodeview.CreateListCodeView; +import cn.com.origin.autocodemanager.views.listcodeview.NewListPropertyNodeDialog; +import cn.com.origin.autocodemanager.views.listcodeview.NewListPropertyValueNodeDialog; +import cn.com.origin.autocodemanager.views.treecodeview.CreateTreeCodeView; +import cn.com.origin.autocodemanager.views.treecodeview.NewTreeCodeNodeDialog; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class AbstractTreeViewRightKeyAction extends ActionGroup { + public TreeViewer treeViewer; + public MenuManager menuManager; + public AbstractCreateTreeView createView; + public AbstractTreeData selectedTreeData; + public TCSession session; + public AutoCodeListCodeView codeListView; + public AutoCodeSegmentView codeSegmentView; + public AutoCodeTreeCodeView codeTreeView; + public TreeAndListCodeOperation treeAndListCodeOperation; + public TreeViewOperation treeViewOperation; + + public AbstractTreeViewRightKeyAction(AbstractCreateTreeView createTreeView) { + this.createView = createTreeView; + this.treeViewer = createTreeView.treeViewer; + initParams(); + this.selectedTreeData = treeViewOperation.getSelectedTreeNode(createTreeView.treeViewer); + } + + public void initParams() { + this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + this.treeViewOperation = new TreeViewOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + if (createView == null) { + return; + } + if (createView.viewPart == null) { + return; + } + codeListView = (AutoCodeListCodeView) createView.viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); + codeSegmentView = (AutoCodeSegmentView) createView.viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + codeTreeView = (AutoCodeTreeCodeView) createView.viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID); + } + + public void fillContextMenu() { + if (menuManager == null) { + // һεø÷ʱ + menuManager = new MenuManager(); + menuManager.add(new LockCodeNodeAction()); + menuManager.add(new UnLockCodeNodeAction()); + menuManager.add(new RemoveCodeNodeAction()); + } + Tree tree = treeViewer.getTree(); + Menu menu = menuManager.createContextMenu(tree); + tree.setMenu(menu); + } + + public class EidtCodeNodeAction extends Action { + public EidtCodeNodeAction() { + setText("༭"); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.EDIT_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪ޸Ľڵ!", "INFO", MessageBox.WARNING); + return; + } + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + TCComponent segmentComponent = segmentTreeData.getPackCodeNodeInfo().getNodeComponent(); + TCComponent selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + if (selectedComponent != null) { + TCComponent[] components = treeAndListCodeOperation.getNodeReferenceComponents(selectedComponent); + String segmentNames = ""; + if (components != null) { + for (int i = 0; i < components.length; i++) { + if (!components[i].equals(segmentComponent)) { + components[i].refresh(); + segmentNames = segmentNames + components[i].getProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name); + segmentNames = segmentNames + "\n"; + } + } + if (segmentNames.trim().length() > 0) { + Boolean value = false; + value = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "INFO", "õ˽ڵ㣺\n" + segmentNames + "ȷ޸ģ"); + if (!value) { + return; + } + } + } + } + Image nodeImage = selectedTreeData.getImage(); + HashMap hashMap = new HashMap(); + if (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() != null) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "true"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, session.getUser().getUid()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + try { + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + } catch (ServiceException e) { + e.printStackTrace(); + } + } + selectedTreeData.setImage(new AbstractTreeData().getImageByType(AutoCodeManagerPropertyName.LockName)); + treeViewer.refresh(selectedTreeData); + + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyNodeName)) { + new NewListPropertyNodeDialog(treeViewer.getControl().getShell(), (CreateListCodeView) createView, "༭б", true).open(); + } else { + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyValueNodeName)) { + new NewListPropertyValueNodeDialog(treeViewer.getControl().getShell(), (CreateListCodeView) createView, "༭б", true).open(); + } else if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.TreeNodeName)) { + new NewTreeCodeNodeDialog(treeViewer.getControl().getShell(), (CreateTreeCodeView) createView, "༭ڵ", true, true).open(); + } else { + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.CodeGroupName)) { + NewCodeNodeDialog codeNodeDialog = new NewCodeNodeDialog(null, createView, AutoCodeManagerPropertyName.AddRuleGroupNodeName, "༭", true); + codeNodeDialog.open(); + } else { + NewCodeNodeDialog codeNodeDialog = new NewCodeNodeDialog(null, createView, AutoCodeManagerPropertyName.AddRuleRootNodeName, "༭", true); + codeNodeDialog.open(); + } + } + } + HashMap hashMap2 = new HashMap(); + if (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() != null) { + hashMap2.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + hashMap2.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap2.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap2.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, session.getUser().getUid()); + hashMap2.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap2); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + } + selectedTreeData.setImage(nodeImage); + treeViewer.refresh(selectedTreeData); + } catch (TCException e) { + e.printStackTrace(); + } catch (ServiceException e) { + e.printStackTrace(); + } + } + } + + public class AddChildrenNodeAction extends Action { + String text = ""; + String type = ""; + + public AddChildrenNodeAction(String text, String type) { + setText(text); + this.text = text; + this.type = type; + ImageDescriptor imageDesc = new AbstractTreeData().getImageDescriptorByType(type); + this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + AbstractTreeData rootNode = treeViewOperation.getSelectedTreeNode(codeSegmentView.getCreateView().treeViewer); + if (!treeViewOperation.isRuleRootNode(rootNode)) { + MessageBox.post("ѡҪ޸Ĺ!", "INFO", MessageBox.WARNING); + return; + } + new CodeSegmentDialog(treeViewer.getControl().getShell(), createView, text, type).open(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public class LockCodeNodeAction extends Action { + public LockCodeNodeAction() { + setText(""); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.LOCK_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪڵ!", "INFO", MessageBox.WARNING); + return; + } + + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + TCComponent segmentComponent = segmentTreeData.getPackCodeNodeInfo().getNodeComponent(); + TCComponent selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + if (selectedComponent != null) { + TCComponent[] components = treeAndListCodeOperation.getNodeReferenceComponents(selectedComponent); + String segmentNames = ""; + if (components != null) { + for (int i = 0; i < components.length; i++) { + if (!components[i].equals(segmentComponent)) { + components[i].refresh(); + segmentNames = segmentNames + components[i].getProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name); + segmentNames = segmentNames + "\n"; + } + } + if (segmentNames.trim().length() > 0) { + Boolean value = false; + value = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "INFO", "õ˽ڵ㣺\n" + segmentNames + "ȷ"); + if (!value) { + return; + } + } + } + } + HashMap hashMap = new HashMap(); + if (selectedComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "true"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, session.getUser().getUid()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + createView.treeViewer.refresh(selectedTreeData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public class UnLockCodeNodeAction extends Action { + public UnLockCodeNodeAction() { + setText(""); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.UNLOCK_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪڵ!", "INFO", MessageBox.WARNING); + return; + } + TCComponent selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + HashMap hashMap = new HashMap(); + if (selectedComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + createView.treeViewer.refresh(selectedTreeData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public class CopyCodeNodeAction extends Action { + public CopyCodeNodeAction() { + setText(""); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.EDIT_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪƽڵ!", "INFO", MessageBox.WARNING); + return; + } + + try { + if (treeViewOperation.isRuleRootNode(selectedTreeData)) { + CopyCodeNodeDialog codeNodeDialog = new CopyCodeNodeDialog(null, createView, "ƹ", true, AutoCodeManagerPropertyName.AddRuleRootNodeName); + codeNodeDialog.open(); + } else { + CopyCodeNodeDialog codeNodeDialog = new CopyCodeNodeDialog(null, createView, "", true, AutoCodeManagerPropertyName.AddRuleGroupNodeName); + codeNodeDialog.open(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + + public class RemoveCodeNodeAction extends Action { + public RemoveCodeNodeAction() { + setText("Ƴ"); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.REMOVE_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪƳڵ!", "INFO", MessageBox.WARNING); + return; + } + try { + boolean value = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "INFO", "ȷƳ"); + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + if (value) { + treeViewOperation.removeTreeNode(createView.treeViewer, selectedTreeData); + treeAndListCodeOperation.removeTreeORListNode(segmentTreeData, selectedTreeData); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.java b/src/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.java new file mode 100644 index 0000000..060b449 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/tree/ORTreeContentProvider.java @@ -0,0 +1,41 @@ +package cn.com.origin.autocodemanager.common.tree; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +public class ORTreeContentProvider implements ITreeContentProvider { + + public Object[] getChildren(Object parentObj) { + return ((AbstractTreeData) parentObj).getChildrenTreeData(); + + } + + public Object getParent(Object element) { + return ((AbstractTreeData) element).getParentTreeData(); + + } + + public boolean hasChildren(Object element) { + boolean flag = false; + if (((AbstractTreeData) element) != null && ((AbstractTreeData) element).getChildrenTreeData() != null && ((AbstractTreeData) element).getChildrenTreeData().length > 0) { + flag = true; + } + return flag; + } + + public Object[] getElements(Object inputElement) { + // TODO Auto-generated method stub + return (Object[]) inputElement; + } + + public void dispose() { + // TODO Auto-generated method stub + + } + + public void inputChanged(Viewer arg0, Object obj1, Object obj2) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.java b/src/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.java new file mode 100644 index 0000000..1bd7941 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/tree/ORTreeLabelProvider.java @@ -0,0 +1,48 @@ +package cn.com.origin.autocodemanager.common.tree; + +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.swt.graphics.Image; + +public class ORTreeLabelProvider implements ILabelProvider { + + public Image getImage(Object obj) { + if (obj instanceof AbstractTreeData) { + AbstractTreeData codeTreeData = (AbstractTreeData) obj; + return codeTreeData.getImage(); + } else { + return null; + } + } + + public String getText(Object obj) { + String nodeName = ""; + if (obj instanceof AbstractTreeData) { + AbstractTreeData treeData = ((AbstractTreeData) obj); + if (treeData.getPackCodeNodeInfo() != null) { + nodeName = treeData.getPackCodeNodeInfo().getNode_name(); + } + } + return nodeName; + } + + public void addListener(ILabelProviderListener listener) { + + } + + public void dispose() { + // TODO Auto-generated method stub + + } + + public boolean isLabelProperty(Object obj, String s) { + // TODO Auto-generated method stub + return false; + } + + public void removeListener(ILabelProviderListener label) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.java b/src/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.java new file mode 100644 index 0000000..af00aba --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/tree/TreeViewOperation.java @@ -0,0 +1,330 @@ +/** + * @author tyl + * @Action ini + * 2011-3-29 + */ +package cn.com.origin.autocodemanager.common.tree; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.TreeItem; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; +import cn.com.origin.autocodemanager.views.AutoCodeSegmentView; +import cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView; +import com.teamcenter.rac.util.MessageBox; + +public class TreeViewOperation { + public TreeAndListCodeOperation treeAndListCodeOperation; + public AutoCodeListCodeView codeListView; + public AutoCodeSegmentView codeSegmentView; + public AutoCodeTreeCodeView codeTreeView; + + public TreeViewOperation() { + this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + } + + public void addChildrenTreeNodeRelations(TreeViewer treeViewer, AbstractTreeData parentNode, AbstractTreeData[] childrenNodes) { + for (int i = 0; i < childrenNodes.length; i++) { + AbstractTreeData childrenNode = childrenNodes[i]; + if (childrenNode.getPackCodeNodeInfo().getNodeComponent() != null) { + treeAndListCodeOperation.createNewCodeRelation(parentNode, childrenNode.getPackCodeNodeInfo().getNodeComponent()); + addChildrenTreeNodeRelations(treeViewer, childrenNode, childrenNode.getChildrenDatas()); + } + } + } + + public boolean isRuleRootNode(AbstractTreeData treeData) { + if (treeData == null) { + return false; + } + if (treeData.getPackCodeNodeInfo().getNodeComponent() == null) { + return false; + } + if (treeData.getPackCodeNodeInfo().is_root) { + return true; + } + return false; + } + + public void addExistCodeNode(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + try { + if (isRuleRootNode(parentData)) { + addNewTreeOrListInput(treeViewer, parentData, childrenData); + } else { + addChildrenData(treeViewer, parentData, childrenData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void appendChildrenNode(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + AbstractTreeData[] childrenDatas = parentData.getChildrenDatas(); + int childrenLength = 1; + + if (childrenDatas != null) { + childrenLength = childrenLength + childrenDatas.length; + } + AbstractTreeData[] treeDatas = new AbstractTreeData[childrenLength]; + boolean isContain = true; + for (int i = 0; i < childrenLength - 1; i++) { + if ((childrenData.getPackCodeNodeInfo().getNodeComponent()).equals(childrenDatas[i].getPackCodeNodeInfo().getNodeComponent())) { + isContain = false; + break; + } + treeDatas[i] = childrenDatas[i]; + } + if (!isContain) { + return; + } else { + treeDatas[childrenLength - 1] = childrenData; + parentData.setTreeAutoCodeNodeChildren(treeDatas); + childrenData.setParentTreeData(parentData); + parentData.setChildrenLoader(true); + treeViewer.refresh(parentData); + } + } + + public void addChildrenRelations(AbstractTreeData parentData, AbstractTreeData childrenData) { + treeAndListCodeOperation.createNewCodeRelation(parentData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + AbstractTreeData[] childrenDatas = parentData.getChildrenDatas(); + int childrenLength = 1; + + if (childrenDatas != null) { + childrenLength = childrenLength + childrenDatas.length; + } + AbstractTreeData[] treeDatas = new AbstractTreeData[childrenLength]; + for (int i = 0; i < childrenLength - 1; i++) { + treeDatas[i] = childrenDatas[i]; + } + treeDatas[childrenLength - 1] = childrenData; + + if (isRuleRootNode(parentData)) { + parentData.setChildrenDatas(treeDatas); + } else { + parentData.setTreeAutoCodeNodeChildren(treeDatas); + } + childrenData.setParentTreeData(parentData); + parentData.setChildrenLoader(true); + } + + public void addTreeNodes(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + treeAndListCodeOperation.createNewCodeRelation(parentData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + AbstractTreeData[] childrenDatas = parentData.getChildrenDatas(); + int childrenLength = 1; + + if (childrenDatas != null) { + childrenLength = childrenLength + childrenDatas.length; + } + AbstractTreeData[] treeDatas = new AbstractTreeData[childrenLength]; + for (int i = 0; i < childrenLength - 1; i++) { + treeDatas[i] = childrenDatas[i]; + } + treeDatas[childrenLength - 1] = childrenData; + + parentData.setTreeAutoCodeNodeChildren(treeDatas); + childrenData.setParentTreeData(parentData); + parentData.setChildrenLoader(true); + treeViewer.refresh(parentData); + } + + public void addChildrenData(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + if (parentData == null) { + return; + } + if (childrenData == null) { + return; + } + treeAndListCodeOperation.createNewCodeRelation(parentData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + AbstractTreeData[] childrenDatas = parentData.getChildrenDatas(); + int childrenLength = 1; + + if (childrenDatas != null) { + childrenLength = childrenLength + childrenDatas.length; + } + AbstractTreeData[] treeDatas = new AbstractTreeData[childrenLength]; + for (int i = 0; i < childrenLength - 1; i++) { + treeDatas[i] = childrenDatas[i]; + } + treeDatas[childrenLength - 1] = childrenData; + + if (isRuleRootNode(parentData)) { + parentData.setChildrenDatas(treeDatas); + } else { + parentData.setTreeAutoCodeNodeChildren(treeDatas); + } + childrenData.setParentTreeData(parentData); + parentData.setChildrenLoader(true); + treeViewer.refresh(parentData); + } + + public boolean appendChildrenData(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + AbstractTreeData[] childrenDatas = parentData.getChildrenDatas(); + int childrenLength = 1; + + if (childrenDatas != null) { + childrenLength = childrenLength + childrenDatas.length; + } + AbstractTreeData[] treeDatas = new AbstractTreeData[childrenLength]; + boolean isContain = false; + for (int i = 0; i < childrenLength - 1; i++) { + if ((childrenData.getPackCodeNodeInfo().getNodeComponent()).equals(childrenDatas[i].getPackCodeNodeInfo().getNodeComponent())) { + isContain = true; + break; + } + treeDatas[i] = childrenDatas[i]; + } + if (isContain) { + MessageBox.post("ӡ" + childrenData.getPackCodeNodeInfo().getNode_name() + "!", "INFO", MessageBox.WARNING); + } else { + treeDatas[childrenLength - 1] = childrenData; + parentData.setTreeAutoCodeNodeChildren(treeDatas); + childrenData.setParentTreeData(parentData); + parentData.setChildrenLoader(true); + treeViewer.refresh(parentData); + } + return isContain; + } + + public void addNewTreeOrListInput(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + // treeAndListCodeOperation.createNewCodeRelation(parentData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + int length = 1; + if (treeViewer.getInput() != null) { + Object[] existDatas = (Object[]) treeViewer.getInput(); + if (existDatas != null) { + length = length + existDatas.length; + } + AbstractTreeData[] childrenDatas = new AbstractTreeData[length]; + if (existDatas != null) { + for (int i = 0; i < existDatas.length; i++) { + childrenDatas[i] = (AbstractTreeData) existDatas[i]; + } + } + childrenData.setParentTreeData(parentData); + childrenDatas[length - 1] = childrenData; + treeViewer.setInput(childrenDatas); + parentData.setChildrenDatas(childrenDatas); + } else { + treeViewer.setInput(new AbstractTreeData[] { childrenData }); + parentData.setChildrenDatas(new AbstractTreeData[] { childrenData }); + childrenData.setParentTreeData(parentData); + } + parentData.setChildrenLoader(true); + treeViewer.refresh(parentData); + treeAndListCodeOperation.createNewCodeRelation(parentData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + } + + public AbstractTreeData getSelectedTreeNode(TreeViewer treeViewer) { + TreeItem[] treeItems = treeViewer.getTree().getSelection(); + if ((treeItems != null) && (treeItems.length > 0)) { + return (AbstractTreeData) treeItems[0].getData(); + } else { + return null; + } + } + + public void removeTreeNode(TreeViewer treeViewer, AbstractTreeData treeData) { + try { + AbstractTreeData parentTreeData = treeData.getParentTreeData(); + if (parentTreeData != null) { + if (isRuleRootNode(parentTreeData)) { + updateTreeOrListInput(treeViewer, parentTreeData, treeData); + } else { + List treeDatas = new ArrayList(); + AbstractTreeData[] parentChildrenData = parentTreeData.getChildrenDatas(); + if (parentChildrenData != null) { + for (int i = 0; i < parentChildrenData.length; i++) { + if (!treeData.equals(parentChildrenData[i])) { + treeDatas.add(parentChildrenData[i]); + } + } + if (treeDatas.size() > 0) { + AbstractTreeData[] treeDatas2 = new AbstractTreeData[treeDatas.size()]; + for (int i = 0; i < treeDatas.size(); i++) { + treeDatas2[i] = treeDatas.get(i); + } + parentTreeData.setTreeAutoCodeNodeChildren(treeDatas2); + } else { + parentTreeData.setTreeAutoCodeNodeChildren(null); + } + } + } + } else { + treeViewer.setInput(null); + } + treeViewer.remove(treeData); + } catch (Exception e) { + e.printStackTrace(); + } + // treeViewer.refresh(parentTreeData); + } + + public void removeNodeFromParent(AbstractTreeData parentTreeData, AbstractTreeData childrenData) { + if ((parentTreeData == null) || (childrenData == null)) { + return; + } + List treeDatas = new ArrayList(); + AbstractTreeData[] parentChildrenData = parentTreeData.getChildrenDatas(); + if (parentChildrenData != null) { + for (int i = 0; i < parentChildrenData.length; i++) { + if (!childrenData.equals(parentChildrenData[i])) { + treeDatas.add(parentChildrenData[i]); + } + } + if (treeDatas.size() > 0) { + AbstractTreeData[] treeDatas2 = new AbstractTreeData[treeDatas.size()]; + for (int i = 0; i < treeDatas.size(); i++) { + treeDatas2[i] = treeDatas.get(i); + } + parentTreeData.setTreeAutoCodeNodeChildren(treeDatas2); + } else { + parentTreeData.setTreeAutoCodeNodeChildren(null); + } + } + + } + + public void updateTreeOrListInput(TreeViewer treeViewer, AbstractTreeData parentData, AbstractTreeData childrenData) { + int length = -1; + if (treeViewer.getInput() != null) { + AbstractTreeData[] existDatas = (AbstractTreeData[]) treeViewer.getInput(); + if (existDatas != null) { + length = length + existDatas.length; + } + if (length >= 1) { + List treeDatas = new ArrayList(); + for (int i = 0; i < existDatas.length; i++) { + if (!childrenData.equals(existDatas[i])) { + treeDatas.add(existDatas[i]); + } + } + AbstractTreeData[] childrenDatas = new AbstractTreeData[treeDatas.size()]; + for (int i = 0; i < treeDatas.size(); i++) { + childrenDatas[i] = treeDatas.get(i); + } + treeViewer.setInput(childrenDatas); + parentData.setTreeAutoCodeNodeChildren(childrenDatas); + } else { + treeViewer.setInput(null); + parentData.setTreeAutoCodeNodeChildren(null); + } + } else { + treeViewer.setInput(null); + parentData.setTreeAutoCodeNodeChildren(null); + } + treeViewer.refresh(parentData); + } + + public void addExistSegmentRelation(TreeViewer treeViewer, AbstractTreeData parentTreeData, AbstractTreeData[] childrenTreeDatas) { + for (int i = 0; i < childrenTreeDatas.length; i++) { + AbstractTreeData childrenData = childrenTreeDatas[i]; + if (childrenData.getPackCodeNodeInfo().getNodeComponent() != null) { + treeAndListCodeOperation.createNewCodeRelation(parentTreeData, childrenData.getPackCodeNodeInfo().getNodeComponent()); + addExistSegmentRelation(treeViewer, childrenData, childrenData.getChildrenDatas()); + } + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.java b/src/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.java new file mode 100644 index 0000000..51fcdad --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/treetable/AbstractTreeTable.java @@ -0,0 +1,157 @@ +/** + * @author tyl + * @Action ini + * 2011-3-16 + */ +package cn.com.origin.autocodemanager.common.treetable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.ui.part.ViewPart; + +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.views.listcodeview.NewItemListCodeView; +import cn.com.origin.autocodemanager.views.treecodeview.NewItemTreeCodeView; +import org.eclipse.swt.graphics.Color; +import com.teamcenter.rac.kernel.TCComponent; + +public class AbstractTreeTable extends AbstractCreateTreeView { + + public AbstractTreeTable(Composite composite, String rootName, ViewPart viewPart) { + super(composite, rootName, viewPart); + // createTree(composite); + } + + public AbstractTreeTable() { + + } + + public AbstractTreeTable(Composite composite, String rootName) { + super(composite, rootName); + + } + + public TreeColumn createColumn(Composite parent, String treeColumnName, int width) { + TreeColumn treeColumn = new TreeColumn(tree, SWT.LEFT); + treeColumn.setText(treeColumnName); + treeColumn.setWidth(width); + return treeColumn; + } + + public void initTree(String rootName) { + tree.setHeaderVisible(true); // ñͷɼ + tree.setLinesVisible(true); // ߿ɼ + + tree.setBackground(new Color(Display.getCurrent(),255,255,255)); + tree.setVisible(true); + tree.setFocus(); // ý + treeViewer.setLabelProvider(new ORTreeTableLabelProvider()); + treeViewer.setContentProvider(new ORTreeTableContentProvider()); + createTreeColumn(); + } + + public void createTreeColumn() { + createColumn(tree, "", 150); + createColumn(tree, "ֵ", 100); + createColumn(tree, "ע", 100); + createColumn(tree, "ǷΪĬֵ", 100); + createColumn(tree, "", 100); + createColumn(tree, "Ƿ", 100); + createColumn(tree, "", 100); + createColumn(tree, "", 100); + createColumn(tree, "޸", 100); + createColumn(tree, "޸", 100); + } + + @Override + public void addMouseAction() { + + } + + @Override + public void addRightKeyAction() { + } + + @Override + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) throws Exception { + if (codeDatas != null && codeDatas.length > 0) { + for (int i = 0; i < codeDatas.length; i++) { + AbstractTreeData autoCodeData = (AbstractTreeData) codeDatas[i]; + if (autoCodeData == null) { + return; + } + List newItemViewNames = new ArrayList(); + newItemViewNames.add(NewItemTreeCodeView.class.getSimpleName()); + newItemViewNames.add(NewItemListCodeView.class.getSimpleName()); + + String thisClassName = this.getClass().getSimpleName(); + if (newItemViewNames.contains(thisClassName)) { + TCComponent component = autoCodeData.getPackCodeNodeInfo().getNodeComponent(); + if ((component != null) &&(autoCodeData.getPackCodeNodeInfo().is_lock)) { + autoCodeData.setTreeAutoCodeNodeChildren(null); + autoCodeData.setChildrenLoader(false); + return; + } + } + TCComponent autoCodeDataComponent = autoCodeData.getPackCodeNodeInfo().getNodeComponent(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + HashMap hashMap = new HashMap(); + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(autoCodeData, parentStr); + if (autoCodeDataComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, autoCodeDataComponent.getUid()); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + } else { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, ""); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, ""); + } + String parentStr2 = ""; + if (autoCodeDataComponent != null) { + if (parentStr.trim().length() == 0) { + parentStr2 = autoCodeDataComponent.getUid(); + } else { + parentStr2 = parentStr + "," + autoCodeDataComponent.getUid(); + } + } else { + parentStr2 = parentStr; + } + + List packCodeNodeInfos = treeAndListCodeOperation.searchTreeORListNodeInfos(hashMap, parentStr2,AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + + if (packCodeNodeInfos != null && packCodeNodeInfos.size() > 0) { + AbstractTreeData autoCodeDataTCComs[] = new AbstractTreeData[packCodeNodeInfos.size()]; + for (int k = 0; k < packCodeNodeInfos.size(); k++) { + if (packCodeNodeInfos.get(k).getNodeComponent() == null) { + continue; + } + PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(k); + autoCodeDataTCComs[k] = new AbstractTreeData(autoCodeData, packCodeNodeInfo); + if (packCodeNodeInfo.isContainsChildren()) { + autoCodeDataTCComs[k].setTreeAutoCodeNodeChildren(new AbstractTreeData[] { new AbstractTreeData() }); + } + } + autoCodeData.setTreeAutoCodeNodeChildren(autoCodeDataTCComs); + autoCodeData.setChildrenLoader(true); + treeViewer.refresh(autoCodeData); + treeViewer.expandToLevel(autoCodeData, 1); + } else { + autoCodeData.setTreeAutoCodeNodeChildren(null); + autoCodeData.setChildrenLoader(true); + treeViewer.refresh(autoCodeData); + treeViewer.expandToLevel(autoCodeData, 1); + } + } + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.java b/src/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.java new file mode 100644 index 0000000..ea3831e --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/treetable/ORNewItemTreeTableLabelProvider.java @@ -0,0 +1,67 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common.treetable; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import com.teamcenter.rac.kernel.TCComponent; + +public class ORNewItemTreeTableLabelProvider implements ITableLabelProvider { + public Image getColumnImage(Object element, int columnIndex) { + if (element instanceof AbstractTreeData) { + AbstractTreeData codeTreeData = (AbstractTreeData) element; + if (columnIndex == 0) { + return codeTreeData.getImage(); + } + } + return null; + } + + public String getColumnText(Object element, int coumnIndex) { + if (element instanceof AbstractTreeData) { + AbstractTreeData codeTreeData = (AbstractTreeData) element; + if (codeTreeData == null) { + return ""; + } + if (codeTreeData.getPackCodeNodeInfo() == null) { + return ""; + } + + TCComponent component = codeTreeData.getPackCodeNodeInfo().getNodeComponent(); + if (component == null) { + return ""; + } + switch (coumnIndex) { + case 0: + return codeTreeData.getPackCodeNodeInfo().getNode_name(); + case 1: + return codeTreeData.getPackCodeNodeInfo().getNode_value(); + case 2: + return codeTreeData.getPackCodeNodeInfo().getNode_desc(); + } + } + return ""; + } + + public void addListener(ILabelProviderListener arg0) { + + } + + public void dispose() { + + } + + public boolean isLabelProperty(Object obj, String obj1) { + return false; + } + + public void removeListener(ILabelProviderListener arg0) { + + } + +} diff --git a/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.java b/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.java new file mode 100644 index 0000000..4c6d21e --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableContentProvider.java @@ -0,0 +1,46 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common.treetable; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +public class ORTreeTableContentProvider implements ITreeContentProvider { + + public Object[] getChildren(Object parentObj) { + // TODO Auto-generated method stub + return ((AbstractTreeData) parentObj).getChildrenTreeData(); + + } + + public Object getParent(Object element) { + // TODO Auto-generated method stub + return ((AbstractTreeData) element).getParentTreeData(); + + } + + public boolean hasChildren(Object element) { + boolean flag = false; + if (((AbstractTreeData) element) != null && ((AbstractTreeData) element).getChildrenTreeData() != null && ((AbstractTreeData) element).getChildrenTreeData().length > 0) { + flag = true; + } + return flag; + } + + public Object[] getElements(Object inputElement) { + return (Object[]) inputElement; + } + + public void dispose() { + + } + + public void inputChanged(Viewer arg0, Object obj1, Object obj2) { + + } +} diff --git a/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.java b/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.java new file mode 100644 index 0000000..3326588 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/common/treetable/ORTreeTableLabelProvider.java @@ -0,0 +1,84 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.common.treetable; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +public class ORTreeTableLabelProvider implements ITableLabelProvider { + public Image getColumnImage(Object element, int columnIndex) { + if (element instanceof AbstractTreeData) { + AbstractTreeData codeTreeData = (AbstractTreeData) element; + if (columnIndex == 0) { + return codeTreeData.getImage(); + } + } + return null; + } + + public String getColumnText(Object element, int coumnIndex) { + if (element instanceof AbstractTreeData) { + try { + AbstractTreeData codeTreeData = (AbstractTreeData) element; + if ((codeTreeData == null) || (codeTreeData.getPackCodeNodeInfo() == null)) { + return ""; + } + switch (coumnIndex) { + case 0: + return codeTreeData.getPackCodeNodeInfo().getNode_name(); + case 1: + return codeTreeData.getPackCodeNodeInfo().getNode_value(); + case 2: + return codeTreeData.getPackCodeNodeInfo().getNode_desc(); + case 3: + if (codeTreeData.getPackCodeNodeInfo().isDefaultSelected) { + return ""; + } else { + return ""; + } + case 4: + return codeTreeData.getPackCodeNodeInfo().getRule_node(); + case 5: + if (codeTreeData.getPackCodeNodeInfo().is_lock) { + return ""; + } else { + return ""; + } + case 6: + return codeTreeData.getPackCodeNodeInfo().getCreate_date(); + case 7: + return codeTreeData.getPackCodeNodeInfo().getCreate_user(); + case 8: + return codeTreeData.getPackCodeNodeInfo().getLast_revise_date(); + case 9: + return codeTreeData.getPackCodeNodeInfo().getLast_revise_user(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return ""; + } + + public void addListener(ILabelProviderListener arg0) { + + } + + public void dispose() { + + } + + public boolean isLabelProperty(Object obj, String obj1) { + return false; + } + + public void removeListener(ILabelProviderListener arg0) { + + } + +} diff --git a/src/cn/com/origin/autocodemanager/export/ExportNodeOperation.java b/src/cn/com/origin/autocodemanager/export/ExportNodeOperation.java new file mode 100644 index 0000000..d69d108 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/export/ExportNodeOperation.java @@ -0,0 +1,127 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.export; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.ExcelOperation; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class ExportNodeOperation { + private TreeAndListCodeOperation treeAndListCodeOperation; + // private TCSession session; + private AbstractTreeData treeData; + private String filePath; + + public ExportNodeOperation(AbstractTreeViewPart viewPart, AbstractTreeData treeData, String filePath) { + // this.viewPart = viewPart; + this.treeData = treeData; + this.filePath = filePath; + initParams(); + } + + public void exportNode() { + ArrayList> arrayList = new ArrayList>(); + File excelFile = new File(filePath); + String sheetTitle = treeData.getPackCodeNodeInfo().getNode_name(); + Object[] cloumnNames = AutoCodeManagerPropertyName.TreeAndListCodeNode_Titles; + + exportTreeNode(treeData.getPackCodeNodeInfo().getNodeComponent(), arrayList, 0); + String parentStr = ""; + exportTreeNodes(treeAndListCodeOperation.getParentStr(treeData, parentStr), treeData.getPackCodeNodeInfo().getNodeComponent().getUid(), arrayList, 0); + + try { + ExcelOperation.writeExcel(sheetTitle, excelFile, cloumnNames, arrayList); + } catch (IOException e) { + } + } + + public void initParams() { + this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + // session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + } + + private void exportTreeNodes(String parentStr, String currentStr, ArrayList> arrayList, int level) { + try { + TCComponent[] tccomponents = null; + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, currentStr); + tccomponents = treeAndListCodeOperation.searchTreeORListNodes(hashMap); + if (tccomponents == null) { + return; + } + + level = level + 1; + for (int i = 0; i < tccomponents.length; i++) { + exportTreeNode(tccomponents[i], arrayList, level); + String parentStr2 = parentStr + "," + currentStr; + if (parentStr2.trim().startsWith(",")) { + parentStr2 = parentStr2.substring(1); + } + exportTreeNodes(parentStr2, tccomponents[i].getUid().trim(), arrayList, level); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void exportTreeNode(TCComponent tccomponent, ArrayList> arrayList, int level) { + if (tccomponent == null) { + return; + } + HashMap hashMap = new HashMap(); + try { + tccomponent.refresh(); + String[] propertyNames = { AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, + AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, + AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, + AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user }; + String[] propertyValues = tccomponent.getProperties(propertyNames); + hashMap.put("", Integer.toString(level)); + hashMap.put("", propertyValues[0]); + hashMap.put("", propertyValues[1]); + hashMap.put("ֵ", propertyValues[2]); + hashMap.put("ע", propertyValues[3]); + hashMap.put("ʽ", propertyValues[4]); + hashMap.put("볤", propertyValues[5]); + hashMap.put("ˮʼֵ", propertyValues[6]); + hashMap.put("ˮֵ", propertyValues[7]); + if (propertyValues[8].equalsIgnoreCase("Y")) { + hashMap.put("ǷΪڵ", "true"); + } else { + hashMap.put("ǷΪڵ", "false"); + } + if (propertyValues[9].equalsIgnoreCase("Y")) { + hashMap.put("ǷΪĬֵ", "true"); + } else { + hashMap.put("ǷΪĬֵ", "false"); + } + if (propertyValues[10].equalsIgnoreCase("Y")) { + hashMap.put("Ƿ", "true"); + } else { + hashMap.put("Ƿ", "false"); + } + hashMap.put("", propertyValues[11]); + hashMap.put("޸", propertyValues[12]); + hashMap.put("", propertyValues[13]); + hashMap.put("޸", propertyValues[14]); + } catch (TCException e) { + e.printStackTrace(); + } + arrayList.add(hashMap); + } +} diff --git a/src/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.java b/src/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.java new file mode 100644 index 0000000..afb8f15 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/CodeCopyHandler.java @@ -0,0 +1,47 @@ +package cn.com.origin.autocodemanager.handlers; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLine; + +public class CodeCopyHandler extends AbstractHandler { + + + public Object execute(ExecutionEvent execut){ + try { + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + String id=""; + InterfaceAIFComponent target=abstractAIFUIApplication.getTargetComponent(); + if(target.getClass().toString().indexOf("TCComponentItem")>=0){ + id=target.getProperty("item_id"); + }else if(target.getClass().toString().indexOf("TCComponentItemRevision")>=0){ + id=target.getProperty("item_id"); + }else if(target.getClass().toString().indexOf("TCComponentBOMLine")>=0){ + TCComponentBOMLine targetLine=(TCComponentBOMLine) target; + id=targetLine.getItem().getProperty("item_id"); + }else if(target.getClass().toString().indexOf("TCComponentCfgAttachmentLine")>=0){ + TCComponentCfgAttachmentLine cfgLine=(TCComponentCfgAttachmentLine) target; + id=cfgLine.getRelatedComponent("me_cl_source").getProperty("item_id"); + }else if(target.getClass().toString().indexOf("TCComponentMfgBvrProcess")>=0){ + id=target.getProperty("bl_item_item_id"); + } + if(!"".equals(id)){ + setClipboard(id); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + public void setClipboard(String str) { + StringSelection ss = new StringSelection(str); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null); + } + +} diff --git a/src/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.java b/src/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.java new file mode 100644 index 0000000..da7af0c --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/DeleteNodeHandler.java @@ -0,0 +1,100 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.ISources; + +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeConstants; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.AutoCodeSegmentView; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DeleteNodeHandler extends AbstractHandler { + + /** + * + */ + public DeleteNodeHandler() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent e) throws ExecutionException { + Object obj = e.getApplicationContext(); +// AutoCodeListCodeView codeListView; +// AutoCodeTreeCodeView codeTreeView; + AutoCodeSegmentView codeSegmentView; + if (obj instanceof IEvaluationContext) { + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) abstractAIFUIApplication.getSession(); + IEvaluationContext appContext = (IEvaluationContext) obj; + Object view = appContext.getVariable(ISources.ACTIVE_PART_NAME); + if (view instanceof AbstractTreeViewPart) { + try { + session.setStatus("ɾ......"); + Boolean value = false; + AbstractTreeViewPart viewPart = (AbstractTreeViewPart) view; +// codeListView = (AutoCodeListCodeView) viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeListCodeView_ID); +// codeTreeView = (AutoCodeTreeCodeView) viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeTreeCodeView_ID); + codeSegmentView = (AutoCodeSegmentView) viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + + AbstractCreateTreeView autocodeView = viewPart.getCreateView(); + TreeViewOperation treeViewOperation = new TreeViewOperation(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + AbstractTreeData selectedTreeData = treeViewOperation.getSelectedTreeNode(autocodeView.treeViewer); + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + + if ((selectedTreeData == null)) { + MessageBox.post("ѡҪɾڵ!", "INFO", MessageBox.WARNING); + return null; + } + if ((selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪɾڵ!", "INFO", MessageBox.WARNING); + return null; + } + if ((segmentTreeData == null)) { + MessageBox.post("ѡҪɾ!", "INFO", MessageBox.WARNING); + return null; + } + if ((segmentTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.CodeGroupName))) { + segmentTreeData = null; + } + if (!value) { + value = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "INFO", "ȷɾ"); + } + if (value) { + boolean isContinueDelete = treeAndListCodeOperation.deleteTreeORListNode(segmentTreeData, selectedTreeData); + if (isContinueDelete) { + treeViewOperation.removeTreeNode(autocodeView.treeViewer, selectedTreeData); + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + session.setReadyStatus(); + } + } + return null; + } +} diff --git a/src/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.java b/src/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.java new file mode 100644 index 0000000..1c7521a --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/DownListNodeHandler.java @@ -0,0 +1,108 @@ +/** + * @author tyl + * @Action ini + * 2011-5-6 + */ +package cn.com.origin.autocodemanager.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.ui.ISources; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; + +import com.teamcenter.rac.kernel.TCComponent; + +public class DownListNodeHandler extends AbstractHandler { + public DownListNodeHandler() { + } + + public Object execute(ExecutionEvent e) throws ExecutionException { + Object obj = e.getApplicationContext(); + if (obj instanceof IEvaluationContext) { +// AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) abstractAIFUIApplication.getSession(); + IEvaluationContext appContext = (IEvaluationContext) obj; + Object view = appContext.getVariable(ISources.ACTIVE_PART_NAME); + if (view instanceof AbstractTreeViewPart) { + TreeViewOperation treeViewOperation = new TreeViewOperation(); + AbstractTreeViewPart viewPart = (AbstractTreeViewPart) view; + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + + AutoCodeListCodeView codeListView = (AutoCodeListCodeView) viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); +// AutoCodeSegmentView codeSegmentView = (AutoCodeSegmentView) viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + AbstractTreeData selectedTreeData = treeViewOperation.getSelectedTreeNode(codeListView.createView.treeViewer); +// AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + if (selectedTreeData == null) { + return null; + } + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyNodeName)) { + AbstractTreeData[] listPropertyTreeDatas = (AbstractTreeData[]) codeListView.createView.treeViewer.getInput(); + for (int i = 0; i < listPropertyTreeDatas.length; i++) { + if (selectedTreeData.equals(listPropertyTreeDatas[i])) { + AbstractTreeData tempTreeData = listPropertyTreeDatas[i]; + if (i < listPropertyTreeDatas.length - 1) { + listPropertyTreeDatas[i] = listPropertyTreeDatas[i + 1]; + listPropertyTreeDatas[i + 1] = tempTreeData; + codeListView.createView.treeViewer.refresh(); + break; + } + } + } + + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(selectedTreeData.getParentTreeData(), parentStr); + String childrenStr = ""; + for (int i = 0; i < listPropertyTreeDatas.length; i++) { + TCComponent component = listPropertyTreeDatas[i].getPackCodeNodeInfo().getNodeComponent(); + if (component != null) { + childrenStr = childrenStr + component.getUid() + ","; + + } + } + if (childrenStr.toString().endsWith(",")) { + childrenStr = childrenStr.substring(0, childrenStr.length() - 1).toString(); + } + treeAndListCodeOperation.updateChildrenCodeRelation(parentStr, selectedTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent().getUid(), childrenStr); + } else { + AbstractTreeData listPropertyTreeNode = selectedTreeData.getParentTreeData(); + AbstractTreeData[] listPropertyValueTreeDatas = listPropertyTreeNode.getChildrenTreeData(); + for (int i = 0; i < listPropertyValueTreeDatas.length; i++) { + if (selectedTreeData.equals(listPropertyValueTreeDatas[i])) { + AbstractTreeData tempTreeData = listPropertyValueTreeDatas[i]; + if (i < listPropertyValueTreeDatas.length - 1) { + listPropertyValueTreeDatas[i] = listPropertyValueTreeDatas[i + 1]; + listPropertyValueTreeDatas[i + 1] = tempTreeData; + listPropertyTreeNode.setTreeAutoCodeNodeChildren(listPropertyValueTreeDatas); + codeListView.createView.treeViewer.refresh(listPropertyTreeNode); + break; + } + } + } + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(selectedTreeData.getParentTreeData(), parentStr); + String childrenStr = ""; + for (int i = 0; i < listPropertyValueTreeDatas.length; i++) { + TCComponent component = listPropertyValueTreeDatas[i].getPackCodeNodeInfo().getNodeComponent(); + if (component != null) { + childrenStr = childrenStr + component.getUid() + ","; + + } + } + if (childrenStr.toString().endsWith(",")) { + childrenStr = childrenStr.substring(0, childrenStr.length() - 1).toString(); + } + treeAndListCodeOperation.updateChildrenCodeRelation(parentStr, selectedTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent().getUid(), childrenStr); + } + } + } + return null; + } +} diff --git a/src/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.java b/src/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.java new file mode 100644 index 0000000..d1af1ab --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/ExportNodeHandler.java @@ -0,0 +1,63 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.handlers; + +import javax.swing.JFileChooser; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.ISources; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.export.ExportNodeOperation; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ExportNodeHandler extends AbstractHandler { + public Object execute(ExecutionEvent e) throws ExecutionException { + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) abstractAIFUIApplication.getSession(); + Object obj = e.getApplicationContext(); + if (obj instanceof IEvaluationContext) { + IEvaluationContext appContext = (IEvaluationContext) obj; + Object view = appContext.getVariable(ISources.ACTIVE_PART_NAME); + if (view instanceof AbstractTreeViewPart) { + AbstractTreeViewPart treeViewPart = (AbstractTreeViewPart) view; + AbstractCreateTreeView treeView = treeViewPart.getCreateView(); + AbstractTreeData selectedNode = new TreeViewOperation().getSelectedTreeNode(treeView.treeViewer); + // TreeViewOperation treeViewOperation=new TreeViewOperation(); + JFileChooser jfc = new JFileChooser(); + jfc.setFileSelectionMode(JFileChooser.CUSTOM_DIALOG); + String filePath = jfc.getFileSystemView().getHomeDirectory().getPath(); + //DirectoryDialog directoryDialog = new DirectoryDialog(Display.getDefault().getActiveShell()); + //directoryDialog.setText(""); + //directoryDialog.open(); + //String filePath = directoryDialog.getFilterPath(); + System.out.println("ѡļ·:" + filePath); + if (filePath != null && !"".equals(filePath)) { + filePath = filePath + "\\" + selectedNode.getPackCodeNodeInfo().getNode_name() + ".xls"; + } else { + MessageBox.post("ѡ·", "INFO", MessageBox.WARNING); + return null; + } + session.setStatus("ڵ......"); + new ExportNodeOperation(treeViewPart, selectedNode, filePath).exportNode(); + session.setReadyStatus(); + } + } + return null; + } + +} diff --git a/src/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.java b/src/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.java new file mode 100644 index 0000000..a46e132 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/ImportCodeNextIdHandler.java @@ -0,0 +1,43 @@ +/** + * @author tyl + * @Action ini + * 2011-5-17 + */ +package cn.com.origin.autocodemanager.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class ImportCodeNextIdHandler extends AbstractHandler { + + private TCUserService userService; + private TCSession session = null; + + public ImportCodeNextIdHandler() { + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. + * ExecutionEvent) + */ + public Object execute(ExecutionEvent e) throws ExecutionException { + try { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + userService = (TCUserService) session.getUserService(); + Object[] params = {}; + userService.call("importHistoryNextID", params); + } catch (TCException e1) { + e1.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.java b/src/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.java new file mode 100644 index 0000000..1731081 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/ImportNodeHandler.java @@ -0,0 +1,60 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.ui.ISources; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.imports.ImportNodeOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ImportNodeHandler extends AbstractHandler { + + public Object execute(ExecutionEvent e) throws ExecutionException { + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) abstractAIFUIApplication.getSession(); + Object obj = e.getApplicationContext(); + if (obj instanceof IEvaluationContext) { + IEvaluationContext appContext = (IEvaluationContext) obj; + Object view = appContext.getVariable(ISources.ACTIVE_PART_NAME); + if (view instanceof AbstractTreeViewPart) { + AbstractTreeViewPart treeViewPart = (AbstractTreeViewPart) view; + AbstractCreateTreeView treeView = treeViewPart.getCreateView(); + AbstractTreeData selectedNode = new TreeViewOperation().getSelectedTreeNode(treeView.treeViewer); + FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell()); + fileDialog.setText(""); + fileDialog.setFilterNames(new String[] { "*.xls" }); + fileDialog.setFilterExtensions(new String[] { "*.xls" }); + fileDialog.open(); + String filePath = fileDialog.getFilterPath(); + String fileName = fileDialog.getFileName(); + // System.out.println("ѡļ·:" + filePath); + if (filePath != null && !"".equals(filePath) && fileName != null && !"".equals(fileName)) { + filePath = filePath + "/" + fileName; + } else { + MessageBox.post("ѡļ", "INFO", MessageBox.WARNING); + return null; + } + session.setStatus("ڵ......"); + new ImportNodeOperation(treeViewPart, selectedNode, filePath).importNode(); + session.setReadyStatus(); + MessageBox.post("ɹ!", "INFO", MessageBox.WARNING); + } + } + return null; + } +} diff --git a/src/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.java b/src/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.java new file mode 100644 index 0000000..efb0fb4 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/handlers/UpListNodeHandler.java @@ -0,0 +1,107 @@ +/** + * @author tyl + * @Action ini + * 2011-5-6 + */ +package cn.com.origin.autocodemanager.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.ui.ISources; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; +import com.teamcenter.rac.kernel.TCComponent; + +public class UpListNodeHandler extends AbstractHandler { + public UpListNodeHandler() { + } + + public Object execute(ExecutionEvent e) throws ExecutionException { + Object obj = e.getApplicationContext(); + if (obj instanceof IEvaluationContext) { +// AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) abstractAIFUIApplication.getSession(); + IEvaluationContext appContext = (IEvaluationContext) obj; + Object view = appContext.getVariable(ISources.ACTIVE_PART_NAME); + if (view instanceof AbstractTreeViewPart) { + TreeViewOperation treeViewOperation = new TreeViewOperation(); + AbstractTreeViewPart viewPart = (AbstractTreeViewPart) view; + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + + AutoCodeListCodeView codeListView = (AutoCodeListCodeView) viewPart.getSite().getPage().findView(AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); +// AutoCodeSegmentView codeSegmentView = (AutoCodeSegmentView) viewPart.getSite().getPage().findView(AutoCodeConstants.AutoCodeSegmentView_ID); + AbstractTreeData selectedTreeData = treeViewOperation.getSelectedTreeNode(codeListView.createView.treeViewer); +// AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + if (selectedTreeData == null) { + return null; + } + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyNodeName)) { + AbstractTreeData[] listPropertyTreeDatas = (AbstractTreeData[]) codeListView.createView.treeViewer.getInput(); + for (int i = 0; i < listPropertyTreeDatas.length; i++) { + if (selectedTreeData.equals(listPropertyTreeDatas[i])) { + AbstractTreeData tempTreeData = listPropertyTreeDatas[i]; + if (i > 0) { + listPropertyTreeDatas[i] = listPropertyTreeDatas[i - 1]; + listPropertyTreeDatas[i -1] = tempTreeData; + codeListView.createView.treeViewer.refresh(); + break; + } + } + } + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(selectedTreeData.getParentTreeData(), parentStr); + String childrenStr = ""; + for (int i = 0; i < listPropertyTreeDatas.length; i++) { + TCComponent component = listPropertyTreeDatas[i].getPackCodeNodeInfo().getNodeComponent(); + if (component != null) { + childrenStr = childrenStr + component.getUid() + ","; + + } + } + if (childrenStr.toString().endsWith(",")) { + childrenStr = childrenStr.substring(0, childrenStr.length() - 1).toString(); + } + treeAndListCodeOperation.updateChildrenCodeRelation(parentStr, selectedTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent().getUid(), childrenStr); + } else { + AbstractTreeData listPropertyTreeNode = selectedTreeData.getParentTreeData(); + AbstractTreeData[] listPropertyValueTreeDatas = listPropertyTreeNode.getChildrenTreeData(); + for (int i = 0; i < listPropertyValueTreeDatas.length; i++) { + if (selectedTreeData.equals(listPropertyValueTreeDatas[i])) { + AbstractTreeData tempTreeData = listPropertyValueTreeDatas[i]; + if (i > 0) { + listPropertyValueTreeDatas[i] = listPropertyValueTreeDatas[i - 1]; + listPropertyValueTreeDatas[i - 1] = tempTreeData; + listPropertyTreeNode.setTreeAutoCodeNodeChildren(listPropertyValueTreeDatas); + codeListView.createView.treeViewer.refresh(listPropertyTreeNode); + break; + } + } + } + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(selectedTreeData.getParentTreeData(), parentStr); + String childrenStr = ""; + for (int i = 0; i < listPropertyValueTreeDatas.length; i++) { + TCComponent component = listPropertyValueTreeDatas[i].getPackCodeNodeInfo().getNodeComponent(); + if (component != null) { + childrenStr = childrenStr + component.getUid() + ","; + + } + } + if (childrenStr.toString().endsWith(",")) { + childrenStr = childrenStr.substring(0, childrenStr.length() - 1).toString(); + } + treeAndListCodeOperation.updateChildrenCodeRelation(parentStr, selectedTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent().getUid(), childrenStr); + } + } + } + return null; + } + +} diff --git a/src/cn/com/origin/autocodemanager/imports/ImportNodeOperation.java b/src/cn/com/origin/autocodemanager/imports/ImportNodeOperation.java new file mode 100644 index 0000000..37a629e --- /dev/null +++ b/src/cn/com/origin/autocodemanager/imports/ImportNodeOperation.java @@ -0,0 +1,159 @@ +/** + * @author tyl + * @Action ini + * 2011-3-22 + */ +package cn.com.origin.autocodemanager.imports; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import jxl.read.biff.BiffException; +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.ExcelOperation; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +public class ImportNodeOperation { + + private TreeViewOperation treeViewOperation; + // private TCSession session; + private AbstractTreeViewPart viewPart; + private AbstractTreeData treeData; + private String filePath; + TCComponent ruleComponent = null; + + public ImportNodeOperation(AbstractTreeViewPart viewPart, AbstractTreeData treeData, String filePath) { + this.viewPart = viewPart; + this.treeData = treeData; + this.filePath = filePath; + initParams(); + } + + public void initParams() { + // this.treeAndListCodeOperation = new TreeAndListCodeOperation(); + this.treeViewOperation = new TreeViewOperation(); + // session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + } + + public void importNode() { + try { + importTreeNode(treeData, filePath); + } catch (BiffException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private ArrayList> getImportFromExcel(String filePath) throws BiffException, IOException { + return ExcelOperation.readExcel(new File(filePath), 1, AutoCodeManagerPropertyName.TreeAndListCodeNode_Titles); + } + + public void importTreeNode(AbstractTreeData parentTreeData, String filePath) throws TCException, BiffException, IOException { + HashMap levelMap = new HashMap(); + ArrayList> arrayList = getImportFromExcel(filePath); + // System.out.println("arrayList:" + arrayList); + if (arrayList != null && arrayList.size() > 0) { + HashMap hashMap = (HashMap) arrayList.get(0); + int levelIndex = 0; + String level = (String) hashMap.get(""); + String name = (String) hashMap.get(""); + try { + levelIndex = Integer.parseInt(level); + } catch (NumberFormatException e) { + MessageBox.post(name + "д!", "INFO", MessageBox.WARNING); + e.printStackTrace(); + return; + } + String parentLevel = String.valueOf(levelIndex - 1); + levelMap.put(parentLevel, parentTreeData); + + for (int i = 0; i < arrayList.size(); i++) { + hashMap = (HashMap) arrayList.get(i); + level = (String) hashMap.get(""); + name = (String) hashMap.get(""); + String type = (String) hashMap.get(""); + try { + levelIndex = Integer.parseInt(level); + } catch (NumberFormatException e) { + MessageBox.post(name + "д!", "INFO", MessageBox.WARNING); + e.printStackTrace(); + return; + } + parentLevel = String.valueOf(levelIndex - 1); + parentTreeData = (AbstractTreeData) levelMap.get(parentLevel); + if (parentTreeData == null) { + MessageBox.post("" + name + "дǷ!", "INFO", MessageBox.WARNING); + return; + } + HashMap newHashMap = new HashMap(); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_index, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, name); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, (String) hashMap.get("ֵ")); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, type); + if ((type.equalsIgnoreCase("tree")) || (type.equalsIgnoreCase("list"))) { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, "true"); + } else { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, "false"); + } + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, (String) hashMap.get("ʽ")); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, (String) hashMap.get("볤")); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, (String) hashMap.get("ע")); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, ""); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, ""); + String isDefault = (String) hashMap.get("ǷΪĬֵ"); + if ((isDefault != null) && ((isDefault.equalsIgnoreCase("false")) || (isDefault.equalsIgnoreCase("true")))) { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, (String) hashMap.get("ǷΪĬֵ")); + } else { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "false"); + } + + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, (String) hashMap.get("ˮʼֵ")); + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, (String) hashMap.get("ˮֵ")); + String maxValue = (String) hashMap.get("ˮֵ"); + if ((maxValue != null) && (!maxValue.equalsIgnoreCase("0")) && (maxValue.trim().length() > 0)) { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, String.valueOf(maxValue.trim().length())); + } else { + newHashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, "0"); + } + if (newHashMap.get(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root).equalsIgnoreCase("true")) { + ruleComponent = null; + } + if (newHashMap.get(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type).equalsIgnoreCase(AutoCodeManagerPropertyName.CodeGroupName)) { + ruleComponent = null; + } + + TCComponent newComponent = new TreeAndListCodeOperation().createNewTreeORListNode(ruleComponent, parentTreeData, newHashMap); + if (newComponent == null) { + return; + } + if ((newHashMap.get(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root) != null) && (newHashMap.get(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root)).equalsIgnoreCase("true")) { + ruleComponent = newComponent; + } + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(newComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + AbstractTreeData treeData = new AbstractTreeData(parentTreeData, packCodeNodeInfo); + + treeViewOperation.addChildrenRelations(parentTreeData, treeData); + viewPart.createView.treeViewer.refresh(parentTreeData); + levelMap.put(level, treeData); + } + } + } +} diff --git a/src/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.java b/src/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.java new file mode 100644 index 0000000..57c2669 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/AutoCodeListCodeView.java @@ -0,0 +1,33 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views; + +import org.eclipse.swt.widgets.Composite; + +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.views.listcodeview.CreateListCodeView; + +public class AutoCodeListCodeView extends AbstractTreeViewPart { + + public AutoCodeListCodeView() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite arg0) { + super.createPartControl(arg0); + createView = new CreateListCodeView(arg0, "б", this); + } + + @Override + public void setFocus() { + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.java b/src/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.java new file mode 100644 index 0000000..ac8153e --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/AutoCodeSegmentView.java @@ -0,0 +1,23 @@ +package cn.com.origin.autocodemanager.views; + +import org.eclipse.swt.widgets.Composite; + +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.views.codeview.CreateCodeSegmentView; + +public class AutoCodeSegmentView extends AbstractTreeViewPart { + public AutoCodeSegmentView() { + super(); + } + + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + createView=new CreateCodeSegmentView(parent,"",AutoCodeSegmentView.this); + } + + @Override + public void setFocus() { + + } +} diff --git a/src/cn/com/origin/autocodemanager/views/AutoCodeTestView.java b/src/cn/com/origin/autocodemanager/views/AutoCodeTestView.java new file mode 100644 index 0000000..e90b2ad --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/AutoCodeTestView.java @@ -0,0 +1,40 @@ +/** + * @author tyl + * @Action ini + * 2011-3-17 + */ +package cn.com.origin.autocodemanager.views; + +import org.eclipse.swt.widgets.Composite; + +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.views.testview.CreateCodeTestView; + +public class AutoCodeTestView extends AbstractTreeViewPart { + + public AutoCodeTestView() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parentComposite) { + super.createPartControl(parentComposite); + new CreateCodeTestView(parentComposite, "", this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.java b/src/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.java new file mode 100644 index 0000000..e1f6be4 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/AutoCodeTreeCodeView.java @@ -0,0 +1,44 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views; + +import org.eclipse.swt.widgets.Composite; + +import cn.com.origin.autocodemanager.common.AbstractTreeViewPart; +import cn.com.origin.autocodemanager.views.treecodeview.CreateTreeCodeView; + +public class AutoCodeTreeCodeView extends AbstractTreeViewPart { + + /** + * + */ +// private CreateTreeCodeView createTreeCodeView; + + public AutoCodeTreeCodeView() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite arg0) { + super.createPartControl(arg0); + createView = new CreateTreeCodeView(arg0, "", this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.java b/src/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.java new file mode 100644 index 0000000..de68c8c --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codestyleview/CreateCodeStyleView.java @@ -0,0 +1,119 @@ +/** + * @author tyl + * @Action ini + * 2011-4-7 + */ +package cn.com.origin.autocodemanager.views.codestyleview; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.part.ViewPart; + +import cn.com.origin.autocodemanager.common.CreateCompositeUtil; + +public class CreateCodeStyleView { + public ViewPart viewPart; + public Text seqBeginText; + public Text seqMaxText; + public Text seqLengthtext; + public Text seqStepText; + public Text seqExcludeStrText; + public Text codeStyleText; + public Text patternMinLengthText; + public Text coverText; + + public CreateCodeStyleView(Composite composite, ViewPart viewPart) { + this.viewPart = viewPart; + createNewComposite(composite); + } + + public void createNewComposite(Composite parent) { + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + parent.setLayout(gridLayout); + parent.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + Group nodeGroup = CreateCompositeUtil.createCompositeGroup(parent, "ˮ"); + nodeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + createSeqPropertyComposite(nodeGroup); + + Group coverGroup = CreateCompositeUtil.createCompositeGroup(parent, "λ"); + coverGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + createCoverComposite(coverGroup); + + Group styleGroup = CreateCompositeUtil.createCompositeGroup(parent, "ʽ"); + styleGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + createCodeStyleComposite(styleGroup); + + Group buttonGroup = CreateCompositeUtil.createCompositeGroup(parent, "dsdsds"); + buttonGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + createButtonComposite(buttonGroup); + } + + + private void createCodeStyleComposite(Composite composite) { + Composite styleComposite = new Composite(composite, SWT.NONE); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + styleComposite.setLayoutData(CreateCompositeUtil.getNewGridData()); + styleComposite.setLayout(gridLayout1); + styleComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + CreateCompositeUtil.createNewWhiteLabel(styleComposite, "ʽ"); + codeStyleText = CreateCompositeUtil.createNewText(styleComposite, "@"); + } + + private void createButtonComposite(Composite composite) { + Composite buttonComposite = new Composite(composite, SWT.NONE); + buttonComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + Button button1 = CreateCompositeUtil.createNewButton(buttonComposite, ""); + button1.setVisible(true); + Button button2 = CreateCompositeUtil.createButton(buttonComposite, "", 30, 100); + button2.setVisible(true); + } + + private void createCoverComposite(Composite composite) { + Composite coverComposite = new Composite(composite, SWT.NONE); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + coverComposite.setLayoutData(CreateCompositeUtil.getNewGridData()); + coverComposite.setLayout(gridLayout1); + coverComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + + CreateCompositeUtil.createNewWhiteLabel(coverComposite, "С"); + patternMinLengthText = CreateCompositeUtil.createNewText(coverComposite, ""); + CreateCompositeUtil.createNewWhiteLabel(coverComposite, "λ"); + coverText = CreateCompositeUtil.createNewText(coverComposite, ""); + } + + /** + * This method initializes createSeqPropertyComposite + * + */ + public void createSeqPropertyComposite(Composite parent) { + Composite seqComposite = new Composite(parent, SWT.NONE); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + seqComposite.setLayoutData(CreateCompositeUtil.getNewGridData()); + seqComposite.setLayout(gridLayout1); + seqComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + + CreateCompositeUtil.createNewWhiteLabel(seqComposite, "ʼֵ"); + seqBeginText = CreateCompositeUtil.createNewText(seqComposite, "0"); + + CreateCompositeUtil.createNewWhiteLabel(seqComposite, "ֵ"); + seqMaxText = CreateCompositeUtil.createNewText(seqComposite, "0"); + + CreateCompositeUtil.createNewWhiteLabel(seqComposite, ""); + seqLengthtext = CreateCompositeUtil.createNewText(seqComposite, "0"); + + CreateCompositeUtil.createNewWhiteLabel(seqComposite, ""); + seqStepText = CreateCompositeUtil.createNewText(seqComposite, "0"); + + CreateCompositeUtil.createNewWhiteLabel(seqComposite, ""); + seqExcludeStrText = CreateCompositeUtil.createNewText(seqComposite, ""); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.java b/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.java new file mode 100644 index 0000000..b5aa25d --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentDialog.java @@ -0,0 +1,230 @@ +/** + * @author tyl + * @Action ini + * 2011-3-23 + */ +package cn.com.origin.autocodemanager.views.codeview; + +import java.util.HashMap; +import java.util.List; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.CreateCompositeUtil; +import cn.com.origin.autocodemanager.common.dialog.AbstractCodeSegmentDialog; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class CodeSegmentDialog extends AbstractCodeSegmentDialog { + + public CodeSegmentDialog(Shell parentShell, AbstractCreateTreeView createView, String title, String action) { + super(parentShell, createView, title, action); + } + + // Ի + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + Group nodeGroup = CreateCompositeUtil.createCompositeGroup(container, ""); + createTreeComposite(nodeGroup); + return container; + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView#addRightKeyAction() + */ + public void addRightKeyAction() { + final Tree tree = treeViewer.getTree(); + tree.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent mouseevent) { + addChildrenDataToParent(); + } + }); + } + + private void addChildrenDataToParent() { + AbstractTreeData parentTreeData = null; + AbstractTreeData childrenTreeData = treeViewOperation.getSelectedTreeNode(treeViewer); + + AbstractTreeData segmentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + + if ((childrenTreeData == null) || (childrenTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪҪӽڵ!", "INFO", MessageBox.WARNING); + return; + } + if ((segmentTreeData == null) || (segmentTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡ޸ĵĹ!", "INFO", MessageBox.WARNING); + return; + } + + parentTreeData = treeViewOperation.getSelectedTreeNode(createView.treeViewer); + if (parentTreeData == null) { + parentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + } + if (action.equals(AutoCodeManagerPropertyName.ListPropertyNodeName)) { + if (!childrenTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyNodeName)) { + MessageBox.post("ѡҪҪӵԽڵ!", "INFO", MessageBox.WARNING); + return; + } + parentTreeData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + AbstractTreeData targetAddNode = addNewChildrenNode(codeSegmentView.createView.treeViewer, parentTreeData, childrenTreeData.getPackCodeNodeInfo().getNodeComponent(), segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + String parentStr = ""; + addNewChildrenNodes(createView.treeViewer, treeAndListCodeOperation.getParentStr(childrenTreeData, parentStr), childrenTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(), targetAddNode, segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + treeViewOperation.addExistCodeNode(createView.treeViewer, parentTreeData, targetAddNode); + createView.treeViewer.refresh(); + } else if (action.equals(AutoCodeManagerPropertyName.TreeNodeName)) { + if ((!childrenTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.TreeNodeName))) { + MessageBox.post("ѡҪҪӵڵ!", "INFO", MessageBox.WARNING); + return; + } + AbstractTreeData targetAddNode = addNewChildrenNode(treeViewer, parentTreeData, childrenTreeData.getPackCodeNodeInfo().getNodeComponent(), segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + String parentStr = ""; + addNewChildrenNodes(createView.treeViewer, treeAndListCodeOperation.getParentStr(childrenTreeData, parentStr), childrenTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(), targetAddNode, segmentTreeData.getPackCodeNodeInfo().getNodeComponent()); + treeViewOperation.appendChildrenNode(createView.treeViewer, parentTreeData, targetAddNode); + createView.treeViewer.refresh(); + } + } + + private AbstractTreeData addNewChildrenNode(TreeViewer treeView, AbstractTreeData parentNode, TCComponent component, TCComponent segmentComponent) { + AbstractTreeData treeNode = null; + try { + if (component == null) { + return null; + } + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(component, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + treeNode = new AbstractTreeData(parentNode, packCodeNodeInfo); + + treeViewOperation.addChildrenRelations(parentNode, treeNode); + treeAndListCodeOperation.addNodeReferenceComponents(component, segmentComponent); + treeView.refresh(parentNode); + } catch (TCException e) { + e.printStackTrace(); + } catch (ServiceException e) { + e.printStackTrace(); + } + return treeNode; + } + + private void addNewChildrenNodes(TreeViewer treeView, String parentStr, String currentStr, AbstractTreeData parentNode, TCComponent segmentComponent) { + try { + TCComponent[] tccomponents = null; + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, currentStr); + tccomponents = treeAndListCodeOperation.searchTreeORListNodes(hashMap); + for (int i = 0; i < tccomponents.length; i++) { + AbstractTreeData copyNode = addNewChildrenNode(treeView, parentNode, tccomponents[i], segmentComponent); + String parentStr2 = parentStr + "," + currentStr; + if (parentStr2.trim().startsWith(",")) { + parentStr2 = parentStr2.substring(1); + } + addNewChildrenNodes(treeView, parentStr2, tccomponents[i].getUid().trim(), copyNode, segmentComponent); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView#createOrgAutoCodeNodeChildren(cn.com.origin.autocodemanager.common.tree.AbstractTreeData[]) + */ + + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) throws Exception { + if (codeDatas != null && codeDatas.length > 0) { + for (int i = 0; i < codeDatas.length; i++) { + AbstractTreeData autoCodeData = (AbstractTreeData) codeDatas[i]; + if (autoCodeData == null) { + continue; + } + TCComponent autoCodeDataComponent = autoCodeData.getPackCodeNodeInfo().getNodeComponent(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + HashMap hashMap = new HashMap(); + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(autoCodeData, parentStr); + + if (autoCodeDataComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, autoCodeDataComponent.getUid()); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + } else { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, ""); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, ""); + } + String parentStr2 = ""; + if (autoCodeDataComponent != null) { + if (parentStr.trim().length() == 0) { + parentStr2 = autoCodeDataComponent.getUid(); + } else { + parentStr2 = parentStr + "," + autoCodeDataComponent.getUid(); + } + } else { + parentStr2 = parentStr; + } + + List packCodeNodeInfos = treeAndListCodeOperation.searchTreeORListNodeInfos(hashMap, parentStr2, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + if (packCodeNodeInfos != null && packCodeNodeInfos.size() > 0) { + AbstractTreeData autoCodeDataTCComs[] = new AbstractTreeData[packCodeNodeInfos.size()]; + for (int k = 0; k < packCodeNodeInfos.size(); k++) { + if (packCodeNodeInfos.get(k).getNodeComponent() == null) { + continue; + } + PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(k); + autoCodeDataTCComs[k] = new AbstractTreeData(autoCodeData, packCodeNodeInfo); + if (packCodeNodeInfo.isContainsChildren()) { + autoCodeDataTCComs[k].setTreeAutoCodeNodeChildren(new AbstractTreeData[] { new AbstractTreeData() }); + } + } + autoCodeData.setTreeAutoCodeNodeChildren(autoCodeDataTCComs); + autoCodeData.setChildrenLoader(true); + treeViewer.refresh(autoCodeData); + } + } + } + } + + // öԻʼС + @Override + protected Point getInitialSize() { + return new Point(370, 500); + } + + // Իť + @Override + protected void createButtonsForButtonBar(final Composite parent) { + createButton(parent, IDialogConstants.OK_ID, "", true); + createButton(parent, IDialogConstants.CANCEL_ID, "ر", false); + getButton(IDialogConstants.OK_ID).setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.OK_IMAGE)); + getButton(IDialogConstants.CANCEL_ID).setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CLOSE_IMAGE)); + } + + // ڵǷΪ + @Override + protected void okPressed() { + addChildrenDataToParent(); + this.close(); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.java b/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.java new file mode 100644 index 0000000..c64fc34 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/CodeSegmentViewRightKeyAction.java @@ -0,0 +1,79 @@ +/** + * @author tyl + * @Action ini + * 2011-3-17 + */ +package cn.com.origin.autocodemanager.views.codeview; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.teamcenter.rac.util.MessageBox; + +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeViewRightKeyAction; + +public class CodeSegmentViewRightKeyAction extends AbstractTreeViewRightKeyAction { + /** + * @param treeViewer + */ + public CodeSegmentViewRightKeyAction(AbstractCreateTreeView createCodeSegmentView) { + super(createCodeSegmentView); + } + + public void fillContextMenu() { + if (menuManager == null) { + // һεø÷ʱ + menuManager = new MenuManager(); + menuManager.add(new NewCodeNodeAction(AutoCodeManagerPropertyName.AddRuleGroupNodeName)); + menuManager.add(new NewCodeNodeAction(AutoCodeManagerPropertyName.AddRuleRootNodeName)); + menuManager.add(new CopyCodeNodeAction()); + menuManager.add(new EidtCodeNodeAction()); + menuManager.add(new LockCodeNodeAction()); + menuManager.add(new UnLockCodeNodeAction()); + } + Tree tree = treeViewer.getTree(); + Menu menu = menuManager.createContextMenu(tree); + tree.setMenu(menu); + } + + private class NewCodeNodeAction extends Action { + String actionType = ""; + String title = ""; + + public NewCodeNodeAction(String actionType) { + this.actionType = actionType; + if (actionType.equals(AutoCodeManagerPropertyName.AddRuleRootNodeName)) { + title = "½"; + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CODE_IMAGE); + this.setImageDescriptor(imageDesc); + } else { + title = "½"; + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CODEGROUP_IMAGE); + this.setImageDescriptor(imageDesc); + } + this.setText(title); + + } + + public void run() { + AbstractTreeData selectedTreeData= treeViewOperation.getSelectedTreeNode(createView.treeViewer); + if((treeViewOperation.isRuleRootNode(selectedTreeData))&&(actionType.equals(AutoCodeManagerPropertyName.AddRuleGroupNodeName))) + { + MessageBox.post("˽ڵ²ܽ!", "INFO", MessageBox.WARNING); + return; + } + NewCodeNodeDialog codeNodeDialog = new NewCodeNodeDialog(null, createView, actionType,title, false); + codeNodeDialog.open(); + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.java b/src/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.java new file mode 100644 index 0000000..96a27a9 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/CopyCodeNodeDialog.java @@ -0,0 +1,167 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views.codeview; + +import java.util.HashMap; + +import org.eclipse.swt.widgets.Shell; + +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class CopyCodeNodeDialog extends NewCodeNodeDialog { + + TCComponent ruleComponent = null; + + public CopyCodeNodeDialog(Shell parentShell, AbstractCreateTreeView codeTreeView, String title, boolean isEdit, String actionType) { + super(parentShell, codeTreeView, actionType, title, isEdit); + } + + // ڵǷΪ + @Override + protected void okPressed() { + String nodename = nodeNameText.getText().trim(); + if (nodename == null || nodename.trim().length() == 0) { + postMesssageBox("ƲΪգ"); + nodeNameText.setFocus(); + return; + } + AbstractTreeData targetCopyNode = saveNewCodeNode(selectedTreeData.getParentTreeData(), selectedTreeData); + String parentStr = ""; + copyCodeNodes(treeAndListCodeOperation.getParentStr(selectedTreeData, parentStr), selectedTreeData.getPackCodeNodeInfo().getNodeComponent().getUid(), targetCopyNode); + try { + codeSegmentView.createView.createOrgAutoCodeNodeChildren(new AbstractTreeData[] { targetCopyNode }); + } catch (Exception e) { + e.printStackTrace(); + } + close(); + } + + private AbstractTreeData saveNewCodeNode(AbstractTreeData parentTreeData, AbstractTreeData selectedTreeData) { + AbstractTreeData treeData = null; + try { + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_index, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, getTextValue(nodeNameText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, getTextValue(nodeValueText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, selectedTreeData.getPackCodeNodeInfo().getNode_type()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, getTextValue(nodeDescriptionText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, String.valueOf(selectedTreeData.getPackCodeNodeInfo().is_root)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, getTextValue(codeStyleText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, getTextValue(codeLengthText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, getTextValue(seqBeginText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, getSeqLength()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, getTextValue(seqMaxText)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, ""); + if (selectedTreeData.getParentTreeData().getPackCodeNodeInfo().getNodeComponent() == null) { + ruleComponent = null; + } + TCComponent newComponent = new TreeAndListCodeOperation().createNewTreeORListNode(ruleComponent, parentTreeData, hashMap); + if (newComponent == null) { + return null; + } + if (selectedTreeData.getPackCodeNodeInfo().is_root) { + ruleComponent = newComponent; + } + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(newComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + packCodeNodeInfo.setNodeComponent(newComponent); + treeData = new AbstractTreeData(parentTreeData, packCodeNodeInfo); + treeViewOperation.addExistCodeNode(createView.treeViewer, parentTreeData, treeData); + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + return treeData; + } + + private void copyCodeNodes(String parentStr, String currentStr, AbstractTreeData parentNode) { + try { + TCComponent[] tccomponents = null; + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, currentStr); + tccomponents = treeAndListCodeOperation.searchTreeORListNodes(hashMap); + if (tccomponents == null) { + return; + } + for (int i = 0; i < tccomponents.length; i++) { + AbstractTreeData copyNode = copyTreeData(parentNode, tccomponents[i]); + String parentStr2 = parentStr + "," + currentStr; + if (parentStr2.trim().startsWith(",")) { + parentStr2 = parentStr2.substring(1); + } + copyCodeNodes(parentStr2, tccomponents[i].getUid().trim(), copyNode); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private AbstractTreeData copyTreeData(AbstractTreeData parentTreeData, TCComponent sourceComponent) { + AbstractTreeData treeData = null; + + try { + sourceComponent.refresh(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(sourceComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + String[] propertyNames = { AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value }; + String[] propertyValues = sourceComponent.getProperties(propertyNames); + HashMap hashMap = new HashMap(); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_index, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name, packCodeNodeInfo.getNode_name()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value, packCodeNodeInfo.getNode_value()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type, packCodeNodeInfo.getNode_type()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc, packCodeNodeInfo.getNode_desc()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root, String.valueOf(packCodeNodeInfo.is_root)); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, packCodeNodeInfo.getCode_style()); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, propertyValues[0]); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, propertyValues[1]); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, propertyValues[2]); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value, propertyValues[3]); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_reference_nodes, ""); + if (packCodeNodeInfo.is_root) { + ruleComponent = null; + } + TCComponent newComponent = new TreeAndListCodeOperation().createNewTreeORListNode(ruleComponent, parentTreeData, hashMap); + if (packCodeNodeInfo.is_root) { + ruleComponent = newComponent; + } + packCodeNodeInfo.setNodeComponent(newComponent); + treeData = new AbstractTreeData(parentTreeData, packCodeNodeInfo); + treeViewOperation.addChildrenRelations(parentTreeData, treeData); + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + return treeData; + } +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.java b/src/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.java new file mode 100644 index 0000000..40be0e4 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/CreateCodeSegmentView.java @@ -0,0 +1,247 @@ +/** + * @author tyl + * @Action ini + * 2011-3-15 + */ +package cn.com.origin.autocodemanager.views.codeview; + +import java.util.HashMap; +import java.util.List; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.ORTreeContentProvider; +import cn.com.origin.autocodemanager.common.tree.ORTreeLabelProvider; +import cn.com.origin.autocodemanager.views.AutoCodeListCodeView; +import cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView; +import com.teamcenter.rac.kernel.TCComponent; + +public class CreateCodeSegmentView extends AbstractCreateTreeView { + private boolean isSelectedAction = false; + + public CreateCodeSegmentView(Composite composite, String rootName, + ViewPart viewPart) { + super(composite, rootName, viewPart); + } + + public CreateCodeSegmentView(Composite composite, String rootName) { + super(composite, rootName); + } + + public void initTree(String rootName) { + tree.setFocus(); // ý + treeViewer.setLabelProvider(new ORTreeLabelProvider()); + treeViewer.setContentProvider(new ORTreeContentProvider()); + rootTreeData = new AbstractTreeData(null, null, rootName, + AutoCodeManagerPropertyName.SegmentName, false); + treeViewer.setInput((new Object[] { rootTreeData })); + if (viewPart != null) { + codeListView = (AutoCodeListCodeView) viewPart + .getSite() + .getPage() + .findView( + AutoCodeManangerConstants.AutoCodeManagerListCodeView_ID); + codeTreeView = (AutoCodeTreeCodeView) viewPart + .getSite() + .getPage() + .findView( + AutoCodeManangerConstants.AutoCodeManagerTreeCodeView_ID); + } + } + + public void addRightKeyAction() { + final Tree tree = treeViewer.getTree(); + tree.addMouseListener(new MouseAdapter() { + public void mouseDown(MouseEvent e) { + if (e.button == 3) { + CodeSegmentViewRightKeyAction rightAction = new CodeSegmentViewRightKeyAction( + CreateCodeSegmentView.this); + rightAction.fillContextMenu(); + } + } + }); + } + + public void createTree(Composite parent, String rootName) { + Composite composite = new Composite(parent, 0); + FillLayout fillLayout = new FillLayout(); + composite.setLayout(fillLayout); + + treeViewer = new TreeViewer(composite, SWT.BORDER); + tree = treeViewer.getTree(); + tree.setBackground(new Color(Display.getCurrent(), 255, 255, 255)); + initTree(rootName); + + treeViewer.expandToLevel(1); + tree.addTreeListener(new TreeListener() { + public void treeCollapsed(TreeEvent treeEvent) { + } + + public void treeExpanded(TreeEvent treeEvent) { + isSelectedAction = false; + AbstractTreeData codeData = (AbstractTreeData) treeEvent.item + .getData(); + if (codeData == null) { + return; + } + try { + expandNode(codeData); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AbstractTreeData selectedData = (AbstractTreeData) e.item + .getData(); + if (selectedData == null) { + return; + } + isSelectedAction = true; + if (selectedData.getParentTreeData() == null) { + if (!selectedData.isChildrenLoader()) { + expandNode(selectedData); + } + return; + } + if ((selectedData.getPackCodeNodeInfo().getNodeComponent() != null) + && (selectedData.getPackCodeNodeInfo().is_root)) { + expandNode(selectedData); + } else { + if ((codeListView != null) && ((codeTreeView != null))) { + codeListView.createView.treeViewer.setInput(null); + codeTreeView.createView.treeViewer.setInput(null); + } + } + } + }); + } + + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) + throws Exception { + if ((codeListView != null) && ((codeTreeView != null))) { + codeListView.createView.treeViewer.setInput(null); + codeTreeView.createView.treeViewer.setInput(null); + } + if (codeDatas != null && codeDatas.length > 0) { + for (int i = 0; i < codeDatas.length; i++) { + AbstractTreeData autoCodeData = (AbstractTreeData) codeDatas[i]; + if (autoCodeData == null) { + continue; + } + TCComponent autoCodeDataComponent = autoCodeData + .getPackCodeNodeInfo().getNodeComponent(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + HashMap hashMap = new HashMap(); + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(autoCodeData, + parentStr); + + if (autoCodeDataComponent != null) { + hashMap + .put( + AutoCodeManagerPropertyName.CodeRelation_current_node, + autoCodeDataComponent.getUid()); + hashMap + .put( + AutoCodeManagerPropertyName.CodeRelation_parent_node, + parentStr); + } else { + hashMap + .put( + AutoCodeManagerPropertyName.CodeRelation_parent_node, + ""); + hashMap + .put( + AutoCodeManagerPropertyName.CodeRelation_current_node, + ""); + } + String parentStr2 = ""; + if (autoCodeDataComponent != null) { + if (parentStr.trim().length() == 0) { + parentStr2 = autoCodeDataComponent.getUid(); + } else { + parentStr2 = parentStr + "," + + autoCodeDataComponent.getUid(); + } + } else { + parentStr2 = parentStr; + } + String[] propertyNames = AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames; + if (isSelectedAction) { + propertyNames = AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames; + } + List packCodeNodeInfos = treeAndListCodeOperation + .searchTreeORListNodeInfos(hashMap, parentStr2, + propertyNames); + if (packCodeNodeInfos != null && packCodeNodeInfos.size() > 0) { + AbstractTreeData autoCodeDataTCComs[] = new AbstractTreeData[packCodeNodeInfos + .size()]; + for (int k = 0; k < packCodeNodeInfos.size(); k++) { + if (packCodeNodeInfos.get(k).getNodeComponent() == null) { + continue; + } + PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos + .get(k); + autoCodeDataTCComs[k] = new AbstractTreeData( + autoCodeData, packCodeNodeInfo); + + if (!packCodeNodeInfo.is_root) { + if (packCodeNodeInfo.isContainsChildren()) { + autoCodeDataTCComs[k] + .setTreeAutoCodeNodeChildren(new AbstractTreeData[] { new AbstractTreeData() }); + } + } + } + if (autoCodeData.getPackCodeNodeInfo().is_root) { + String type = autoCodeData.getPackCodeNodeInfo() + .getNode_type(); + if ((codeListView != null) && ((codeTreeView != null))) { + if (type + .equals(AutoCodeManagerPropertyName.ListName)) { + codeListView.createView.treeViewer + .setInput(autoCodeDataTCComs); + } else if (type + .equals(AutoCodeManagerPropertyName.TreeName)) { + codeTreeView.createView.treeViewer + .setInput(autoCodeDataTCComs); + } + } + } else { + autoCodeData + .setTreeAutoCodeNodeChildren(autoCodeDataTCComs); + autoCodeData.setChildrenLoader(true); + treeViewer.refresh(autoCodeData); + treeViewer.expandToLevel(autoCodeData, 1); + } + } else { + autoCodeData.setTreeAutoCodeNodeChildren(null); + autoCodeData.setChildrenLoader(true); + treeViewer.refresh(autoCodeData); + treeViewer.expandToLevel(autoCodeData, 1); + continue; + } + } + } + } +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.java b/src/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.java new file mode 100644 index 0000000..717ca1c --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/NewCodeNodeDialog.java @@ -0,0 +1,146 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views.codeview; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.dialog.AbstractCodeDialog; +import cn.com.origin.autocodemanager.common.tree.AbstractCreateTreeView; + +public class NewCodeNodeDialog extends AbstractCodeDialog { + + String actionType; + + public NewCodeNodeDialog(Shell parentShell, AbstractCreateTreeView codeTreeView, String actionType, String title, boolean isEdit) { + super(parentShell, codeTreeView, title, isEdit); + this.actionType = actionType; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + if (actionType.equals(AutoCodeManagerPropertyName.AddRuleGroupNodeName)) { + Group nodeGroup = createCompositeGroup(container, ""); + createGroupComposite(nodeGroup); + } else { + Group nodeGroup = createCompositeGroup(container, ""); + createNodeComposite(nodeGroup); + Group seqGroup = createCompositeGroup(container, "ˮ"); + createSeqComposite(seqGroup); + } + return container; + } + + public void createGroupComposite(Composite parent) { + Composite composite = new Composite(parent, 0); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.grabExcessHorizontalSpace = true; + gridData1.verticalSpan = 20; + gridData1.grabExcessVerticalSpace = true; + gridData1.verticalAlignment = GridData.FILL; + composite.setLayoutData(gridData1); + composite.setLayout(gridLayout1); + initNewGroupComposite(composite); + if (selectedTreeData != null) { + if (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() != null) { + setTextValue(nodeNameText, selectedTreeData.getPackCodeNodeInfo().getNode_name()); + setTextValue(nodeDescriptionText, selectedTreeData.getPackCodeNodeInfo().getNode_desc()); + } + } + } + + public void initNewGroupComposite(Composite composite) { + createNewLabel(composite, ""); + nodeNameText = createNewText(composite, ""); + createNewLabel(composite, "ע"); + nodeDescriptionText = createNewText(composite, ""); + } + + public void initNewCodeComposite(Composite composite) { + createNewLabel(composite, ""); + nodeNameText = createNewText(composite, ""); + + createNewLabel(composite, "λ"); + nodeValueText = createNewText(composite, ""); + + createNewLabel(composite, "ע"); + nodeDescriptionText = createNewText(composite, ""); + + createNewLabel(composite, "ʽ"); + codeStyleText = createNewText(composite, "[T][L]"); + + createNewLabel(composite, "볤"); + codeLengthText = createNewText(composite, "14"); + + createNewLabel(composite, ""); + String[] items = new String[] { "", "б" }; + typeCombo = createNewCombo(composite, items); + + } + + // ڵǷΪ + @Override + protected void okPressed() { + String nodename = nodeNameText.getText().trim(); + if (nodename == null || nodename.trim().length() == 0) { + postMesssageBox("ƲΪգ"); + nodeNameText.setFocus(); + return; + } + String type = ""; + if (typeCombo != null) { + if (typeCombo.getText().equals("")) { + type = AutoCodeManagerPropertyName.TreeName; + } else { + type = AutoCodeManagerPropertyName.ListName; + } + } + if (actionType.equals(AutoCodeManagerPropertyName.AddRuleGroupNodeName)) { + type = AutoCodeManagerPropertyName.CodeGroupName; + } + if (actionType.equals(AutoCodeManagerPropertyName.AddRuleGroupNodeName)) { + saveNewCodeNode(selectedTreeData, selectedComponent, createView.treeViewer, type, false); + } else { + if ((treeViewOperation.isRuleRootNode(selectedTreeData))) { + saveNewCodeNode(selectedTreeData.getParentTreeData(), selectedComponent, createView.treeViewer, type, true); + } else { + saveNewCodeNode(selectedTreeData, selectedComponent, createView.treeViewer, type, true); + } + } + close(); + } + + // öԻʼС + @Override + protected Point getInitialSize() { + if (actionType.equals(AutoCodeManagerPropertyName.AddRuleGroupNodeName)) { + return new Point(250, 200); + } else { + return new Point(270, 440); + } + + } + + // öԻ򴰿ڱͼ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.CODENODE_IMAGE)); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.java b/src/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.java new file mode 100644 index 0000000..6ff3fd2 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/codeview/NewCodeTestView.java @@ -0,0 +1,15 @@ +package cn.com.origin.autocodemanager.views.codeview; + +import org.eclipse.swt.widgets.Composite; + +public class NewCodeTestView extends CreateCodeSegmentView{ + + public NewCodeTestView(Composite composite, String rootName) { + super(composite, rootName); + } + public void addRightKeyAction() { + + } + + +} diff --git a/src/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.java b/src/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.java new file mode 100644 index 0000000..4dea4a8 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/listcodeview/CodeListViewRightKeyAction.java @@ -0,0 +1,160 @@ +/** + * @author tyl + * @Action ini + * 2011-3-17 + */ +package cn.com.origin.autocodemanager.views.listcodeview; + +import java.util.HashMap; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.util.MessageBox; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeViewRightKeyAction; + +public class CodeListViewRightKeyAction extends AbstractTreeViewRightKeyAction { + public CodeListViewRightKeyAction(CreateListCodeView createListCodeView) { + super(createListCodeView); + } + + public void fillContextMenu() { + if (menuManager == null) { + // һεø÷ʱ + menuManager = new MenuManager(); + menuManager.add(new NewCodeNodeAction()); + menuManager.add(new NewCodeNodeValueAction()); + menuManager.add(new AddChildrenNodeAction("", AutoCodeManagerPropertyName.ListPropertyNodeName)); + menuManager.add(new SetDefaultSelectedAction()); + menuManager.add(new CancelDefaultSelectedAction()); + menuManager.add(new EidtCodeNodeAction()); + menuManager.add(new RemoveCodeNodeAction()); + menuManager.add(new LockCodeNodeAction()); + menuManager.add(new UnLockCodeNodeAction()); + } + Tree tree = treeViewer.getTree(); + Menu menu = menuManager.createContextMenu(tree); + tree.setMenu(menu); + } + + public class SetDefaultSelectedAction extends Action { + public SetDefaultSelectedAction() { + setText("Ĭֵ"); +// ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.UNLOCK_IMAGE); +// this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪýڵ!", "INFO", MessageBox.WARNING); + return; + } + + TCComponent selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + if (!selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyValueNodeName)) { + MessageBox.post("ѡбֵ!", "INFO", MessageBox.WARNING); + return; + } + HashMap hashMap = new HashMap(); + if (selectedComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "true"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + createView.treeViewer.refresh(selectedTreeData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public class CancelDefaultSelectedAction extends Action { + public CancelDefaultSelectedAction() { + setText("ȡĬֵ"); +// ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.UNLOCK_IMAGE); +// this.setImageDescriptor(imageDesc); + } + + public void run() { + try { + if ((selectedTreeData == null) || (selectedTreeData.getPackCodeNodeInfo().getNodeComponent() == null)) { + MessageBox.post("ѡҪýڵ!", "INFO", MessageBox.WARNING); + return; + } + + TCComponent selectedComponent = selectedTreeData.getPackCodeNodeInfo().getNodeComponent(); + if (!selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyValueNodeName)) { + MessageBox.post("ѡбֵ!", "INFO", MessageBox.WARNING); + return; + } + + HashMap hashMap = new HashMap(); + if (selectedComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected, "false"); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date, ""); + hashMap.put(AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user, session.getUser().getUid()); + TCComponent updateComponent = new TreeAndListCodeOperation().updateTreeORListNode(selectedComponent, hashMap); + PackCodeNodeInfo packCodeNodeInfo = treeAndListCodeOperation.getTreeAndListStringValue(updateComponent, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + selectedTreeData.setPackCodeNodeInfo(packCodeNodeInfo); + createView.treeViewer.refresh(selectedTreeData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private class NewCodeNodeAction extends Action { + public NewCodeNodeAction() { + setText("½"); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.LISTNODE_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + AbstractTreeData rootNode = treeViewOperation.getSelectedTreeNode(codeSegmentView.getCreateView().treeViewer); + if (rootNode == null) { + MessageBox.post("ѡҪ޸Ľڵ!", "INFO", MessageBox.WARNING); + return; + } + String type = rootNode.getPackCodeNodeInfo().getNode_type(); + if (!type.equals(AutoCodeManagerPropertyName.ListName)) { + MessageBox.post("ѡҪ޸бڵ!", "INFO", MessageBox.WARNING); + return; + } + new NewListPropertyNodeDialog(treeViewer.getControl().getShell(), (CreateListCodeView) createView, "½", false).open(); + } + } + + private class NewCodeNodeValueAction extends Action { + public NewCodeNodeValueAction() { + setText("½ֵ"); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.LISTVALUE_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + AbstractTreeData rootNode = treeViewOperation.getSelectedTreeNode(createView.treeViewer); + if (rootNode == null) { + MessageBox.post("ѡҪ޸Ľڵ!", "INFO", MessageBox.WARNING); + return; + } + new NewListPropertyValueNodeDialog(treeViewer.getControl().getShell(), (CreateListCodeView) createView, "½ֵ", false).open(); + } + } +} diff --git a/src/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.java b/src/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.java new file mode 100644 index 0000000..80b83cc --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/listcodeview/CreateListCodeView.java @@ -0,0 +1,82 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views.listcodeview; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.treetable.AbstractTreeTable; + +public class CreateListCodeView extends AbstractTreeTable { + public CreateListCodeView(Composite composite, String rootName, ViewPart viewPart) { + super(composite, rootName, viewPart); + + } + + public CreateListCodeView() { + + } + + public void addRightKeyAction() { + tree.addMouseListener(new MouseAdapter() { + public void mouseDown(MouseEvent e) { + if (e.button == 3) { + CodeListViewRightKeyAction rightAction = new CodeListViewRightKeyAction(CreateListCodeView.this); + rightAction.fillContextMenu(); + } + } + }); + } + + public void createTree(Composite parent, String rootName) { + Composite composite = parent; + treeViewer = new TreeViewer(composite, SWT.BORDER); + tree = treeViewer.getTree(); + initTree(rootName); + + treeViewer.expandToLevel(1); + tree.addTreeListener(new TreeListener() { + public void treeCollapsed(TreeEvent treeEvent) { + } + public void treeExpanded(TreeEvent treeEvent) { + AbstractTreeData codeData = (AbstractTreeData) treeEvent.item.getData(); + if (codeData == null) { + return; + } + try { + expandNode(codeData); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AbstractTreeData selectedData = (AbstractTreeData) e.item.getData(); + if (selectedData == null) { + return; + } + if (selectedData.getParentTreeData() == null) { + expandNode(selectedData); + } + } + }); + } + + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) throws Exception { + super.createOrgAutoCodeNodeChildren(codeDatas); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.java b/src/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.java new file mode 100644 index 0000000..deb3ecf --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/listcodeview/NewItemListCodeView.java @@ -0,0 +1,456 @@ +/** + * @author tyl + * @Action ini + * 2011-4-13 + */ +package cn.com.origin.autocodemanager.views.listcodeview; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class NewItemListCodeView extends CreateListCodeView { + + public Label[] propertyLabel; + public Combo[] propertyComb; + boolean isSetName = true; + private String icoName = ""; + public String codeName = ""; + public StringBuffer pattern = new StringBuffer(); + public StringBuffer codeDesc = new StringBuffer(); + private Map icoPropertyMap; + private String splitString = "<---->"; + + public NewItemListCodeView(Composite composite, String rootName, ViewPart viewPart) { + super(composite, rootName, viewPart); + } + + public void createTree(Composite parent, String rootName) { + Composite composite = parent; + treeViewer = new TreeViewer(composite, SWT.BORDER); + tree = treeViewer.getTree(); + initTree(rootName); + treeViewer.expandToLevel(1); + tree.addTreeListener(new TreeListener() { + public void treeCollapsed(TreeEvent treeEvent) { + } + + public void treeExpanded(TreeEvent treeEvent) { + AbstractTreeData codeData = (AbstractTreeData) treeEvent.item.getData(); + if (codeData == null) { + return; + } + if (codeData.getPackCodeNodeInfo().is_lock) { + codeData.setTreeAutoCodeNodeChildren(null); + return; + } + expandNode(codeData); + } + }); + + tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AbstractTreeData selectedData = (AbstractTreeData) e.item.getData(); + if (selectedData == null) { + return; + } + if (selectedData.getParentTreeData() == null) { + expandNode(selectedData); + } + } + }); + } + + public void getListPropertyValue(AbstractTreeData segmentNode) { + initPropertyValue(); + try { + if ((segmentNode != null) && (segmentNode.getPackCodeNodeInfo().getNodeComponent() != null)) { + String firstNodeName = segmentNode.getPackCodeNodeInfo().getNode_name(); + String firstNodeValue = segmentNode.getPackCodeNodeInfo().getNode_value(); + if (firstNodeValue.trim().length() > 0) { + codeDesc.append(firstNodeValue + "::" + firstNodeName); + codeDesc.append("\n"); + pattern.append(firstNodeValue); + pattern.append(" "); + } + } + if (propertyComb != null && propertyComb.length > 0) { + for (int i = 0; i < propertyComb.length; i++) { + if (propertyComb[i] == null) { + continue; + } + if (propertyComb[i].getText().length() == 0) { + return; + } + String codeListValue = propertyComb[i].getText(); + String name = propertyLabel[i].getText().trim(); + codeName = name.substring(0, name.length() - 1).toString(); + if (codeListValue != null && !"".equals(codeListValue)) { + if (codeListValue.contains(splitString)) { + String temp[] = codeListValue.split(splitString); + if (temp.length > 0) { + icoPropertyMap.put(codeName.trim(), temp[1].trim()); + codeDesc.append(replaceSpecialValue(temp[0].trim()) + "::" + temp[1].trim()); + codeDesc.append("\n"); + pattern.append(replaceSpecialValue(temp[0].trim())); + pattern.append(" "); + } + } else { + icoPropertyMap.put(codeName.trim(), codeListValue); + codeDesc.append(replaceSpecialValue(codeListValue) + "::" + "д"); + codeDesc.append("\n"); + pattern.append(replaceSpecialValue(codeListValue)); + pattern.append(" "); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String replaceSpecialValue(String value) { + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + String dateStr = formatter.format(date); + // System.out.println("dateStr:::::" + dateStr); + String temps[] = dateStr.split("-"); + if (value.contains(AutoCodeManagerPropertyName.Code_year4)) { + value = value.replace(AutoCodeManagerPropertyName.Code_year4, temps[0]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_year2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_year2, temps[0].substring(2)); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_mouth1)) { + value = value.replace(AutoCodeManagerPropertyName.Code_mouth1, temps[1]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_mouth2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_mouth2, temps[1]); + value = value + " "; + } + + if (value.contains(AutoCodeManagerPropertyName.Code_date1)) { + value = value.replace(AutoCodeManagerPropertyName.Code_date1, temps[2]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_date2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_date2, temps[2]); + value = value + " "; + } + return value; + } + + /** + * @return the icoPropertyMap + */ + public Map getIcoPropertyMap() { + return icoPropertyMap; + } + + /** + * @param icoPropertyMap + * the icoPropertyMap to set + */ + public void setIcoPropertyMap(Map icoPropertyMap) { + this.icoPropertyMap = icoPropertyMap; + } + + private void initPropertyValue() { + icoName = ""; + codeName = ""; + icoPropertyMap = new HashMap(); + pattern = new StringBuffer(); + codeDesc = new StringBuffer(); + } + + public String getFirstComboName() { + String value = ""; + if (isSetName) { + if (propertyComb != null && propertyComb.length > 0) { + for (int i = 0; i < propertyComb.length; i++) { + if (propertyComb[i] == null) { + continue; + } + String codeListValue = propertyComb[i].getText(); + if (codeListValue != null && !"".equals(codeListValue)) { + if (codeListValue.contains(splitString)) { + String temp[] = codeListValue.split(splitString); + if (temp.length > 0) { + // value = temp[0].trim(); + value = temp[1].trim(); + } + } else { + value = ""; + } + } + break; + } + } + } + return value; + } + + public void createCombox(Composite composite, AbstractTreeData segmentTreeData) { + try { + TCComponent segmentComponent = segmentTreeData.getPackCodeNodeInfo().getNodeComponent(); + composite.setLayout(new GridLayout(2, false)); + initPropertyValue(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + HashMap hashMap11 = new HashMap(); + String parentStr11 = ""; + parentStr11 = treeAndListCodeOperation.getParentStr(segmentTreeData, parentStr11); + if (segmentTreeData.getPackCodeNodeInfo().getNodeComponent() != null) { + hashMap11.put(AutoCodeManagerPropertyName.CodeRelation_current_node, segmentComponent.getUid()); + hashMap11.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr11); + } else { + hashMap11.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, ""); + hashMap11.put(AutoCodeManagerPropertyName.CodeRelation_current_node, ""); + } + String parentStr12 = ""; + if (segmentComponent != null) { + if (parentStr11.trim().length() == 0) { + parentStr12 = segmentComponent.getUid(); + } else { + parentStr12 = parentStr11 + "," + segmentComponent.getUid(); + } + } else { + parentStr12 = parentStr11; + } + List packCodeNodeInfos = treeAndListCodeOperation.searchTreeORListNodeInfos(hashMap11, parentStr12, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + if ((packCodeNodeInfos == null) || (packCodeNodeInfos.size() == 0)) { + return; + } + + propertyLabel = new Label[packCodeNodeInfos.size()]; + propertyComb = new Combo[packCodeNodeInfos.size()]; + for (int i = 0; i < packCodeNodeInfos.size(); i++) { + if (packCodeNodeInfos.get(i).getNodeComponent() == null) { + continue; + } + PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(i); + GridData gridDataLabel = new GridData(); + gridDataLabel.horizontalSpan = 1; + GridData gridDataLabeCombo = new GridData(); + gridDataLabeCombo.horizontalSpan = 1; + + String labelText = packCodeNodeInfo.getNode_name(); + propertyLabel[i] = new Label(composite, SWT.NONE); + propertyLabel[i].setText(labelText + ":"); + propertyLabel[i].setLayoutData(gridDataLabel); + if (packCodeNodeInfo.is_lock) { + propertyComb[i].setItems(new String[] { "<---->" }); + continue; + } + HashMap hashMap21 = new HashMap(); + String parentStr21 = ""; + String parentStr22 = ""; + parentStr21 = treeAndListCodeOperation.getParentStr(segmentTreeData, parentStr21); + if (parentStr21.trim().length() > 0) { + parentStr21 = parentStr21 + "," + segmentComponent.getUid(); + } else { + parentStr21 = segmentComponent.getUid(); + } + hashMap21.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr21); + hashMap21.put(AutoCodeManagerPropertyName.CodeRelation_current_node, packCodeNodeInfo.getNodeComponent().getUid()); + + List packCodeNodeInfos2 = treeAndListCodeOperation.searchTreeORListNodeInfos(hashMap21, parentStr22, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + if ((packCodeNodeInfos2 != null) && (packCodeNodeInfos2.size() > 0)) { + propertyComb[i] = new Combo(composite, SWT.NONE | SWT.READ_ONLY); + propertyComb[i].setLayoutData(gridDataLabeCombo); + String items[] = new String[packCodeNodeInfos2.size()]; + String selectValue = ""; + for (int k = 0; k < packCodeNodeInfos2.size(); k++) { + PackCodeNodeInfo packCodeNodeInfo2 = packCodeNodeInfos2.get(k); + if (packCodeNodeInfo2.is_lock) { + items[k] = "<---->"; + continue; + } + String key = packCodeNodeInfo2.getNode_name(); + String value = packCodeNodeInfo2.getNode_value(); + items[k] = value + "<---->" + key; + boolean isSelected = packCodeNodeInfo2.isDefaultSelected; + if (isSelected) { + selectValue = items[k]; + } + } + propertyComb[i].setItems(items); + if (selectValue.length() > 0) { + propertyComb[i].setText(selectValue); + } + int itemCount = propertyComb[i].getItemCount(); + if (itemCount < 15) { + propertyComb[i].setVisibleItemCount(itemCount); + } else { + propertyComb[i].setVisibleItemCount(15); + } + } else { + if (isSetName) { + isSetName = false; + } + propertyComb[i] = new Combo(composite, SWT.NONE); + propertyComb[i].setLayoutData(gridDataLabeCombo); + } + composite.redraw(); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + composite.redraw(); + } + + /** + * @return the propertyLabel + */ + public Label[] getPropertyLabel() { + return propertyLabel; + } + + /** + * @param propertyLabel + * the propertyLabel to set + */ + public void setPropertyLabel(Label[] propertyLabel) { + this.propertyLabel = propertyLabel; + } + + /** + * @return the propertyComb + */ + public Combo[] getPropertyComb() { + return propertyComb; + } + + /** + * @param propertyComb + * the propertyComb to set + */ + public void setPropertyComb(Combo[] propertyComb) { + this.propertyComb = propertyComb; + } + + /** + * + */ + public NewItemListCodeView() { + // TODO Auto-generated constructor stub + } + + /** + * @return the newSeq + */ + // public String getNewSeq() { + // return newSeq; + // } + // + // /** + // * @param newSeq + // * the newSeq to set + // */ + // public void setNewSeq(String newSeq) { + // this.newSeq = newSeq; + // } + /** + * @return the icoName + */ + public String getIcoName() { + return icoName; + } + + /** + * @param icoName + * the icoName to set + */ + public void setIcoName(String icoName) { + this.icoName = icoName; + } + + /** + * @return the codeStyle + */ + // public String getCodeStyle() { + // return codeStyle; + // } + // + // /** + // * @param codeStyle + // * the codeStyle to set + // */ + // public void setCodeStyle(String codeStyle) { + // this.codeStyle = codeStyle; + // } + /** + * @return the pattern + */ + public StringBuffer getPattern() { + return pattern; + } + + /** + * @param pattern + * the pattern to set + */ + public void setPattern(StringBuffer pattern) { + this.pattern = pattern; + } + + /** + * @return the codeDesc + */ + public StringBuffer getCodeDesc() { + return codeDesc; + } + + /** + * @param codeDesc + * the codeDesc to set + */ + public void setCodeDesc(StringBuffer codeDesc) { + this.codeDesc = codeDesc; + } + + /** + * @return the codeName + */ + public String getCodeName() { + return codeName; + } + + /** + * @param codeName + * the codeName to set + */ + public void setCodeName(String codeName) { + this.codeName = codeName; + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.java b/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.java new file mode 100644 index 0000000..6793a1c --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyNodeDialog.java @@ -0,0 +1,67 @@ +package cn.com.origin.autocodemanager.views.listcodeview; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; + +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.dialog.AbstractCodeDialog; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +public class NewListPropertyNodeDialog extends AbstractCodeDialog { + + public NewListPropertyNodeDialog(Shell parentShell, CreateListCodeView codeListViewTree, String title, boolean isEdit) { + super(parentShell, codeListViewTree, title, isEdit); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + Group nodeGroup = createCompositeGroup(container, "б"); + createNodeComposite(nodeGroup); + return container; + } + + public void initNewCodeComposite(Composite composite) { + createNewLabel(composite, ""); + nodeNameText = createNewText(composite, ""); + + createNewLabel(composite, "ע"); + nodeDescriptionText = createNewText(composite, ""); + + } + + // ڵǷΪF + @Override + protected void okPressed() { + String nodename = nodeNameText.getText().trim(); + if (nodename == null || nodename.trim().length() == 0) { + postMesssageBox("ƲΪգ"); + nodeNameText.setFocus(); + return; + } + AbstractTreeData rootData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + saveNewCodeNode(rootData, selectedComponent, createView.treeViewer, AutoCodeManagerPropertyName.ListPropertyNodeName, false); + close(); + } + + // öԻʼС + // @Override + protected Point getInitialSize() { + return new Point(250, 220); + } + + // öԻ򴰿ڱͼ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.LISTNODE_IMAGE)); + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.java b/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.java new file mode 100644 index 0000000..3c70550 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/listcodeview/NewListPropertyValueNodeDialog.java @@ -0,0 +1,79 @@ +package cn.com.origin.autocodemanager.views.listcodeview; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.dialog.AbstractCodeDialog; + +public class NewListPropertyValueNodeDialog extends AbstractCodeDialog { + + public NewListPropertyValueNodeDialog(Shell parentShell, CreateListCodeView codeListViewTree, String title, boolean isEdit) { + super(parentShell, codeListViewTree, title, isEdit); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + Group nodeGroup = createCompositeGroup(container, "бֵ"); + createNodeComposite(nodeGroup); + return container; + } + + public void initNewCodeComposite(Composite composite) { + createNewLabel(composite, ""); + nodeNameText = createNewText(composite, ""); + + createNewLabel(composite, "ֵ"); + nodeValueText = createNewText(composite, ""); + + createNewLabel(composite, "ע"); + nodeDescriptionText = createNewText(composite, ""); + } + + // ڵǷΪ + @Override + protected void okPressed() { + String nodename = nodeNameText.getText().trim(); + String nodevalue = nodeValueText.getText().trim(); + if (nodename == null || nodename.trim().length() == 0) { + postMesssageBox("ƲΪգ"); + nodeNameText.setFocus(); + return; + } + if (nodevalue == null || nodevalue.trim().length() == 0) { + postMesssageBox("ֵΪգ"); + nodeValueText.setFocus(); + return; + } + if (selectedTreeData == null) { + postMesssageBox("ѡԣ"); + } else { + if (selectedTreeData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListPropertyValueNodeName)) { + saveNewCodeNode(selectedTreeData.getParentTreeData(), selectedComponent, createView.treeViewer, AutoCodeManagerPropertyName.ListPropertyValueNodeName, false); + } else { + saveNewCodeNode(selectedTreeData, selectedComponent, createView.treeViewer, AutoCodeManagerPropertyName.ListPropertyValueNodeName, false); + } + } + close(); + } + + // öԻʼС + @Override + protected Point getInitialSize() { + return new Point(250, 230); + } + + // öԻ򴰿ڱͼ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.LISTVALUE_IMAGE)); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.java b/src/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.java new file mode 100644 index 0000000..ae4b392 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/testview/CreateCodeTestView.java @@ -0,0 +1,704 @@ +/** + * @author tyl + * @Action ini + * 2011-3-17 + */ +package cn.com.origin.autocodemanager.views.testview; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.CreateCompositeUtil; +import cn.com.origin.autocodemanager.common.TCPreferenceUitl; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.codeview.NewCodeTestView; +import cn.com.origin.autocodemanager.views.listcodeview.NewItemListCodeView; +import cn.com.origin.autocodemanager.views.treecodeview.NewItemTreeCodeView; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +public class CreateCodeTestView { + private SashForm sashFormCodeView; + private CTabItem codeTreeCTab; + private CTabItem codeListCTab; + private Composite compositCodeTree; + private Composite compositCodeList; + private CTabFolder ctabFolder; + private Text idLengthText; + private Text DescText; + private Text idText; + private Text revText; + private Text nameText; + private Combo unitCombo; + private NewCodeTestView classificationView; + private NewItemListCodeView listView; + private NewItemTreeCodeView treeView; + private TreeViewer classificationTreeViewer; + private TreeViewOperation treeViewOperation; + public TreeAndListCodeOperation treeAndListCodeOperation; + private TCSession session; + private TCComponentItemType tccomponentitemtype; + private AbstractTreeData selectedSegmentNode = null; + private TCComponent selectedSegmentTCComponent = null; + private String pattern = ""; + private String codeDesc = ""; + private String codeStyle = ""; + private String newSeq = ""; + private int codeLength; + private String firstListICOName = ""; + private Map segmentItemType; + private String origin_isCodePatternCanEditTypes = "origin_isCodePatternCanEditTypes"; + private String origin_showUnit_excludeTypes = "origin_showUnit_excludeTypes"; + private String origin_isItemNameTextDefaultNull = "origin_isItemNameTextDefaultNull"; + private SashForm itemInfoComposite; + private SashForm sashFormClassfication; + + public Text getIdLengthText() { + return idLengthText; + } + + public void setIdLengthText(Text idLengthText) { + this.idLengthText = idLengthText; + } + + public Combo getUnitCombo() { + return unitCombo; + } + + public void setUnitCombo(Combo unitCombo) { + this.unitCombo = unitCombo; + } + + public Text getDescText() { + return DescText; + } + + public void setDescText(Text descText) { + DescText = descText; + } + + public Text getIdText() { + return idText; + } + + public void setIdText(Text idText) { + this.idText = idText; + } + + public Text getRevText() { + return revText; + } + + public void setRevText(Text revText) { + this.revText = revText; + } + + public Text getNameText() { + return nameText; + } + + public void setNameText(Text nameText) { + this.nameText = nameText; + } + + public CreateCodeTestView(Composite composite, String rootName, ViewPart viewPart) { + treeViewOperation = new TreeViewOperation(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + try { + tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + createDialogArea(composite); + } + + protected Control createDialogArea(Composite parent) { + Composite container = parent; + FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL); + container.setLayout(fillLayout); + sashFormClassfication = new SashForm(container, SWT.NONE); + // SashForm sashFormClassfication = new SashForm(container, SWT.BORDER | SWT.H_SCROLL); + // sashFormClassfication.setOrientation(SWT.HORIZONTAL); + classificationView = new NewCodeTestView(sashFormClassfication, ""); + + classificationTreeViewer = classificationView.treeViewer; + addMouseAction(); + sashFormCodeView = new SashForm(container, SWT.NONE); + GridData gridData9 = new GridData(); + gridData9.heightHint = 70; + gridData9.horizontalAlignment = GridData.FILL; + gridData9.verticalAlignment = GridData.CENTER; + gridData9.grabExcessHorizontalSpace = true; + + ctabFolder = new CTabFolder(sashFormCodeView, SWT.BORDER); + ctabFolder.setBorderVisible(true); + ctabFolder.setSimple(false); + ctabFolder.setLayoutData(gridData9); + + codeTreeCTab = new CTabItem(ctabFolder, SWT.NONE); + codeTreeCTab.setText(""); + compositCodeTree = new Composite(ctabFolder, SWT.NONE); + compositCodeTree.setBackground(new Color(Display.getCurrent(), 255, 255, 255)); + + compositCodeTree.setLayout(new FillLayout()); + codeTreeCTab.setControl(compositCodeTree); + treeView = new NewItemTreeCodeView(compositCodeTree, "root"); + + codeListCTab = new CTabItem(ctabFolder, SWT.NONE); + codeListCTab.setText("б"); + ctabFolder.setSelection(0); + compositCodeList = new Composite(ctabFolder, SWT.NONE); + compositCodeList.setLayout(new FillLayout()); + codeListCTab.setControl(compositCodeList); + + listView = new NewItemListCodeView(); + ctabFolder.setSelection(1); + + itemInfoComposite = new SashForm(container, SWT.NONE); + createNewItemInfo(itemInfoComposite); + return container; + } + + private void createNewItemInfo(Composite parent) { + Composite composite = new Composite(parent, SWT.BORDER); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + composite.setLayout(gridLayout); + CreateCompositeUtil.createNewLabel(composite, ""); + idText = CreateCompositeUtil.createNewText(composite, ""); + + CreateCompositeUtil.createNewLabel(composite, "볤"); + idLengthText = CreateCompositeUtil.createNewText(composite, ""); + + CreateCompositeUtil.createNewLabel(composite, "ϰ汾"); + revText = CreateCompositeUtil.createNewText(composite, ""); + + CreateCompositeUtil.createNewLabel(composite, ""); + nameText = CreateCompositeUtil.createNewText(composite, ""); + CreateCompositeUtil.createNewLabel(composite, ""); + DescText = CreateCompositeUtil.createTextArea(composite, "", 90, 300); + idText.setEnabled(false); + idLengthText.setEnabled(false); + revText.setEnabled(false); + DescText.setEnabled(false); + } + + private TCComponent[] getParentGroupNode(AbstractTreeData segmentNode) { + TCComponent[] tccomponents = null; + classificationTreeViewer.refresh(); + if (segmentNode == null) { + return null; + } + if ((segmentNode.getPackCodeNodeInfo().getNodeComponent() != null) && (segmentNode.getPackCodeNodeInfo().is_root)) { + } else { + return null; + } + getRealItemType(segmentNode, segmentNode.getParentTreeData()); + return tccomponents; + } + + private void getRealItemType(AbstractTreeData segmentNode, AbstractTreeData parentNode) { + if ((parentNode != null) && (parentNode.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ItemName))) { + String realItemType = parentNode.getPackCodeNodeInfo().getRealTypeName().trim(); + if (!segmentItemType.containsKey(segmentNode)) { + segmentItemType.put(segmentNode, realItemType); + } + } else { + if (parentNode != null) { + parentNode = parentNode.getParentTreeData(); + getRealItemType(segmentNode, parentNode); + } + } + } + + public void setTreeNodes(AbstractTreeData segmentNode) { + try { + classificationTreeViewer.refresh(); + if (segmentNode == null) { + return; + } + getRealItemType(segmentNode, segmentNode.getParentTreeData()); + TCComponent autoCodeDataComponent = segmentNode.getPackCodeNodeInfo().getNodeComponent(); + TreeAndListCodeOperation treeAndListCodeOperation = new TreeAndListCodeOperation(); + HashMap hashMap = new HashMap(); + + String parentStr = ""; + parentStr = treeAndListCodeOperation.getParentStr(segmentNode, parentStr); + if (autoCodeDataComponent != null) { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, autoCodeDataComponent.getUid()); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr); + } else { + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, ""); + hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, ""); + } + String parentStr2 = ""; + if (autoCodeDataComponent != null) { + if (parentStr.trim().length() == 0) { + parentStr2 = autoCodeDataComponent.getUid(); + } else { + parentStr2 = parentStr + "," + autoCodeDataComponent.getUid(); + } + } else { + parentStr2 = parentStr; + } + List packCodeNodeInfos = treeAndListCodeOperation.searchTreeORListNodeInfos(hashMap, parentStr2, AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames); + if (packCodeNodeInfos != null && packCodeNodeInfos.size() > 0) { + AbstractTreeData autoCodeDataTCComs[] = new AbstractTreeData[packCodeNodeInfos.size()]; + for (int k = 0; k < packCodeNodeInfos.size(); k++) { + if (packCodeNodeInfos.get(k).getNodeComponent() == null) { + continue; + } + PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(k); + autoCodeDataTCComs[k] = new AbstractTreeData(segmentNode, packCodeNodeInfo); + if (packCodeNodeInfo.isContainsChildren()) { + autoCodeDataTCComs[k].setTreeAutoCodeNodeChildren(new AbstractTreeData[] { new AbstractTreeData() }); + } + } + treeView.treeViewer.setInput(autoCodeDataTCComs); + treeView.treeViewer.refresh(); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void addMouseAction() { + classificationTreeViewer.getTree().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + try { + initClassificationMouseClick(); + selectedSegmentNode = treeViewOperation.getSelectedTreeNode(classificationTreeViewer); + if (selectedSegmentNode == null) { + return; + } + selectedSegmentTCComponent = selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent(); + if (selectedSegmentTCComponent == null) { + return; + } + if (selectedSegmentTCComponent.getLogicalProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock)) { + ScrolledComposite scrolledComposite = new ScrolledComposite(ctabFolder, SWT.H_SCROLL | SWT.V_SCROLL); + codeListCTab.setControl(scrolledComposite); + treeView.treeViewer.setInput(null); + return; + } + if ((selectedSegmentNode.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.TreeName)) || (selectedSegmentNode.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListName))) { + String realType = selectedSegmentNode.getPackCodeNodeInfo().getRealTypeName(); + if (TCPreferenceUitl.isSelectExsitToTCPreferenceValues(session, origin_showUnit_excludeTypes, realType)) { + unitCombo.setEnabled(false); + } + } + if (selectedSegmentNode.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.TreeName)) { + classificationView.treeViewer.refresh(); + listView.setPropertyComb(null); + treeView.treeViewer.setInput(null); + Composite compositTemp = new Composite(ctabFolder, SWT.NONE); + codeListCTab.setControl(compositTemp); + setTreeNodes(treeViewOperation.getSelectedTreeNode(classificationView.treeViewer)); + ctabFolder.setSelection(0); + ctabFolder.redraw(); + + treeView.treeViewer.getTree().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + initTreeOrListMouseClick(); + AbstractTreeData selectedData = treeViewOperation.getSelectedTreeNode(treeView.treeViewer); + if (selectedData == null) { + return; + } + if (selectedData.getPackCodeNodeInfo().getNodeComponent() == null) { + return; + } + if ((selectedData.getPackCodeNodeInfo().is_lock)) { + return; + } + String currentNodeDesc = ""; + String currentNodeValue = ""; + String name = ""; + // õϢ + getCodeInfo(selectedData); + name = selectedData.getPackCodeNodeInfo().getNode_name(); + currentNodeValue = replaceSpecialValue(selectedData.getPackCodeNodeInfo().node_value); + if (currentNodeValue.length() > 0) { + currentNodeDesc = currentNodeValue + "::" + selectedData.getPackCodeNodeInfo().getNode_name(); + } + if (currentNodeValue.trim().length() > 0) { + pattern = pattern + " " + currentNodeValue + " "; + } + if (currentNodeDesc.trim().length() > 0) { + codeDesc = codeDesc + currentNodeDesc; + } + if (!TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_isItemNameTextDefaultNull)) { + nameText.setText(name); + } else { + nameText.setText(""); + } + getFinalPattern(selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent()); + getSequenceNo(pattern, selectedData.getPackCodeNodeInfo().getNodeComponent()); + idText.setText(getID(codeStyle)); + setIDPatternTextIsCanEdit(); + idLengthText.setText(String.valueOf(idText.getText().replace(" ", "").trim().length())); + DescText.setText(codeDesc); + } + }); + } else if (selectedSegmentNode.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ListName)) { + treeView.treeViewer.setInput(null); + ctabFolder.setLayout(new FillLayout()); + ScrolledComposite scrolledComposite = new ScrolledComposite(ctabFolder, SWT.H_SCROLL | SWT.V_SCROLL); + Composite compositTemp = new Composite(scrolledComposite, SWT.NONE); + compositTemp.setLayout(new FillLayout()); + scrolledComposite.setContent(compositTemp); + getParentGroupNode(selectedSegmentNode); + + listView.createCombox(compositTemp, selectedSegmentNode); + codeListCTab.setControl(scrolledComposite); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setMinWidth(250); + scrolledComposite.setMinHeight(1000); + ctabFolder.setSelection(1); + ctabFolder.redraw(); + + Combo[] coms = listView.getPropertyComb(); + if (coms == null) { + return; + } + for (int i = 0; i < coms.length; i++) { + if (coms[i] == null) { + continue; + } + int comboStyle = coms[i].getStyle(); + if (comboStyle == 33554692) { + coms[i].addFocusListener(new FocusListener() { + public void focusGained(FocusEvent event) { + } + + public void focusLost(FocusEvent event) { + initTreeOrListMouseClick(); + try { + firstListICOName = listView.getFirstComboName(); + listView.getListPropertyValue(selectedSegmentNode); + codeDesc = listView.getCodeDesc().toString(); + pattern = listView.getPattern().toString(); + revText.setText(tccomponentitemtype.getNewRev(null)); + + if (!TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_isItemNameTextDefaultNull)) { + nameText.setText(firstListICOName); + } else { + nameText.setText(""); + } + getFinalPattern(selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent()); + getSequenceNo(pattern, selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent()); + idText.setText(getID(codeStyle)); + setIDPatternTextIsCanEdit(); + idLengthText.setText(String.valueOf(idText.getText().replace(" ", "").trim().length())); + DescText.setText(codeDesc); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + } else { + coms[i].addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent selectionevent) { + initTreeOrListMouseClick(); + try { + firstListICOName = listView.getFirstComboName(); + listView.getListPropertyValue(selectedSegmentNode); + codeDesc = listView.getCodeDesc().toString(); + pattern = listView.getPattern().toString(); + revText.setText(tccomponentitemtype.getNewRev(null)); + + if (!TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_isItemNameTextDefaultNull)) { + nameText.setText(firstListICOName); + } else { + nameText.setText(""); + } + getFinalPattern(selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent()); + getSequenceNo(pattern, selectedSegmentNode.getPackCodeNodeInfo().getNodeComponent()); + idText.setText(getID(codeStyle)); + setIDPatternTextIsCanEdit(); + idLengthText.setText(String.valueOf(idText.getText().replace(" ", "").trim().length())); + DescText.setText(codeDesc); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + } + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + } + + private void setIDPatternTextIsCanEdit() { + String realItemType = "Item"; + if (segmentItemType != null) { + realItemType = (String) segmentItemType.get(selectedSegmentNode); + } + if (TCPreferenceUitl.isSelectExsitToTCPreferenceValues(session, origin_isCodePatternCanEditTypes, realItemType)) { + idText.setEnabled(true); + } + } + + public String replaceSpecialValue(String value) { + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + String dateStr = formatter.format(date); + String temps[] = dateStr.split("-"); + if (value.contains(AutoCodeManagerPropertyName.Code_year4)) { + value = value.replace(AutoCodeManagerPropertyName.Code_year4, temps[0]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_year2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_year2, temps[0].substring(2)); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_mouth1)) { + value = value.replace(AutoCodeManagerPropertyName.Code_mouth1, temps[1]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_mouth2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_mouth2, temps[1]); + value = value + " "; + } + + if (value.contains(AutoCodeManagerPropertyName.Code_date1)) { + value = value.replace(AutoCodeManagerPropertyName.Code_date1, temps[2]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_date2)) { + value = value.replace(AutoCodeManagerPropertyName.Code_date2, temps[2]); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_seq)) { + value = value.replace(AutoCodeManagerPropertyName.Code_seq, newSeq); + value = value + " "; + } + if (value.contains(AutoCodeManagerPropertyName.Code_pattern)) { + value = value.replace(AutoCodeManagerPropertyName.Code_pattern, pattern); + value = value + " "; + } + return value; + } + + public void getCodeInfo(AbstractTreeData treeData) { + if (treeData != null) { + AbstractTreeData parentData = treeData.getParentTreeData(); + if ((parentData != null) && (parentData.getPackCodeNodeInfo().getNodeComponent() != null)) { + getCodeInfo(parentData); + String nodeValue = ""; + String nodeName = ""; + if (!parentData.getPackCodeNodeInfo().getNode_type().equals(AutoCodeManagerPropertyName.ItemName)) { + nodeValue = replaceSpecialValue(parentData.getPackCodeNodeInfo().getNode_value()); + nodeName = parentData.getPackCodeNodeInfo().getNode_name(); + } + if (nodeValue.trim().length() > 0) { + pattern = pattern + nodeValue; + pattern = pattern + " "; + codeDesc = codeDesc + nodeValue; + codeDesc = codeDesc + "::"; + codeDesc = codeDesc + nodeName; + codeDesc = codeDesc + "\n"; + } + } + } + } + + private void initTreeOrListMouseClick() { + try { + if (treeViewOperation.getSelectedTreeNode(classificationTreeViewer) == null) { + return; + } + pattern = ""; + codeDesc = ""; + newSeq = ""; + DescText.setText(""); + idText.setText(""); + if (unitCombo != null) { + unitCombo.setText(""); + } + idText.setEnabled(false); + revText.setText(tccomponentitemtype.getNewRev(null)); + idLengthText.setText(""); + nameText.setText(""); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void initClassificationMouseClick() { + try { + if (treeViewOperation.getSelectedTreeNode(classificationTreeViewer) == null) { + return; + } + pattern = ""; + codeDesc = ""; + pattern = ""; + newSeq = ""; + DescText.setText(""); + idText.setText(""); + if (unitCombo != null) { + unitCombo.setText(""); + } + idText.setEnabled(false); + idLengthText.setText(""); + revText.setText(tccomponentitemtype.getNewRev(null)); + nameText.setText(""); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public String getParentCodeData(AbstractTreeData treeData, String str) { + if (treeData != null) { + AbstractTreeData parentData = treeData.getParentTreeData(); + if ((parentData != null) && (parentData.getPackCodeNodeInfo().getNodeComponent() != null)) { + str = getParentCodeData(parentData, str); + String nodeValue = parentData.getPackCodeNodeInfo().getNode_value(); + if (nodeValue.trim().length() > 0) { + str = str + nodeValue; + str = str + " "; + } + } + } + return str; + } + + public String getParentDescData(AbstractTreeData treeData, String str) { + if (treeData != null) { + AbstractTreeData parentData = treeData.getParentTreeData(); + if ((parentData != null) && (parentData.getPackCodeNodeInfo().getNodeComponent() != null)) { + str = getParentDescData(parentData, str); + String nodeValue = parentData.getPackCodeNodeInfo().getNode_value(); + String nodeDesc = parentData.getPackCodeNodeInfo().getNode_name(); + if (nodeValue.trim().length() > 0) { + str = str + nodeValue; + str = str + "::"; + str = str + nodeDesc; + str = str + "\n"; + } + } + } + return str; + } + + public String getID(String value) { + String id = replaceSpecialValue(value); +// return id.replace(" ", "").trim(); + return id; + } + + private String getFinalPattern(TCComponent seqComponent) { + newSeq = ""; + int codeSeqLength = 0; + try { + if (seqComponent != null) { + String[] propNames = { AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length }; + String[] propValues = seqComponent.getProperties(propNames); + codeStyle = propValues[0]; + codeLength = Integer.valueOf(propValues[1]); + codeSeqLength = Integer.valueOf(propValues[2]); + } + } catch (TCException e) { + e.printStackTrace(); + } + String finalPattern = replaceSpecialValue(codeStyle); + int coverNum = codeLength - finalPattern.replace(" ", "").trim().length() - codeSeqLength; + String coverStr = ""; + if (coverNum > 0) { + for (int i = 0; i < coverNum; i++) { + coverStr = coverStr + "0"; + } + if (coverStr.trim().length() > 0) { + pattern = pattern + coverStr + " "; + } + } + return pattern; + } + + private String getSequenceNo(String codeCounterName, TCComponent selectedComponent) { + try { + codeCounterName = codeCounterName.replace(" ", "").trim(); + TCComponent seqComponent = selectedComponent.getReferenceProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node); + if (seqComponent != null) { + String[] propNames = { AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style, AutoCodeManagerPropertyName.TreeAndListCodeNode_code_length, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_begin_value, AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_length, + AutoCodeManagerPropertyName.TreeAndListCodeNode_seq_max_value }; + String[] propValues = seqComponent.getProperties(propNames); + codeStyle = propValues[0]; + codeLength = Integer.valueOf(propValues[1]); + int startValue = Integer.valueOf(propValues[2]); + int codeSeqLength = Integer.valueOf(propValues[3]); + int endValue = Integer.valueOf(propValues[4]); + int increaseStep = 1; + String excludeStr = ""; + int seqValue = startValue + increaseStep; + if (seqValue > endValue) { + seqValue = startValue; + } + String seqStr = String.valueOf(seqValue); + if (excludeStr.length() > 0) { + int exclude = Integer.valueOf(excludeStr); + + if (seqStr.contains(excludeStr)) { + seqStr.replace(excludeStr, String.valueOf(exclude++)); + } + } + int length1 = seqStr.length(); + if (codeSeqLength > 0) { + if (length1 > codeSeqLength) { + newSeq = seqStr.substring(0, codeSeqLength - 1); + } else { + newSeq = seqStr; + for (int i = 0; i < (codeSeqLength - length1); i++) { + newSeq = "0" + newSeq; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + return newSeq; + } + return newSeq; + } +} diff --git a/src/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.java b/src/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.java new file mode 100644 index 0000000..517e1ab --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/treecodeview/CodeTreeViewRightKeyAction.java @@ -0,0 +1,87 @@ +/** + * @author tyl + * @Action ini + * 2011-3-17 + */ +package cn.com.origin.autocodemanager.views.treecodeview; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeViewRightKeyAction; +import com.teamcenter.rac.util.MessageBox; + +public class CodeTreeViewRightKeyAction extends AbstractTreeViewRightKeyAction { + + /** + * @param treeViewer + */ + public CodeTreeViewRightKeyAction(CreateTreeCodeView createTreeCodeView) { + super(createTreeCodeView); + } + + public void fillContextMenu() { + if (menuManager == null) { + // һεø÷ʱ + menuManager = new MenuManager(); + menuManager.add(new NewCodeNodeAction(AutoCodeManagerPropertyName.AddTreeNodeName)); + menuManager.add(new NewCodeNodeAction(AutoCodeManagerPropertyName.AddChildrenTreeNodeName)); + menuManager.add(new AddChildrenNodeAction("ӽڵ", AutoCodeManagerPropertyName.TreeNodeName)); + menuManager.add(new EidtCodeNodeAction()); + menuManager.add(new RemoveCodeNodeAction()); + menuManager.add(new LockCodeNodeAction()); + menuManager.add(new UnLockCodeNodeAction()); + } + Tree tree = treeViewer.getTree(); + Menu menu = menuManager.createContextMenu(tree); + tree.setMenu(menu); + } + + public class NewCodeNodeAction extends Action { + private String actionType; + private String title; + + public NewCodeNodeAction(String type) { + this.actionType = type; + if (type.equals(AutoCodeManagerPropertyName.AddChildrenTreeNodeName)) { + title = "½ڵ"; + } else { + title = "½ƽڵ"; + } + setText(title); + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.TREENODE_IMAGE); + this.setImageDescriptor(imageDesc); + } + + public void run() { + AbstractTreeData rootNode = treeViewOperation.getSelectedTreeNode(codeSegmentView.getCreateView().treeViewer); + if (rootNode == null) { + MessageBox.post("ѡҪ޸Ĺ!", "INFO", MessageBox.WARNING); + return; + } + String type = rootNode.getPackCodeNodeInfo().getNode_type(); + if (!type.equals(AutoCodeManagerPropertyName.TreeName)) { + MessageBox.post("ѡҪ޸ ı!", "INFO", MessageBox.WARNING); + return; + } + if (type.equals(AutoCodeManagerPropertyName.AddChildrenTreeNodeName)) { + setText("½ڵ"); + } else { + setText("½ƽڵ"); + } + if (actionType.equals(AutoCodeManagerPropertyName.AddChildrenTreeNodeName)) { + new NewTreeCodeNodeDialog(treeViewer.getControl().getShell(), (CreateTreeCodeView) createView, title, false, true).open(); + } else { + new NewTreeCodeNodeDialog(treeViewer.getControl().getShell(), (CreateTreeCodeView) createView, title, false, false).open(); + } + } + } + +} diff --git a/src/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.java b/src/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.java new file mode 100644 index 0000000..60c2f07 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/treecodeview/CreateTreeCodeView.java @@ -0,0 +1,38 @@ +/** + * @author tyl + * @Action ini + * 2011-3-21 + */ +package cn.com.origin.autocodemanager.views.treecodeview; + +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.treetable.AbstractTreeTable; + +public class CreateTreeCodeView extends AbstractTreeTable { + boolean isNewItem = false; + public CreateTreeCodeView(Composite composite, String rootName, ViewPart viewPart) { + super(composite, rootName, viewPart); + } + public CreateTreeCodeView(Composite composite, String rootName) { + super(composite, rootName); + isNewItem = true; + } + public void addRightKeyAction() { + tree.addMouseListener(new MouseAdapter() { + public void mouseDown(MouseEvent e) { + if (e.button == 3) { + CodeTreeViewRightKeyAction rightAction = new CodeTreeViewRightKeyAction(CreateTreeCodeView.this); + rightAction.fillContextMenu(); + } + } + }); + } + + public void createOrgAutoCodeNodeChildren(AbstractTreeData[] codeDatas) throws Exception { + super.createOrgAutoCodeNodeChildren(codeDatas); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.java b/src/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.java new file mode 100644 index 0000000..7073a87 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/treecodeview/NewItemTreeCodeView.java @@ -0,0 +1,84 @@ +/** + * @author tyl + * @Action ini + * 2011-4-13 + */ +package cn.com.origin.autocodemanager.views.treecodeview; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.treetable.ORNewItemTreeTableLabelProvider; +import cn.com.origin.autocodemanager.common.treetable.ORTreeTableContentProvider; +import com.teamcenter.rac.kernel.TCComponent; + +public class NewItemTreeCodeView extends CreateTreeCodeView { + + public NewItemTreeCodeView(Composite composite, String rootName, ViewPart viewPart) { + super(composite, rootName, viewPart); + } + + public NewItemTreeCodeView(Composite composite, String rootName) { + super(composite, rootName); + } + + public void initTree(String rootName) { + tree.setHeaderVisible(true); // ñͷɼ + tree.setLinesVisible(true); // ߿ɼ + tree.setFocus(); // ý + treeViewer.setLabelProvider(new ORNewItemTreeTableLabelProvider()); + treeViewer.setContentProvider(new ORTreeTableContentProvider()); + createTreeColumn(); + } + + public void createTreeColumn() { + createColumn(tree, "", 250); + createColumn(tree, "ֵ", 100); + createColumn(tree, "ע", 50); + } + + public void createTree(Composite parent, String rootName) { + Composite composite = parent; + treeViewer = new TreeViewer(composite, SWT.BORDER); + tree = treeViewer.getTree(); + initTree(rootName); + treeViewer.expandToLevel(1); + tree.addTreeListener(new TreeListener() { + public void treeCollapsed(TreeEvent treeEvent) { + } + public void treeExpanded(TreeEvent treeEvent) { + AbstractTreeData codeData = (AbstractTreeData) treeEvent.item.getData(); + if (codeData == null) { + return; + } + TCComponent component = codeData.getPackCodeNodeInfo().getNodeComponent(); + if ((component != null) && (codeData.getPackCodeNodeInfo().is_lock)) { + codeData.setTreeAutoCodeNodeChildren(null); + codeData.setChildrenLoader(false); + return; + } else { + expandNode(codeData); + } + } + }); + + tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AbstractTreeData selectedData = (AbstractTreeData) e.item.getData(); + if (selectedData == null) { + return; + } + if (selectedData.getParentTreeData() == null) { + expandNode(selectedData); + } + } + }); + } +} diff --git a/src/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.java b/src/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.java new file mode 100644 index 0000000..40d8906 --- /dev/null +++ b/src/cn/com/origin/autocodemanager/views/treecodeview/NewTreeCodeNodeDialog.java @@ -0,0 +1,80 @@ +package cn.com.origin.autocodemanager.views.treecodeview; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import cn.com.origin.autocodemanager.common.AutoCodeManagerImageKey; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.AutoCodeManangerConstants; +import cn.com.origin.autocodemanager.common.CacheImage; +import cn.com.origin.autocodemanager.common.dialog.AbstractCodeDialog; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; + +public class NewTreeCodeNodeDialog extends AbstractCodeDialog { + boolean isNewChildren = false; + + public NewTreeCodeNodeDialog(Shell parentShell, CreateTreeCodeView codeTreeView, String title, boolean isEdit, boolean isNewChildren) { + super(parentShell, codeTreeView, title, isEdit); + this.isNewChildren = isNewChildren; + + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + Group nodeGroup = createCompositeGroup(container, ""); + createNodeComposite(nodeGroup); + return container; + } + + public void initNewCodeComposite(Composite composite) { + createNewLabel(composite, "ڵ"); + nodeNameText = createNewText(composite, ""); + + createNewLabel(composite, "ֵ"); + nodeValueText = createNewText(composite, ""); + + createNewLabel(composite, "ע"); + nodeDescriptionText = createNewText(composite, ""); + } + + // ڵǷΪ + @Override + protected void okPressed() { + String nodename = nodeNameText.getText().trim(); + if (nodename == null || nodename.trim().length() == 0) { + postMesssageBox("ڵƲΪգ"); + nodeNameText.setFocus(); + return; + } + if (selectedTreeData == null) { + AbstractTreeData rootData = treeViewOperation.getSelectedTreeNode(codeSegmentView.createView.treeViewer); + saveNewCodeNode(rootData, selectedComponent, codeTreeView.createView.treeViewer, AutoCodeManagerPropertyName.TreeNodeName, false); + } else { + if (isNewChildren) { + saveNewCodeNode(selectedTreeData, selectedComponent, createView.treeViewer, AutoCodeManagerPropertyName.TreeNodeName, false); + } else { + saveNewCodeNode(selectedTreeData.getParentTreeData(), selectedComponent, createView.treeViewer, AutoCodeManagerPropertyName.TreeNodeName, false); + } + } + close(); + } + + // öԻʼС + @Override + protected Point getInitialSize() { + return new Point(250, 230); + } + + // öԻ򴰿ڱͼ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setImage(CacheImage.getINSTANCE().getImage(AutoCodeManangerConstants.AutoCodeMananger_APPLICATION_ID, AutoCodeManagerImageKey.TREENODE_IMAGE)); + + } + +} diff --git a/src/icons/add.png b/src/icons/add.png new file mode 100644 index 0000000..bc58bd7 Binary files /dev/null and b/src/icons/add.png differ diff --git a/src/icons/addgroup_16.png b/src/icons/addgroup_16.png new file mode 100644 index 0000000..71b9d47 Binary files /dev/null and b/src/icons/addgroup_16.png differ diff --git a/src/icons/addnode_16.png b/src/icons/addnode_16.png new file mode 100644 index 0000000..d84fdfd Binary files /dev/null and b/src/icons/addnode_16.png differ diff --git a/src/icons/adduser_16.png b/src/icons/adduser_16.png new file mode 100644 index 0000000..b184734 Binary files /dev/null and b/src/icons/adduser_16.png differ diff --git a/src/icons/addvalue_16.png b/src/icons/addvalue_16.png new file mode 100644 index 0000000..3cf9bd3 Binary files /dev/null and b/src/icons/addvalue_16.png differ diff --git a/src/icons/autocode_16.png b/src/icons/autocode_16.png new file mode 100644 index 0000000..44938f5 Binary files /dev/null and b/src/icons/autocode_16.png differ diff --git a/src/icons/autocode_24.png b/src/icons/autocode_24.png new file mode 100644 index 0000000..2ac939f Binary files /dev/null and b/src/icons/autocode_24.png differ diff --git a/src/icons/autocode_32.png b/src/icons/autocode_32.png new file mode 100644 index 0000000..528106c Binary files /dev/null and b/src/icons/autocode_32.png differ diff --git a/src/icons/classficationcode_16.png b/src/icons/classficationcode_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/src/icons/classficationcode_16.png differ diff --git a/src/icons/close_16.png b/src/icons/close_16.png new file mode 100644 index 0000000..9935027 Binary files /dev/null and b/src/icons/close_16.png differ diff --git a/src/icons/code2_16.png b/src/icons/code2_16.png new file mode 100644 index 0000000..242a122 Binary files /dev/null and b/src/icons/code2_16.png differ diff --git a/src/icons/code_16.png b/src/icons/code_16.png new file mode 100644 index 0000000..c1757aa Binary files /dev/null and b/src/icons/code_16.png differ diff --git a/src/icons/codenode_16.png b/src/icons/codenode_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/src/icons/codenode_16.png differ diff --git a/src/icons/delete_16.png b/src/icons/delete_16.png new file mode 100644 index 0000000..dc602bc Binary files /dev/null and b/src/icons/delete_16.png differ diff --git a/src/icons/down_16.png b/src/icons/down_16.png new file mode 100644 index 0000000..35ef44f Binary files /dev/null and b/src/icons/down_16.png differ diff --git a/src/icons/edit_16.png b/src/icons/edit_16.png new file mode 100644 index 0000000..d133306 Binary files /dev/null and b/src/icons/edit_16.png differ diff --git a/src/icons/exceltemplate_16.png b/src/icons/exceltemplate_16.png new file mode 100644 index 0000000..d0f4a26 Binary files /dev/null and b/src/icons/exceltemplate_16.png differ diff --git a/src/icons/exceltemplate_32.png b/src/icons/exceltemplate_32.png new file mode 100644 index 0000000..f961043 Binary files /dev/null and b/src/icons/exceltemplate_32.png differ diff --git a/src/icons/export_16.png b/src/icons/export_16.png new file mode 100644 index 0000000..baa7c0f Binary files /dev/null and b/src/icons/export_16.png differ diff --git a/src/icons/exporttoexcel_16.png b/src/icons/exporttoexcel_16.png new file mode 100644 index 0000000..9cc4cd1 Binary files /dev/null and b/src/icons/exporttoexcel_16.png differ diff --git a/src/icons/exporttoexcel_24.png b/src/icons/exporttoexcel_24.png new file mode 100644 index 0000000..4ec0c15 Binary files /dev/null and b/src/icons/exporttoexcel_24.png differ diff --git a/src/icons/folder_16.png b/src/icons/folder_16.png new file mode 100644 index 0000000..e7499ce Binary files /dev/null and b/src/icons/folder_16.png differ diff --git a/src/icons/grant_16.png b/src/icons/grant_16.png new file mode 100644 index 0000000..f7a63ad Binary files /dev/null and b/src/icons/grant_16.png differ diff --git a/src/icons/group_16.png b/src/icons/group_16.png new file mode 100644 index 0000000..71a4bfb Binary files /dev/null and b/src/icons/group_16.png differ diff --git a/src/icons/home_data.png b/src/icons/home_data.png new file mode 100644 index 0000000..2e436a7 Binary files /dev/null and b/src/icons/home_data.png differ diff --git a/src/icons/import_16.png b/src/icons/import_16.png new file mode 100644 index 0000000..e3213a6 Binary files /dev/null and b/src/icons/import_16.png differ diff --git a/src/icons/importhistory_16.png b/src/icons/importhistory_16.png new file mode 100644 index 0000000..57a85f8 Binary files /dev/null and b/src/icons/importhistory_16.png differ diff --git a/src/icons/item_16.png b/src/icons/item_16.png new file mode 100644 index 0000000..6ff9793 Binary files /dev/null and b/src/icons/item_16.png differ diff --git a/src/icons/linkageNode_16.png b/src/icons/linkageNode_16.png new file mode 100644 index 0000000..2bf5ddd Binary files /dev/null and b/src/icons/linkageNode_16.png differ diff --git a/src/icons/linkage_16.png b/src/icons/linkage_16.png new file mode 100644 index 0000000..3d6c823 Binary files /dev/null and b/src/icons/linkage_16.png differ diff --git a/src/icons/list_16.png b/src/icons/list_16.png new file mode 100644 index 0000000..8c83db0 Binary files /dev/null and b/src/icons/list_16.png differ diff --git a/src/icons/listproperty_16.png b/src/icons/listproperty_16.png new file mode 100644 index 0000000..eccc1f1 Binary files /dev/null and b/src/icons/listproperty_16.png differ diff --git a/src/icons/listvalue_16.png b/src/icons/listvalue_16.png new file mode 100644 index 0000000..ead21d5 Binary files /dev/null and b/src/icons/listvalue_16.png differ diff --git a/src/icons/lock_16.png b/src/icons/lock_16.png new file mode 100644 index 0000000..197232e Binary files /dev/null and b/src/icons/lock_16.png differ diff --git a/src/icons/newclassfication_16.png b/src/icons/newclassfication_16.png new file mode 100644 index 0000000..3c91d1c Binary files /dev/null and b/src/icons/newclassfication_16.png differ diff --git a/src/icons/newcodetreenode_16.png b/src/icons/newcodetreenode_16.png new file mode 100644 index 0000000..92353fc Binary files /dev/null and b/src/icons/newcodetreenode_16.png differ diff --git a/src/icons/newlistproperty_16.png b/src/icons/newlistproperty_16.png new file mode 100644 index 0000000..8c83db0 Binary files /dev/null and b/src/icons/newlistproperty_16.png differ diff --git a/src/icons/newlistvalue_16.png b/src/icons/newlistvalue_16.png new file mode 100644 index 0000000..3cd33d0 Binary files /dev/null and b/src/icons/newlistvalue_16.png differ diff --git a/src/icons/ok_16.png b/src/icons/ok_16.png new file mode 100644 index 0000000..380ce66 Binary files /dev/null and b/src/icons/ok_16.png differ diff --git a/src/icons/organization_16.png b/src/icons/organization_16.png new file mode 100644 index 0000000..88d3093 Binary files /dev/null and b/src/icons/organization_16.png differ diff --git a/src/icons/person_16.png b/src/icons/person_16.png new file mode 100644 index 0000000..fa412c8 Binary files /dev/null and b/src/icons/person_16.png differ diff --git a/src/icons/remove_16.png b/src/icons/remove_16.png new file mode 100644 index 0000000..4ff8845 Binary files /dev/null and b/src/icons/remove_16.png differ diff --git a/src/icons/role_16.png b/src/icons/role_16.png new file mode 100644 index 0000000..78c754d Binary files /dev/null and b/src/icons/role_16.png differ diff --git a/src/icons/seq_16.png b/src/icons/seq_16.png new file mode 100644 index 0000000..fad4c83 Binary files /dev/null and b/src/icons/seq_16.png differ diff --git a/src/icons/tree_16.png b/src/icons/tree_16.png new file mode 100644 index 0000000..6d82492 Binary files /dev/null and b/src/icons/tree_16.png differ diff --git a/src/icons/treenode_16.png b/src/icons/treenode_16.png new file mode 100644 index 0000000..822f6d0 Binary files /dev/null and b/src/icons/treenode_16.png differ diff --git a/src/icons/unlock_16.png b/src/icons/unlock_16.png new file mode 100644 index 0000000..fbf2acc Binary files /dev/null and b/src/icons/unlock_16.png differ diff --git a/src/icons/up_16.png b/src/icons/up_16.png new file mode 100644 index 0000000..96d82de Binary files /dev/null and b/src/icons/up_16.png differ