| /***************************************************************************** |
| * Copyright (c) 2020 CEA LIST. |
| * |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * CEA LIST - Initial API and implementation |
| * |
| *****************************************************************************/ |
| |
| package org.eclipse.papyrus.cdo.security.internal.conditions; |
| |
| import org.eclipse.core.expressions.PropertyTester; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.papyrus.cdo.security.handlers.EditUserHandler; |
| |
| public class EditUserCondition extends PropertyTester { |
| |
| private final static String propertyValue = "EditUserCondition"; |
| |
| /** |
| * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) |
| * |
| * @param receiver |
| * @param property |
| * @param args |
| * @param expectedValue |
| * @return |
| */ |
| @Override |
| public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { |
| if (!(expectedValue instanceof Boolean) |
| || !(propertyValue.equals(property)) |
| || !(receiver instanceof IStructuredSelection)) { |
| return false;// worst case, so we result false |
| } |
| return EditUserHandler.isValidSelection(); |
| } |
| |
| } |