package com.onaro.sanscreen.client.view.actions; import com.onaro.sanscreen.client.view.refresh.*; import com.onaro.sanscreen.client.view.selection.*; import com.onaro.sanscreen.client.view.ActionFactory; import com.onaro.util.*; import com.onaro.util.jfc.*; import javax.swing.*; import java.awt.event.*; import java.util.*; /** * An action enabling an auto refresh */ public class AutoRefreshAction extends ConfigurableAction { private static final long serialVersionUID = 1L; /** * @param conf a a configuration element having the following attributes: * @param resources contains the action's properties * @throws InvalidConfigException the attributes listed above are missing */ public AutoRefreshAction(ActionFactory.ActionInitInfo actionInitInfo, ResourceBundle resources ) throws IllegalInitException { super(actionInitInfo, resources); } public void actionPerformed(ActionEvent e) { assert e.getSource() instanceof JCheckBoxMenuItem : "Source is not of the correct type"; //$NON-NLS-1$ boolean selected = ((JCheckBoxMenuItem)e.getSource()).isSelected(); RefreshManager.getInstance().setEnabled(selected); } public void setSelected(boolean selected) { super.setSelected(selected); RefreshManager.getInstance().setEnabled(selected); } public void setEnableBySelection(ObjectSelectionModel selection) { super.setSelected(RefreshManager.getInstance().getEnabled()); super.setEnableBySelection(selection); } public String toString() { return "AutoRefreshAction"; //$NON-NLS-1$ } }