Package org.eclipse.nebula.widgets.nattable.edit.command

Source Code of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommandHandler

/*******************************************************************************
* Copyright (c) 2012, 2013 Original authors and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Original authors and others - initial API and implementation
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.edit.command;

import org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.edit.EditController;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.swt.widgets.Composite;

/**
* Command handler for handling {@link EditCellCommand}s. Will first check if
* putting the cell into edit mode is allowed. If it is allowed it will call the
* {@link EditController} for activation of the edit mode.
*/
public class EditCellCommandHandler extends
        AbstractLayerCommandHandler<EditCellCommand> {

    public Class<EditCellCommand> getCommandClass() {
        return EditCellCommand.class;
    }

    @Override
    public boolean doCommand(EditCellCommand command) {
        ILayerCell cell = command.getCell();
        Composite parent = command.getParent();
        IConfigRegistry configRegistry = command.getConfigRegistry();

        // check if the cell is editable
        IEditableRule rule = configRegistry.getConfigAttribute(
                EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell
                        .getConfigLabels().getLabels());

        if (rule.isEditable(cell, configRegistry)) {
            EditController.editCell(cell, parent, cell.getDataValue(),
                    configRegistry);
        }

        // as commands by default are intended to be consumed by the handler,
        // always
        // return true, whether the activation of the edit mode was successfull
        // or not
        return true;
    }

}
TOP

Related Classes of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommandHandler

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.