public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>flintstones.group</groupId>
|
||||
<artifactId>flintstones.bundles</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>flintstones.model.method.provider</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Provider</name>
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.model.method.provider</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362725</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,22 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Provider
|
||||
Bundle-SymbolicName: flintstones.model.method.provider
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.model.method.provider
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: javax.inject,
|
||||
org.eclipse.e4.core.contexts,
|
||||
flintstones.model.method.service,
|
||||
org.eclipse.e4.core.di,
|
||||
org.eclipse.e4.ui.model.workbench,
|
||||
org.eclipse.e4.core.services,
|
||||
flintstones.helper.extensionpoint,
|
||||
flintstones.entity.method,
|
||||
flintstones.helper.data,
|
||||
javax.annotation,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.model.method.phase.service,
|
||||
flintstones.entity.method.phase.ui
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: component.xml
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
component.xml
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="flintstones.method">
|
||||
<implementation class="flintstones.model.method.provider.MethodServiceContextFunction" />
|
||||
<property name="service.context.key" type="String" value="flintstones.model.method.service.IMethodService" />
|
||||
<service>
|
||||
<provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package flintstones.model.method.provider;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextFunction;
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
|
||||
//import flintstones.method.provider.MethodServiceProvider;
|
||||
import flintstones.model.method.service.IMethodService;
|
||||
|
||||
/**
|
||||
* The Class DomainServiceContextFunction add the Domain Service instance to global context.
|
||||
*/
|
||||
public class MethodServiceContextFunction extends ContextFunction {
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.e4.core.contexts.ContextFunction#compute(org.eclipse.e4.core.
|
||||
* contexts.IEclipseContext, java.lang.String) */
|
||||
@Override
|
||||
public Object compute(IEclipseContext context, String contextKey) {
|
||||
IMethodService domainService = ContextInjectionFactory.make(MethodServiceProvider.class, context);
|
||||
MApplication application = context.get(MApplication.class);
|
||||
IEclipseContext applicationContext = application.getContext();
|
||||
applicationContext.set(IMethodService.class, domainService);
|
||||
return domainService;
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package flintstones.model.method.provider;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
|
||||
import flintstones.entity.method.Method;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.helper.data.HashMapList;
|
||||
import flintstones.helper.extensionpoint.BaseRegistry;
|
||||
import flintstones.helper.extensionpoint.ExtensionRegistry;
|
||||
import flintstones.model.method.phase.IPhaseMethodService;
|
||||
import flintstones.model.method.service.IMethodService;
|
||||
|
||||
class MethodServiceProvider implements IMethodService {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IPhaseMethodService phaseService;
|
||||
|
||||
@Inject
|
||||
IEventBroker broker;
|
||||
|
||||
private BaseRegistry reg;
|
||||
private BaseRegistry categoryReg;
|
||||
|
||||
private HashMapList<String, Method> categoryMethodMapping = null; // null -> Regen
|
||||
|
||||
private HashMap<String, Method> methods = new HashMap<>();
|
||||
|
||||
public MethodServiceProvider() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.reg = new BaseRegistry(Method.EXTENSION_POINT);
|
||||
this.categoryReg = new BaseRegistry(Method.EXTENSION_POINT_CATEGORY);
|
||||
this.cacheAllMethods();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadPhasesFor(Method method) {
|
||||
ExtensionRegistry methodRegistry = this.reg.getFirstRegistryWhere(Method.Fields.uid, method.getId());
|
||||
ExtensionRegistry[] phasesEr = methodRegistry.getAttributeReferences(Method.Fields.phase);
|
||||
|
||||
// Prepare phases
|
||||
PhaseMethodUI[] phasesUI = phaseService.createPhases(Arrays.stream(phasesEr).map(k -> k.getAttribute(PhaseMethod.Fields.uid)).toArray(String[]::new));
|
||||
for(PhaseMethodUI ui : phasesUI)
|
||||
ui.getModel().setMethodData(method.getExportedData());
|
||||
|
||||
method.setPhases(phasesUI);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheAllMethods() {
|
||||
|
||||
methods.clear();
|
||||
categoryMethodMapping = null;
|
||||
|
||||
String methodIds[] = reg.getAllAttributesUnique(Method.Fields.uid);
|
||||
for (String methodId : methodIds) {
|
||||
Method method = (Method) reg.instantiate(methodId, this.context);
|
||||
method.setId(methodId);
|
||||
method.setName(reg.getAttributeFromId(methodId, Method.Fields.name));
|
||||
method.setCategory(lookForCategory(reg.getAttributeFromId(methodId, Method.Fields.category)));
|
||||
methods.put(method.getId(), method);
|
||||
}
|
||||
}
|
||||
|
||||
private String lookForCategory(String categoryId) {
|
||||
return categoryReg.getAllRegistriesWhere(Method.Fields.uid, categoryId)[0]
|
||||
.getAttribute(Method.Fields.category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAllCategories() {
|
||||
HashSet<String> set = new HashSet<>();
|
||||
methods.values().stream().forEach(k -> set.add(k.getCategory()));
|
||||
return set.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method[] getAllMethodForCategory(String category) {
|
||||
if (categoryMethodMapping == null)
|
||||
cacheCategoryMethod();
|
||||
|
||||
Comparator<Method> byName = Comparator.comparing(Method::getName);
|
||||
categoryMethodMapping.get(category).sort(byName);
|
||||
return categoryMethodMapping.get(category).toArray(new Method[0]);
|
||||
}
|
||||
|
||||
private void cacheCategoryMethod() {
|
||||
categoryMethodMapping = new HashMapList<String, Method>();
|
||||
|
||||
for (Method m : methods.values())
|
||||
categoryMethodMapping.add(m.getCategory(), m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
broker.send("TOPIC_RATING/CONTAINER/CLEAR", null);
|
||||
phaseService.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method[] getAll() {
|
||||
return methods.values().toArray(new Method[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user