diff options
author | 2021-08-03 18:42:39 +0900 | |
---|---|---|
committer | 2021-08-06 19:32:38 +0900 | |
commit | be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch) | |
tree | 1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor/src/rba/tool/editor/util | |
parent | 71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff) |
Initial commit
Bug-AGL: SPEC-4033
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.editor/src/rba/tool/editor/util')
3 files changed, 114 insertions, 0 deletions
diff --git a/rba.tool.editor/src/rba/tool/editor/util/ExtensionModuleManager.java b/rba.tool.editor/src/rba/tool/editor/util/ExtensionModuleManager.java new file mode 100644 index 0000000..966acf0 --- /dev/null +++ b/rba.tool.editor/src/rba/tool/editor/util/ExtensionModuleManager.java @@ -0,0 +1,63 @@ +package rba.tool.editor.util; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + +import com.google.inject.Module; + +public class ExtensionModuleManager { + public static final ExtensionModuleManager INSTANCE = new ExtensionModuleManager(); + + private static final String EXTENSION_POINT = "rba.tool.editor.rbaToolEditorExtensionModule"; //$NON-NLS-1$ + + private static final String EXTENSION_POINT_ELEMENT = "extensionModule"; //$NON-NLS-1$ + + private static final String EXTENSION_POINT_ELEMENT_ATTRIBUTE = "class"; //$NON-NLS-1$ + + private List<Module> constraintProviders; + + private ExtensionModuleManager() { + } + + public List<Module> getExtensionModules() { + if (constraintProviders == null) { + constraintProviders = new ArrayList<Module>(); + init(); + } + return constraintProviders; + } + + private void init() { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT); // $NON-NLS-1$ + IExtension[] extensions = extensionPoint.getExtensions(); + + List<Module> providerList = new ArrayList<Module>(); + for (int i = 0; i < extensions.length; i++) { + IConfigurationElement[] elements = extensions[i].getConfigurationElements(); + for (int j = 0; j < elements.length; j++) { + IConfigurationElement element = elements[j]; + String elementName = element.getName(); + if (elementName.equalsIgnoreCase(EXTENSION_POINT_ELEMENT)) { // $NON-NLS-1$ + try { + Object provider = element.createExecutableExtension(EXTENSION_POINT_ELEMENT_ATTRIBUTE); // $NON-NLS-1$ + if (provider instanceof Module) { + Module factory = (Module) provider; + providerList.add(factory); + } + } catch (CoreException e) { + // do nothing + } + } + } + } + constraintProviders.addAll(providerList); + } +} diff --git a/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorNameUtil.xtend b/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorNameUtil.xtend new file mode 100644 index 0000000..e7b7321 --- /dev/null +++ b/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorNameUtil.xtend @@ -0,0 +1,11 @@ +package rba.tool.editor.util + +class RBAModelEditorNameUtil { + public static val MODEL_FOLDER_NAME = "model" + public static val BUILD_FOLDER_NAME = ".applied" + public static val BUILD_TEMP_FOLDER_NAME = "temp" + public static val TEMPLATE_FOLDER_NAME = "extension" + + public static val MODEL_FILE_EXT = "rba" + public static val TEMPLATE_FILE_EXT = "ext" +} diff --git a/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorToolUtil.xtend b/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorToolUtil.xtend new file mode 100644 index 0000000..1055423 --- /dev/null +++ b/rba.tool.editor/src/rba/tool/editor/util/RBAModelEditorToolUtil.xtend @@ -0,0 +1,40 @@ +package rba.tool.editor.util + +import java.util.Collection +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.EStructuralFeature +import org.eclipse.emf.ecore.EValidator +import rba.core.AbstractAllocatable +import rba.core.AbstractContent +import rba.core.Expression +import rba.core.RBACorePackage + +class RBAModelEditorToolUtil { + + def public static String getExpressionText(Expression expression) { + return if (expression !== null) expression.getExpressionText() else "[Invalid_Expression]"; + } + + def public static boolean isSkippedSyntax(EObject obj, EStructuralFeature feature) { + // AbstractAllocatable -> contents + if (obj instanceof AbstractAllocatable && feature == RBACorePackage.Literals.ABSTRACT_ALLOCATABLE__CONTENTS) { + return true; + } + // AbstractAllocatable -> group + if (obj instanceof AbstractAllocatable && feature == RBACorePackage.Literals.ABSTRACT_ALLOCATABLE__ALLOCATABLE_GROUP) { + return true; + } + // AbstractContent -> group + if (obj instanceof AbstractContent && feature == RBACorePackage.Literals.ABSTRACT_CONTENT__CONTENT_GROUP) { + return true; + } + return false; + } + + def public static boolean isValidated(Object context, EValidator validator) { + if (context instanceof Collection<?>) { + return (context as Collection<?>).contains(validator); + } + return false; + } +} |