Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 264587 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/diagram/ui/internal/figures/BorderItemContainerFigure.java (-22 / +72 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-25 Link Here
11
11
12
package org.eclipse.gmf.runtime.diagram.ui.internal.figures;
12
package org.eclipse.gmf.runtime.diagram.ui.internal.figures;
13
13
14
import java.util.Iterator;
14
import java.util.List;
15
import java.util.ListIterator;
15
import java.util.ListIterator;
16
16
17
import org.eclipse.draw2d.Figure;
18
import org.eclipse.draw2d.FigureListener;
17
import org.eclipse.draw2d.FigureListener;
19
import org.eclipse.draw2d.Graphics;
18
import org.eclipse.draw2d.Graphics;
19
import org.eclipse.draw2d.GraphicsSource;
20
import org.eclipse.draw2d.IFigure;
20
import org.eclipse.draw2d.IFigure;
21
import org.eclipse.draw2d.ScalableFreeformLayeredPane;
21
import org.eclipse.draw2d.ScalableFreeformLayeredPane;
22
import org.eclipse.draw2d.TreeSearch;
22
import org.eclipse.draw2d.TreeSearch;
23
import org.eclipse.draw2d.UpdateManager;
23
import org.eclipse.draw2d.Viewport;
24
import org.eclipse.draw2d.Viewport;
24
import org.eclipse.draw2d.geometry.Point;
25
import org.eclipse.draw2d.geometry.Point;
25
import org.eclipse.draw2d.geometry.Rectangle;
26
import org.eclipse.draw2d.geometry.Rectangle;
Lines 50-55 Link Here
50
    
51
    
51
    private BorderItemContainerHelper helper = new BorderItemContainerHelper();
52
    private BorderItemContainerHelper helper = new BorderItemContainerHelper();
52
    
53
    
54
	private BorderedItemContainerUpdateManagerWrapper updateManagerWrapper = new BorderedItemContainerUpdateManagerWrapper();
55
    
53
	/**
56
	/**
54
	 * Constructor
57
	 * Constructor
55
	 */
58
	 */
Lines 313-323 Link Here
313
	}
316
	}
314
317
315
	public void erase() {
318
	public void erase() {
316
		if (getChildren().isEmpty()) {
319
		if (getParent() != null && isVisible()) {
317
			super.erase();
318
		} else {
319
			if (getParent() == null || !isVisible())
320
				return;
321
			repaint();
320
			repaint();
322
		}
321
		}
323
	}
322
	}
Lines 326-342 Link Here
326
	 * Refresh adornments
325
	 * Refresh adornments
327
	 */
326
	 */
328
	public void repaint() {
327
	public void repaint() {
329
		if (getChildren().isEmpty()) {
328
		repaint(getExtendedBounds());
330
			super.repaint();
331
		} else {
332
			if (getParent() == null || !isVisible())
333
				return;
334
			Rectangle rectBounds = getExtendedBounds();
335
			getParent().getParent().repaint(rectBounds);
336
			if (getViewport() != null) {
337
				getViewport().repaint(rectBounds);
338
			}
339
		}
340
	}
329
	}
341
    
330
    
342
    public void invalidate() {
331
    public void invalidate() {
Lines 350-355 Link Here
350
        super.validate();
339
        super.validate();
351
    }
340
    }
352
    
341
    
342
	@Override
343
	public UpdateManager getUpdateManager() {
344
		if (getParent() != null) {
345
			return updateManagerWrapper;
346
		}
347
		return super.getUpdateManager();
348
	}
349
353
    /**
350
    /**
354
     * Gets the extended bounds of the figure which includes the bounds of all
351
     * Gets the extended bounds of the figure which includes the bounds of all
355
     * the border item figures.
352
     * the border item figures.
Lines 359-367 Link Here
359
    public Rectangle getExtendedBounds() {
356
    public Rectangle getExtendedBounds() {
360
        if (extendedBounds == null) {
357
        if (extendedBounds == null) {
361
            extendedBounds = getParent().getBounds().getCopy();
358
            extendedBounds = getParent().getBounds().getCopy();
362
            Iterator iterator = getChildren().iterator();
359
            for (IFigure childFigure : (List<IFigure>) getChildren()) {
363
            while (iterator.hasNext()) {
364
                Figure childFigure = (Figure) iterator.next();
365
                Rectangle childBounds = (childFigure instanceof IExpandableFigure) ? ((IExpandableFigure) childFigure)
360
                Rectangle childBounds = (childFigure instanceof IExpandableFigure) ? ((IExpandableFigure) childFigure)
366
                    .getExtendedBounds()
361
                    .getExtendedBounds()
367
                    : childFigure.getBounds(); 
362
                    : childFigure.getBounds(); 
Lines 430-433 Link Here
430
    	
425
    	
431
    }
426
    }
432
    
427
    
428
    private class BorderedItemContainerUpdateManagerWrapper extends UpdateManager {
429
    	
430
    	public BorderedItemContainerUpdateManagerWrapper() {
431
    	}
432
433
		@Override
434
		public void setGraphicsSource(GraphicsSource gs) {
435
			BorderItemContainerFigure.this.getParent().getUpdateManager().setGraphicsSource(gs);
436
		}
437
438
		@Override
439
		public synchronized void addDirtyRegion(IFigure figure, int x, int y,
440
				int w, int h) {
441
			Rectangle r = new Rectangle(x, y, w, h);
442
			IFigure borderedNodeParent = BorderItemContainerFigure.this.getParent().getParent();
443
			IFigure walker = figure;
444
			do {
445
				walker = walker.getParent();
446
				walker.translateToParent(r);
447
			} while (walker != borderedNodeParent && walker.getParent() != null);
448
			walker.getUpdateManager().addDirtyRegion(walker, r.x, r.y, r.width, r.height);
449
		}
450
451
		@Override
452
		public synchronized void addInvalidFigure(IFigure f) {
453
			BorderItemContainerFigure.this.getParent().getUpdateManager().addInvalidFigure(f);
454
		}
455
456
		@Override
457
		public synchronized void performUpdate() {
458
			BorderItemContainerFigure.this.getParent().getUpdateManager().performUpdate();
459
		}
460
461
		@Override
462
		public synchronized void performUpdate(Rectangle exposed) {
463
			BorderItemContainerFigure.this.getParent().getUpdateManager().performUpdate(exposed);
464
		}
465
466
		@Override
467
		public void performValidation() {
468
			BorderItemContainerFigure.this.getParent().getUpdateManager().performValidation();
469
		}
470
471
		@Override
472
		public synchronized void runWithUpdate(Runnable runnable) {
473
			BorderItemContainerFigure.this.getParent().getUpdateManager().runWithUpdate(runnable);
474
		}
475
476
		@Override
477
		public void setRoot(IFigure figure) {
478
			BorderItemContainerFigure.this.getParent().getUpdateManager().setRoot(figure);
479
		}
480
481
    }
482
433
}
483
}

Return to bug 264587