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.ui.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.ui.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>1779484362722</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,18 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Provider
|
||||
Bundle-SymbolicName: flintstones.model.domain.ui.provider
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.model.domain.ui.provider
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.model.domain.ui.service,
|
||||
flintstones.helper.extensionpoint,
|
||||
flintstones.entity.domain.ui,
|
||||
flintstones.entity.domain.ui.chart,
|
||||
flintstones.entity.domain,
|
||||
flintstones.entity.domain.ui.dialog,
|
||||
org.eclipse.jface,
|
||||
org.eclipse.e4.ui.model.workbench,
|
||||
javax.inject
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: component.xml
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
component.xml
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DomainUIService context function">
|
||||
<implementation class="flintstones.model.domain.ui.provider.DomainUIServiceContextFunction" />
|
||||
<property name="service.context.key" type="String" value="flintstones.model.domain.ui.service.IDomainUIService" />
|
||||
<service>
|
||||
<provide interface="org.eclipse.e4.core.contexts.IContextFunction" />
|
||||
</service>
|
||||
|
||||
</scr:component>
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package flintstones.model.domain.ui.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.ui.service.IDomainUIService;
|
||||
/**
|
||||
* The Class DomainServiceContextFunction add the Domain Service instance to global context.
|
||||
*/
|
||||
public class DomainUIServiceContextFunction 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) {
|
||||
IDomainUIService domainService = ContextInjectionFactory.make(DomainUIServiceProvider.class, context);
|
||||
MApplication application = context.get(MApplication.class);
|
||||
IEclipseContext applicationContext = application.getContext();
|
||||
applicationContext.set(IDomainUIService.class, domainService);
|
||||
return domainService;
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package flintstones.model.domain.ui.provider;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.ui.DomainUI;
|
||||
import flintstones.entity.domain.ui.chart.DomainChart;
|
||||
import flintstones.entity.domain.ui.dialog.DomainDialog;
|
||||
import flintstones.helper.extensionpoint.BaseRegistry;
|
||||
import flintstones.helper.extensionpoint.ExtensionRegistry;
|
||||
import flintstones.model.domain.ui.service.IDomainUIService;
|
||||
|
||||
/**
|
||||
* The Class DomainUIServiceProvider.
|
||||
*
|
||||
* @author Sinbad 2
|
||||
* Service provided for Domain UI ( create domain, modify domain and domain chart )
|
||||
*/
|
||||
class DomainUIServiceProvider implements IDomainUIService {
|
||||
|
||||
/** The chart extension point. */
|
||||
private final String CHART_EXTENSION_POINT = "flintstones.domain.ui.chart.extensionpoint"; //$NON-NLS-1$
|
||||
|
||||
/** The new domain dialog extension point. */
|
||||
private final String NEW_DOMAIN_DIALOG_EXTENSION_POINT = "flintstones.domain.ui.new.dialog.extensionpoint"; //$NON-NLS-1$
|
||||
|
||||
/** The modify domain dialog extension point. */
|
||||
private final String MODIFY_DOMAIN_DIALOG_EXTENSION_POINT = "flintstones.domain.ui.modify.dialog.extensionpoint"; //$NON-NLS-1$
|
||||
|
||||
/** The chart registry. */
|
||||
private final BaseRegistry chartReg;
|
||||
|
||||
/** The new domain dialog registry. */
|
||||
private final BaseRegistry newReg;
|
||||
|
||||
/** The modify domain dialog registry. */
|
||||
private final BaseRegistry modReg;
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private enum registries {
|
||||
newdialog, modifydialog, chart
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new domain UI service provider.
|
||||
*/
|
||||
public DomainUIServiceProvider() {
|
||||
this.chartReg = new BaseRegistry(this.CHART_EXTENSION_POINT);
|
||||
this.chartReg.setLabel_implementation(DomainUI.Fields.chart);
|
||||
this.newReg = new BaseRegistry(this.NEW_DOMAIN_DIALOG_EXTENSION_POINT);
|
||||
this.modReg = new BaseRegistry(this.MODIFY_DOMAIN_DIALOG_EXTENSION_POINT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.domain.ui.service.IDomainUIService#getDescriptionNewDomainDialog(
|
||||
* java.lang.String) */
|
||||
@Override
|
||||
public String getDescriptionNewDomainDialog(String id) {
|
||||
ExtensionRegistry registry = this.newReg.getFirstRegistryWhere(DomainUI.Fields.uid, id);
|
||||
return registry.getAttribute(DomainUI.Fields.description);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.domain.ui.service.IDomainUIService#newDomainDialog(flintstones.
|
||||
* domain.Domain, java.lang.String) */
|
||||
@Override
|
||||
public DomainDialog newDomainDialog(Domain domain, String id) {
|
||||
DomainDialog result = (DomainDialog) this.newReg.instantiate(id, this.context);
|
||||
result.setDomainTop(domain);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.domain.ui.service.IDomainUIService#modifyDomainDialog(flintstones
|
||||
* .domain.Domain, java.lang.String) */
|
||||
@Override
|
||||
public DomainDialog modifyDomainDialog(Domain domain) {
|
||||
|
||||
|
||||
String dialogId = getModifyDomainDialogId(domain.getType());
|
||||
ExtensionRegistry er = modReg.getFirstRegistryWhere(DomainUI.Fields.uid,dialogId);
|
||||
if(er == null)
|
||||
return null;
|
||||
|
||||
DomainDialog result = (DomainDialog) this.modReg.instantiate(dialogId, this.context);
|
||||
result.setDomainTop(domain);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.domain.ui.service.IDomainUIService#getExtensionIdsForDomain(java.
|
||||
* lang.String) */
|
||||
@Override
|
||||
public String[] getExtensionIdsForDomain(String domain, String part) {
|
||||
BaseRegistry reg = getBaseRegistry(part);
|
||||
return reg.getAllAttributesWhere(DomainUI.Fields.domain, domain, DomainUI.Fields.uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the requested base registry.
|
||||
*
|
||||
* @param part the part "chart","modify","new"
|
||||
* @return the base registry
|
||||
*/
|
||||
private BaseRegistry getBaseRegistry(String part) {
|
||||
|
||||
// Compat. fix
|
||||
if (part.equals("new")) //$NON-NLS-1$
|
||||
part = "newdialog"; //$NON-NLS-1$
|
||||
else if (part.equals("modify")) //$NON-NLS-1$
|
||||
part = "modifydialog"; //$NON-NLS-1$
|
||||
|
||||
if (part.equals(registries.chart.toString()))
|
||||
return this.chartReg;
|
||||
else if (part.equals(registries.newdialog.toString()))
|
||||
return this.newReg;
|
||||
else if (part.equals(registries.modifydialog.toString()))
|
||||
return this.modReg;
|
||||
else
|
||||
throw new InvalidParameterException("Part no valida " + part); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private String getExtensionNameForDomain(String domain, String part) {
|
||||
BaseRegistry reg = this.getBaseRegistry(part);
|
||||
ExtensionRegistry e = reg.getFirstRegistryWhere(DomainUI.Fields.domain, domain);
|
||||
|
||||
if(e == null)
|
||||
return null;
|
||||
|
||||
return e.getAttribute(DomainUI.Fields.uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainChart createChart(String domainId) {
|
||||
String chartId = getExtensionNameForDomain(domainId, "chart");
|
||||
|
||||
// Support for chart-less domains
|
||||
ExtensionRegistry reg = chartReg.getFirstRegistryWhere(DomainUI.Fields.uid, chartId);
|
||||
if(reg == null)
|
||||
return null;
|
||||
|
||||
if( reg.getAttribute("chart") == null )
|
||||
return null;
|
||||
|
||||
DomainChart result = (DomainChart) chartReg.instantiate(chartId, this.context);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModifyDomainDialogId(String domainType) {
|
||||
String[] dialogIds = getExtensionIdsForDomain(domainType,"modify");
|
||||
String dialogId = dialogIds[0];
|
||||
return dialogId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user