Project

General

Profile

Download (2.09 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2008, 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

    
12
package org.eclipse.gef.internal.ui.palette.editparts;
13

    
14
import org.eclipse.draw2d.Figure;
15
import org.eclipse.draw2d.Graphics;
16
import org.eclipse.draw2d.IFigure;
17
import org.eclipse.draw2d.MarginBorder;
18

    
19
import org.eclipse.gef.internal.ui.palette.PaletteColorUtil;
20
import org.eclipse.gef.palette.PaletteToolbar;
21
import org.eclipse.gef.ui.palette.PaletteViewerPreferences;
22

    
23
/**
24
 * An editpart for the <code>PaletteToolbar</code>.
25
 * 
26
 * @author crevells
27
 * @since 3.4
28
 */
29
public class ToolbarEditPart extends GroupEditPart {
30

    
31
	/**
32
	 * Creates a new instance.
33
	 * 
34
	 * @param model
35
	 *            the <code>PaletteToolbar</code>
36
	 */
37
	public ToolbarEditPart(PaletteToolbar model) {
38
		super(model);
39
	}
40

    
41
	public IFigure createFigure() {
42
		IFigure figure = new Figure() {
43

    
44
			protected void paintFigure(Graphics graphics) {
45
				super.paintFigure(graphics);
46

    
47
				// draw top border
48
				graphics.setForegroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND);
49
				graphics.drawLine(getBounds().getTopLeft(), getBounds()
50
						.getTopRight());
51

    
52
				// draw bottom border
53
				graphics.setForegroundColor(PaletteColorUtil.WIDGET_BACKGROUND_NORMAL_SHADOW_70);
54
				graphics.drawLine(
55
						getBounds().getBottomLeft().getTranslated(0, -1),
56
						getBounds().getBottomRight().getTranslated(0, -1));
57
			}
58

    
59
		};
60
		figure.setOpaque(true);
61
		figure.setBackgroundColor(PaletteColorUtil.WIDGET_BACKGROUND);
62
		figure.setBorder(new MarginBorder(2, 1, 1, 1));
63

    
64
		return figure;
65
	}
66

    
67
	protected int getLayoutSetting() {
68
		return PaletteViewerPreferences.LAYOUT_ICONS;
69
	}
70

    
71
	public boolean isToolbarItem() {
72
		return true;
73
	}
74

    
75
}
(22-22/22)