Package DisplayProject.actions

Source Code of DisplayProject.actions.ReEditCell

/*
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.actions;

import java.awt.Component;

import javax.swing.JTable;

import org.apache.log4j.Logger;

import DisplayProject.DataField;
import DisplayProject.RadioList;
import DisplayProject.table.ArrayFieldCellHelper;
import Framework.EventHandle;
import Framework.ParameterHolder;
/**
* This pending action is used to cause the re-editing  of a data field.
* It is used in implementing the Forte PurgeEvents mechanism
* @author Peter
*
*/
public class ReEditCell extends PendingAction {
    private static Logger logger = Logger.getLogger(ReEditCell.class);

    private EventHandle ev = null;
    public ReEditCell(EventHandle ev) {
        super((Component)ev.getSourceObject());
        this.ev = ev;
    }
    public void performAction() {
        if (ev.getParameters() != null) {
            /*
             * we are a data field in an array field
             */
            ParameterHolder aph = ((ParameterHolder)ev.getParameter(ArrayFieldCellHelper.CLIENT_PROPERTY_ARRAY_FIELD));
            if (aph != null){
                JTable table = (JTable)aph.getObject();
                // TF:27/9/07:Row and columns will be 1-based, and we need them to be 0-based
                int row = ((ParameterHolder)ev.getParameter("row")).getInt()-1
                int col = ((ParameterHolder)ev.getParameter("column")).getInt()-1
                table.requestFocusInWindow();
                if (table.getCellEditor()!= null)
                    table.getCellEditor().cancelCellEditing();
                table.changeSelection(row, col,  false, false);
                //FormattedCellEditor ed = (FormattedCellEditor)table.getCellEditor(row, col);
                table.editCellAt(row, col);

            }
        } else {
            /*
             * we are a data field on its own
             */
            if (this._component instanceof DataField) {
                ((DataField)this._component).requestFocus();
            } else if (this._component instanceof RadioList) {
                ((RadioList)this._component).requestFocus();
            }
        }
        if (this._component instanceof DataField) {
            ((DataField)this._component).setLastValue(null);
        } else if (this._component instanceof RadioList) {
            ((RadioList)this._component).setPreviousValue();
        }
    }
    public static void edit(EventHandle ev){
        Object obj = ev.getSourceObject();
        if(!(obj instanceof Component))
        {
            logger.debug( "Will error because obj is of type " + obj.getClass().getName());
            return;
        }
        else
        {
            //logger.debug( "Will NOT error because obj is of type (s/be Component) " + obj.getClass().getName());
        }
        ActionMgr.addAction(new ReEditCell(ev));
    }



}
TOP

Related Classes of DisplayProject.actions.ReEditCell

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.