Project

General

Profile

« Previous | Next » 

Revision c872869c

Added by Patrick Plitzner over 5 years ago

ref #7923 Set character representation during creation

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/character/CharacterEditor.java
56 56
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
57 57
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
58 58
import eu.etaxonomy.cdm.api.service.ITermService;
59
import eu.etaxonomy.cdm.model.common.Representation;
59 60
import eu.etaxonomy.cdm.model.description.Character;
60 61
import eu.etaxonomy.cdm.model.description.FeatureNode;
61 62
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
72 73
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
73 74
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
74 75
import eu.etaxonomy.taxeditor.model.MessagingUtils;
76
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
75 77
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
76 78
import eu.etaxonomy.taxeditor.store.CdmStore;
77 79
import eu.etaxonomy.taxeditor.ui.dialog.selection.FeatureTreeSelectionDialog;
......
218 220

  
219 221
    private void init(){
220 222
        btnAddCharacter.addSelectionListener(new SelectionAdapter() {
221
            /**
222
             * {@inheritDoc}
223
             */
224 223
            @Override
225 224
            public void widgetSelected(SelectionEvent e) {
226 225
                ISelection structureTreeSelection = structuresTreeEditorComposite.getViewer().getSelection();
......
234 233
                for (Character character : characters) {
235 234
                    //add new Character to feature tree
236 235
                    FeatureNode parent = ((FeatureTree) characterTreeEditorComposite.getViewer().getInput()).getRoot();
237
                    CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(parent.getUuid(), character.getUuid());
236
                    CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(parent, character);
238 237
                }
239

  
240
                setDirty();
241 238
                characterTreeEditorComposite.getViewer().refresh();
242 239
            }
243 240
        });
......
254 251
            Iterator<FeatureNode> propertiesIterator = propertyTreeSelection.iterator();
255 252
            while(propertiesIterator.hasNext()){
256 253
                FeatureNode propertyNode = propertiesIterator.next();
254
                Representation structureRepresentation = structureNode.getFeature().getRepresentation(PreferencesUtil.getGlobalLanguage());
255
                Representation propertyRepresentation = propertyNode.getFeature().getRepresentation(PreferencesUtil.getGlobalLanguage());
256
                String label = null;
257
                String abbrevLabel = null;
258
                if(structureRepresentation.getLabel()!=null && propertyRepresentation.getLabel()!=null){
259
                    label = structureRepresentation.getLabel()+" "+propertyRepresentation.getLabel();
260
                }
261
                if(structureRepresentation.getAbbreviatedLabel()!=null && propertyRepresentation.getAbbreviatedLabel()!=null){
262
                    abbrevLabel = structureRepresentation.getAbbreviatedLabel()+" "+propertyRepresentation.getAbbreviatedLabel();
263
                }
257 264
                //create new Character
258
                Character character = Character.NewInstance(structureNode, propertyNode);
265
                Character character = Character.NewInstance(structureNode, propertyNode, null, label, abbrevLabel);
259 266
                characters.add(character);
260 267
            }
261 268
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/CharacterTransfer.java
23 23
import org.eclipse.swt.dnd.TransferData;
24 24

  
25 25
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
26
import eu.etaxonomy.cdm.model.common.Representation;
26 27
import eu.etaxonomy.cdm.model.description.Character;
27 28
import eu.etaxonomy.cdm.model.description.FeatureNode;
29
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28 30
import eu.etaxonomy.taxeditor.store.CdmStore;
29 31

  
30 32
/**
......
100 102
                        IFeatureNodeService featureNodeService = CdmStore.getService(IFeatureNodeService.class);
101 103
                        FeatureNode structure = featureNodeService.load(UUID.fromString(split[0]));
102 104
                        FeatureNode property = featureNodeService.load(UUID.fromString(split[1]));
103
                        characters.add(Character.NewInstance(structure, property));
105
                        Representation structureRepresentation = structure.getFeature().getRepresentation(PreferencesUtil.getGlobalLanguage());
106
                        Representation propertyRepresentation = property.getFeature().getRepresentation(PreferencesUtil.getGlobalLanguage());
107
                        String label = null;
108
                        String abbrevLabel = null;
109
                        if(structureRepresentation.getLabel()!=null && propertyRepresentation.getLabel()!=null){
110
                            label = structureRepresentation.getLabel()+" "+propertyRepresentation.getLabel();
111
                        }
112
                        if(structureRepresentation.getAbbreviatedLabel()!=null && propertyRepresentation.getAbbreviatedLabel()!=null){
113
                            abbrevLabel = structureRepresentation.getAbbreviatedLabel()+" "+propertyRepresentation.getAbbreviatedLabel();
114
                        }
115
                        characters.add(Character.NewInstance(structure, property, null, label, abbrevLabel));
104 116
                    }
105 117
                }catch(EOFException e){
106 118
                    return characters.toArray();

Also available in: Unified diff