<commit_before>package org.jtrim.swing.access;

import javax.swing.JButton;
import org.jtrim.access.AccessChangeAction;
import org.jtrim.access.AccessManager;
import org.jtrim.utils.ExceptionHelper;

/**
 * Defines an {@link AccessChangeAction} which sets the caption of a
 * {@code JButton} depending on the availability of the associated group of
 * rights.
 * <P>
 * The intended use of the {@code ButtonCancelSwitcher} is to set the cancel
 * caption for the button when the given rights are not available (assuming that
 * they are not available because of a task which maybe canceled).
 * <P>
 * Note that {@code ButtonCancelSwitcher} does call the {@code setText} method
 * of the {@code JButton} instances in the
 * {@link #onChangeAccess(boolean) onChangeAccess} method, so the
 * {@link AccessManager} governing the rights must be set to use an executor
 * which submits tasks to the AWT event dispatch thread (or wrap the
 * {@code ComponentDisabler} in an {@code AccessChangeAction} which makes sure
 * that the {@code onChangeAccess} method does not get called on an
 * inappropriate thread).
 *
 * <h3>Thread safety</h3>
 * The {@link #onChangeAccess(boolean) onChangeAccess} may only be called from
 * the AWT event dispatch thread but other methods are safe to be accessed from
 * multiple threads concurrently.
 *
 * <h4>Synchronization transparency</h4>
 * Methods of this class are not <I>synchronization transparent</I>.
 *
 * @author <NAME><commit_msg>Fixed a checkstyle issue in ButtonCancelSwitcher.<commit_after>package org.jtrim.swing.access;

import javax.swing.JButton;
import org.jtrim.access.AccessChangeAction;
import org.jtrim.utils.ExceptionHelper;

/**
 * Defines an {@link AccessChangeAction} which sets the caption of a
 * {@code JButton} depending on the availability of the associated group of
 * rights.
 * <P>
 * The intended use of the {@code ButtonCancelSwitcher} is to set the cancel
 * caption for the button when the given rights are not available (assuming that
 * they are not available because of a task which maybe canceled).
 * <P>
 * Note that {@code ButtonCancelSwitcher} does call the {@code setText} method
 * of the {@code JButton} instances in the
 * {@link #onChangeAccess(boolean) onChangeAccess} method, so the
 * {@link org.jtrim.access.AccessManager} governing the rights must be set to
 * use an executor which submits tasks to the AWT event dispatch thread (or wrap
 * the {@code ComponentDisabler} in an {@code AccessChangeAction} which makes
 * sure that the {@code onChangeAccess} method does not get called on an
 * inappropriate thread).
 *
 * <h3>Thread safety</h3>
 * The {@link #onChangeAccess(boolean) onChangeAccess} may only be called from
 * the AWT event dispatch thread but other methods are safe to be accessed from
 * multiple threads concurrently.
 *
 * <h4>Synchronization transparency</h4>
 * Methods of this class are not <I>synchronization transparent</I>.
 *
 * @author <NAME>
{'fraction_non_alphanumeric': 0.08445945945945946, 'fraction_numerical': 0.002702702702702703, 'mean_word_length': 4.7272727272727275, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1374886', 'n_tokens_mistral': 804, 'n_tokens_neox': 794, 'n_words': 360}