Project

General

Profile

Download (1.22 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.gef.editparts;
12

    
13
import org.eclipse.draw2d.IFigure;
14
import org.eclipse.draw2d.Viewport;
15

    
16
import org.eclipse.gef.GraphicalEditPart;
17

    
18
/**
19
 * @author hudsonr
20
 */
21
abstract class ViewportHelper {
22

    
23
	protected GraphicalEditPart owner;
24

    
25
	protected ViewportHelper(GraphicalEditPart owner) {
26
		this.owner = owner;
27
	}
28

    
29
	protected Viewport findViewport(GraphicalEditPart part) {
30
		IFigure figure = null;
31
		Viewport port = null;
32
		do {
33
			if (figure == null)
34
				figure = part.getContentPane();
35
			else
36
				figure = figure.getParent();
37
			if (figure instanceof Viewport) {
38
				port = (Viewport) figure;
39
				break;
40
			}
41
		} while (figure != part.getFigure() && figure != null);
42
		return port;
43
	}
44

    
45
}
(17-17/21)