1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
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
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.internal.systemtap.ui.ide.uistructures;
14
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
16
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
17
import org.eclipse.linuxtools.systemtap.ui.logging.LogManager;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.KeyEvent;
20
import org.eclipse.swt.events.KeyListener;
21
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.swt.widgets.Text;
30
import org.eclipse.swt.widgets.Label;
34
* A dialog box displayed to prompt the user for additional arguments to pass to stap when the
35
* user presses the Run with Options button.
39
public class StapSettingsDialog extends Dialog {
40
public StapSettingsDialog(Shell parentShell) {
42
LogManager.logDebug("Start/End StapSettingsDialog: parentShell-" + parentShell, this);
43
LogManager.logInfo("Initializing", this);
46
protected void configureShell(Shell shell) {
47
super.configureShell(shell);
48
LogManager.logDebug("Start configureShell: shell-" + shell, this);
49
shell.setText(Localization.getString("StapSettingsDialog.StapOptions"));
50
shell.setSize(new org.eclipse.swt.graphics.Point(640,170 + ((1+checkBox.length)>>1) + 50*((1+text.length)>>1)));
51
LogManager.logDebug("End configureShell:", this);
54
protected Control createDialogArea(Composite parent) {
55
LogManager.logDebug("Start createDialogArea: parent-" + parent, this);
56
Composite comp = (Composite) super.createDialogArea(parent);
59
GridLayout gridLayout = new GridLayout();
60
gridLayout.numColumns = 2;
61
cmpChkBoxes = new Composite(comp, SWT.NONE);
62
cmpChkBoxes.setLayout(gridLayout);
63
cmpChkBoxes.setBounds(new Rectangle(100,5,460,30*((1+checkBox.length)>>1)));
66
for(i=0; i<IDEPreferenceConstants.P_STAP.length - IDEPreferenceConstants.P_STAP_OPTS.length; i++) {
67
checkBox[i] = new Button(cmpChkBoxes, SWT.CHECK);
68
checkBox[i].setText(IDEPreferenceConstants.P_STAP[i][0] + IDEPreferenceConstants.P_STAP[i][1]);
69
checkBox[i].setBackground(cmpChkBoxes.getBackground());
72
//Labels and Text fields
73
cmpTxtBoxes = new Composite(comp, SWT.NONE);
74
cmpTxtBoxes.setBounds(new Rectangle(5,5+30*((1+checkBox.length)>>1),620,50*((1+text.length)>>1)));
76
for(int j=0; j<IDEPreferenceConstants.P_STAP_OPTS.length; i++, j++) {
77
label[j] = new Label(cmpTxtBoxes, SWT.NONE);
78
label[j].setBounds(new Rectangle(320*(j/5),50*(j%5),300,17));
79
label[j].setText(IDEPreferenceConstants.P_STAP[i][0] + IDEPreferenceConstants.P_STAP[i][1]);
80
label[j].setBackground(cmpChkBoxes.getBackground());
81
text[j] = new Text(cmpTxtBoxes, SWT.BORDER);
82
text[j].setBounds(new Rectangle(320*(j/5),20+50*(j%5),300,27));
84
if("-v".equals(IDEPreferenceConstants.P_STAP[i][0])) {
85
text[j].addKeyListener(new KeyListener() {
86
public void keyPressed(KeyEvent e) {
87
if('v' != e.character) {
92
public void keyReleased(KeyEvent e) {}
94
} else if("-p NUM".equals(IDEPreferenceConstants.P_STAP[i][0])) {
95
text[j].addKeyListener(new KeyListener() {
96
public void keyPressed(KeyEvent e) {
97
if(32 <= e.character && 126 >= e.character) {
98
if('1' > e.character || '5' < e.character)
100
else if(0 < text[1].getText().length())
105
public void keyReleased(KeyEvent e) {}
107
} else if("-s NUM".equals(IDEPreferenceConstants.P_STAP[i][0])) {
108
text[j].addKeyListener(new KeyListener() {
109
public void keyPressed(KeyEvent e) {
110
if(32 <= e.character && 126 >= e.character) {
111
if(!Character.isDigit(e.character))
116
public void keyReleased(KeyEvent e) {}
121
LogManager.logDebug("End createDialogArea: returnVal-" + comp, this);
125
protected void buttonPressed(int buttonID) {
126
LogManager.logDebug("Start buttonPressed: buttonID-" + buttonID, this);
127
if(0 == buttonID) { //OK
128
cmdOpts = new boolean[checkBox.length];
129
cmdOptVals = new String[text.length];
131
for(int i=0; i<cmdOpts.length; i++)
132
cmdOpts[i] = checkBox[i].getSelection();
134
for(int i=0; i<cmdOptVals.length; i++)
135
cmdOptVals[i] = text[i].getText();
138
super.buttonPressed(buttonID);
139
LogManager.logDebug("End buttonPressed:", this);
142
public boolean[] getStapOpts() {
143
LogManager.logDebug("Start/End getStapOpts: returnVal-" + cmdOpts, this);
147
public String[] getStapOptVals() {
148
LogManager.logDebug("Start/End getStapOptVals: returnVal-" + cmdOptVals, this);
152
public void dispose() {
153
LogManager.logInfo("Disposing", this);
156
cmpChkBoxes.dispose();
157
cmpTxtBoxes.dispose();
158
for(int i=0; i<checkBox.length; i++)
159
checkBox[i].dispose();
161
for(int i=0; i<label.length; i++) {
169
//private static String[] tapsets = null;
170
private static boolean[] cmdOpts = null;
171
private static String[] cmdOptVals = null;
173
private Composite cmpChkBoxes = null;
174
private Composite cmpTxtBoxes = null;
175
private Button checkBox[] = new Button[IDEPreferenceConstants.P_STAP.length - IDEPreferenceConstants.P_STAP_OPTS.length];
176
private Label label[] = new Label[IDEPreferenceConstants.P_STAP_OPTS.length];
177
private Text text[] = new Text[IDEPreferenceConstants.P_STAP_OPTS.length];
b'\\ No newline at end of file'