Project

General

Profile

Revision 55031c8b

ID55031c8b54ac487e9500d59ace74bc476a3931a1
Parent 4674e650
Child 7fab194f

Added by Katja Luther over 2 years ago

fix #6527: refactor media deletion configurator and the corresponding wizard

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java
64 64
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
65 65
			throws ExecutionException {
66 66

  
67
	    ImagesUtility.removeMediaFromGallery(description, media);
67
	   // ImagesUtility.removeMediaFromGallery(description, media);
68 68

  
69 69
		monitor.worked(20);
70 70
		CdmStore.getService(IMediaService.class).delete(media.getUuid(), config);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java
35 35

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

  
42 45

  
43 46
    public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style, boolean inBulkEditor) {
44 47
        super(parent, style);
48
        this.inBulkEditor = inBulkEditor;
45 49
        this.configurator = configurator;
46 50
        addDisposeListener(new DisposeListener() {
47 51
            @Override
......
52 56
        toolkit.paintBordersFor(this);
53 57
        setLayout(new RowLayout(SWT.VERTICAL));
54 58
        setBackground(getBackground());
55

  
59
        
60
        
56 61
        if (inBulkEditor){
57 62
            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
58 63
            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
64
            btnDeleteIfUsedInTaxonDescription.setEnabled(true);
65
            btnDeleteIfUsedInTaxonDescription.setSelection(configurator.isDeleteIfUsedInTaxonDescription());
66
            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
67
            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
68
            btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
69
            btnDeleteIfUsedInSpecimenDescription.setSelection(configurator.isDeleteIfUsedInSpecimenDescription());
59 70
        }
60 71
        else {
61
            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.RADIO);
62
            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_delete);
63

  
72
        	
73
        	btnDelete = new Button(this, SWT.RADIO);
74
        	btnDelete.setText(Messages.DeleteConfiguration_media_delete);
75
        	
76
//            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
77
//            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
78
//            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
79
//            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
80
//            btnDelete.addListener(SWT.Selection, (Event e) -> {
81
//                Button b = (Button) e.widget;
82
//                btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
83
//                btnDeleteIfUsedInTaxonDescription.setEnabled(b.getSelection());
84
//            });
64 85
            btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
65 86
            btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
87
            btnDelete.setSelection(!configurator.isOnlyRemoveFromGallery());
88
        	btnRemoveFromImageGallery.setSelection(configurator.isOnlyRemoveFromGallery());
66 89
        }
67 90

  
68
        btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
69
        btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
70

  
71
        if(inBulkEditor){
72
            btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
73
        }
74
        else{
75
            btnDeleteIfUsedInSpecimenDescription.setEnabled(false);
76

  
77
            btnDeleteIfUsedInTaxonDescription.addListener(SWT.Selection, (Event e) -> {
78
                Button b = (Button) e.widget;
79
                btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
80

  
81
            });
82
        }
83
        btnDeleteIfUsedInTaxonDescription.setSelection(true);
84

  
85 91
        m_bindingContext = initDataBindings();
86 92

  
87 93
    }
......
89 95
    protected DataBindingContext initDataBindings() {
90 96
        DataBindingContext bindingContext = new DataBindingContext();
91 97
        //
92
        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
93
        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
94
        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
95

  
96
        if(btnRemoveFromImageGallery!=null){
98
        if (inBulkEditor){
99
	        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
100
	        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
101
	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
102
	        
103
	        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
104
	        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
105
	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
106
        } else{       
107
        
108
	        IObservableValue observeSelectionBtnDelete = WidgetProperties.selection().observe(btnDelete);
109
	        IObservableValue deleteConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
110
	        bindingContext.bindValue(observeSelectionBtnDelete, deleteConfiguratorObserveValue, null, null);
111
       
97 112
            IObservableValue observeSelectionBtnRemoveFromImageGallery = WidgetProperties.selection().observe(btnRemoveFromImageGallery);
98 113
            IObservableValue removeFromImageGalleryConfiguratorObserveValue = PojoProperties.value("onlyRemoveFromGallery").observe(configurator);
99 114
            bindingContext.bindValue(observeSelectionBtnRemoveFromImageGallery, removeFromImageGalleryConfiguratorObserveValue, null, null);
100 115
        }
101 116

  
102
        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
103
        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
104
        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
117
       
105 118

  
106 119
        return bindingContext;
107 120
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)