xiaoxia 8 years ago
parent
commit
804478d318
  1. 10
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

10
designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -107,7 +107,7 @@ public class UITreeComboBox extends JComboBox{
class UITreeComboBoxRenderer extends DefaultListCellRenderer { class UITreeComboBoxRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus){ int index, boolean isSelected, boolean cellHasFocus){
if(tree != null ){ if(tree != null && tree.getSelectedTreePath().length > 0){
TreePath path = tree.getSelectedTreePath()[0]; TreePath path = tree.getSelectedTreePath()[0];
tree.setAndScrollSelectionPath(path); tree.setAndScrollSelectionPath(path);
Object node = path.getLastPathComponent(); Object node = path.getLastPathComponent();
@ -131,14 +131,12 @@ public class UITreeComboBox extends JComboBox{
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) {
TreePath[] paths = tree.getSelectedTreePath(); TreePath[] paths = tree.getSelectedTreePath();
if (tree != null && paths.length > 0) {
if (paths.length == 1) {
tree.setAndScrollSelectionPath(paths[0]); tree.setAndScrollSelectionPath(paths[0]);
} else {
tree.setSelectionPaths(paths);
}
setSelectedItem(paths[0]); setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath(); MenuSelectionManager.defaultManager().clearSelectedPath();
}
} else { } else {
tree.refreshUI(); tree.refreshUI();
repaint(); repaint();

Loading…
Cancel
Save