Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/emf/org.eclipse.papyrus.emf.ui/api/org/eclipse/papyrus/emf/ui/validators/SingleEStructuralFeatureValidator.java')
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.emf.ui/api/org/eclipse/papyrus/emf/ui/validators/SingleEStructuralFeatureValidator.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/emf/org.eclipse.papyrus.emf.ui/api/org/eclipse/papyrus/emf/ui/validators/SingleEStructuralFeatureValidator.java b/plugins/emf/org.eclipse.papyrus.emf.ui/api/org/eclipse/papyrus/emf/ui/validators/SingleEStructuralFeatureValidator.java
new file mode 100755
index 00000000000..4fbc1496fef
--- /dev/null
+++ b/plugins/emf/org.eclipse.papyrus.emf.ui/api/org/eclipse/papyrus/emf/ui/validators/SingleEStructuralFeatureValidator.java
@@ -0,0 +1,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);
+ }
+
+}

Back to the top