Project

General

Profile

« Previous | Next » 

Revision aee16929

Added by Cherian Mathew about 7 years ago

ConceptRelationshipComposite : ui fixes for controls
EditConceptRelationshipComposite : changed polling interval to 1 sec
IStatusComposite, StatusComposite, StatusPresenter, ConceptRelationshipUI, ConceptRelationshipView : allowing setting of classifications via url parameters
StatusPresenterTest : testing method for getting
StatusEditorUI, DbStatusUI, AbstractAuthenticatedUI, NavigatorTestUI : exposing vaadin request to abstract init method
d3.conceptrelationshiptree_connector.js : changed size to work on smaller screens
edit.scss, styles.scss : corrected icon size

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/ConceptRelationshipComposite.java
9 9
*/
10 10
package eu.etaxonomy.cdm.vaadin.component;
11 11

  
12
import java.util.Arrays;
12 13
import java.util.UUID;
13 14

  
14 15
import org.json.JSONException;
......
36 37
import eu.etaxonomy.cdm.vaadin.session.ISelectionListener;
37 38
import eu.etaxonomy.cdm.vaadin.session.SelectionEvent;
38 39
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinSessionUtilities;
40
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinUtilities;
39 41
import eu.etaxonomy.cdm.vaadin.view.ConceptRelationshipView;
40 42
import eu.etaxonomy.cdm.vaadin.view.IConceptRelationshipComponentListener;
41 43

  
......
60 62
    private Button editButton;
61 63
    @AutoGenerated
62 64
    private Button newButton;
63

  
64 65
    private final IConceptRelationshipComponentListener listener;
65 66

  
66 67
    private IdUuidName fromTaxonIun;
......
126 127
                       null,
127 128
                       Action.Create,
128 129
                       view.getDirection());
130
               setSelectedTaxonRelUuid(null);
129 131
            }
130 132
        });
131 133
    }
......
140 142
                        selectedTaxonRelUuid,
141 143
                        Action.Update,
142 144
                        view.getDirection());
145
                setSelectedTaxonRelUuid(null);
143 146
            }
144 147
        });
145 148
    }
......
154 157
                        selectedTaxonRelUuid,
155 158
                        Action.Delete,
156 159
                        view.getDirection());
160
                setSelectedTaxonRelUuid(null);
157 161
            }
158 162
        });
159 163
    }
......
175 179
    }
176 180

  
177 181
    private void enableControls(boolean enabled) {
178
        newButton.setEnabled(enabled);
179
        editButton.setEnabled(enabled);
180
        deleteButton.setEnabled(enabled);
182
        CdmVaadinUtilities.setEnabled(this, enabled, Arrays.asList(d3ConceptRelationShipTree));
181 183
    }
182 184

  
183 185
    private void updateControls() {
......
200 202
            fromTaxonIun = (IdUuidName)event.getSelectedObjects().get(0);
201 203
            view.setPrimaryStatusCompositeUuid((UUID)event.getSelectedObjects().get(1));
202 204
            refreshRelationshipView(view.getDirection());
205
            setSelectedTaxonRelUuid(null);
203 206
            updateControls();
204 207
        }
205 208
    }
src/main/java/eu/etaxonomy/cdm/vaadin/component/EditConceptRelationshipComposite.java
339 339
                CdmVaadinUtilities.setEnabled(mainLayout, false, null);
340 340

  
341 341
                try {
342
                    CdmVaadinUtilities.exec(new CdmVaadinOperation(200, cdmProgressComponent) {
342
                    CdmVaadinUtilities.exec(new CdmVaadinOperation(1000, cdmProgressComponent) {
343 343
                        @Override
344 344
                        public boolean execute() {
345 345
                            UUID relTypeUuid = presenter.getTaxonRTypeContainer().getUuid(conceptRComboBox.getValue());
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java
156 156

  
157 157

  
158 158

  
159
    public void setClassification(String classification) {
160
        if(classification == null) {
161
            return;
162
        }
163
        Object selectedClassificationId = listener.getClassificationId(classification);
164
        if(selectedClassificationId == null) {
165
            Notification.show("Classification named " + classification + " does not exist.");
166
        } else {
167
            classificationComboBox.setValue(selectedClassificationId);
168
        }
169
    }
159 170

  
160 171
    public void init() {
161 172
        taxaTreeTable.setSelectable(true);
162

  
163 173
        initClassificationComboBox();
164 174
    }
165 175

  
......
168 178
    }
169 179

  
170 180

  
171
    public void setTaxaTableEnabled(boolean enabled) {
172
        taxaTreeTable.setEnabled(enabled);
173
    }
174

  
175
    public void setTaxaTableSelectable(boolean isTaxaTableSelectable) {
176
        taxaTreeTable.setSelectable(isTaxaTableSelectable);
177
    }
181
//    public void setTaxaTableEnabled(boolean enabled) {
182
//        taxaTreeTable.setEnabled(enabled);
183
//    }
184
//
185
//    public void setTaxaTableSelectable(boolean isTaxaTableSelectable) {
186
//        taxaTreeTable.setSelectable(isTaxaTableSelectable);
187
//    }
178 188

  
179 189
    public TreeTable getTaxaTreeTable() {
180 190
        return taxaTreeTable;
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenter.java
10 10
package eu.etaxonomy.cdm.vaadin.presenter;
11 11

  
12 12
import java.sql.SQLException;
13
import java.util.Collection;
13 14
import java.util.UUID;
14 15

  
16
import com.vaadin.data.util.filter.Compare;
17
import com.vaadin.data.util.filter.Compare.Equal;
18

  
15 19
import eu.etaxonomy.cdm.api.service.ITaxonService;
16 20
import eu.etaxonomy.cdm.model.common.CdmBase;
17 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
......
61 65
        return leafNodeTaxonContainer;
62 66
    }
63 67

  
68
    @Override
69
    public Object getClassificationId(String classification) {
70
        if(classification == null) {
71
            return null;
72
        }
73
        Equal cnameFilter = new Compare.Equal("titleCache", classification);
74
        classificationContainer.addContainerFilter(cnameFilter);
75
        Collection<?> itemIds = classificationContainer.getItemIds();
76
        Object itemId = null;
77
        if(!itemIds.isEmpty()) {
78
            itemId = itemIds.iterator().next();
79
        }
80
        classificationContainer.removeContainerFilter(cnameFilter);
81
        return itemId;
82
    }
83

  
64 84
    @Override
65 85
    public void refresh() {
66 86
        leafNodeTaxonContainer.refresh();
src/main/java/eu/etaxonomy/cdm/vaadin/ui/AbstractAuthenticatedUI.java
43 43
        // Create and register the views
44 44
        Authentication authentication = (Authentication) VaadinSession.getCurrent().getAttribute("authentication");
45 45

  
46
        doInit();
46
        doInit(request);
47 47

  
48 48
        if(ignoreAuthentication || (authentication != null && authentication.isAuthenticated())) {
49 49
        	UI.getCurrent().getNavigator().navigateTo(getFirstViewName());
......
52 52
        }
53 53
	}
54 54

  
55
	protected abstract void doInit();
55
	protected abstract void doInit(VaadinRequest request);
56 56

  
57 57
	public abstract String getFirstViewName();
58 58

  
src/main/java/eu/etaxonomy/cdm/vaadin/ui/ConceptRelationshipUI.java
9 9
*/
10 10
package eu.etaxonomy.cdm.vaadin.ui;
11 11

  
12
import java.util.logging.Logger;
13 12

  
14 13
import javax.servlet.annotation.WebServlet;
15 14

  
15
import org.apache.log4j.Logger;
16

  
16 17
import com.vaadin.annotations.Theme;
17 18
import com.vaadin.annotations.VaadinServletConfiguration;
18 19
import com.vaadin.navigator.Navigator;
20
import com.vaadin.server.VaadinRequest;
19 21
import com.vaadin.server.VaadinServlet;
20 22
import com.vaadin.ui.UI;
21 23

  
......
33 35

  
34 36
    private static final String FIRST_VIEW = "editcr";
35 37

  
36
    private final static Logger logger =
37
            Logger.getLogger(ConceptRelationshipUI.class.getName());
38
    private final static Logger logger = Logger.getLogger(ConceptRelationshipUI.class);
38 39

  
39 40
    @WebServlet(value = {"/app/editcr/*"}, asyncSupported = true)
40
    @VaadinServletConfiguration(productionMode = false, ui = ConceptRelationshipUI.class, widgetset = "eu.etaxonomy.cdm.vaadin.AppWidgetSet")
41
    @VaadinServletConfiguration(productionMode = true, ui = ConceptRelationshipUI.class, widgetset = "eu.etaxonomy.cdm.vaadin.AppWidgetSet")
41 42
    public static class Servlet extends VaadinServlet {
42 43
    }
43 44

  
44 45
    @Override
45
    protected void doInit() {
46
    protected void doInit(VaadinRequest request) {
46 47
        // FIXME: remove this when testing is done
47
        //setIgnoreAuthentication(true);
48
        setIgnoreAuthentication(true);
48 49

  
49 50
        getPage().setTitle("Concept Relationship Editor");
50
        ConceptRelationshipView crEditor = new ConceptRelationshipView();
51
        logger.warn("original classification : " + request.getParameter("oc"));
52
        logger.warn("copy classification : " + request.getParameter("cc"));
53
        String oc = request.getParameter("oc");
54
        String cc = request.getParameter("cc");
55

  
56
        ConceptRelationshipView crEditor = new ConceptRelationshipView(oc,cc);
51 57
        UI.getCurrent().getNavigator().addView(FIRST_VIEW, crEditor);
52 58

  
53 59
    }
src/main/java/eu/etaxonomy/cdm/vaadin/ui/DbStatusUI.java
6 6
import com.vaadin.annotations.Title;
7 7
import com.vaadin.annotations.VaadinServletConfiguration;
8 8
import com.vaadin.navigator.Navigator;
9
import com.vaadin.server.VaadinRequest;
9 10
import com.vaadin.ui.UI;
10 11

  
11 12
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.DistributionSelectionPresenter;
......
31 32

  
32 33

  
33 34
	@Override
34
	protected void doInit() {
35
	protected void doInit(VaadinRequest request) {
35 36
		Navigator navigator = UI.getCurrent().getNavigator();
36 37
		DistributionSelectionView dsv = new DistributionSelectionView();
37 38
		new DistributionSelectionPresenter(dsv);
src/main/java/eu/etaxonomy/cdm/vaadin/ui/StatusEditorUI.java
23 23
import com.vaadin.annotations.Theme;
24 24
import com.vaadin.annotations.VaadinServletConfiguration;
25 25
import com.vaadin.navigator.Navigator;
26
import com.vaadin.server.VaadinRequest;
26 27
import com.vaadin.server.VaadinServlet;
27 28
import com.vaadin.ui.UI;
28 29

  
......
46 47
    }
47 48

  
48 49
    @Override
49
    protected void doInit() {
50
    protected void doInit(VaadinRequest request) {
50 51
        // FIXME: remove this when testing is done
51 52
        //setIgnoreAuthentication(true);
52 53

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/ConceptRelationshipView.java
58 58
    private ConceptRelationshipComposite conceptRelationshipComposite;
59 59
    @AutoGenerated
60 60
    private StatusComposite statusCompositeLeft;
61

  
62 61
    private StatusComposite primaryStatusComposite, secondaryStatusComposite;
63 62

  
64 63
    private Direction direction;
......
69 68
     * The constructor will not be automatically regenerated by the
70 69
     * visual editor.
71 70
     */
72
    public ConceptRelationshipView() {
71
    public ConceptRelationshipView(String oc, String cc) {
73 72

  
74 73
        buildMainLayout();
75 74
        setCompositionRoot(mainLayout);
76 75

  
77 76
        conceptRelationshipComposite.setView(this);
78
        conceptRelationshipComposite.setSizeFull();
79

  
77
        //mainLayout.setSizeUndefined();
80 78
        setPrimaryStatusCompositeUuid(statusCompositeLeft.getSelectedClassificationUuid());
81 79
        direction = Direction.LEFT_RIGHT;
82 80
        CdmVaadinSessionUtilities.getCurrentBasicEventService().register(this);
83 81

  
82
        statusCompositeLeft.setClassification(oc);
83
        statusCompositeRight.setClassification(cc);
84

  
84 85
        initDropHandlers();
85 86
    }
86 87

  
......
123 124
    @Override
124 125
    public void onAction(BasicEvent event) {
125 126
        if(ConceptRelationshipComposite.UPDATE_START_ID.equals(event.getEventId())) {
126
            primaryStatusComposite.setTaxaTableEnabled(false);
127
            secondaryStatusComposite.setTaxaTableSelectable(false);
127
            primaryStatusComposite.getTaxaTreeTable().setEnabled(false);
128
            secondaryStatusComposite.getTaxaTreeTable().setSelectable(false);
128 129
        }
129 130
        if(ConceptRelationshipComposite.UPDATE_END_ID.equals(event.getEventId())) {
130
            primaryStatusComposite.setTaxaTableEnabled(true);
131
            secondaryStatusComposite.setTaxaTableSelectable(true);
131
            primaryStatusComposite.getTaxaTreeTable().setEnabled(true);
132
            secondaryStatusComposite.getTaxaTreeTable().setSelectable(true);
132 133
        }
133 134
    }
134 135

  
135
    @AutoGenerated
136
    private HorizontalLayout buildMainLayout() {
137
        // common part: create layout
138
        mainLayout = new HorizontalLayout();
139
        mainLayout.setImmediate(false);
140
        mainLayout.setWidth("100%");
141
        mainLayout.setHeight("100%");
142
        mainLayout.setMargin(true);
143

  
144
        // top-level component properties
145
        setWidth("100.0%");
146
        setHeight("100.0%");
147

  
148
        // statusCompositeLeft
149
        statusCompositeLeft = new StatusComposite();
150
        statusCompositeLeft.setImmediate(false);
151
        statusCompositeLeft.setWidth("-1px");
152
        statusCompositeLeft.setHeight("-1px");
153
        mainLayout.addComponent(statusCompositeLeft);
154

  
155
        // conceptRelationshipComposite
156
        conceptRelationshipComposite = new ConceptRelationshipComposite();
157
        conceptRelationshipComposite.setImmediate(false);
158
        conceptRelationshipComposite.setWidth("-1px");
159
        conceptRelationshipComposite.setHeight("-1px");
160
        mainLayout.addComponent(conceptRelationshipComposite);
161
        mainLayout.setExpandRatio(conceptRelationshipComposite, 1.0f);
162
        mainLayout.setComponentAlignment(conceptRelationshipComposite, new Alignment(20));
163

  
164
        // statusCompositeRight
165
        statusCompositeRight = new StatusComposite();
166
        statusCompositeRight.setImmediate(false);
167
        statusCompositeRight.setWidth("-1px");
168
        statusCompositeRight.setHeight("-1px");
169
        mainLayout.addComponent(statusCompositeRight);
170

  
171
        return mainLayout;
172
    }
173

  
174 136
    private class ConceptRelationshipDropHandler implements DropHandler {
175 137

  
176 138
        private StatusComposite sourceSc;
......
234 196
        }
235 197

  
236 198
    }
199

  
200
    @AutoGenerated
201
    private HorizontalLayout buildMainLayout() {
202
        // common part: create layout
203
        mainLayout = new HorizontalLayout();
204
        mainLayout.setImmediate(false);
205
        mainLayout.setWidth("100%");
206
        mainLayout.setHeight("100%");
207
        mainLayout.setMargin(true);
208

  
209
        // top-level component properties
210
        setWidth("100.0%");
211
        setHeight("100.0%");
212

  
213
        // statusCompositeLeft
214
        statusCompositeLeft = new StatusComposite();
215
        statusCompositeLeft.setImmediate(false);
216
        statusCompositeLeft.setWidth("-1px");
217
        statusCompositeLeft.setHeight("-1px");
218
        mainLayout.addComponent(statusCompositeLeft);
219

  
220
        // conceptRelationshipComposite
221
        conceptRelationshipComposite = new ConceptRelationshipComposite();
222
        conceptRelationshipComposite.setImmediate(false);
223
        conceptRelationshipComposite.setWidth("-1px");
224
        conceptRelationshipComposite.setHeight("-1px");
225
        mainLayout.addComponent(conceptRelationshipComposite);
226
        mainLayout.setExpandRatio(conceptRelationshipComposite, 1.0f);
227
        mainLayout.setComponentAlignment(conceptRelationshipComposite, new Alignment(20));
228

  
229
        // statusCompositeRight
230
        statusCompositeRight = new StatusComposite();
231
        statusCompositeRight.setImmediate(false);
232
        statusCompositeRight.setWidth("-1px");
233
        statusCompositeRight.setHeight("-1px");
234
        mainLayout.addComponent(statusCompositeRight);
235

  
236
        return mainLayout;
237
    }
237 238
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/IStatusComposite.java
106 106
         *
107 107
         */
108 108
        public void refreshSynonymCache();
109

  
110
        /**
111
         * @param classification
112
         * @return
113
         */
114
        public Object getClassificationId(String classification);
109 115
    }
110 116

  
111 117
    public void setListener(StatusComponentListener listener);
src/main/resources/eu/etaxonomy/cdm/vaadin/jscomponent/lib/d3.conceptrelationshiptree_connector.js
8 8
    var connector = this;
9 9
    var diagramElement = connector.getElement();
10 10
    var margin = {top: 20, right: 120, bottom: 20, left: 120},
11
    width = 960 - margin.right - margin.left,
12
    height = 800 - margin.top - margin.bottom;
11
    width = 740 - margin.right - margin.left,
12
    height = 600 - margin.top - margin.bottom;
13 13

  
14 14
    var i = 0,
15 15
    duration = 750,
src/main/webapp/VAADIN/themes/edit/edit.scss
41 41

  
42 42
    .cr-arrow .v-icon {
43 43
        color: #006666;
44
        font-size: 40px;
44
        font-size: 30px;
45 45
    }
46 46

  
47 47
}
src/main/webapp/VAADIN/themes/edit/styles.css
5899 5899

  
5900 5900
.edit .cr-arrow .v-icon {
5901 5901
	color: #006666;
5902
	font-size: 40px;
5902
	font-size: 30px;
5903 5903
}
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenterTest.java
95 95
        Assert.assertFalse(pb);
96 96
    }
97 97

  
98
    @Test
99
    public void testGetClassificationId() throws SQLException {
100
        CdmSQLContainer container = sp.loadClassifications();
101
        Object classificationId = sp.getClassificationId("Classification1");
102
        Assert.assertEquals("11", classificationId.toString());
103
        classificationId = sp.getClassificationId("ClassificationDoesNotExist");
104
        Assert.assertNull(classificationId);
105
    }
106

  
98 107
    @Ignore
99 108
    @Test
100 109
    public void testLoadClassifications() throws SQLException {
src/test/java/eu/etaxonomy/cdm/vaadin/ui/NavigatorTestUI.java
7 7
import com.vaadin.annotations.Theme;
8 8
import com.vaadin.annotations.VaadinServletConfiguration;
9 9
import com.vaadin.navigator.Navigator;
10
import com.vaadin.server.VaadinRequest;
10 11
import com.vaadin.ui.UI;
11 12

  
12 13
import eu.etaxonomy.cdm.vaadin.servlet.CdmVaadinConversationalServlet;
......
30 31
	}
31 32

  
32 33
	@Override
33
	protected void doInit() {
34
	protected void doInit(VaadinRequest request) {
34 35
		getPage().setTitle("Navigation Example");
35 36
		NaviTestView ntv1 = new NaviTestView();
36 37
		ntv1.setText("Congratulations! you have reached the first view. If you have got here without logging in there we are in trouble :)");

Also available in: Unified diff