The method is quite simple that an ElementPropertyChangeListener is to be added to TDataBox and that when property A has been changed and thus the value the value in the DataBox is changed the Editor of property B will load that value.
public void propertyChange(PropertyChangeEvent evt) {
String pro = TWaverUtil.getPropertyName(evt);
Element element = (Element)evt.getSource();
if("A".equals(pro)){
CustomUtil.ref = CustomUtil.getBRefs((Integer)element.getUserProperty("A"));
}
}
public static String[] getBRefs(int v){
switch(v){
case 1:
case 2:
return REF1;
default:
return REF2;
}
}
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
JComboBox comboBox = (JComboBox)this.getComponent();
comboBox.removeAllItems();
if(CustomUtil.ref!=null){
for(int i=0;i<CustomUtil.ref.length;i++){
comboBox.addItem(CustomUtil.ref[i]);
}
}
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
No comments:
Post a Comment