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
|
/*******************************************************************************
* Copyright (c) 2000, 2015 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.help.internal.webapp.data;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
/**
* This class calls eclipse API's directly, so it should only be instantiated in
* the workbench scenario, not in the infocenter.
*/
public class ToolbarButton {
private String name;
private String tooltip;
private String image;
private String action;
private String param;
private String styleClass;
private boolean state;
private boolean isSeparator;
public ToolbarButton() {
isSeparator = true;
}
public ToolbarButton(String name, String tooltip, String image,
String action, String param, String state) {
this.name = name;
this.tooltip = tooltip;
this.image = image;
this.action = action;
this.param = param;
this.state = state.equalsIgnoreCase("on")?true:false; //$NON-NLS-1$
if (state.startsWith("hid")) //$NON-NLS-1$
this.styleClass = "buttonHidden"; //$NON-NLS-1$
else if ("menu".equals(action)) { //$NON-NLS-1$
this.styleClass = "buttonMenu"; //$NON-NLS-1$
}
else
this.styleClass = state.equalsIgnoreCase("on")?"buttonOn":"button"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
}
public boolean isSeparator() {
return isSeparator;
}
public boolean isMenu() {
return "menu".equals(action); //$NON-NLS-1$
}
public String getName() {
return name;
}
public String[][] getMenuData() {
List<String[]> list = new ArrayList<String[]>();
StringTokenizer tok = new StringTokenizer(param, ","); //$NON-NLS-1$
while(tok.hasMoreTokens()) {
String token = tok.nextToken();
int index = token.indexOf('=');
list.add(new String[] { token.substring(0, index), token.substring(index + 1) });
}
return list.toArray(new String[list.size()][]);
}
public String getTooltip() {
return tooltip;
}
/**
* Returns the image
*
* @return String
*/
public String getImage() {
return image;
}
public String getAction() {
return action;
}
public String getParam() {
return param;
}
public boolean isOn() {
return state;
}
public String getStyleClass() {
return styleClass;
}
}
|