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.phase.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.phase.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>1779484362724</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>
|
||||
+2
@@ -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.method.phase.provider
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.model.method.phase.provider
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.eclipse.e4.core.contexts,
|
||||
javax.inject,
|
||||
flintstones.helper.extensionpoint,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.model.method.phase.service,
|
||||
org.eclipse.e4.ui.model.workbench,
|
||||
flintstones.entity.method.phase.ui,
|
||||
javax.annotation,
|
||||
org.eclipse.e4.core.services
|
||||
Service-Component: component.xml
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Import-Package: org.osgi.service.event
|
||||
@@ -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="PhaseMethod context function">
|
||||
<implementation class="flintstones.model.method.phase.provider.PhaseMethodServiceContextFunction" />
|
||||
<property name="service.context.key" type="String" value="flintstones.model.method.phase.IPhaseMethodService" />
|
||||
<service>
|
||||
<provide interface="org.eclipse.e4.core.contexts.IContextFunction" />
|
||||
</service>
|
||||
</scr:component>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package flintstones.model.method.phase.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.method.phase.IPhaseMethodService;
|
||||
|
||||
/**
|
||||
* The Class PhaseMethodServiceContextFunction add the PhaseMethod Service instance to global context.
|
||||
*/
|
||||
public class PhaseMethodServiceContextFunction extends ContextFunction {
|
||||
|
||||
@Override
|
||||
public Object compute(IEclipseContext context, String contextKey) {
|
||||
IPhaseMethodService service = ContextInjectionFactory.make(PhaseMethodServiceProvider.class, context);
|
||||
MApplication application = context.get(MApplication.class);
|
||||
IEclipseContext applicationContext = application.getContext();
|
||||
applicationContext.set(IPhaseMethodService.class, service);
|
||||
return service;
|
||||
}
|
||||
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package flintstones.model.method.phase.provider;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.helper.extensionpoint.BaseRegistry;
|
||||
import flintstones.model.method.phase.IPhaseMethodService;
|
||||
|
||||
/**
|
||||
* The Class PhaseMethodServiceProvider.
|
||||
*/
|
||||
class PhaseMethodServiceProvider implements IPhaseMethodService {
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IEventBroker broker;
|
||||
|
||||
/** The reg. */
|
||||
private BaseRegistry reg;
|
||||
private BaseRegistry uireg;
|
||||
|
||||
/** The PhaseMethod list. */
|
||||
private final LinkedHashMap<String, PhaseMethodUI> phases = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Instantiates a new phasemethod service provider.
|
||||
*/
|
||||
@Inject
|
||||
public PhaseMethodServiceProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
this.reg = new BaseRegistry(PhaseMethod.EXTENSION_POINT);
|
||||
this.uireg = new BaseRegistry(PhaseMethodUI.EXTENSION_POINT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.phasemethod.service.IPhaseMethodService#getAll()
|
||||
*/
|
||||
@Override
|
||||
public PhaseMethodUI[] getAll() {
|
||||
return this.phases.values().toArray(new PhaseMethodUI[this.phases.values().size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhaseMethodUI[] createPhases(String[] phasesId) {
|
||||
|
||||
// Unsuscribe from event broker so garbage collector can remove the class from memory
|
||||
phases.values() //
|
||||
.stream() //
|
||||
.filter(k -> k instanceof EventHandler ) //
|
||||
.forEach(k -> broker.unsubscribe((EventHandler)k));
|
||||
|
||||
phases.clear();
|
||||
|
||||
PhaseMethodUI[] phasesUI = new PhaseMethodUI[phasesId.length];
|
||||
PhaseMethod phase = null;
|
||||
int x = 0;
|
||||
for (String phaseId : phasesId) {
|
||||
// Create the Phase
|
||||
PhaseMethodUI phaseUI = createPhase(phaseId);
|
||||
phasesUI[x++] = phaseUI;
|
||||
|
||||
phases.put(phaseId, phaseUI);
|
||||
|
||||
// Link phases models
|
||||
if( phase != null )
|
||||
phaseUI.getModel().setPreviousPhase(phase);
|
||||
phase = phaseUI.getModel();
|
||||
|
||||
}
|
||||
|
||||
return phasesUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhaseMethodUI get(String id) {
|
||||
return phases.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Entry<String, PhaseMethodUI> entry : this.phases.entrySet()) {
|
||||
sb.append(entry.getKey() + " ==> " + entry.getValue().getModel().getName() + " | "
|
||||
+ entry.getValue().toString() + "\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.phases.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhaseMethodUI createPhase(String phaseId) {
|
||||
|
||||
// Create the model
|
||||
PhaseMethod phase = (PhaseMethod) this.reg.instantiate(phaseId, this.context);
|
||||
phase.setId(phaseId);
|
||||
phase.setPosition(phases.size());
|
||||
|
||||
// Create the Phase UI
|
||||
String phaseUiId = getIdFor(phase.getId());
|
||||
PhaseMethodUI phaseui = (PhaseMethodUI) this.uireg.instantiate(phaseUiId, this.context);
|
||||
phaseui.setModel(phase);
|
||||
|
||||
return phaseui;
|
||||
}
|
||||
|
||||
private String getIdFor(String phaseId) {
|
||||
String[] matches = this.uireg.getAllAttributesWhere(PhaseMethodUI.Fields.phasemethod, phaseId,
|
||||
PhaseMethodUI.Fields.uid);
|
||||
if (matches.length != 1)
|
||||
throw new Error("Encontrados " + matches.length + " " + phaseId + " (Debe ser 1) --> "
|
||||
+ this.uireg.getRegistryId());
|
||||
return this.uireg.getAllAttributesWhere(PhaseMethodUI.Fields.phasemethod, phaseId, PhaseMethodUI.Fields.uid)[0];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user