001package jmri.jmrit.whereused;
002
003import javax.swing.JTextArea;
004import jmri.NamedBean;
005import jmri.NamedBean.DisplayOptions;
006
007/**
008 * Find sensor references.
009 *
010 * @author Dave Sand Copyright (C) 2020
011 */
012public class SensorWhereUsed {
013
014    /**
015     * Populate a textarea with the whereused content for the supplied sensor.
016     * @param sensor The sensor bean.
017     * @return a populated textarea.
018     */
019    static public JTextArea getWhereUsed(NamedBean sensor) {
020        JTextArea textArea = new JTextArea();
021        String label = Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameSensor"));  // NOI18N
022        textArea.append(Bundle.getMessage("ReferenceTitle", label, sensor.getDisplayName(DisplayOptions.USERNAME_SYSTEMNAME)));  // NOI18N
023        textArea.append(Bundle.getMessage("ListenerCount", sensor.getNumPropertyChangeListeners()));  // NOI18N
024
025        textArea.append(WhereUsedCollectors.checkTurnouts(sensor));
026        textArea.append(WhereUsedCollectors.checkLights(sensor));
027        textArea.append(WhereUsedCollectors.checkRoutes(sensor));
028        textArea.append(WhereUsedCollectors.checkBlocks(sensor));
029        textArea.append(WhereUsedCollectors.checkLayoutBlocks(sensor));
030        textArea.append(WhereUsedCollectors.checkSignalHeadLogic(sensor));
031        textArea.append(WhereUsedCollectors.checkSignalMastLogic(sensor));
032        textArea.append(WhereUsedCollectors.checkSignalGroups(sensor));
033        textArea.append(WhereUsedCollectors.checkOBlocks(sensor));
034        textArea.append(WhereUsedCollectors.checkEntryExit(sensor));
035        textArea.append(WhereUsedCollectors.checkLogixConditionals(sensor));
036        textArea.append(WhereUsedCollectors.checkLogixNGConditionals(sensor));
037        textArea.append(WhereUsedCollectors.checkSections(sensor));
038        textArea.append(WhereUsedCollectors.checkTransits(sensor));
039        textArea.append(WhereUsedCollectors.checkPanels(sensor));
040        textArea.append(WhereUsedCollectors.checkCTC(sensor));
041        return textArea;
042    }
043}