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

14
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 { setSelectedItem(paths[0]);
tree.setSelectionPaths(paths); MenuSelectionManager.defaultManager().clearSelectedPath();
} }
setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath();
} else { } else {
tree.refreshUI(); tree.refreshUI();
repaint(); repaint();
@ -205,7 +203,7 @@ class TreePopup extends JPopupMenu implements ComboPopup{
} }
} }
public void show(){ public void show() {
updatePopup(); updatePopup();
show(comboBox, 0, comboBox.getHeight()); show(comboBox, 0, comboBox.getHeight());
comboBox.getTree().requestFocus(); comboBox.getTree().requestFocus();

Loading…
Cancel
Save