|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.fr.design.gui.itree.checkboxtree; |
|
|
|
package com.fr.design.gui.itree.checkboxtree; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.design.event.StateChangeListener; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.Constants; |
|
|
@ -75,6 +76,8 @@ public class TristateCheckBox extends UICheckBox { |
|
|
|
|
|
|
|
|
|
|
|
private final TristateDecorator model; |
|
|
|
private final TristateDecorator model; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StateChangeListener stateChangeListener; |
|
|
|
|
|
|
|
|
|
|
|
public TristateCheckBox(String text, Icon icon, State initial) { |
|
|
|
public TristateCheckBox(String text, Icon icon, State initial) { |
|
|
|
super(text, icon); |
|
|
|
super(text, icon); |
|
|
|
setUI(new TristateCheckBoxUI()); |
|
|
|
setUI(new TristateCheckBoxUI()); |
|
|
@ -83,7 +86,7 @@ public class TristateCheckBox extends UICheckBox { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
grabFocus(); |
|
|
|
grabFocus(); |
|
|
|
model.setState(getNextState(model.getState())); |
|
|
|
setState(getNextState(model.getState())); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
// Reset the keyboard action map
|
|
|
|
// Reset the keyboard action map
|
|
|
@ -92,7 +95,7 @@ public class TristateCheckBox extends UICheckBox { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
grabFocus(); |
|
|
|
grabFocus(); |
|
|
|
model.setState(getNextState(model.getState())); |
|
|
|
setState(getNextState(model.getState())); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
map.put("released", null); |
|
|
|
map.put("released", null); |
|
|
@ -125,12 +128,20 @@ public class TristateCheckBox extends UICheckBox { |
|
|
|
public void addMouseListener(MouseListener l) { |
|
|
|
public void addMouseListener(MouseListener l) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void addStateChangeListener(StateChangeListener stateChangeListener) { |
|
|
|
|
|
|
|
this.stateChangeListener=stateChangeListener; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the new state to either SELECTED, NOT_SELECTED or |
|
|
|
* Set the new state to either SELECTED, NOT_SELECTED or |
|
|
|
* DO_NOT_CARE. If state == null, it is treated as DO_NOT_CARE. |
|
|
|
* DO_NOT_CARE. If state == null, it is treated as DO_NOT_CARE. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setState(State state) { |
|
|
|
public void setState(State state) { |
|
|
|
|
|
|
|
State old = getState(); |
|
|
|
model.setState(state); |
|
|
|
model.setState(state); |
|
|
|
|
|
|
|
if (old != state) { |
|
|
|
|
|
|
|
fireBoxStateChanged(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -141,6 +152,11 @@ public class TristateCheckBox extends UICheckBox { |
|
|
|
return model.getState(); |
|
|
|
return model.getState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void fireBoxStateChanged() { |
|
|
|
|
|
|
|
if (stateChangeListener != null) { |
|
|
|
|
|
|
|
stateChangeListener.stateChange(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Exactly which Design Pattern is this? Is it an Adapter, |
|
|
|
* Exactly which Design Pattern is this? Is it an Adapter, |
|
|
|