Project

General

Profile

Download (2.15 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
    private Reference reference;
33
    private Label warnForReferencedObjects;
34
    
35
    public ReferencingObjectsMessagesSection(CdmFormFactory formFactory, ICdmFormElement layoutComposite, int style, Reference reference){
36
        super(formFactory, layoutComposite, style);
37
        this.reference = reference;
38
    }
39

    
40
    private void displayReferencingObjectsMessage() {
41

    
42
        if (reference.getId() != 0){
43
            long referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(reference);
44
            if (referencingObjectsCount > 1){
45

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

    
52
                //warnForReferencedObjects.setVisible(false);
53
            }
54
        }
55
    }
56
}
(6-6/6)