20 package net.sf.gridarta.gui.filter;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.util.HashMap;
26 import javax.swing.AbstractButton;
27 import javax.swing.JCheckBoxMenuItem;
28 import javax.swing.JComponent;
29 import javax.swing.JSeparator;
30 import javax.swing.event.ChangeEvent;
31 import javax.swing.event.ChangeListener;
35 import net.
sf.japi.swing.action.ActionBuilder;
36 import net.
sf.japi.swing.action.ActionBuilderFactory;
37 import org.jetbrains.annotations.NotNull;
51 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
58 private final Map<String, JComponent>
content =
new HashMap<>();
96 active.getModel().setSelected(this.config.isEnabled());
97 active.addChangeListener(
new ChangeListener() {
100 public void stateChanged(@NotNull
final ChangeEvent e) {
104 component.add(active);
105 inverted.getModel().setSelected(this.config.isInverted());
106 inverted.addChangeListener(
new ChangeListener() {
109 public void stateChanged(@NotNull
final ChangeEvent e) {
113 component.add(inverted);
114 component.add(
new JSeparator());
118 if (content.containsKey(name)) {
123 entry.setVisible(
true);
125 content.put(name, entry);
126 component.add(entry);
130 if (!content.containsKey(name)) {
134 final Component c = content.get(name);
135 content.remove(name);
final Map< String, JComponent > content
Maps sub-filter name to corresponding menu item.
final NamedFilterConfig config
The filter configuration that is shown in component.
void setEnabled(final boolean enabled)
Updates a Component to reflect the current state of a NamedFilterConfig.
static final ActionBuilder ACTION_BUILDER
The action builder.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Base package of all Gridarta classes.
FilterComponent(@NotNull final Container component, @NotNull final NamedFilterConfig config)
Createsa a new instance.
Utility class for ActionBuilder related functions.
void removeFilter(@NotNull final String name)
final AbstractButton inverted
The checkbox menu items which shows the "inverted" state of config.
void setInverted(final boolean inverted)
Sets whether the filter should match if all sub-filters match or if at least one sub-filter does not ...
final AbstractButton active
The checkbox menu items which shows the "active" state of config.
Interface for filter configurations.
final Container component
The components which shows the state of config.
A FilterConfig that has a name.
void addFilter(@NotNull final String name, @NotNull final FilterConfig<?, ?> config)