Search in sources :

Example 1 with GuiLafPreferencesManager

use of apps.gui.GuiLafPreferencesManager in project JMRI by JMRI.

the class JUnitUtil method initGuiLafPreferencesManager.

public static void initGuiLafPreferencesManager() {
    GuiLafPreferencesManager m = new GuiLafPreferencesManager();
    InstanceManager.setDefault(GuiLafPreferencesManager.class, m);
}
Also used : GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager)

Example 2 with GuiLafPreferencesManager

use of apps.gui.GuiLafPreferencesManager in project JMRI by JMRI.

the class GuiLafConfigPane method doToolTipDismissDelay.

public void doToolTipDismissDelay(JPanel panel) {
    GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
    JLabel toolTipDismissDelayLabel = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelay"));
    toolTipDismissDelaySpinner = new JSpinner(new SpinnerNumberModel(manager.getToolTipDismissDelay() / 1000, MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME, 1));
    this.toolTipDismissDelaySpinner.addChangeListener((ChangeEvent e) -> {
        // convert to milliseconds from seconds
        manager.setToolTipDismissDelay((int) toolTipDismissDelaySpinner.getValue() * 1000);
    });
    this.toolTipDismissDelaySpinner.setToolTipText(MessageFormat.format(ConfigBundle.getMessage("GUIToolTipDismissDelayToolTip"), MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME));
    toolTipDismissDelayLabel.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    JLabel toolTipDismissDelayUoM = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelayUoM"));
    toolTipDismissDelayUoM.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    panel.add(toolTipDismissDelayLabel);
    panel.add(toolTipDismissDelaySpinner);
    panel.add(toolTipDismissDelayUoM);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner)

Example 3 with GuiLafPreferencesManager

use of apps.gui.GuiLafPreferencesManager in project JMRI by JMRI.

the class GuiLafConfigPane method doFontSize.

public void doFontSize(JPanel panel) {
    GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
    Integer[] sizes = new Integer[MAX_DISPLAYED_FONT_SIZE - MIN_DISPLAYED_FONT_SIZE + 1];
    for (int i = 0; i < sizes.length; i++) {
        sizes[i] = i + MIN_DISPLAYED_FONT_SIZE;
    }
    fontSizeComboBox = new JComboBox<>(sizes);
    // allow users to set font sizes not listed
    fontSizeComboBox.setEditable(true);
    JLabel fontSizeLabel = new JLabel(ConfigBundle.getMessage("ConsoleFontSize"));
    fontSizeComboBox.setSelectedItem(manager.getFontSize());
    JLabel fontSizeUoM = new JLabel(ConfigBundle.getMessage("ConsoleFontSizeUoM"));
    JButton resetButton = new JButton(ConfigBundle.getMessage("ResetDefault"));
    resetButton.setToolTipText(ConfigBundle.getMessage("GUIFontSizeReset"));
    panel.add(fontSizeLabel);
    panel.add(fontSizeComboBox);
    panel.add(fontSizeUoM);
    panel.add(resetButton);
    fontSizeComboBox.addActionListener((ActionEvent e) -> {
        manager.setFontSize((int) fontSizeComboBox.getSelectedItem());
    });
    resetButton.addActionListener((ActionEvent e) -> {
        if ((int) fontSizeComboBox.getSelectedItem() != manager.getDefaultFontSize()) {
            fontSizeComboBox.setSelectedItem(manager.getDefaultFontSize());
        }
    });
}
Also used : GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel)

Example 4 with GuiLafPreferencesManager

use of apps.gui.GuiLafPreferencesManager in project JMRI by JMRI.

the class GuiLafConfigPaneXml method store.

/**
     * Default implementation for storing the static contents of the Swing LAF
     *
     * @param o Object to store, of type GuiLafConfigPane
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Element e = new Element("gui");
    GuiLafConfigPane g = (GuiLafConfigPane) o;
    String lafClassName = g.getClassName();
    e.setAttribute("LAFclass", lafClassName);
    e.setAttribute("class", this.getClass().getName());
    Locale l = g.getLocale();
    e.setAttribute("LocaleLanguage", l.getLanguage());
    e.setAttribute("LocaleCountry", l.getCountry());
    e.setAttribute("LocaleVariant", l.getVariant());
    GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
    if (manager.getFontSize() != manager.getDefaultFontSize()) {
        e.setAttribute("fontsize", Integer.toString(manager.getFontSize()));
    }
    e.setAttribute("nonStandardMouseEvent", (g.mouseEvent.isSelected() ? "yes" : "no"));
    e.setAttribute("graphicTableState", (g.graphicStateDisplay.isSelected() ? "yes" : "no"));
    return e;
}
Also used : Locale(java.util.Locale) GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) Element(org.jdom2.Element) GuiLafConfigPane(apps.GuiLafConfigPane)

Aggregations

GuiLafPreferencesManager (apps.gui.GuiLafPreferencesManager)4 JLabel (javax.swing.JLabel)2 GuiLafConfigPane (apps.GuiLafConfigPane)1 ActionEvent (java.awt.event.ActionEvent)1 Locale (java.util.Locale)1 JButton (javax.swing.JButton)1 JSpinner (javax.swing.JSpinner)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 ChangeEvent (javax.swing.event.ChangeEvent)1 Element (org.jdom2.Element)1