|
|
@ -29,6 +29,8 @@ import com.fr.stable.Nameable; |
|
|
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import javax.swing.event.ListDataEvent; |
|
|
|
|
|
|
|
import javax.swing.event.ListDataListener; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
@ -55,6 +57,7 @@ public abstract class UIListControlPane extends UIControlPane { |
|
|
|
protected int editingIndex; |
|
|
|
protected int editingIndex; |
|
|
|
protected String selectedName; |
|
|
|
protected String selectedName; |
|
|
|
private boolean isNameRepeated = false; |
|
|
|
private boolean isNameRepeated = false; |
|
|
|
|
|
|
|
protected boolean isPopulating = false; |
|
|
|
|
|
|
|
|
|
|
|
public UIListControlPane() { |
|
|
|
public UIListControlPane() { |
|
|
|
this.initComponentPane(); |
|
|
|
this.initComponentPane(); |
|
|
@ -94,11 +97,25 @@ public abstract class UIListControlPane extends UIControlPane { |
|
|
|
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).update(); |
|
|
|
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).update(); |
|
|
|
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).populate(); |
|
|
|
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).populate(); |
|
|
|
UIListControlPane.this.checkButtonEnabled(); |
|
|
|
UIListControlPane.this.checkButtonEnabled(); |
|
|
|
// plough:感觉每次valueChange都保存一下,会稍微影响效率
|
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
nameableList.getModel().addListDataListener(new ListDataListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void intervalAdded(ListDataEvent e) { |
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void intervalRemoved(ListDataEvent e) { |
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void contentsChanged(ListDataEvent e) { |
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public UINameEdList createJNameList() { |
|
|
|
public UINameEdList createJNameList() { |
|
|
@ -179,9 +196,11 @@ public abstract class UIListControlPane extends UIControlPane { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populate(Nameable[] nameableArray) { |
|
|
|
public void populate(Nameable[] nameableArray) { |
|
|
|
|
|
|
|
isPopulating = true; // 加一个标识位,避免切换单元格时,触发 saveSettings
|
|
|
|
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); |
|
|
|
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); |
|
|
|
listModel.removeAllElements(); |
|
|
|
listModel.removeAllElements(); |
|
|
|
if (ArrayUtils.isEmpty(nameableArray)) { |
|
|
|
if (ArrayUtils.isEmpty(nameableArray)) { |
|
|
|
|
|
|
|
isPopulating = false; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -193,6 +212,8 @@ public abstract class UIListControlPane extends UIControlPane { |
|
|
|
this.nameableList.setSelectedIndex(0); |
|
|
|
this.nameableList.setSelectedIndex(0); |
|
|
|
} |
|
|
|
} |
|
|
|
this.checkButtonEnabled(); |
|
|
|
this.checkButtonEnabled(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isPopulating = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|