package com.traxel.lumbermill.log;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
final JToggleButton PLAY = new JToggleButton(new javax.swing.ImageIcon(
getClass().getResource("/de/cismet/beanmill/res/start.png")));
final JToggleButton PAUSE = new JToggleButton(new javax.swing.ImageIcon(
getClass().getResource("/de/cismet/beanmill/res/pause.png")));
final JToggleButton STOP = new JToggleButton(new javax.swing.ImageIcon(
getClass().getResource("/de/cismet/beanmill/res/stop.png")));
final JButton CLEAR = new JButton(new javax.swing.ImageIcon(
getClass().getResource("/de/cismet/beanmill/res/delete.png")));
ButtonGroup bg = new ButtonGroup();
private final Log LOG;
private final ActiveStateIcon PLAY_ICON = new ActiveStateIcon.PlayIcon();
private final ActiveStateIcon PAUSE_ICON = new ActiveStateIcon.PauseIcon();
private final ActiveStateIcon STOP_ICON = new ActiveStateIcon.StopIcon();
private final ActiveStateIcon CLEAR_ICON = new ActiveStateIcon.ClearIcon();
PLAY.setToolTipText("Start Logging");
PAUSE.setToolTipText("Pause Logging");
STOP.setToolTipText("Stop Logging");
CLEAR.setToolTipText("Clear Output");
this.setFloatable(false);
LOG = log;
LOG.addPropertyListener(this);
if (Log.PLAY == LOG.getActiveState()) {
PLAY_ICON.setActive(true);
} else if (Log.PAUSE == LOG.getActiveState()) {
PAUSE_ICON.setActive(true);
} else if (Log.STOP == LOG.getActiveState()) {
STOP_ICON.setActive(true);
}
add(PLAY);
add(PAUSE);
add(STOP);
add(CLEAR);
bg.add(PLAY);
bg.add(PAUSE);
bg.add(STOP);
PLAY.setSelected(true);
}
@Override
if (LOG.equals(e.getSource())
&& "_activeState".equals(e.getPropertyName())) {
final int newValue;
PLAY_ICON.setActive(false);
PAUSE_ICON.setActive(false);
STOP_ICON.setActive(false);
CLEAR_ICON.setActive(false);
newValue = ((Integer)e.getNewValue()).intValue();
if (Log.PLAY == newValue) {
PLAY_ICON.setActive(true);
} else if (Log.PAUSE == newValue) {
PAUSE_ICON.setActive(true);
} else if (Log.STOP == newValue) {
STOP_ICON.setActive(true);
}
repaint();
}
}
return CLEAR;
}
}