Browse Source

REPORT-23260 将原本的全选框替换为三态的CheckBox,并在三态的CheckBox中添加状态监听器

feature/big-screen
Yuan.Wang 4 years ago
parent
commit
383d6fc231
  1. 9
      designer-base/src/main/java/com/fr/design/event/StateChangeListener.java
  2. 2
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  3. 20
      designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java

9
designer-base/src/main/java/com/fr/design/event/StateChangeListener.java

@ -0,0 +1,9 @@
package com.fr.design.event;
/**
* @Author: Yuan.Wang
* @Date: 2020/7/29
*/
public interface StateChangeListener {
public void stateChange();
}

2
designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java

File diff suppressed because one or more lines are too long

20
designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java

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

Loading…
Cancel
Save