implementation and generalization of a form framework to be used in the tabbed proper...
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / forms / entitysections / RightsSection.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.forms.entitysections;
5
6 import org.eclipse.jface.action.Action;
7 import org.eclipse.jface.action.IAction;
8 import org.eclipse.swt.events.SelectionAdapter;
9 import org.eclipse.swt.events.SelectionEvent;
10 import org.eclipse.swt.widgets.Composite;
11
12 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
13 import eu.etaxonomy.cdm.model.media.Rights;
14
15 /**
16 * @author nho
17 *
18 */
19 public class RightsSection extends AbstractEntitySetSection<IdentifiableEntity> {
20
21 /**
22 * @param parent
23 * @param entity
24 * @param style
25 */
26 protected RightsSection(Composite parent, IdentifiableEntity entity,
27 int style) {
28 super(parent, entity, style);
29 setText("Rights");
30 }
31
32 /* (non-Javadoc)
33 * @see eu.etaxonomy.taxeditor.forms.AbstractEntitySetSection#createDynamicContents()
34 */
35 @Override
36 protected void createDynamicContents() {
37 // TODO Auto-generated method stub
38
39 }
40
41 private class RemoveListener extends SelectionAdapter{
42 private Rights rights;
43
44 public RemoveListener(Rights rights){
45 this.rights = rights;
46 }
47
48 /* (non-Javadoc)
49 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
50 */
51 @Override
52 public void widgetSelected(SelectionEvent e) {
53 getEntity().removeRights(rights);
54 internalUpdateSection(true);
55 }
56 }
57
58 /* (non-Javadoc)
59 * @see eu.etaxonomy.taxeditor.forms.AbstractEntitySetSection#getAddAction()
60 */
61 @Override
62 protected IAction getAddAction() {
63 Action addRights = new Action("add", Action.AS_PUSH_BUTTON){
64 /* (non-Javadoc)
65 * @see org.eclipse.jface.action.Action#run()
66 */
67 @Override
68 public void run() {
69 Rights rights = Rights.NewInstance();
70 getEntity().addRights(rights);
71 internalUpdateSection(true);
72 if(! getSection().isExpanded())
73 getSection().setExpanded(true);
74 internalUpdateSection(true);
75 }
76 };
77 addRights.setToolTipText("Create a new marker");
78 return addRights;
79 }
80
81 }