Project

General

Profile

Revision 751d31d7

ID751d31d7cc06602e71c1bba1e49683804eed563d
Parent 50fa099c
Child 7a22ac0a

Added by Patrick Plitzner over 6 years ago

  • removed TextReadOnly (#4254)
    • just used a Text field with "editable" flag set to false
    • added dummy title cache text as section header
    • just showing the first 10 characters

View differences:

.gitattributes
1403 1403
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/combo/EnumTermComboController.java -text
1404 1404
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElement.java -text
1405 1405
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElementController.java -text
1406
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextReadOnly.java -text
1407
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextReadOnlyController.java -text
1408 1406
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextWithLabelElementController.java -text
1409 1407
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextWithLabelElementMVC.java -text
1410 1408
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/interfaces/CdmCompositeController.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/OriginalLabelDataController.java
9 9
*/
10 10
package eu.etaxonomy.taxeditor.ui.mvc;
11 11

  
12
import org.eclipse.swt.events.ModifyEvent;
13
import org.eclipse.swt.events.ModifyListener;
14

  
15 12
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
16 13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
23 20
 * @date 17.06.2014
24 21
 *
25 22
 */
26
public class OriginalLabelDataController extends AbstractCdmDetailElement<DerivedUnitFacade> implements CdmCompositeController, ModifyListener{
23
public class OriginalLabelDataController extends AbstractCdmDetailElement<DerivedUnitFacade> implements CdmCompositeController{
27 24

  
28 25
    private final OriginalLabelDataElement originalLabelDataElement;
29 26

  
......
40 37
    }
41 38

  
42 39
    /* (non-Javadoc)
43
     * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
44
     */
45
    @Override
46
    public void modifyText(ModifyEvent e) {
47
        System.out.println("Modify");
48
    }
49

  
50
    /* (non-Javadoc)
51 40
     * @see eu.etaxonomy.taxeditor.ui.element.IRelevantFormElement#setIrrelevant(boolean)
52 41
     */
53 42
    @Override
......
77 66
     */
78 67
    @Override
79 68
    protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
80
        System.out.println("Create");
81
        originalLabelDataElement.getTextReadOnly().getText().setText(entity.getTitleCache());
69
        originalLabelDataElement.getText().setText(entity.getTitleCache());
82 70
    }
83 71

  
84 72
    /* (non-Javadoc)
......
86 74
     */
87 75
    @Override
88 76
    public void handleEvent(Object eventSource) {
89
        // TODO Auto-generated method stub
90
        System.out.println("Hndle");
91 77
    }
92 78
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/OriginalLabelDataElement.java
12 12
import org.eclipse.swt.SWT;
13 13
import org.eclipse.swt.widgets.Composite;
14 14
import org.eclipse.swt.widgets.Label;
15
import org.eclipse.swt.widgets.Text;
15 16
import org.eclipse.ui.forms.widgets.TableWrapData;
16 17
import org.eclipse.ui.forms.widgets.TableWrapLayout;
17 18

  
18 19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.mvc.element.TextReadOnly;
21 21

  
22 22
/**
23 23
 * @author pplitzner
......
25 25
 *
26 26
 */
27 27
public class OriginalLabelDataElement extends AbstractCdmComposite<OriginalLabelDataController>{
28
    private final TextReadOnly textReadOnly;
28
    private final Text text;
29 29

  
30 30
    /**
31 31
     * @param parent
......
41 41
            tableWrapLayout.leftMargin = 0;
42 42
            tableWrapLayout.horizontalSpacing = 0;
43 43
            tableWrapLayout.bottomMargin = 0;
44
            tableWrapLayout.numColumns = 2;
44
            tableWrapLayout.numColumns = 3;
45 45
            setLayout(tableWrapLayout);
46 46
        }
47 47

  
48 48
        Label lblOriginalLabelData = new Label(this, SWT.NONE);
49
        lblOriginalLabelData.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
49 50
        lblOriginalLabelData.setText("Original Label Data");
50 51

  
51
        textReadOnly = new TextReadOnly(this, SWT.NONE);
52
        textReadOnly.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
52
        text = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
53
        text.setEditable(false);
54
        text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
55
        new Label(this, SWT.NONE);
53 56

  
54 57
        // TODO Auto-generated constructor stub
55 58
    }
......
62 65
        controller = new OriginalLabelDataController(formFactory, parentElement, this, SWT.NONE);
63 66
    }
64 67

  
65
    public TextReadOnly getTextReadOnly() {
66
        return textReadOnly;
68
    public Text getText() {
69
        return text;
67 70
    }
68 71
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextReadOnly.java
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.mvc.element;
11

  
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.DisposeEvent;
14
import org.eclipse.swt.events.DisposeListener;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Display;
17
import org.eclipse.swt.widgets.Text;
18
import org.eclipse.ui.forms.widgets.FormToolkit;
19
import org.eclipse.ui.forms.widgets.TableWrapData;
20
import org.eclipse.ui.forms.widgets.TableWrapLayout;
21

  
22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite;
25

  
26
/**
27
 * @author pplitzner
28
 * @date 18.06.2014
29
 *
30
 */
31
public class TextReadOnly extends AbstractCdmComposite<TextReadOnlyController> {
32

  
33
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
34
    private final Text text;
35

  
36
    /**
37
     * Create the composite.
38
     * @param parent
39
     * @param style
40
     */
41
    public TextReadOnly(Composite parent, int style) {
42
        super(parent, style);
43
        addDisposeListener(new DisposeListener() {
44
            @Override
45
            public void widgetDisposed(DisposeEvent e) {
46
                toolkit.dispose();
47
            }
48
        });
49
        toolkit.paintBordersFor(this);
50
        {
51
            setLayout(new TableWrapLayout());
52
        }
53

  
54
        text = new Text(this, SWT.BORDER | SWT.MULTI);
55
        text.setEnabled(false);
56
        text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
57

  
58
    }
59

  
60
    /* (non-Javadoc)
61
     * @see eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite#initInternalController(eu.etaxonomy.taxeditor.ui.element.CdmFormFactory, eu.etaxonomy.taxeditor.ui.element.ICdmFormElement)
62
     */
63
    @Override
64
    protected void initInternalController(CdmFormFactory formFactory, ICdmFormElement parentElement) {
65
        controller = new TextReadOnlyController(this, formFactory, parentElement, null, SWT.NONE);
66
    }
67

  
68
    public Text getText() {
69
        return text;
70
    }
71
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextReadOnlyController.java
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.mvc.element;
11

  
12
import org.eclipse.swt.events.ModifyEvent;
13
import org.eclipse.swt.events.ModifyListener;
14
import org.eclipse.swt.widgets.Text;
15

  
16
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
20
import eu.etaxonomy.taxeditor.ui.mvc.interfaces.CdmCompositeController;
21

  
22
/**
23
 * @author pplitzner
24
 * @date 18.06.2014
25
 *
26
 */
27
public class TextReadOnlyController extends AbstractCdmFormElement implements IEnableableFormElement, CdmCompositeController, ModifyListener{
28

  
29
    protected Text text;
30

  
31

  
32
    public TextReadOnlyController(TextReadOnly textReadOnly, CdmFormFactory formFactory, ICdmFormElement parentElement,
33
            String initialText, int style) {
34
        super(formFactory, parentElement);
35
        text = textReadOnly.getText();
36
        text.addModifyListener(this);
37
    }
38

  
39
    /* (non-Javadoc)
40
     * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
41
     */
42
    @Override
43
    public void modifyText(ModifyEvent e) {
44
        System.out.println("Modify");
45
    }
46

  
47
    /* (non-Javadoc)
48
     * @see eu.etaxonomy.taxeditor.ui.element.IRelevantFormElement#setIrrelevant(boolean)
49
     */
50
    @Override
51
    public void setIrrelevant(boolean irrelevant) {
52
        // TODO Auto-generated method stub
53

  
54
    }
55

  
56

  
57
    /* (non-Javadoc)
58
     * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#setEnabled(boolean)
59
     */
60
    @Override
61
    public void setEnabled(boolean enabled) {
62
        this.text.setEnabled(enabled);
63
    }
64

  
65

  
66
    /* (non-Javadoc)
67
     * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled()
68
     */
69
    @Override
70
    public boolean isEnabled() {
71
        return this.text.isEnabled();
72
    }
73
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/OriginalLabelDataSection.java
43 43
     */
44 44
    @Override
45 45
    public String getHeading() {
46
        return "Original Label Data";
46
        return "Original Label Data: ";
47
    }
48

  
49
    /* (non-Javadoc)
50
     * @see org.eclipse.ui.forms.widgets.ExpandableComposite#setText(java.lang.String)
51
     */
52
    @Override
53
    public void setText(String title) {
54
        String text = getHeading();
55
        if(getEntity()!=null){// && getEntity().getOriginalLabelData!=null){
56
            String titleCache = getEntity().getTitleCache();
57
            text += titleCache.substring(0, Math.min(10, titleCache.length()));
58
            text += "...";
59
        }
60
        if(text!=null){
61
            super.setText(text);
62
        }
63
        else{
64
            super.setText(title);
65
        }
47 66
    }
48 67

  
49 68
    /* (non-Javadoc)

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)