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.domain.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.domain.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>1779484362721</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,19 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Provider
|
||||
Bundle-SymbolicName: flintstones.model.domain.provider
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.model.domain.provider
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: javax.inject,
|
||||
org.eclipse.e4.core.contexts,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.entity.domain,
|
||||
org.eclipse.e4.core.di,
|
||||
org.eclipse.e4.ui.model.workbench,
|
||||
flintstones.helper.extensionpoint,
|
||||
javax.annotation
|
||||
Service-Component: component.xml
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: flintstones.model.domain.provider
|
||||
Import-Package: org.eclipse.e4.core.services.nls
|
||||
@@ -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.model.domain.provider">
|
||||
<implementation class="flintstones.model.domain.provider.DomainServiceContextFunction" />
|
||||
<service>
|
||||
<provide interface="org.eclipse.e4.core.contexts.IContextFunction" />
|
||||
</service>
|
||||
<property name="service.context.key" type="String" value="flintstones.model.domain.service.IDomainService"/>
|
||||
</scr:component>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package flintstones.model.domain.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.model.domain.service.IDomainService;
|
||||
|
||||
/**
|
||||
* The Class DomainServiceContextFunction add the Domain Service instance to global context.
|
||||
*/
|
||||
public class DomainServiceContextFunction 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) {
|
||||
IDomainService domainService = ContextInjectionFactory.make(DomainServiceProvider.class, context);
|
||||
MApplication application = context.get(MApplication.class);
|
||||
IEclipseContext applicationContext = application.getContext();
|
||||
applicationContext.set(IDomainService.class, domainService);
|
||||
return domainService;
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package flintstones.model.domain.provider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.DomainMockup;
|
||||
import flintstones.helper.extensionpoint.BaseRegistry;
|
||||
import flintstones.helper.extensionpoint.ExtensionRegistry;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* The Class DomainServiceProvider implements {@link flintstones.domain.service.IDomainService}.
|
||||
*/
|
||||
class DomainServiceProvider implements IDomainService{
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private BaseRegistry domainReg;
|
||||
private BaseRegistry domainCategoryReg;
|
||||
|
||||
/** The domain list. */
|
||||
private final LinkedHashMap<String, Domain> domains = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Instantiates a new domain service provider.
|
||||
*/
|
||||
public DomainServiceProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
@PostConstruct
|
||||
private void initialize() {
|
||||
domainReg = new BaseRegistry(Domain.EXTENSION_POINT);
|
||||
domainCategoryReg = new BaseRegistry(Domain.EXTENSION_POINT_CATEGORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain create(String id) {
|
||||
Domain domain = (Domain) domainReg.instantiate(id, context);
|
||||
domain.setType(id);
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Domain d) {
|
||||
if(domains.get(d.getId()) != null)
|
||||
throw new RuntimeException("Element already existed domainService.add("+ d.getName()+ ")");
|
||||
|
||||
d.updateId();
|
||||
domains.put(d.getId(), d);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.domain.service.IDomainService#getAll() */
|
||||
@Override
|
||||
public Domain[] getAll() {
|
||||
return domains.values().toArray(new Domain[domains.values().size()]);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Domain[] getAll(String type) {
|
||||
List<Domain> domainsType = new ArrayList<>();
|
||||
|
||||
Domain[] domains = this.domains.values().toArray(new Domain[this.domains.values().size()]);
|
||||
for(Domain domain: domains) {
|
||||
if(domain.getType().equals(type))
|
||||
domainsType.add(domain);
|
||||
}
|
||||
|
||||
return domainsType.toArray(new Domain[domainsType.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.domain.service.IDomainService#getById(java.lang.String) */
|
||||
@Override
|
||||
public Domain getByName(String name) {
|
||||
for(String id: domains.keySet()) {
|
||||
if(domains.get(id).getName().equals(name))
|
||||
return domains.get(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain getById(String id) {
|
||||
return domains.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain removeDomain(String id) {
|
||||
Domain d = domains.remove(id);
|
||||
return d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
domains.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Domain d : domains.values())
|
||||
sb.append(d.getName() + " ==> " + d.toString() + "\n");
|
||||
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainMockup[] getMockupDomains() {
|
||||
|
||||
ArrayList<DomainMockup> mockups = new ArrayList<>();
|
||||
ExtensionRegistry[] categories = domainCategoryReg.getAllRegistries();
|
||||
|
||||
for(ExtensionRegistry categoryReg : categories) {
|
||||
|
||||
String categoryId = categoryReg.getAttribute("uid");
|
||||
String categoryLabel = categoryReg.getAttribute("label");
|
||||
|
||||
DomainMockup parentMockup = new DomainMockup(categoryLabel);
|
||||
mockups.add(parentMockup);
|
||||
|
||||
ExtensionRegistry[] domainErs = domainReg.getAllRegistriesWhere(Domain.Fields.category, categoryId);
|
||||
for(ExtensionRegistry domainEr : domainErs ) {
|
||||
String domainId = domainEr.getAttribute(Domain.Fields.uid);
|
||||
String domainLabel = domainEr.getAttribute(Domain.Fields.label);
|
||||
DomainMockup mockup = new DomainMockup(domainId, domainLabel, categoryLabel);
|
||||
parentMockup.addDomain(mockup);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mockups.toArray(new DomainMockup[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String id) {
|
||||
return domains.get(id) != null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user