1
/********************************************************************************
2
* Copyright (c) 2009 Motorola Inc. All rights reserved.
3
* This program and the accompanying materials are made available under the terms
4
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
5
* available at http://www.eclipse.org/legal/epl-v10.html
8
* Otavio Ferranti (Motorola)
11
* {Name} (company) - description of contribution.
12
********************************************************************************/
14
package org.eclipse.linuxtools.sequoyah.device.tools.cpuload;
16
import org.eclipse.jface.dialogs.TitleAreaDialog;
17
import org.eclipse.linuxtools.sequoyah.device.tools.ITool;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Spinner;
29
* @author Otavio Ferranti
31
public class DialogOptions extends TitleAreaDialog {
33
final private String WINDOW_TITLE = Messages.OptionsDialog_Window_Title;
34
final private String WINDOW_MESSAGE = Messages.OptionsDialog_Window_Message;
35
final private String LABEL_REFRESH = Messages.OptionsDialog_Label_Refresh_Rate;
36
final private String LABEL_TIMEUNIT = "ms"; //$NON-NLS-1$
38
private Spinner spinner;
40
private ITool tool = null;
46
public DialogOptions(Shell parent, ITool tool) {
52
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
54
protected Control createDialogArea(Composite parent) {
55
setTitle(WINDOW_TITLE);
56
setMessage(WINDOW_MESSAGE);
58
Composite dialogArea = new Composite(parent, SWT.NONE);
59
GridLayout gridLayout = new GridLayout(3, false);
61
gridLayout.marginLeft = 7;
62
gridLayout.marginRight = 7;
64
dialogArea.setLayout(gridLayout);
65
dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
66
dialogArea.setFont(parent.getFont());
68
Label refreshLabel = new Label(dialogArea, SWT.NULL);
69
refreshLabel.setText(LABEL_REFRESH);
71
spinner = new Spinner(dialogArea, SWT.BORDER);
73
Label timeUnit = new Label(dialogArea, SWT.NULL);
74
timeUnit.setText(LABEL_TIMEUNIT);
76
spinner.setMinimum(0);
77
spinner.setMaximum(50000);
78
spinner.setSelection(tool.getRefreshDelay());
79
spinner.setIncrement(100);
80
spinner.setPageIncrement(500);
88
* @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
90
protected Point getInitialSize() {
91
return super.getInitialSize();
95
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
97
protected void okPressed() {
98
tool.setRefreshDelay(spinner.getSelection());
103
* @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
105
protected void cancelPressed() {
106
super.cancelPressed();