Package DisplayProject

Source Code of DisplayProject.ActivateActionListener

/*
Copyright (c) 2003-2009 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package DisplayProject;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import javax.swing.ButtonGroup;
import javax.swing.DefaultButtonModel;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JRadioButtonMenuItem;

import DisplayProject.events.ChildEventHelper;
import Framework.EventHandle;
import Framework.ParameterHolder;

/**
* this class is the action listener for Menu actions and post the necessary Forte events
*/
public class ActivateActionListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        List<EventHandle> eventsToPost = new ArrayList<EventHandle>();
        Hashtable<String, Object> qq_Params = new Hashtable<String, Object>();
        qq_Params.put("x", new ParameterHolder(0));
        qq_Params.put("y", new ParameterHolder(0));
        int modifiers = 0;
        if ((e.getModifiers() & ActionEvent.CTRL_MASK) > 0)
            modifiers = modifiers | 1;
        if ((e.getModifiers() & ActionEvent.SHIFT_MASK) > 0)
            modifiers = modifiers | 2;
        if ((e.getModifiers() & ActionEvent.ALT_MASK) > 0)
            modifiers = modifiers | 4;
        if ((e.getModifiers() & ActionEvent.META_MASK) > 0)
            modifiers = modifiers | 8;
        qq_Params.put("modifier", new ParameterHolder(modifiers));
        qq_Params.put("node", new ParameterHolder(null));
        qq_Params.put("row", new ParameterHolder(0));
        qq_Params.put("column", new ParameterHolder(0));
        if (e.getSource() instanceof JRadioButtonMenuItem) {
            ButtonGroup bg = ((DefaultButtonModel) ((JRadioButtonMenuItem) e
                    .getSource()).getModel()).getGroup();
            eventsToPost.add(new EventHandle(bg, "Activate", qq_Params));
        } else {
            Component me = (Component) e.getSource();

            //System.out.println("Activate on ["+ me.toString() + "]");
            eventsToPost.add(new EventHandle(me, "Activate", qq_Params));
            // TF:13/11/07:Commented this out as there is now a childActivateListener to take care of this
            //ChildEventHelper.postEventToAllParents(me, "ChildActivate", null, eventsToPost);
        }
        /*
         * toData() must be called to update the mapped data object.
         * This method will be overidden in each control.
         */
        if ((e.getSource() instanceof JCheckBoxMenuItem)
                || (e.getSource() instanceof JRadioButtonMenuItem)) {
            toData();
            afterValueChange((Component) e.getSource(), eventsToPost);
        }
        FocusHelper.menuActivate((JComponent) e.getSource(), eventsToPost);
    }

    public void toData() {

    }

    private void afterValueChange(Component me, List<EventHandle> eventsToPost) {
        eventsToPost.add(new EventHandle(me, "AfterValueChange"));
        ChildEventHelper.postEventToAllParents(me, "ChildAfterValueChange", null, eventsToPost);
    }
}
TOP

Related Classes of DisplayProject.ActivateActionListener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.