001/** 002 * 003 */ 004package icy.action; 005 006import icy.gui.main.ActiveSequenceListener; 007import icy.main.Icy; 008import icy.sequence.Sequence; 009import icy.sequence.SequenceEvent; 010 011import java.util.ArrayList; 012import java.util.List; 013 014/** 015 * @author Stephane 016 */ 017public class ActionManager 018{ 019 /** 020 * All registered action 021 */ 022 public static List<IcyAbstractAction> actions = null; 023 024 // internals 025 private static ActiveSequenceListener activeSequenceListener; 026 027 public static synchronized void init() 028 { 029 // init actions 030 if (actions == null) 031 { 032 actions = new ArrayList<IcyAbstractAction>(); 033 034 // add all kernels actions 035 actions.addAll(FileActions.getAllActions()); 036 actions.addAll(GeneralActions.getAllActions()); 037 actions.addAll(PreferencesActions.getAllActions()); 038 actions.addAll(SequenceOperationActions.getAllActions()); 039 actions.addAll(RoiActions.getAllActions()); 040 actions.addAll(CanvasActions.getAllActions()); 041 actions.addAll(ViewerActions.getAllActions()); 042 actions.addAll(WindowActions.getAllActions()); 043 044 activeSequenceListener = new ActiveSequenceListener() 045 { 046 @Override 047 public void sequenceDeactivated(Sequence sequence) 048 { 049 // nothing here 050 } 051 052 @Override 053 public void sequenceActivated(Sequence sequence) 054 { 055 // force action components refresh 056 for (IcyAbstractAction action : actions) 057 action.enabledChanged(); 058 } 059 060 @Override 061 public void activeSequenceChanged(SequenceEvent event) 062 { 063 // nothing here 064 } 065 }; 066 067 // listen these event 068 Icy.getMainInterface().addActiveSequenceListener(activeSequenceListener); 069 } 070 } 071}