main
commit
16b25d0753
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/dom4j-2.1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/hutool-all-5.8.25.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ojdbc8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/swingx-1.6.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.connor.jd.DtoE</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,7 @@
|
||||
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.source=1.8
|
@ -0,0 +1,23 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: DtoE
|
||||
Bundle-SymbolicName: com.connor.jd.DtoE;singleton:=true
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Vendor: CONNOR
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
com.teamcenter.rac.kernel;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.util;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.common;bundle-version="13000.1.0",
|
||||
com.teamcenter.rac.aifrcp;bundle-version="13000.1.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.15.100",
|
||||
TcSoaStructureManagementLoose;bundle-version="13000.1.0",
|
||||
org.apache.poi.39;bundle-version="3.9.0"
|
||||
Automatic-Module-Name: com.connor.jd.DtoE
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: com.teamcenter.rac.kernel
|
||||
Export-Package: com.connor.ml.tcm.outfile.ML_01
|
||||
Bundle-ClassPath: lib/hutool-all-5.8.25.jar,
|
||||
lib/mssql-jdbc-7.0.0.jre8.jar,
|
||||
lib/ojdbc8.jar,
|
||||
lib/swingx-1.6.1.jar,
|
||||
.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
icons/,\
|
||||
lib/hutool-all-5.8.25.jar,\
|
||||
lib/mssql-jdbc-7.0.0.jre8.jar,\
|
||||
lib/ojdbc8.jar,\
|
||||
lib/swingx-1.6.1.jar
|
||||
src.includes = lib/
|
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 526 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
|
||||
<extension point="org.eclipse.ui.commands">
|
||||
<command name="DBOM转EBOM" categoryId="com.connor.ml.tcm.outfile.commands.category" id="DBOMtoEBOM"> </command>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.ui.handlers">
|
||||
<handler class="com.connor.ml.tcm.outfile.ML_01.DbomTransitionToEbomHandler" commandId="DBOMtoEBOM"> </handler>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.ui.menus">
|
||||
<menuContribution locationURI="menu:com.connor.plm.test.menus.sampleMenu?after=additions">
|
||||
<command commandId="DBOMtoEBOM" style="push"/>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
@ -0,0 +1,34 @@
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
public class BomValBean {
|
||||
|
||||
private String bl_czbh;
|
||||
private String bl_jdjz;
|
||||
|
||||
private String bl_quantity;
|
||||
public String getBl_quantity() {
|
||||
return bl_quantity;
|
||||
}
|
||||
public void setBl_quantity(String bl_quantity) {
|
||||
this.bl_quantity = bl_quantity;
|
||||
}
|
||||
public String getBl_czbh() {
|
||||
return bl_czbh;
|
||||
}
|
||||
public void setBl_czbh(String bl_czbh) {
|
||||
this.bl_czbh = bl_czbh;
|
||||
}
|
||||
public String getBl_jdjz() {
|
||||
return bl_jdjz;
|
||||
}
|
||||
public void setBl_jdjz(String bl_jdjz) {
|
||||
this.bl_jdjz = bl_jdjz;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BomValBean [bl_czbh=" + bl_czbh + ", bl_jdjz=" + bl_jdjz + ", bl_quantity=" + bl_quantity + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
|
||||
public class DbomTransitionToEbomHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
// TODO Auto-generated method stub
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
try {
|
||||
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session);
|
||||
command.executeModal();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import org.jdesktop.swingx.JXTreeTable;
|
||||
|
||||
import com.connor.ml.tcm.outfile.bean.NodeBean;
|
||||
|
||||
public class JTreeTable extends JXTreeTable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<Integer> isNotEditableRow;
|
||||
//CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this);
|
||||
private TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this);
|
||||
|
||||
public List<Integer> getIsNotEditableRow() {
|
||||
return isNotEditableRow;
|
||||
}
|
||||
|
||||
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
|
||||
this.isNotEditableRow = isNotEditableRow;
|
||||
}
|
||||
|
||||
public JTreeTable(JTreeTableModel testTreeTableModel) {
|
||||
// Auto-generated constructor stub
|
||||
super(testTreeTableModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int arg0, int arg1) {
|
||||
// Auto-generated method stub
|
||||
return true;//super.isCellEditable(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableCellEditor getCellEditor(int row, int column) {
|
||||
// Auto-generated method stub
|
||||
//if(isNotEditableRow.contains(row) && column == 2)
|
||||
|
||||
|
||||
return cellEditor;
|
||||
//return super.getCellEditor(row, column);
|
||||
}
|
||||
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
int row = this.rowAtPoint(e.getPoint());
|
||||
int col = this.columnAtPoint(e.getPoint());
|
||||
String tiptextString = null;
|
||||
if (row > -1 && col > -1) {
|
||||
Object value = this.getValueAt(row, col);
|
||||
if (null != value && !"".equals(value))
|
||||
tiptextString = value.toString();// 技륫鞫刻데禱목코휭
|
||||
}
|
||||
return tiptextString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getCellRenderer(int row, int column) {
|
||||
// Auto-generated method stub
|
||||
Object val = getValueAt(row, NodeBean.LABEL);
|
||||
if(column == NodeBean.LABEL && val != null && (val.equals("0") || val.equals("1")))
|
||||
{
|
||||
return checkboxRenderer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getCellRenderer(row, column);
|
||||
}
|
||||
}
|
||||
|
||||
// 茶꾜죗
|
||||
public void HiddenCell(int column) {
|
||||
TableColumn tc = this.getTableHeader().getColumnModel()
|
||||
.getColumn(column);
|
||||
tc.setMaxWidth(0);
|
||||
tc.setPreferredWidth(0);
|
||||
tc.setWidth(0);
|
||||
tc.setMinWidth(0);
|
||||
this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0);
|
||||
this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
|
||||
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
|
||||
import org.jdesktop.swingx.treetable.TreeTableNode;
|
||||
|
||||
import com.connor.ml.tcm.outfile.bean.NodeBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author vearn
|
||||
*/
|
||||
public class JTreeTableModel extends DefaultTreeTableModel {
|
||||
|
||||
private String[] _names = { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"};
|
||||
|
||||
|
||||
private List<Integer> isNotEditableRow;
|
||||
|
||||
|
||||
|
||||
public JTreeTableModel(TreeTableNode node, String[] names) {
|
||||
super(node);
|
||||
|
||||
_names = names;
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> getIsNotEditableRow() {
|
||||
return isNotEditableRow;
|
||||
}
|
||||
|
||||
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
|
||||
this.isNotEditableRow = isNotEditableRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列的数量
|
||||
*/
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return _names.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表头显示的内容
|
||||
*/
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
return _names[column];
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回在单元格中显示的Object
|
||||
*/
|
||||
@Override
|
||||
public Object getValueAt(Object node, int column) {
|
||||
Object value = null;
|
||||
if (node instanceof DefaultMutableTreeTableNode) {
|
||||
DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
|
||||
Object o = mutableNode.getUserObject();
|
||||
if (o != null && o instanceof NodeBean) {
|
||||
NodeBean bean = (NodeBean) o;
|
||||
value = bean.getValueAt(column);
|
||||
if(column == NodeBean.LABEL && value.equals("3")) {
|
||||
value = "";
|
||||
}
|
||||
// if(column > 4)
|
||||
// System.out.println("getValueAt" + column + "==" + value);
|
||||
/*switch (column) {
|
||||
case 0:
|
||||
value = bean.getDbom();
|
||||
break;
|
||||
case 1:
|
||||
value = bean.getEbom();
|
||||
break;
|
||||
case 2:
|
||||
value = bean.getLabel();
|
||||
if(value.equals("3")) {
|
||||
value = "";
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
value = bean.getEbomId();
|
||||
break;
|
||||
case 4:
|
||||
value = bean.getEbomDesc();
|
||||
break;
|
||||
case 5:
|
||||
value = bean.getNum();
|
||||
break;
|
||||
case 6:
|
||||
value = bean.getRefreshStatus();
|
||||
break;
|
||||
case 7:
|
||||
value = bean.getParentString();
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置所有单元格都不能编辑
|
||||
*
|
||||
* @param the node (i.e. row) for which editing is to be determined
|
||||
* @param the column for which editing is to be determined
|
||||
* @return false
|
||||
*/
|
||||
@Override
|
||||
public boolean isCellEditable(Object node, int column) {
|
||||
//if(column == 5)
|
||||
//{
|
||||
return true;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
|
||||
public class TableCellCheckboxRenderer extends JCheckBox implements
|
||||
TableCellRenderer {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private List<Integer> processRows;
|
||||
protected EventListenerList listenerList = new EventListenerList();
|
||||
protected ChangeEvent changeEvent = new ChangeEvent(this);
|
||||
//private TestTreeTableModel tableModel;
|
||||
|
||||
public List<Integer> getProcessRows() {
|
||||
return processRows;
|
||||
}
|
||||
|
||||
public void setProcessRows(List<Integer> processRows) {
|
||||
this.processRows = processRows;
|
||||
|
||||
}
|
||||
|
||||
public TableCellCheckboxRenderer(final JTreeTable table) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
this.setHorizontalAlignment(SwingConstants.CENTER);// ±íÍ·±êÇ©¾çÖÐ
|
||||
this.setBorderPainted(true);
|
||||
|
||||
if(value != null)
|
||||
{
|
||||
// if(value.toString().equals("1"))
|
||||
// {
|
||||
// if(table.getColumnName(column).equals("¸ÄÖÆ") && hasFocus)
|
||||
// {
|
||||
// if(table.getValueAt(row, column + 1).toString().equals("1"))
|
||||
// {
|
||||
// table.setValueAt(0, row, column + 1);
|
||||
// }
|
||||
// }
|
||||
// else if(table.getColumnName(column).equals("ɾ³ý") && hasFocus)
|
||||
// {
|
||||
// if(table.getValueAt(row, column - 1).toString().equals("1"))
|
||||
// {
|
||||
// table.setValueAt(0, row, column - 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(value.toString().equals("1"))
|
||||
// {
|
||||
// System.out.println(value.toString().equals("1") + "====");
|
||||
// }
|
||||
this.setSelected(value.toString().equals("1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSelected(false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.connor.ml.tcm.outfile.ML_01;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
String s = "11111112-32222222-4444";
|
||||
System.out.println(s.substring(0, s.indexOf("-")));
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.connor.ml.tcm.outfile.bean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
|
||||
|
||||
import com.connor.ml.tcm.outfile.ML_01.BomValBean;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author vearn
|
||||
*/
|
||||
public class NodeBean {
|
||||
|
||||
private String dbom;//对象ID
|
||||
private String ebom;//对象名称
|
||||
// private String ebomId;//对象名称
|
||||
// private String ebomDesc;//物料描述
|
||||
private String num;//数量
|
||||
private String label;//对象名称
|
||||
private String refreshStatus;//发布状态
|
||||
private String parentString;//对应父节点
|
||||
// private String bl_plmxml_abs_xform ;//绝对变换矩阵
|
||||
private TCComponentItemRevision pRev;//对应父节点
|
||||
private TCComponentItemRevision rev;//对应父节点
|
||||
private TCComponent tcComponent;
|
||||
private Boolean isTw = false;
|
||||
private DefaultMutableTreeTableNode rootNode;
|
||||
private Map<TCComponentItemRevision, List<BomValBean>> bomValMap = new HashMap<TCComponentItemRevision, List<BomValBean>>();
|
||||
|
||||
public static int DBOM = 0;
|
||||
public static int PARENT = 1;
|
||||
public static int EBOM = 2;
|
||||
public static int STATUS = 3;
|
||||
public static int LABEL = 4;
|
||||
|
||||
private HashMap<Integer, String> values = new HashMap<>();
|
||||
private TCComponentBOMLine bomLine;
|
||||
|
||||
public Boolean getIsTw() {
|
||||
return isTw;
|
||||
}
|
||||
public DefaultMutableTreeTableNode getRootNode() {
|
||||
return rootNode;
|
||||
}
|
||||
public void setRootNode(DefaultMutableTreeTableNode rootNode) {
|
||||
this.rootNode = rootNode;
|
||||
}
|
||||
public void setIsTw(Boolean isTw) {
|
||||
this.isTw = isTw;
|
||||
}
|
||||
public TCComponent getTcComponent() {
|
||||
return tcComponent;
|
||||
}
|
||||
public void setTcComponent(TCComponent tcComponent) {
|
||||
this.tcComponent = tcComponent;
|
||||
}
|
||||
public TCComponentItemRevision getRev() {
|
||||
return rev;
|
||||
}
|
||||
public void setRev(TCComponentItemRevision rev) {
|
||||
this.rev = rev;
|
||||
}
|
||||
public TCComponentItemRevision getpRev() {
|
||||
return pRev;
|
||||
}
|
||||
public Map<TCComponentItemRevision, List<BomValBean>> getBomValMap() {
|
||||
return bomValMap;
|
||||
}
|
||||
public void setBomValMap(Map<TCComponentItemRevision, List<BomValBean>> bomValMap) {
|
||||
this.bomValMap = bomValMap;
|
||||
}
|
||||
public void setpRev(TCComponentItemRevision pRev) {
|
||||
this.pRev = pRev;
|
||||
}
|
||||
// public String getBl_plmxml_abs_xform() {
|
||||
// return bl_plmxml_abs_xform;
|
||||
// }
|
||||
// public void setBl_plmxml_abs_xform(String bl_plmxml_abs_xform) {
|
||||
// this.bl_plmxml_abs_xform = bl_plmxml_abs_xform;
|
||||
// }
|
||||
|
||||
public String getDbom() {//0
|
||||
return dbom;
|
||||
}
|
||||
public void setDbom(String dbom) {//0
|
||||
this.dbom = dbom;
|
||||
setValueAt(DBOM, dbom);
|
||||
}
|
||||
public String getEbom() {//1
|
||||
return ebom;
|
||||
}
|
||||
public void setEbom(String ebom) {//1
|
||||
this.ebom = ebom;
|
||||
setValueAt(EBOM, ebom);
|
||||
}
|
||||
public String getLabel() {//2
|
||||
return label;
|
||||
}
|
||||
public void setLabel(String label) {//2
|
||||
this.label = label;
|
||||
setValueAt(LABEL, label);
|
||||
}
|
||||
// public String getEbomId() {//3
|
||||
// return ebomId;
|
||||
// }
|
||||
// public void setEbomId(String ebomId) {//3
|
||||
// this.ebomId = ebomId;
|
||||
// }
|
||||
// public String getEbomDesc() {//4
|
||||
// return ebomDesc;
|
||||
// }
|
||||
// public void setEbomDesc(String ebomDesc) {//4
|
||||
// this.ebomDesc = ebomDesc;
|
||||
// }
|
||||
public String getNum() {//5
|
||||
return num;
|
||||
}
|
||||
public void setNum(String num) {//5
|
||||
this.num = num;
|
||||
}
|
||||
public String getRefreshStatus() {//6
|
||||
return refreshStatus;
|
||||
}
|
||||
public void setRefreshStatus(String refreshStatus) {//6
|
||||
this.refreshStatus = refreshStatus;
|
||||
setValueAt(STATUS, refreshStatus);
|
||||
}
|
||||
public String getParentString() {//7
|
||||
return parentString;
|
||||
}
|
||||
public void setParentString(String parentString) {//7
|
||||
this.parentString = parentString;
|
||||
setValueAt(PARENT, parentString);
|
||||
}
|
||||
|
||||
public String getValueAt(int i) {
|
||||
if(values.containsKey(i))
|
||||
return values.get(i);
|
||||
return "";
|
||||
}
|
||||
public void setValueAt(int i, String val) {
|
||||
values.put(i, val);
|
||||
}
|
||||
|
||||
public TCComponentBOMLine getBom() {
|
||||
return bomLine;
|
||||
}
|
||||
public void setBom(TCComponentBOMLine bomLine) {
|
||||
this.bomLine = bomLine;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return dbom + "--" + ebom;
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
package com.connor.ml.tcm.outfile.util;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
@SuppressWarnings({ "serial", "rawtypes", "unchecked" })
|
||||
public class JAutoCompleteComboBox extends JComboBox {
|
||||
private AutoCompleter completer;
|
||||
private String propName;
|
||||
|
||||
public JAutoCompleteComboBox() {
|
||||
super();
|
||||
addCompleter();
|
||||
}
|
||||
|
||||
public JAutoCompleteComboBox(ComboBoxModel cm) {
|
||||
super(cm);
|
||||
addCompleter();
|
||||
}
|
||||
|
||||
public JAutoCompleteComboBox(Object[] items) {
|
||||
super(items);
|
||||
addCompleter();
|
||||
}
|
||||
|
||||
public JAutoCompleteComboBox(List v) {
|
||||
super((Vector) v);
|
||||
addCompleter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
public void setPropName(String propName) {
|
||||
this.propName = propName;
|
||||
}
|
||||
|
||||
private void addCompleter() {
|
||||
setEditable(true);
|
||||
completer = new AutoCompleter(this);
|
||||
}
|
||||
|
||||
public void autoComplete(String str) {
|
||||
this.completer.autoComplete(str, str.length());
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return ((JTextField) getEditor().getEditorComponent()).getText();
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
((JTextField) getEditor().getEditorComponent()).setText(text);
|
||||
}
|
||||
|
||||
public boolean containsItem(String itemString) {
|
||||
for (int i = 0; i < this.getModel().getSize(); i++) {
|
||||
String _item = " " + this.getModel().getElementAt(i);
|
||||
if (_item.equals(itemString))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
class AutoCompleter implements KeyListener, ItemListener {
|
||||
|
||||
private JComboBox owner = null;
|
||||
private JTextField editor = null;
|
||||
|
||||
private ComboBoxModel model = null;
|
||||
|
||||
public AutoCompleter(JComboBox comboBox) {
|
||||
owner = comboBox;
|
||||
editor = (JTextField) comboBox.getEditor().getEditorComponent();
|
||||
editor.addKeyListener(this);
|
||||
model = comboBox.getModel();
|
||||
owner.addItemListener(this);
|
||||
}
|
||||
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void keyReleased(KeyEvent e) {
|
||||
char ch = e.getKeyChar();
|
||||
// if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)
|
||||
// || ch == KeyEvent.VK_DELETE)
|
||||
// return;
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
int caretPosition = editor.getCaretPosition();
|
||||
String str = editor.getText();
|
||||
if (str.length() == 0)
|
||||
return;
|
||||
autoComplete(str, caretPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
protected void autoComplete(String strf, int caretPosition) {
|
||||
Object[] opts;
|
||||
opts = getMatchingOptions(strf.substring(0, caretPosition));
|
||||
if (owner != null) {
|
||||
model = new DefaultComboBoxModel(opts);
|
||||
owner.setModel(model);
|
||||
}
|
||||
if (opts.length > 0) {
|
||||
String str = opts[0].toString();
|
||||
editor.setCaretPosition(caretPosition);
|
||||
if (owner != null) {
|
||||
try {
|
||||
owner.showPopup();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Object[] getMatchingOptions(String str) {
|
||||
List v = new Vector();
|
||||
List v1 = new Vector();
|
||||
// v.add(str);
|
||||
for (int k = 0; k < model.getSize(); k++) {
|
||||
Object itemObj = model.getElementAt(k);
|
||||
if (itemObj != null) {
|
||||
String item = itemObj.toString().toLowerCase();
|
||||
if (item.indexOf((str.toLowerCase())) > -1)
|
||||
v.add(model.getElementAt(k));
|
||||
else
|
||||
v1.add(model.getElementAt(k));
|
||||
} else
|
||||
v1.add(model.getElementAt(k));
|
||||
}
|
||||
for (int i = 0; i < v1.size(); i++) {
|
||||
v.add(v1.get(i));
|
||||
}
|
||||
// if (v.isEmpty())
|
||||
return v.toArray();
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
int caretPosition = editor.getCaretPosition();
|
||||
if (caretPosition != -1) {
|
||||
try {
|
||||
editor.moveCaretPosition(caretPosition);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue