Skip to content

Commit ed47024

Browse files
committed
Add component property types for IModelProcessorContribution attributes
These annotation simplify the specification of the 'beforefragment' and 'apply' service property for IModelProcessorContribution implementations and makes it type-safe and more robust: ''' @component(service = IModelProcessorContribution.class) @IModelProcessorContribution.Beforefragment(true) @IModelProcessorContribution.Apply(IModelProcessorContribution.APPLY_ALWAYS) public class SampleContribution implements IModelProcessorContribution { '''
1 parent 2ebbbe9 commit ed47024

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-SymbolicName: org.eclipse.e4.ui.workbench;singleton:=true
4-
Bundle-Version: 1.15.600.qualifier
4+
Bundle-Version: 1.16.0.qualifier
55
Bundle-Name: %pluginName
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/IModelProcessorContribution.java

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
package org.eclipse.e4.ui.workbench.modeling;
1616

17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Target;
1719
import java.util.Collections;
1820
import java.util.List;
21+
import org.osgi.service.component.annotations.ComponentPropertyType;
1922

2023
/**
2124
* Service component interface to be able to register model processors via OSGi
@@ -32,7 +35,7 @@ public interface IModelProcessorContribution {
3235
/**
3336
* Service property key for specifying the beforeFragment attribute, which
3437
* specifies if the processor has to be invoked before model fragments are
35-
* added. If not specified it defaults to <code>true</code>.
38+
* added. If not specified it defaults to {@code true}.
3639
*/
3740
String BEFORE_FRAGMENT_PROPERTY_KEY = "beforefragment"; //$NON-NLS-1$
3841
/**
@@ -44,11 +47,33 @@ public interface IModelProcessorContribution {
4447
* Component annotation:<br>
4548
* <code>@Component(property = { IModelProcessorContribution.BEFORE_FRAGMENT_PROPERTY_PREFIX + "false" })</code>
4649
* </p>
50+
*
51+
* @deprecated Instead annotate the component with the
52+
* {@link Beforefragment @Beforefragment(true|false)} component
53+
* property type
4754
*/
55+
@Deprecated(forRemoval = true, since = "1.16")
4856
String BEFORE_FRAGMENT_PROPERTY_PREFIX = "beforefragment:Boolean="; //$NON-NLS-1$
57+
58+
/**
59+
* An OSGi service component property type used to specify the value of the
60+
* {@code beforeFragment} attribute , which specifies if the processor has to be
61+
* invoked before model fragments are added. If not specified it defaults to
62+
* {@code true}.
63+
*
64+
* @since 1.16
65+
* @see #BEFORE_FRAGMENT_PROPERTY_KEY
66+
*/
67+
@ComponentPropertyType
68+
@Target(ElementType.TYPE)
69+
@interface Beforefragment {
70+
boolean value() default true;
71+
}
72+
4973
/**
5074
* Service property key for specifying the apply attribute, which defines in
51-
* which case a processor is run. If not specified it defaults to <i>always</i>.
75+
* which case a processor is run. If not specified it defaults to
76+
* {@code always}.
5277
*/
5378
String APPLY_PROPERTY_KEY = "apply"; //$NON-NLS-1$
5479
/**
@@ -59,8 +84,30 @@ public interface IModelProcessorContribution {
5984
* Component annotation:<br>
6085
* <code>@Component(property = { IModelProcessorContribution.APPLY_PROPERTY_PREFIX + "initial" })</code>
6186
* </p>
87+
*
88+
* @deprecated Instead annotate the component with the {@link Apply @Apply(&lt
89+
* a-value &gt)} component property type
6290
*/
91+
@Deprecated(forRemoval = true, since = "1.16")
6392
String APPLY_PROPERTY_PREFIX = "apply="; //$NON-NLS-1$
93+
94+
/**
95+
* An OSGi service component property type used to specify the {@code apply}
96+
* attribute, which defines in which case a processor is run. If not specified
97+
* it defaults to {@code always}.
98+
*
99+
* @since 1.16
100+
* @see #APPLY_PROPERTY_KEY
101+
* @see #APPLY_ALWAYS
102+
* @see #APPLY_INITIAL
103+
*
104+
*/
105+
@ComponentPropertyType
106+
@Target(ElementType.TYPE)
107+
@interface Apply {
108+
String value() default APPLY_ALWAYS;
109+
}
110+
64111
/**
65112
* Value for the <code>apply</code> attribute. If set the processor is executed
66113
* each time the application is started.

0 commit comments

Comments
 (0)