|
@@ -1,3 +1,13 @@
|
|
|
+/**
|
|
|
+ * Copyright (c) 2013 committers of YAKINDU 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:
|
|
|
+ * committers of YAKINDU - initial API and implementation
|
|
|
+ *
|
|
|
+ */
|
|
|
package de.itemis.gmf.runtime.commons.parsers;
|
|
|
|
|
|
import org.eclipse.core.runtime.Assert;
|
|
@@ -22,7 +32,7 @@ import de.itemis.xtext.utils.gmf.directedit.IEAttributeProvider;
|
|
|
/**
|
|
|
* Direct editing parser that allows editing of an EAttribute of type String.
|
|
|
*
|
|
|
- * @author andreas muelder
|
|
|
+ * @author andreas muelder - Initial contribution and API
|
|
|
*
|
|
|
*/
|
|
|
public class StringAttributeParser implements IParser {
|
|
@@ -52,24 +62,32 @@ public class StringAttributeParser implements IParser {
|
|
|
if (string != null && !string.trim().isEmpty()) {
|
|
|
return String.valueOf(string);
|
|
|
} else {
|
|
|
- return "<" + attribute.getName() + ">";
|
|
|
+ return createEmptyStringLabel(attribute);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
|
|
|
+ protected String createEmptyStringLabel(EAttribute attribute) {
|
|
|
+ return "<" + attribute.getName() + ">";
|
|
|
+ }
|
|
|
+
|
|
|
+ public IParserEditStatus isValidEditString(IAdaptable element,
|
|
|
+ String editString) {
|
|
|
return new ParserEditStatus(pluginId, IParserEditStatus.OK, "");
|
|
|
}
|
|
|
|
|
|
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
|
|
|
+ public ICommand getParseCommand(IAdaptable adapter, String newString,
|
|
|
+ int flags) {
|
|
|
if (newString == null) {
|
|
|
return UnexecutableCommand.INSTANCE;
|
|
|
}
|
|
|
EObject element = (EObject) adapter.getAdapter(EObject.class);
|
|
|
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
|
|
|
+ TransactionalEditingDomain editingDomain = TransactionUtil
|
|
|
+ .getEditingDomain(element);
|
|
|
if (editingDomain == null) {
|
|
|
return UnexecutableCommand.INSTANCE;
|
|
|
}
|
|
|
- SetRequest request = new SetRequest(element, provider.getAttribute(), newString);
|
|
|
+ SetRequest request = new SetRequest(element, provider.getAttribute(),
|
|
|
+ newString);
|
|
|
return new SetValueCommand(request);
|
|
|
}
|
|
|
|
|
@@ -80,7 +98,8 @@ public class StringAttributeParser implements IParser {
|
|
|
|
|
|
public boolean isAffectingEvent(Object event, int flags) {
|
|
|
if (event instanceof Notification) {
|
|
|
- return (((Notification) event).getFeature() == provider.getAttribute());
|
|
|
+ return (((Notification) event).getFeature() == provider
|
|
|
+ .getAttribute());
|
|
|
}
|
|
|
return false;
|
|
|
}
|