Project

General

Profile

Revision b6b0c782

IDb6b0c782e20bc2a98510f2a59338e1a34b843519
Parent 3f0054fb
Child 2db3b81b

Added by Patrick Plitzner almost 3 years ago

ref #6595 Enhance selection propagation for name editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractGroupedContainerE4.java
554 554
		}
555 555
	}
556 556

  
557
	private boolean isExecuting = false;
557
	private Delay delay = new Delay(Display.getCurrent());
558

  
559
	private class Delay extends Thread{
560

  
561
	    private volatile boolean stop = false;
562
        private Display display;
563

  
564
        public Delay(Display display) {
565
            this.display = display;
566
        }
567
        @Override
568
        public void run() {
569

  
570
            while (!stop) {
571
                try {
572
                    // my code goes here
573
                    Thread.sleep(1000);
574
                    if(!stop){
575
                        display.syncExec(new Runnable() {
576
                            @Override
577
                            public void run() {
578
                                getEditor().getManagedForm().setInput(selection);
579
                            }
580
                        });
581
                    }
582
                } catch (InterruptedException ex) {
583
                    stop = true;
584
                }
585
            }
586
        }
587
        public void requestStop() {
588
            stop = true;
589
        }
590
	}
558 591

  
559 592
	protected void setDelayedSelection() {
560
		// TODO this might be done better
561
		// this is the quickest solution i could come up with and it improves
562
		// performance
563
		// please reimplement if you know better.
564 593
		selection = this;
565 594

  
566
		// start timer
567 595
		Display display = Display.getCurrent();
568
		Runnable runnable = new Runnable() {
569 596

  
570
			@Override
571
            public void run() {
572
				getEditor().getManagedForm().setInput(selection);
573
				isExecuting = false;
574
			}
575
		};
576
		if(!isExecuting){
577
		    isExecuting = true;
578
		    display.timerExec(1000, runnable);
579
		}
597
		delay.requestStop();
598
		delay = new Delay(display);
599
		delay.start();
580 600

  
581 601
	}
582 602

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)