Project

General

Profile

Download (2.18 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.reference;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.widgets.Composite;
13
import org.eclipse.swt.widgets.Display;
14
import org.eclipse.swt.widgets.Label;
15

    
16
import eu.etaxonomy.cdm.common.CdmUtils;
17
import eu.etaxonomy.cdm.model.reference.Reference;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
23

    
24
/**
25
 * @author k.luther
26
 * @date 27.03.2017
27
 *
28
 */
29
public class ReferencingObjectsMessagesSection extends AbstractFormSection {
30

    
31

    
32
    Reference reference;
33
    Label warnForReferencedObjects;
34

    
35

    
36
    public ReferencingObjectsMessagesSection(CdmFormFactory formFactory, ICdmFormElement layoutComposite, int style, Reference reference){
37
        super(formFactory, layoutComposite, style);
38
        this.reference = reference;
39
    }
40

    
41

    
42

    
43

    
44
    private void displayReferencingObjectsMessage() {
45

    
46
        if (reference.getId() != 0){
47
            Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(reference);
48
            Composite container;
49
            if (referencingObjectsCount > 1){
50

    
51
                    warnForReferencedObjects = formFactory.createLabel(getLayoutComposite(), CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
52
                    warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
53
                    warnForReferencedObjects.setLayoutData(LayoutConstants.FILL(1, 1));
54
                    warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor(
55
                            SWT.COLOR_RED));
56

    
57

    
58
                //warnForReferencedObjects.setVisible(false);
59
            }
60
        }
61

    
62

    
63

    
64
    }
65

    
66

    
67

    
68
}
(6-6/6)