1 package org
.argeo
.cms
.swt
.widgets
;
3 import org
.argeo
.cms
.swt
.CmsSwtUtils
;
4 import org
.argeo
.cms
.ux
.widgets
.DataPart
;
5 import org
.argeo
.cms
.ux
.widgets
.DataView
;
6 import org
.eclipse
.swt
.events
.SelectionEvent
;
7 import org
.eclipse
.swt
.events
.SelectionListener
;
8 import org
.eclipse
.swt
.widgets
.Composite
;
10 public abstract class AbstractSwtPart
<INPUT
, TYPE
> extends Composite
implements DataView
<INPUT
, TYPE
> {
11 private static final long serialVersionUID
= -1999179054267812170L;
13 protected DataPart
<INPUT
, TYPE
> dataPart
;
15 protected final SelectionListener selectionListener
;
17 public AbstractSwtPart(Composite parent
, int style
, DataPart
<INPUT
, TYPE
> dataPart
) {
19 setLayout(CmsSwtUtils
.noSpaceGridLayout());
21 this.dataPart
= dataPart
;
23 selectionListener
= new SelectionListener() {
25 private static final long serialVersionUID
= 4334785560035009330L;
28 public void widgetSelected(SelectionEvent e
) {
29 if (dataPart
.getOnSelected() != null)
30 dataPart
.getOnSelected().accept((TYPE
) e
.item
.getData());
34 public void widgetDefaultSelected(SelectionEvent e
) {
35 if (dataPart
.getOnAction() != null)
36 dataPart
.getOnAction().accept((TYPE
) e
.item
.getData());
40 dataPart
.addView(this);
41 addDisposeListener((e
) -> dataPart
.removeView(this));
44 public abstract void refresh();