blob: bc57360d16c014616909d06f66f4f7a58ba8fc92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.internal.core.editor.structure;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.wb.core.controls.CImageLabel;
import org.eclipse.wb.internal.core.utils.check.Assert;
import org.eclipse.wb.internal.core.utils.ui.GridDataFactory;
import org.eclipse.wb.internal.core.utils.ui.GridLayoutFactory;
/**
* The site {@link Composite} for {@link IPage}.
*
* @author scheglov_ke
* @coverage core.editor.structure
*/
public final class PageSiteComposite extends Composite {
private final CImageLabel m_title;
private final ToolBarManager m_toolBarManager;
private final ToolBar m_toolBar;
private IPage m_page;
////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public PageSiteComposite(Composite parent, int style) {
super(parent, style);
GridLayoutFactory.create(this).noMargins().spacingV(0).columns(2);
// title
{
m_title = new CImageLabel(this, SWT.NONE);
GridDataFactory.create(m_title).grabH().fill();
}
// toolbar
{
m_toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT);
GridDataFactory.create(m_toolBar).fill();
m_toolBarManager = new ToolBarManager(m_toolBar);
}
// separator
{
Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
GridDataFactory.create(separator).spanH(2).grabH().fillH();
}
}
////////////////////////////////////////////////////////////////////////////
//
// Access
//
////////////////////////////////////////////////////////////////////////////
/**
* Sets the {@link Image} for title;
*/
public void setTitleImage(Image image) {
m_title.setImage(image);
}
/**
* Sets the text for title.
*/
public void setTitleText(String title) {
m_title.setText(title);
}
/**
* Sets the {@link IPage} to display.
*/
public void setPage(IPage page) {
Assert.isNull(m_page);
Assert.isNotNull(page);
m_page = page;
// create Control
m_page.createControl(this);
GridDataFactory.create(m_page.getControl()).spanH(2).grab().fill();
// set toolbar
m_page.setToolBar(m_toolBarManager);
}
// BEGIN ADT MODIFICATIONS
public ToolBar getToolBar() {
return m_toolBar;
}
// END ADT MODIFICATIONS
}
|