/******************************************************************************* * Copyright (c) 2006-2013 The RCP Company 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: * The RCP Company - initial API and implementation *******************************************************************************/ package com.rcpcompany.uibindings.internal.propertyTesters; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.edit.command.DeleteCommand; import org.eclipse.emf.edit.domain.EditingDomain; import com.rcpcompany.uibindings.Constants; import com.rcpcompany.uibindings.internal.Activator; import com.rcpcompany.uibindings.utils.EditingDomainUtils; import com.rcpcompany.utils.logging.LogUtils; /** * Property tester for {@link EObject}. * * TODO TEST * * @author Tonny Madsen, The RCP Company */ public class EObjectPropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (Activator.getDefault().TRACE_PROPERTY_TESTERS) { LogUtils.debug(this, Constants.PREFIX + property + "(" + receiver + ")"); } if (!(receiver instanceof EObject)) { LogUtils.error(this, "Receiver not EObject: " + receiver); return false; } final EObject obj = (EObject) receiver; if (Constants.PROPERTY_CAN_DELETE.equals(property)) { final EditingDomain ed = EditingDomainUtils.getEditingDomain(); final Command cmd = DeleteCommand.create(ed, obj); return cmd.canExecute(); } return false; } }