Search in sources :

Example 1 with MessageCheckList

use of com.glitchcog.fontificator.gui.controls.messages.MessageCheckList 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++;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) ListInput(com.glitchcog.fontificator.gui.component.ListInput) JCheckBox(javax.swing.JCheckBox) LabeledSlider(com.glitchcog.fontificator.gui.component.LabeledSlider) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) MessageCheckList(com.glitchcog.fontificator.gui.controls.messages.MessageCheckList) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

LabeledSlider (com.glitchcog.fontificator.gui.component.LabeledSlider)1 ListInput (com.glitchcog.fontificator.gui.component.ListInput)1 MessageCheckList (com.glitchcog.fontificator.gui.controls.messages.MessageCheckList)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 TitledBorder (javax.swing.border.TitledBorder)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1