blob: 4fbc1496fef17db1fee7df16a6ab3305dab6cdd1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*****************************************************************************
* Copyright (c) 2019 CEA LIST and others.
*
* 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
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.emf.ui.validators;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.papyrus.emf.ui.messages.Messages;
/**
* Validator for single selection of {@link EStructuralFeature}
*/
public final class SingleEStructuralFeatureValidator extends AbstractSelectionStatusValidator {
/**
* @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[])
*
* @param selection
* @return
*/
@Override
public IStatus validate(Object[] selection) {
String errorMessage = ""; //$NON-NLS-1$
if (selection.length == 0) {
errorMessage = NO_SELECTION;
} else {
final Object firstSelection = selection[0];
if (false == firstSelection instanceof EStructuralFeature || selection.length != 1) {
errorMessage = Messages.SingleEStructuralFeatureValidator_YouMustSelectOneEStructuralFeature;
}
}
return buildIStatus(errorMessage);
}
}
|