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
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*******************************************************************************
* 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.model.property.editor.presentation;
import org.eclipse.wb.internal.core.DesignerPlugin;
import org.eclipse.wb.internal.core.EnvironmentUtils;
import org.eclipse.wb.internal.core.model.property.Property;
import org.eclipse.wb.internal.core.model.property.table.PropertyTable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
/**
* Implementation of {@link PropertyEditorPresentation} for displaying {@link Button}.
*
* @author scheglov_ke
* @author mitin_aa
* @coverage core.model.property.editor
*/
public abstract class ButtonPropertyEditorPresentation extends PropertyEditorPresentation {
private final int m_style;
private final ButtonPropertyEditorPresentationImpl m_impl;
////////////////////////////////////////////////////////////////////////////
//
// Constructors
//
////////////////////////////////////////////////////////////////////////////
public ButtonPropertyEditorPresentation() {
this(SWT.NONE);
}
public ButtonPropertyEditorPresentation(int style) {
m_style = style;
m_impl =
EnvironmentUtils.IS_MAC
? new ButtonPropertyEditorPresentationImplMac(this)
: new ButtonPropertyEditorPresentationImpl(this);
}
////////////////////////////////////////////////////////////////////////////
//
// Access
//
////////////////////////////////////////////////////////////////////////////
/**
* Sets "selection" property of {@link Button}.
*/
public final void setSelection(PropertyTable propertyTable, Property property, boolean selected) {
m_impl.setSelection(propertyTable, property, selected);
}
////////////////////////////////////////////////////////////////////////////
//
// PropertyEditorPresentation
//
////////////////////////////////////////////////////////////////////////////
@Override
public final int show(final PropertyTable propertyTable,
final Property property,
final int x,
final int y,
final int width,
final int height) {
return m_impl.show(propertyTable, property, x, y, width, height);
}
@Override
public final void hide(PropertyTable propertyTable, Property property) {
m_impl.hide(propertyTable, property);
}
////////////////////////////////////////////////////////////////////////////
//
// Access
//
////////////////////////////////////////////////////////////////////////////
final int getStyle() {
return m_style;
}
////////////////////////////////////////////////////////////////////////////
//
// Implementation
//
////////////////////////////////////////////////////////////////////////////
/**
* @return the {@link Image} to display on {@link Button}.
*/
protected Image getImage() {
return DesignerPlugin.getImage("properties/dots.gif");
}
/**
* @return the tooltip text to display for {@link Button}.
*/
protected String getTooltip() {
return null;
}
/**
* Handles click on {@link Button}.
*/
protected abstract void onClick(PropertyTable propertyTable, Property property) throws Exception;
}
|