Commit a7cd6c78 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Implement the service using an extension point

Issue-Ref: 4030
Issue-Url: https://af3-developer.fortiss.org/issues/4030

Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parent 75f9508c
......@@ -25,6 +25,7 @@ Export-Package: org.fortiss.af3.exploration.ui,
org.fortiss.af3.exploration.ui.menu,
org.fortiss.af3.exploration.ui.perspective,
org.fortiss.af3.exploration.ui.perspective.dashboard.projectwizard,
org.fortiss.af3.exploration.ui.perspective.extension,
org.fortiss.af3.exploration.ui.perspective.generic,
org.fortiss.af3.exploration.ui.perspective.navigator,
org.fortiss.af3.exploration.ui.perspective.process,
......
......@@ -3,6 +3,7 @@
<!-- (c) 2017 fortiss GmbH -->
<plugin>
<extension-point id="externalDSEExtensionProvider" name="External DSE Extension Provider" schema="schema/externalDSEExtensionProvider.exsd"/>
<!-- TODO(AD, #3669): Currently disabled in the UI. -->
<!--extension
point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.fortiss.af3.exploration.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.fortiss.af3.exploration.ui" id="externalDSEExtensionProvider" name="External DSE Extension Provider"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="externalDSEExtensionProvider" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="externalDSEExtensionProvider">
<complexType>
<sequence>
<element ref="externalDSEExtensionProvider" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="externalDSEExtensionProvider" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.ui.perspective.extension.IExternalDSEExtensionProvider"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
IExternalDSEExtensionProvider.java 85871542b13d45760c58811ed1a830fc73176d55 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.extension;
import java.util.List;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.tooling.kernel.service.base.IObjectAware;
/**
* Interface for the providers of external DSE extensions.
* Instances are handled by the {@link IExternalDSEExtensionService}.
*
* @author munaro
*/
public interface IExternalDSEExtensionProvider extends IObjectAware<Object> {
/** Returns the constraint patterns to add. */
List<PatternFXControllerBase> getConstraintPatterns();
/** Returns the objective patterns to add. */
List<PatternFXControllerBase> getObjectivePatterns();
}
DSEPerspectiveManager.java ad2b28bf6bb8414eda0b1606c53befb8ef731a3a GREEN
EventBroker.java 5614a199ffe288807a29cf9c213787f52c3555e8 GREEN
ExternalDSEExtensionService.java 1f70e2b21f7f898dff39f8be6444adba26e043fc YELLOW
ExternalDSEExtensionService.java ed03ba0980c15dd10bc696687f3a1b2e32e36c87 YELLOW
IDSEPerspectiveManager.java 2bc063e88352828ca0d3264730670694dbee76e4 GREEN
IEventListener.java 6d7eb240719a7d7ef0a2619c2fc72a22109c2786 GREEN
IExternalDSEExtensionService.java 7fed5771345d2b7510d5bb509240db0a39e99254 YELLOW
IExternalDSEExtensionService.java f7a7b36329b112a1236752cf7f8f23ebf0f04818 YELLOW
......@@ -16,16 +16,24 @@
package org.fortiss.af3.exploration.ui.perspective.service;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getBundle;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getConfigurationElements;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.loadClass;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.fortiss.af3.exploration.ui.perspective.extension.IExternalDSEExtensionProvider;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.osgi.framework.Bundle;
/**
* Singleton implementation of {@link IExternalDSEExtensionService}.
......@@ -58,6 +66,16 @@ public class ExternalDSEExtensionService
return INSTANCE;
}
/** The connector extension point ID. */
private static final String EXTENSION_POINT_NAME =
"org.fortiss.af3.exploration.ui.externalDSEExtensionProvider";
/** The connector configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "externalDSEExtensionProvider";
/** The connector attribute name. */
private static final String ATTRIBUTE_NAME = "externalDSEExtensionProvider";
/** {@inheritDoc} */
@Override
public void startService() {
......@@ -67,19 +85,21 @@ public class ExternalDSEExtensionService
/** {@inheritDoc} */
@Override
public void initializeService() {
// Nothing to do
}
for(IConfigurationElement ce : getConfigurationElements(EXTENSION_POINT_NAME,
CONFIGURATION_ELEMENT_NAME)) {
Bundle bundle = getBundle(ce);
try {
Class<?> handlerClass = loadClass(ce.getAttribute(ATTRIBUTE_NAME), bundle);
IExternalDSEExtensionProvider provider =
(IExternalDSEExtensionProvider)handlerClass.getConstructor().newInstance();
registeredConstraintPatterns.addAll(provider.getConstraintPatterns());
registeredObjectivePatterns.addAll(provider.getObjectivePatterns());
} catch(Exception ex) {
error(ToolingKernelActivator.getDefault(), ex.getMessage(), ex);
}
/** {@inheritDoc} */
@Override
public void registerConstraintPattern(PatternFXControllerBase pattern) {
registeredConstraintPatterns.add(pattern);
}
/** {@inheritDoc} */
@Override
public void registerObjectivePattern(PatternFXControllerBase pattern) {
registeredObjectivePatterns.add(pattern);
}
}
/** {@inheritDoc} */
......
......@@ -38,22 +38,6 @@ public interface IExternalDSEExtensionService {
/** Initializes the service. */
public void initializeService();
/**
* Adds a new section to the constraint view.
*
* @param pattern
* Controller of the pattern to be included
*/
public void registerConstraintPattern(PatternFXControllerBase pattern);
/**
* Adds a new section to the objective view.
*
* @param pattern
* Controller of the pattern to be included
*/
public void registerObjectivePattern(PatternFXControllerBase pattern);
/** Returns all registered constraint patterns. */
public List<PatternFXControllerBase> getConstraintPatterns();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment