@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jacob.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jsqlparser-4.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@ -0,0 +1 @@
|
||||
/bin/
|
||||
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>cn.net.connor.std.processedit</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@ -0,0 +1,57 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Processedit
|
||||
Bundle-SymbolicName: cn.net.connor.std.processedit;singleton:=true
|
||||
Bundle-Version: 13000.1.0
|
||||
Bundle-Activator: cn.net.connor.std.processedit.Activator
|
||||
Eclipse-RegisterBuddy: cn.net.connor.std.aifrcp,cn.net.connor.std.fx
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
com.teamcenter.rac.util;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.tcapps;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.ui.views;bundle-version="13000.1.0",
|
||||
org.apache.poi.39,
|
||||
TcSoaCommon,
|
||||
TcSoaCoreRac,
|
||||
TcSoaCoreTypes,
|
||||
com.teamcenter.rac.cme.mpp;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.cme.activity;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.cme.time;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.cme.legacy;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.cme.bvr.connect;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.cme.framework,
|
||||
com.teamcenter.rac.classification.icm;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.classification.icadmin;bundle-version="13000.1.0",
|
||||
TcSoaStructureManagementRac;bundle-version="13000.1.0",
|
||||
TcSoaStructureManagementLoose;bundle-version="13000.1.0",
|
||||
TcSoaCoreLoose,
|
||||
com.teamcenter.rac.aifrcp;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.kernel;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.common;bundle-version="13000.1.0",
|
||||
cn.net.connor.std.aifrcp;bundle-version="13000.1.0",
|
||||
cn.net.connor.std.fx;bundle-version="13000.1.0",
|
||||
cn.net.connor.std.gdtex;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.commonclient;bundle-version="13000.1.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Automatic-Module-Name: cn.net.connor.std.processedit
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: cn.net.connor.std.processedit,
|
||||
cn.net.connor.std.processedit.choose,
|
||||
cn.net.connor.std.processedit.choosefromsql,
|
||||
cn.net.connor.std.processedit.commands,
|
||||
cn.net.connor.std.processedit.meopviewfx,
|
||||
cn.net.connor.std.processedit.meopviewfx.bean,
|
||||
cn.net.connor.std.processedit.meopviewfx.reorder,
|
||||
cn.net.connor.std.processedit.meopviewfx.ui,
|
||||
cn.net.connor.std.processedit.modifymeopno,
|
||||
cn.net.connor.std.processedit.newdatasetfromtemplate,
|
||||
cn.net.connor.std.processedit.newmeop,
|
||||
cn.net.connor.std.processedit.newmeprocess,
|
||||
cn.net.connor.std.processedit.processview,
|
||||
cn.net.connor.std.processedit.processview.safeicon,
|
||||
cn.net.connor.std.processedit.searchbysql,
|
||||
cn.net.connor.std.processedit.util,
|
||||
cn.net.connor.std.processedit.word
|
||||
Bundle-ClassPath: lib/jsqlparser-4.3.jar,
|
||||
.,
|
||||
lib/jacob.jar
|
||||
@ -0,0 +1,8 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
icons/,\
|
||||
lib/jsqlparser-4.3.jar,\
|
||||
lib/jacob.jar
|
||||
|
After Width: | Height: | Size: 456 B |
|
After Width: | Height: | Size: 942 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 727 B |
|
After Width: | Height: | Size: 474 B |
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 526 B |
|
After Width: | Height: | Size: 793 B |
|
After Width: | Height: | Size: 912 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,261 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension point="org.eclipse.ui.startup">
|
||||
<startup class="cn.net.connor.std.processedit.KStartup"/>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.views">
|
||||
<category id="cn.net.connor.std.processedit.view" name="工艺视图"/>
|
||||
<view
|
||||
category="cn.net.connor.std.processedit.view"
|
||||
closable="true"
|
||||
allowMultiple="false"
|
||||
icon="icons/meprocess_16.png"
|
||||
class="cn.net.connor.std.processedit.processview.ProcessPropertyView"
|
||||
id="cn.net.connor.std.processedit.processview.ProcessPropertyView"
|
||||
name="工艺工序编辑">
|
||||
</view>
|
||||
<view
|
||||
category="cn.net.connor.std.processedit.view"
|
||||
closable="true"
|
||||
allowMultiple="false"
|
||||
icon="icons/meoperation_16.png"
|
||||
class="cn.net.connor.std.processedit.meopviewfx.MEOPEditView"
|
||||
id="cn.net.connor.std.processedit.meopview.MEOPEditView"
|
||||
name="工步编辑">
|
||||
</view>
|
||||
</extension>
|
||||
<extension point="com.teamcenter.rac.aifrcp.viewDefs">
|
||||
<view
|
||||
alwaysUseSetRootInputObject="true"
|
||||
autoCloseEnabled="true"
|
||||
folderId="RAC_Folder_UR"
|
||||
id="cn.net.connor.std.processedit.processview.ProcessPropertyView"
|
||||
selectionInPrimaryEffectsInvisbleSecondary="false"
|
||||
selectionInSecondaryEffectsPrimary="false"
|
||||
type="secondary">
|
||||
</view>
|
||||
<view
|
||||
alwaysUseSetRootInputObject="true"
|
||||
autoCloseEnabled="true"
|
||||
folderId="RAC_Folder_UR"
|
||||
id="cn.net.connor.std.processedit.meopview.MEOPEditView"
|
||||
selectionInPrimaryEffectsInvisbleSecondary="false"
|
||||
selectionInSecondaryEffectsPrimary="false"
|
||||
type="secondary">
|
||||
</view>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.commands">
|
||||
<command name="创建工艺" id="cn.net.connor.std.processedit.commands.NewProcessCommand"/>
|
||||
<command name="创建工序" id="cn.net.connor.std.processedit.commands.NewMeopCommand"/>
|
||||
<command name="工艺工序编辑" id="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.processview.ProcessPropertyView"/>
|
||||
<command name="工步编辑" id="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.meopview.MEOPEditView"/>
|
||||
<command name="附件" id="cn.net.connor.std.processedit.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments"/>
|
||||
<command name="修改工序号" id="cn.net.connor.std.processedit.commands.ModifyMeopNoCommand"/>
|
||||
<command name="标准工序略图" id="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_BZGXLT"/>
|
||||
<command name="下料工序略图" id="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_XLGXLT"/>
|
||||
<command name="创建原材料BOM" id="cn.net.connor.std.processedit.commands.CreateBOMViewHandler"/>
|
||||
|
||||
<command name="工艺分工" id="ProcessDivisionHandler"/>
|
||||
<command name="工序分工" id="GXDivisionHandler"/>
|
||||
|
||||
|
||||
<command name="工艺复用" id="ProcessMultiplexHandler"/>
|
||||
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.handlers">
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.NewProcessCommand" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.NewMeopCommand" class="cn.net.connor.std.aifrcp.KHandler">
|
||||
<activeWhen>
|
||||
<and>
|
||||
<reference
|
||||
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
|
||||
</reference>
|
||||
</and>
|
||||
</activeWhen>
|
||||
</handler>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.processview.ProcessPropertyView" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.meopview.MEOPEditView" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.ModifyMeopNoCommand" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_BZGXLT" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_XLGXLT" class="cn.net.connor.std.aifrcp.KHandler"/>
|
||||
|
||||
|
||||
<handler commandId="ProcessDivisionHandler" class="cn.net.connor.std.processedit.ldy.ProcessDivisionHandler"/>
|
||||
<handler commandId="GXDivisionHandler" class="cn.net.connor.std.processedit.ldy.GXDivisionHandler"/>
|
||||
<handler commandId="ProcessMultiplexHandler" class="cn.net.connor.std.processedit.ldy.ProcessMultiplexHandler"/>
|
||||
<handler commandId="cn.net.connor.std.processedit.commands.CreateBOMViewHandler" class="cn.net.connor.std.processedit.commands.CreateBOMViewHandler"/>
|
||||
|
||||
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.menus">
|
||||
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
|
||||
<menu label="工艺管理" id="cn.net.connor.std.processedit.mainmenu">
|
||||
<separator name ="sp1" visible="false"/>
|
||||
<separator name ="sp2" visible="true"/>
|
||||
<separator name ="sp3" visible="true"/>
|
||||
<separator name ="sp4" visible="true"/>
|
||||
<separator name ="sp5" visible="true"/>
|
||||
<separator name ="sp6" visible="true"/>
|
||||
<separator name ="sp7" visible="true"/>
|
||||
<menu label="生成工艺卡" id="cn.net.connor.std.processedit.mainmenu.card"/>
|
||||
<!--menu label="DWG 工序略图" id="cn.net.connor.std.processedit.mainmenu.dwgdataset"/-->
|
||||
</menu>
|
||||
</menuContribution>
|
||||
<menuContribution locationURI="menu:cn.net.connor.std.processedit.mainmenu.dwgdataset?after=additions">
|
||||
<command commandId="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_BZGXLT" id="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_BZGXLT">
|
||||
<visibleWhen>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_BZGXLT">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_XLGXLT" id="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_XLGXLT">
|
||||
<visibleWhen>
|
||||
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.NewDatasetFromTemplateCommand#Connor_AVIC_XLGXLT">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
|
||||
<menuContribution locationURI="menu:cn.net.connor.std.processedit.mainmenu?after=sp6">
|
||||
|
||||
|
||||
<command commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.processview.ProcessPropertyView" id="cn.net.connor.std.processedit.mainmenu.gygxbj">
|
||||
<visibleWhen>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.processview.ProcessPropertyView">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
|
||||
<command commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.meopview.MEOPEditView" id="cn.net.connor.std.processedit.mainmenu.gdbj">
|
||||
<visibleWhen>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.OpenViewCommand#cn.net.connor.std.processedit.meopview.MEOPEditView">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
|
||||
<command commandId="ProcessDivisionHandler" id="ProcessDivisionHandler" mnemonic="S"/>
|
||||
<command commandId="GXDivisionHandler" id="GXDivisionHandler" mnemonic="S"/>
|
||||
<command commandId="ProcessMultiplexHandler" id="ProcessMultiplexHandler" mnemonic="S"/>
|
||||
<command commandId="cn.net.connor.std.processedit.commands.CreateBOMViewHandler" id="cn.net.connor.std.processedit.commands.CreateBOMViewHandler" mnemonic="S"/>
|
||||
</menuContribution>
|
||||
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
|
||||
<command commandId="cn.net.connor.std.processedit.commands.NewProcessCommand" icon="icons/meprocess_16.png" id="popups.newprocess">
|
||||
<visibleWhen>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.NewProcessCommand">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
|
||||
|
||||
<command commandId="cn.net.connor.std.processedit.commands.NewMeopCommand" icon="icons/meoperation_16.png" id="popups.newmeop">
|
||||
<visibleWhen>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or">
|
||||
<equals
|
||||
value="cn.net.connor.std.processedit.commands.NewMeopCommand">
|
||||
</equals>
|
||||
</iterate>
|
||||
</not>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
|
||||
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.bindings">
|
||||
<!--创建工艺-->
|
||||
<key
|
||||
commandId="cn.net.connor.std.processedit.commands.NewProcessCommand"
|
||||
sequence="M3+N"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key>
|
||||
<!--创建工序-->
|
||||
<key
|
||||
commandId="cn.net.connor.std.processedit.commands.NewMeopCommand"
|
||||
sequence="M3+C"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key>
|
||||
<!--修订工艺>
|
||||
<!key
|
||||
commandId="com.connor.nhjs.gy.revise.process.ReviseProcessHandler"
|
||||
sequence="M3+R"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key-->
|
||||
<!--工序简图>
|
||||
<key
|
||||
commandId="cn.net.connor.std.word.commands.MeopDatasetCommand"
|
||||
sequence="M3+J"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key-->
|
||||
<!--工艺合本>
|
||||
<key
|
||||
commandId="cn.net.connor.std.word.commands.MergePDFCommand"
|
||||
sequence="M3+H"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key-->
|
||||
<!--打开附件-->
|
||||
<key
|
||||
commandId="cn.net.connor.std.processedit.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments"
|
||||
sequence="M3+I"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key>
|
||||
<!--工艺借用-->
|
||||
<key
|
||||
commandId="ProcessBorrowHandler"
|
||||
sequence="M3+M"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key>
|
||||
<!--工序借用>
|
||||
<key
|
||||
commandId="MEOPBorrowHandler"
|
||||
sequence="M3+O"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key-->
|
||||
<!--创建变更>
|
||||
<key
|
||||
commandId="cn.com.create.change.CreateChangeHandler"
|
||||
sequence="M3+L"
|
||||
schemeId="com.teamcenter.rac.scheme">
|
||||
</key-->
|
||||
</extension>
|
||||
</plugin>
|
||||
@ -0,0 +1,44 @@
|
||||
package cn.net.connor.std.processedit;
|
||||
|
||||
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.net.connor.std.processedit"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.net.connor.std.processedit;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IStartup;
|
||||
|
||||
import javafx.embed.swt.FXCanvas;
|
||||
|
||||
public class KStartup implements IStartup {
|
||||
|
||||
@Override
|
||||
public void earlyStartup() {
|
||||
Display.getDefault().asyncExec(()->{
|
||||
try {
|
||||
Class<?> c = FXCanvas.class;
|
||||
Method m = c.getDeclaredMethod("initFx", new Class[0]);
|
||||
m.setAccessible(true);
|
||||
m.invoke(FXCanvas.class, new Object[0]);
|
||||
System.out.println("FXCanvas inited");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
package cn.net.connor.std.processedit.choose;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ChooseDialog extends KDialog {
|
||||
|
||||
private ChooseDialogController controller;
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private JButton b_search;
|
||||
private static final Registry REG = Registry.getRegistry(ChooseDialog.class);
|
||||
|
||||
public ChooseDialog(AbstractAIFDialog newMeopDialog, KDialogController controller) {
|
||||
super(newMeopDialog,true,controller);
|
||||
this.controller = (ChooseDialogController) controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
this.b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.doSelect();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ChooseDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_search.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.doSearch();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ChooseDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(REG.getString("select.TITLE"));
|
||||
this.setPreferredSize(new Dimension(900, 500));
|
||||
this.setMinimumSize(new Dimension(550, 400));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.CENTER, initTablePanel());
|
||||
this.add(BorderLayout.EAST, initSearchPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
|
||||
this.b_search = new JButton(REG.getString("search"));
|
||||
this.b_ok = new JButton(REG.getString("ok"));
|
||||
this.b_cel = new JButton(REG.getString("cancel"));
|
||||
if (controller.searchCols.size() > 0) {
|
||||
panel.add(b_search);
|
||||
}
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initSearchPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
if (controller.searchCols.size() == 0) {
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
return panel;
|
||||
}
|
||||
JPanel searchPanel = new JPanel(new GridBagLayout());
|
||||
searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(5, 5, 5, 5));
|
||||
for (String title : controller.searchCols) {
|
||||
KUtil.newRow(searchPanel, new JLabel(title), s, 1);
|
||||
JTextField textField = new JTextField(12);
|
||||
controller.searchComps.put(title, textField);
|
||||
KUtil.addCol(searchPanel, textField, s, 1, 1);
|
||||
textField.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||
b_search.doClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(searchPanel, new JLabel(""), s, 1);
|
||||
JScrollPane scroll = new JScrollPane(searchPanel);
|
||||
scroll.setBorder(null);
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
panel.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initTablePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 0));
|
||||
JScrollPane scroll = new JScrollPane(controller.tableBean.getTable());
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
if(!controller.isNHJSChooseSafeDesc) {
|
||||
controller.tableBean.getTable().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(e.getButton() == MouseEvent.BUTTON1 && e.getClickCount()==2) {
|
||||
b_ok.doClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,172 @@
|
||||
package cn.net.connor.std.processedit.choose;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.KExcelTable;
|
||||
import cn.net.connor.std.processedit.util.KExcelTable.Config;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
|
||||
public class ChooseDialogController extends KDialogController {
|
||||
|
||||
private String typeName;
|
||||
private String[] config;
|
||||
private List<PrefComponent> prefComponents;
|
||||
// private Map<String, JTextComponent> otherComps;
|
||||
private ChooseDialog dialog;
|
||||
protected File excelFile;
|
||||
protected List<Config> configs = new ArrayList<Config>();
|
||||
protected List<String> searchCols = new ArrayList<String>();
|
||||
protected Map<String, JTextField> searchComps = new HashMap<String, JTextField>();
|
||||
protected KExcelTable tableBean;
|
||||
protected boolean isNHJSChooseSafeDesc = false;
|
||||
private static final String PREFIX_NHJS_CHOOSE_SAFE_DESC = "#NHJS_SAFE_DESC#";
|
||||
private static final Registry REG = Registry.getRegistry(ChooseDialogController.class);
|
||||
|
||||
public ChooseDialogController(AbstractAIFApplication app, String type, PrefComponent bean, List<PrefComponent> prefComponents) {
|
||||
this.typeName = type;
|
||||
this.config = bean.getExcelConfig();
|
||||
this.prefComponents = prefComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (ChooseDialog) aifDialog;
|
||||
int len = KUtil.getLen(config);
|
||||
if (len == 0) {
|
||||
System.out.println("No Choose Config");
|
||||
throw new TCException(REG.getString("novalidchooseconfig.ERROR"));
|
||||
}
|
||||
String uid = config[0];
|
||||
this.isNHJSChooseSafeDesc = uid.startsWith(PREFIX_NHJS_CHOOSE_SAFE_DESC);
|
||||
if(this.isNHJSChooseSafeDesc) {
|
||||
uid = uid.substring(PREFIX_NHJS_CHOOSE_SAFE_DESC.length());
|
||||
}
|
||||
System.out.println(">> Uid: " + uid);
|
||||
if (!KUtil.isEmpty(typeName)) {
|
||||
int ind = uid.indexOf("" + typeName + ":");
|
||||
if (ind > 0) {
|
||||
uid = uid.substring(ind + typeName.length() + 1);
|
||||
}
|
||||
}
|
||||
int ind = uid.indexOf(';');
|
||||
if (ind > 0) {
|
||||
uid = uid.substring(0, ind);
|
||||
}
|
||||
System.out.println(">> Uid for type [" + typeName + "] is: " + uid);
|
||||
if (KUtil.isEmpty(uid)) {
|
||||
throw new TCException(REG.getString("novalidchooseconfig.ERROR"));
|
||||
}
|
||||
TCComponentDataset excelDataset = null;
|
||||
try {
|
||||
excelDataset = (TCComponentDataset) session.stringToComponent(uid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (excelDataset == null || !"MSExcelX".equals(excelDataset.getType())) {
|
||||
throw new TCException(REG.getString("novalidchooseconfig.ERROR"));
|
||||
}
|
||||
// Read Config
|
||||
for (int i = 1; i < len; i++) {
|
||||
String pref = config[i];
|
||||
String[] split = pref.split("=", -1);
|
||||
int splitCnt = KUtil.getLen(split);
|
||||
String tableCol = null, excelCol = null, propConfig = null;
|
||||
int prefW = 100;
|
||||
if (splitCnt > 0) {
|
||||
tableCol = split[0];
|
||||
}
|
||||
if (splitCnt > 1) {
|
||||
excelCol = split[1];
|
||||
}
|
||||
if (splitCnt > 2) {
|
||||
propConfig = split[2];
|
||||
}
|
||||
if (splitCnt > 3) {
|
||||
try {
|
||||
prefW = Integer.parseInt(split[3]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!KUtil.isEmpty(tableCol) && !KUtil.isEmpty(excelCol)) {
|
||||
if (tableCol.startsWith("#")) {
|
||||
tableCol = tableCol.substring(1);
|
||||
System.out.println(">> Add Search: " + tableCol);
|
||||
if (!this.searchCols.contains(tableCol)) {
|
||||
this.searchCols.add(tableCol);
|
||||
}
|
||||
}
|
||||
this.configs.add(new Config(tableCol, excelCol, propConfig, prefW));
|
||||
} else {
|
||||
System.out.println("ERROR Config: " + pref);
|
||||
}
|
||||
}
|
||||
this.excelFile = KUtil.getDatasetFile(excelDataset);
|
||||
if (this.excelFile == null || !this.excelFile.exists()) {
|
||||
throw new TCException(REG.getString("novalidchooseconfig.ERROR"));
|
||||
}
|
||||
this.tableBean = new KExcelTable(configs, excelFile.getAbsolutePath(), this.isNHJSChooseSafeDesc);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void doSearch() throws Exception {
|
||||
Map<String, String> searchInfo = new HashMap<String, String>();
|
||||
System.out.println("Perform Search..");
|
||||
for (String colName : this.searchComps.keySet()) {
|
||||
String value = this.searchComps.get(colName).getText();
|
||||
if (!KUtil.isEmpty(value)) {
|
||||
System.out.println(">> " + colName + " = " + value);
|
||||
searchInfo.put(colName, value);
|
||||
}
|
||||
}
|
||||
this.tableBean.performSearch(searchInfo);
|
||||
}
|
||||
|
||||
public void doSelect() throws Exception {
|
||||
LinkedHashMap<Config, String> data = this.tableBean.getSelectedData();
|
||||
if (data == null || data.size() <= 0) {
|
||||
System.out.println("No Select Info");
|
||||
dialog.disposeDialog();
|
||||
return;
|
||||
}
|
||||
System.out.println("Selected Row: " + Arrays.toString(data.values().toArray()));
|
||||
for (Config colConfig : data.keySet()) {
|
||||
String val = data.get(colConfig);
|
||||
String addition = colConfig.getAdditionalInfo();
|
||||
if (KUtil.isEmpty(addition)) {
|
||||
continue;
|
||||
}
|
||||
System.out.println(">> Set " + addition + " = " + val);
|
||||
for (PrefComponent comp : this.prefComponents) {
|
||||
if (addition.equals(comp.getPropConfig())) {
|
||||
System.out.println(comp.getValueComp());
|
||||
if (comp.getValueComp() instanceof JTextArea) {
|
||||
// 安全说明进行追加
|
||||
JTextArea textArea = (JTextArea) comp.getValueComp();
|
||||
textArea.setText(textArea.getText() + val);
|
||||
} else {
|
||||
comp.setValue(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dialog.disposeDialog();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
select.TITLE=\u9009\u62E9
|
||||
search=\u67E5\u8BE2
|
||||
ok=\u786E\u5B9A
|
||||
cancel=\u53D6\u6D88
|
||||
novalidchooseconfig.ERROR=\u6CA1\u6709\u627E\u5230\u6709\u6548\u914D\u7F6E
|
||||
@ -0,0 +1,158 @@
|
||||
package cn.net.connor.std.processedit.choosefromsql;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ChooseFromSqlDialog extends KDialog {
|
||||
|
||||
private ChooseFromSqlDialogController controller;
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private JButton b_search;
|
||||
protected String[] config;
|
||||
protected List<PrefComponent> prefComponents;
|
||||
protected Map<String, TCComponent> revChildren;
|
||||
private static final Registry REG = Registry.getRegistry(ChooseFromSqlDialog.class);
|
||||
|
||||
public ChooseFromSqlDialog(PrefComponent bean, List<PrefComponent> prefComponents, Map<String, TCComponent> revChildren) {
|
||||
super();
|
||||
this.config = bean.getSqlConfig();
|
||||
this.prefComponents = prefComponents;
|
||||
this.revChildren = revChildren;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
this.b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.doSelect();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ChooseFromSqlDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_search.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.doSearch();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ChooseFromSqlDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.controller = (ChooseFromSqlDialogController) aifController;
|
||||
this.setTitle(REG.getString("select.TITLE"));
|
||||
this.setPreferredSize(new Dimension(900, 500));
|
||||
this.setMinimumSize(new Dimension(550, 400));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.CENTER, initTablePanel());
|
||||
this.add(BorderLayout.WEST, initSearchPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
|
||||
this.b_search = new JButton(REG.getString("search"));
|
||||
this.b_ok = new JButton(REG.getString("ok"));
|
||||
this.b_cel = new JButton(REG.getString("cancel"));
|
||||
if (controller.searchCols_DB_UI.size() > 0) {
|
||||
panel.add(b_search);
|
||||
}
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initSearchPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
if (controller.searchCols_DB_UI.size() == 0) {
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
return panel;
|
||||
}
|
||||
JPanel searchPanel = new JPanel(new GridBagLayout());
|
||||
searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10));
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(0, 10, 10, 0));
|
||||
for (String dbColName : controller.searchCols_DB_UI.keySet()) {
|
||||
String title = controller.searchCols_DB_UI.get(dbColName);
|
||||
KUtil.newRow(searchPanel, new JLabel(title), s, 1);
|
||||
JTextField textField = new JTextField(12);
|
||||
controller.searchComps.put(dbColName, textField);
|
||||
KUtil.addCol(searchPanel, textField, s, 1, 1);
|
||||
textField.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||
b_search.doClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(searchPanel, new JLabel(""), s, 1);
|
||||
JScrollPane scroll = new JScrollPane(searchPanel);
|
||||
scroll.setBorder(null);
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
panel.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initTablePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10));
|
||||
JScrollPane scroll = new JScrollPane(controller.tableBean.getTable());
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
controller.tableBean.getTable().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||
b_ok.doClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,242 @@
|
||||
package cn.net.connor.std.processedit.choosefromsql;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KSqlUtil;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.KSqlTable;
|
||||
import cn.net.connor.std.processedit.util.KSqlTable.Config;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
import net.sf.jsqlparser.JSQLParserException;
|
||||
import net.sf.jsqlparser.expression.Alias;
|
||||
import net.sf.jsqlparser.parser.CCJSqlParserManager;
|
||||
import net.sf.jsqlparser.statement.Statement;
|
||||
import net.sf.jsqlparser.statement.select.AllTableColumns;
|
||||
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||
import net.sf.jsqlparser.statement.select.Select;
|
||||
import net.sf.jsqlparser.statement.select.SelectExpressionItem;
|
||||
import net.sf.jsqlparser.statement.select.SelectItem;
|
||||
|
||||
public class ChooseFromSqlDialogController extends KDialogController {
|
||||
|
||||
private String[] config;
|
||||
private List<PrefComponent> prefComponents;
|
||||
// private Map<String, JTextComponent> otherComps;
|
||||
private ChooseFromSqlDialog dialog;
|
||||
protected List<Config> configs = new ArrayList<Config>();
|
||||
protected Map<String, String> searchCols_DB_UI = new LinkedHashMap<>();
|
||||
protected Map<String, JTextField> searchComps = new HashMap<String, JTextField>();
|
||||
protected KSqlTable tableBean;
|
||||
private Map<String, TCComponent> revChildren;
|
||||
private TCComponentItemType itemType;
|
||||
private static final Registry REG = Registry.getRegistry(ChooseFromSqlDialogController.class);
|
||||
|
||||
public static void getTableNameBySql(String sql, List<String> headers, List<String> fields) throws JSQLParserException {
|
||||
try {
|
||||
CCJSqlParserManager pm = new CCJSqlParserManager();
|
||||
Statement statement = pm.parse(new StringReader(sql));
|
||||
if (statement instanceof Select) {
|
||||
Select selectStatement = (Select) statement;
|
||||
PlainSelect selectBody = (PlainSelect) selectStatement.getSelectBody();
|
||||
List<SelectItem> selectItemlist = selectBody.getSelectItems();
|
||||
SelectItem selectItem = null;
|
||||
SelectExpressionItem selectExpressionItem = null;
|
||||
AllTableColumns allTableColumns = null;
|
||||
Alias alias = null;
|
||||
if (selectItemlist != null) {
|
||||
for (int i = 0; i < selectItemlist.size(); i++) {
|
||||
selectItem = selectItemlist.get(i);
|
||||
if (selectItem instanceof SelectExpressionItem) {
|
||||
selectExpressionItem = (SelectExpressionItem) selectItemlist.get(i);
|
||||
alias = selectExpressionItem.getAlias();
|
||||
String columnName = "";
|
||||
if (alias != null) {
|
||||
columnName = alias.getName();
|
||||
} else {
|
||||
columnName = selectExpressionItem.getExpression().toString();
|
||||
}
|
||||
headers.add(columnName);
|
||||
fields.add(selectExpressionItem.getExpression().toString());
|
||||
} else if (selectItem instanceof AllTableColumns) {
|
||||
allTableColumns = (AllTableColumns) selectItemlist.get(i);
|
||||
headers.add(allTableColumns.toString());
|
||||
fields.add(allTableColumns.toString());
|
||||
} else {
|
||||
headers.add(selectItem.toString());
|
||||
fields.add(selectItem.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (JSQLParserException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (ChooseFromSqlDialog) aifDialog;
|
||||
this.config = dialog.config;
|
||||
this.prefComponents = dialog.prefComponents;
|
||||
this.revChildren = dialog.revChildren;
|
||||
int len = KUtil.getLen(config);
|
||||
if (len == 0) {
|
||||
System.out.println("No Choose Config");
|
||||
throw new TCException(REG.getString("novalidchooseconfig.ERROR"));
|
||||
}
|
||||
String sql = String.join("\n", config);
|
||||
System.out.println(">> sql: \n" + sql);
|
||||
List<String> headers = new ArrayList<>();
|
||||
List<String> fields = new ArrayList<>();
|
||||
getTableNameBySql(sql, headers, fields);
|
||||
System.out.println(">> headers: " + headers);
|
||||
System.out.println(">> fields: " + fields);
|
||||
len = headers == null ? 0 : headers.size();
|
||||
// Read Config
|
||||
for (int i = 0; i < len; i++) {
|
||||
String dbColName = headers.get(i);
|
||||
String dbFieldName = fields.get(i);
|
||||
String[] split = dbColName.replace("\"", "").split("=", -1);
|
||||
int splitCnt = KUtil.getLen(split);
|
||||
String tableCol = null, propConfig = null;
|
||||
int prefW = 100;
|
||||
if (splitCnt > 0) {
|
||||
tableCol = split[0];
|
||||
}
|
||||
if (splitCnt > 1) {
|
||||
propConfig = split[1];
|
||||
}
|
||||
if (splitCnt > 2) {
|
||||
try {
|
||||
prefW = Integer.parseInt(split[2]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!KUtil.isEmpty(tableCol)) {
|
||||
if (tableCol.startsWith("#")) {
|
||||
tableCol = tableCol.substring(1);
|
||||
System.out.println(">> Add Search: " + tableCol);
|
||||
if (!this.searchCols_DB_UI.containsKey(dbFieldName)) {
|
||||
this.searchCols_DB_UI.put(dbFieldName, tableCol);
|
||||
}
|
||||
}
|
||||
this.configs.add(new Config(tableCol, dbFieldName, propConfig, prefW));
|
||||
} else {
|
||||
System.out.println("ERROR Config: " + dbColName);
|
||||
}
|
||||
if (dbColName.startsWith("\"")) {
|
||||
sql = sql.replace(dbColName, "");
|
||||
}
|
||||
}
|
||||
System.out.println("Formated Sql: \n" + sql);
|
||||
this.tableBean = new KSqlTable(configs, sql);
|
||||
this.itemType = (TCComponentItemType) session.getTypeComponent("Item");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void doSearch() throws Exception {
|
||||
Map<String, String> searchInfo = new HashMap<String, String>();
|
||||
System.out.println("Perform Search..");
|
||||
for (String colName : this.searchComps.keySet()) {
|
||||
String value = this.searchComps.get(colName).getText();
|
||||
if (!KUtil.isEmpty(value)) {
|
||||
System.out.println(">> " + colName + " = " + value);
|
||||
searchInfo.put(colName, value);
|
||||
}
|
||||
}
|
||||
Connection conn = KSqlUtil.getOracleConnection(session, ProcessUtil.PREF_DB_CONN);
|
||||
try {
|
||||
this.tableBean.performSearch(searchInfo, conn);
|
||||
} finally {
|
||||
KSqlUtil.free(conn);
|
||||
}
|
||||
}
|
||||
|
||||
public void doSelect() throws Exception {
|
||||
revChildren.clear();
|
||||
LinkedHashMap<Config, String> data = this.tableBean.getSelectedData();
|
||||
if (data == null || data.size() <= 0) {
|
||||
System.out.println("No Select Info");
|
||||
dialog.disposeDialog();
|
||||
return;
|
||||
}
|
||||
System.out.println("Selected Row: " + Arrays.toString(data.values().toArray()));
|
||||
for (Config colConfig : data.keySet()) {
|
||||
String val = data.get(colConfig);
|
||||
String addition = colConfig.getAdditionalInfo();
|
||||
if (KUtil.isEmpty(addition)) {
|
||||
continue;
|
||||
}
|
||||
if ("UID".equalsIgnoreCase(colConfig.getColName())) {
|
||||
String relationName = addition;
|
||||
System.out.println(">> Add " + relationName + " = " + val);
|
||||
if (!KUtil.isEmpty(val)) {
|
||||
TCComponent comp = null;
|
||||
try {
|
||||
comp = session.stringToComponent(val);
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(">> Find component: " + comp);
|
||||
if (comp == null) {
|
||||
throw new TCException(REG.getString("loaduid.ERROR"));
|
||||
}
|
||||
revChildren.put(relationName, comp);
|
||||
}
|
||||
continue;
|
||||
} else if ("ID".equalsIgnoreCase(colConfig.getColName())) {
|
||||
String relationName = addition;
|
||||
System.out.println(">> Add " + relationName + " = " + val);
|
||||
if (!KUtil.isEmpty(val)) {
|
||||
TCComponent[] items = null;
|
||||
try {
|
||||
items = itemType.findItems(val);
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(">> Find item: " + Arrays.toString(items));
|
||||
int itemCnt = KUtil.getLen(items);
|
||||
TCComponentItemRevision rev = null;
|
||||
for (int i = 0; i < itemCnt; i++) {
|
||||
TCComponentItem item = (TCComponentItem) items[i];
|
||||
rev = item.getLatestItemRevision();
|
||||
}
|
||||
System.out.println(">> Revision: " + rev);
|
||||
if (rev == null) {
|
||||
throw new TCException(String.format(REG.getString("loadid.ERROR1"), val));
|
||||
}
|
||||
revChildren.put(relationName, rev);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
System.out.println(">> Set " + addition + " = " + val);
|
||||
for (PrefComponent comp : this.prefComponents) {
|
||||
if (addition.equals(comp.getPropConfig())) {
|
||||
comp.setValue(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
dialog.disposeDialog();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
select.TITLE=\u9009\u62E9
|
||||
search=\u67E5\u8BE2
|
||||
ok=\u786E\u5B9A
|
||||
cancel=\u53D6\u6D88
|
||||
novalidchooseconfig.ERROR=\u6CA1\u6709\u627E\u5230\u6709\u6548\u914D\u7F6E
|
||||
loaduid.ERROR=\u65E0\u6CD5\u52A0\u8F7D\u5BF9\u8C61\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u6709\u76F8\u5173\u6743\u9650\u3002
|
||||
loadid.ERROR1=\u672A\u627E\u5230\u5BF9\u8C61\u201C%s\u201D\u7684\u6700\u65B0\u7248\u672C
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
public class CreateBOMViewHandler extends AbstractHandler {
|
||||
|
||||
// @Override
|
||||
// public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
// // TODO Auto-generated method stub
|
||||
// AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
// TCSession session = (TCSession) app.getSession();
|
||||
// InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||
// if(targetComponent instanceof TCComponentBOMLine) {
|
||||
// TCComponentBOMLine bomLine = (TCComponentBOMLine)targetComponent;
|
||||
// try {
|
||||
// TCComponentItemRevision revision = (TCComponentItemRevision)bomLine.getRelatedComponent("bl_line_object");
|
||||
// TCComponent[] reference = revision.getReferenceListProperty("structure_revisions");
|
||||
// if(reference != null && reference.length > 0) {
|
||||
// MessageBox.post("该物料已有BOM,不能重复创建!",
|
||||
// "提示",MessageBox.INFORMATION);
|
||||
// return null;
|
||||
// }else {
|
||||
// KUtil.setByPassItk(session, true);
|
||||
// TCComponentItemType t = (TCComponentItemType) session.getTypeService().getTypeComponent("Item");
|
||||
// TCComponentItem item1 = t.findItems("000001")[0];
|
||||
// TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
// TCComponentBOMWindow window = bomWinType.create(null);
|
||||
// TCComponentBOMLine newBom = window.setWindowTopLine(null, revision, null, null);
|
||||
// TCComponentBOMLine newnewLine = newBom.add(item1, item1.getLatestItemRevision(), null, false);
|
||||
// window.save();
|
||||
// newnewLine.cut();
|
||||
// window.save();
|
||||
// window.close();
|
||||
// KUtil.setByPassItk(session, false);
|
||||
// MessageBox.post("创建成功!", "", MessageBox.INFORMATION);
|
||||
// }
|
||||
// } catch (TCException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }else {
|
||||
// MessageBox.post("请选择BOMLine对象!", "提示", MessageBox.INFORMATION);
|
||||
//
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
// TODO Auto-generated method stub
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||
if(targetComponent instanceof TCComponentBOMLine) {
|
||||
|
||||
TCComponentBOMLine bomLine = (TCComponentBOMLine)targetComponent;
|
||||
|
||||
G4MDialog classDialog = new G4MDialog("精雕分类", null, session,bomLine);
|
||||
new Thread(classDialog).start();
|
||||
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
MessageBox.post("请选择BOMLine对象!", "提示", MessageBox.INFORMATION);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,252 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.classification.common.AbstractG4MApplication;
|
||||
import com.teamcenter.rac.classification.common.G4MApplicationPanel;
|
||||
import com.teamcenter.rac.classification.common.G4MUserAppContext;
|
||||
import com.teamcenter.rac.classification.common.table.G4MTable;
|
||||
import com.teamcenter.rac.classification.icm.ICMApplication;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentICO;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class G4MDialog extends AbstractAIFDialog {
|
||||
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private ICMApplication app;
|
||||
private MyG4MContext m_context;
|
||||
protected TCComponentICO ico;
|
||||
private String expandClass;
|
||||
private List<TCComponentItemRevision> revList;
|
||||
private TCComponentBOMLine targeTcComponentBOMLine;
|
||||
InterfaceAIFComponent iaf;
|
||||
TCComponentForm form;
|
||||
TCSession session;
|
||||
// public G4MDialog(String expandClass, InterfaceAIFComponent iaf, QZjsbjdBean jsbjdBean, TCSession session, TCComponentForm form) {
|
||||
// super(AIFDesktop.getActiveDesktop(), true);
|
||||
// this.jsbjdBean=jsbjdBean;
|
||||
// this.expandClass = expandClass;
|
||||
// this.iaf = iaf;
|
||||
// this.session=session;
|
||||
// this.form=form;
|
||||
// try {
|
||||
// this.app = new ICMApplication();
|
||||
// this.m_context = new MyG4MContext(app, "k0");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// initUI();
|
||||
// }
|
||||
public G4MDialog(String expandClass, InterfaceAIFComponent iaf, TCSession session,TCComponentBOMLine targeTcComponentBOMLine) {
|
||||
super(AIFDesktop.getActiveDesktop(), true);
|
||||
this.expandClass = expandClass;
|
||||
this.iaf = iaf;
|
||||
this.session=session;
|
||||
this.targeTcComponentBOMLine = targeTcComponentBOMLine;
|
||||
try {
|
||||
this.app = new ICMApplication();
|
||||
this.m_context = new MyG4MContext(app, "k0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
initUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
showDialog();
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
this.setTitle("材料选取");
|
||||
this.setLayout(new BorderLayout());
|
||||
this.setPreferredSize(new Dimension(1000, 600));
|
||||
this.setMinimumSize(new Dimension(640, 480));
|
||||
MyG4MPanel panel = new MyG4MPanel(null);
|
||||
try {
|
||||
m_context.openComponent(iaf);
|
||||
panel.initialize(m_context);
|
||||
this.add(BorderLayout.CENTER, panel);
|
||||
m_context.getTree().expandToClass(expandClass);
|
||||
// new Thread(m_context.getClassificationDialog()).start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// panel.open(iaf);
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
addListeners();
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
G4MTable table = m_context.getTablePane().getG4MTable();
|
||||
List<?> list = null;
|
||||
if (table != null) {
|
||||
ISelection sel = table.getSelection();
|
||||
if (sel != null && sel instanceof StructuredSelection) {
|
||||
list = ((StructuredSelection) sel).toList();
|
||||
|
||||
}
|
||||
}
|
||||
if (list == null || list.size() == 0) {
|
||||
MessageBox.post("请选择要使用的对象", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "请选择要使用的对象");
|
||||
return;
|
||||
}
|
||||
if (list.size() > 1) {
|
||||
MessageBox.post("请选择单行数据", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "请选择单行数据");
|
||||
return;
|
||||
}
|
||||
Object target = list.get(0);
|
||||
revList = new ArrayList<TCComponentItemRevision>();
|
||||
if (target != null && target instanceof TCComponentICO) {
|
||||
ico = (TCComponentICO) target;
|
||||
System.out.println(" ico.getClassId()=====" + ico.getClassId());
|
||||
|
||||
TCComponent classifiedObject = ico.getClassifiedObject();
|
||||
TCComponentItemRevision rev = null;
|
||||
if(classifiedObject instanceof TCComponentItemRevision) {
|
||||
rev = (TCComponentItemRevision) classifiedObject;
|
||||
}else if(classifiedObject instanceof TCComponentItem) {
|
||||
TCComponentItem item = (TCComponentItem) classifiedObject;
|
||||
try {
|
||||
rev = item.getLatestItemRevision();
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
System.out.println("ico.id==="+ico.getId());
|
||||
|
||||
|
||||
System.out.println("rev==="+rev);
|
||||
revList.add(rev);
|
||||
|
||||
|
||||
if(revList != null && revList.size() > 0) {
|
||||
|
||||
try {
|
||||
TCComponentItemRevision revision = (TCComponentItemRevision)targeTcComponentBOMLine.getRelatedComponent("bl_line_object");
|
||||
KUtil.setByPassItk(session, true);
|
||||
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
TCComponentBOMWindow window = bomWinType.create(null);
|
||||
TCComponentBOMLine newBom = window.setWindowTopLine(null, revision, null, null);
|
||||
for (int i = 0; i < revList.size(); i++) {
|
||||
TCComponentItemRevision tcComponentItemRevision = revList.get(i);
|
||||
newBom.add(tcComponentItemRevision.getItem(), tcComponentItemRevision, null, false);
|
||||
}
|
||||
window.save();
|
||||
window.close();
|
||||
KUtil.setByPassItk(session, false);
|
||||
|
||||
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
MessageBox.post("请选择分类对象!", "提示", MessageBox.INFORMATION);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageBox.post("图纸引用成功!!!", "成功", MessageBox.INFORMATION);
|
||||
} else {
|
||||
MessageBox.post("选择的数据不是ICO对象", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "选择的数据不是ICO对象");
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private JPanel initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5));
|
||||
this.b_ok = new JButton("确定");
|
||||
this.b_cel = new JButton("取消");
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public class MyG4MContext extends G4MUserAppContext {
|
||||
|
||||
public MyG4MContext(AbstractAIFUIApplication paramAbstractAIFUIApplication, String paramString)
|
||||
throws Exception {
|
||||
super(paramAbstractAIFUIApplication, paramString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBusy(String paramString) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdle(String paramString) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MyG4MPanel extends G4MApplicationPanel {
|
||||
|
||||
public MyG4MPanel(AbstractG4MApplication paramAbstractG4MApplication) {
|
||||
super(paramAbstractG4MApplication);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeSignaled() {
|
||||
try {
|
||||
m_context.clear();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// m_context.openComponent(iaf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KCommand;
|
||||
import cn.net.connor.std.processedit.modifymeopno.ModifyMeopNoDialog;
|
||||
|
||||
public class ModifyMeopNoCommand extends KCommand{
|
||||
|
||||
public ModifyMeopNoCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
this.setRunnable(new ModifyMeopNoDialog());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KCommand;
|
||||
import cn.net.connor.std.processedit.newdatasetfromtemplate.NewDatasetFromTemplateOperation;
|
||||
|
||||
public class NewDatasetFromTemplateCommand extends KCommand{
|
||||
|
||||
public NewDatasetFromTemplateCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
this.setRunnable(new NewDatasetFromTemplateOperation(app, actionInfo));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KCommand;
|
||||
import cn.net.connor.std.processedit.newmeop.NewMeopDialog;
|
||||
import cn.net.connor.std.processedit.newmeop.NewMeopDialogController;
|
||||
|
||||
public class NewMeopCommand extends KCommand {
|
||||
|
||||
public NewMeopCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
System.out.println("NewMeopCommand");
|
||||
this.setRunnable(new NewMeopDialog(new NewMeopDialogController(app)));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KCommand;
|
||||
import cn.net.connor.std.processedit.newmeprocess.NewProcessDialog;
|
||||
import cn.net.connor.std.processedit.newmeprocess.NewProcessDialogController;
|
||||
|
||||
public class NewProcessCommand extends KCommand{
|
||||
|
||||
public NewProcessCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
System.out.println("NewProcessCommand");
|
||||
this.setRunnable(new NewProcessDialog(new NewProcessDialogController(app)));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package cn.net.connor.std.processedit.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.cme.time.common.ActivityUtils;
|
||||
import com.teamcenter.rac.cme.time.common.CommonUtils;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentCfgActivityLine;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PlatformHelper;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KCommand;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
public class OpenViewCommand extends KCommand {
|
||||
|
||||
public OpenViewCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void executeCommand() throws Exception {
|
||||
System.out.println("Open View: " + actionInfo);
|
||||
if (KUtil.isEmpty(actionInfo)) {
|
||||
return;
|
||||
}
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
IWorkbenchWindow var1 = AIFUtility.getActiveDesktop().getDesktopWindow();
|
||||
IWorkbenchPage var2 = var1.getActivePage();
|
||||
IViewPart sv = var2.findView(actionInfo);
|
||||
if (sv == null) {
|
||||
sv = var2.showView(actionInfo);
|
||||
}
|
||||
PlatformHelper.getCurrentPage().activate(sv);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void test() throws Exception{
|
||||
TCComponentBOMLine targetLine = (TCComponentBOMLine) app.getTargetComponent();
|
||||
TCComponentCfgActivityLine actLine = (TCComponentCfgActivityLine) targetLine.getReferenceProperty("bl_me_activity_lines");
|
||||
if (actLine != null) {
|
||||
TCComponent[] cc = ActivityUtils.getSortedActivityChildren(actLine);
|
||||
System.out.println(">> " + Arrays.toString(cc));
|
||||
int len = KUtil.getLen(cc);
|
||||
if (len > 1) {
|
||||
CommonUtils.getSession().suspendEvent();
|
||||
try {
|
||||
ActivityUtils.moveActivityBefore(cc[1], cc[0]);
|
||||
} catch (TCException tCException) {
|
||||
MessageBox.post(tCException);
|
||||
} finally {
|
||||
CommonUtils.getSession().resumeEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class CheckHeaderCellRenderer implements TableCellRenderer {
|
||||
DefaultTableModel tableModel;
|
||||
JTableHeader tableHeader;
|
||||
final JCheckBox selectBox;
|
||||
|
||||
public CheckHeaderCellRenderer(final JTable table, boolean select) {
|
||||
this.tableModel = (DefaultTableModel) table.getModel();
|
||||
this.tableHeader = table.getTableHeader();
|
||||
selectBox = new JCheckBox(tableModel.getColumnName(0));
|
||||
selectBox.setSelected(select);
|
||||
tableHeader.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() > 0) {
|
||||
// 获得选中列
|
||||
int selectColumn = tableHeader.columnAtPoint(e.getPoint());
|
||||
if (selectColumn == 0) {
|
||||
boolean value = !selectBox.isSelected();
|
||||
selectBox.setSelected(value);
|
||||
// tableModel.selectAllOrNull(value);
|
||||
for(int i=0; i<tableModel.getRowCount(); i++) {
|
||||
tableModel.setValueAt(value, i, 0);
|
||||
}
|
||||
tableHeader.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
String valueStr = (String) value;
|
||||
JLabel label = new JLabel(valueStr);
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中
|
||||
selectBox.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中
|
||||
selectBox.setBorderPainted(true);
|
||||
// selectBox.setSelected(true);
|
||||
JComponent component = (column == 0) ? selectBox : label;
|
||||
|
||||
component.setForeground(tableHeader.getForeground());
|
||||
component.setBackground(tableHeader.getBackground());
|
||||
component.setFont(tableHeader.getFont());
|
||||
component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCAccessControlService;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class CutterWordTimeHandler extends AbstractHandler implements IHandler{
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("CutterWordTimeHandler");
|
||||
// new Thread() {
|
||||
// public void run() {
|
||||
// }
|
||||
// }.start();
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
InterfaceAIFComponent target = app.getTargetComponent();
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
if(!(target instanceof TCComponentBOMLine)) {
|
||||
MessageBox.post(desktop, "请选择工序BOM进行操作", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
TCComponentItemRevision rev = ((TCComponentBOMLine)target).getItemRevision();
|
||||
if(!rev.isTypeOf("LD6_MEOPRevision")) {
|
||||
MessageBox.post(desktop, "请选择工序BOM进行操作", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
TCAccessControlService accessControlService = session.getTCAccessControlService();
|
||||
if(!accessControlService.checkUsersPrivilege(session.getUser(), rev, TCAccessControlService.WRITE)) {
|
||||
MessageBox.post(desktop, "当前用户对"+rev+"没有写权限,无法执行命令", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
CutterWordTimeOperation operation = new CutterWordTimeOperation(session, (TCComponentBOMLine)target);
|
||||
session.queueOperation(operation);
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CutterWordTimeOperation extends AbstractAIFOperation {
|
||||
|
||||
// private TCSession session;
|
||||
private TCComponentBOMLine target;
|
||||
|
||||
public CutterWordTimeOperation(TCSession session, TCComponentBOMLine target) {
|
||||
// this.session = session;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
BigDecimal loadingTime = new BigDecimal(0), measureTime = new BigDecimal(0);
|
||||
StringBuilder message = new StringBuilder("");
|
||||
for(AIFComponentContext c : target.getChildren()) {
|
||||
TCComponentBOMLine bom = (TCComponentBOMLine) c.getComponent();
|
||||
TCComponentItemRevision rev = bom.getItemRevision();
|
||||
if(!rev.isTypeOf("LD6_ComtooldesRevision"))
|
||||
continue;
|
||||
String ld6_loadingTime = rev.getProperty("ld6_loadingTime");
|
||||
if(ld6_loadingTime.isEmpty())
|
||||
ld6_loadingTime = "0";
|
||||
String ld6_measureTime = rev.getProperty("ld6_measureTime");
|
||||
if(ld6_measureTime.isEmpty())
|
||||
ld6_measureTime = "0";
|
||||
String bl_quantity = bom.getProperty("bl_quantity");
|
||||
if(bl_quantity.isEmpty())
|
||||
bl_quantity = "1";
|
||||
try {
|
||||
// loadingTime += Double.parseDouble(ld6_loadingTime) * Double.parseDouble(bl_quantity);
|
||||
loadingTime = loadingTime.add(new BigDecimal(ld6_loadingTime).multiply(new BigDecimal(bl_quantity)));
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
message.append("组合刀具【").append(rev).append("】的装刀时间有错误无法计算\n");
|
||||
}
|
||||
try {
|
||||
// measureTime += Double.parseDouble(ld6_measureTime) * Double.parseDouble(bl_quantity);
|
||||
measureTime = measureTime.add(new BigDecimal(ld6_measureTime).multiply(new BigDecimal(bl_quantity)));
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
message.append("组合刀具【").append(rev).append("】的量刀时间有错误无法计算\n");
|
||||
}
|
||||
}
|
||||
target.getItemRevision().setProperty("ld6_loadingTime", ""+loadingTime);
|
||||
target.getItemRevision().setProperty("ld6_measureTime", ""+measureTime);
|
||||
target.refresh();
|
||||
|
||||
if(message.length()==0)
|
||||
MessageBox.post(desktop, "刀具工时统计完成", "INFO", MessageBox.INFORMATION);
|
||||
else
|
||||
MessageBox.post(desktop, message.toString(), "WARN", MessageBox.WARNING);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class GXDivisionHandler extends AbstractHandler implements IHandler{
|
||||
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("DivisionHandler");
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
InterfaceAIFComponent[] targetComponents = app.getTargetComponents();
|
||||
|
||||
List<TCComponentBOMLine> tcList = new ArrayList<>();
|
||||
for (InterfaceAIFComponent comp : targetComponents) {
|
||||
if (comp instanceof TCComponentBOMLine) {
|
||||
tcList.add((TCComponentBOMLine) comp);
|
||||
}
|
||||
// 可选:记录非 TCComponent 对象用于调试
|
||||
// else { System.out.println("跳过非TCComponent对象: " + comp); }
|
||||
}
|
||||
|
||||
// 3. 转换为数组
|
||||
TCComponentBOMLine[] target = tcList.toArray(new TCComponentBOMLine[0]);
|
||||
|
||||
|
||||
|
||||
if(target.length <= 0) {
|
||||
MessageBox.post(desktop, "请选择工序路线对象进行工序分工", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* String type = ((TCComponentBOMLine)target).getItemRevision().getType();
|
||||
* if(!type.equals("LD6_MEProcessCrRevision")) { MessageBox.post(desktop,
|
||||
* "请选择工序路线BOM进行工序分工", "ERROR", MessageBox.ERROR); return null; }
|
||||
*/
|
||||
|
||||
String[] options = session.getPreferenceService().getStringValues("Connor_GXFG");
|
||||
if(options==null || options.length==0) {
|
||||
MessageBox.post(desktop, "首选项Connor_GXFG配置不正确", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
// String optionC[] = session.getPreferenceService().getStringValues("Connor_AVIC_Apply_Create");
|
||||
// if(optionC==null || optionC.length==0) {
|
||||
// MessageBox.post(AIFUtility.getActiveDesktop(), "首选项Connor_AVIC_Apply_Create配置不正确", "ERROR", MessageBox.ERROR);
|
||||
// return null;
|
||||
// }
|
||||
// String options[] = new String[] { "名称", "状态" };
|
||||
new GXDivisionDialog(session, target, options);
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class ProcessBorrowHandler extends AbstractHandler implements IHandler{
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("ProcessBorrowHandler");
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
TCComponent target = (TCComponent)app.getTargetComponent();
|
||||
if(!(target instanceof TCComponentBOMLine)) {
|
||||
MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
// if(((TCComponentBOMLine)target).parent() != null) {
|
||||
// MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
// return null;
|
||||
// }
|
||||
TCComponentItem item = ((TCComponentBOMLine)target).getItem();
|
||||
if(!item.isTypeOf("LD6_MEProcessCr")) {
|
||||
MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
new ProcessBorrowOperation(session, (TCComponentBOMLine)target).executeOperation();
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class ProcessBorrowOperation extends AbstractAIFOperation {
|
||||
|
||||
private TCSession session;
|
||||
private TCComponentBOMLine target;
|
||||
private HashMap<TCComponentItem, TCComponentItemRevision> revMap;
|
||||
|
||||
public ProcessBorrowOperation(TCSession session, TCComponentBOMLine target) {
|
||||
this.session = session;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
revMap = new HashMap<>();
|
||||
TCComponentItemType itemType = (TCComponentItemType) session.getTypeService().getTypeComponent("LD6_MEProcessCr");
|
||||
TCComponentItem item = target.getItemRevision().saveAsItem(itemType.getNewID(), null);
|
||||
TCComponentBOMWindow window = TCUtil.getWindow(session);
|
||||
TCComponentBOMLine bom = TCUtil.getBOMLine(session, window, item.getLatestItemRevision());
|
||||
recycle(bom);
|
||||
window.save();
|
||||
window.close();
|
||||
TCComponentFolder home = session.getUser().getHomeFolder();
|
||||
home.add("contents", item);
|
||||
|
||||
MessageBox.post(desktop, "工艺路线【"+item+"】已存至Home文件夹下", "INFO", MessageBox.INFORMATION);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private void recycle(TCComponentBOMLine parent) throws Exception {
|
||||
for(AIFComponentContext c : parent.getChildren()) {
|
||||
TCComponentBOMLine bom = (TCComponentBOMLine) c.getComponent();
|
||||
TCComponentItem item = bom.getItem();
|
||||
if(revMap.containsKey(item)) {
|
||||
TCComponentItemRevision rev = revMap.get(item);
|
||||
bom.replace(rev.getItem(), rev, null);
|
||||
continue;
|
||||
}
|
||||
if(!item.isTypeOf(new String[] { "LD6_MEProcess", "LD6_OMEOP", "LD6_MEOP" }))
|
||||
continue;
|
||||
TCComponentItemType itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(item.getType());
|
||||
TCComponentItem newItem = bom.getItemRevision().saveAsItem(itemType.getNewID(), null);
|
||||
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
|
||||
bom.replace(newItem, newRev, null);
|
||||
revMap.put(item, newRev);
|
||||
|
||||
recycle(bom);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class ProcessDivisionHandler extends AbstractHandler implements IHandler{
|
||||
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("ProcessDivisionHandler");
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
InterfaceAIFComponent[] targetComponents = app.getTargetComponents();
|
||||
|
||||
List<TCComponentBOMLine> tcList = new ArrayList<>();
|
||||
for (InterfaceAIFComponent comp : targetComponents) {
|
||||
if (comp instanceof TCComponentBOMLine) {
|
||||
tcList.add((TCComponentBOMLine) comp);
|
||||
}
|
||||
// 可选:记录非 TCComponent 对象用于调试
|
||||
// else { System.out.println("跳过非TCComponent对象: " + comp); }
|
||||
}
|
||||
|
||||
// 3. 转换为数组
|
||||
TCComponentBOMLine[] target = tcList.toArray(new TCComponentBOMLine[0]);
|
||||
|
||||
if(target.length <= 0) {
|
||||
MessageBox.post(desktop, "请选择工艺路线对象进行工艺分工", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* String type = ((TCComponentBOMLine)target).getItemRevision().getType();
|
||||
* if(!type.equals("LD6_MEProcessCrRevision")) { MessageBox.post(desktop,
|
||||
* "请选择工艺路线BOM进行工艺分工", "ERROR", MessageBox.ERROR); return null; }
|
||||
*/
|
||||
|
||||
String[] options = session.getPreferenceService().getStringValues("Connor_GYFG");
|
||||
if(options==null || options.length==0) {
|
||||
MessageBox.post(desktop, "首选项Connor_GYFG配置不正确", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
// String optionC[] = session.getPreferenceService().getStringValues("Connor_AVIC_Apply_Create");
|
||||
// if(optionC==null || optionC.length==0) {
|
||||
// MessageBox.post(AIFUtility.getActiveDesktop(), "首选项Connor_AVIC_Apply_Create配置不正确", "ERROR", MessageBox.ERROR);
|
||||
// return null;
|
||||
// }
|
||||
// String options[] = new String[] { "名称", "状态" };
|
||||
new ProcessDivisionDialog(session, target, options);
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEProcess;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class ProcessMultiplexHandler extends AbstractHandler implements IHandler{
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("ProcessBorrowHandler");
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
TCComponent target = (TCComponent)app.getTargetComponent();
|
||||
if(!(target instanceof TCComponentBOMLine)) {
|
||||
MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
if(((TCComponentBOMLine)target).parent() != null) {
|
||||
MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
TCComponentItem item = ((TCComponentBOMLine)target).getItem();
|
||||
if(!(item instanceof TCComponentMEProcess)) {
|
||||
MessageBox.post(desktop, "请选择工艺BOM进行创建", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
String[] prefs = new String[] { "Connor_LD_GYJY_Item", "Connor_LD_GYJY_Process", "Connor_LD_GYJY_Borrow", "Connor_LD_GYJY_Prop", "Connor_LD_GYJY_Clear" };
|
||||
Vector<String[]> options = new Vector<>();
|
||||
for(String s : prefs) {
|
||||
// if(s.equals("Connor_AVIC_GYJY_Borrow")) {
|
||||
// options.add(new String[] {});
|
||||
// continue;
|
||||
// }
|
||||
String searchOptions[] = session.getPreferenceService().getStringValues(s);
|
||||
if(searchOptions == null) {
|
||||
// MessageBox.post(desktop, "首选项"+s+"配置不正确", "ERROR", MessageBox.ERROR);
|
||||
// return null;
|
||||
options.add(new String[] {});
|
||||
continue;
|
||||
}
|
||||
options.add(searchOptions);
|
||||
}
|
||||
new ProcessMultiplexDialog(session, (TCComponentBOMLine)target, options);
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,452 @@
|
||||
package cn.net.connor.std.processedit.ldy;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.common.AIFTreeNode;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.common.organization.OrgTreePanel;
|
||||
import com.teamcenter.rac.common.organization.OrganizationTree;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentGroupMember;
|
||||
import com.teamcenter.rac.kernel.TCComponentProject;
|
||||
import com.teamcenter.rac.kernel.TCComponentUser;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PropertyLayout;
|
||||
|
||||
public class SelectUserDialog extends AbstractAIFDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private JButton add;
|
||||
private JButton remove;
|
||||
private OrganizationTree tree;
|
||||
private JTree projectTree;
|
||||
private JList<String> l_user;
|
||||
private DefaultListModel<String> lm_user;
|
||||
private JTextField editPropMap;
|
||||
// private String group;
|
||||
private boolean isMulti;
|
||||
private JTable table;
|
||||
private int colIndex;
|
||||
private int[] rowIndex;
|
||||
private TCComponentProject project;
|
||||
private HashMap<String, TCComponentUser> userMap;
|
||||
|
||||
public SelectUserDialog(JTextField editPropMap, boolean isMulti) throws Exception {
|
||||
super(true);
|
||||
this.editPropMap = editPropMap;
|
||||
this.isMulti = isMulti;
|
||||
initUI();
|
||||
}
|
||||
|
||||
private String getValue() {
|
||||
String val = "";
|
||||
if (editPropMap != null) {
|
||||
val = editPropMap.getText();
|
||||
} else if (table != null) {
|
||||
val = (String) table.getValueAt(rowIndex[0], colIndex);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
private void setValue(String text) {
|
||||
if (editPropMap != null) {
|
||||
editPropMap.setText(text);
|
||||
} else if (table != null) {
|
||||
for(int i : rowIndex)
|
||||
table.setValueAt(text, i, colIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public SelectUserDialog(JTable table, boolean isMulti, int[] rowIndex, int colIndex, TCComponentProject projectID) throws Exception {
|
||||
super(true);
|
||||
this.table = table;
|
||||
this.isMulti = isMulti;
|
||||
this.colIndex = colIndex;
|
||||
this.rowIndex = rowIndex;
|
||||
this.project = projectID;
|
||||
initUI();
|
||||
}
|
||||
|
||||
public SelectUserDialog(JTable table, int[] rowIndex, int colIndex, HashMap<String, TCComponentUser> userMap) throws Exception {
|
||||
super(true);
|
||||
this.table = table;
|
||||
this.colIndex = colIndex;
|
||||
this.rowIndex = rowIndex;
|
||||
this.userMap = userMap;
|
||||
initUI();
|
||||
}
|
||||
|
||||
private void initUI() throws Exception {
|
||||
this.setTitle("Ñ¡ÔñÈËÔ±");
|
||||
this.setLayout(new BorderLayout());
|
||||
int pweight = 440, pheight = 480, mweight = 280, mheight = 320;
|
||||
if (isMulti) {
|
||||
// this.setPreferredSize(new Dimension(640, 480));
|
||||
// this.setMinimumSize(new Dimension(480, 320));
|
||||
pweight = 640;
|
||||
mweight = 480;
|
||||
}
|
||||
if(project != null) {
|
||||
pheight = 700;
|
||||
mheight = 700;
|
||||
}
|
||||
this.setPreferredSize(new Dimension(pweight, pheight));
|
||||
this.setMinimumSize(new Dimension(mweight, mheight));
|
||||
OrgTreePanel orgPanel = new OrgTreePanel((TCSession) AIFUtility.getCurrentApplication().getSession());
|
||||
this.tree = orgPanel.getOrgTree();
|
||||
|
||||
if(project != null) {
|
||||
JPanel panel = new JPanel(new PropertyLayout());
|
||||
panel.add("1.1.center.center", orgPanel);
|
||||
panel.add("2.1.center.center", initProjectPanel(orgPanel));
|
||||
// FlowLayout flow = new FlowLayout();
|
||||
// flow.setAlignOnBaseline(true);
|
||||
// JPanel panel = new JPanel(flow);
|
||||
// panel.add(orgPanel);
|
||||
// panel.add(initProjectPanel(orgPanel));
|
||||
this.add(BorderLayout.WEST, panel);
|
||||
}else {
|
||||
this.add(BorderLayout.CENTER, orgPanel);
|
||||
}
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
if (isMulti) {
|
||||
JPanel lp = initListPanel();
|
||||
this.add(BorderLayout.EAST, lp);
|
||||
initData();
|
||||
}
|
||||
addListeners();
|
||||
this.setAlwaysOnTop(true);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
String text = getValue();
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String[] split = text.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
lm_user.addElement(split[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel initListPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
FlowLayout flow = new FlowLayout();
|
||||
flow.setVgap(100);
|
||||
JPanel btnPanel = new JPanel(flow);
|
||||
btnPanel.add(this.add);
|
||||
// btnPanel.add("2.1.center.center", this.remove);
|
||||
this.lm_user = new DefaultListModel<>();
|
||||
this.l_user = new JList<>(lm_user);
|
||||
l_user.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
this.l_user.setCellRenderer(new DeleteListRenderer(l_user));
|
||||
JScrollPane scroll = new JScrollPane(l_user);
|
||||
scroll.setPreferredSize(new Dimension(200, 0));
|
||||
// this.add.setPreferredSize(new Dimension(50, 30));
|
||||
panel.add(BorderLayout.WEST, btnPanel);
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 5));
|
||||
this.b_ok = new JButton("È·¶¨");
|
||||
this.b_cel = new JButton("È¡Ïû");
|
||||
this.add = new JButton("+");
|
||||
this.remove = new JButton("-");
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JScrollPane initProjectPanel(OrgTreePanel orgPanel) throws Exception {//TODO
|
||||
Dimension orgDimension = orgPanel.getPreferredSize();
|
||||
orgPanel.setPreferredSize(new Dimension(orgDimension.width*2, orgDimension.height-100));
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(project.getProjectID(), true);
|
||||
projectTree = new JTree(root);
|
||||
|
||||
List<Object> team = project.getTeam();
|
||||
TCComponent[] members = (TCComponent[])team.get(0);
|
||||
for(TCComponent c : members) {
|
||||
if(c instanceof TCComponentGroupMember) {
|
||||
TCComponentGroupMember member = (TCComponentGroupMember)c;
|
||||
DefaultMutableTreeNode childRoot = new DefaultMutableTreeNode(member, true);
|
||||
root.add(childRoot);
|
||||
}
|
||||
}
|
||||
|
||||
projectTree.setPreferredSize(new Dimension(orgDimension.width*2, orgDimension.height/2));
|
||||
// projectTree.setMaximumSize(new Dimension(orgDimension.width*2, orgDimension.height/2));
|
||||
JScrollPane projectPane = new JScrollPane(projectTree);
|
||||
return projectPane;
|
||||
}
|
||||
|
||||
private TCComponentUser getSelectUser() throws Exception {
|
||||
// Object[] comps = tree.getSelectedOrgObjects();
|
||||
AIFTreeNode[] comps = tree.getSelectedNodes();
|
||||
// System.out.println("comps:"+(comps==null));
|
||||
if (comps == null) {
|
||||
if(projectTree == null)
|
||||
return null;
|
||||
else if(projectTree.getSelectionModel() == null)
|
||||
return null;
|
||||
else if(projectTree.getLastSelectedPathComponent() == null)
|
||||
return null;
|
||||
DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) projectTree.getLastSelectedPathComponent();
|
||||
Object selectObject = selectNode.getUserObject();
|
||||
if(selectObject instanceof TCComponentGroupMember) {
|
||||
// String member = ((TCComponentGroupMember) selectObject).toString();
|
||||
// if(member.indexOf(".")>0)
|
||||
// group = member.substring(0, member.indexOf("."));
|
||||
// else
|
||||
// group = member.substring(0, member.indexOf("/"));
|
||||
TCComponentUser user = ((TCComponentGroupMember) selectObject).getUser();
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
}else
|
||||
return null;
|
||||
}
|
||||
// System.out.println("comps:"+comps.length);
|
||||
for (int i = 0; i < comps.length; i++) {
|
||||
// OrgObject comp = (OrgObject) comps[i];
|
||||
TCComponent gm = (TCComponent) comps[i].getContextComponent().getComponent();
|
||||
// System.out.println("gm:"+gm);
|
||||
if (gm != null && (gm instanceof TCComponentGroupMember)) {
|
||||
TCComponentUser user = ((TCComponentGroupMember) gm).getUser();
|
||||
if (user != null) {
|
||||
// group = ((DefaultMutableTreeNode)comps[i].getParent().getParent()).getUserObject().toString();
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
this.b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
if (isMulti) {
|
||||
int size = lm_user.getSize();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < size; i++) {
|
||||
String text = lm_user.getElementAt(i);
|
||||
if (text != null) {
|
||||
sb.append(text).append(";");
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.setLength(sb.length() - 1);
|
||||
}
|
||||
setValue(sb.toString());
|
||||
} else {
|
||||
TCComponentUser user = getSelectUser();
|
||||
if (user != null) {
|
||||
String value = user.getUserId() +"/"+ user.getUserName();
|
||||
userMap.put(value, user);
|
||||
setValue(value);
|
||||
} else {
|
||||
setValue("");
|
||||
}
|
||||
}
|
||||
disposeDialog();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post("Error:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tree.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
super.mouseClicked(e);
|
||||
if(projectTree != null)
|
||||
projectTree.clearSelection();
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||
TCComponentUser user = getSelectUser();
|
||||
System.out.println("user:"+user);
|
||||
if (user != null) {
|
||||
if (isMulti) {
|
||||
if (!lm_user.contains(user.toString())) {
|
||||
lm_user.addElement(user.toString());
|
||||
}
|
||||
} else {
|
||||
String value = user.getUserId() +"/"+ user.getUserName();
|
||||
userMap.put(value, user);
|
||||
setValue(value);
|
||||
disposeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post("Error:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
if(projectTree != null) {
|
||||
projectTree.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
super.mouseClicked(e);
|
||||
tree.clearSelection();
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||
TCComponentUser user = getSelectUser();
|
||||
if (user != null) {
|
||||
if (isMulti) {
|
||||
if (!lm_user.contains(user.toString())) {
|
||||
lm_user.addElement(user.toString());
|
||||
}
|
||||
} else {
|
||||
String value = user.getUserId() +"/"+ user.getUserName();
|
||||
userMap.put(value, user);
|
||||
setValue(value);
|
||||
disposeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post("Error:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if(l_user!=null) {
|
||||
this.l_user.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
int ind = l_user.getSelectedIndex();
|
||||
if (ind >= 0) {
|
||||
lm_user.remove(ind);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
super.mouseEntered(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
super.mouseExited(e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
this.add.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
TCComponentUser user = getSelectUser();
|
||||
System.out.println("user:"+user);
|
||||
if (user != null) {
|
||||
if (!lm_user.contains(user.toString())) {
|
||||
lm_user.addElement(user.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post("Error:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.remove.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
private class DeleteListRenderer extends JPanel implements ListCellRenderer<String> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
JButton btn;
|
||||
JLabel label;
|
||||
|
||||
public DeleteListRenderer(final JList<? extends String> list) {
|
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 1));
|
||||
this.setBackground(Color.WHITE);
|
||||
btn = getDeletetBtn();
|
||||
label = new JLabel("");
|
||||
this.add(btn);
|
||||
this.add(label);
|
||||
|
||||
btn.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int ind = list.getSelectedIndex();
|
||||
System.out.println(ind);
|
||||
if (ind >= 0) {
|
||||
list.remove(ind);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
label.setText(value);
|
||||
return this;
|
||||
}
|
||||
private JButton getDeletetBtn() {
|
||||
ImageIcon icon = new ImageIcon(SelectUserDialog.class.getResource("image/delete.png"));
|
||||
JButton btn = new JButton(icon);
|
||||
btn.setPreferredSize(new Dimension(23, 23));
|
||||
btn.setContentAreaFilled(false);
|
||||
btn.setFocusPainted(false);
|
||||
btn.setBorderPainted(false);
|
||||
btn.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
return btn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.ui.views.AbstractContentViewPart;
|
||||
|
||||
import cn.net.connor.std.processedit.meopviewfx.ui.MEOPPanel;
|
||||
import javafx.embed.swt.FXCanvas;
|
||||
import javafx.scene.Scene;
|
||||
|
||||
public class MEOPEditView extends AbstractContentViewPart {
|
||||
public static final String ID = MEOPEditView.class.getName();
|
||||
private Object currentObj = null;
|
||||
private MEOPPanel meopPanel;
|
||||
|
||||
@Override
|
||||
protected void processEmptySelection(IWorkbenchPart iWorkbenchPart, List<Object> list) {
|
||||
if (list == null || list.size() != 1) {
|
||||
return;
|
||||
}
|
||||
final Object target = list.get(0);
|
||||
if (target != null && !(target.equals(currentObj))) {
|
||||
System.out.println("Select: " + target);
|
||||
currentObj = target;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (meopPanel != null)
|
||||
meopPanel.updateSelection(target);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
public MEOPEditView() {
|
||||
this.setProcessNullSelectionsEnabled(true);
|
||||
this.setUseScrolledForm(false);
|
||||
this.setShowHeader(true);
|
||||
this.setMultiSelectionSupported(true);
|
||||
this.setUISupportsAssociate(false);
|
||||
this.setUISupportsSetScope(false);
|
||||
this.setUISupportsViewLocking(true);
|
||||
this.setUseInitialInputJobEnabled(false);
|
||||
this.setProcessSelectionFromSiblingViewEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createContent(Composite parent) {
|
||||
System.out.println("Init UI...");
|
||||
parent.setLayout(new FillLayout());
|
||||
FXCanvas fxCanvas = new FXCanvas(parent, 16777216);
|
||||
this.meopPanel = new MEOPPanel(AIFUtility.getCurrentApplication().getDesktop());
|
||||
Scene scene = this.meopPanel.getScene();
|
||||
System.out.println("Init UI Complete");
|
||||
fxCanvas.setScene(scene);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,334 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.bean;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.SoaUtil;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.services.internal.rac.structuremanagement.StructureService;
|
||||
import com.teamcenter.services.internal.rac.structuremanagement._2011_06.Structure;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
public class KTableRow {
|
||||
|
||||
public static final String BOMLINE = "BOMLINE";
|
||||
public static final String ITEM = "ITEM";
|
||||
public static final String ITEMMASTER = "ITEMMASTER";
|
||||
public static final String REV = "REV";
|
||||
public static final String REVMASTER = "REVMASTER";
|
||||
private static double ZOOM = 1;
|
||||
static {
|
||||
try {
|
||||
ZOOM = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getPreferenceService().getDoubleValue("Connor_AVIC_GXBZ_Web_Zoom");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (ZOOM < 0) {
|
||||
ZOOM = 1;
|
||||
}
|
||||
System.out.println("GDT ZOOM = " + ZOOM);
|
||||
}
|
||||
|
||||
private TCComponentBOMLine bomline;
|
||||
private TCComponentItem item;
|
||||
private TCComponentItemRevision rev;
|
||||
private TCComponent itemMaster;
|
||||
private TCComponent revMaster;
|
||||
private boolean showWebView = true;
|
||||
private WebView webView;
|
||||
private String webContent;
|
||||
|
||||
public KTableRow(TCComponentBOMLine bomline, TCComponentItem item, TCComponentItemRevision rev, TCComponent itemMaster, TCComponent revMaster) {
|
||||
this.bomline = bomline;
|
||||
this.item = item;
|
||||
this.rev = rev;
|
||||
this.itemMaster = itemMaster;
|
||||
this.revMaster = revMaster;
|
||||
}
|
||||
|
||||
public Map<PropConfig, SimpleStringProperty> stringProps = new HashMap<PropConfig, SimpleStringProperty>();
|
||||
protected Map<PropConfig, String> savedValues = new HashMap<PropConfig, String>();
|
||||
|
||||
public TCComponentBOMLine getBomLine() {
|
||||
return this.bomline;
|
||||
}
|
||||
|
||||
public void setValueByPropName(String config, String value) throws Exception {
|
||||
if (KUtil.isEmpty(config)) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Set Row Value [" + config + "] = [" + value + "]");
|
||||
for (PropConfig propConfig : stringProps.keySet()) {
|
||||
if (config.equalsIgnoreCase(propConfig.propName)) {
|
||||
stringProps.get(propConfig).setValue(value);
|
||||
}
|
||||
}
|
||||
System.out.println(">> config not found");
|
||||
}
|
||||
|
||||
public boolean parseConfig(PropConfig config) throws Exception {
|
||||
if (config == null) {
|
||||
return true;
|
||||
}
|
||||
String value = getTCValue(config.propLoc, config.propName);
|
||||
stringProps.put(config, new SimpleStringProperty(value));
|
||||
savedValues.put(config, value);
|
||||
if (!KUtil.isEmpty(config.filterValue)) {
|
||||
// && !config.filterValue.equals(value)
|
||||
// 20200722 split filter
|
||||
String[] filters = config.filterValue.split(";");
|
||||
boolean checkOK = false;
|
||||
for (String string : filters) {
|
||||
if (string.equals(value)) {
|
||||
checkOK = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return checkOK;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getTCValue(String proploc, String propName) throws Exception {
|
||||
TCComponent comp = getTCComponent(proploc);
|
||||
if (comp == null) {
|
||||
return "";
|
||||
}
|
||||
return comp.getStringProperty(propName);
|
||||
}
|
||||
|
||||
public TCComponent getTCComponent(String proploc) {
|
||||
if (KUtil.isEmpty(proploc)) {
|
||||
return bomline;
|
||||
}
|
||||
proploc = proploc.toUpperCase();
|
||||
switch (proploc) {
|
||||
case BOMLINE:
|
||||
return bomline;
|
||||
case ITEM:
|
||||
return item;
|
||||
case REV:
|
||||
return rev;
|
||||
case ITEMMASTER:
|
||||
return itemMaster;
|
||||
case REVMASTER:
|
||||
return revMaster;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean loadTCValues(Map<String, String> bomlinePropMap, Map<String, String> itemPropMap, Map<String, String> revPropMap, Map<String, String> itemMasterPropMap,
|
||||
Map<String, String> revMasterPropMap) {
|
||||
boolean modified = false;
|
||||
for (PropConfig config : stringProps.keySet()) {
|
||||
if (!config.canEdit) {
|
||||
continue;
|
||||
}
|
||||
String value = stringProps.get(config).getValueSafe();
|
||||
if (savedValues.containsKey(config)) {
|
||||
String savedValue = savedValues.get(config);
|
||||
if (value.equals(savedValue)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
String propName = config.propName;
|
||||
String proploc = config.propLoc.toUpperCase();
|
||||
System.out.println(">> " + proploc + "." + propName + " = " + value);
|
||||
switch (proploc) {
|
||||
case BOMLINE:
|
||||
bomlinePropMap.put(propName, value);
|
||||
break;
|
||||
case ITEM:
|
||||
itemPropMap.put(propName, value);
|
||||
if ("object_name".equals(propName)) {
|
||||
revPropMap.put(propName, value);
|
||||
}
|
||||
break;
|
||||
case REV:
|
||||
revPropMap.put(propName, value);
|
||||
if ("object_name".equals(propName)) {
|
||||
itemPropMap.put(propName, value);
|
||||
}
|
||||
break;
|
||||
case ITEMMASTER:
|
||||
itemMasterPropMap.put(propName, value);
|
||||
break;
|
||||
case REVMASTER:
|
||||
revMasterPropMap.put(propName, value);
|
||||
break;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void saveTCData(TCComponentBOMLine parentLine, TCComponentItemType itemType, int precise, TCComponent viewTypeTag) throws Exception {
|
||||
if (bomline == null) {
|
||||
if (itemType != null && parentLine != null) {
|
||||
System.out.println("Create New Row...");
|
||||
item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), itemType.getName(), "-", "", null);
|
||||
System.out.println(">> new item: " + item);
|
||||
rev = item.getLatestItemRevision();
|
||||
itemMaster = item.getRelatedComponent("IMAN_master_form");
|
||||
revMaster = rev.getRelatedComponent("IMAN_master_form_rev");
|
||||
bomline = parentLine.add(item, rev, null, false, "");
|
||||
}
|
||||
}
|
||||
if (bomline == null) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Update: " + bomline + ", Precise = " + precise);
|
||||
if (precise != 0) {
|
||||
TCComponent[] bvrs = rev.getReferenceListProperty("structure_revisions");
|
||||
System.out.println("BVR: " + Arrays.toString(bvrs));
|
||||
if (KUtil.getLen(bvrs) == 0) {
|
||||
TCSession session = rev.getSession();
|
||||
StructureService structureService = StructureService.getService(session);
|
||||
Structure.CreateOrSaveAsPSBOMViewRevisionResponse createOrSaveAsPSBOMViewRevisionResponse = null;
|
||||
Structure.CreateOrSaveAsPSBOMViewRevisionInput[] arrayOfCreateOrSaveAsPSBOMViewRevisionInput = new Structure.CreateOrSaveAsPSBOMViewRevisionInput[1];
|
||||
arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0] = new Structure.CreateOrSaveAsPSBOMViewRevisionInput();
|
||||
(arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0]).clientId = (new Integer(0)).toString();
|
||||
(arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0]).isPrecise = precise > 0;
|
||||
(arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0]).viewTypeTag = viewTypeTag;
|
||||
(arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0]).itemObject = rev.getItem();
|
||||
(arrayOfCreateOrSaveAsPSBOMViewRevisionInput[0]).itemRevObj = rev;
|
||||
createOrSaveAsPSBOMViewRevisionResponse = structureService.createOrSavePSBOMViewRevision(arrayOfCreateOrSaveAsPSBOMViewRevisionInput);
|
||||
SoaUtil.checkPartialErrors(createOrSaveAsPSBOMViewRevisionResponse.serviceData);
|
||||
} else {
|
||||
bomline.setPrecision(precise > 0);
|
||||
}
|
||||
}
|
||||
Map<String, String> revPropMap = new HashMap<>();
|
||||
Map<String, String> revMasterPropMap = new HashMap<>();
|
||||
Map<String, String> itemPropMap = new HashMap<>();
|
||||
Map<String, String> itemMasterPropMap = new HashMap<>();
|
||||
Map<String, String> bomlinePropMap = new HashMap<>();
|
||||
if (!loadTCValues(bomlinePropMap, itemPropMap, revPropMap, itemMasterPropMap, revMasterPropMap)) {
|
||||
return;
|
||||
}
|
||||
if (itemPropMap.size() > 0) {
|
||||
item.setProperties(itemPropMap);
|
||||
}
|
||||
if (revPropMap.size() > 0) {
|
||||
rev.setProperties(revPropMap);
|
||||
}
|
||||
if (itemMasterPropMap.size() > 0) {
|
||||
itemMaster.setProperties(itemMasterPropMap);
|
||||
}
|
||||
if (revMasterPropMap.size() > 0) {
|
||||
revMaster.setProperties(revMasterPropMap);
|
||||
}
|
||||
if (bomlinePropMap.size() > 0) {
|
||||
bomline.setProperties(bomlinePropMap);
|
||||
}
|
||||
bomline.refresh();
|
||||
}
|
||||
|
||||
public void removeLine() throws Exception {
|
||||
if (bomline != null) {
|
||||
System.out.println(">> Remove: " + bomline);
|
||||
bomline.cut();
|
||||
}
|
||||
}
|
||||
|
||||
public void showWebView(boolean showWebView) {
|
||||
this.showWebView = showWebView;
|
||||
}
|
||||
|
||||
public boolean showWebView() {
|
||||
return showWebView;
|
||||
}
|
||||
|
||||
public WebView getWebView() {
|
||||
return this.webView;
|
||||
}
|
||||
|
||||
public WebView checkWebView() {
|
||||
if (!showWebView) {
|
||||
return null;
|
||||
}
|
||||
if (webView == null) {
|
||||
webView = new WebView();
|
||||
webView.setDisable(true);
|
||||
webView.setMouseTransparent(true);
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
webView.setZoom(ZOOM);
|
||||
// webView.getEngine().documentProperty().addListener((obj, prev, newv) -> {
|
||||
// if (newv == null) {
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// // String heightText = webView.getEngine().executeScript(
|
||||
// // "var body = document.body, html = document.documentElement;Math.max(
|
||||
// // body.scrollHeight, body.offsetHeight, html.clientHeight,
|
||||
// html.scrollHeight,
|
||||
// // html.offsetHeight );")
|
||||
// // .toString();
|
||||
//
|
||||
// // double height = Double.parseDouble(heightText.replace("px", ""));
|
||||
// // webView.setPrefHeight(height + 12);
|
||||
// // System.out.println("Set Height [" + getTCComponent(BOMLINE) + "]: " +
|
||||
// // height);
|
||||
// new Thread(() -> {
|
||||
// Platform.runLater(() -> {
|
||||
// String heightText = webView.getEngine().executeScript("var body =
|
||||
// document.body, html = document.documentElement;Math.max( body.scrollHeight,
|
||||
// body.offsetHeight );")
|
||||
// .toString();
|
||||
// double height2 = Double.parseDouble(heightText.replace("px", "")) + 12;
|
||||
// System.out.println("Set Height [" + getTCComponent(BOMLINE) + "][" +
|
||||
// webView.getWidth() + "]: " + height2);
|
||||
// webView.setPrefHeight(height2);
|
||||
// webView.getParent().layout();
|
||||
// webView.layout();
|
||||
// });
|
||||
// }).start();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
// webView.getEngine().getLoadWorker().stateProperty().addListener(new
|
||||
// ChangeListener<State>() {
|
||||
// @Override
|
||||
// public void changed(ObservableValue<? extends State> observable, State
|
||||
// oldValue, State newValue) {
|
||||
// if (newValue == State.SUCCEEDED) {
|
||||
// // webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
return webView;
|
||||
}
|
||||
|
||||
public void loadContent(String html) {
|
||||
if (html == null) {
|
||||
html = "";
|
||||
}
|
||||
if (html.equals(this.webContent)) {
|
||||
return;
|
||||
}
|
||||
webView.setPrefWidth(Region.USE_COMPUTED_SIZE);
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
WebEngine engine = webView.getEngine();
|
||||
this.webContent = html;
|
||||
engine.loadContent(html);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,217 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.bean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class KTableRowBackup20220509 {
|
||||
|
||||
public static final String BOMLINE = "BOMLINE";
|
||||
public static final String ITEM = "ITEM";
|
||||
public static final String ITEMMASTER = "ITEMMASTER";
|
||||
public static final String REV = "REV";
|
||||
public static final String REVMASTER = "REVMASTER";
|
||||
|
||||
private TCComponentBOMLine bomline;
|
||||
private TCComponentItem item;
|
||||
private TCComponentItemRevision rev;
|
||||
private TCComponent itemMaster;
|
||||
private TCComponent revMaster;
|
||||
private boolean showWebView = true;
|
||||
|
||||
public KTableRowBackup20220509(TCComponentBOMLine bomline, TCComponentItem item, TCComponentItemRevision rev, TCComponent itemMaster, TCComponent revMaster) {
|
||||
this.bomline = bomline;
|
||||
this.item = item;
|
||||
this.rev = rev;
|
||||
this.itemMaster = itemMaster;
|
||||
this.revMaster = revMaster;
|
||||
}
|
||||
|
||||
public Map<PropConfig, SimpleStringProperty> stringProps = new HashMap<PropConfig, SimpleStringProperty>();
|
||||
protected Map<PropConfig, String> savedValues = new HashMap<PropConfig, String>();
|
||||
|
||||
public TCComponentBOMLine getBomLine() {
|
||||
return this.bomline;
|
||||
}
|
||||
|
||||
public void setValueByPropName(String config, String value) throws Exception{
|
||||
if(KUtil.isEmpty(config)) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Set Row Value ["+config+"] = ["+value+"]");
|
||||
for (PropConfig propConfig : stringProps.keySet()) {
|
||||
if(config.equalsIgnoreCase(propConfig.propName)) {
|
||||
stringProps.get(propConfig).setValue(value);
|
||||
}
|
||||
}
|
||||
System.out.println(">> config not found");
|
||||
}
|
||||
|
||||
public boolean parseConfig(PropConfig config) throws Exception {
|
||||
if (config == null) {
|
||||
return true;
|
||||
}
|
||||
String value = getTCValue(config.propLoc, config.propName);
|
||||
stringProps.put(config, new SimpleStringProperty(value));
|
||||
savedValues.put(config, value);
|
||||
if (!KUtil.isEmpty(config.filterValue)) {
|
||||
// && !config.filterValue.equals(value)
|
||||
// 20200722 split filter
|
||||
String[] filters = config.filterValue.split(";");
|
||||
boolean checkOK = false;
|
||||
for (String string : filters) {
|
||||
if (string.equals(value)) {
|
||||
checkOK = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return checkOK;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getTCValue(String proploc, String propName) throws Exception {
|
||||
TCComponent comp = getTCComponent(proploc);
|
||||
if (comp == null) {
|
||||
return "";
|
||||
}
|
||||
return comp.getStringProperty(propName);
|
||||
}
|
||||
|
||||
public TCComponent getTCComponent(String proploc) {
|
||||
if (KUtil.isEmpty(proploc)) {
|
||||
return bomline;
|
||||
}
|
||||
proploc = proploc.toUpperCase();
|
||||
switch (proploc) {
|
||||
case BOMLINE:
|
||||
return bomline;
|
||||
case ITEM:
|
||||
return item;
|
||||
case REV:
|
||||
return rev;
|
||||
case ITEMMASTER:
|
||||
return itemMaster;
|
||||
case REVMASTER:
|
||||
return revMaster;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean loadTCValues(Map<String, String> bomlinePropMap, Map<String, String> itemPropMap, Map<String, String> revPropMap, Map<String, String> itemMasterPropMap,
|
||||
Map<String, String> revMasterPropMap) {
|
||||
boolean modified = false;
|
||||
for (PropConfig config : stringProps.keySet()) {
|
||||
if (!config.canEdit) {
|
||||
continue;
|
||||
}
|
||||
String value = stringProps.get(config).getValueSafe();
|
||||
if (savedValues.containsKey(config)) {
|
||||
String savedValue = savedValues.get(config);
|
||||
if (value.equals(savedValue)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
String propName = config.propName;
|
||||
String proploc = config.propLoc.toUpperCase();
|
||||
System.out.println(">> " + proploc + "." + propName + " = " + value);
|
||||
switch (proploc) {
|
||||
case BOMLINE:
|
||||
bomlinePropMap.put(propName, value);
|
||||
break;
|
||||
case ITEM:
|
||||
itemPropMap.put(propName, value);
|
||||
if ("object_name".equals(propName)) {
|
||||
revPropMap.put(propName, value);
|
||||
}
|
||||
break;
|
||||
case REV:
|
||||
revPropMap.put(propName, value);
|
||||
if ("object_name".equals(propName)) {
|
||||
itemPropMap.put(propName, value);
|
||||
}
|
||||
break;
|
||||
case ITEMMASTER:
|
||||
itemMasterPropMap.put(propName, value);
|
||||
break;
|
||||
case REVMASTER:
|
||||
revMasterPropMap.put(propName, value);
|
||||
break;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void saveTCData(TCComponentBOMLine parentLine, TCComponentItemType itemType) throws Exception {
|
||||
if (bomline == null) {
|
||||
if (itemType != null && parentLine != null) {
|
||||
System.out.println("Create New Row...");
|
||||
item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), itemType.getName(), "-", "", null);
|
||||
System.out.println(">> new item: " + item);
|
||||
rev = item.getLatestItemRevision();
|
||||
itemMaster = item.getRelatedComponent("IMAN_master_form");
|
||||
revMaster = rev.getRelatedComponent("IMAN_master_form_rev");
|
||||
bomline = parentLine.add(item, rev, null, false, "");
|
||||
}
|
||||
}
|
||||
if (bomline == null) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Update: " + bomline);
|
||||
Map<String, String> revPropMap = new HashMap<>();
|
||||
Map<String, String> revMasterPropMap = new HashMap<>();
|
||||
Map<String, String> itemPropMap = new HashMap<>();
|
||||
Map<String, String> itemMasterPropMap = new HashMap<>();
|
||||
Map<String, String> bomlinePropMap = new HashMap<>();
|
||||
if (!loadTCValues(bomlinePropMap, itemPropMap, revPropMap, itemMasterPropMap, revMasterPropMap)) {
|
||||
return;
|
||||
}
|
||||
if (itemPropMap.size() > 0) {
|
||||
item.setProperties(itemPropMap);
|
||||
}
|
||||
if (revPropMap.size() > 0) {
|
||||
rev.setProperties(revPropMap);
|
||||
}
|
||||
if (itemMasterPropMap.size() > 0) {
|
||||
itemMaster.setProperties(itemMasterPropMap);
|
||||
}
|
||||
if (revMasterPropMap.size() > 0) {
|
||||
revMaster.setProperties(revMasterPropMap);
|
||||
}
|
||||
if (bomlinePropMap.size() > 0) {
|
||||
bomline.setProperties(bomlinePropMap);
|
||||
}
|
||||
bomline.refresh();
|
||||
}
|
||||
|
||||
public void removeLine() throws Exception {
|
||||
if (bomline != null) {
|
||||
System.out.println(">> Remove: " + bomline);
|
||||
bomline.cut();
|
||||
}
|
||||
}
|
||||
|
||||
public void showWebView(boolean showWebView) {
|
||||
this.showWebView = showWebView;
|
||||
}
|
||||
|
||||
public boolean showWebView() {
|
||||
return showWebView;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,113 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.bean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.cme.time.common.ActivityUtils;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentCfgActivityLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEActivity;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEActivityType;
|
||||
import com.teamcenter.rac.kernel.TCComponentMECfgLine;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
public class KTableRowMEActivity extends KTableRow {
|
||||
|
||||
public TCComponentCfgActivityLine actline;
|
||||
private TCComponentMEActivity folder;
|
||||
|
||||
public KTableRowMEActivity(TCComponentCfgActivityLine bomline,TCComponentMEActivity folder) {
|
||||
super(null,null,null,null,null);
|
||||
this.actline = bomline;
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TCComponent getTCComponent(String proploc) {
|
||||
if(KUtil.isEmpty(proploc)) {
|
||||
return folder;
|
||||
}
|
||||
proploc = proploc.toUpperCase();
|
||||
switch (proploc) {
|
||||
case BOMLINE:
|
||||
return actline;
|
||||
case ITEM:
|
||||
return folder;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean loadTCValues(Map<String, String> bomlinePropMap , Map<String, String> itemPropMap) {
|
||||
boolean modified = false;
|
||||
for (PropConfig config : stringProps.keySet()) {
|
||||
if(!config.canEdit) {
|
||||
continue;
|
||||
}
|
||||
String value = stringProps.get(config).getValueSafe();
|
||||
String propName = config.propName;
|
||||
String proploc = config.propLoc.toUpperCase();
|
||||
if(savedValues.containsKey(config)) {
|
||||
String savedValue = savedValues.get(config);
|
||||
if(value.equals(savedValue)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
System.out.println(">> "+proploc+"."+propName+" = "+value);
|
||||
switch(proploc) {
|
||||
case BOMLINE:
|
||||
bomlinePropMap.put(propName, value);
|
||||
break;
|
||||
case ITEM:
|
||||
itemPropMap.put(propName, value);
|
||||
break;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + proploc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void saveTCData(TCComponentCfgActivityLine parentLine, TCComponentMEActivityType itemType) throws Exception{
|
||||
if(actline==null) {
|
||||
if(itemType!=null&&parentLine!=null) {
|
||||
System.out.println("Create New Activity...");
|
||||
folder= itemType.createActivity("-", itemType.getName(), "", 0.0D);
|
||||
System.out.println(">> New Activity: "+folder);
|
||||
this.actline = (TCComponentCfgActivityLine) ActivityUtils.addActivity(parentLine, folder);
|
||||
System.out.println(">> New Line: "+this.actline);
|
||||
}
|
||||
}
|
||||
if(actline==null) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Update: "+actline);
|
||||
Map<String, String> itemPropMap = new HashMap<>();
|
||||
Map<String, String> bomlinePropMap = new HashMap<>();
|
||||
if(!loadTCValues(bomlinePropMap, itemPropMap)) {
|
||||
System.out.println(">> No modified property");
|
||||
return;
|
||||
}
|
||||
if(itemPropMap.size()>0) {
|
||||
folder.setProperties(itemPropMap);
|
||||
}
|
||||
if(bomlinePropMap.size()>0) {
|
||||
actline.setProperties(bomlinePropMap);
|
||||
}
|
||||
actline.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine() throws Exception{
|
||||
if(actline!=null) {
|
||||
System.out.println(">> Remove Activity: "+actline);
|
||||
ActivityUtils.removeActivity((TCComponentMECfgLine)actline);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.bean;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponentListOfValues;
|
||||
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
|
||||
|
||||
import javafx.scene.control.Control;
|
||||
|
||||
public class PropConfig {
|
||||
public String propName;
|
||||
public String propDisplayName;
|
||||
public String propLoc;
|
||||
public TCComponentListOfValues lov;
|
||||
public String filterValue;
|
||||
public TCPropertyDescriptor propDesc;
|
||||
public int width;
|
||||
public int maxCharacterInRow;
|
||||
public boolean canEdit;
|
||||
private Control control;
|
||||
private Object savedValue;
|
||||
public int height;
|
||||
|
||||
public PropConfig(String propLoc, TCPropertyDescriptor propDesc, String filterValue, int width, int height, int maxCharacterInRow) {
|
||||
this.propName = propDesc.getName();
|
||||
this.propDisplayName = propDesc.getDisplayName();
|
||||
this.propLoc = propLoc;
|
||||
this.filterValue = filterValue;
|
||||
this.lov = propDesc.getLOV();
|
||||
this.propDesc = propDesc;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.maxCharacterInRow = maxCharacterInRow;
|
||||
// this.canEdit =
|
||||
// propDesc.isModifiable()&&!"bl_occ_type".equals(propName)&&!"item_id".equals(propName);
|
||||
this.canEdit = propDesc.isModifiable() && !"item_id".equals(propName);
|
||||
System.out.println(propName + " >> " + lov + " >> " + canEdit + " >> " + width + "x" + height);
|
||||
}
|
||||
|
||||
public void setSavedValue(Object savedValue) {
|
||||
this.savedValue = savedValue;
|
||||
}
|
||||
|
||||
public boolean valueChanged(Object newValue) {
|
||||
if (savedValue != null) {
|
||||
return !savedValue.equals(newValue);
|
||||
}
|
||||
return newValue != null;
|
||||
}
|
||||
|
||||
public void setControl(Control control) {
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
public Control getControl() {
|
||||
return control;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return propName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
public class TextBean {
|
||||
|
||||
private String text;
|
||||
private String realValue;
|
||||
public List<TextBean> children = new ArrayList<TextBean>();
|
||||
|
||||
public TextBean(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void setRealValue(String realValue) {
|
||||
this.realValue = realValue;
|
||||
}
|
||||
|
||||
public String getRealValue() {
|
||||
return KUtil.isEmpty(realValue)?text:realValue;
|
||||
}
|
||||
|
||||
public String getDisplayValue() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDisplayValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj==null) {
|
||||
return false;
|
||||
}
|
||||
if(obj instanceof TextBean) {
|
||||
return text.equals(((TextBean) obj).text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.reorder;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
import com.teamcenter.rac.util.iTextField;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ReorderDialog extends KDialog {
|
||||
|
||||
public static final Registry REG = Registry.getRegistry(ReorderDialog.class);
|
||||
private JButton b_Ok;
|
||||
private JButton b_Cancel;
|
||||
private iTextField tf_startNum;
|
||||
private iTextField tf_stepNum;
|
||||
private int startNum;
|
||||
private int stepNum;
|
||||
private TableView<KTableRow> table;
|
||||
private Map<PropConfig, Integer> sequenceConfigMap;
|
||||
|
||||
public ReorderDialog(TableView<KTableRow> table, Map<PropConfig, Integer> sequenceConfigMap) {
|
||||
super();
|
||||
this.table = table;
|
||||
this.sequenceConfigMap = sequenceConfigMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
b_Cancel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
b_Ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
loadNumbers();
|
||||
disposeDialog();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ReorderDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void loadNumbers() throws Exception {
|
||||
String startNumStr = tf_startNum.getText().trim();
|
||||
String stepNumStr = tf_stepNum.getText().trim();
|
||||
if (KUtil.isEmpty(startNumStr) || KUtil.isEmpty(stepNumStr)) {
|
||||
throw new TCException(REG.getString("require.error"));
|
||||
}
|
||||
this.startNum = -1;
|
||||
this.stepNum = -1;
|
||||
try {
|
||||
startNum = Integer.parseInt(startNumStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
throw new TCException(String.format(REG.getString("format.error1"), startNumStr));
|
||||
}
|
||||
try {
|
||||
stepNum = Integer.parseInt(stepNumStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
throw new TCException(String.format(REG.getString("format.error1"), stepNumStr));
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
KTableRow[] rows = table.getItems().toArray(new KTableRow[] {});
|
||||
int len = KUtil.getLen(rows);
|
||||
for (int i = 0; i < len; i++) {
|
||||
KTableRow row = rows[i];
|
||||
String seq = String.valueOf(startNum + i * stepNum);
|
||||
for (PropConfig sequenceConfig : this.sequenceConfigMap.keySet()) {
|
||||
row.stringProps.get(sequenceConfig).setValue(seq);
|
||||
}
|
||||
}
|
||||
int maxSeq = startNum + stepNum * (len - 1);
|
||||
for (PropConfig sequenceConfig : this.sequenceConfigMap.keySet()) {
|
||||
sequenceConfigMap.put(sequenceConfig, maxSeq);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(REG.getString("dialog.title"));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.CENTER, initCenterPanel());
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 8));
|
||||
panel.add(this.b_Ok = new JButton(REG.getString("ok.btn")));
|
||||
panel.add(this.b_Cancel = new JButton(REG.getString("cancel.btn")));
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initCenterPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(8, 8, 0, 0));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 8));
|
||||
KUtil.newRow(panel, new JLabel(REG.getString("startnum.label")), s, 1);
|
||||
KUtil.addCol(panel, this.tf_startNum = new iTextField(16, true), s, 1, 0);
|
||||
KUtil.newRow(panel, new JLabel(REG.getString("stepnum.label")), s, 1);
|
||||
KUtil.addCol(panel, this.tf_stepNum = new iTextField(16, true), s, 1, 0);
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.reorder;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
|
||||
public class ReorderDialogController extends KDialogController{
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
dialog.title=\u5BF9\u7ED3\u6784\u91CD\u6392\u5E8F
|
||||
ok.btn=\u786E\u5B9A
|
||||
cancel.btn=\u53D6\u6D88
|
||||
startnum.label=\u5F00\u59CB\u6570\u5B57\uFF1A
|
||||
stepnum.label=\u589E\u91CF\uFF1A
|
||||
format.error1=\u201C%s\u201D\u4E0D\u662F\u6709\u6548\u7684\u503C
|
||||
require.error=\u8BF7\u586B\u5199\u5FC5\u586B\u503C
|
||||
@ -0,0 +1,323 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import com.teamcenter.rac.treetable.SwingTextContextActivator;
|
||||
import com.teamcenter.rac.util.Utilities;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.fx.KFXTextLocator;
|
||||
import cn.net.connor.std.gdtex.KGenerateGDTHTML;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.Event;
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableColumn.CellEditEvent;
|
||||
import javafx.scene.control.TablePosition;
|
||||
import javafx.scene.control.TableRow;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
/**
|
||||
* select color:
|
||||
*
|
||||
* .table-row-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-row-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* .table-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
|
||||
public class KFXEditableStringAreaHtmlTableCell<T, E> extends TableCell<T, String> {
|
||||
|
||||
protected PropConfig config;
|
||||
protected TextArea textArea;
|
||||
|
||||
// private static final Registry REG =
|
||||
// Registry.getRegistry(KFXEditableStringAreaHtmlTableCell.class);
|
||||
// private static int FONTSIZE = -1;
|
||||
// static {
|
||||
// try {
|
||||
// // String zoomStr = REG.getString("zoom");
|
||||
// // if (!KUtil.isEmpty(zoomStr)) {
|
||||
// // double d = Double.parseDouble(zoomStr);
|
||||
// // System.out.println("Zoom: " + d);
|
||||
// // ZOOM = d;
|
||||
// // }
|
||||
// // FONTSIZE = REG.getInt("fontsize", -1);
|
||||
// } catch (Exception e) {
|
||||
// }
|
||||
// if (ZOOM < 0) {
|
||||
// ZOOM = 1;
|
||||
// }
|
||||
// }
|
||||
protected ChangeListener<? super Boolean> changeListener = (obs, ov, nv) -> {
|
||||
if (!nv) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
};
|
||||
private Text text;
|
||||
private KFXTextLocator textLocator;
|
||||
|
||||
public KFXEditableStringAreaHtmlTableCell(PropConfig config, KFXTextLocator textLocator) {
|
||||
super();
|
||||
this.config = config;
|
||||
this.textLocator = textLocator;
|
||||
// this.localToSceneTransformProperty().addListener((obs, oldIndex, newIndex) ->
|
||||
// {
|
||||
// if (getGraphic() == null || oldIndex==newIndex) {
|
||||
// return;
|
||||
// }
|
||||
// if(!(getGraphic() instanceof WebView)) {
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startEdit() {
|
||||
if (editableProperty().get()) {
|
||||
if (!isEmpty()) {
|
||||
super.startEdit();
|
||||
createTextField();
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startEdit(int temp) {
|
||||
if (isEditing()) {
|
||||
System.out.println("=====>" + temp);
|
||||
textArea.positionCaret(temp);
|
||||
}
|
||||
}
|
||||
|
||||
public KTableRow showWebView() {
|
||||
Object obj = null;
|
||||
try {
|
||||
obj = super.getTableRow().getItem();
|
||||
} catch (Exception e1) {
|
||||
}
|
||||
if (obj != null && (obj instanceof KTableRow)) {
|
||||
WebView webView = ((KTableRow) obj).checkWebView();
|
||||
if (webView != null) {
|
||||
webView.setOnScroll(e -> {
|
||||
Event.fireEvent(KFXEditableStringAreaHtmlTableCell.this, e);
|
||||
});
|
||||
// webView.setOnMouseClicked(null);
|
||||
// if (isEditable()) {
|
||||
// webView.setOnMouseClicked(e -> {
|
||||
// System.out.println("?????????/");
|
||||
// TableView<T> table = getTableView();
|
||||
// if (table == null) {
|
||||
// return;
|
||||
// }
|
||||
// TableRow<?> row = getTableRow();
|
||||
// int rowNum = row.getIndex();
|
||||
// if (rowNum < 0) {
|
||||
// return;
|
||||
// }
|
||||
// TableColumn<T, String> col = getTableColumn();
|
||||
// if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
// table.getSelectionModel().select(rowNum, col);
|
||||
// return;
|
||||
// }
|
||||
// KTableRow bean = (KTableRow) table.getItems().get(rowNum);
|
||||
// bean.showWebView(false);
|
||||
// updateItem(getItem(), isEmpty());
|
||||
// table.layout();
|
||||
// table.edit(rowNum, col);
|
||||
// });
|
||||
// }
|
||||
return ((KTableRow) obj);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelEdit() {
|
||||
super.cancelEdit();
|
||||
// setText((String) getItem());
|
||||
// setGraphic(null);
|
||||
KTableRow webView = showWebView();
|
||||
if (webView != null) {
|
||||
setGraphic(webView.getWebView());
|
||||
} else {
|
||||
setGraphic(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
// if (webView == null) {
|
||||
// createWebView();
|
||||
// }
|
||||
if (text == null) {
|
||||
text = new Text();
|
||||
text.wrappingWidthProperty().bind(getTableColumn().widthProperty().subtract(20));
|
||||
text.textProperty().bind(itemProperty());
|
||||
text.getStyleClass().add("ktext");
|
||||
text.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Bounds> observable, Bounds oldValue, Bounds newValue) {
|
||||
KTableRow webView = showWebView();
|
||||
if (webView == null) {
|
||||
return;
|
||||
}
|
||||
double height = text.getLayoutBounds().getHeight() + 30; // +20 is for paddings
|
||||
webView.getWebView().setPrefHeight(height);
|
||||
}
|
||||
});
|
||||
}
|
||||
KTableRow webView = showWebView();
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else if (webView != null) {
|
||||
String newValue = item;
|
||||
String html = KUtil.isEmpty(newValue) || newValue.startsWith("<html>") ? newValue : KGenerateGDTHTML.generatePage(newValue);
|
||||
// createWebView(html);
|
||||
webView.loadContent(html);
|
||||
setGraphic(webView.getWebView());
|
||||
double height = text.getLayoutBounds().getHeight() + 30; // +20 is for paddings
|
||||
// System.out.println("Set Height [" + webView.getTCComponent(KTableRow.BOMLINE)
|
||||
// + "]: " + height);
|
||||
webView.getWebView().setPrefHeight(height);
|
||||
// webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// Platform.runLater(() -> {
|
||||
// try {
|
||||
// // System.out.println("Load Html: " + newValue);
|
||||
// // System.out.println(">> " + html);
|
||||
// String html = newValue == null || newValue.startsWith("<html>") ? newValue :
|
||||
// GenerateGDTHTML.generatePage(newValue);
|
||||
// webView.getEngine().loadContent(html);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
// setGraphic(webView);
|
||||
} else {
|
||||
if (isEditing()) {
|
||||
if (textArea != null) {
|
||||
textArea.setText(getString());
|
||||
// textArea.selectAll();
|
||||
}
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
} else {
|
||||
setGraphic(text);
|
||||
// setText(getString());
|
||||
// setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTextField() {
|
||||
if (textArea == null) {
|
||||
textArea = new TextArea();
|
||||
textArea.setWrapText(true);
|
||||
// if (FONTSIZE > 0) {
|
||||
// try {
|
||||
// textArea.setFont(Font.font(FONTSIZE));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
textArea.setOnKeyPressed((ke) -> {
|
||||
if (ke.getCode().equals(KeyCode.ESCAPE)) {
|
||||
textArea.focusedProperty().removeListener(changeListener);
|
||||
cancelEdit();
|
||||
}
|
||||
if (ke.getCode().equals(KeyCode.TAB)) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
});
|
||||
textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
|
||||
if (arg2) {
|
||||
SwingTextContextActivator.instance().activateContext();
|
||||
} else {
|
||||
SwingTextContextActivator.instance().deactivateContext();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (textLocator != null) {
|
||||
textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
if (newValue) {
|
||||
System.out.println("focus get:" + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
textLocator.updateControl(KFXEditableStringAreaHtmlTableCell.this);
|
||||
} else {
|
||||
System.out.println("focus lost: " + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
}
|
||||
}
|
||||
});
|
||||
textArea.caretPositionProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
||||
if (textArea.isFocused()) {
|
||||
System.out.println("caret: " + oldValue + " -> " + newValue);
|
||||
Utilities.setPrivateField(textLocator, "currentCaret", newValue.intValue());
|
||||
// textLocator.currentCaret = newValue.intValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
textArea.setText(getString());
|
||||
textArea.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
||||
textArea.setPrefHeight(this.getHeight());
|
||||
textArea.focusedProperty().addListener(changeListener);
|
||||
// textArea.setOnAction(evt -> commitEdit(textField.getText()));
|
||||
}
|
||||
|
||||
protected String getString() {
|
||||
return getItem() == null ? "" : getItem().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void commitEdit(String item) {
|
||||
if (isEditing()) {
|
||||
super.commitEdit(item);
|
||||
} else {
|
||||
final TableView table = getTableView();
|
||||
if (table != null) {
|
||||
TablePosition position = new TablePosition(getTableView(), getTableRow().getIndex(), getTableColumn());
|
||||
CellEditEvent editEvent = new CellEditEvent(table, position, TableColumn.editCommitEvent(), item);
|
||||
Event.fireEvent(getTableColumn(), editEvent);
|
||||
}
|
||||
updateItem(item, false);
|
||||
if (table != null) {
|
||||
table.edit(-1, null);
|
||||
}
|
||||
// super.commitEdit(item); // 20201217 bug fix
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
if (row != null && row.getIndex() >= 0) {
|
||||
KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex());
|
||||
bean.showWebView(true);
|
||||
updateItem(item, isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,431 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import com.teamcenter.rac.stylesheet.gdt.GenerateGDTHTML;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
import com.teamcenter.rac.util.Utilities;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.fx.KFXTextLocator;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Worker.State;
|
||||
import javafx.event.Event;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableColumn.CellEditEvent;
|
||||
import javafx.scene.control.TablePosition;
|
||||
import javafx.scene.control.TableRow;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
/**
|
||||
* select color:
|
||||
*
|
||||
* .table-row-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-row-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* .table-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
|
||||
public class KFXEditableStringAreaHtmlTableCellBackup20220409<T, E> extends TableCell<T, String> {
|
||||
protected WebView webView;
|
||||
protected PropConfig config;
|
||||
protected TextArea textArea;
|
||||
private static final Registry REG = Registry.getRegistry(KFXEditableStringAreaHtmlTableCellBackup20220409.class);
|
||||
private static double ZOOM = 1;
|
||||
private static int FONTSIZE = -1;
|
||||
static {
|
||||
try {
|
||||
String zoomStr = REG.getString("zoom");
|
||||
if (!KUtil.isEmpty(zoomStr)) {
|
||||
double d = Double.parseDouble(zoomStr);
|
||||
System.out.println("Zoom: " + d);
|
||||
ZOOM = d;
|
||||
}
|
||||
FONTSIZE = REG.getInt("fontsize", -1);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (ZOOM < 0) {
|
||||
ZOOM = 1;
|
||||
}
|
||||
}
|
||||
protected ChangeListener<? super Boolean> changeListener = (obs, ov, nv) -> {
|
||||
if (!nv) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
};
|
||||
private Text text;
|
||||
private KFXTextLocator textLocator;
|
||||
|
||||
public KFXEditableStringAreaHtmlTableCellBackup20220409(PropConfig config, KFXTextLocator textLocator) {
|
||||
super();
|
||||
this.config = config;
|
||||
this.textLocator = textLocator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startEdit() {
|
||||
if (editableProperty().get()) {
|
||||
if (!isEmpty()) {
|
||||
super.startEdit();
|
||||
createTextField();
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startEdit(int temp) {
|
||||
if (isEditing()) {
|
||||
System.out.println("=====>" + temp);
|
||||
textArea.positionCaret(temp);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean showWebView() {
|
||||
Object obj = super.getTableRow().getItem();
|
||||
boolean showWebView = true;
|
||||
if (obj != null && (obj instanceof KTableRow)) {
|
||||
showWebView = ((KTableRow) obj).showWebView();
|
||||
}
|
||||
return showWebView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelEdit() {
|
||||
super.cancelEdit();
|
||||
// setText((String) getItem());
|
||||
// setGraphic(null);
|
||||
if (showWebView()) {
|
||||
setGraphic(webView);
|
||||
} else {
|
||||
setGraphic(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
// if (webView == null) {
|
||||
// createWebView();
|
||||
// }
|
||||
if (text == null) {
|
||||
text = new Text();
|
||||
text.wrappingWidthProperty().bind(getTableColumn().widthProperty().subtract(20));
|
||||
text.textProperty().bind(itemProperty());
|
||||
text.getStyleClass().add("ktext");
|
||||
}
|
||||
boolean showWebView = showWebView();
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else if (showWebView) {
|
||||
String newValue = item;
|
||||
String html = KUtil.isEmpty(newValue) || newValue.startsWith("<html>") ? newValue : GenerateGDTHTML.generatePage(newValue);
|
||||
createWebView(html);
|
||||
// webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// Platform.runLater(() -> {
|
||||
// try {
|
||||
// // System.out.println("Load Html: " + newValue);
|
||||
// // System.out.println(">> " + html);
|
||||
// String html = newValue == null || newValue.startsWith("<html>") ? newValue :
|
||||
// GenerateGDTHTML.generatePage(newValue);
|
||||
// webView.getEngine().loadContent(html);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
// setGraphic(webView);
|
||||
} else {
|
||||
if (isEditing()) {
|
||||
if (textArea != null) {
|
||||
textArea.setText(getString());
|
||||
// textArea.selectAll();
|
||||
}
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
} else {
|
||||
setGraphic(text);
|
||||
// setText(getString());
|
||||
// setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTextField() {
|
||||
if (textArea == null) {
|
||||
textArea = new TextArea();
|
||||
textArea.setWrapText(true);
|
||||
if (FONTSIZE > 0) {
|
||||
try {
|
||||
textArea.setFont(Font.font(FONTSIZE));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
textArea.setOnKeyPressed((ke) -> {
|
||||
if (ke.getCode().equals(KeyCode.ESCAPE)) {
|
||||
textArea.focusedProperty().removeListener(changeListener);
|
||||
cancelEdit();
|
||||
}
|
||||
if (ke.getCode().equals(KeyCode.TAB)) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
});
|
||||
|
||||
if (textLocator != null) {
|
||||
textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
if (newValue) {
|
||||
System.out.println("focus get:" + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
textLocator.updateControl(KFXEditableStringAreaHtmlTableCellBackup20220409.this);
|
||||
} else {
|
||||
System.out.println("focus lost: " + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
}
|
||||
}
|
||||
});
|
||||
textArea.caretPositionProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
||||
if (textArea.isFocused()) {
|
||||
System.out.println("caret: " + oldValue + " -> " + newValue);
|
||||
Utilities.setPrivateField(textLocator, "currentCaret", newValue.intValue());
|
||||
// textLocator.currentCaret = newValue.intValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
textArea.setText(getString());
|
||||
textArea.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
||||
textArea.setPrefHeight(this.getHeight());
|
||||
textArea.focusedProperty().addListener(changeListener);
|
||||
// textArea.setOnAction(evt -> commitEdit(textField.getText()));
|
||||
}
|
||||
|
||||
protected synchronized void createWebView(String value) {
|
||||
if(webView==null) {
|
||||
webView = new WebView();
|
||||
webView.setCache(false);
|
||||
if (ZOOM != 1) {
|
||||
webView.setZoom(ZOOM);
|
||||
}
|
||||
webView.setPrefHeight(120 * ZOOM);
|
||||
// webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
|
||||
// @Override
|
||||
// public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
|
||||
// if (newValue != State.SUCCEEDED) {
|
||||
// // System.out.println("Load Failed: "+newValue);
|
||||
// webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// KFXEditableStringAreaHtmlTableCell.this.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// Object res = webView.getEngine().executeScript(
|
||||
// "var body = document.body, html = document.documentElement; Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );");
|
||||
// double height = Integer.parseInt(res.toString()) * ZOOM + 20;
|
||||
// webView.setPrefHeight(height);
|
||||
// KFXEditableStringAreaHtmlTableCell.this.setPrefHeight(height);
|
||||
// webView.getEngine().reload();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
WebEngine engine = webView.getEngine();
|
||||
//webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// KFXEditableStringAreaHtmlTableCell.this.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
setGraphic(webView);
|
||||
engine.loadContent(value);
|
||||
engine.reload();
|
||||
// Platform.runLater(()->{
|
||||
// engine.loadContent(value);
|
||||
// });
|
||||
// engine.documentProperty().addListener((obj, prev, newv) -> {
|
||||
// Double height = 20.0;
|
||||
// if(!KUtil.isEmpty(value)) {
|
||||
// String heightText = engine.executeScript("var body = document.body," + "html = document.documentElement;" + "Math.max( body.scrollHeight , body.offsetHeight, "
|
||||
// + "html.clientHeight, html.scrollHeight , html.offsetHeight );").toString();
|
||||
// height = Double.parseDouble(heightText.replace("px", "")) * ZOOM + 10;
|
||||
// }
|
||||
// webView.setPrefHeight(height);
|
||||
// this.setPrefHeight(height);
|
||||
// });
|
||||
webView.setOnScroll(e -> {
|
||||
Event.fireEvent(KFXEditableStringAreaHtmlTableCellBackup20220409.this, e);
|
||||
});
|
||||
if (isEditable()) {
|
||||
webView.setOnMouseClicked(e -> {
|
||||
TableView<T> table = getTableView();
|
||||
if (table == null) {
|
||||
return;
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
int rowNum = row.getIndex();
|
||||
if (rowNum < 0) {
|
||||
return;
|
||||
}
|
||||
TableColumn<T, String> col = getTableColumn();
|
||||
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
table.getSelectionModel().select(rowNum, col);
|
||||
return;
|
||||
}
|
||||
KTableRow bean = (KTableRow) table.getItems().get(rowNum);
|
||||
bean.showWebView(false);
|
||||
updateItem(getItem(), isEmpty());
|
||||
table.layout();
|
||||
table.edit(rowNum, col);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void createWebViewBackup() {
|
||||
webView = new WebView();
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
if (ZOOM != 1) {
|
||||
webView.setZoom(ZOOM);
|
||||
}
|
||||
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
|
||||
if (newValue != State.SUCCEEDED) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Object res = webView.getEngine().executeScript(
|
||||
"var body = document.body, html = document.documentElement; Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );");
|
||||
// System.out.println("Height: " + res);
|
||||
int height = Integer.parseInt(res.toString());
|
||||
// int width = Integer.parseInt(webView.getEngine().executeScript("var body =
|
||||
// document.body, html = document.documentElement; Math.max( body.scrollWidth,
|
||||
// body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth
|
||||
// );").toString());
|
||||
webView.setPrefHeight(height * ZOOM);
|
||||
KFXEditableStringAreaHtmlTableCellBackup20220409.this.setPrefHeight(height * ZOOM + 20);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (isEditable()) {
|
||||
webView.setOnScroll(e -> {
|
||||
Event.fireEvent(getTableColumn(), e);
|
||||
});
|
||||
webView.setOnMouseClicked(e -> {
|
||||
TableView<T> table = getTableView();
|
||||
if (table == null) {
|
||||
return;
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
int rowNum = row.getIndex();
|
||||
if (rowNum < 0) {
|
||||
return;
|
||||
}
|
||||
TableColumn<T, String> col = getTableColumn();
|
||||
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
table.getSelectionModel().select(rowNum, col);
|
||||
return;
|
||||
}
|
||||
KTableRow bean = (KTableRow) table.getItems().get(rowNum);
|
||||
bean.showWebView(false);
|
||||
updateItem(getItem(), isEmpty());
|
||||
table.layout();
|
||||
table.edit(rowNum, col);
|
||||
});
|
||||
// webView.setOnMouseClicked(e -> {
|
||||
// if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
// if (e.getButton() == MouseButton.SECONDARY && e.getClickCount() == 1) {
|
||||
// Object obj = super.getTableRow().getItem();
|
||||
// if (obj != null && (obj instanceof KTableRow)) {
|
||||
// Event.fireEvent(getTableColumn(), e);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// TableRow<?> row = getTableRow();
|
||||
// KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex());
|
||||
// String oldValue = bean.stringProps.get(config).getValueSafe();
|
||||
// System.out.println("Modify [" + row + "]: " + oldValue);
|
||||
// Display localDisplay = Display.getCurrent();
|
||||
// if (localDisplay == null) {
|
||||
// localDisplay = Display.getDefault();
|
||||
// }
|
||||
// GdtEditor editor = new GdtEditor(new JTextArea(oldValue));
|
||||
// editor.setValue(oldValue);
|
||||
// localDisplay.asyncExec(new Runnable() {
|
||||
// public void run() {
|
||||
// Shell localShell = UIUtilities.getCurrentModalShell();
|
||||
// GdtDialog gdtDialog = new GdtDialog(localShell, null, editor, true) {
|
||||
// public boolean close() {
|
||||
// try {
|
||||
// String newValue = editor.getValue();
|
||||
// System.out.println("New Value: " + newValue);
|
||||
// bean.stringProps.get(config).setValue(newValue);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return super.close();
|
||||
// }
|
||||
// };
|
||||
// editor.setGdtDialog(gdtDialog);
|
||||
// gdtDialog.open();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
}
|
||||
// webView.prefWidthProperty().bind(getTableColumn().widthProperty().subtract(20));
|
||||
}
|
||||
|
||||
protected String getString() {
|
||||
return getItem() == null ? "" : getItem().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void commitEdit(String item) {
|
||||
if (isEditing()) {
|
||||
super.commitEdit(item);
|
||||
} else {
|
||||
final TableView table = getTableView();
|
||||
if (table != null) {
|
||||
TablePosition position = new TablePosition(getTableView(), getTableRow().getIndex(), getTableColumn());
|
||||
CellEditEvent editEvent = new CellEditEvent(table, position, TableColumn.editCommitEvent(), item);
|
||||
Event.fireEvent(getTableColumn(), editEvent);
|
||||
}
|
||||
updateItem(item, false);
|
||||
if (table != null) {
|
||||
table.edit(-1, null);
|
||||
}
|
||||
// super.commitEdit(item); // 20201217 bug fix
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
if (row != null && row.getIndex() >= 0) {
|
||||
KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex());
|
||||
bean.showWebView(true);
|
||||
updateItem(item, isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,448 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import com.teamcenter.rac.treetable.SwingTextContextActivator;
|
||||
import com.teamcenter.rac.util.Utilities;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.fx.KFXTextLocator;
|
||||
import cn.net.connor.std.gdtex.KGenerateGDTHTML;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Worker.State;
|
||||
import javafx.event.Event;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableColumn.CellEditEvent;
|
||||
import javafx.scene.control.TablePosition;
|
||||
import javafx.scene.control.TableRow;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
/**
|
||||
* select color:
|
||||
*
|
||||
* .table-row-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-row-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* .table-cell .ktext { -fx-fill: black; }
|
||||
*
|
||||
* .table-cell:selected .ktext { -fx-fill: white; }
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
|
||||
public class KFXEditableStringAreaHtmlTableCellBackup20220509<T, E> extends TableCell<T, String> {
|
||||
|
||||
protected WebView webView;
|
||||
protected PropConfig config;
|
||||
protected TextArea textArea;
|
||||
// private static final Registry REG =
|
||||
// Registry.getRegistry(KFXEditableStringAreaHtmlTableCell.class);
|
||||
private static double ZOOM = 1;
|
||||
private int dy = 1;
|
||||
// private static int FONTSIZE = -1;
|
||||
// static {
|
||||
// try {
|
||||
// // String zoomStr = REG.getString("zoom");
|
||||
// // if (!KUtil.isEmpty(zoomStr)) {
|
||||
// // double d = Double.parseDouble(zoomStr);
|
||||
// // System.out.println("Zoom: " + d);
|
||||
// // ZOOM = d;
|
||||
// // }
|
||||
// // FONTSIZE = REG.getInt("fontsize", -1);
|
||||
// } catch (Exception e) {
|
||||
// }
|
||||
// if (ZOOM < 0) {
|
||||
// ZOOM = 1;
|
||||
// }
|
||||
// }
|
||||
protected ChangeListener<? super Boolean> changeListener = (obs, ov, nv) -> {
|
||||
if (!nv) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
};
|
||||
private Text text;
|
||||
private KFXTextLocator textLocator;
|
||||
|
||||
public KFXEditableStringAreaHtmlTableCellBackup20220509(PropConfig config, KFXTextLocator textLocator) {
|
||||
super();
|
||||
this.config = config;
|
||||
this.textLocator = textLocator;
|
||||
webView = new WebView();
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
webView.getEngine().documentProperty().addListener((obj, prev, newv) -> {
|
||||
try {
|
||||
String heightText = webView.getEngine()
|
||||
.executeScript(
|
||||
"var body = document.body, html = document.documentElement;Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );")
|
||||
.toString();
|
||||
double height = Double.parseDouble(heightText.replace("px", "")) * ZOOM;
|
||||
webView.setPrefHeight(height);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
|
||||
if (newValue != State.SUCCEEDED) {
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.localToSceneTransformProperty().addListener((obs, oldIndex, newIndex) -> {
|
||||
if (getGraphic() == webView) {
|
||||
try {
|
||||
webView.getEngine().reload();
|
||||
webView.setPrefHeight(webView.getPrefHeight() + dy);
|
||||
dy = -dy;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
webView.setOnScroll(e -> {
|
||||
Event.fireEvent(KFXEditableStringAreaHtmlTableCellBackup20220509.this, e);
|
||||
});
|
||||
if (isEditable()) {
|
||||
webView.setOnMouseClicked(e -> {
|
||||
TableView<T> table = getTableView();
|
||||
if (table == null) {
|
||||
return;
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
int rowNum = row.getIndex();
|
||||
if (rowNum < 0) {
|
||||
return;
|
||||
}
|
||||
TableColumn<T, String> col = getTableColumn();
|
||||
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
table.getSelectionModel().select(rowNum, col);
|
||||
return;
|
||||
}
|
||||
KTableRow bean = (KTableRow) table.getItems().get(rowNum);
|
||||
bean.showWebView(false);
|
||||
updateItem(getItem(), isEmpty());
|
||||
table.layout();
|
||||
table.edit(rowNum, col);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startEdit() {
|
||||
if (editableProperty().get()) {
|
||||
if (!isEmpty()) {
|
||||
super.startEdit();
|
||||
createTextField();
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startEdit(int temp) {
|
||||
if (isEditing()) {
|
||||
System.out.println("=====>" + temp);
|
||||
textArea.positionCaret(temp);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean showWebView() {
|
||||
Object obj = super.getTableRow().getItem();
|
||||
boolean showWebView = true;
|
||||
if (obj != null && (obj instanceof KTableRow)) {
|
||||
showWebView = ((KTableRow) obj).showWebView();
|
||||
}
|
||||
return showWebView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelEdit() {
|
||||
super.cancelEdit();
|
||||
// setText((String) getItem());
|
||||
// setGraphic(null);
|
||||
if (showWebView()) {
|
||||
setGraphic(webView);
|
||||
} else {
|
||||
setGraphic(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
// if (webView == null) {
|
||||
// createWebView();
|
||||
// }
|
||||
if (text == null) {
|
||||
text = new Text();
|
||||
text.wrappingWidthProperty().bind(getTableColumn().widthProperty().subtract(20));
|
||||
text.textProperty().bind(itemProperty());
|
||||
text.getStyleClass().add("ktext");
|
||||
}
|
||||
boolean showWebView = showWebView();
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else if (showWebView) {
|
||||
String newValue = item;
|
||||
String html = KUtil.isEmpty(newValue) || newValue.startsWith("<html>") ? newValue : KGenerateGDTHTML.generatePage(newValue);
|
||||
createWebView(html);
|
||||
// webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// Platform.runLater(() -> {
|
||||
// try {
|
||||
// // System.out.println("Load Html: " + newValue);
|
||||
// // System.out.println(">> " + html);
|
||||
// String html = newValue == null || newValue.startsWith("<html>") ? newValue :
|
||||
// GenerateGDTHTML.generatePage(newValue);
|
||||
// webView.getEngine().loadContent(html);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
// setGraphic(webView);
|
||||
} else {
|
||||
if (isEditing()) {
|
||||
if (textArea != null) {
|
||||
textArea.setText(getString());
|
||||
// textArea.selectAll();
|
||||
}
|
||||
setText(null);
|
||||
setGraphic(textArea);
|
||||
} else {
|
||||
setGraphic(text);
|
||||
// setText(getString());
|
||||
// setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTextField() {
|
||||
if (textArea == null) {
|
||||
textArea = new TextArea();
|
||||
textArea.setWrapText(true);
|
||||
// if (FONTSIZE > 0) {
|
||||
// try {
|
||||
// textArea.setFont(Font.font(FONTSIZE));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
textArea.setOnKeyPressed((ke) -> {
|
||||
if (ke.getCode().equals(KeyCode.ESCAPE)) {
|
||||
textArea.focusedProperty().removeListener(changeListener);
|
||||
cancelEdit();
|
||||
}
|
||||
if (ke.getCode().equals(KeyCode.TAB)) {
|
||||
commitEdit(textArea.getText());
|
||||
}
|
||||
});
|
||||
textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
|
||||
if(arg2) {
|
||||
SwingTextContextActivator.instance().activateContext();
|
||||
}else {
|
||||
SwingTextContextActivator.instance().deactivateContext();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (textLocator != null) {
|
||||
textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
if (newValue) {
|
||||
System.out.println("focus get:" + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
textLocator.updateControl(KFXEditableStringAreaHtmlTableCellBackup20220509.this);
|
||||
} else {
|
||||
System.out.println("focus lost: " + getTableColumn().getText() + ":" + getTableRow().getIndex());
|
||||
}
|
||||
}
|
||||
});
|
||||
textArea.caretPositionProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
||||
if (textArea.isFocused()) {
|
||||
System.out.println("caret: " + oldValue + " -> " + newValue);
|
||||
Utilities.setPrivateField(textLocator, "currentCaret", newValue.intValue());
|
||||
// textLocator.currentCaret = newValue.intValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
textArea.setText(getString());
|
||||
textArea.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
||||
textArea.setPrefHeight(this.getHeight());
|
||||
textArea.focusedProperty().addListener(changeListener);
|
||||
// textArea.setOnAction(evt -> commitEdit(textField.getText()));
|
||||
}
|
||||
|
||||
protected synchronized void createWebView(String value) {
|
||||
// webWrapper.styleProperty().setValue("-fx-border-color: blue");
|
||||
setGraphic(webView);
|
||||
WebEngine engine = webView.getEngine();
|
||||
// webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
// KFXEditableStringAreaHtmlTableCell.this.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
engine.loadContent(value);
|
||||
// Platform.runLater(()->{
|
||||
// engine.loadContent(value);
|
||||
// });
|
||||
// engine.documentProperty().addListener((obj, prev, newv) -> {
|
||||
// Double height = 20.0;
|
||||
// if(!KUtil.isEmpty(value)) {
|
||||
// String heightText = engine.executeScript("var body = document.body," + "html
|
||||
// = document.documentElement;" + "Math.max( body.scrollHeight ,
|
||||
// body.offsetHeight, "
|
||||
// + "html.clientHeight, html.scrollHeight , html.offsetHeight );").toString();
|
||||
// height = Double.parseDouble(heightText.replace("px", "")) * ZOOM + 10;
|
||||
// }
|
||||
// webView.setPrefHeight(height);
|
||||
// this.setPrefHeight(height);
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
protected void createWebViewBackup() {
|
||||
WebView webView = new WebView();
|
||||
webView.setPrefHeight(Region.USE_COMPUTED_SIZE);
|
||||
if (ZOOM != 1) {
|
||||
webView.setZoom(ZOOM);
|
||||
}
|
||||
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
|
||||
if (newValue != State.SUCCEEDED) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Object res = webView.getEngine().executeScript(
|
||||
"var body = document.body, html = document.documentElement; Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );");
|
||||
// System.out.println("Height: " + res);
|
||||
int height = Integer.parseInt(res.toString());
|
||||
// int width = Integer.parseInt(webView.getEngine().executeScript("var body =
|
||||
// document.body, html = document.documentElement; Math.max( body.scrollWidth,
|
||||
// body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth
|
||||
// );").toString());
|
||||
webView.setPrefHeight(height * ZOOM);
|
||||
KFXEditableStringAreaHtmlTableCellBackup20220509.this.setPrefHeight(height * ZOOM + 20);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (isEditable()) {
|
||||
webView.setOnScroll(e -> {
|
||||
Event.fireEvent(getTableColumn(), e);
|
||||
});
|
||||
webView.setOnMouseClicked(e -> {
|
||||
TableView<T> table = getTableView();
|
||||
if (table == null) {
|
||||
return;
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
int rowNum = row.getIndex();
|
||||
if (rowNum < 0) {
|
||||
return;
|
||||
}
|
||||
TableColumn<T, String> col = getTableColumn();
|
||||
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
table.getSelectionModel().select(rowNum, col);
|
||||
return;
|
||||
}
|
||||
KTableRow bean = (KTableRow) table.getItems().get(rowNum);
|
||||
bean.showWebView(false);
|
||||
updateItem(getItem(), isEmpty());
|
||||
table.layout();
|
||||
table.edit(rowNum, col);
|
||||
});
|
||||
// webView.setOnMouseClicked(e -> {
|
||||
// if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
// if (e.getButton() == MouseButton.SECONDARY && e.getClickCount() == 1) {
|
||||
// Object obj = super.getTableRow().getItem();
|
||||
// if (obj != null && (obj instanceof KTableRow)) {
|
||||
// Event.fireEvent(getTableColumn(), e);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// TableRow<?> row = getTableRow();
|
||||
// KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex());
|
||||
// String oldValue = bean.stringProps.get(config).getValueSafe();
|
||||
// System.out.println("Modify [" + row + "]: " + oldValue);
|
||||
// Display localDisplay = Display.getCurrent();
|
||||
// if (localDisplay == null) {
|
||||
// localDisplay = Display.getDefault();
|
||||
// }
|
||||
// GdtEditor editor = new GdtEditor(new JTextArea(oldValue));
|
||||
// editor.setValue(oldValue);
|
||||
// localDisplay.asyncExec(new Runnable() {
|
||||
// public void run() {
|
||||
// Shell localShell = UIUtilities.getCurrentModalShell();
|
||||
// GdtDialog gdtDialog = new GdtDialog(localShell, null, editor, true) {
|
||||
// public boolean close() {
|
||||
// try {
|
||||
// String newValue = editor.getValue();
|
||||
// System.out.println("New Value: " + newValue);
|
||||
// bean.stringProps.get(config).setValue(newValue);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return super.close();
|
||||
// }
|
||||
// };
|
||||
// editor.setGdtDialog(gdtDialog);
|
||||
// gdtDialog.open();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
}
|
||||
// webView.prefWidthProperty().bind(getTableColumn().widthProperty().subtract(20));
|
||||
}
|
||||
|
||||
protected String getString() {
|
||||
return getItem() == null ? "" : getItem().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void commitEdit(String item) {
|
||||
if (isEditing()) {
|
||||
super.commitEdit(item);
|
||||
} else {
|
||||
final TableView table = getTableView();
|
||||
if (table != null) {
|
||||
TablePosition position = new TablePosition(getTableView(), getTableRow().getIndex(), getTableColumn());
|
||||
CellEditEvent editEvent = new CellEditEvent(table, position, TableColumn.editCommitEvent(), item);
|
||||
Event.fireEvent(getTableColumn(), editEvent);
|
||||
}
|
||||
updateItem(item, false);
|
||||
if (table != null) {
|
||||
table.edit(-1, null);
|
||||
}
|
||||
// super.commitEdit(item); // 20201217 bug fix
|
||||
}
|
||||
TableRow<?> row = getTableRow();
|
||||
if (row != null && row.getIndex() >= 0) {
|
||||
KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex());
|
||||
bean.showWebView(true);
|
||||
updateItem(item, isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
|
||||
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.net.connor.std.processedit.meopviewfx.ui.MEOPPanelController">
|
||||
<children>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||
<center>
|
||||
<SplitPane dividerPositions="1.0" prefHeight="160.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<SplitPane dividerPositions="0.4" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
|
||||
<items>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||
<center>
|
||||
<TableView fx:id="table1" editable="true" prefHeight="200.0" prefWidth="200.0" style="-fx-faint-focus-color: transparent; -fx-focus-color: rgba(0,0,0,0.2); -fx-background-insets: 0;" styleClass="dark-table" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
<BorderPane minHeight="0.0">
|
||||
<top>
|
||||
<ScrollPane fitToWidth="true" style="-fx-background-insets: 0;">
|
||||
<content>
|
||||
<FlowPane fx:id="propPane" hgap="8.0" vgap="5.0" BorderPane.alignment="CENTER">
|
||||
<BorderPane.margin>
|
||||
<Insets bottom="5.0" />
|
||||
</BorderPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</FlowPane>
|
||||
</content>
|
||||
<BorderPane.margin>
|
||||
<Insets bottom="5.0" />
|
||||
</BorderPane.margin>
|
||||
</ScrollPane>
|
||||
</top>
|
||||
<center>
|
||||
<TableView fx:id="table2" editable="true" minHeight="0.0" prefHeight="200.0" prefWidth="200.0" style="-fx-faint-focus-color: transparent; -fx-focus-color: rgba(0,0,0,0.2);" visible="false" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
<right>
|
||||
<VBox fx:id="buttonBox" minHeight="0.0" spacing="5.0" visible="false" BorderPane.alignment="CENTER">
|
||||
<padding>
|
||||
<Insets left="5.0" />
|
||||
</padding>
|
||||
<children>
|
||||
<Button fx:id="b_AddRow" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#addRowButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<Button fx:id="b_DelRow" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#delRowButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<Button fx:id="b_MoveUp" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#moveUpButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<Button fx:id="b_MoveDown" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#moveDownButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<!--Button fx:id="b_Symbol" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#symbolButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<Button fx:id="b_Reorder" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#reorderButtonClicked" prefHeight="25.0" prefWidth="25.0" />
|
||||
<Button fx:id="b_Search" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#searchButtonClicked" prefHeight="25.0" prefWidth="25.0" /-->
|
||||
</children>
|
||||
</VBox>
|
||||
</right>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</BorderPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
<TabPane fx:id="textTab" prefHeight="200.0" prefWidth="200.0" side="RIGHT" tabClosingPolicy="UNAVAILABLE" />
|
||||
</items>
|
||||
</SplitPane>
|
||||
</center>
|
||||
<bottom>
|
||||
<GridPane hgap="20.0" BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button mnemonicParsing="false" onAction="#reloadDataButtonClick" text=" 更新 " />
|
||||
<Button mnemonicParsing="false" onAction="#saveButtonClick" text=" 保存 " GridPane.columnIndex="1" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="10.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</GridPane>
|
||||
</bottom>
|
||||
</BorderPane>
|
||||
<AnchorPane fx:id="cover" prefHeight="200.0" prefWidth="200.0" visible="false">
|
||||
<children>
|
||||
<ProgressIndicator prefHeight="30.0" prefWidth="30.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</StackPane>
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.pse.common.BOMLineNode;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import cn.net.connor.std.fx.KFXPanel;
|
||||
|
||||
public class MEOPPanel extends KFXPanel{
|
||||
|
||||
private MEOPPanelController controller;
|
||||
|
||||
public MEOPPanel(Window dialog) {
|
||||
super(dialog, MEOPPanel.class, "style.css");
|
||||
this.controller = (MEOPPanelController)aifController;
|
||||
initData();
|
||||
}
|
||||
|
||||
public void refreshUI(TCComponentBOMLine targetLine) throws Exception{
|
||||
this.controller.refreshUI(targetLine);
|
||||
}
|
||||
|
||||
public synchronized void updateSelection(Object targetObj) {
|
||||
System.out.println("Update: "+targetObj);
|
||||
if (targetObj != null && targetObj instanceof AIFComponentContext) {
|
||||
targetObj = ((AIFComponentContext) targetObj).getComponent();
|
||||
}
|
||||
if (targetObj != null && targetObj instanceof BOMLineNode) {
|
||||
targetObj = ((BOMLineNode) targetObj).getComponent();
|
||||
}
|
||||
if (targetObj == null || !(targetObj instanceof TCComponentBOMLine)) {
|
||||
} else {
|
||||
TCComponentBOMLine targetLine = (TCComponentBOMLine) targetObj;
|
||||
try {
|
||||
refreshUI(targetLine);
|
||||
} catch (Exception e) {
|
||||
MessageBox.post(getParentDialog(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,473 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.cme.application.MFGLegacyApplication;
|
||||
import com.teamcenter.rac.cme.framework.treetable.CMEBOMTreeTable;
|
||||
import com.teamcenter.rac.cme.framework.views.primary.BOMPrimaryView;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PlatformHelper;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.fx.KFXPanel;
|
||||
import cn.net.connor.std.fx.KFXPanelController;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.TextBean;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class MEOPPanelController extends KFXPanelController {
|
||||
|
||||
public static final String PREF_BOM_TABLE = "Connor_AVIC_GXBZ_Bomline";
|
||||
public static final String PREF_PREFIX_BOM_TABLE_WITH_TYPE = "Connor_AVIC_GXBZ_";
|
||||
public static final String PREF_PREFIX_PROP_FLOW_WITH_TYPE = "Connor_AVIC_GXBZ_Property_";
|
||||
public static final String PREF_PREFIX_SEARCH_BY_SQL = "Connor_AVIC_GXBZ_SelectSql_";
|
||||
|
||||
@FXML
|
||||
private TableView<KTableRow> table1;
|
||||
@FXML
|
||||
private TableView<KTableRow> table2;
|
||||
@FXML
|
||||
private FlowPane propPane;
|
||||
@FXML
|
||||
private AnchorPane cover;
|
||||
@FXML
|
||||
private Button b_AddRow;
|
||||
@FXML
|
||||
private Button b_DelRow;
|
||||
@FXML
|
||||
private Button b_MoveUp;
|
||||
@FXML
|
||||
private Button b_MoveDown;
|
||||
@FXML
|
||||
private Button b_Reorder;
|
||||
@FXML
|
||||
private VBox buttonBox;
|
||||
@FXML
|
||||
private TabPane textTab;
|
||||
@FXML
|
||||
private Button b_Symbol;
|
||||
@FXML
|
||||
private Button b_Search;
|
||||
private boolean busy = false;
|
||||
|
||||
private TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
||||
private TableLoader table1Loader = new TableLoader(session);
|
||||
private TableLoader table2Loader;
|
||||
private PropFlowLoader propLoader = new PropFlowLoader(session);
|
||||
private static final Registry REG = Registry.getRegistry(MEOPPanelController.class);
|
||||
|
||||
// private MEOPPanel panel;
|
||||
|
||||
public Image folder = new Image(MEOPPanelController.class.getResourceAsStream("/icons/folder_24.png"), 18, 18, true, false);
|
||||
public Image text = new Image(MEOPPanelController.class.getResourceAsStream("/icons/text.png"), 18, 18, true, false);
|
||||
private TCComponentBOMLine targetLine;
|
||||
private CMEBOMTreeTable bomTreeTable;
|
||||
private MFGLegacyApplication bomApp;
|
||||
private BOMPrimaryView bomView;
|
||||
|
||||
@Override
|
||||
public void initData(KFXPanel panel) throws Exception {
|
||||
// this.panel = (MEOPPanel) panel;
|
||||
// table1.getSelectionModel().setCellSelectionEnabled(true);
|
||||
// table2.getSelectionModel().setCellSelectionEnabled(true);
|
||||
b_AddRow.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/add_24px.png"), 19, 19, true, false)));
|
||||
b_DelRow.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/delete_24px.png"), 19, 19, true, false)));
|
||||
b_MoveUp.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/up_24px.png"), 19, 19, true, false)));
|
||||
b_MoveDown.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/down_24px.png"), 19, 19, true, false)));
|
||||
if(b_Reorder!=null)
|
||||
b_Reorder.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/sort-line-2.png"), 19, 19, true, false)));
|
||||
if(b_Symbol!=null)
|
||||
b_Symbol.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/T.png"), 19, 19, true, false)));
|
||||
if(b_Search!=null)
|
||||
b_Search.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/search-2.png"), 19, 19, true, false)));
|
||||
table1.setVisible(table1Loader.load(table1, PREF_BOM_TABLE));
|
||||
if (table1.isVisible()) {
|
||||
String colName = REG.getString("index.COL");
|
||||
TableColumn<KTableRow, String> c = new TableColumn<KTableRow, String>(colName);
|
||||
c.setCellFactory(col -> new TableCell<KTableRow, String>() {
|
||||
@Override
|
||||
public void updateIndex(int index) {
|
||||
super.updateIndex(index);
|
||||
if (isEmpty() || index < 0) {
|
||||
setText(null);
|
||||
} else {
|
||||
setText(Integer.toString(index + 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
Platform.runLater(() -> {
|
||||
c.setEditable(false);
|
||||
c.setSortable(false);
|
||||
c.setPrefWidth(70);
|
||||
table1.getColumns().add(0, c);
|
||||
});
|
||||
}
|
||||
textTab.getTabs().clear();
|
||||
// load special text
|
||||
Map<String, TextBean> textMap = new TextTreeLoader(session).loadText();
|
||||
for (String sheetName : textMap.keySet()) {
|
||||
TextBean bean = textMap.get(sheetName);
|
||||
Tab tab = new Tab(sheetName);
|
||||
textTab.getTabs().add(tab);
|
||||
TreeView<TextBean> tree = new TreeView<TextBean>();
|
||||
TreeItem<TextBean> rootNode = new TreeItem<TextBean>(bean, new ImageView(folder));
|
||||
tree.setRoot(rootNode);
|
||||
tree.setShowRoot(false);
|
||||
rootNode.setExpanded(true);
|
||||
loadTree(rootNode, bean);
|
||||
tab.setContent(tree);
|
||||
tree.setOnMouseClicked(e -> {
|
||||
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
|
||||
return;
|
||||
}
|
||||
TreeItem<TextBean> treeItem = tree.getSelectionModel().getSelectedItem();
|
||||
if (treeItem.getChildren().size() > 0) {
|
||||
return;
|
||||
}
|
||||
String text = treeItem.getValue().getRealValue();
|
||||
System.out.println("Insert: " + text);
|
||||
long time = Math.max(table1Loader.focuseTime, table2Loader.focuseTime);
|
||||
time = Math.max(time, propLoader.focuseTime);
|
||||
if (propLoader.focuseTime == time) {
|
||||
propLoader.insertText(text);
|
||||
}
|
||||
if (table1Loader.focuseTime == time) {
|
||||
table1Loader.insertText(text);
|
||||
}
|
||||
if (table2Loader.focuseTime == time) {
|
||||
String parentText = treeItem.getParent() == null ? "" : treeItem.getParent().getValue().getRealValue();
|
||||
table2Loader.insertText(text, parentText);
|
||||
}
|
||||
});
|
||||
}
|
||||
table2.getSelectionModel().selectedItemProperty().addListener(e -> {
|
||||
try {
|
||||
int index = table2.getSelectionModel().getSelectedIndex();
|
||||
System.out.println("Select Table2: " + index);
|
||||
KTableRow row = table2.getSelectionModel().getSelectedItem();
|
||||
TCComponentBOMLine bomLine = row == null ? null : row.getBomLine();
|
||||
System.out.println(">> bomline: " + bomLine);
|
||||
if (bomLine == null) {
|
||||
bomLine = targetLine;
|
||||
}
|
||||
if (!bomLine.equals(table1Loader.targetLine)) {
|
||||
table1Loader.loadTCData(bomLine, true);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(e1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initBomTreeTableInfo() throws Exception {
|
||||
this.bomTreeTable = null;
|
||||
this.bomApp = null;
|
||||
this.bomView = null;
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
TCComponentBOMWindow bomWindow = targetLine.window();
|
||||
System.out.println(">> BomWindow: " + bomWindow);
|
||||
System.out.println(">> " + app.getClass());
|
||||
if (app instanceof MFGLegacyApplication) {
|
||||
this.bomApp = (MFGLegacyApplication) app;
|
||||
List<Object> viewParts = PlatformHelper.getAllViewParts();
|
||||
IWorkbenchWindow var1 = AIFUtility.getActiveDesktop().getDesktopWindow();
|
||||
IWorkbenchPage page = var1.getActivePage();
|
||||
for (Object viewPart : viewParts) {
|
||||
if (viewPart == null || !(viewPart instanceof CompatibilityView)) {
|
||||
continue;
|
||||
}
|
||||
IViewPart view = ((CompatibilityView) viewPart).getView();
|
||||
if (view == null || !(view instanceof BOMPrimaryView)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BOMPrimaryView bomView = (BOMPrimaryView) view;
|
||||
CMEBOMTreeTable treeTable = bomView.getBOMTreeTable();
|
||||
if (treeTable == null) {
|
||||
continue;
|
||||
}
|
||||
boolean visible = page.isPartVisible(view);
|
||||
System.out.println(">> BOMPrimaryView: [" + visible + "]" + bomView);
|
||||
if (!visible) {
|
||||
continue;
|
||||
}
|
||||
if (treeTable.getBOMWindow() == bomWindow) {
|
||||
System.out.println(">>>>> find window");
|
||||
TCComponentBOMLine[] bomlines = treeTable.getSelectedBOMLines();
|
||||
System.out.println(">> Selected lines: " + Arrays.toString(bomlines));
|
||||
boolean findLine = false;
|
||||
int bomLineCnt = KUtil.getLen(bomlines);
|
||||
for (int i = 0; i < bomLineCnt; i++) {
|
||||
if (targetLine == bomlines[i]) {
|
||||
findLine = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findLine) {
|
||||
System.out.println(">>>>> Find targetline");
|
||||
this.bomTreeTable = treeTable;
|
||||
this.bomView = bomView;
|
||||
// Display.getDefault().syncExec(()->{
|
||||
// view.setFocus();
|
||||
// });
|
||||
// treeTable.setRefreshingBOM();
|
||||
// ((MFGLegacyApplication) app).refreshBOM();
|
||||
// treeTable.refreshBOMLine(targetLine, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void reloadDataButtonClick() {
|
||||
new Thread(() -> {
|
||||
session.setStatus("Reloading...");
|
||||
setProgressVisible(true);
|
||||
try {
|
||||
reloadData(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
setProgressVisible(false);
|
||||
System.out.println("Reload Complete");
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void saveButtonClick() {
|
||||
if (this.bomView != null) {
|
||||
Display.getDefault().syncExec(() -> {
|
||||
this.bomView.setFocus();
|
||||
});
|
||||
}
|
||||
new Thread(() -> {
|
||||
session.setStatus("Saving...");
|
||||
setProgressVisible(true);
|
||||
if (this.bomTreeTable != null) {
|
||||
try {
|
||||
this.bomTreeTable.setRefreshingBOM();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
saveData();
|
||||
reloadData(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
if (this.bomApp != null) {
|
||||
try {
|
||||
this.bomApp.refreshBOM();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
setProgressVisible(false);
|
||||
System.out.println("Save Complete");
|
||||
}).start();
|
||||
}
|
||||
|
||||
public synchronized void reloadData(TCComponentBOMLine targetLine) throws Exception {
|
||||
if (targetLine == null) {
|
||||
targetLine = this.targetLine;
|
||||
// AIFComponentContext cc =
|
||||
// AIFUtility.getCurrentApplication().getTargetContext();
|
||||
// System.out.println("Select: "+cc);
|
||||
// if(cc!=null&&cc.getComponent()!=null&&(cc.getComponent() instanceof
|
||||
// TCComponentBOMLine)){
|
||||
// targetLine = (TCComponentBOMLine) cc.getComponent();
|
||||
// }
|
||||
}
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
this.targetLine = targetLine;
|
||||
System.out.println("Load Line: " + targetLine);
|
||||
initBomTreeTableInfo();
|
||||
TCComponentItemType itemType = targetLine == null ? null : targetLine.getItem().getTypeComponent();
|
||||
String prefName = itemType == null ? null : PREF_PREFIX_BOM_TABLE_WITH_TYPE + itemType.getTypeName();
|
||||
if (TableLoaderMEActivity.isActivityConfig(session, prefName)) {
|
||||
table2Loader = new TableLoaderMEActivity(session);
|
||||
} else {
|
||||
table2Loader = new TableLoader(session);
|
||||
}
|
||||
boolean table2Visible = table2Loader.load(table2, prefName);
|
||||
String prefName2 = itemType == null ? null : PREF_PREFIX_PROP_FLOW_WITH_TYPE + itemType.getTypeName();
|
||||
boolean propVisible = propLoader.load(propPane, prefName2, itemType);
|
||||
if (!Platform.isFxApplicationThread()) {
|
||||
Platform.runLater(() -> {
|
||||
table2.setVisible(table2Visible);
|
||||
buttonBox.setVisible(table2Visible);
|
||||
propPane.setVisible(propVisible);
|
||||
try {
|
||||
propLoader.loadTCData(this.targetLine);
|
||||
table1Loader.loadTCData(this.targetLine, true);
|
||||
table2Loader.loadTCData(this.targetLine, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
table2.setVisible(table2Visible);
|
||||
buttonBox.setVisible(table2Visible);
|
||||
propPane.setVisible(propVisible);
|
||||
propLoader.loadTCData(targetLine);
|
||||
table1Loader.loadTCData(targetLine, true);
|
||||
table2Loader.loadTCData(targetLine, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveData() throws Exception {
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
propLoader.saveTCData(targetLine);
|
||||
table1Loader.saveTCData();
|
||||
table2Loader.saveTCData();
|
||||
targetLine.refresh();
|
||||
// session.refresh();
|
||||
// AIFUtility.getCurrentApplication().refresh();
|
||||
}
|
||||
|
||||
private void loadTree(TreeItem<TextBean> rootNode, TextBean bean) {
|
||||
int childCnt = bean.children.size();
|
||||
for (int i = 0; i < childCnt; i++) {
|
||||
TextBean childBean = bean.children.get(i);
|
||||
boolean isFolder = childBean.children.size() > 0;
|
||||
TreeItem<TextBean> cNode = isFolder ? new TreeItem<TextBean>(childBean, new ImageView(folder)) : new TreeItem<TextBean>(childBean, new ImageView(text));
|
||||
rootNode.getChildren().add(cNode);
|
||||
if (isFolder) {
|
||||
loadTree(cNode, childBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshUI(TCComponentBOMLine targetLine) throws Exception {
|
||||
if (busy) {
|
||||
System.out.println("Task Running. Skip load: " + targetLine);
|
||||
return;
|
||||
}
|
||||
setProgressVisible(true);
|
||||
try {
|
||||
reloadData(targetLine);
|
||||
} finally {
|
||||
setProgressVisible(false);
|
||||
}
|
||||
// this.targetLine = targetLine;
|
||||
// TCComponentItemType itemType = targetLine == null ? null :
|
||||
// targetLine.getItem().getTypeComponent();
|
||||
// String prefName = itemType == null ? null : PREF_PREFIX_BOM_TABLE_WITH_TYPE +
|
||||
// itemType.getTypeName();
|
||||
// boolean table2Visible = table2Loader.load(table2, prefName);
|
||||
// String prefName2 = itemType == null ? null : PREF_PREFIX_PROP_FLOW_WITH_TYPE
|
||||
// + itemType.getTypeName();
|
||||
// boolean propVisible = propLoader.load(propPane, prefName2, itemType);
|
||||
// Platform.runLater(() -> {
|
||||
// table2.setVisible(table2Visible);
|
||||
// buttonBox.setVisible(table2Visible);
|
||||
// propPane.setVisible(propVisible);
|
||||
// });
|
||||
// reloadData();
|
||||
}
|
||||
|
||||
public void addRowButtonClicked() {
|
||||
table2Loader.addRow();
|
||||
}
|
||||
|
||||
public void delRowButtonClicked() {
|
||||
table2Loader.removeRow();
|
||||
}
|
||||
|
||||
public void moveUpButtonClicked() {
|
||||
table2Loader.moveUp();
|
||||
}
|
||||
|
||||
public void moveDownButtonClicked() {
|
||||
table2Loader.moveDown();
|
||||
}
|
||||
|
||||
public void reorderButtonClicked() {
|
||||
try {
|
||||
table2Loader.reorder();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void symbolButtonClicked() {
|
||||
try {
|
||||
table2Loader.editSymbol();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void searchButtonClicked() {
|
||||
try {
|
||||
TCComponentItemType itemType = targetLine == null ? null : targetLine.getItem().getTypeComponent();
|
||||
String prefName = itemType == null ? null : PREF_PREFIX_SEARCH_BY_SQL + itemType.getTypeName();
|
||||
table2Loader.doSearch(prefName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgressVisible(boolean visible) {
|
||||
this.busy = visible;
|
||||
if (cover != null) {
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
cover.setVisible(visible);
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
cover.setVisible(visible);
|
||||
});
|
||||
}
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,374 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLineType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentListOfValues;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCProperty;
|
||||
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.treetable.SwingTextContextActivator;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.fx.KFXTextLocator;
|
||||
import cn.net.connor.std.fx.KLOVComboBox;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextInputControl;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.Region;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class PropFlowLoader extends KFXTextLocator {
|
||||
|
||||
protected List<PropConfig> propConfigs = new ArrayList<PropConfig>();
|
||||
private TCSession session;
|
||||
private static final Registry REG = Registry.getRegistry(PropFlowLoader.class);
|
||||
|
||||
public PropFlowLoader(TCSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public boolean load(FlowPane flowPane, String prefName, TCComponentItemType itemType) throws Exception {
|
||||
clearLocatorData();
|
||||
Platform.runLater(() -> {
|
||||
flowPane.getChildren().clear();
|
||||
});
|
||||
propConfigs.clear();
|
||||
if (KUtil.isEmpty(prefName) || itemType == null) {
|
||||
return false;
|
||||
}
|
||||
System.out.println("Load FlowPane from pref: " + prefName);
|
||||
String[] prefVals = KUtil.getPrefVals(session, prefName);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
if (len <= 1) {
|
||||
return false;
|
||||
}
|
||||
System.out.println(">> Item Type: " + itemType.getDisplayTypeName());
|
||||
TCComponentType revMasterType = null;
|
||||
TCComponentBOMLineType bomlineType = null;
|
||||
TCComponentItemRevisionType revType = itemType.getItemRevisionType();
|
||||
revMasterType = session.getTypeComponent(revType.getTypeName() + "Master");
|
||||
if (revMasterType == null) {
|
||||
revMasterType = session.getTypeComponent(revType.getTypeName() + " Master");
|
||||
}
|
||||
if (revMasterType == null) {
|
||||
throw new Exception(String.format(REG.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master"));
|
||||
}
|
||||
bomlineType = (TCComponentBOMLineType) session.getTypeComponent("BOMLine");
|
||||
if (bomlineType == null) {
|
||||
throw new Exception(String.format(REG.getString("typenotfound.ERROR1"), "BOMLine"));
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
String propName = prefVals[i];
|
||||
System.out.println("Load Config: " + propName);
|
||||
if (KUtil.isEmpty(propName)) {
|
||||
continue;
|
||||
}
|
||||
String propLoc = KTableRow.REVMASTER;
|
||||
String filterValue = null;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
width = width * 10 + (propName.charAt(0) - '0');
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
if (propName.startsWith("x")) {
|
||||
propName = propName.substring(1);
|
||||
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
height = height * 10 + (propName.charAt(0) - '0');
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
}
|
||||
// while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
// width = width * 10 + (propName.charAt(0) - '0');
|
||||
// propName = propName.substring(1);
|
||||
// }
|
||||
// int ind = propName.indexOf('.');
|
||||
// if (ind > 0) {
|
||||
// propLoc = propName.substring(0, ind);
|
||||
// propName = propName.substring(ind + 1);
|
||||
// }
|
||||
int ind = propName.indexOf('=');
|
||||
if (ind > 0) {
|
||||
filterValue = propName.substring(ind + 1);
|
||||
propName = propName.substring(0, ind);
|
||||
}
|
||||
TCPropertyDescriptor propDesc;
|
||||
if (propName.startsWith("**")) {
|
||||
propLoc = KTableRow.BOMLINE;
|
||||
propName = propName.substring(2);
|
||||
propDesc = bomlineType.getPropDesc(propName);
|
||||
if (propDesc == null) {
|
||||
throw new Exception(String.format(REG.getString("propnotdefinedintype.ERROR2"), propName, bomlineType.getDisplayTypeName()));
|
||||
}
|
||||
} else if (propName.startsWith("*")) {
|
||||
propLoc = KTableRow.REV;
|
||||
propName = propName.substring(1);
|
||||
propDesc = revType.getPropDesc(propName);
|
||||
if (propDesc == null) {
|
||||
throw new Exception(String.format(REG.getString("propnotdefinedintype.ERROR2"), propName, revType.getDisplayTypeName()));
|
||||
}
|
||||
} else {
|
||||
propDesc = revMasterType.getPropDesc(propName);
|
||||
if (propDesc == null) {
|
||||
throw new Exception(String.format(REG.getString("propnotdefinedintype.ERROR2"), propName, revMasterType.getDisplayTypeName()));
|
||||
}
|
||||
}
|
||||
this.propConfigs.add(new PropConfig(propLoc, propDesc, filterValue, width, height, 0));
|
||||
}
|
||||
System.out.println("Load complete");
|
||||
int size = this.propConfigs.size();
|
||||
if (size == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
PropConfig config = propConfigs.get(i);
|
||||
addPropPane(flowPane, config);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void loadTCData(TCComponentBOMLine targetLine) throws Exception {
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
TCComponent revMaster = targetLine == null ? null : targetLine.getItemRevision().getRelatedComponent("IMAN_master_form_rev");
|
||||
TCComponent rev = targetLine == null ? null : targetLine.getItemRevision();
|
||||
int size = this.propConfigs.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < size; j++) {
|
||||
PropConfig config = propConfigs.get(j);
|
||||
Control control = config.getControl();
|
||||
if (control == null) {
|
||||
continue;
|
||||
}
|
||||
TCComponent comp = KTableRow.REV.equals(config.propLoc) ? rev : KTableRow.BOMLINE.equals(config.propLoc) ? targetLine : revMaster;
|
||||
if (control instanceof TextInputControl) {
|
||||
TCPropertyDescriptor propDesc = comp.getTypeComponent().getPropDesc(config.propName);
|
||||
String text;
|
||||
if (propDesc.getType() == TCPropertyDescriptor.SERVER_PROP_double) {
|
||||
double num = comp.getDoubleProperty(config.propName);
|
||||
text = KUtil.isEmpty(comp.getProperty(config.propName)) ? "" : (ProcessUtil.DF.format(num));
|
||||
} else {
|
||||
text = comp.getStringProperty(config.propName);
|
||||
}
|
||||
((TextInputControl) control).setText(text);
|
||||
config.setSavedValue(text);
|
||||
} else if (control instanceof DatePicker) {
|
||||
Date date = comp.getDateProperty(config.propName);
|
||||
((DatePicker) control).setValue(KUtil.dateToLocalDate(date));
|
||||
config.setSavedValue(date);
|
||||
} else if (control instanceof KLOVComboBox) {
|
||||
String text = comp.getStringProperty(config.propName);
|
||||
((KLOVComboBox) control).setValue(text);
|
||||
config.setSavedValue(text);
|
||||
} else if (control instanceof ComboBox) {
|
||||
String text = comp.getStringProperty(config.propName);
|
||||
((ComboBox<String>) control).setValue(text);
|
||||
config.setSavedValue(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTCData(TCComponentBOMLine targetLine) throws Exception {
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Update Property: " + targetLine);
|
||||
TCComponentItemRevision rev = targetLine == null ? null : targetLine.getItemRevision();
|
||||
TCComponent revMaster = targetLine == null ? null : targetLine.getItemRevision().getRelatedComponent("IMAN_master_form_rev");
|
||||
int size = this.propConfigs.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < size; j++) {
|
||||
PropConfig config = propConfigs.get(j);
|
||||
Control control = config.getControl();
|
||||
if (control == null || !config.canEdit) {
|
||||
continue;
|
||||
}
|
||||
TCComponent comp = KTableRow.REV.equals(config.propLoc) ? rev : KTableRow.BOMLINE.equals(config.propLoc) ? targetLine : revMaster;
|
||||
String propName = config.propName;
|
||||
if (control instanceof TextInputControl) {
|
||||
String value = ((TextInputControl) control).getText();
|
||||
if (config.valueChanged(value)) {
|
||||
System.out.println(">> " + propName + " = " + value);
|
||||
comp.setProperty(propName, value);
|
||||
}
|
||||
} else if (control instanceof DatePicker) {
|
||||
Date value = KUtil.localDateToDate(((DatePicker) control).getValue());
|
||||
if (config.valueChanged(value)) {
|
||||
System.out.println(">> " + propName + " = " + value);
|
||||
comp.setDateProperty(propName, value);
|
||||
}
|
||||
} else if (control instanceof KLOVComboBox) {
|
||||
String value = ((KLOVComboBox) control).getSelectionModel().getSelectedItem();
|
||||
if (config.valueChanged(value)) {
|
||||
System.out.println(">> " + propName + " = " + value);
|
||||
comp.setStringProperty(propName, value);
|
||||
}
|
||||
} else if (control instanceof ComboBox) {
|
||||
String value = ((ComboBox<String>) control).getSelectionModel().getSelectedItem();
|
||||
if (config.valueChanged(value)) {
|
||||
System.out.println(">> " + propName + " = " + value);
|
||||
comp.setStringProperty(propName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
rev.refresh();
|
||||
revMaster.refresh();
|
||||
targetLine.refresh();
|
||||
}
|
||||
|
||||
private void addPropPane(FlowPane flowPane, PropConfig config) throws Exception {
|
||||
String title = config.propDisplayName;
|
||||
TCComponentListOfValues lov = config.lov;
|
||||
// HBox propPane = new HBox();
|
||||
BorderPane propPane = new BorderPane();
|
||||
// propPane.setSpacing(5);
|
||||
// propPane.setAlignment(Pos.CENTER_LEFT);
|
||||
propPane.setPrefWidth(280);
|
||||
Label label = new Label(title + " ");
|
||||
label.setAlignment(Pos.CENTER_RIGHT);
|
||||
label.setMinWidth(80);
|
||||
Platform.runLater(() -> {
|
||||
// propPane.getChildren().add(label);
|
||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
||||
propPane.setLeft(label);
|
||||
flowPane.getChildren().add(propPane);
|
||||
});
|
||||
if (config.propDesc.isType(TCProperty.PROP_date)) {
|
||||
DatePicker dp = new DatePicker();
|
||||
config.setControl(dp);
|
||||
dp.setDisable(!config.canEdit);
|
||||
} else if (lov == null) {
|
||||
if (!KUtil.isEmpty(config.filterValue)) {
|
||||
String[] split = config.filterValue.split(";");
|
||||
ComboBox<String> cb = new ComboBox<String>();
|
||||
cb.getItems().add("");
|
||||
for (String string : split) {
|
||||
cb.getItems().add(string);
|
||||
}
|
||||
cb.setMaxWidth(300);
|
||||
config.setControl(cb);
|
||||
cb.setDisable(!config.canEdit);
|
||||
} else {
|
||||
// Text
|
||||
TextInputControl tf;
|
||||
if (config.width > 0 && config.height > 0) {
|
||||
tf = new TextArea();
|
||||
tf.setPrefWidth(config.width);
|
||||
tf.setPrefHeight(config.height);
|
||||
((TextArea)tf).setWrapText(true);
|
||||
propPane.setPrefWidth(Region.USE_COMPUTED_SIZE);
|
||||
} else {
|
||||
tf = new TextField();
|
||||
}
|
||||
config.setControl(tf);
|
||||
tf.setEditable(config.canEdit);
|
||||
tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
if (newValue) {
|
||||
System.out.println("focus get: " + title);
|
||||
updateControl(tf);
|
||||
} else {
|
||||
System.out.println("focus lost: " + title);
|
||||
}
|
||||
}
|
||||
});
|
||||
tf.caretPositionProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
||||
if (tf.isFocused()) {
|
||||
System.out.println("caret: " + oldValue + " -> " + newValue);
|
||||
currentCaret = newValue.intValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
KLOVComboBox cb = new KLOVComboBox(lov);
|
||||
cb.setMaxWidth(300);
|
||||
config.setControl(cb);
|
||||
cb.setDisable(!config.canEdit);
|
||||
}
|
||||
if (config.getControl() != null) {
|
||||
config.getControl().focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
|
||||
if (arg2) {
|
||||
SwingTextContextActivator.instance().activateContext();
|
||||
} else {
|
||||
SwingTextContextActivator.instance().deactivateContext();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
propPane.setCenter(config.getControl());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertText(String text) {
|
||||
if (KUtil.isEmpty(text)) {
|
||||
return;
|
||||
}
|
||||
Control currentControl = getCurrentControl();
|
||||
if (currentControl == null) {
|
||||
return;
|
||||
}
|
||||
if (currentControl instanceof TextField) {
|
||||
((TextField) currentControl).insertText(currentCaret, text);
|
||||
currentCaret += text.length();
|
||||
int temp = currentCaret;
|
||||
currentControl.requestFocus();
|
||||
((TextField) currentControl).positionCaret(temp);
|
||||
} else if (currentControl instanceof TextArea) {
|
||||
TextArea textArea = (TextArea) currentControl;
|
||||
String oldValue = textArea.getText();
|
||||
String newValue;
|
||||
System.out.println(currentCaret + ":" + oldValue);
|
||||
int temp = currentCaret;
|
||||
if (oldValue == null) {
|
||||
newValue = text;
|
||||
} else if (currentCaret >= 0 && currentCaret <= oldValue.length()) {
|
||||
newValue = oldValue.substring(0, currentCaret) + text + oldValue.substring(currentCaret);
|
||||
currentCaret += text.length();
|
||||
temp = currentCaret;
|
||||
} else {
|
||||
newValue = oldValue + text;
|
||||
}
|
||||
System.out.println("-> " + newValue);
|
||||
textArea.setText(newValue);
|
||||
currentControl.requestFocus();
|
||||
textArea.positionCaret(temp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,332 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.teamcenter.rac.cme.time.common.ActivityUtils;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentCfgActivityLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLineType;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEActivity;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEActivityType;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRow;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.KTableRowMEActivity;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.PropConfig;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
public class TableLoaderMEActivity extends TableLoader {
|
||||
|
||||
protected TCComponentMEActivityType folderType;
|
||||
|
||||
public TableLoaderMEActivity(TCSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
public static boolean isActivityConfig(TCSession session, String prefName) {
|
||||
if (KUtil.isEmpty(prefName)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
String[] prefVals = KUtil.getPrefVals(session, prefName);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
if (len <= 1) {
|
||||
return false;
|
||||
}
|
||||
String itemTypeName = prefVals[0];
|
||||
TCComponentType typeComp = session.getTypeComponent(itemTypeName);
|
||||
if (typeComp == null) {
|
||||
return false;
|
||||
}
|
||||
if (typeComp instanceof TCComponentMEActivityType) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean load(TableView<KTableRow> table, String prefName) throws Exception {
|
||||
this.table = table;
|
||||
clearLocatorData();
|
||||
Platform.runLater(() -> {
|
||||
table.getColumns().clear();
|
||||
table.getItems().clear();
|
||||
});
|
||||
propConfigs.clear();
|
||||
sequenceConfigMap.clear();
|
||||
sequenceConfigMapReorder.clear();
|
||||
if (KUtil.isEmpty(prefName)) {
|
||||
return false;
|
||||
}
|
||||
System.out.println("Load table from pref: " + prefName);
|
||||
String[] prefVals = KUtil.getPrefVals(session, prefName);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
if (len <= 1) {
|
||||
return false;
|
||||
}
|
||||
String itemTypeName = prefVals[0];
|
||||
System.out.println(">> Item Type: " + itemTypeName);
|
||||
TCComponentCfgAttachmentLineType cfglineType = null;
|
||||
folderType = null;
|
||||
cfglineType = (TCComponentCfgAttachmentLineType) session.getTypeComponent("CfgActivityLine");
|
||||
if (cfglineType == null) {
|
||||
throw new Exception("Type not found: CfgAttachmentLine");
|
||||
}
|
||||
folderType = (TCComponentMEActivityType) session.getTypeComponent(itemTypeName);
|
||||
if (folderType == null) {
|
||||
throw new Exception(String.format(REG.getString("typenotfound.ERROR1"), itemTypeName));
|
||||
}
|
||||
for (int i = 1; i < len; i++) {
|
||||
String propName = prefVals[i];
|
||||
System.out.println("Load Config: " + propName);
|
||||
if (KUtil.isEmpty(propName)) {
|
||||
continue;
|
||||
}
|
||||
if (propName.toLowerCase().startsWith("sequence_step=")) {
|
||||
String numStr = propName.substring("sequence_step=".length()).trim();
|
||||
if (!KUtil.isEmpty(numStr)) {
|
||||
try {
|
||||
this.defaultSequenceStep = Integer.parseInt(numStr);
|
||||
System.out.println("Default Sequence Step: " + this.defaultSequenceStep);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
String propLoc = null;
|
||||
String filterValue = null;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int maxCharacter = 0;
|
||||
if ('-' == propName.charAt(0)) {
|
||||
width = -1;
|
||||
propName = propName.substring(1);
|
||||
} else {
|
||||
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
width = width * 10 + (propName.charAt(0) - '0');
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
if (propName.startsWith("x")) {
|
||||
propName = propName.substring(1);
|
||||
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
height = height * 10 + (propName.charAt(0) - '0');
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
}
|
||||
if (propName.startsWith("$")) {
|
||||
propName = propName.substring(1);
|
||||
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
|
||||
maxCharacter = maxCharacter * 10 + (propName.charAt(0) - '0');
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
int ind = propName.indexOf('.');
|
||||
if (ind > 0) {
|
||||
propLoc = propName.substring(0, ind);
|
||||
propName = propName.substring(ind + 1);
|
||||
}
|
||||
ind = propName.indexOf('=');
|
||||
if (ind > 0) {
|
||||
filterValue = propName.substring(ind + 1);
|
||||
propName = propName.substring(0, ind);
|
||||
}
|
||||
// System.out.println(propName + "|" + filterValue);
|
||||
TCComponentType type = null;
|
||||
if (KUtil.isEmpty(propLoc)) {
|
||||
type = folderType;
|
||||
propLoc = KTableRow.ITEM;
|
||||
} else {
|
||||
switch (propLoc.toUpperCase()) {
|
||||
case KTableRow.BOMLINE:
|
||||
type = cfglineType;
|
||||
break;
|
||||
case KTableRow.ITEM:
|
||||
type = folderType;
|
||||
break;
|
||||
default:
|
||||
System.out.println(">> Prop location error: " + propLoc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type != null) {
|
||||
boolean isSeq = propName.startsWith("#");
|
||||
boolean reorder = false;
|
||||
if (isSeq) {
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
reorder = propName.startsWith("#");
|
||||
if (reorder) {
|
||||
propName = propName.substring(1);
|
||||
}
|
||||
TCPropertyDescriptor propDesc = type.getPropDesc(propName);
|
||||
if (propDesc == null) {
|
||||
throw new Exception(String.format(REG.getString("propnotdefinedintype.ERROR2"), propName, type.getDisplayTypeName()));
|
||||
}
|
||||
PropConfig propConfig;
|
||||
this.propConfigs.add(propConfig = new PropConfig(propLoc, propDesc, filterValue, width, height, maxCharacter));
|
||||
if (reorder) {
|
||||
this.sequenceConfigMapReorder.put(propConfig, 0);
|
||||
} else if (isSeq) {
|
||||
this.sequenceConfigMap.put(propConfig, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Load complete");
|
||||
int size = this.propConfigs.size();
|
||||
if (size == 0) {
|
||||
return false;
|
||||
}
|
||||
this.gdtPropNames = KUtil.getPrefVals(session, PREF_GDT_PROP);
|
||||
for (int i = 0; i < size; i++) {
|
||||
PropConfig config = propConfigs.get(i);
|
||||
addTableCol(table, config);
|
||||
}
|
||||
// table.setOnMouseClicked(e->{
|
||||
// if(e.getButton()!=MouseButton.SECONDARY || e.getClickCount()!=1) {
|
||||
// return;
|
||||
// }
|
||||
// KTableRow row = table.getSelectionModel().getSelectedItem();
|
||||
// if(row!=null) {
|
||||
// row.switchWebView();
|
||||
// table.refresh();
|
||||
// }
|
||||
// });
|
||||
return true;
|
||||
}
|
||||
|
||||
public void loadTCData(TCComponentBOMLine targetLine, boolean useLatestRev) throws Exception {
|
||||
Platform.runLater(() -> {
|
||||
table.getItems().clear();
|
||||
});
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
int size = this.propConfigs.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
removeRows.clear();
|
||||
this.targetLine = targetLine;
|
||||
this.targetLine.refresh();
|
||||
TCComponentCfgActivityLine actLine = (TCComponentCfgActivityLine) targetLine.getReferenceProperty("bl_me_activity_lines");
|
||||
System.out.println("Activity line: " + targetLine + " -> " + actLine);
|
||||
if (actLine == null) {
|
||||
return;
|
||||
}
|
||||
TCComponent[] cc = ActivityUtils.getSortedActivityChildren(actLine);
|
||||
System.out.println(">> " + Arrays.toString(cc));
|
||||
int len = KUtil.getLen(cc);
|
||||
for (int i = 0; i < len; i++) {
|
||||
TCComponentCfgActivityLine bomine = (TCComponentCfgActivityLine) cc[i];
|
||||
bomine.refresh();
|
||||
TCComponentMEActivity item = (TCComponentMEActivity) bomine.getUnderlyingComponent();
|
||||
if (this.folderType != null && !this.folderType.getName().equals(item.getType())) {
|
||||
continue;
|
||||
}
|
||||
KTableRowMEActivity row = new KTableRowMEActivity(bomine, item);
|
||||
boolean checkOK = true;
|
||||
for (int j = 0; j < size; j++) {
|
||||
PropConfig config = propConfigs.get(j);
|
||||
if (!row.parseConfig(config)) {
|
||||
checkOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (checkOK) {
|
||||
for (PropConfig sequenceConfig : this.sequenceConfigMap.keySet()) {
|
||||
int maxSeqNo = this.sequenceConfigMap.get(sequenceConfig);
|
||||
String seq2 = row.getTCValue(sequenceConfig.propLoc, sequenceConfig.propName);
|
||||
if (!KUtil.isEmpty(seq2)) {
|
||||
try {
|
||||
int seqNum = Integer.parseInt(seq2);
|
||||
if (seqNum > maxSeqNo) {
|
||||
maxSeqNo = seqNum;
|
||||
this.sequenceConfigMap.put(sequenceConfig, maxSeqNo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PropConfig sequenceConfig : this.sequenceConfigMapReorder.keySet()) {
|
||||
int maxSeqNo = this.sequenceConfigMapReorder.get(sequenceConfig);
|
||||
String seq2 = row.getTCValue(sequenceConfig.propLoc, sequenceConfig.propName);
|
||||
if (!KUtil.isEmpty(seq2)) {
|
||||
try {
|
||||
int seqNum = Integer.parseInt(seq2);
|
||||
if (seqNum > maxSeqNo) {
|
||||
maxSeqNo = seqNum;
|
||||
this.sequenceConfigMapReorder.put(sequenceConfig, maxSeqNo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
table.getItems().add(row);
|
||||
});
|
||||
}
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
table.refresh();
|
||||
});
|
||||
System.out.println("Max Sequence: " + sequenceConfigMap);
|
||||
System.out.println("Max Sequence Reorder: " + sequenceConfigMapReorder);
|
||||
}
|
||||
|
||||
public void saveTCData() throws Exception {
|
||||
System.out.println("Save: " + targetLine);
|
||||
if (targetLine == null) {
|
||||
return;
|
||||
}
|
||||
targetLine.refresh();
|
||||
TCComponentCfgActivityLine actLine = (TCComponentCfgActivityLine) targetLine.getReferenceProperty("bl_me_activity_lines");
|
||||
if (actLine != null) {
|
||||
actLine.refresh();
|
||||
}
|
||||
TCComponent alObject = actLine == null ? null : actLine.getReferenceProperty("al_object");
|
||||
System.out.println("Activity line: " + targetLine + " -> " + alObject);
|
||||
if (actLine == null) {
|
||||
return;
|
||||
}
|
||||
if (alObject == null) {
|
||||
throw new TCException(REG.getString("alobjectisnull.ERROR"));
|
||||
}
|
||||
while (removeRows.size() > 0) {
|
||||
removeRows.get(0).removeLine();
|
||||
removeRows.remove(0);
|
||||
}
|
||||
KTableRow[] rows = table.getItems().toArray(new KTableRow[] {});
|
||||
int len = KUtil.getLen(rows);
|
||||
TCComponentCfgActivityLine pline = null;
|
||||
for (int i = 0; i < len; i++) {
|
||||
KTableRowMEActivity row = (KTableRowMEActivity) rows[i];
|
||||
row.saveTCData(actLine, folderType);
|
||||
if (pline != null && row.actline != null) {
|
||||
ActivityUtils.moveActivityAfter(row.actline, pline);
|
||||
}
|
||||
pline = row.actline;
|
||||
}
|
||||
}
|
||||
|
||||
public KTableRow getNewRow() {
|
||||
KTableRow row = new KTableRowMEActivity(null, null);
|
||||
for (PropConfig propConfig : propConfigs) {
|
||||
row.stringProps.put(propConfig, new SimpleStringProperty(""));
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,258 @@
|
||||
package cn.net.connor.std.processedit.meopviewfx.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KSqlUtil;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.meopviewfx.bean.TextBean;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
|
||||
public class TextTreeLoader {
|
||||
|
||||
private static final String PREF_COMMON_FOLDER = "Connor_AVIC_GXBZ_Common_Folder";
|
||||
private static final String PREF_PERSONAL_FOLDER = "Connor_AVIC_GXBZ_Personal_Folder";
|
||||
private static final String FLAG_REALVALUE = "#RV#";
|
||||
private static final String PREFFLAG_REALVALUE = "#RealValue#";
|
||||
private static final Registry REG = Registry.getRegistry(TextTreeLoader.class);
|
||||
|
||||
public static class FileBean {
|
||||
File file;
|
||||
int realValueCol;
|
||||
|
||||
public FileBean(File file, int realValueCol) {
|
||||
this.file = file;
|
||||
this.realValueCol = realValueCol;
|
||||
}
|
||||
}
|
||||
|
||||
private TCSession session;
|
||||
|
||||
public TextTreeLoader(TCSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public Map<String, TextBean> loadText105() throws Exception {
|
||||
Map<String, TextBean> textMap = new LinkedHashMap<String, TextBean>();
|
||||
String key = REG.getString("mkhgy");
|
||||
String sql = "select pac5_JG1, pac5_JG2, pac5_JG3, pac5_JG4, pac5_JG5, pac5_JG6 from pAc5_MKHGYRevMasters";
|
||||
Connection conn = KSqlUtil.getOracleConnection(session, ProcessUtil.PREF_DB_CONN);
|
||||
List<String[]> data = null;
|
||||
int colCnt = 6;
|
||||
TextBean root = new TextBean(key);
|
||||
textMap.put(key, root);
|
||||
try {
|
||||
data = KSqlUtil.queryStringArray(conn, sql, null, colCnt);
|
||||
} finally {
|
||||
KSqlUtil.free(conn);
|
||||
}
|
||||
int cnt = data == null?0:data.size();
|
||||
for(int i=0; i<cnt ;i++) {
|
||||
String[] rowData = data.get(i);
|
||||
TextBean parent = root;
|
||||
for(int c=0; c<colCnt; c++) {
|
||||
String text = rowData[c];
|
||||
if(KUtil.isEmpty(text)) {
|
||||
break;
|
||||
}
|
||||
TextBean child = new TextBean(text);
|
||||
int ind = parent.children.indexOf(child);
|
||||
if(ind>=0) {
|
||||
parent = parent.children.get(ind);
|
||||
}else {
|
||||
parent.children.add(child);
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return textMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, TextBean> loadText() throws Exception {
|
||||
Map<String, TextBean> textMap = new LinkedHashMap<String, TextBean>();
|
||||
List<FileBean> docFiles = getConfigFile();
|
||||
int size = docFiles.size();
|
||||
if (size == 0) {
|
||||
System.out.println("Special Text File not found");
|
||||
return textMap;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
FileBean docFile = docFiles.get(i);
|
||||
System.out.println("Load File: " + docFile.file.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(docFile.file);
|
||||
XSSFWorkbook wb = new XSSFWorkbook(in);
|
||||
in.close();
|
||||
int sheetCnt = wb.getNumberOfSheets();
|
||||
for (int j = 0; j < sheetCnt; j++) {
|
||||
XSSFSheet sheet = wb.getSheetAt(0);
|
||||
String sheetName = sheet.getSheetName();
|
||||
System.out.println(">> Load Sheet: " + sheetName);
|
||||
if (textMap.containsKey(sheetName)) {
|
||||
System.out.println("SKIP");
|
||||
continue;
|
||||
}
|
||||
TextBean bean = readSheet(sheet, docFile.realValueCol);
|
||||
if (bean != null && bean.children.size() > 0) {
|
||||
textMap.put(sheetName, bean);
|
||||
} else {
|
||||
System.out.println("No Data");
|
||||
}
|
||||
}
|
||||
}
|
||||
return textMap;
|
||||
}
|
||||
|
||||
private TextBean readSheet(XSSFSheet sheet, int realValueCol) throws Exception {
|
||||
TextBean root = new TextBean(sheet.getSheetName());
|
||||
int firstRow = sheet.getFirstRowNum();
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
Map<Integer, TextBean> parents = new HashMap<Integer, TextBean>();
|
||||
parents.put(0, root);
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
XSSFRow row = sheet.getRow(i);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
int firstCol = row.getFirstCellNum();
|
||||
if (firstCol < 0) {
|
||||
firstCol = 0;
|
||||
}
|
||||
int lastCol = row.getLastCellNum();
|
||||
for (int j = firstCol; j <= lastCol; j++) {
|
||||
XSSFCell cell = row.getCell(j);
|
||||
if (cell == null || cell.getCellType() != XSSFCell.CELL_TYPE_STRING) {
|
||||
continue;
|
||||
}
|
||||
if (!parents.containsKey(j)) {
|
||||
continue;
|
||||
}
|
||||
String text = cell.getStringCellValue();
|
||||
if (KUtil.isEmpty(text)) {
|
||||
continue;
|
||||
}
|
||||
if (j == realValueCol) {
|
||||
parents.get(j).setRealValue(text);
|
||||
continue;
|
||||
}
|
||||
if (text.startsWith(FLAG_REALVALUE)) {
|
||||
parents.get(j).setRealValue(text.substring(FLAG_REALVALUE.length()));
|
||||
continue;
|
||||
}
|
||||
TextBean bean = new TextBean(text);
|
||||
// for(int k=j+1;k<=lastCol;k++) {
|
||||
// XSSFCell realValueCell = row.getCell(k);
|
||||
// if(realValueCell!=null&&realValueCell.getCellType()==XSSFCell.CELL_TYPE_STRING)
|
||||
// {
|
||||
// String realValue = realValueCell.getStringCellValue();
|
||||
// if(!KUtil.isEmpty(realValue)) {
|
||||
// bean.setRealValue(realValue);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
parents.get(j).children.add(bean);
|
||||
parents.put(j + 1, bean);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
protected List<FileBean> getConfigFile() {
|
||||
List<FileBean> files = new ArrayList<>();
|
||||
try {
|
||||
addFileFromPref(files, PREF_COMMON_FOLDER, "");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Load Text Tree From <" + PREF_COMMON_FOLDER + "> Error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
addFileFromPref(files, PREF_PERSONAL_FOLDER, session.getUser().getUserId());
|
||||
} catch (Exception e) {
|
||||
System.out.println("Load Text Tree From <" + PREF_PERSONAL_FOLDER + "> Error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
private void addFileFromPref(List<FileBean> files, String prefName, String subFolder) throws Exception {
|
||||
String uid = KUtil.getPrefVal(session, prefName);
|
||||
if (KUtil.isEmpty(uid)) {
|
||||
return;
|
||||
}
|
||||
int realValueColumn = -1;
|
||||
int ind = uid.indexOf(PREFFLAG_REALVALUE);
|
||||
if (ind > 0) {
|
||||
String numStr = uid.substring(ind + PREFFLAG_REALVALUE.length());
|
||||
uid = uid.substring(0, ind);
|
||||
try {
|
||||
realValueColumn = Integer.parseInt(numStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
TCComponent comp = session.stringToComponent(uid);
|
||||
if (comp == null) {
|
||||
return;
|
||||
}
|
||||
if (comp instanceof TCComponentFolder) {
|
||||
TCComponentFolder folder = (TCComponentFolder) comp;
|
||||
AIFComponentContext[] children = folder.getChildren();
|
||||
if (!KUtil.isEmpty(subFolder)) {
|
||||
for (AIFComponentContext c : children) {
|
||||
InterfaceAIFComponent child = c.getComponent();
|
||||
if (child instanceof TCComponentFolder) {
|
||||
if (subFolder.equals(((TCComponentFolder) child).getStringProperty("object_name"))) {
|
||||
children = child.getChildren();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AIFComponentContext c : children) {
|
||||
InterfaceAIFComponent child = c.getComponent();
|
||||
if ("MSExcelX".equals(child.getType())) {
|
||||
File[] dbFiles = ((TCComponentDataset) child).getFiles("");
|
||||
if (dbFiles != null) {
|
||||
for (int i = 0; i < dbFiles.length; i++) {
|
||||
files.add(new FileBean(dbFiles[i], realValueColumn));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (comp instanceof TCComponentDataset) {
|
||||
TCComponentDataset dataset = (TCComponentDataset) comp;
|
||||
if ("MSExcelX".equals(dataset.getType())) {
|
||||
File[] dbFiles = dataset.getFiles("");
|
||||
if (dbFiles != null) {
|
||||
for (int i = 0; i < dbFiles.length; i++) {
|
||||
files.add(new FileBean(dbFiles[i], realValueColumn));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
.root {
|
||||
-fx-font-family: "Microsoft YaHei";
|
||||
}
|
||||
|
||||
.table-row-cell .ktext {
|
||||
-fx-fill: black;
|
||||
}
|
||||
|
||||
.table-row-cell:selected .ktext {
|
||||
-fx-fill: white;
|
||||
}
|
||||
|
||||
.table-cell .ktext {
|
||||
-fx-fill: black;
|
||||
}
|
||||
|
||||
.table-cell:selected .ktext {
|
||||
-fx-fill: white;
|
||||
}
|
||||
|
||||
.tab-pane .tab-header-area {
|
||||
-fx-padding: 5 2 0 0;
|
||||
}
|
||||
|
||||
* :disabled {
|
||||
-fx-opacity: 0.85;
|
||||
}
|
||||
|
||||
.dark-table .table-row-cell:odd {
|
||||
-fx-control-inner-background: #e6e6e6;
|
||||
}
|
||||
|
||||
.dark-table .table-row-cell:even {
|
||||
-fx-control-inner-background: #fff;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
mkhgy=\u6A21\u5757\u5316\u5DE5\u827A
|
||||
typenotfound.ERROR1=\u672A\u5B9A\u4E49\u7C7B\u578B\u201C%s\u201D
|
||||
propnotdefinedintype.ERROR2=\u5C5E\u6027\u201C%s\u201D\u672A\u5728\u7C7B\u578B\u201C%s\u201D\u4E2D\u5B9A\u4E49
|
||||
index.COL=\u5E8F\u53F7
|
||||
noseqconfig.ERROR=\u8BE5\u7C7B\u578B\u4E0D\u652F\u6301\u6392\u5E8F
|
||||
OK.NAME=\u786E\u5B9A
|
||||
GDT_EDITOR_DIALOG.TITLE=\u7279\u6B8A\u7B26\u53F7
|
||||
zoom=1.5
|
||||
alobjectisnull.ERROR=\u65E0\u6CD5\u83B7\u53D6\u5DE5\u6B65\u884C\u5BF9\u8C61
|
||||
@ -0,0 +1,170 @@
|
||||
package cn.net.connor.std.processedit.modifymeopno;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ModifyMeopNoDialog extends KDialog {
|
||||
|
||||
public static final Registry REG = Registry.getRegistry(ModifyMeopNoDialog.class);
|
||||
protected JButton b_ok;
|
||||
protected DefaultTableModel tableModel;
|
||||
protected JTable table;
|
||||
private ModifyMeopNoDialogController controller;
|
||||
protected JButton b_delete;
|
||||
protected JButton b_moveup;
|
||||
protected JButton b_movedown;
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
this.b_delete.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.delete();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ModifyMeopNoDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_moveup.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.moveup();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ModifyMeopNoDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_movedown.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.movedown();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(ModifyMeopNoDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.controller = (ModifyMeopNoDialogController)aifController;
|
||||
this.setTitle(REG.getString("modifymeopno.TITLE"));
|
||||
this.setPreferredSize(new Dimension(800, 600));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.CENTER, initTablePanel());
|
||||
this.add(BorderLayout.EAST, initBtnPanel());
|
||||
try {
|
||||
controller.readMeop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(this, e);
|
||||
}
|
||||
controller.checkRelease();
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(16, 0, 7, 7));
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(0, 0, 12, 0));
|
||||
KUtil.newRow(panel, this.b_delete = new JButton(REG.getString("delete")), s, 1);
|
||||
KUtil.newRow(panel, this.b_moveup = new JButton(REG.getString("moveup")), s, 1);
|
||||
KUtil.newRow(panel, this.b_movedown = new JButton(REG.getString("movedown")), s, 1);
|
||||
KUtil.newRow(panel, this.b_ok = new JButton(REG.getString("ok")), s, 1);
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(panel, new JLabel(), s, 1);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initTablePanel() {
|
||||
this.tableModel = new DefaultTableModel();
|
||||
this.table = new JTable(tableModel) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.setRowHeight(23);
|
||||
tableModel.setDataVector(null, controller.tableHeaders);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.setDefaultRenderer(Object.class, new ColorTableRenderer());
|
||||
int colCnt = KUtil.getLen(controller.tableHeaders);
|
||||
TableColumnModel colModel = this.table.getColumnModel();
|
||||
for (int i = 0; i < colCnt; i++) {
|
||||
colModel.getColumn(i).setPreferredWidth(controller.tableHeaderWidth[i]);
|
||||
}
|
||||
colModel.getColumn(0).setMinWidth(0);
|
||||
colModel.getColumn(0).setMaxWidth(0);
|
||||
if (colCnt > 5) {
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
}
|
||||
JScrollPane scroll = new JScrollPane(table);
|
||||
scroll.setBorder(null);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
|
||||
return panel;
|
||||
}
|
||||
|
||||
public static class ColorTableRenderer extends DefaultTableCellRenderer {
|
||||
public static final Color DEFBLUE = new Color(51, 153, 255);
|
||||
public static final Color RED = new Color(255, 59, 48);
|
||||
public static final Color GREEN = new Color(158, 234, 106);
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (hasFocus) {
|
||||
setBackground(DEFBLUE);
|
||||
} else {
|
||||
Object obj = t.getValueAt(row, 0);
|
||||
if(obj instanceof ModifyMeopNoRow) {
|
||||
if(((ModifyMeopNoRow) obj).isReleased()) {
|
||||
setBackground(RED);
|
||||
}else {
|
||||
setBackground(GREEN);
|
||||
}
|
||||
}else {
|
||||
setBackground(Color.WHITE);
|
||||
}
|
||||
}
|
||||
return super.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,247 @@
|
||||
package cn.net.connor.std.processedit.modifymeopno;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
|
||||
public class ModifyMeopNoDialogController extends KDialogController {
|
||||
|
||||
public static final Registry REG = Registry.getRegistry(ModifyMeopNoDialogController.class);
|
||||
public static final String PREF_MEOP_TYPE = "Connor_AVIC_SQGXH_GXLX";
|
||||
public static final String PREF_MEOP_TABLE = "Connor_AVIC_SQGXH_SXBJ";
|
||||
private String[] meopTypes;
|
||||
protected String[] tableHeaders;
|
||||
protected int[] tableHeaderWidth;
|
||||
private String[] tableProps;
|
||||
private ModifyMeopNoDialog dialog;
|
||||
private TCComponentBOMLine procLine;
|
||||
private TCComponentItemRevision targetRev;
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (ModifyMeopNoDialog) aifDialog;
|
||||
InterfaceAIFComponent comp = app.getTargetComponent();
|
||||
System.out.println("Select: " + comp);
|
||||
if (comp != null) {
|
||||
if (comp instanceof TCComponentBOMLine) {
|
||||
this.procLine = (TCComponentBOMLine) comp;
|
||||
TCComponentItemRevision rev = this.procLine.getItemRevision();
|
||||
System.out.println(">> " + rev.getType());
|
||||
if (ProcessUtil.isMEProcess(session, rev.getItem().getType())) {
|
||||
// if (rev instanceof TCComponentMEProcessRevision) {
|
||||
this.targetRev = rev;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetRev == null) {
|
||||
throw new TCException(REG.getString("selectprocessrev.ERROR"));
|
||||
}
|
||||
this.meopTypes = KUtil.getPrefVals(session, PREF_MEOP_TYPE);
|
||||
String[] tableConfigs = KUtil.getPrefVals(session, PREF_MEOP_TABLE);
|
||||
if (KUtil.getLen(meopTypes) == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TYPE));
|
||||
}
|
||||
if (KUtil.getLen(tableConfigs) == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TABLE));
|
||||
}
|
||||
int colCnt = KUtil.getLen(tableConfigs);
|
||||
tableHeaders = new String[colCnt + 1];
|
||||
tableHeaderWidth = new int[colCnt + 1];
|
||||
tableHeaders[0] = "Hidden";
|
||||
tableHeaderWidth[0] = 0;
|
||||
tableProps = new String[colCnt];
|
||||
for (int i = 0; i < colCnt; i++) {
|
||||
int colIndex = i + 1;
|
||||
String config = tableConfigs[i];
|
||||
int ind = config.lastIndexOf('=');
|
||||
if (ind > 0) {
|
||||
tableHeaders[colIndex] = config.substring(0, ind);
|
||||
tableProps[i] = config.substring(ind + 1);
|
||||
} else {
|
||||
tableHeaders[colIndex] = config;
|
||||
tableProps[i] = config;
|
||||
}
|
||||
int width = 0;
|
||||
while (tableHeaders[colIndex].length() > 0 && Character.isDigit(tableHeaders[colIndex].charAt(0))) {
|
||||
width = width * 10 + (tableHeaders[colIndex].charAt(0) - '0');
|
||||
tableHeaders[colIndex] = tableHeaders[colIndex].substring(1);
|
||||
}
|
||||
if (width < 1) {
|
||||
width = 120;
|
||||
}
|
||||
tableHeaderWidth[colIndex] = width;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void readMeop() throws Exception {
|
||||
System.out.println("Load Meop: " + this.procLine + " | " + Arrays.toString(meopTypes));
|
||||
if (this.procLine == null) {
|
||||
return;
|
||||
}
|
||||
KUtil.setByPassItk(session, true);
|
||||
try {
|
||||
this.procLine.refresh();
|
||||
AIFComponentContext[] cc = this.procLine.getChildren();
|
||||
int len = KUtil.getLen(cc);
|
||||
for (int i = 0; i < len; i++) {
|
||||
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
|
||||
String cType = cLine.getItem().getType();
|
||||
System.out.println((i + 1) + ". " + cLine + " -> " + cType);
|
||||
if (KUtil.inArray(cType, meopTypes) >= 0) {
|
||||
dialog.tableModel.addRow(new ModifyMeopNoRow(cLine).getRowData(tableProps));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
KUtil.setByPassItk(session, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete() throws Exception {
|
||||
int selectedRow = dialog.table.getSelectedRow();
|
||||
System.out.println("Delete: " + selectedRow);
|
||||
if (selectedRow < 0) {
|
||||
return;
|
||||
}
|
||||
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
|
||||
TCComponentBOMLine bomline = bean.getBomline();
|
||||
System.out.println("Remove Line: " + bomline);
|
||||
KUtil.setByPassItk(session, true);
|
||||
try {
|
||||
// int currentSeq = NewMeopDialogController.getMeopNo(bomline);
|
||||
// System.out.println("Current Seq: " + currentSeq);
|
||||
bomline.cut();
|
||||
dialog.tableModel.removeRow(selectedRow);
|
||||
// if (checkSeq(currentSeq)) {
|
||||
// int rowCnt = dialog.table.getRowCount();
|
||||
// for (int i = selectedRow; i < rowCnt; i++) {
|
||||
// bean = (ModifyMeopNoRow) dialog.table.getValueAt(i, 0);
|
||||
// bomline = bean.getBomline();
|
||||
// bomline.refresh();
|
||||
// int seq = NewMeopDialogController.getMeopNo(bomline);
|
||||
// // int seq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
|
||||
// System.out.println("Change Sequence: " + bomline + " " + seq + " -> " + (seq - 5));
|
||||
// seq -= 5;
|
||||
// NewMeopDialogController.setMeopNo(bomline, seq);
|
||||
// // bomline.setProperty("bl_sequence_no", "" + seq);
|
||||
// bomline.refresh();
|
||||
// dialog.tableModel.removeRow(i);
|
||||
// dialog.tableModel.insertRow(i, bean.getRowData(tableProps));
|
||||
// }
|
||||
// } else {
|
||||
// System.out.println("Skip Change");
|
||||
// }
|
||||
procLine.refresh();
|
||||
} finally {
|
||||
KUtil.setByPassItk(session, false);
|
||||
}
|
||||
checkRelease();
|
||||
}
|
||||
|
||||
public boolean checkSeq(int seq) {
|
||||
return seq > 0 && seq % 5 == 0;
|
||||
}
|
||||
|
||||
public void checkRelease() {
|
||||
int rowCnt = dialog.table.getRowCount();
|
||||
boolean hasRelease = false;
|
||||
for (int i = 0; i < rowCnt; i++) {
|
||||
if (((ModifyMeopNoRow) dialog.table.getValueAt(i, 0)).isReleased()) {
|
||||
hasRelease = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dialog.b_moveup.setEnabled(!hasRelease);
|
||||
dialog.b_movedown.setEnabled(!hasRelease);
|
||||
}
|
||||
|
||||
public void moveup() throws Exception {
|
||||
int selectedRow = dialog.table.getSelectedRow();
|
||||
System.out.println("Move Up: " + selectedRow);
|
||||
if (selectedRow <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
KUtil.setByPassItk(session, true);
|
||||
try {
|
||||
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
|
||||
TCComponentBOMLine bomline = bean.getBomline();
|
||||
System.out.println("Select Line: " + bomline);
|
||||
ModifyMeopNoRow otherbean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow - 1, 0);
|
||||
TCComponentBOMLine otherBomline = otherbean.getBomline();
|
||||
System.out.println("Other Line: " + otherBomline);
|
||||
int blseq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
|
||||
int otherblSeq = Integer.parseInt(otherBomline.getStringProperty("bl_sequence_no"));
|
||||
bomline.setProperty("bl_sequence_no", otherblSeq + "");
|
||||
otherBomline.setProperty("bl_sequence_no", blseq + "");
|
||||
// int seq = NewMeopDialogController.getMeopNo(bomline);
|
||||
// int otherSeq = NewMeopDialogController.getMeopNo(otherBomline);
|
||||
// if (checkSeq(seq) && checkSeq(otherSeq)) {
|
||||
// NewMeopDialogController.setMeopNo(bomline, otherSeq);
|
||||
// NewMeopDialogController.setMeopNo(otherBomline, seq);
|
||||
// } else {
|
||||
// System.out.println("Skip Change");
|
||||
// }
|
||||
bomline.refresh();
|
||||
otherBomline.refresh();
|
||||
procLine.refresh();
|
||||
dialog.tableModel.removeRow(selectedRow);
|
||||
dialog.tableModel.removeRow(selectedRow - 1);
|
||||
dialog.tableModel.insertRow(selectedRow - 1, otherbean.getRowData(tableProps));
|
||||
dialog.tableModel.insertRow(selectedRow - 1, bean.getRowData(tableProps));
|
||||
dialog.table.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1);
|
||||
} finally {
|
||||
KUtil.setByPassItk(session, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void movedown() throws Exception {
|
||||
int selectedRow = dialog.table.getSelectedRow();
|
||||
System.out.println("Move Down: " + selectedRow);
|
||||
int rowCnt = dialog.table.getRowCount();
|
||||
if (selectedRow < 0 || selectedRow == rowCnt - 1) {
|
||||
return;
|
||||
}
|
||||
KUtil.setByPassItk(session, true);
|
||||
try {
|
||||
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
|
||||
TCComponentBOMLine bomline = bean.getBomline();
|
||||
System.out.println("Select Line: " + bomline);
|
||||
ModifyMeopNoRow otherbean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow + 1, 0);
|
||||
TCComponentBOMLine otherBomline = otherbean.getBomline();
|
||||
System.out.println("Other Line: " + otherBomline);
|
||||
int blseq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
|
||||
int otherblSeq = Integer.parseInt(otherBomline.getStringProperty("bl_sequence_no"));
|
||||
bomline.setProperty("bl_sequence_no", otherblSeq + "");
|
||||
otherBomline.setProperty("bl_sequence_no", blseq + "");
|
||||
// int seq = NewMeopDialogController.getMeopNo(bomline);
|
||||
// int otherSeq = NewMeopDialogController.getMeopNo(otherBomline);
|
||||
// if (checkSeq(seq) && checkSeq(otherSeq)) {
|
||||
// NewMeopDialogController.setMeopNo(bomline, otherSeq);
|
||||
// NewMeopDialogController.setMeopNo(otherBomline, seq);
|
||||
// } else {
|
||||
// System.out.println("Skip Change");
|
||||
// }
|
||||
bomline.refresh();
|
||||
otherBomline.refresh();
|
||||
procLine.refresh();
|
||||
dialog.tableModel.removeRow(selectedRow + 1);
|
||||
dialog.tableModel.removeRow(selectedRow);
|
||||
dialog.tableModel.insertRow(selectedRow, bean.getRowData(tableProps));
|
||||
dialog.tableModel.insertRow(selectedRow, otherbean.getRowData(tableProps));
|
||||
dialog.table.getSelectionModel().setSelectionInterval(selectedRow + 1, selectedRow + 1);
|
||||
} finally {
|
||||
KUtil.setByPassItk(session, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package cn.net.connor.std.processedit.modifymeopno;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.aifrcp.util.PropLocation;
|
||||
|
||||
public class ModifyMeopNoRow {
|
||||
|
||||
private TCComponentBOMLine bomline;
|
||||
private boolean isReleased;
|
||||
private HashMap<String, TCComponent> markedComponents;
|
||||
|
||||
public ModifyMeopNoRow(TCComponentBOMLine cLine) throws Exception {
|
||||
this.bomline = cLine;
|
||||
this.bomline.refresh();
|
||||
TCComponentItemRevision rev = cLine.getItemRevision();
|
||||
if(rev==null) {
|
||||
throw new Exception("revision not found: "+cLine);
|
||||
}
|
||||
rev.refresh();
|
||||
markedComponents = new HashMap<String, TCComponent>();
|
||||
PropLocation.initLocationMap(markedComponents , getBomline());
|
||||
this.isReleased=KUtil.isReleased(rev);
|
||||
}
|
||||
|
||||
public boolean isReleased() {
|
||||
return this.isReleased;
|
||||
}
|
||||
|
||||
public Object[] getRowData(String[] tableProps) throws Exception{
|
||||
int len = KUtil.getLen(tableProps);
|
||||
Object[] data = new Object[len+1];
|
||||
data[0] = this;
|
||||
for(int i=0; i<len; i++) {
|
||||
String[] config = tableProps[i].split("\\.");
|
||||
if(KUtil.getLen(config)!=2) {
|
||||
data[i+1] = tableProps[i];
|
||||
continue;
|
||||
}
|
||||
String propLoc = config[0].toUpperCase();
|
||||
if(markedComponents.containsKey(propLoc)) {
|
||||
data[i+1] = markedComponents.get(propLoc).getProperty(config[1]);
|
||||
}else {
|
||||
data[i+1] = tableProps[i];
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getBomline().toString();
|
||||
}
|
||||
|
||||
public TCComponentBOMLine getBomline() {
|
||||
return bomline;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
modifymeopno.TITLE=\u4FEE\u6539\u5DE5\u5E8F\u53F7
|
||||
moveup=\u4E0A\u79FB
|
||||
movedown=\u4E0B\u79FB
|
||||
delete=\u5220\u9664
|
||||
ok=\u786E\u5B9A
|
||||
selectprocessrev.ERROR=\u8BF7\u9009\u62E9\u5DE5\u827A\u8FDB\u884C\u64CD\u4F5C
|
||||
prefnotconfiged.ERROR1=\u9996\u9009\u9879\u672A\u914D\u7F6E\uFF1A%s
|
||||
@ -0,0 +1,226 @@
|
||||
package cn.net.connor.std.processedit.newdatasetfromtemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.cme.application.MFGLegacyApplication;
|
||||
import com.teamcenter.rac.cme.framework.treetable.CMEBOMTreeTable;
|
||||
import com.teamcenter.rac.cme.framework.views.primary.BOMPrimaryView;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PlatformHelper;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KOperation;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class NewDatasetFromTemplateOperation extends KOperation {
|
||||
|
||||
public static final Registry REG = Registry.getRegistry(NewDatasetFromTemplateOperation.class);
|
||||
private String prefName;
|
||||
private TCComponentDataset template;
|
||||
private String[] selectTypes;
|
||||
private String relation;
|
||||
private String nameConfig;
|
||||
private String successAlert;
|
||||
private String existAlert;
|
||||
private TCComponentItemRevision targetRev;
|
||||
private TCComponentBOMLine targetBOMLine;
|
||||
private boolean refreshCfgLines = false;
|
||||
|
||||
public NewDatasetFromTemplateOperation(AbstractAIFApplication app, String prefName) {
|
||||
super(app, REG.getString("op.Name"));
|
||||
this.prefName = prefName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
String[] prefValues = KUtil.getPrefVals(session, prefName);
|
||||
System.out.println("NewDatasetFromTemplateOperation");
|
||||
System.out.println(prefName + " -> " + Arrays.toString(prefValues));
|
||||
int prefCnt = KUtil.getLen(prefValues);
|
||||
/**
|
||||
* select=select type relation=relation name=dataset name success=success alert
|
||||
* dataset=uid exist=exist alert
|
||||
*/
|
||||
for (int i = 0; i < prefCnt; i++) {
|
||||
String pref = prefValues[i];
|
||||
int ind = pref.indexOf('=');
|
||||
if (ind <= 0) {
|
||||
continue;
|
||||
}
|
||||
String key = pref.substring(0, ind).trim().toLowerCase();
|
||||
String value = pref.substring(ind + 1);
|
||||
switch (key) {
|
||||
case "select":
|
||||
this.selectTypes = value.split(";");
|
||||
break;
|
||||
case "relation":
|
||||
this.relation = value;
|
||||
break;
|
||||
case "name":
|
||||
this.nameConfig = value;
|
||||
break;
|
||||
case "success":
|
||||
this.successAlert = value;
|
||||
break;
|
||||
case "dataset":
|
||||
String uid = value;
|
||||
try {
|
||||
this.template = (TCComponentDataset) session.stringToComponent(uid);
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "exist":
|
||||
this.existAlert = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println("Template: " + this.template);
|
||||
if (this.template == null || KUtil.getLen(this.selectTypes) == 0 || KUtil.isEmpty(this.relation) || KUtil.isEmpty(this.nameConfig)) {
|
||||
throw new TCException(String.format(REG.getString("pref.Error1"), prefName));
|
||||
}
|
||||
InterfaceAIFComponent target = app.getTargetComponent();
|
||||
if (target != null) {
|
||||
if (target instanceof TCComponentBOMLine) {
|
||||
this.targetBOMLine = (TCComponentBOMLine) target;
|
||||
this.targetRev = targetBOMLine.getItemRevision();
|
||||
} else if (target instanceof TCComponentCfgAttachmentLine) {
|
||||
TCComponent obj = ((TCComponentCfgAttachmentLine) target).getUnderlyingComponent();
|
||||
if (obj != null && (obj instanceof TCComponentItemRevision)) {
|
||||
this.targetRev = (TCComponentItemRevision) obj;
|
||||
this.refreshCfgLines = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (refreshCfgLines) {
|
||||
TCComponentBOMWindow bomWindow = ((TCComponentCfgAttachmentLine) target).window().getBomWindow();
|
||||
System.out.println(">> BomWindow: " + bomWindow);
|
||||
System.out.println(">> " + app.getClass());
|
||||
if (app instanceof MFGLegacyApplication) {
|
||||
List<Object> viewParts = PlatformHelper.getAllViewParts();
|
||||
IWorkbenchWindow var1 = AIFUtility.getActiveDesktop().getDesktopWindow();
|
||||
IWorkbenchPage page = var1.getActivePage();
|
||||
for (Object viewPart : viewParts) {
|
||||
if (viewPart == null || !(viewPart instanceof CompatibilityView)) {
|
||||
continue;
|
||||
}
|
||||
IViewPart view = ((CompatibilityView) viewPart).getView();
|
||||
if (view == null || !(view instanceof BOMPrimaryView)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BOMPrimaryView bomView = (BOMPrimaryView) view;
|
||||
CMEBOMTreeTable treeTable = bomView.getBOMTreeTable();
|
||||
if (treeTable == null) {
|
||||
continue;
|
||||
}
|
||||
boolean visible = page.isPartVisible(view);
|
||||
System.out.println(">> BOMPrimaryView: [" + visible + "]" + bomView);
|
||||
if (!visible) {
|
||||
continue;
|
||||
}
|
||||
if (treeTable.getBOMWindow() == bomWindow) {
|
||||
System.out.println(">>>>> find window");
|
||||
TCComponentBOMLine[] bomlines = treeTable.getSelectedBOMLines();
|
||||
System.out.println(">> Selected lines: " + Arrays.toString(bomlines));
|
||||
int bomLineCnt = KUtil.getLen(bomlines);
|
||||
if (bomLineCnt == 1 && this.targetRev == bomlines[0].getItemRevision()) {
|
||||
this.targetBOMLine = bomlines[0];
|
||||
System.out.println(">>>>> Find targetline");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String targetType = this.targetRev == null ? "" : this.targetRev.getType();
|
||||
System.out.println("Select " + target + " [" + targetType + "]");
|
||||
if (KUtil.isEmpty(targetType) || KUtil.inArray(targetType, selectTypes) < 0) {
|
||||
String[] typeNames = new String[this.selectTypes.length];
|
||||
for (int i = 0; i < this.selectTypes.length; i++) {
|
||||
typeNames[i] = KUtil.getTypeName(session, this.selectTypes[i]);
|
||||
}
|
||||
throw new TCException(String.format(REG.getString("select.Error1"), Arrays.toString(typeNames)));
|
||||
}
|
||||
if (this.targetBOMLine == null) {
|
||||
throw new TCException(REG.getString("nobomline.Error"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
this.targetRev.refresh();
|
||||
this.targetBOMLine.refresh();
|
||||
String dsName = KUtil.getPropValueByPath(targetBOMLine, nameConfig, "-");
|
||||
System.out.println("Dataset Name: " + dsName);
|
||||
if (!KUtil.isEmpty(this.existAlert)) {
|
||||
TCComponent existDataset = KUtil.getChildByTypeAndName(targetRev, template.getType(), dsName, relation);
|
||||
System.out.println("Exist: " + existDataset);
|
||||
if (existDataset != null) {
|
||||
MessageBox.post(existAlert, "", MessageBox.WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
TCComponentDataset newDataset = this.template.saveAs(dsName);
|
||||
System.out.println("New Dataset: " + newDataset);
|
||||
if (newDataset == null) {
|
||||
throw new TCException(REG.getString("saveas.Error"));
|
||||
}
|
||||
this.targetRev.add(relation, newDataset);
|
||||
this.targetRev.refresh();
|
||||
// rename file ref
|
||||
TCComponent[] refs = newDataset.getReferenceListProperty("ref_list");
|
||||
if (KUtil.getLen(refs) > 0) {
|
||||
TCComponent ref = refs[0];
|
||||
String fileName = ref.getStringProperty("original_file_name");
|
||||
System.out.println("Check file name: " + fileName);
|
||||
int ind = fileName.lastIndexOf('.');
|
||||
if (ind > 0) {
|
||||
String ext = fileName.substring(ind);
|
||||
String newName = dsName;
|
||||
if (!newName.toLowerCase().endsWith(ext.toLowerCase())) {
|
||||
newName += ext;
|
||||
}
|
||||
ref.lock();
|
||||
try {
|
||||
ref.setStringProperty("original_file_name", newName);
|
||||
ref.save();
|
||||
} finally {
|
||||
ref.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!KUtil.isEmpty(this.successAlert)) {
|
||||
MessageBox.post(successAlert, "", MessageBox.INFORMATION);
|
||||
}
|
||||
session.refreshComponentsByType("CfgBlAttachmentLine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
op.Name=\u4ECE\u6A21\u677F\u53E6\u5B58\u6570\u636E\u96C6
|
||||
pref.Error1=\u9996\u9009\u9879\u201C%s\u201D\u914D\u7F6E\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\u3002
|
||||
select.Error1=\u8BF7\u9009\u62E9%s\u8FDB\u884C\u64CD\u4F5C\u3002
|
||||
saveas.Error=\u53E6\u5B58\u6A21\u677F\u6570\u636E\u96C6\u5931\u8D25
|
||||
nobomline.Error=\u672A\u627E\u5230\u5173\u8054BOM\u884C
|
||||
@ -0,0 +1,260 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.classification.common.AbstractG4MApplication;
|
||||
import com.teamcenter.rac.classification.common.G4MApplicationPanel;
|
||||
import com.teamcenter.rac.classification.common.G4MUserAppContext;
|
||||
import com.teamcenter.rac.classification.common.table.G4MTable;
|
||||
import com.teamcenter.rac.classification.icm.ICMApplication;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentICO;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class G4MDialog extends AbstractAIFDialog {
|
||||
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private ICMApplication app;
|
||||
private MyG4MContext m_context;
|
||||
protected TCComponentICO ico;
|
||||
private String expandClass;
|
||||
InterfaceAIFComponent iaf;
|
||||
TCComponentForm form;
|
||||
TCSession session;
|
||||
List<PrefComponent> prefComponents;
|
||||
// public G4MDialog(String expandClass, InterfaceAIFComponent iaf, QZjsbjdBean jsbjdBean, TCSession session, TCComponentForm form) {
|
||||
// super(AIFDesktop.getActiveDesktop(), true);
|
||||
// this.jsbjdBean=jsbjdBean;
|
||||
// this.expandClass = expandClass;
|
||||
// this.iaf = iaf;
|
||||
// this.session=session;
|
||||
// this.form=form;
|
||||
// try {
|
||||
// this.app = new ICMApplication();
|
||||
// this.m_context = new MyG4MContext(app, "k0");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// initUI();
|
||||
// }
|
||||
public G4MDialog(String expandClass, InterfaceAIFComponent iaf, TCSession session,List<PrefComponent> prefComponents) {
|
||||
super(AIFDesktop.getActiveDesktop(), true);
|
||||
this.expandClass = expandClass;
|
||||
this.iaf = iaf;
|
||||
this.session=session;
|
||||
this.prefComponents = prefComponents;
|
||||
try {
|
||||
this.app = new ICMApplication();
|
||||
this.m_context = new MyG4MContext(app, "k0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
initUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
showDialog();
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
this.setTitle("材料选取");
|
||||
this.setLayout(new BorderLayout());
|
||||
this.setPreferredSize(new Dimension(1000, 600));
|
||||
this.setMinimumSize(new Dimension(640, 480));
|
||||
MyG4MPanel panel = new MyG4MPanel(null);
|
||||
try {
|
||||
m_context.openComponent(iaf);
|
||||
panel.initialize(m_context);
|
||||
this.add(BorderLayout.CENTER, panel);
|
||||
m_context.getTree().expandToClass(expandClass);
|
||||
// new Thread(m_context.getClassificationDialog()).start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// panel.open(iaf);
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
addListeners();
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
G4MTable table = m_context.getTablePane().getG4MTable();
|
||||
List<?> list = null;
|
||||
if (table != null) {
|
||||
ISelection sel = table.getSelection();
|
||||
if (sel != null && sel instanceof StructuredSelection) {
|
||||
list = ((StructuredSelection) sel).toList();
|
||||
|
||||
}
|
||||
}
|
||||
if (list == null || list.size() == 0) {
|
||||
MessageBox.post("请选择要使用的对象", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "请选择要使用的对象");
|
||||
return;
|
||||
}
|
||||
if (list.size() > 1) {
|
||||
MessageBox.post("请选择单行数据", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "请选择单行数据");
|
||||
return;
|
||||
}
|
||||
Object target = list.get(0);
|
||||
if (target != null && target instanceof TCComponentICO) {
|
||||
ico = (TCComponentICO) target;
|
||||
System.out.println(" ico.getClassId()=====" + ico.getClassId());
|
||||
|
||||
TCComponent classifiedObject = ico.getClassifiedObject();
|
||||
TCComponentItemRevision rev = null;
|
||||
if(classifiedObject instanceof TCComponentItemRevision) {
|
||||
rev = (TCComponentItemRevision) classifiedObject;
|
||||
}else if(classifiedObject instanceof TCComponentItem) {
|
||||
TCComponentItem item = (TCComponentItem) classifiedObject;
|
||||
try {
|
||||
rev = item.getLatestItemRevision();
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
System.out.println("ico.id==="+ico.getId());
|
||||
|
||||
|
||||
System.out.println("rev==="+rev);
|
||||
|
||||
|
||||
if(rev != null) {
|
||||
try {
|
||||
for (PrefComponent comp : prefComponents) {
|
||||
String key = comp.getPropConfig();
|
||||
if(key.contains(".")) {
|
||||
String[] split = key.split("\\.");
|
||||
if(split[0].equalsIgnoreCase("item")) {
|
||||
String stringProperty = rev.getItem().getStringProperty(split[1]);
|
||||
System.out.println(String.format("---set [%s]=[%s]", key, stringProperty));
|
||||
if(stringProperty != null && !stringProperty.isEmpty()) {
|
||||
comp.setValue(stringProperty);
|
||||
}
|
||||
|
||||
}else if(split[0].equalsIgnoreCase("rev")) {
|
||||
String stringProperty = rev.getStringProperty(split[1]);
|
||||
System.out.println(String.format("---set [%s]=[%s]", key, stringProperty));
|
||||
if(stringProperty != null && !stringProperty.isEmpty()) {
|
||||
comp.setValue(stringProperty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
MessageBox.post("请选择分类对象!", "提示", MessageBox.INFORMATION);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageBox.post("工序引用成功!!!", "成功", MessageBox.INFORMATION);
|
||||
} else {
|
||||
MessageBox.post("选择的数据不是ICO对象", "", MessageBox.INFORMATION);
|
||||
// KUtil.info(G4MDialog.this, "选择的数据不是ICO对象");
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private JPanel initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5));
|
||||
this.b_ok = new JButton("确定");
|
||||
this.b_cel = new JButton("取消");
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public class MyG4MContext extends G4MUserAppContext {
|
||||
|
||||
public MyG4MContext(AbstractAIFUIApplication paramAbstractAIFUIApplication, String paramString)
|
||||
throws Exception {
|
||||
super(paramAbstractAIFUIApplication, paramString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBusy(String paramString) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdle(String paramString) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MyG4MPanel extends G4MApplicationPanel {
|
||||
|
||||
public MyG4MPanel(AbstractG4MApplication paramAbstractG4MApplication) {
|
||||
super(paramAbstractG4MApplication);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeSignaled() {
|
||||
try {
|
||||
m_context.clear();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// m_context.openComponent(iaf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class MeopNoDialog extends KDialog {
|
||||
|
||||
private JButton b_insert;
|
||||
private JButton b_ok;
|
||||
protected DefaultTableModel tableModel;
|
||||
protected JTable table;
|
||||
private MeopNoDialogController controller;
|
||||
private boolean ok = false;
|
||||
private static final Registry REG = Registry.getRegistry(MeopNoDialog.class);
|
||||
|
||||
public MeopNoDialog(AbstractAIFDialog parent, boolean model, KDialogController controller) {
|
||||
super(parent, model, controller);
|
||||
this.controller = (MeopNoDialogController) controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
this.b_insert.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.insert();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(MeopNoDialog.this, e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ok = true;
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, String> getMeopInfo() throws Exception {
|
||||
if (!initDialog()) {
|
||||
return null;
|
||||
}
|
||||
controller.readMeop();
|
||||
showDialog();
|
||||
if (!ok) {
|
||||
return null;
|
||||
}
|
||||
return controller.getInsertedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(REG.getString("applymeopno.TITLE"));
|
||||
this.setPreferredSize(new Dimension(800, 600));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.CENTER, initTablePanel());
|
||||
this.add(BorderLayout.EAST, initBtnPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(16, 0, 7, 7));
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(0, 0, 12, 0));
|
||||
KUtil.newRow(panel, this.b_insert = new JButton(REG.getString("insert")), s, 1);
|
||||
KUtil.newRow(panel, this.b_ok = new JButton(REG.getString("ok")), s, 1);
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(panel, new JLabel(), s, 1);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initTablePanel() {
|
||||
this.tableModel = new DefaultTableModel();
|
||||
this.table = new JTable(tableModel);
|
||||
table.setRowHeight(23);
|
||||
tableModel.setDataVector(null, controller.tableHeaders);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
int colCnt = KUtil.getLen(controller.tableHeaders);
|
||||
TableColumnModel colModel = this.table.getColumnModel();
|
||||
for (int i = 0; i < colCnt; i++) {
|
||||
colModel.getColumn(i).setPreferredWidth(controller.tableHeaderWidth[i]);
|
||||
}
|
||||
if (colCnt > 5) {
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
}
|
||||
JScrollPane scroll = new JScrollPane(table);
|
||||
scroll.setBorder(null);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
public class MeopNoDialogController extends KDialogController {
|
||||
|
||||
public static final String PREF_MEOP_TYPE = "Connor_AVIC_SQGXH_GXLX";
|
||||
public static final String PREF_MEOP_TABLE = "Connor_AVIC_SQGXH_SXBJ";
|
||||
private String[] meopTypes;
|
||||
protected String[] tableHeaders;
|
||||
protected int[] tableHeaderWidth;
|
||||
private String[] tableProps;
|
||||
private MeopNoDialog dialog;
|
||||
private TCComponentBOMLine procLine;
|
||||
private int newRowNum = -1;
|
||||
private static final Registry REG = Registry.getRegistry(MeopNoDialogController.class);
|
||||
|
||||
public MeopNoDialogController(AbstractAIFApplication app, TCComponentBOMLine procLine) {
|
||||
super();
|
||||
this.procLine = procLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (MeopNoDialog) aifDialog;
|
||||
this.meopTypes = KUtil.getPrefVals(session, PREF_MEOP_TYPE);
|
||||
String[] tableConfigs = KUtil.getPrefVals(session, PREF_MEOP_TABLE);
|
||||
if (KUtil.getLen(meopTypes) == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TYPE));
|
||||
}
|
||||
if (KUtil.getLen(tableConfigs) == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TABLE));
|
||||
}
|
||||
int colCnt = KUtil.getLen(tableConfigs);
|
||||
tableHeaders = new String[colCnt];
|
||||
tableHeaderWidth = new int[colCnt];
|
||||
tableProps = new String[colCnt];
|
||||
for (int i = 0; i < colCnt; i++) {
|
||||
String config = tableConfigs[i];
|
||||
int ind = config.lastIndexOf('=');
|
||||
if (ind > 0) {
|
||||
tableHeaders[i] = config.substring(0, ind);
|
||||
tableProps[i] = config.substring(ind + 1);
|
||||
} else {
|
||||
tableHeaders[i] = config;
|
||||
tableProps[i] = config;
|
||||
}
|
||||
int width = 0;
|
||||
while (tableHeaders[i].length() > 0 && Character.isDigit(tableHeaders[i].charAt(0))) {
|
||||
width = width * 10 + (tableHeaders[i].charAt(0) - '0');
|
||||
tableHeaders[i] = tableHeaders[i].substring(1);
|
||||
}
|
||||
if (width < 1) {
|
||||
width = 120;
|
||||
}
|
||||
tableHeaderWidth[i] = width;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void readMeop() throws Exception {
|
||||
System.out.println("Load Meop: " + this.procLine+" | "+Arrays.toString(meopTypes));
|
||||
if (this.procLine == null) {
|
||||
return;
|
||||
}
|
||||
this.procLine.refresh();
|
||||
AIFComponentContext[] cc = this.procLine.getChildren();
|
||||
int len = KUtil.getLen(cc);
|
||||
for (int i = 0; i < len; i++) {
|
||||
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
|
||||
String cType = cLine.getItem().getType();
|
||||
System.out.println((i+1)+". "+cLine+" -> "+cType);
|
||||
if(KUtil.inArray(cType, meopTypes)>=0) {
|
||||
dialog.tableModel.addRow(new MeopNoRow(cLine).getRowData(tableProps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void insert() throws Exception {
|
||||
int selectedRow = dialog.table.getSelectedRow();
|
||||
System.out.println("Insert to: "+selectedRow);
|
||||
if(selectedRow<0) {
|
||||
newRowNum = dialog.table.getRowCount();
|
||||
dialog.tableModel.addRow(new Object[] {});
|
||||
}else {
|
||||
newRowNum = selectedRow;
|
||||
dialog.tableModel.insertRow(newRowNum, new Object[] {});
|
||||
}
|
||||
System.out.println("New RowNum: "+this.newRowNum);
|
||||
}
|
||||
|
||||
public Map<String, String> getInsertedData(){
|
||||
System.out.println("New RowNum: "+this.newRowNum);
|
||||
if(this.newRowNum<0) {
|
||||
return null;
|
||||
}
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
int colCnt = KUtil.getLen(tableProps);
|
||||
for(int i=0; i<colCnt; i++) {
|
||||
String value = (String) dialog.table.getValueAt(this.newRowNum, i);
|
||||
if(value==null) {
|
||||
value = "";
|
||||
}
|
||||
res.put(tableProps[i], value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.aifrcp.util.PropLocation;
|
||||
|
||||
public class MeopNoRow {
|
||||
|
||||
private TCComponentBOMLine bomline;
|
||||
|
||||
public MeopNoRow(TCComponentBOMLine cLine) {
|
||||
this.bomline = cLine;
|
||||
}
|
||||
|
||||
|
||||
public Object[] getRowData(String[] tableProps) throws Exception{
|
||||
int len = KUtil.getLen(tableProps);
|
||||
Object[] data = new Object[len];
|
||||
Map<String, TCComponent> markedComponents = new HashMap<String, TCComponent>();
|
||||
PropLocation.initLocationMap(markedComponents , bomline);
|
||||
for(int i=0; i<len; i++) {
|
||||
String[] config = tableProps[i].split("\\.");
|
||||
if(KUtil.getLen(config)!=2) {
|
||||
data[i] = tableProps[i];
|
||||
continue;
|
||||
}
|
||||
String propLoc = config[0].toUpperCase();
|
||||
if(markedComponents.containsKey(propLoc)) {
|
||||
data[i] = markedComponents.get(propLoc).getProperty(config[1]);
|
||||
}else {
|
||||
data[i] = tableProps[i];
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,311 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
import com.teamcenter.rac.util.iTextField;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.newmeop.NewMeopDialogController.MEOPType;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NewMeopDialog extends KDialog {
|
||||
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
protected DefaultListModel<MEOPType> lm_type;
|
||||
protected JList<MEOPType> l_type;
|
||||
private NewMeopDialogController controller;
|
||||
private JButton b_assignId;
|
||||
private PrefComponent idComponent;
|
||||
private Map<PrefComponent,JButton> chooseComponents = new HashMap<PrefComponent, JButton>();
|
||||
private PrefComponent sequenceComponent;
|
||||
private JButton b_assignMeopNo;
|
||||
private JButton b_insertMeopNo;
|
||||
private JButton b_WorkCenter;
|
||||
protected iTextField tf_WorkCenter;
|
||||
private static final Registry REG = Registry.getRegistry(NewMeopDialog.class);
|
||||
|
||||
public NewMeopDialog(KDialogController controller) {
|
||||
super(controller);
|
||||
this.controller = (NewMeopDialogController)controller;
|
||||
}
|
||||
|
||||
private void setCompEnabled(boolean b) {
|
||||
b_ok.setEnabled(b);
|
||||
b_cel.setEnabled(b);
|
||||
for (JButton btn : chooseComponents.values()) {
|
||||
btn.setEnabled(b);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAssignId(String newId) {
|
||||
if(idComponent!=null&&b_assignId!=null) {
|
||||
if(KUtil.isEmpty(newId)) {
|
||||
idComponent.setValue(null);
|
||||
b_assignId.setEnabled(true);
|
||||
}else {
|
||||
idComponent.setValue(newId);
|
||||
b_assignId.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMeopNo(String newId) {
|
||||
if(sequenceComponent!=null&&b_assignMeopNo!=null&&b_insertMeopNo!=null) {
|
||||
if(KUtil.isEmpty(newId)) {
|
||||
sequenceComponent.setValue(null);
|
||||
// b_assignMeopNo.setEnabled(true);
|
||||
// b_insertMeopNo.setEnabled(true);
|
||||
}else {
|
||||
sequenceComponent.setValue(newId);
|
||||
// b_assignMeopNo.setEnabled(false);
|
||||
// b_insertMeopNo.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
if(b_WorkCenter != null)
|
||||
b_WorkCenter.addActionListener(new ActionListener() {//TODO b_WorkCenter
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.chooseWorkCenter();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(NewMeopDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setCompEnabled(false);
|
||||
try {
|
||||
controller.doCreate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(NewMeopDialog.this,e);
|
||||
}
|
||||
setCompEnabled(true);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
if(b_assignId!=null&&idComponent!=null) {
|
||||
b_assignId.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.assignId();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(NewMeopDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if(this.sequenceComponent!=null&&this.b_assignMeopNo!=null&&this.b_insertMeopNo!=null) {
|
||||
b_assignMeopNo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.assignMeopNo();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(NewMeopDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
b_insertMeopNo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
controller.insertMeopNo();
|
||||
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
MessageBox.post(NewMeopDialog.this,e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for (PrefComponent bean : chooseComponents.keySet()) {
|
||||
JButton btn = chooseComponents.get(bean);
|
||||
btn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MEOPType typeComp = l_type.getSelectedValue();
|
||||
if (typeComp == null) {
|
||||
MessageBox.post(NewMeopDialog.this, REG.getString("selectMeopType.INFO"), "", MessageBox.WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
//bean.performChoose(NewMeopDialog.this, typeComp.type, controller.getApp(), controller.prefComponents);
|
||||
G4MDialog classDialog = new G4MDialog("¾«µñ·ÖÀà", null, controller.session,controller.prefComponents);
|
||||
new Thread(classDialog).start();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
this.l_type.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent arg0) {
|
||||
if(arg0.getValueIsAdjusting()) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Select Type Change > "+l_type.getSelectedValue());
|
||||
setAssignId(null);
|
||||
setMeopNo(null);
|
||||
if(controller.shortDescPrefComp!=null&&l_type.getSelectedValue()!=null) {
|
||||
controller.shortDescPrefComp.setValue(l_type.getSelectedValue().additional);
|
||||
}
|
||||
controller.clearWorkCenter();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(REG.getString("newmeop.TITLE"));
|
||||
this.setPreferredSize(new Dimension(850, 780));
|
||||
this.setMinimumSize(new Dimension(850, 780));
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(BorderLayout.WEST, initTypePanel());
|
||||
this.add(BorderLayout.CENTER, initPropPanel());
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
|
||||
this.b_ok = new JButton(REG.getString("ok"));
|
||||
this.b_cel = new JButton(REG.getString("cancel"));
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initPropPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(BorderLayout.CENTER, initMEPropPanel());
|
||||
panel.add(BorderLayout.SOUTH, initDESCPropPanel());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initDESCPropPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
if(controller.shortDescPrefComp!=null) {
|
||||
//panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), ProcessLocale.getString("medesc.TITLE")));
|
||||
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), controller.shortDescPrefComp.getLabel().getText()));
|
||||
JScrollPane scroll = new JScrollPane(controller.shortDescPrefComp.getValueComp());
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
controller.prefComponents.add(controller.shortDescPrefComp);
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initMEPropPanel() {
|
||||
JPanel wrapper = new JPanel(new BorderLayout());
|
||||
wrapper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), REG.getString("meinfo.TITLE")));
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(20,30,20,30));
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(6, 6, 6, 6));
|
||||
List<PrefComponent> comps = controller.prefComponents;
|
||||
int colCnt = 1;
|
||||
int size = comps.size();
|
||||
for(int i=0;i<size;i++) {
|
||||
PrefComponent prefComponent = comps.get(i);
|
||||
if(i%colCnt==0) {
|
||||
KUtil.newRow(panel, prefComponent.label, s, 1);
|
||||
}else {
|
||||
KUtil.addCol(panel, prefComponent.label, s, 1, 0);
|
||||
}
|
||||
KUtil.addCol(panel, prefComponent.getValueComp(), s, 1, 1);
|
||||
if("item.item_id".equals(prefComponent.propConfig.toLowerCase())) {
|
||||
KUtil.addCol(panel, this.b_assignId = new JButton(REG.getString("assign")), s, 1, 0);
|
||||
this.idComponent = prefComponent;
|
||||
}
|
||||
//else if(KUtil.getLen(prefComponent.getExcelConfig())>0) {
|
||||
else if("item.object_name".equals(prefComponent.propConfig.toLowerCase())) {
|
||||
JButton b_choose = new JButton(REG.getString("select"));
|
||||
KUtil.addCol(panel, b_choose, s, 1, 0);
|
||||
chooseComponents.put(prefComponent, b_choose);
|
||||
// }else if("revmaster.ac5_OperationNumber".equalsIgnoreCase(prefComponent.propConfig)) {
|
||||
}else if("bomline.bl_sequence_no".equalsIgnoreCase(prefComponent.propConfig)) {
|
||||
KUtil.addCol(panel,this.b_assignMeopNo = new JButton(REG.getString("shenqing")), s, 1, 0);
|
||||
KUtil.addCol(panel,this.b_insertMeopNo = new JButton(REG.getString("insert")), s, 1, 0);
|
||||
this.b_insertMeopNo.setVisible(false);
|
||||
this.sequenceComponent = prefComponent;
|
||||
}
|
||||
}
|
||||
/*KUtil.newRow(panel, new JLabel(REG.getString("workcenter")), s, 1);
|
||||
this.tf_WorkCenter = new iTextField(18);
|
||||
// this.tf_WorkCenter.setRequired(true);
|
||||
// this.tf_WorkCenter.setEditable(false);//TODO tf_WorkCenter
|
||||
KUtil.addCol(panel, tf_WorkCenter, s, 1, 1);
|
||||
KUtil.addCol(panel, this.b_WorkCenter = new JButton(REG.getString("select")), s, 1, 0);*/
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(panel, new JLabel(""), s, 1);
|
||||
JScrollPane scroll = new JScrollPane(panel);
|
||||
//scroll.setBorder(null);
|
||||
wrapper.add(BorderLayout.CENTER, scroll);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private Component initTypePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setPreferredSize(new Dimension(200,0));
|
||||
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 0), REG.getString("meoptype.TITLE")));
|
||||
this.lm_type = new DefaultListModel<MEOPType>();
|
||||
this.l_type = new JList<MEOPType>(lm_type);
|
||||
for (MEOPType t : controller.meopTypes) {
|
||||
this.lm_type.addElement(t);
|
||||
}
|
||||
if(controller.meopTypes.size() == 1) {
|
||||
l_type.setSelectedIndex(0);
|
||||
}
|
||||
this.l_type.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
JScrollPane scroll = new JScrollPane(this.l_type);
|
||||
panel.add(BorderLayout.CENTER, scroll);
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,629 @@
|
||||
package cn.net.connor.std.processedit.newmeop;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.SoaUtil;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
import com.teamcenter.services.rac.core.DataManagementService;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.processview.KAssignResourceCommand;
|
||||
import cn.net.connor.std.processedit.util.OptionItem;
|
||||
import cn.net.connor.std.processedit.util.PrefComponent;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
|
||||
public class NewMeopDialogController extends KDialogController {
|
||||
|
||||
private NewMeopDialog dialog;
|
||||
private TCComponentBOMLine targetLine;
|
||||
private TCComponentItemRevision targetRev;
|
||||
public static final String PREF_PREFIX = "Connor_AVIC_MEOP_";
|
||||
public static final String PREF_PREFIX_EXCEL = "Connor_AVIC_MEOPEXCEL_";
|
||||
public static final String PREF_PROPS = "Connor_AVIC_MEOP_Properties";
|
||||
public static final String PREF_REL_LOV = "Connor_AVIC_MEOP_LOV_";
|
||||
public static final String PREF_WORKCENTER_CLS_ID = "Connor_AVIC_MEOP_WorkCenter_Class";
|
||||
public static final Registry REG = Registry.getRegistry(NewMeopDialogController.class);
|
||||
|
||||
protected List<MEOPType> meopTypes = new ArrayList<NewMeopDialogController.MEOPType>();
|
||||
protected List<PrefComponent> prefComponents = new ArrayList<PrefComponent>();
|
||||
protected int propCols = 1;
|
||||
protected PrefComponent shortDescPrefComp;
|
||||
private KAssignResourceCommand workcenterCmd;
|
||||
public TCSession session;
|
||||
public class MEOPType {
|
||||
protected String type;
|
||||
protected String disType;
|
||||
protected String additional;
|
||||
protected TCComponentItemType itemType;
|
||||
protected boolean isPrecise;
|
||||
|
||||
public MEOPType(TCSession session, String type, String disType, String additional, boolean isPrecise) throws Exception {
|
||||
this.type = type;
|
||||
this.disType = disType;
|
||||
this.additional = additional;
|
||||
this.isPrecise = isPrecise;
|
||||
this.itemType = (TCComponentItemType) session.getTypeComponent(type);
|
||||
if (this.itemType == null) {
|
||||
throw new Exception(String.format(REG.getString("typenotfound.ERROR1"), type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return " " + disType;
|
||||
}
|
||||
}
|
||||
|
||||
public NewMeopDialogController(AbstractAIFApplication app) {
|
||||
super();
|
||||
session = (TCSession) app.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (NewMeopDialog) aifDialog;
|
||||
InterfaceAIFComponent comp = app.getTargetComponent();
|
||||
System.out.println("Select: " + comp);
|
||||
if (comp != null) {
|
||||
if (comp instanceof TCComponentBOMLine) {
|
||||
this.targetLine = (TCComponentBOMLine) comp;
|
||||
TCComponentItemRevision rev = this.targetLine.getItemRevision();
|
||||
System.out.println(">> " + rev.getType());
|
||||
if (ProcessUtil.isMEProcess(session, rev.getItem().getType())) {
|
||||
// if (rev instanceof TCComponentMEProcessRevision) {
|
||||
this.targetRev = rev;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetRev == null) {
|
||||
throw new TCException(REG.getString("selectprocessrev.ERROR"));
|
||||
}
|
||||
{
|
||||
String prefName = PREF_PREFIX + this.targetRev.getType();
|
||||
String[] prefVals = KUtil.getPrefVals(session, prefName);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
for (int i = 0; i < len; i++) {
|
||||
String type = prefVals[i];
|
||||
boolean isPrecise = type.startsWith("#");
|
||||
if (isPrecise) {
|
||||
type = type.substring(1);
|
||||
}
|
||||
String addition = "";
|
||||
int ind = type.indexOf('=');
|
||||
if (ind > 0) {
|
||||
addition = type.substring(ind + 1).replace("\\n", "\n");
|
||||
type = type.substring(0, ind);
|
||||
}
|
||||
String disType = KUtil.getTypeName(session, type);
|
||||
if (KUtil.isEmpty(disType)) {
|
||||
System.out.println("Error Config: " + prefVals[i]);
|
||||
continue;
|
||||
}
|
||||
this.meopTypes.add(new MEOPType(session, type, disType, addition, isPrecise));
|
||||
}
|
||||
if (this.meopTypes.size() == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), prefName));
|
||||
}
|
||||
}
|
||||
{
|
||||
String[] prefVals = KUtil.getPrefVals(session, PREF_PROPS);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
for (int i = 0; i < len; i++) {
|
||||
String pref = prefVals[i];
|
||||
if (pref.length() == 1 && Character.isDigit(pref.charAt(0))) {
|
||||
int col = pref.charAt(0) - '0';
|
||||
if (col > 0) {
|
||||
System.out.println("Reset Proc Col: " + col);
|
||||
this.propCols = col;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
PrefComponent prefComp = new PrefComponent(pref, "");
|
||||
if (prefComp.init(session, targetRev, prefComponents)) {
|
||||
prefComponents.add(prefComp);
|
||||
} else {
|
||||
System.out.println("Error Config: " + pref);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (prefComponents.size() == 0) {
|
||||
throw new TCException(String.format(REG.getString("prefnotconfiged.ERROR1"), PREF_PROPS));
|
||||
}
|
||||
|
||||
for (int i = 0; i < prefComponents.size(); i++) {
|
||||
PrefComponent prefParent = prefComponents.get(i);
|
||||
if (prefParent.isLovParent) {
|
||||
for (int j = 0; j < prefComponents.size(); j++) {
|
||||
PrefComponent prefChild = prefComponents.get(j);
|
||||
if (prefParent.lovName.equals(prefChild.lovName) && prefChild.isLovChild) {
|
||||
prefParent.comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String selectedProvince = (String) prefParent.bigJtf.getText();
|
||||
if (selectedProvince != null) {
|
||||
List<String> cities = prefParent.listLov.get(selectedProvince);
|
||||
|
||||
// 清空子级控件和数据
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.opHashMap.clear();
|
||||
prefChild.lovDisRealMap.clear();
|
||||
prefChild.list.clear();
|
||||
|
||||
if (cities != null && !cities.isEmpty()) {
|
||||
for (String city : cities) {
|
||||
OptionItem optionItem = new OptionItem(city, "");
|
||||
prefChild.comboBox.addItem(optionItem);
|
||||
prefChild.opHashMap.put(city, optionItem);
|
||||
prefChild.lovDisRealMap.put(city, city);
|
||||
prefChild.list.add(city);
|
||||
}
|
||||
// 关键:不自动选中任何项
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
} else {
|
||||
// 没有子项时也确保无选中
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
}
|
||||
} else {
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.comboBox.setSelectedIndex(-1); // 确保无选中
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String descPropName = REG.getString("shortdesc.PROPNAME");
|
||||
this.shortDescPrefComp = new PrefComponent(descPropName, "");
|
||||
if (!shortDescPrefComp.init(session, targetRev, prefComponents)) {
|
||||
this.shortDescPrefComp = null;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void assignId() throws Exception {
|
||||
MEOPType type = dialog.l_type.getSelectedValue();
|
||||
if (type == null) {
|
||||
throw new TCException(REG.getString("selectMeopType.INFO"));
|
||||
}
|
||||
TCComponentItemType itemType = type.itemType;
|
||||
String newId = itemType.getNewID();
|
||||
System.out.println("New ID: " + type.type + " -> " + newId);
|
||||
dialog.setAssignId(newId);
|
||||
}
|
||||
|
||||
public int getMeopNo(TCComponentBOMLine line) throws Exception {
|
||||
// TCComponentItemRevision rev = line.getItemRevision();
|
||||
// if (rev == null) {
|
||||
// throw new TCException("Get Revision Failed: " + line);
|
||||
// }
|
||||
// TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
|
||||
// if (form == null) {
|
||||
// throw new TCException("Get RevisionMaster Failed: " + rev);
|
||||
// }
|
||||
// form.refresh();
|
||||
// String seqStr = form.getStringProperty("ac5_OperationNumber");
|
||||
String seqStr = line.getProperty("bl_sequence_no");
|
||||
System.out.println("Op Number: " + line + " -> " + seqStr);
|
||||
int seq = 0;
|
||||
if (!KUtil.isEmpty(seqStr)) {
|
||||
try {
|
||||
seq = Integer.parseInt(seqStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setMeopNo(TCComponentBOMLine line, int meopNo) throws Exception {
|
||||
System.out.println("Set Op Number: " + line + " -> " + meopNo);
|
||||
line.lock();
|
||||
try {
|
||||
line.setProperty("bl_sequence_no", meopNo + "");
|
||||
line.save();
|
||||
} finally {
|
||||
line.unlock();
|
||||
}
|
||||
targetLine.refresh();
|
||||
// if(meopNo<0) {
|
||||
// return;
|
||||
// }
|
||||
// TCComponentItemRevision rev = line.getItemRevision();
|
||||
// if (rev == null) {
|
||||
// throw new TCException("Get Revision Failed: " + line);
|
||||
// }
|
||||
// TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
|
||||
// if (form == null) {
|
||||
// throw new TCException("Get RevisionMaster Failed: " + rev);
|
||||
// }
|
||||
// form.refresh();
|
||||
// form.lock();
|
||||
// try {
|
||||
// form.setStringProperty("ac5_OperationNumber", meopNo + "");
|
||||
// form.save();
|
||||
// form.refresh();
|
||||
// } finally {
|
||||
// form.unlock();
|
||||
// }
|
||||
}
|
||||
|
||||
public void assignMeopNo() throws Exception {
|
||||
targetLine.refresh();
|
||||
AIFComponentContext[] cc = targetLine.getChildren();
|
||||
int maxSeq = 0;
|
||||
int len = KUtil.getLen(cc);
|
||||
for (int i = 0; i < len; i++) {
|
||||
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
|
||||
int seq = getMeopNo(cLine);
|
||||
maxSeq = Math.max(seq, maxSeq);
|
||||
}
|
||||
maxSeq += 10;
|
||||
System.out.println("New Sequence: " + maxSeq);
|
||||
dialog.setMeopNo("" + maxSeq);
|
||||
}
|
||||
|
||||
public void insertMeopNo() throws Exception {
|
||||
Map<String, String> propData = new MeopNoDialog(dialog, true, new MeopNoDialogController(app, targetLine)).getMeopInfo();
|
||||
System.out.println("Prop Info: " + propData);
|
||||
if (propData == null || propData.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (PrefComponent comp : prefComponents) {
|
||||
String key = comp.getPropConfig();
|
||||
if (propData.containsKey(key)) {
|
||||
String value = propData.get(key);
|
||||
System.out.println(String.format("set [%s]=[%s]", key, value));
|
||||
comp.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void doCreate() throws Exception {
|
||||
MEOPType typeComp = dialog.l_type.getSelectedValue();
|
||||
if (typeComp == null) {
|
||||
throw new TCException(REG.getString("selectMeopType.INFO"));
|
||||
}
|
||||
TCComponentItemType itemType = typeComp.itemType;
|
||||
// Check Require
|
||||
// if (!checkRequire()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String type = itemType.getName();
|
||||
System.out.println("Select Type: " + type);
|
||||
if (KUtil.isEmpty(type)) {
|
||||
throw new TCException(REG.getString("selectType.INFO"));
|
||||
}
|
||||
if (!checkRequire()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String checkCombox = checkCombox();
|
||||
|
||||
|
||||
System.out.println("checkCombox==="+checkCombox);
|
||||
|
||||
if (!checkCombox.equals("")) {
|
||||
|
||||
throw new Exception(checkCombox);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TCComponentItemRevisionType revType = itemType.getItemRevisionType();
|
||||
String revTypeName = revType.getName();
|
||||
String itemMasterTypeName = type + " Master";
|
||||
String revMasterTypeName = revTypeName + " Master";
|
||||
if (session.getTypeComponent(itemMasterTypeName) == null) {
|
||||
itemMasterTypeName = type + "Master";
|
||||
}
|
||||
if (session.getTypeComponent(revMasterTypeName) == null) {
|
||||
revMasterTypeName = revTypeName + "Master";
|
||||
}
|
||||
TCComponentType revMasterType = session.getTypeComponent(revMasterTypeName);
|
||||
TCComponentType itemMasterType = session.getTypeComponent(itemMasterTypeName);
|
||||
System.out.println("Revision Type: " + type);
|
||||
System.out.println("Item Master Type: " + itemMasterTypeName);
|
||||
System.out.println("Revision Master Type: " + revMasterTypeName);
|
||||
Map<String, String> revPropMap = new HashMap<>();
|
||||
Map<String, String> revMasterPropMap = new HashMap<>();
|
||||
Map<String, String> itemPropMap = new HashMap<>();
|
||||
Map<String, String> itemMasterPropMap = new HashMap<>();
|
||||
Map<String, Double> revPropMapD = new HashMap<>();
|
||||
Map<String, Double> revMasterPropMapD = new HashMap<>();
|
||||
Map<String, Double> itemPropMapD = new HashMap<>();
|
||||
Map<String, Double> itemMasterPropMapD = new HashMap<>();
|
||||
Map<String, String> bomLinePropMap = new HashMap<>();
|
||||
for (PrefComponent prefComponent : this.prefComponents) {
|
||||
// KUtil.initPropMap(prefComponent.propConfig, prefComponent.getValue(),
|
||||
// itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap,
|
||||
// bomLinePropMap);
|
||||
String propConfig = prefComponent.propConfig;
|
||||
String value = prefComponent.getValue();
|
||||
if (KUtil.isEmpty(propConfig)) {
|
||||
continue;
|
||||
}
|
||||
String propFrom = null, propName = null;
|
||||
String[] split = propConfig.split("\\.");
|
||||
if (KUtil.getLen(split) == 2) {
|
||||
propFrom = split[0].trim().toUpperCase();
|
||||
propName = split[1].trim();
|
||||
}
|
||||
if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) {
|
||||
continue;
|
||||
}
|
||||
TCComponentType targetType = null;
|
||||
Map<String, String> target;
|
||||
Map<String, Double> targetD = null;
|
||||
if ("ITEM".equals(propFrom)) {
|
||||
target = itemPropMap;
|
||||
targetD = itemPropMapD;
|
||||
targetType = itemType;
|
||||
// System.out.println(">> ITEM PROP: " + propName + " = " + value);
|
||||
} else if ("REV".equals(propFrom)) {
|
||||
// System.out.println(">> REV PROP: " + propName + " = " + value);
|
||||
target = revPropMap;
|
||||
targetD = revPropMapD;
|
||||
targetType = revType;
|
||||
} else if ("ITEMMASTER".equals(propFrom)) {
|
||||
// System.out.println(">> ITEMMASTER PROP: " + propName + " = " + value);
|
||||
target = itemMasterPropMap;
|
||||
targetD = itemMasterPropMapD;
|
||||
targetType = itemMasterType;
|
||||
} else if ("REVMASTER".equals(propFrom)) {
|
||||
// System.out.println(">> REVMASTER PROP: " + propName + " = " + value);
|
||||
target = revMasterPropMap;
|
||||
targetD = revMasterPropMapD;
|
||||
targetType = revMasterType;
|
||||
} else if ("BOMLINE".equals(propFrom)) {
|
||||
System.out.println(">> BOMLINE PROP: " + propName + " = " + value);
|
||||
target = bomLinePropMap;
|
||||
} else {
|
||||
throw new TCException(String.format(KUtil.REG.getString("proplocationnotdefined.ERROR1"), propFrom));
|
||||
}
|
||||
if (target == null && targetD == null) {
|
||||
return;
|
||||
}
|
||||
if (targetType != null) {
|
||||
TCPropertyDescriptor desc = targetType.getPropDesc(propName);
|
||||
// System.out.println(propName+" - "+desc.getType());
|
||||
if (desc != null && desc.getType() == TCPropertyDescriptor.SERVER_PROP_double) {
|
||||
if (!KUtil.isEmpty(value)) {
|
||||
double d = Double.parseDouble(value);
|
||||
targetD.put(propName, d);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
target.put(propName, value);
|
||||
}
|
||||
String bl_sequence_no = bomLinePropMap.get("bl_sequence_no");
|
||||
int n = 0;
|
||||
for(AIFComponentContext l : targetLine.getChildren()) {
|
||||
TCComponentBOMLine line = (TCComponentBOMLine) l.getComponent();
|
||||
if(line.getProperty("bl_sequence_no").equals(bl_sequence_no))
|
||||
n++;
|
||||
}
|
||||
if(n >= 3) {
|
||||
throw new TCException(REG.getString("sequence.ERROR"));
|
||||
}
|
||||
String propType = "ac5_Type";
|
||||
// propType = "object_desc"; //
|
||||
// revMasterPropMap.remove("nhl8_ProShortDescss"); //TODO
|
||||
if (revMasterPropMap.containsKey(propType)) {
|
||||
String ac5Type = revMasterPropMap.get(propType);
|
||||
System.out.println(propType + ": " + ac5Type);
|
||||
if (!KUtil.isEmpty(ac5Type)) {
|
||||
revPropMap.put("item_revision_id", ac5Type + "00");
|
||||
}
|
||||
}
|
||||
CreateInput revMasterInput = new CreateInput();
|
||||
revMasterInput.boName = revMasterTypeName;
|
||||
revMasterInput.stringProps = revMasterPropMap;
|
||||
revMasterInput.doubleProps = revMasterPropMapD;
|
||||
CreateInput itemMasterInput = new CreateInput();
|
||||
itemMasterInput.boName = itemMasterTypeName;
|
||||
itemMasterInput.stringProps = itemMasterPropMap;
|
||||
itemMasterInput.doubleProps = itemMasterPropMapD;
|
||||
CreateInput revInput = new CreateInput();
|
||||
revInput.boName = revTypeName;
|
||||
revInput.stringProps = revPropMap;
|
||||
revInput.doubleProps = revPropMapD;
|
||||
Map<String, CreateInput[]> revMasterInfoMap = new HashMap<>();
|
||||
revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput });
|
||||
revInput.compoundCreateInput = revMasterInfoMap;
|
||||
// create rev
|
||||
CreateInput itemInput = new CreateInput();
|
||||
itemInput.boName = type;
|
||||
itemInput.stringProps = itemPropMap;
|
||||
itemInput.doubleProps = itemPropMapD;
|
||||
Map<String, CreateInput[]> revInfoMap = new HashMap<>();
|
||||
revInfoMap.put("revision", new CreateInput[] { revInput });
|
||||
revInfoMap.put("IMAN_master_form", new CreateInput[] { itemMasterInput });
|
||||
itemInput.compoundCreateInput = revInfoMap;
|
||||
// create info
|
||||
CreateIn cI = new CreateIn();
|
||||
cI.clientId = "CreateItem";
|
||||
cI.data = itemInput;
|
||||
// service
|
||||
DataManagementService service = DataManagementService.getService(session);
|
||||
// create
|
||||
CreateResponse resp = service.createObjects(new CreateIn[] { cI });
|
||||
SoaUtil.checkPartialErrors(resp.serviceData);
|
||||
CreateOut[] cOs = resp.output;
|
||||
TCComponentItem newItem = null;
|
||||
if (cOs.length > 0) {
|
||||
for (TCComponent s : cOs[0].objects) {
|
||||
if (s instanceof TCComponentItem) {
|
||||
newItem = (TCComponentItem) s;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("New Item: " + newItem);
|
||||
if (newItem == null) {
|
||||
throw new TCException(REG.getString("createprocess.ERROR"));
|
||||
}
|
||||
newItem.refresh();
|
||||
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
|
||||
System.out.println("New Rev: " + newRev);
|
||||
TCComponentBOMLine newLine = this.targetLine.add(newItem, newRev, null, false);
|
||||
if (bomLinePropMap.size() > 0) {
|
||||
System.out.println("Set Bom Property: " + bomLinePropMap);
|
||||
newLine.setProperties(bomLinePropMap);
|
||||
newLine.refresh();
|
||||
}
|
||||
targetLine.setPrecision(true);
|
||||
TCComponentItemType t = (TCComponentItemType) session.getTypeService().getTypeComponent("Item");
|
||||
TCComponentItem item1 = t.findItems("000001")[0];
|
||||
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
TCComponentBOMWindow window = bomWinType.create(null);
|
||||
TCComponentBOMLine newBom = window.setWindowTopLine(null, newRev, null, null);
|
||||
TCComponentBOMLine newnewLine = newBom.add(item1, item1.getLatestItemRevision(), null, false);
|
||||
window.save();
|
||||
newnewLine.cut();
|
||||
window.save();
|
||||
window.close();
|
||||
if(workcenterCmd != null) {
|
||||
System.out.println("Add Workcenter: " + workcenterCmd.getSelected());
|
||||
workcenterCmd.doAssign(newLine);
|
||||
}
|
||||
session.queueOperation(new AbstractAIFOperation() {
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
try {
|
||||
System.out.println("Switch to Precise: " + typeComp.isPrecise);
|
||||
newLine.setPrecision(typeComp.isPrecise);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
targetLine.refresh();
|
||||
}
|
||||
});
|
||||
dialog.setAssignId(null);
|
||||
dialog.setMeopNo(null);
|
||||
for (PrefComponent c : this.prefComponents) {
|
||||
c.setValue(null);
|
||||
}
|
||||
if (this.shortDescPrefComp != null) {
|
||||
this.shortDescPrefComp.setValue(null);
|
||||
}
|
||||
clearWorkCenter();
|
||||
}
|
||||
|
||||
private boolean checkRequire() {
|
||||
List<String> requireTitles = new ArrayList<String>();
|
||||
for (PrefComponent prefComponent : this.prefComponents) {
|
||||
if (!prefComponent.checkRequire()) {
|
||||
requireTitles.add(prefComponent.title.replace(" ", "").replace(":", "").replace(REG.getString("CN_SYMBEL4"), "").replace(REG.getString("CN_SYMBEL5"), ""));
|
||||
}
|
||||
}
|
||||
// if (workcenterCmd!=null && this.workcenterCmd.getSelected() == null) {
|
||||
// requireTitles.add(REG.getString("workcenter"));
|
||||
// }
|
||||
if (requireTitles.size() > 0) {
|
||||
MessageBox.post(dialog, String.format(REG.getString("requireprop.INFO1"), requireTitles.toString()), "", MessageBox.WARNING);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public AbstractAIFApplication getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void chooseWorkCenter() throws Exception {
|
||||
if (this.workcenterCmd == null) {
|
||||
MEOPType typeComp = dialog.l_type.getSelectedValue();
|
||||
if (typeComp == null) {
|
||||
throw new TCException(REG.getString("selectMeopType.INFO"));
|
||||
}
|
||||
TCComponentItemType itemType = typeComp.itemType;
|
||||
TCComponentItem item = new TCComponentItem() {
|
||||
@Override
|
||||
public TCComponentItemType getTypeComponent() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TCSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getClassNameHierarchy() throws TCException {
|
||||
return itemType.getClassNameHierarchy();
|
||||
}
|
||||
};
|
||||
System.out.println("TypeName: " + itemType);
|
||||
this.workcenterCmd = new KAssignResourceCommand(KUtil.getPrefVal(session, NewMeopDialogController.PREF_WORKCENTER_CLS_ID), item);
|
||||
}
|
||||
this.workcenterCmd.executeModal();
|
||||
TCComponent comp = workcenterCmd.getSelected();
|
||||
if(dialog.tf_WorkCenter != null)
|
||||
dialog.tf_WorkCenter.setText(comp == null ? "" : comp.toString());
|
||||
}
|
||||
|
||||
public void clearWorkCenter() {
|
||||
workcenterCmd = null;
|
||||
if(dialog.tf_WorkCenter != null)
|
||||
dialog.tf_WorkCenter.setText("");
|
||||
}
|
||||
|
||||
private String checkCombox() {
|
||||
List<String> requireTitles = new ArrayList<String>();
|
||||
for (PrefComponent prefComponent : prefComponents) {
|
||||
if (!prefComponent.checkCombox()) {
|
||||
requireTitles.add(prefComponent.title+"请选择下拉值!");
|
||||
}
|
||||
}
|
||||
if (requireTitles.size() > 0) {
|
||||
//MessageBox.post(dialog, String.format(REG.getString("requireprop.INFO1"), requireTitles.toString()), "", MessageBox.WARNING);
|
||||
return requireTitles.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
shortdesc.PROPNAME=$\u5DE5\u827A\u77ED\u63CF\u8FF0=revmaster.object_desc
|
||||
#shortdesc.PROPNAME=$\u5DE5\u827A\u77ED\u63CF\u8FF0=revmaster.object_desc
|
||||
selectMeopType.INFO=\u8BF7\u5148\u9009\u62E9\u5DE5\u5E8F\u7C7B\u578B
|
||||
newmeop.TITLE=\u521B\u5EFA\u5DE5\u5E8F
|
||||
ok=\u786E\u5B9A
|
||||
cancel=\u53D6\u6D88
|
||||
assign=\u6307\u6D3E
|
||||
select=\u9009\u62E9
|
||||
shenqing=\u7533\u8BF7
|
||||
insert=\u63D2\u5165
|
||||
meoptype.TITLE=\u5DE5\u5E8F\u7C7B\u578B
|
||||
meinfo.TITLE=\u5DE5\u827A/\u5DE5\u5E8F\u4FE1\u606F
|
||||
applymeopno.TITLE=\u7533\u8BF7\u5DE5\u5E8F\u53F7
|
||||
prefnotconfiged.ERROR1=\u9996\u9009\u9879\u672A\u914D\u7F6E\uFF1A%s
|
||||
typenotfound.ERROR1=\u672A\u5B9A\u4E49\u5BF9\u8C61\u7C7B\u578B\uFF1A%s
|
||||
selectprocessrev.ERROR=\u8BF7\u9009\u62E9\u5DE5\u827A\u8FDB\u884C\u64CD\u4F5C
|
||||
selectType.INFO=\u8BF7\u9009\u62E9\u8981\u521B\u5EFA\u7684\u5BF9\u8C61\u7C7B\u578B
|
||||
createprocess.ERROR=\u521B\u5EFA\u5DE5\u827A\u5F02\u5E38
|
||||
requireprop.INFO1=\u8BF7\u586B\u5199\u5FC5\u586B\u5C5E\u6027\uFF1A\: %s
|
||||
workcenter=\u5DE5\u4F5C\u4E2D\u5FC3
|
||||
sequence.ERROR=\u540C\u4E00\u5DE5\u827A\u8DEF\u7EBF\u4E0B\u4E0D\u5141\u8BB8\u5B58\u57283\u6761\u4EE5\u4E0A\u76F8\u540C\u5DE5\u5E8F\u53F7\u7684\u5DE5\u5E8F
|
||||
@ -0,0 +1,161 @@
|
||||
package cn.net.connor.std.processedit.newmeprocess;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialog;
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NewProcessDialog extends KDialog {
|
||||
|
||||
private JButton b_ok;
|
||||
private JButton b_cel;
|
||||
private NewProcessDialogController controller;
|
||||
private static final Registry REG = Registry.getRegistry(NewProcessDialog.class);
|
||||
|
||||
public NewProcessDialog(KDialogController controller) {
|
||||
super(controller);
|
||||
this.controller = (NewProcessDialogController) controller;
|
||||
}
|
||||
|
||||
private void setCompEnabled(boolean b) {
|
||||
b_ok.setEnabled(b);
|
||||
b_cel.setEnabled(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
this.b_cel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeDialog();
|
||||
}
|
||||
});
|
||||
this.b_ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setCompEnabled(false);
|
||||
try {
|
||||
controller.doCreate();
|
||||
disposeDialog();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(NewProcessDialog.this, e);
|
||||
}
|
||||
setCompEnabled(true);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(REG.getString("newprocess.TITLE"));
|
||||
this.setPreferredSize(new Dimension(800, 780));
|
||||
this.setMinimumSize(new Dimension(800, 700));
|
||||
this.setLayout(new BorderLayout());
|
||||
JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
||||
pane.setResizeWeight(0.6);
|
||||
pane.setTopComponent(initProcPanel());
|
||||
pane.setBottomComponent(initItemPanel());
|
||||
pane.setBorder(null);
|
||||
this.add(BorderLayout.CENTER, pane);
|
||||
this.add(BorderLayout.SOUTH, initBtnPanel());
|
||||
}
|
||||
|
||||
private Component initBtnPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
|
||||
this.b_ok = new JButton(REG.getString("ok"));
|
||||
this.b_cel = new JButton(REG.getString("cancel"));
|
||||
panel.add(b_ok);
|
||||
panel.add(b_cel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component initProcPanel() {
|
||||
String title = REG.getString("procgroup.TITLE");
|
||||
List<PrefComponent> comps = controller.procComps;
|
||||
int colCnt = controller.procCols;
|
||||
JPanel wrapper = new JPanel(new BorderLayout());
|
||||
wrapper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30,5,5,5), title));
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(4, 0, 4, 25));
|
||||
int size = comps.size();
|
||||
int compIndex = 0;
|
||||
for(int i=0;i<size;i++) {
|
||||
PrefComponent prefComponent = comps.get(i);
|
||||
if(prefComponent.isInvisible()) {
|
||||
continue;
|
||||
}
|
||||
// if(compIndex%colCnt==0) {
|
||||
// KUtil.newRow(panel, prefComponent.getPanel(), s, 1);
|
||||
// }else {
|
||||
// KUtil.addCol(panel, prefComponent.getPanel(), s, 1, 0);
|
||||
// }
|
||||
KUtil.newRow(panel, prefComponent.getPanel(), s, 1);
|
||||
compIndex++;
|
||||
}
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(panel, new JLabel(""), s, 1);
|
||||
JScrollPane scroll = new JScrollPane(panel);
|
||||
scroll.setBorder(null);
|
||||
wrapper.add(BorderLayout.CENTER, scroll);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private Component initItemPanel() {
|
||||
String title = REG.getString("itemgroup.TITLE");
|
||||
List<PrefComponent> comps = controller.itemComps;
|
||||
int colCnt = controller.itemCols;
|
||||
JPanel wrapper = new JPanel(new BorderLayout());
|
||||
wrapper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30,5,5,5), title));
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(4, 0, 4, 25));
|
||||
int size = comps.size();
|
||||
int compIndex = 0;
|
||||
for(int i=0;i<size;i++) {
|
||||
PrefComponent prefComponent = comps.get(i);
|
||||
if(prefComponent.isInvisible()) {
|
||||
continue;
|
||||
}
|
||||
// if(compIndex%colCnt==0) {
|
||||
// KUtil.newRow(panel, prefComponent.getPanel(), s, 1);
|
||||
// }else {
|
||||
// KUtil.addCol(panel, prefComponent.getPanel(), s, 1, 0);
|
||||
// }
|
||||
KUtil.newRow(panel, prefComponent.getPanel(), s, 1);
|
||||
compIndex++;
|
||||
}
|
||||
s.weighty = 1;
|
||||
KUtil.newRow(panel, new JLabel(""), s, 1);
|
||||
JScrollPane scroll = new JScrollPane(panel);
|
||||
scroll.setBorder(null);
|
||||
wrapper.add(BorderLayout.CENTER, scroll);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,474 @@
|
||||
package cn.net.connor.std.processedit.newmeprocess;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.SoaUtil;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
import com.teamcenter.services.rac.core.DataManagementService;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
|
||||
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
|
||||
|
||||
import cn.net.connor.std.aifrcp.KDialogController;
|
||||
import cn.net.connor.std.aifrcp.util.KUtil;
|
||||
import cn.net.connor.std.processedit.util.OptionItem;
|
||||
import cn.net.connor.std.processedit.util.ProcessUtil;
|
||||
|
||||
public class NewProcessDialogController extends KDialogController {
|
||||
|
||||
private NewProcessDialog dialog;
|
||||
private TCComponentItemRevision targetRev;
|
||||
public static final String PREF_PREFIX = "Connor_AVIC_";
|
||||
public static final String PREF_GROUP_SPLITTER = "---";
|
||||
public static final String PROP_OBJECT_TYPE = "object_type";
|
||||
protected List<PrefComponent> procComps = new ArrayList<PrefComponent>();
|
||||
protected List<PrefComponent> itemComps = new ArrayList<PrefComponent>();
|
||||
private PrefComponent objectTypeComp;
|
||||
protected int procCols = 2;
|
||||
protected int itemCols = 2;
|
||||
public static final String PREF_PROCTYPE_SYMBOL = "Connor_AVIC_ProcType_Symbol";
|
||||
private Map<String, String> procTypeSymbolMap = new HashMap<String, String>();
|
||||
private Map<PrefComponent, String> symbolCompMap = new HashMap<PrefComponent, String>();
|
||||
public static final String FLAG_TYPE_SYMBOL = "[PROC_TYPE]";
|
||||
private static final Registry REG = Registry.getRegistry(NewProcessDialogController.class);
|
||||
|
||||
public NewProcessDialogController(AbstractAIFApplication app) {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
this.dialog = (NewProcessDialog) aifDialog;
|
||||
InterfaceAIFComponent comp = app.getTargetComponent();
|
||||
if (comp == null || !(comp instanceof TCComponentItemRevision)) {
|
||||
throw new Exception(REG.getString("selectnewprocesstarget.ERROR"));
|
||||
}
|
||||
this.targetRev = (TCComponentItemRevision) comp;
|
||||
String revType = this.targetRev.getType();
|
||||
System.out.println("Select Rev: " + this.targetRev + "| " + revType);
|
||||
String prefName = PREF_PREFIX + revType;
|
||||
System.out.println("Load Preference: " + prefName);
|
||||
String[] prefVals = KUtil.getPrefVals(session, prefName);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
if (len == 0) {
|
||||
System.out.println(String.format(REG.getString("prefnotconfiged.ERROR1"), prefName));
|
||||
throw new TCException(REG.getString("selectnewprocesstarget.ERROR"));
|
||||
}
|
||||
/*if (!"NHL8_VirtualPart".equals(this.targetRev.getItem().getType())) {
|
||||
TCComponent[] statusList = this.targetRev.getReferenceListProperty("release_status_list");
|
||||
System.out.println("Check Release Status: " + Arrays.toString(statusList));
|
||||
if (KUtil.getLen(statusList) < 1) {
|
||||
MessageBox.post(REG.getString("revreleased.ERROR"), "", MessageBox.WARNING);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
List<PrefComponent> compList = procComps;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String pref = prefVals[i];
|
||||
if (pref.length() == 1 && Character.isDigit(pref.charAt(0))) {
|
||||
if (compList == itemComps) {
|
||||
int col = pref.charAt(0) - '0';
|
||||
if (col > 0) {
|
||||
System.out.println("Reset Item Col: " + col);
|
||||
itemCols = col;
|
||||
}
|
||||
} else if (compList == procComps) {
|
||||
int col = pref.charAt(0) - '0';
|
||||
if (col > 0) {
|
||||
System.out.println("Reset Proc Col: " + col);
|
||||
procCols = col;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (pref.startsWith(PREF_GROUP_SPLITTER)) {
|
||||
compList = itemComps;
|
||||
continue;
|
||||
}
|
||||
PrefComponent prefComp = new PrefComponent(pref, this.targetRev);
|
||||
if (prefComp.init(session)) {
|
||||
if (PROP_OBJECT_TYPE.equals(prefComp.propConfig)) {
|
||||
this.objectTypeComp = prefComp;
|
||||
System.out.println("objectTypeComp.lov.length=="+objectTypeComp.lov.length);
|
||||
if(objectTypeComp.comboBox != null && objectTypeComp.lov.length == 1)
|
||||
{
|
||||
objectTypeComp.comboBox.setSelectedIndex(1);
|
||||
}
|
||||
}
|
||||
compList.add(prefComp);
|
||||
} else {
|
||||
System.out.println("Error Config: " + pref);
|
||||
}
|
||||
}
|
||||
if (procComps.size() + itemComps.size() == 0) {
|
||||
throw new Exception(String.format(REG.getString("prefnotconfiged.ERROR1"), prefName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (PrefComponent c : procComps) {
|
||||
if (c.textField != null && c.getValue() != null && c.getValue().contains(FLAG_TYPE_SYMBOL)) {
|
||||
this.symbolCompMap.put(c, c.getValue());
|
||||
c.textField.setText(c.getValue().replace(FLAG_TYPE_SYMBOL, ""));
|
||||
}
|
||||
}
|
||||
for (PrefComponent c : itemComps) {
|
||||
if (c.textField != null && c.getValue() != null && c.getValue().contains(FLAG_TYPE_SYMBOL)) {
|
||||
this.symbolCompMap.put(c, c.getValue());
|
||||
c.textField.setText(c.getValue().replace(FLAG_TYPE_SYMBOL, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < itemComps.size(); i++) {
|
||||
PrefComponent prefParent = itemComps.get(i);
|
||||
if (prefParent.isLovParent) {
|
||||
for (int j = 0; j < itemComps.size(); j++) {
|
||||
PrefComponent prefChild = itemComps.get(j);
|
||||
if (prefParent.lovName.equals(prefChild.lovName) && prefChild.isLovChild) {
|
||||
prefParent.comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String selectedProvince = (String) prefParent.bigJtf.getText();
|
||||
if (selectedProvince != null) {
|
||||
List<String> cities = prefParent.listLov.get(selectedProvince);
|
||||
|
||||
// 清空子级控件和数据
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.opHashMap.clear();
|
||||
prefChild.lovDisRealMap.clear();
|
||||
prefChild.list.clear();
|
||||
|
||||
if (cities != null && !cities.isEmpty()) {
|
||||
for (String city : cities) {
|
||||
OptionItem optionItem = new OptionItem(city, "");
|
||||
prefChild.comboBox.addItem(optionItem);
|
||||
prefChild.opHashMap.put(city, optionItem);
|
||||
prefChild.lovDisRealMap.put(city, city);
|
||||
prefChild.list.add(city);
|
||||
}
|
||||
// 关键:不自动选中任何项
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
} else {
|
||||
// 没有子项时也确保无选中
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
}
|
||||
} else {
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.comboBox.setSelectedIndex(-1); // 确保无选中
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < procComps.size(); i++) {
|
||||
PrefComponent prefParent = procComps.get(i);
|
||||
if (prefParent.isLovParent) {
|
||||
for (int j = 0; j < procComps.size(); j++) {
|
||||
PrefComponent prefChild = procComps.get(j);
|
||||
if (prefParent.lovName.equals(prefChild.lovName) && prefChild.isLovChild) {
|
||||
prefParent.comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String selectedProvince = (String) prefParent.bigJtf.getText();
|
||||
if (selectedProvince != null) {
|
||||
List<String> cities = prefParent.listLov.get(selectedProvince);
|
||||
|
||||
// 清空子级控件和数据
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.opHashMap.clear();
|
||||
prefChild.lovDisRealMap.clear();
|
||||
prefChild.list.clear();
|
||||
|
||||
if (cities != null && !cities.isEmpty()) {
|
||||
for (String city : cities) {
|
||||
OptionItem optionItem = new OptionItem(city, "");
|
||||
prefChild.comboBox.addItem(optionItem);
|
||||
prefChild.opHashMap.put(city, optionItem);
|
||||
prefChild.lovDisRealMap.put(city, city);
|
||||
prefChild.list.add(city);
|
||||
}
|
||||
// 关键:不自动选中任何项
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
} else {
|
||||
// 没有子项时也确保无选中
|
||||
prefChild.comboBox.setSelectedIndex(-1);
|
||||
}
|
||||
} else {
|
||||
prefChild.comboBox.removeAllItems();
|
||||
prefChild.comboBox.setSelectedIndex(-1); // 确保无选中
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
String[] prefVals2 = KUtil.getPrefVals(session, PREF_PROCTYPE_SYMBOL);
|
||||
int len2 = KUtil.getLen(prefVals2);
|
||||
for (int i = 0; i < len2; i++) {
|
||||
String pref = prefVals2[i];
|
||||
int ind = pref.indexOf('=');
|
||||
if (ind > 0) {
|
||||
String type = pref.substring(0, ind);
|
||||
String symbol = pref.substring(ind + 1);
|
||||
System.out.println("Type Symbol: " + type + " -> " + symbol);
|
||||
this.procTypeSymbolMap.put(type, symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.symbolCompMap.size() > 0 && this.objectTypeComp != null && this.objectTypeComp.comboBox != null) {
|
||||
this.objectTypeComp.comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
String type = objectTypeComp.getValue();
|
||||
String symbol = procTypeSymbolMap.containsKey(type) ? procTypeSymbolMap.get(type) : "";
|
||||
System.out.println("Select Type: " + type + " -> " + symbol);
|
||||
for (PrefComponent c : symbolCompMap.keySet()) {
|
||||
String text = symbolCompMap.get(c);
|
||||
System.out.println(text);
|
||||
text = text.replace(FLAG_TYPE_SYMBOL, symbol);
|
||||
c.textField.setText(text);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void doCreate() throws Exception {
|
||||
if (this.objectTypeComp == null) {
|
||||
throw new Exception(REG.getString("typecompnotfound.ERROR"));
|
||||
}
|
||||
String type = this.objectTypeComp.getValue();
|
||||
System.out.println("Select Type: " + type);
|
||||
if (KUtil.isEmpty(type)) {
|
||||
throw new Exception(REG.getString("selectType.INFO"));
|
||||
}
|
||||
String relName = this.objectTypeComp.getAddtionalValue();
|
||||
System.out.println("Create Relation: " + relName);
|
||||
String archiveRelation = "";
|
||||
if(KUtil.isEmpty(relName)) {
|
||||
throw new Exception(REG.getString("typecompnotfound.ERROR"));
|
||||
}
|
||||
int ind = relName.indexOf('-');
|
||||
if (ind > 0) {
|
||||
archiveRelation = relName.substring(ind + 1);
|
||||
relName = relName.substring(0, ind);
|
||||
}
|
||||
if (KUtil.isEmpty(archiveRelation)) {
|
||||
throw new Exception(REG.getString("typecompnotfound.ERROR"));
|
||||
}
|
||||
if(type.equals("LD6_MEProcessCr")) {
|
||||
AIFComponentContext[] cs = ((TCComponent)targetRev.getChildren(archiveRelation)[0].getComponent()).getChildren();
|
||||
System.out.println("getChildren: " + cs.length);
|
||||
int n = 0;
|
||||
for(AIFComponentContext c : cs) {
|
||||
if(c.getComponent().getType().equals("LD6_MEProcessCr"))
|
||||
n++;
|
||||
}
|
||||
if(n >= 3) {
|
||||
throw new Exception(REG.getString("relation.ERROR"));
|
||||
}
|
||||
}
|
||||
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
|
||||
if (itemType == null) {
|
||||
throw new Exception(String.format(REG.getString("typenotfound.ERROR1"), type));
|
||||
}
|
||||
String checkRequire = checkRequire();
|
||||
|
||||
|
||||
if (!checkRequire.equals("")) {
|
||||
|
||||
throw new Exception(String.format(REG.getString("requireprop.INFO1"), checkRequire));
|
||||
}
|
||||
|
||||
String checkCombox = checkCombox();
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("checkCombox==="+checkCombox);
|
||||
|
||||
if (!checkCombox.equals("")) {
|
||||
|
||||
throw new Exception(checkCombox);
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean addedToNewRev = false;
|
||||
try {
|
||||
KUtil.setByPassItk(session, true);
|
||||
TCComponentItemRevisionType revType = itemType.getItemRevisionType();
|
||||
String revTypeName = revType.getName();
|
||||
String itemMasterTypeName = type + " Master";
|
||||
String revMasterTypeName = revTypeName + " Master";
|
||||
if (session.getTypeComponent(itemMasterTypeName) == null) {
|
||||
itemMasterTypeName = type + "Master";
|
||||
}
|
||||
if (session.getTypeComponent(revMasterTypeName) == null) {
|
||||
revMasterTypeName = revTypeName + "Master";
|
||||
}
|
||||
System.out.println("Revision Type: " + type);
|
||||
System.out.println("Item Master Type: " + itemMasterTypeName);
|
||||
System.out.println("Revision Master Type: " + revMasterTypeName);
|
||||
Map<String, String> revPropMap = new HashMap<>();
|
||||
Map<String, String> revMasterPropMap = new HashMap<>();
|
||||
Map<String, String> itemPropMap = new HashMap<>();
|
||||
Map<String, String> itemMasterPropMap = new HashMap<>();
|
||||
for (PrefComponent prefComponent : itemComps) {
|
||||
KUtil.initPropMap(prefComponent.propConfig, prefComponent.getValue(), itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap);
|
||||
}
|
||||
for (PrefComponent prefComponent : procComps) {
|
||||
KUtil.initPropMap(prefComponent.propConfig, prefComponent.getValue(), itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap);
|
||||
}
|
||||
CreateInput revMasterInput = new CreateInput();
|
||||
revMasterInput.boName = revMasterTypeName;
|
||||
revMasterInput.stringProps = revMasterPropMap;
|
||||
if ("NHL8_AssemblyPro".equals(type) && "NHL8_VirtualPart".equals(targetRev.getItem().getType())) {
|
||||
System.out.println(">> set nhl8_isFcheck = true");
|
||||
System.out.println(">> set nhl8_isfPass = true");
|
||||
revMasterInput.boolProps = new HashMap<>();
|
||||
revMasterInput.boolProps.put("nhl8_isFcheck", true);
|
||||
revMasterInput.boolProps.put("nhl8_isfPass", true);
|
||||
}
|
||||
CreateInput itemMasterInput = new CreateInput();
|
||||
itemMasterInput.boName = itemMasterTypeName;
|
||||
itemMasterInput.stringProps = itemMasterPropMap;
|
||||
CreateInput revInput = new CreateInput();
|
||||
revInput.boName = revTypeName;
|
||||
revInput.stringProps = revPropMap;
|
||||
Map<String, CreateInput[]> revMasterInfoMap = new HashMap<>();
|
||||
revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput });
|
||||
revInput.compoundCreateInput = revMasterInfoMap;
|
||||
// create rev
|
||||
CreateInput itemInput = new CreateInput();
|
||||
itemInput.boName = type;
|
||||
itemInput.stringProps = itemPropMap;
|
||||
Map<String, CreateInput[]> revInfoMap = new HashMap<>();
|
||||
revInfoMap.put("revision", new CreateInput[] { revInput });
|
||||
revInfoMap.put("IMAN_master_form", new CreateInput[] { itemMasterInput });
|
||||
itemInput.compoundCreateInput = revInfoMap;
|
||||
// create info
|
||||
CreateIn cI = new CreateIn();
|
||||
cI.clientId = "CreateItem";
|
||||
cI.data = itemInput;
|
||||
// service
|
||||
DataManagementService service = DataManagementService.getService(session);
|
||||
// create
|
||||
CreateResponse resp = service.createObjects(new CreateIn[] { cI });
|
||||
SoaUtil.checkPartialErrors(resp.serviceData);
|
||||
CreateOut[] cOs = resp.output;
|
||||
TCComponentItem newItem = null;
|
||||
if (cOs.length > 0) {
|
||||
for (TCComponent s : cOs[0].objects) {
|
||||
if (s instanceof TCComponentItem) {
|
||||
newItem = (TCComponentItem) s;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("New Item: " + newItem);
|
||||
if (newItem == null) {
|
||||
throw new Exception(REG.getString("createprocess.ERROR"));
|
||||
}
|
||||
newItem.refresh();
|
||||
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
|
||||
System.out.println("New Rev: " + newRev);
|
||||
ProcessUtil.switchToPrecise(session, newRev);
|
||||
addedToNewRev = false;
|
||||
if (newRev != null) {
|
||||
try {
|
||||
newRev.add(relName, this.targetRev);
|
||||
newRev.refresh();
|
||||
this.targetRev.add(archiveRelation, newItem);
|
||||
this.targetRev.refresh();
|
||||
addedToNewRev = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(dialog, e.getMessage(), "错误", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
if (!addedToNewRev) {
|
||||
TCComponentFolder folder = session.getUser().getNewStuffFolder();
|
||||
folder.add("contents", newItem);
|
||||
folder.refresh();
|
||||
}
|
||||
MessageBox.post(dialog, addedToNewRev ? REG.getString("newprocesscomplete.INFO") : REG.getString("newprocesscomplete.ERROR"), "", MessageBox.INFORMATION);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(dialog, e.getMessage(), "错误", MessageBox.ERROR);
|
||||
} finally {
|
||||
KUtil.setByPassItk(session, false);
|
||||
}
|
||||
}
|
||||
|
||||
private String checkRequire() {
|
||||
List<String> requireTitles = new ArrayList<String>();
|
||||
for (PrefComponent prefComponent : itemComps) {
|
||||
if (!prefComponent.checkRequire()) {
|
||||
requireTitles.add(prefComponent.title.replace(" ", "").replace(":", "").replace(REG.getString("CN_SYMBEL4"), "").replace(REG.getString("CN_SYMBEL5"), ""));
|
||||
}
|
||||
}
|
||||
for (PrefComponent prefComponent : procComps) {
|
||||
if (!prefComponent.checkRequire()) {
|
||||
requireTitles.add(prefComponent.title.replace(" ", "").replace(":", "").replace(REG.getString("CN_SYMBEL4"), "").replace(REG.getString("CN_SYMBEL5"), ""));
|
||||
}
|
||||
}
|
||||
if (requireTitles.size() > 0) {
|
||||
//MessageBox.post(dialog, String.format(REG.getString("requireprop.INFO1"), requireTitles.toString()), "", MessageBox.WARNING);
|
||||
return requireTitles.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String checkCombox() {
|
||||
List<String> requireTitles = new ArrayList<String>();
|
||||
for (PrefComponent prefComponent : itemComps) {
|
||||
if (!prefComponent.checkCombox()) {
|
||||
requireTitles.add(prefComponent.title+"请选择下拉值!");
|
||||
}
|
||||
}
|
||||
for (PrefComponent prefComponent : procComps) {
|
||||
if (!prefComponent.checkCombox()) {
|
||||
requireTitles.add(prefComponent.title+"请选择下拉值!"); }
|
||||
}
|
||||
if (requireTitles.size() > 0) {
|
||||
//MessageBox.post(dialog, String.format(REG.getString("requireprop.INFO1"), requireTitles.toString()), "", MessageBox.WARNING);
|
||||
return requireTitles.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
newprocess.TITLE=\u521B\u5EFA\u5DE5\u827A
|
||||
ok=\u786E\u5B9A
|
||||
cancel=\u53D6\u6D88
|
||||
itemgroup.TITLE=\u96F6\u7EC4\u4EF6\u5C5E\u6027
|
||||
procgroup.TITLE=\u5DE5\u827A\u64CD\u4F5C
|
||||
selectnewprocesstarget.ERROR=\u8BF7\u9009\u62E9\u96F6\u4EF6\u6216\u7EC4\u4EF6\u8FDB\u884C\u64CD\u4F5C
|
||||
prefnotconfiged.ERROR1=\u9996\u9009\u9879\u672A\u914D\u7F6E\uFF1A%s
|
||||
typecompnotfound.ERROR=\u672A\u5B9A\u4E49\u5BF9\u8C61\u7C7B\u578B\u63A7\u4EF6
|
||||
selectType.INFO=\u8BF7\u9009\u62E9\u8981\u521B\u5EFA\u7684\u5BF9\u8C61\u7C7B\u578B
|
||||
createprocess.ERROR=\u521B\u5EFA\u5DE5\u827A\u5F02\u5E38
|
||||
newprocesscomplete.INFO=\u521B\u5EFA\u6210\u529F
|
||||
newprocesscomplete.ERROR=\u521B\u5EFA\u5DE5\u827A\u5B8C\u6210\uFF0C\u4FDD\u5B58\u5230NewStuff\u6587\u4EF6\u5939
|
||||
CN_SYMBEL1=\uFF08
|
||||
CN_SYMBEL2=\uFF09
|
||||
CN_SYMBEL3=\uFF01
|
||||
CN_SYMBEL4=\uFF1A
|
||||
CN_SYMBEL5=\u3000
|
||||
requireprop.INFO1=\u8BF7\u586B\u5199\u5FC5\u586B\u5C5E\u6027\uFF1A\: %s
|
||||
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
|
||||
propnotdefinedintype.ERROR2=\u5C5E\u6027\u201C%s\u201D\u672A\u5728\u7C7B\u578B\u201C%s\u201D\u4E2D\u5B9A\u4E49
|
||||
revreleased.ERROR=\u672A\u53D1\u5E03\u72B6\u6001\u4E0D\u5141\u8BB8\u521B\u5EFA\u5DE5\u827A
|
||||
relation.ERROR=\u5DE5\u827A\u8DEF\u7EBF\u6570\u91CF\u8D85\u8FC7\u9650\u5236\uFF0C\u65E0\u6CD5\u5EFA\u7ACB\u5173\u7CFB
|
||||