Project

General

Profile

Revision 3a45849e

ID3a45849e303f94b037aec064b79ec27ba126fb63
Parent b5fcefe6
Child 2d49766c

Added by Patrick Plitzner over 2 years ago

ref #7549 Add fallback tooltip

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CategoricalChartTooltip.java
13 13
import org.eclipse.jface.window.ToolTip;
14 14
import org.eclipse.swt.SWT;
15 15
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.layout.FillLayout;
16 17
import org.eclipse.swt.layout.GridData;
17 18
import org.eclipse.swt.layout.GridLayout;
18 19
import org.eclipse.swt.widgets.Composite;
19 20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.swt.widgets.Label;
20 22
import org.swtchart.Chart;
21 23
import org.swtchart.IAxis;
22 24
import org.swtchart.IBarSeries;
......
25 27

  
26 28
import eu.etaxonomy.cdm.model.description.Feature;
27 29
import eu.etaxonomy.cdm.model.description.State;
30
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
28 31

  
29 32
/**
30 33
 * @author pplitzner
......
33 36
 */
34 37
public class CategoricalChartTooltip extends ToolTip {
35 38

  
39
    static final String TOOLTIP_NOT_AVAILABLE = Messages.CategoricalChartTooltip_TOOLTIP_NOT_AVAILABLE;
40

  
36 41
    private CharacterMatrix matrix;
37 42

  
38 43
    public CategoricalChartTooltip(CharacterMatrix matrix) {
......
50 55
    @Override
51 56
    protected Composite createToolTipContentArea(Event event,
52 57
            Composite parent) {
53
        parent.setLayout(new GridLayout());
54 58

  
59
        int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
60
        int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
61
        Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
62
        CategoricalDataHistogram histogram = matrix.getFeatureToHistogramMap().get(feature);
63

  
64
        Composite tooltip;
65
        if(histogram!=null && !histogram.getStates().isEmpty()){
66
            parent.setLayout(new GridLayout());
67
            tooltip = createTooltip(event, parent);
68
        }
69
        else{
70
            tooltip = new Composite(parent, SWT.NONE);
71
            tooltip.setLayout(new FillLayout());
72
            Label label = new Label(tooltip, SWT.NONE);
73
            label.setText(TOOLTIP_NOT_AVAILABLE);
74
        }
75
        return tooltip;
76
    }
77

  
78
    private Composite createTooltip(Event event, Composite parent) {
55 79
        Chart chart = new Chart(parent, SWT.NONE);
56 80
        chart.setLayoutData(new GridData(600, 300));
57 81

  
......
87 111
        chart.getLegend().setVisible(false);
88 112

  
89 113
        IBarSeries barSeries = (IBarSeries) chart.getSeriesSet()
90
            .createSeries(SeriesType.BAR, "state counts");
114
            .createSeries(SeriesType.BAR, "state counts"); //$NON-NLS-1$
91 115
        ISeriesLabel seriesLabel = barSeries.getLabel();
92 116
        seriesLabel.setVisible(true);
93 117
        barSeries.setYSeries(counts);
......
106 130
        int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
107 131
        int rowPos = matrix.getNatTable().getRowPositionByY(event.y);
108 132
        Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
109
        CategoricalDataHistogram histogram = matrix.getFeatureToHistogramMap().get(feature);
110 133

  
111 134
        if(matrix.isShowTooltips()
112 135
                && rowPos==1
113 136
                && colIndex>=CharacterMatrix.LEADING_COLUMN_COUNT
114
                && histogram!=null
115
                && !histogram.getStates().isEmpty()) {
137
                && feature.isSupportsCategoricalData()) {
116 138
            return true;
117 139
        }
118 140
        return false;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/QuantitativeChartTooltip.java
16 16
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
17 17
import org.eclipse.swt.SWT;
18 18
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.layout.FillLayout;
19 20
import org.eclipse.swt.layout.GridData;
20 21
import org.eclipse.swt.layout.GridLayout;
21 22
import org.eclipse.swt.widgets.Composite;
22 23
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Label;
23 25
import org.swtchart.Chart;
24 26
import org.swtchart.IAxis;
25 27
import org.swtchart.ILineSeries;
......
53 55
    @Override
54 56
    protected Composite createToolTipContentArea(Event event,
55 57
            Composite parent) {
56
        parent.setLayout(new GridLayout());
57 58

  
59
        int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
60
        int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
61
        Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
62
        QuantitativeDataStatistics dataStatistics = matrix.getFeatureToQuantDataStatisticsMap().get(feature);
63

  
64
        Composite tooltip;
65
        if(dataStatistics!=null){
66
            parent.setLayout(new GridLayout());
67
            tooltip = createTooltip(event, parent);
68
        }
69
        else{
70
            tooltip = new Composite(parent, SWT.NONE);
71
            tooltip.setLayout(new FillLayout());
72
            Label label = new Label(tooltip, SWT.NONE);
73
            label.setText(CategoricalChartTooltip.TOOLTIP_NOT_AVAILABLE);
74
        }
75
        return tooltip;
76

  
77
    }
78

  
79
    private Composite createTooltip(Event event, Composite parent){
58 80
        Chart chart = new Chart(parent, SWT.NONE);
59 81
        chart.setLayoutData(new GridData(600, 300));
60 82

  
......
115 137
        int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
116 138
        int rowPos = matrix.getNatTable().getRowPositionByY(event.y);
117 139
        Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
118
        QuantitativeDataStatistics dataStatistics = matrix.getFeatureToQuantDataStatisticsMap().get(feature);
119 140

  
120 141
        if(matrix.isShowTooltips()
121 142
                && rowPos==1
122
                && colIndex>=CharacterMatrix.LEADING_COLUMN_COUNT
123
                && dataStatistics!=null) {
143
                && feature.isSupportsQuantitativeData()
144
                && colIndex>=CharacterMatrix.LEADING_COLUMN_COUNT) {
124 145
            return true;
125 146
        }
126 147
        return false;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
22 22
    public static String AbstractGroupedContainer_NEW_HETERO_SYNONYM;
23 23
    public static String AddDerivedUnitFacadeMediaOperation_CREATE_FAILED;
24 24
    public static String AddDerivedUnitFacadeMediaOperation_CREATE_FAILED_MESSAGE;
25
    public static String CategoricalChartTooltip_TOOLTIP_NOT_AVAILABLE;
25 26
    public static String CdmAuthorityEditor_SAVING_AUTHORITY_EDITOR;
26 27
    public static String ChangeConceptRelationshipTypeOperation_NOT_IMPLEMENTED;
27 28
    public static String ChangeConceptToSynonymOperation_MULTI_REPS;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
1
CategoricalChartTooltip_TOOLTIP_NOT_AVAILABLE=Tooltip not available. First aggregate the data.
1 2
CreateFieldUnitContextMenu_CREATE_FIELD_UNIT_FOR=Create new field unit for %s
2 3
CreateDescriptiveDataSetHandler_NEW_DESCRIPTIVE_DATA_SET=New descriptive data set
3 4
SingleReadSequenceContextMenu_REMOVE_FROM_SEQUENCE=Remove from this Sequence
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
1
CategoricalChartTooltip_TOOLTIP_NOT_AVAILABLE=Tooltip nicht verf?gbar. Daten m?ssen erst aggregiert werden.
1 2
CreateFieldUnitContextMenu_CREATE_FIELD_UNIT_FOR=Erzeuge neue Field Unit f?r %s
2 3
CreateDescriptiveDataSetHandler_NEW_DESCRIPTIVE_DATA_SET=Neues Descriptive Data Set
3 4
SingleReadSequenceContextMenu_REMOVE_FROM_SEQUENCE=Von Sequenz entfernen

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)