Project

General

Profile

Revision 450785be

ID450785be8803f4d8688bf8044dd84201410884b8
Parent fc53e2e8
Child c31b09a1

Added by Fabian Reimeier about 3 years ago

ref #6903 initialize layout and click listener just once and refactoring

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTableViewBean.java
45 45
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
46 46
import eu.etaxonomy.cdm.vaadin.container.PresenceAbsenceTermContainer;
47 47
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
48
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
48 49
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
49 50
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
50 51
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
......
71 72
	private Grid grid;
72 73

  
73 74
    private CdmSQLContainer container;
74
	private AreaAndTaxonSettingsConfigWindow distributionSettingConfigWindow;
75
	private AreaAndTaxonSettingsConfigWindow areaAndTaxonConfigWindow;;
76
	private DistributionStatusSettingsConfigWindow distributionStatusConfigWindow;
75 77

  
76 78
	public DistributionTableViewBean() {
77 79
		super();
......
255 257
     */
256 258
	@Override
257 259
	public void openStatusSettings() {
258
		DistributionStatusSettingsConfigWindow cw = new DistributionStatusSettingsConfigWindow(this);
259
		Window window  = cw.createWindow("Status");
260
		UI.getCurrent().addWindow(window);
260
        if(distributionStatusConfigWindow==null){
261
            distributionStatusConfigWindow = new DistributionStatusSettingsConfigWindow(this);
262
        }
263
        Window window  = distributionStatusConfigWindow.createWindow("Status");
264
        UI.getCurrent().addWindow(window);
261 265
	}
262 266

  
263 267
    /**
......
265 269
     */
266 270
	@Override
267 271
	public void openAreaAndTaxonSettings() {
268
		if(distributionSettingConfigWindow==null){
269
			distributionSettingConfigWindow = new AreaAndTaxonSettingsConfigWindow(this);
272
		if(areaAndTaxonConfigWindow==null){
273
			areaAndTaxonConfigWindow = new AreaAndTaxonSettingsConfigWindow(this);
270 274
		}
271
        Window window  = distributionSettingConfigWindow.createWindow("Areas and Taxa");
275
        Window window  = areaAndTaxonConfigWindow.createWindow("Areas and Taxa");
272 276
        UI.getCurrent().addWindow(window);
273 277
	}
274 278

  
......
313 317
     */
314 318
	@Override
315 319
	protected void initContent() {
316
		AbsoluteLayout mainLayout = initLayout();
317
		setCompositionRoot(mainLayout);
318
		createEditClickListener();
320
	    /*
321
	     * This method is called twice. One time before and one time after login.
322
	     * Initializing the layout and click listeners twice is unnecessary and produces
323
	     * strange behavior (e.g. one click on settings-button opens settings-window several times),
324
	     * so we check for user authentication first.
325
	     */
326
	    if(UserHelper.fromSession().userIsAutheticated() && !UserHelper.fromSession().userIsAnnonymous()) {
327
	        AbsoluteLayout mainLayout = initLayout();
328
    		setCompositionRoot(mainLayout);
329
    		createEditClickListener();
330
	    }
319 331
	}
320 332
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)