Project

General

Profile

Download (7.08 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 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.dialog.configurator.deleteConfigurator;
10

    
11
import org.eclipse.core.databinding.DataBindingContext;
12
import org.eclipse.core.databinding.beans.PojoProperties;
13
import org.eclipse.core.databinding.observable.value.IObservableValue;
14
import org.eclipse.jface.databinding.swt.WidgetProperties;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.DisposeEvent;
17
import org.eclipse.swt.events.DisposeListener;
18
import org.eclipse.swt.layout.RowLayout;
19
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.ui.forms.widgets.FormToolkit;
24

    
25
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
26
import eu.etaxonomy.taxeditor.l10n.Messages;
27

    
28
/**
29
 * @author k.luther
30
 * @date 02.11.2016
31
 *
32
 */
33
public class DeleteMediaConfiguratorComposite extends Composite {
34
    private final DataBindingContext m_bindingContext;
35

    
36
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
37
    private final MediaDeletionConfigurator configurator;
38
    private Button btnDelete;
39
//    private Button btnDeleteIfUsedInTaxonDescription;
40
//    private Button btnDeleteIfUsedInSpecimenDescription;
41
    private Button btnDeleteIfUsedInSomeWhereElse;
42
    private Button btnRemoveFromImageGallery;
43
    
44
    private boolean inBulkEditor;
45

    
46

    
47
    public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style, boolean inBulkEditor) {
48
        super(parent, style);
49
        this.inBulkEditor = inBulkEditor;
50
        this.configurator = configurator;
51
        addDisposeListener(new DisposeListener() {
52
            @Override
53
            public void widgetDisposed(DisposeEvent e) {
54
                toolkit.dispose();
55
            }
56
        });
57
        toolkit.paintBordersFor(this);
58
        setLayout(new RowLayout(SWT.VERTICAL));
59
        setBackground(getBackground());
60
        
61
        
62
//        if (inBulkEditor){
63
//            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
64
//            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
65
//            btnDeleteIfUsedInTaxonDescription.setEnabled(true);
66
//            btnDeleteIfUsedInTaxonDescription.setSelection(configurator.isDeleteIfUsedInTaxonDescription());
67
//            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
68
//            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
69
//            btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
70
//            btnDeleteIfUsedInSpecimenDescription.setSelection(configurator.isDeleteIfUsedInSpecimenDescription());
71
//        }
72
//        else {
73
        	
74
        	
75
        	//btnDelete.setSelection(configurator.setDeleteFrom(deleteFrom););
76
        	
77
        	btnDeleteIfUsedInSomeWhereElse = new Button(this, SWT.RADIO);
78
        	btnDeleteIfUsedInSomeWhereElse.setText(Messages.DeleteConfiguration_media_deleteIfUsedSomeWhereElse);
79
        	btnDeleteIfUsedInSomeWhereElse.setEnabled(true);
80
        	btnDeleteIfUsedInSomeWhereElse.setSelection(configurator.isDeleteFromEveryWhere());
81
        	
82
//            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
83
//            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
84
//            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
85
//            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
86
//            btnDelete.addListener(SWT.Selection, (Event e) -> {
87
//                Button b = (Button) e.widget;
88
//                btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
89
//                btnDeleteIfUsedInTaxonDescription.setEnabled(b.getSelection());
90
//            });
91
        	if (!inBulkEditor){
92
        		btnDelete = new Button(this, SWT.RADIO);
93
            	btnDelete.setText(Messages.DeleteConfiguration_media_delete);
94
            	
95
	            btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
96
	            btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
97
	            btnRemoveFromImageGallery.setSelection(configurator.isOnlyRemoveFromGallery());
98
        	}
99
//        }
100

    
101
        m_bindingContext = initDataBindings();
102

    
103
    }
104

    
105
    protected DataBindingContext initDataBindings() {
106
        DataBindingContext bindingContext = new DataBindingContext();
107
        //
108
//        if (inBulkEditor){
109
//	        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
110
//	        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
111
//	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
112
//	        
113
//	        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
114
//	        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
115
//	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
116
//        } else{       
117
        	IObservableValue observeSelectionBtnDeleteIfUsedInSomeWhereElse = WidgetProperties.selection().observe(btnDeleteIfUsedInSomeWhereElse);
118
 	        IObservableValue deleteIfUsedInSomeWhereElseConfiguratorObserveValue = PojoProperties.value("deleteFromEveryWhere").observe(configurator);
119
 	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSomeWhereElse, deleteIfUsedInSomeWhereElseConfiguratorObserveValue, null, null);
120
 	        
121
//	        IObservableValue observeSelectionBtnDelete = WidgetProperties.selection().observe(btnDelete);
122
//	        IObservableValue deleteConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
123
//	        bindingContext.bindValue(observeSelectionBtnDelete, deleteConfiguratorObserveValue, null, null);
124
 	       if (!inBulkEditor){
125
	            IObservableValue observeSelectionBtnRemoveFromImageGallery = WidgetProperties.selection().observe(btnRemoveFromImageGallery);
126
	            IObservableValue removeFromImageGalleryConfiguratorObserveValue = PojoProperties.value("onlyRemoveFromGallery").observe(configurator);
127
	            bindingContext.bindValue(observeSelectionBtnRemoveFromImageGallery, removeFromImageGalleryConfiguratorObserveValue, null, null);
128
 	       }
129

    
130
       
131

    
132
        return bindingContext;
133
    }
134

    
135

    
136
}
(2-2/7)