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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation.
* 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 - Anithra P J
*******************************************************************************/
package org.eclipse.linuxtools.systemtap.ui.dashboardextension.dialogs;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.linuxtools.systemtap.ui.dashboard.internal.DashboardPlugin;
import org.eclipse.linuxtools.systemtap.ui.dashboard.preferences.DashboardPreferenceConstants;
public class ScriptDetails extends Dialog {
private Text dirText;
private Text scriptText;
private Button OKButton;
private Button cancelButton;
private boolean canceled = true;
public ScriptDetails(Shell parent) {
super(parent);
}
/**
* This allows outside classes to determine if the user clicked ok or cancel.
* @return boolean representing whether the cancel button was pressed or not
*/
public boolean isCanceled() {
return canceled;
}
public void open() {
Shell parent = getParent();
final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("Enter Script details");
shell.setSize(350, 160);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
shell.setLayout(layout);
GridData data = new GridData();
data.grabExcessHorizontalSpace = false;
data.horizontalAlignment = SWT.LEFT;
Label dirLabel = new Label(shell, SWT.NONE);
dirLabel.setText("Examples Dir: ");
dirLabel.setLayoutData(data);
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = SWT.FILL;
dirText = new Text(shell, SWT.SINGLE | SWT.BORDER);
dirText.setLayoutData(data);
dirText.setText(DashboardPlugin.getDefault().getPluginPreferences().getString(DashboardPreferenceConstants.P_DASHBOARD_EXAMPLES_DIR));
data = new GridData();
data.grabExcessHorizontalSpace = false;
data.horizontalAlignment = SWT.LEFT;
Label scriptLabel = new Label(shell, SWT.NONE);
scriptLabel.setText("Script: ");
scriptLabel.setLayoutData(data);
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = SWT.FILL;
scriptText = new Text(shell, SWT.SINGLE | SWT.BORDER);
scriptText.setLayoutData(data);
//scriptText.setText(ConsoleLogPlugin.getDefault().getPluginPreferences().getString(ConsoleLogPreferenceConstants.SCP_PASSWORD));
data = new GridData();
data.horizontalAlignment = SWT.RIGHT;
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setLayoutData(data);
cancelButton.setSize(50, 100);
cancelButton.setText("Cancel");
cancelButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
shell.dispose();
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
data = new GridData();
data.horizontalAlignment = SWT.RIGHT;
OKButton = new Button(shell, SWT.PUSH);
OKButton.setLayoutData(data);
OKButton.setSize(50, 100);
OKButton.setText("OK");
OKButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
// FIXME: no error handling is done, should probably be
// pushed down to the connection level
// Set the preferences to this new info.
DashboardPlugin.getDefault().getPreferenceStore().setValue(DashboardPreferenceConstants.P_DASHBOARD_EXAMPLES_DIR, dirText.getText());
DashboardPlugin.getDefault().getPreferenceStore().setValue(DashboardPreferenceConstants.P_DASHBOARD_SCRIPT, scriptText.getText());
canceled = false;
shell.close();
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
}
|