]>
git.argeo.org Git - gpl/argeo-jcr.git/blob - org.argeo.cms.jcr.ui/src/org/argeo/cms/e4/maintenance/AbstractOsgiComposite.java
1 package org
.argeo
.cms
.e4
.maintenance
;
3 import java
.util
.Collection
;
5 import org
.argeo
.api
.cms
.CmsLog
;
6 import org
.argeo
.cms
.swt
.CmsSwtUtils
;
7 import org
.eclipse
.swt
.SWT
;
8 import org
.eclipse
.swt
.layout
.GridData
;
9 import org
.eclipse
.swt
.widgets
.Composite
;
10 import org
.osgi
.framework
.BundleContext
;
11 import org
.osgi
.framework
.FrameworkUtil
;
12 import org
.osgi
.framework
.InvalidSyntaxException
;
13 import org
.osgi
.framework
.ServiceReference
;
15 abstract class AbstractOsgiComposite
extends Composite
{
16 private static final long serialVersionUID
= -4097415973477517137L;
17 protected final BundleContext bc
= FrameworkUtil
.getBundle(getClass()).getBundleContext();
18 protected final CmsLog log
= CmsLog
.getLog(getClass());
20 public AbstractOsgiComposite(Composite parent
, int style
) {
22 parent
.setLayout(CmsSwtUtils
.noSpaceGridLayout());
23 setLayout(CmsSwtUtils
.noSpaceGridLayout());
24 setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
28 protected abstract void initUi(int style
);
30 protected <T
> T
getService(Class
<?
extends T
> clazz
) {
31 return bc
.getService(bc
.getServiceReference(clazz
));
34 protected <T
> Collection
<ServiceReference
<T
>> getServiceReferences(Class
<T
> clazz
, String filter
) {
36 return bc
.getServiceReferences(clazz
, filter
);
37 } catch (InvalidSyntaxException e
) {
38 throw new IllegalArgumentException("Filter " + filter
+ " is invalid", e
);