use of com.glitchcog.fontificator.gui.component.ListInput in project ChatGameFontificator by GlitchCog.
the class MessageCensorPanel method build.
@Override
protected void build() {
setBorder(new TitledBorder(ControlPanelBase.getBaseBorder(), "Message Censorship Configuration", TitledBorder.CENTER, TitledBorder.TOP));
setLayout(new GridBagLayout());
GridBagConstraints gbc = ControlPanelBase.getGbc();
enableCensorshipBox = new JCheckBox("Enable message censoring");
purgeOnTwitchBanBox = new JCheckBox("Purge messages on Twitch ban/timeout");
censorAllUrlsBox = new JCheckBox("Censor all messages containing URLs");
censorFirstPostUrlsBox = new JCheckBox("Censor messages containing URLs in a user's initial post");
censorUnknownCharsBox = new JCheckBox("Censor messages containing a specified percentage of extended characters:");
final String minLabel = "> 0";
// @formatter:off
unknownCharSlider = new LabeledSlider("", "%", ConfigCensor.MIN_UNKNOWN_CHAR_PCT, ConfigCensor.MAX_UNKNOWN_CHAR_PCT, Math.max(Math.max(Integer.toString(ConfigCensor.MIN_UNKNOWN_CHAR_PCT).length(), Integer.toString(ConfigCensor.MAX_UNKNOWN_CHAR_PCT).length()), minLabel.length())) {
// @formatter:on
private static final long serialVersionUID = 1L;
@Override
public String getValueString() {
if (getValue() == slider.getMinimum()) {
return minLabel;
} else {
return super.getValueString();
}
}
};
userWhitelist = new ListInput("User Whitelist", "Exempt from all censorship", this);
userBlacklist = new ListInput("User Blacklist", "Every message censored", this);
bannedWordList = new ListInput("Banned Words", "Containing censors message", this);
ActionListener bl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateConfig();
chat.repaint();
chat.initMessageRollout();
}
};
enableCensorshipBox.addActionListener(bl);
purgeOnTwitchBanBox.addActionListener(bl);
censorAllUrlsBox.addActionListener(bl);
censorFirstPostUrlsBox.addActionListener(bl);
censorUnknownCharsBox.addActionListener(bl);
unknownCharSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setUnknownCharPercentage(unknownCharSlider.getValue());
}
});
messageList = new MessageCheckList(chat, this);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.gridwidth = 3;
add(new JLabel("Censorship rules affect the visualization only; they don't influence the visibility of IRC posts."), gbc);
gbc.gridy++;
add(enableCensorshipBox, gbc);
gbc.gridy++;
add(purgeOnTwitchBanBox, gbc);
gbc.gridy++;
add(censorAllUrlsBox, gbc);
gbc.gridy++;
add(censorFirstPostUrlsBox, gbc);
gbc.gridy++;
JPanel unknownPanel = new JPanel(new GridBagLayout());
GridBagConstraints uGbc = getGbc();
uGbc.anchor = GridBagConstraints.WEST;
uGbc.weightx = 1.0;
uGbc.fill = GridBagConstraints.NONE;
unknownPanel.add(censorUnknownCharsBox, uGbc);
uGbc.gridy++;
uGbc.anchor = GridBagConstraints.EAST;
uGbc.weightx = 1.0;
uGbc.weighty = 1.0;
uGbc.fill = GridBagConstraints.BOTH;
unknownPanel.add(unknownCharSlider, uGbc);
add(unknownPanel, gbc);
gbc.gridy++;
gbc.weightx = 0.33;
gbc.gridwidth = 1;
add(userWhitelist, gbc);
gbc.gridx++;
add(userBlacklist, gbc);
gbc.gridx++;
add(bannedWordList, gbc);
gbc.gridx++;
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
add(messageList, gbc);
gbc.gridy++;
}
Aggregations