Project

General

Profile

« Previous | Next » 

Revision 5200fbd3

Added by Cherian Mathew about 9 years ago

ConceptRelationshipComposite, StatusComposite : implemented drag drop for new concept relationship
CdmDataChangeService, SelectionService : making sure events list is cleared after fire

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/ConceptRelationshipComposite.java
60 60

  
61 61
    private IdUuidName fromTaxonIun;
62 62

  
63
    private static final String CREATE_NEW_CR_TITLE = "Create New Concept Relationship";
63
    public static final String CREATE_NEW_CR_TITLE = "Create New Concept Relationship";
64 64

  
65 65
    /**
66 66
     * The constructor should first build the main layout, set the
......
100 100

  
101 101
            @Override
102 102
            public void buttonClick(ClickEvent event) {
103
                showEditConceptRelationshipWindow(CREATE_NEW_CR_TITLE);
103
                showEditConceptRelationshipWindow(CREATE_NEW_CR_TITLE, fromTaxonIun, null, null);
104 104
            }
105 105
        });
106 106
    }
107 107

  
108
    private void showEditConceptRelationshipWindow(String windowTitle) {
108
    public static void showEditConceptRelationshipWindow(String windowTitle,
109
            IdUuidName fromTaxonIun,
110
            IdUuidName taxonRTypeIun,
111
            IdUuidName toTaxonIun) {
109 112
        Window dialog = new Window(windowTitle);
110 113
        dialog.setModal(false);
111 114
        dialog.setClosable(false);
112 115
        dialog.setResizable(false);
113 116
        UI.getCurrent().addWindow(dialog);
114 117

  
115
        EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(dialog,fromTaxonIun, null, null);
118
        EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(dialog,fromTaxonIun, taxonRTypeIun, toTaxonIun);
116 119
        dialog.setContent(ecrc);
117 120
    }
118 121

  
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java
19 19
import org.apache.log4j.Logger;
20 20

  
21 21
import com.vaadin.annotations.AutoGenerated;
22
import com.vaadin.data.Container.Hierarchical;
22 23
import com.vaadin.data.Item;
23 24
import com.vaadin.data.Property;
24 25
import com.vaadin.data.Property.ValueChangeEvent;
......
32 33
import com.vaadin.event.ItemClickEvent.ItemClickListener;
33 34
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
34 35
import com.vaadin.event.LayoutEvents.LayoutClickListener;
36
import com.vaadin.event.Transferable;
37
import com.vaadin.event.dd.DragAndDropEvent;
38
import com.vaadin.event.dd.DropHandler;
39
import com.vaadin.event.dd.acceptcriteria.AcceptAll;
40
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
35 41
import com.vaadin.navigator.View;
36 42
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
37 43
import com.vaadin.server.FontAwesome;
44
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
38 45
import com.vaadin.ui.Alignment;
39 46
import com.vaadin.ui.Button;
40 47
import com.vaadin.ui.Button.ClickEvent;
......
210 217
                }
211 218
            });
212 219

  
220
            taxaTreeTable.setDropHandler(new DropHandler() {
221

  
222
                @Override
223
                public AcceptCriterion getAcceptCriterion() {
224
                    return AcceptAll.get();
225
                }
226

  
227
                @Override
228
                public void drop(DragAndDropEvent event) {
229
                    // Wrapper for the object that is dragged
230
                    Transferable t = event.getTransferable();
231
                    Component source = t.getSourceComponent();
232

  
233
                    // This is the case where the source of the dd is another
234
                    // taxon table not the one in this object
235
                    if (source instanceof TreeTable  && source != taxaTreeTable) {
236
                        TreeTable table = (TreeTable)t.getSourceComponent();
237
                        Hierarchical sourceHierachicalContainer = table.getContainerDataSource();
238

  
239
                        IdUuidName fromTaxonIun, toTaxonIun;
240
                        if(sourceHierachicalContainer instanceof LeafNodeTaxonContainer) {
241
                            LeafNodeTaxonContainer lntc = (LeafNodeTaxonContainer)sourceHierachicalContainer;
242
                            Object sourceItemId = t.getData("itemId");
243
                            String fromName = (String)lntc.getProperty(sourceItemId, LeafNodeTaxonContainer.NAME_ID).getValue();
244

  
245
                            AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event.getTargetDetails());
246
                            Object targetItemId = dropData.getItemIdOver();
247
                            String toName = (String)listener.getCurrentLeafNodeTaxonContainer().getProperty(targetItemId, LeafNodeTaxonContainer.NAME_ID).getValue();
248

  
249
                            fromTaxonIun = new IdUuidName(sourceItemId,
250
                                    lntc.getUuid(sourceItemId),
251
                                    fromName);
252
                            toTaxonIun = new IdUuidName(targetItemId,
253
                                    listener.getCurrentLeafNodeTaxonContainer().getUuid(targetItemId),
254
                                    toName);
255
                            ConceptRelationshipComposite.showEditConceptRelationshipWindow(ConceptRelationshipComposite.CREATE_NEW_CR_TITLE,
256
                                    fromTaxonIun,
257
                                    null,
258
                                    toTaxonIun);
259
                        }
260
                    }
261

  
262

  
263
                }
264
            });
265

  
213 266
            // NOTE : Not really sure why we need to refresh the container here.
214 267
            // in the case of 'Table' this is not required
215 268
            listener.refresh();
src/main/java/eu/etaxonomy/cdm/vaadin/session/CdmDataChangeService.java
41 41
    }
42 42

  
43 43
    public void fireCurrentChangeEvents(boolean async) {
44
        for(CdmChangeEvent event : currentEvents) {
45
            fireChangeEvent(event,async);
44
        try {
45
            for(CdmChangeEvent event : currentEvents) {
46
                fireChangeEvent(event,async);
47
            }
48
        } finally {
49
            currentEvents.clear();
46 50
        }
47
        currentEvents.clear();
48 51
    }
49 52

  
50 53
    public void fireChangeEvent(CdmChangeEvent event, boolean async) {
src/main/java/eu/etaxonomy/cdm/vaadin/session/SelectionService.java
41 41
    }
42 42

  
43 43
    public void fireCurrentSelectionEvents(boolean async) {
44
        for(SelectionEvent event : currentEvents) {
45
            fireSelectionEvent(event,async);
44
        try {
45
            for(SelectionEvent event : currentEvents) {
46
                fireSelectionEvent(event,async);
47
            }
48
        } finally {
49
            currentEvents.clear();
46 50
        }
47
        currentEvents.clear();
48 51
    }
49 52

  
50 53
    public void fireSelectionEvent(final SelectionEvent event, boolean async) {

Also available in: Unified diff