Project

General

Profile

Revision e7df9bb1

IDe7df9bb107f5171b369ccd9aa051ce1518c2e8e6
Parent 5c025bd1
Child fa6c7d4c

Added by Patrick Plitzner almost 4 years ago

ref #7086 Add "browse" and "delete" button to area selection in WSeditor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetComposite.java
12 12
import org.eclipse.swt.SWT;
13 13
import org.eclipse.swt.layout.GridData;
14 14
import org.eclipse.swt.layout.GridLayout;
15
import org.eclipse.swt.widgets.Button;
15 16
import org.eclipse.swt.widgets.Composite;
16 17
import org.eclipse.swt.widgets.Label;
17 18
import org.eclipse.swt.widgets.Text;
......
22 23
import eu.etaxonomy.cdm.model.location.NamedArea;
23 24
import eu.etaxonomy.cdm.model.name.Rank;
24 25
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
26
import eu.etaxonomy.taxeditor.model.ImageResources;
25 27
import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
26 28
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
27 29
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
......
39 41
    private TreeViewer taxonNodeTree;
40 42
    private NamedArea area;
41 43
    private Text textAreaText;
44
    private Button btnChooseArea;
45
    private Button btnRemoveArea;
42 46

  
43 47
    public WorkingSetComposite(Composite parent, int style) {
44 48
        super(parent, style);
......
81 85
        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
82 86
        lblNewLabel_4.setText("Area");
83 87

  
84
        textAreaText = new Text(this, SWT.BORDER);
88
        Composite composite = new Composite(this, SWT.NONE);
89
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
90
        GridLayout gl_composite = new GridLayout(3, false);
91
        gl_composite.horizontalSpacing = 0;
92
        gl_composite.verticalSpacing = 0;
93
        gl_composite.marginHeight = 0;
94
        gl_composite.marginWidth = 0;
95
        composite.setLayout(gl_composite);
96

  
97
        textAreaText = new Text(composite, SWT.BORDER);
85 98
        textAreaText.setEditable(false);
86 99
        textAreaText.setText("Choose...");
87 100
        textAreaText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
88 101

  
102
        btnChooseArea = new Button(composite, SWT.NONE);
103
        btnChooseArea.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
104

  
105
        btnRemoveArea = new Button(composite, SWT.NONE);
106
        btnRemoveArea.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
107

  
89 108
        featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
90
        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
109
        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
110
        new Label(this, SWT.NONE);
91 111
    }
92 112

  
93 113
    @Override
......
134 154
        this.area = area;
135 155
        textAreaText.setText(area.getLabel());
136 156
    }
137
    public Text getTextAreaText() {
138
        return textAreaText;
157
    public void removeArea() {
158
        this.area = null;
159
        textAreaText.setText("");
160
    }
161
    public Button getBtnChooseArea() {
162
        return btnChooseArea;
163
    }
164
    public Button getBtnRemoveArea() {
165
        return btnRemoveArea;
139 166
    }
140 167
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
40 40
import org.eclipse.swt.events.KeyEvent;
41 41
import org.eclipse.swt.events.ModifyEvent;
42 42
import org.eclipse.swt.events.ModifyListener;
43
import org.eclipse.swt.events.SelectionAdapter;
43 44
import org.eclipse.swt.widgets.Composite;
44 45
import org.eclipse.swt.widgets.Display;
45 46
import org.eclipse.swt.widgets.Shell;
......
119 120
        composite.getRankMin().addSelectionChangedListener(event->dirty.setDirty(true));
120 121
        composite.getRankMax().addSelectionChangedListener(event->dirty.setDirty(true));
121 122

  
122
        composite.getTextAreaText().addListener(SWT.MouseDown, event-> {
123
            NamedArea area = NamedAreaSelectionDialog.select(shell, null, null);
124
            if(area!=null){
125
                composite.setArea(area);
123
        composite.getBtnChooseArea().addSelectionListener(new SelectionAdapter() {
124

  
125
            @Override
126
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
127
                NamedArea area = NamedAreaSelectionDialog.select(shell, null, null);
128
                if(area!=null){
129
                    composite.setArea(area);
130
                }
131
                dirty.setDirty(true);
132
            }
133
        });
134
        composite.getBtnRemoveArea().addSelectionListener(new SelectionAdapter() {
135

  
136
            @Override
137
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
138
                composite.removeArea();
139
                dirty.setDirty(true);
126 140
            }
127
            dirty.setDirty(true);
128 141
        });
129 142

  
130 143
        composite.getFeatureTreeEditorComposite().init(null, null, e->selectionService.setSelection(e.getSelection()), null);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)