Project

General

Profile

Download (2.39 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.bulkeditor.e4;
10

    
11
import org.eclipse.jface.window.DefaultToolTip;
12
import org.eclipse.jface.window.ToolTip;
13
import org.eclipse.nebula.widgets.nattable.NatTable;
14
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
15
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Event;
18

    
19
import eu.etaxonomy.taxeditor.l10n.Messages;
20

    
21
/**
22
 * @author pplitzner
23
 * @since Jul 6, 2018
24
 *
25
 */
26
public class BulkEditorTooltip extends DefaultToolTip {
27

    
28
    private NatTable natTable;
29

    
30
    public BulkEditorTooltip(NatTable natTable) {
31
        super(natTable, ToolTip.NO_RECREATE, false);
32
        this.natTable = natTable;
33
}
34

    
35
    @Override
36
    protected Object getToolTipArea(Event event) {
37
        int col = this.natTable.getColumnPositionByX(event.x);
38
        int row = this.natTable.getRowPositionByY(event.y);
39

    
40
        return new Point(col, row);
41
    }
42

    
43
    @Override
44
    protected String getText(Event event) {
45
        int col = this.natTable.getColumnPositionByX(event.x);
46
        int row = this.natTable.getRowPositionByY(event.y);
47

    
48
        LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
49
        if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_TARGET)){
50
            return Messages.BulkEditorTooltip_TARGET;
51
        }
52
        else if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_CANDIDATE)){
53
            return Messages.BulkEditorTooltip_CANDIDATE;
54
        }
55
        return ""; //$NON-NLS-1$
56
    }
57

    
58
    @Override
59
    protected Composite createToolTipContentArea(Event event,
60
            Composite parent) {
61
        return super.createToolTipContentArea(event, parent);
62
    }
63

    
64
    @Override
65
    protected boolean shouldCreateToolTip(Event event) {
66
        int col = this.natTable.getColumnPositionByX(event.x);
67
        int row = this.natTable.getRowPositionByY(event.y);
68

    
69
        LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
70
        if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_CANDIDATE)
71
                || configLabels.hasLabel(BulkEditorE4Composite.LABEL_TARGET)){
72
            return true;
73
        }
74
        return false;
75
    }
76

    
77
}
(7-7/7)