Project

General

Profile

Revision 6ba01b22

ID6ba01b22eb1d7637f3df0d50e504132325bfd151
Parent 1c621bae
Child 72eff2a6

Added by Patrick Plitzner over 1 year ago

ref #6746 Add details view for feature tree and feature node

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.featuretree.e4;
11 11

  
12
import java.util.ArrayList;
13 12
import java.util.Arrays;
14 13
import java.util.HashMap;
15 14
import java.util.List;
......
20 19
import javax.inject.Inject;
21 20

  
22 21
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.NullProgressMonitor;
24 22
import org.eclipse.e4.ui.di.Focus;
25 23
import org.eclipse.e4.ui.di.Persist;
26 24
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
......
28 26
import org.eclipse.e4.ui.services.EMenuService;
29 27
import org.eclipse.e4.ui.workbench.modeling.EPartService;
30 28
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
31
import org.eclipse.jface.dialogs.IDialogConstants;
32
import org.eclipse.jface.dialogs.MessageDialog;
33 29
import org.eclipse.jface.viewers.ISelectionChangedListener;
34 30
import org.eclipse.jface.viewers.IStructuredSelection;
35 31
import org.eclipse.jface.viewers.SelectionChangedEvent;
36 32
import org.eclipse.jface.viewers.TreeViewer;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.events.ModifyEvent;
39
import org.eclipse.swt.events.ModifyListener;
40
import org.eclipse.swt.events.SelectionAdapter;
41
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.dnd.DND;
34
import org.eclipse.swt.dnd.Transfer;
35
import org.eclipse.swt.layout.FillLayout;
42 36
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Text;
44 37
import org.eclipse.ui.IMemento;
45 38

  
46 39
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
......
49 42
import eu.etaxonomy.cdm.model.description.FeatureNode;
50 43
import eu.etaxonomy.cdm.model.description.FeatureTree;
51 44
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
45
import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
46
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
47
import eu.etaxonomy.taxeditor.featuretree.FeatureTreeContentProvider;
48
import eu.etaxonomy.taxeditor.featuretree.FeatureTreeLabelProvider;
52 49
import eu.etaxonomy.taxeditor.model.AbstractUtility;
53 50
import eu.etaxonomy.taxeditor.model.IContextListener;
51
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
54 52
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
55 53
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
56 54
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
57 55
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
58 56
import eu.etaxonomy.taxeditor.store.CdmStore;
59
import eu.etaxonomy.taxeditor.ui.dialog.selection.FeatureTreeSelectionDialog;
60 57
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
61 58
import eu.etaxonomy.taxeditor.workbench.part.IE4ViewerPart;
62 59

  
......
66 63
 * @date 06.06.2017
67 64
 *
68 65
 */
69
public class FeatureTreeEditor implements ICdmEntitySessionEnabled, ModifyListener, ISelectionChangedListener,
70
        IE4ViewerPart, IE4SavablePart, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, IConversationEnabled {
66
public class FeatureTreeEditor implements ICdmEntitySessionEnabled, ISelectionChangedListener,
67
        IE4ViewerPart, IE4SavablePart, IPartContentHasDetails, IPartContentHasSupplementalData,
68
        IContextListener, IConversationEnabled, IDirtyMarkable {
71 69

  
72 70
    private ConversationHolder conversation;
73 71

  
......
79 77
    @Inject
80 78
    private MDirtyable dirty;
81 79

  
82
    private FeatureTreeEditorComposite composite;
80
//    private FeatureTreeEditorComposite composite;
83 81

  
84 82
    @Inject
85 83
    private MPart thisPart;
86 84

  
85
    private TreeViewer viewer;
86

  
87 87
    @Inject
88 88
    public FeatureTreeEditor() {
89 89
        CdmStore.getContextManager().addContextListener(this);
......
98 98
        else{
99 99
            return;
100 100
        }
101
        composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
102
        composite.init(new FeatureNodeDragListener(composite.getViewer()),
103
                new FeatureNodeDropAdapter(dirty, composite.getViewer()), this, new SelectionAdapter() {
104
            @Override
105
            public void widgetSelected(SelectionEvent e) {
106
                if(isDirty()){
107
                    MessageDialog dialog;
108
                    String[] buttonLables = {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
109
                    dialog = new MessageDialog(null, "Unsaved changes", null, "You have unsaved changes. Do you want to save?",
110
                            MessageDialog.QUESTION_WITH_CANCEL, 0, buttonLables);
111
                    int returnCode = dialog.open();
112

  
113
                    if (returnCode == 0){
114
                        //YES
115
                        save(new NullProgressMonitor());
116
                    } else if (returnCode == 1){
117
                        //NO
118
                        if(CdmStore.isActive()){
119
                            clearSession();
120
                            initSession();
121
                            composite.setSelectedTree(null);
122
                        }
123
                    } else if (returnCode == 2){
124
                        //CANCEL
125
                        return;
126
                    }
127
                }
128
                FeatureTree tree = FeatureTreeSelectionDialog.select(composite.getDisplay().getActiveShell(), //conversation,
129
                        null);
130
                if (tree != null) {
131
                    composite.setSelectedTree(tree);
132
                }
133
            }
134
        }, this);
101
        parent.setLayout(new FillLayout());
102
        viewer = new TreeViewer(parent);
103
        viewer.setContentProvider(new FeatureTreeContentProvider());
104
        viewer.setLabelProvider(new FeatureTreeLabelProvider());
105

  
106
        int ops = DND.DROP_COPY | DND.DROP_MOVE;
107
        Transfer[] transfers = new Transfer[] { FeatureNodeTransfer
108
                .getInstance(), TermTransfer.getInstance() };
109
        viewer.addDragSupport(ops, transfers, new FeatureNodeDragListener(viewer));
110
        viewer.addDropSupport(ops, transfers, new FeatureNodeDropAdapter(dirty, viewer));
111
        viewer.addSelectionChangedListener(this);
112

  
113
        List<FeatureTree> trees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
114
        viewer.setInput(trees);
115

  
116
//        composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
117
//        composite.init(new FeatureNodeDragListener(composite.getViewer()),
118
//                new FeatureNodeDropAdapter(dirty, composite.getViewer()), this, new SelectionAdapter() {
119
//            @Override
120
//            public void widgetSelected(SelectionEvent e) {
121
//                if(isDirty()){
122
//                    MessageDialog dialog;
123
//                    String[] buttonLables = {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
124
//                    dialog = new MessageDialog(null, "Unsaved changes", null, "You have unsaved changes. Do you want to save?",
125
//                            MessageDialog.QUESTION_WITH_CANCEL, 0, buttonLables);
126
//                    int returnCode = dialog.open();
127
//
128
//                    if (returnCode == 0){
129
//                        //YES
130
//                        save(new NullProgressMonitor());
131
//                    } else if (returnCode == 1){
132
//                        //NO
133
//                        if(CdmStore.isActive()){
134
//                            clearSession();
135
//                            initSession();
136
//                            composite.setSelectedTree(null);
137
//                        }
138
//                    } else if (returnCode == 2){
139
//                        //CANCEL
140
//                        return;
141
//                    }
142
//                }
143
//                FeatureTree tree = FeatureTreeSelectionDialog.select(composite.getDisplay().getActiveShell(), //conversation,
144
//                        null);
145
//                if (tree != null) {
146
//                    composite.setSelectedTree(tree);
147
//                }
148
//            }
149
//        }, this);
135 150

  
136 151
        //create context menu
137
        menuService.registerContextMenu(composite.getViewer().getControl(), "eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor");
152
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor");
138 153
    }
139 154

  
140 155
    private void initSession(){
......
166 181
	    return dirty.isDirty();
167 182
	}
168 183

  
169
    public FeatureTree getSelectedFeatureTree(){
170
        return composite.getFeatureTree();
171
    }
172

  
173
	/** {@inheritDoc} */
174
	@Override
175
	public void modifyText(ModifyEvent e) {
176
	    composite.getFeatureTree().setTitleCache(((Text) e.widget).getText(), true);
177
		setDirty(true);
178
	}
179

  
180 184
	/** {@inheritDoc} */
181 185
	@Override
182 186
	public void selectionChanged(SelectionChangedEvent event) {
......
186 190

  
187 191
	@Focus
188 192
	public void focus(){
189
	    if(composite!=null){
190
	        composite.getViewer().getControl().setFocus();
193
	    if(viewer!=null){
194
	        viewer.getControl().setFocus();
191 195
	    }
192 196
        if(conversation!=null && !conversation.isBound()){
193 197
            conversation.bind();
......
199 203

  
200 204
	@Override
201 205
    public void refresh(){
202
	    composite.getViewer().refresh();
206
	    viewer.refresh();
203 207
	}
204 208

  
205 209
	public TreeViewer getViewer(){
206
	    return composite.getViewer();
210
	    return viewer;
207 211
	}
208 212

  
209 213
	/**
......
211 215
	 */
212 216
	@Override
213 217
	public IStructuredSelection getSelection() {
214
	    return (IStructuredSelection) composite.getViewer().getSelection();
218
	    return (IStructuredSelection) viewer.getSelection();
215 219
	}
216 220

  
217 221
	/**
......
232 236
        // commit the conversation and start a new transaction immediately
233 237
        conversation.commit(true);
234 238

  
235
        CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(composite.getFeatureTree());
239
        List<FeatureTree> trees = (List<FeatureTree>) viewer.getInput();
240
        CdmStore.getService(IFeatureTreeService.class).merge(trees);
236 241

  
237 242
        this.setDirty(false);
238 243
	}
......
265 270
     */
266 271
    @Override
267 272
    public List<FeatureTree> getRootEntities() {
268
        List<FeatureTree> root = new ArrayList<>();
269
        root.add(composite.getFeatureTree());
270
        return root;
273
        return (List<FeatureTree>) viewer.getInput();
271 274
    }
272 275

  
273 276
    /**
......
319 322
    public void update(CdmDataChangeMap arg0) {
320 323
    }
321 324

  
325
    /**
326
     * {@inheritDoc}
327
     */
328
    @Override
329
    public void changed(Object element) {
330
        dirty.setDirty(true);
331
    }
332

  
333
    /**
334
     * {@inheritDoc}
335
     */
336
    @Override
337
    public void forceDirty() {
338
        dirty.setDirty(true);
339
    }
340

  
322 341
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddChildFeatureHandler.java
57 57
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
58 58
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection) {
59 59
        return thisPart.getObject() instanceof FeatureTreeEditor
60
                && ((FeatureTreeEditor) thisPart.getObject()).getSelectedFeatureTree()!=null
61 60
                && selection instanceof FeatureNode;
62 61
    }
63 62
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddFeatureHandler.java
54 54
    }
55 55

  
56 56
    @CanExecute
57
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart) {
58
        return thisPart.getObject() instanceof FeatureTreeEditor && ((FeatureTreeEditor) thisPart.getObject()).getSelectedFeatureTree()!=null;
57
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
58
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection) {
59
        return thisPart.getObject() instanceof FeatureTreeEditor
60
                && selection instanceof FeatureTree;
59 61
    }
60 62
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/FeatureTreeExportHandler.java
36 36

  
37 37
    @Execute
38 38
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
39
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
40
        FeatureTreeEditor editor = ((FeatureTreeEditor) thisPart.getObject());
41
        FeatureTree selectedFeatureTree = editor.getSelectedFeatureTree();
39
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
40
            @Named(IServiceConstants.ACTIVE_SELECTION)FeatureTree selection){
41
        FeatureTree selectedFeatureTree = selection;
42 42
        if(selectedFeatureTree==null){
43 43
            MessagingUtils.informationDialog("Export not possible", "There is no feature tree selected.");
44 44
            return;
......
57 57
    }
58 58

  
59 59
    @CanExecute
60
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
61
        return thisPart.getObject() instanceof FeatureTreeEditor && ((FeatureTreeEditor) thisPart.getObject()).getSelectedFeatureTree()!=null;
60
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
61
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection){
62
        return thisPart.getObject() instanceof FeatureTreeEditor && selection instanceof FeatureTree;
62 63
    }
63 64

  
64 65
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureHandler.java
19 19
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
20 20
import eu.etaxonomy.cdm.api.service.config.FeatureNodeDeletionConfigurator;
21 21
import eu.etaxonomy.cdm.model.description.FeatureNode;
22
import eu.etaxonomy.cdm.model.description.FeatureTree;
22 23
import eu.etaxonomy.taxeditor.store.CdmStore;
23 24
import eu.etaxonomy.taxeditor.workbench.part.IE4ViewerPart;
24 25

  
......
46 47
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
47 48
        if(thisPart.getObject() instanceof IE4ViewerPart){
48 49
            IE4ViewerPart viewerPart = (IE4ViewerPart)thisPart.getObject();
49
            return viewerPart.getSelection()!=null && !viewerPart.getSelection().isEmpty();
50
            return viewerPart.getSelection() instanceof FeatureTree;
50 51
        }
51 52
        return false;
52 53
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
179 179
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
180 180
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
181 181
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
182
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureNodeDetailElement;
183
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureNodeDetailSection;
184
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailElement;
185
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureTreeDetailSection;
186
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElement;
187
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSection;
188
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElement;
189
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSection;
182 190
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement;
183 191
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement;
184 192
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
......
1648 1656
        return element;
1649 1657
    }
1650 1658

  
1659
    public FeatureTreeDetailElement createFeatureTreeDetailElement(ICdmFormElement parentElement, int style){
1660
        FeatureTreeDetailElement element = new FeatureTreeDetailElement(this, parentElement);
1661
        addAndAdaptElement(parentElement, element);
1662
        return element;
1663
    }
1664

  
1665
    public FeatureNodeDetailElement createFeatureNodeDetailElement(ICdmFormElement parentElement, int style){
1666
        FeatureNodeDetailElement element = new FeatureNodeDetailElement(this, parentElement);
1667
        addAndAdaptElement(parentElement, element);
1668
        return element;
1669
    }
1670

  
1651 1671

  
1652 1672
    //--------DetailSections---------
1653 1673
    public NameDetailSection createNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
......
1656 1676
        return section;
1657 1677
    }
1658 1678

  
1679
    public FeatureNodeDetailSection createFeatureNodeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1680
        FeatureNodeDetailSection section = new FeatureNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1681
        addAndAdaptSection(parentElement, section);
1682
        return section;
1683
    }
1684

  
1685
    public FeatureTreeDetailSection createFeatureTreeDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1686
        FeatureTreeDetailSection section = new FeatureTreeDetailSection(this, conversation, parentElement, selectionProvider, style);
1687
        addAndAdaptSection(parentElement, section);
1688
        return section;
1689
    }
1690

  
1659 1691
    public ReferenceDetailSection createReferenceDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1660 1692
        ReferenceDetailSection section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1661 1693
        addAndAdaptSection(parentElement, section);
......
2338 2370
        return section;
2339 2371
    }
2340 2372

  
2373
    public InapplicableIfEntityCollectionSection createInapplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2374
        InapplicableIfEntityCollectionSection section = new InapplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2375
        addAndAdaptSection(parentElement, section);
2376
        return section;
2377
    }
2378

  
2379
    public OnlyApplicableIfEntityCollectionSection createOnlyApplicableIfEntityCollectionSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2380
        OnlyApplicableIfEntityCollectionSection section = new OnlyApplicableIfEntityCollectionSection(this, conversation, parentElement, style);
2381
        addAndAdaptSection(parentElement, section);
2382
        return section;
2383
    }
2384

  
2341 2385
    public AnnotationSection createAnnotationSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2342 2386
        AnnotationSection section = new AnnotationSection(this, conversation, parentElement, style);
2343 2387
        addAndAdaptSection(parentElement, section);
......
2753 2797
            element = new MeasurementUnitCollectionElement(this, parentElement, (MeasurementUnit) entity, removeListener, backgroundColor, style);
2754 2798
        } else if (entity instanceof StatisticalMeasure) {
2755 2799
            element = new StatisticalMeasureCollectionElement(this, parentElement, (StatisticalMeasure) entity, removeListener, backgroundColor, style);
2800
        } else if (entity instanceof State && parentElement instanceof InapplicableIfEntityCollectionSection) {
2801
            element = new InapplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2802
        } else if (entity instanceof State && parentElement instanceof OnlyApplicableIfEntityCollectionSection) {
2803
            element = new OnlyApplicableIfCollectionElement(this, parentElement, (State) entity, removeListener, backgroundColor, style);
2756 2804
        }
2757 2805

  
2758 2806
        //check for parent section when entity is null
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureNodeDetailElement.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import org.eclipse.ui.forms.widgets.ExpandableComposite;
12

  
13
import eu.etaxonomy.cdm.model.description.FeatureNode;
14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
18

  
19
/**
20
 *
21
 * @author pplitzner
22
 * @since Dec 21, 2017
23
 *
24
 */
25
public class FeatureNodeDetailElement extends AbstractCdmDetailElement<FeatureNode> {
26

  
27
    private InapplicableIfEntityCollectionSection sectionInapplicableIf;
28
    private OnlyApplicableIfEntityCollectionSection sectionOnlyApplicableIf;
29

  
30
	public FeatureNodeDetailElement(CdmFormFactory formFactory,
31
			ICdmFormElement formElement) {
32
		super(formFactory, formElement);
33
	}
34

  
35
	@Override
36
	protected void createControls(ICdmFormElement formElement, FeatureNode entity, int style) {
37
	    sectionInapplicableIf = formFactory.createInapplicableIfEntityCollectionSection(getConversationHolder(),
38
                    formElement, ExpandableComposite.TWISTIE);
39
	    sectionInapplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
40
	    sectionInapplicableIf.setEntity(getEntity());
41
	    sectionOnlyApplicableIf = formFactory.createOnlyApplicableIfEntityCollectionSection(getConversationHolder(),
42
	            formElement, ExpandableComposite.TWISTIE);
43
	    sectionOnlyApplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
44
	    sectionOnlyApplicableIf.setEntity(getEntity());
45
    }
46

  
47
	@Override
48
	public void handleEvent(Object eventSource) {
49
	}
50

  
51
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureNodeDetailSection.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import org.eclipse.jface.viewers.ISelectionProvider;
12

  
13
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
14
import eu.etaxonomy.cdm.model.description.FeatureNode;
15
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
16
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
18
import eu.etaxonomy.taxeditor.ui.section.ICdmDetailElement;
19

  
20
/**
21
 *
22
 * @author pplitzner
23
 * @since Dec 21, 2017
24
 *
25
 */
26
public class FeatureNodeDetailSection extends AbstractCdmDetailSection<FeatureNode> {
27

  
28
	public FeatureNodeDetailSection(CdmFormFactory formFactory,
29
	        ConversationHolder conversation, ICdmFormElement parentElement,
30
			ISelectionProvider selectionProvider, int style) {
31
		super(formFactory, conversation, parentElement, selectionProvider, style);
32
	}
33

  
34
	@Override
35
	public String getHeading() {
36
		return FeatureNode.class.getSimpleName();
37
	}
38

  
39
    /**
40
     * {@inheritDoc}
41
     */
42
    @Override
43
    protected ICdmDetailElement<FeatureNode> createCdmDetailElement(AbstractCdmDetailSection<FeatureNode> parentElement,
44
            int style) {
45
        return formFactory.createFeatureNodeDetailElement(parentElement, style);
46
    }
47

  
48
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureTreeDetailElement.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import eu.etaxonomy.cdm.model.description.FeatureTree;
12
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
13
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
14
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
15
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @since Dec 21, 2017
21
 *
22
 */
23
public class FeatureTreeDetailElement extends AbstractCdmDetailElement<FeatureTree> {
24

  
25
    private ToggleableTextElement toggleableText_titleCache;
26

  
27
	public FeatureTreeDetailElement(CdmFormFactory formFactory,
28
			ICdmFormElement formElement) {
29
		super(formFactory, formElement);
30
	}
31

  
32
	@Override
33
	protected void createControls(ICdmFormElement formElement, FeatureTree entity, int style) {
34
	    toggleableText_titleCache = formFactory.createToggleableTextField(
35
                formElement, "Title Cache", entity.getTitleCache(),
36
                entity.isProtectedTitleCache(), style);
37
    }
38

  
39
	@Override
40
	public void handleEvent(Object eventSource) {
41
	    if (eventSource == toggleableText_titleCache) {
42
            getEntity().setTitleCache(toggleableText_titleCache.getText(),
43
                    toggleableText_titleCache.getState());
44
        }
45
        if (eventSource != toggleableText_titleCache) {
46
            toggleableText_titleCache.setText(getEntity().getTitleCache());
47
        }
48
	}
49

  
50
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureTreeDetailSection.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import org.eclipse.jface.viewers.ISelectionProvider;
12

  
13
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
14
import eu.etaxonomy.cdm.model.description.FeatureTree;
15
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
16
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
18
import eu.etaxonomy.taxeditor.ui.section.ICdmDetailElement;
19

  
20
/**
21
 *
22
 * @author pplitzner
23
 * @since Dec 21, 2017
24
 *
25
 */
26
public class FeatureTreeDetailSection extends AbstractCdmDetailSection<FeatureTree> {
27

  
28
	public FeatureTreeDetailSection(CdmFormFactory formFactory,
29
	        ConversationHolder conversation, ICdmFormElement parentElement,
30
			ISelectionProvider selectionProvider, int style) {
31
		super(formFactory, conversation, parentElement, selectionProvider, style);
32
	}
33

  
34
	@Override
35
	public String getHeading() {
36
		return FeatureTree.class.getSimpleName();
37
	}
38

  
39
    /**
40
     * {@inheritDoc}
41
     */
42
    @Override
43
    protected ICdmDetailElement<FeatureTree> createCdmDetailElement(AbstractCdmDetailSection<FeatureTree> parentElement,
44
            int style) {
45
        return formFactory.createFeatureTreeDetailElement(parentElement, style);
46
    }
47

  
48
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/InapplicableIfCollectionElement.java
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import org.eclipse.swt.events.SelectionListener;
12
import org.eclipse.swt.graphics.Color;
13

  
14
import eu.etaxonomy.cdm.model.common.TermType;
15
import eu.etaxonomy.cdm.model.description.FeatureNode;
16
import eu.etaxonomy.cdm.model.description.State;
17
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
18
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
22

  
23
/**
24
 * @author pplitzner
25
 * @date Apr 27, 2015
26
 *
27
 */
28
public class InapplicableIfCollectionElement extends AbstractEntityCollectionElement<State> {
29

  
30
    private TermComboElement<State> comboState;
31

  
32
    public InapplicableIfCollectionElement(CdmFormFactory formFactory, AbstractFormSection section, State entity,
33
            SelectionListener removeListener, Color backgroundColor, int style) {
34
        super(formFactory, section, entity, removeListener, backgroundColor, style);
35

  
36
    }
37

  
38
    @Override
39
    public void createControls(ICdmFormElement element, int style) {
40
        comboState = formFactory.createDefinedTermComboElement(TermType.State, element, "Inapplicable if", null, style);
41
    }
42

  
43
    @Override
44
    public void setEntity(State entity) {
45
        this.entity = entity;
46
        if(entity.getId()!=0){
47
            comboState.setSelection(entity);
48
            comboState.removeEmptyElement();
49
        }
50
    }
51

  
52
    @Override
53
    public void handleEvent(Object eventSource) {
54
        if(eventSource==comboState && comboState.getSelection()!=null){
55
            if(getParentElement() instanceof InapplicableIfEntityCollectionSection){
56
                InapplicableIfEntityCollectionSection parentElement = (InapplicableIfEntityCollectionSection) getParentElement();
57
                FeatureNode node = parentElement.getEntity();
58
                node.removeInapplicableState(entity);
59
                State state = comboState.getSelection();
60
                node.addInapplicableState(state);
61
                entity = state;
62
                parentElement.removeElementAndUpdate(null);
63
            }
64
        }
65
    }
66

  
67
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/InapplicableIfEntityCollectionSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.feature;
11

  
12
import java.util.Collection;
13
import java.util.Comparator;
14

  
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.description.FeatureNode;
17
import eu.etaxonomy.cdm.model.description.State;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
21
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
22

  
23
/**
24
 * @author pplitzner
25
 * @date 06.03.2018
26
 *
27
 */
28
public class InapplicableIfEntityCollectionSection extends AbstractUnboundEntityCollectionSection<FeatureNode, State>{
29

  
30
    public InapplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
31
            ICdmFormElement parentElement, int style) {
32
        super(formFactory, conversation, parentElement, "Inapplicable If", style);
33
    }
34

  
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    protected Collection<State> getEntityCollection(FeatureNode entity) {
40
        return entity.getInapplicableIf();
41
    }
42

  
43
    /**
44
     * {@inheritDoc}
45
     */
46
    @Override
47
    public Comparator<State> getComparator() {
48
        return new DefaultCdmBaseComparator<>();
49
    }
50

  
51
    /**
52
     * {@inheritDoc}
53
     */
54
    @Override
55
    public State createNewElement() {
56
        return State.NewInstance();
57
    }
58

  
59
    /**
60
     * {@inheritDoc}
61
     */
62
    @Override
63
    public void addElement(State element) {
64
        //never called
65
    }
66

  
67
    /**
68
     * {@inheritDoc}
69
     */
70
    @Override
71
    public State addExisting() {
72
        return null;
73
    }
74

  
75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    public boolean allowAddExisting() {
80
        return false;
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    public void removeElement(State element) {
88
        getEntity().removeInapplicableState(element);
89
    }
90

  
91
    /** {@inheritDoc} */
92
    @Override
93
    public String getEmptyString() {
94
        return "No state added yet.";
95
    }
96

  
97
    /** {@inheritDoc} */
98
    @Override
99
    protected String getTooltipString() {
100
        return "Add a state";
101
    }
102

  
103
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/OnlyApplicableIfCollectionElement.java
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

  
11
import org.eclipse.swt.events.SelectionListener;
12
import org.eclipse.swt.graphics.Color;
13

  
14
import eu.etaxonomy.cdm.model.common.TermType;
15
import eu.etaxonomy.cdm.model.description.FeatureNode;
16
import eu.etaxonomy.cdm.model.description.State;
17
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
18
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
22

  
23
/**
24
 * @author pplitzner
25
 * @date Apr 27, 2015
26
 *
27
 */
28
public class OnlyApplicableIfCollectionElement extends AbstractEntityCollectionElement<State> {
29

  
30
    private TermComboElement<State> comboState;
31

  
32
    public OnlyApplicableIfCollectionElement(CdmFormFactory formFactory, AbstractFormSection section, State entity,
33
            SelectionListener removeListener, Color backgroundColor, int style) {
34
        super(formFactory, section, entity, removeListener, backgroundColor, style);
35

  
36
    }
37

  
38
    @Override
39
    public void createControls(ICdmFormElement element, int style) {
40
        comboState = formFactory.createDefinedTermComboElement(TermType.State, element, "Only applicable if", null, style);
41
    }
42

  
43
    @Override
44
    public void setEntity(State entity) {
45
        this.entity = entity;
46
        if(entity.getId()!=0){
47
            comboState.setSelection(entity);
48
            comboState.removeEmptyElement();
49
        }
50
    }
51

  
52
    @Override
53
    public void handleEvent(Object eventSource) {
54
        if(eventSource==comboState && comboState.getSelection()!=null){
55
            if(getParentElement() instanceof OnlyApplicableIfEntityCollectionSection){
56
                OnlyApplicableIfEntityCollectionSection parentElement = (OnlyApplicableIfEntityCollectionSection) getParentElement();
57
                FeatureNode node = parentElement.getEntity();
58
                node.removeApplicableState(entity);
59
                State state = comboState.getSelection();
60
                node.addApplicableState(state);
61
                entity = state;
62
                parentElement.removeElementAndUpdate(null);
63
            }
64
        }
65
    }
66

  
67
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/OnlyApplicableIfEntityCollectionSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.feature;
11

  
12
import java.util.Collection;
13
import java.util.Comparator;
14

  
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.description.FeatureNode;
17
import eu.etaxonomy.cdm.model.description.State;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
21
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
22

  
23
/**
24
 * @author pplitzner
25
 * @date 06.03.2018
26
 *
27
 */
28
public class OnlyApplicableIfEntityCollectionSection extends AbstractUnboundEntityCollectionSection<FeatureNode, State>{
29

  
30
    public OnlyApplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
31
            ICdmFormElement parentElement, int style) {
32
        super(formFactory, conversation, parentElement, "Only applicable if", style);
33
    }
34

  
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    protected Collection<State> getEntityCollection(FeatureNode entity) {
40
        return entity.getOnlyApplicableIf();
41
    }
42

  
43
    /**
44
     * {@inheritDoc}
45
     */
46
    @Override
47
    public Comparator<State> getComparator() {
48
        return new DefaultCdmBaseComparator<>();
49
    }
50

  
51
    /**
52
     * {@inheritDoc}
53
     */
54
    @Override
55
    public State createNewElement() {
56
        return State.NewInstance();
57
    }
58

  
59
    /**
60
     * {@inheritDoc}
61
     */
62
    @Override
63
    public void addElement(State element) {
64
        //never called
65
    }
66

  
67
    /**
68
     * {@inheritDoc}
69
     */
70
    @Override
71
    public State addExisting() {
72
        return null;
73
    }
74

  
75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    public boolean allowAddExisting() {
80
        return false;
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    public void removeElement(State element) {
88
        getEntity().removeApplicableState(element);
89
    }
90

  
91
    /** {@inheritDoc} */
92
    @Override
93
    public String getEmptyString() {
94
        return "No state added yet.";
95
    }
96

  
97
    /** {@inheritDoc} */
98
    @Override
99
    protected String getTooltipString() {
100
        return "Add a state";
101
    }
102

  
103
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
82 82
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
83 83
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
84 84
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
85
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureNodeDetailSection;
85 86
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
86 87
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
87 88
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
......
332 333
        else if (input instanceof FeatureNodeContainer) {
333 334
            createFeatureDistributionSection(rootElement);
334 335

  
335
        }else if (input instanceof Character) {
336
        } else if (input instanceof FeatureNode) {
337
            createFeatureNodeSection(rootElement);
338

  
339
        } else if (input instanceof Character) {
336 340
            createCharacterSection(rootElement);
337 341

  
338 342
        }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
......
765 769

  
766 770
    }
767 771

  
772
    private void createFeatureNodeSection(RootElement parent) {
773
        destroySections();
774

  
775
        FeatureNodeDetailSection featureDistributionSection = formFactory.createFeatureNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
776

  
777
        addPart(featureDistributionSection);
778
    }
779

  
768 780
    private void createFeatureDistributionSection(RootElement parent) {
769 781
        destroySections();
770 782

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)