@@ -0,0 +1,2859 @@
+/*%0A * Copyright (C) 2011 0xlab - http://0xlab.org/%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A * Authored by Kan-Ru Chen %3Ckanru@0xlab.org%3E%0A */%0A%0Apackage org.zeroxlab.aster;%0A%0Aimport java.util.*;%0Aimport javax.swing.event.*;%0A%0Apublic class DefaultActionListModel implements ActionListModel %7B%0A    /** The listeners waiting for model changes. */%0A    protected EventListenerList listenerList = new EventListenerList();%0A%0A    public void addChangeListener(ChangeListener l) %7B%0A        listenerList.add(ChangeListener.class, l);%0A    %7D%0A%0A    public void removeChangeListener(ChangeListener l) %7B%0A        listenerList.remove(ChangeListener.class, l);%0A    %7D%0A%0A    /**%0A     * Run each %3Ccode%3EChangeListener%3C/code%3E's %3Ccode%3EstateChanged%3C/code%3E%0A     * method.%0A     */%0A    protected void fireStateChanged() %7B%0A        ChangeEvent ev = null;%0A        Object%5B%5D listeners = listenerList.getListenerList();%0A        for (int i = listeners.length-2; i %3E= 0; i -= 2) %7B%0A            if (listeners%5Bi%5D == ChangeListener.class) %7B%0A                // Lazily create the event:%0A                if (ev == null)%0A                    ev = new ChangeEvent(this);%0A                ((ChangeListener)listeners%5Bi+1%5D).stateChanged(ev);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns an array of all the change listeners registered on this%0A     * %3Ccode%3EDefaultActionListModel%3C/code%3E.%0A     *%0A     * @return all of this model's %3Ccode%3EChangeListener%3C/code%3Es or an empty%0A     *         arrary if no change listeners are currently registered%0A     *%0A     * @see #addchangeListener%0A     * @see #removeChangeListener%0A     */%0A    public ChangeListener%5B%5D getChangeListeners() %7B%0A        return (ChangeListener%5B%5D) listenerList.getListeners(ChangeListener.class);%0A    %7D%0A%0A    /** The command stack */%0A    Deque actionList = new ArrayDeque%3CAsterCommand%3E();%0A    /** The recall command */%0A    AsterCommand recall;%0A%0A    public DefaultActionListModel() %7B%0A    %7D%0A%0A    public void setRecall(AsterCommand cmd) %7B%0A        recall = cmd;%0A        fireStateChanged();%0A    %7D%0A%0A    public void pushCmd(AsterCommand cmd) %7B%0A        actionList.addFirst(cmd);%0A        fireStateChanged();%0A    %7D%0A%0A    public void popCmd() %7B%0A        try %7B%0A            actionList.removeFirst();%0A            fireStateChanged();%0A        %7D catch (NoSuchElementException e) %7B%0A            // log.w(%22try to pop empty command list%22);%0A        %7D%0A    %7D%0A%7D%0A

Add default action list model implementation.