summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java')
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java
new file mode 100644
index 0000000..5fb258e
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java
@@ -0,0 +1,126 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel 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
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.remotetools.actions;
12
13import org.eclipse.jface.dialogs.IDialogConstants;
14import org.eclipse.jface.dialogs.IDialogSettings;
15import org.eclipse.swt.SWT;
16import org.eclipse.swt.events.ModifyEvent;
17import org.eclipse.swt.events.ModifyListener;
18import org.eclipse.swt.layout.GridData;
19import org.eclipse.swt.layout.GridLayout;
20import org.eclipse.swt.widgets.Button;
21import org.eclipse.swt.widgets.Composite;
22import org.eclipse.swt.widgets.Control;
23import org.eclipse.swt.widgets.Label;
24import org.eclipse.swt.widgets.Shell;
25import org.eclipse.swt.widgets.Text;
26import org.yocto.sdk.remotetools.Activator;
27import org.yocto.sdk.remotetools.Messages;
28import org.yocto.sdk.remotetools.SWTFactory;
29
30public class PowertopSettingDialog extends BaseSettingDialog {
31
32 static protected String TITLE="Powertop";
33
34 protected boolean showPid=false;
35 protected Float time;
36 protected Text timeText;
37
38 protected PowertopSettingDialog(Shell parentShell, String title, String conn) {
39 super(parentShell,title,conn);
40 }
41
42 public PowertopSettingDialog(Shell parentShell) {
43 this(parentShell,
44 TITLE,
45 Activator.getDefault().getDialogSettings().get(IBaseConstants.CONNECTION_NAME_POWERTOP)
46 );
47 }
48
49 public Float getTime() {
50 return time;
51 }
52
53 @Override
54 protected Control createDialogArea(Composite parent) {
55 Composite comp=(Composite)super.createDialogArea(parent);
56 GridLayout topLayout = new GridLayout();
57 comp.setLayout(topLayout);
58
59 /*argument*/
60 SWTFactory.createVerticalSpacer(comp, 1);
61 createInternal(comp);
62
63 updateOkButton();
64 return comp;
65 }
66
67 protected void createInternal(Composite parent)
68 {
69 Composite projComp = new Composite(parent, SWT.NONE);
70 GridLayout projLayout = new GridLayout();
71 projLayout.numColumns = 4;
72 projLayout.marginHeight = 0;
73 projLayout.marginWidth = 0;
74 projComp.setLayout(projLayout);
75 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
76 projComp.setLayoutData(gd);
77
78 Label label = new Label(projComp, SWT.NONE);
79 label.setText(Messages.Powertop_Time_Text);
80 gd = new GridData();
81 gd.horizontalSpan = 1;
82 label.setLayoutData(gd);
83
84 timeText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
85 timeText.setText("5");
86 timeText.addModifyListener(new ModifyListener() {
87 public void modifyText(ModifyEvent e) {
88 updateOkButton();
89 }
90 });
91 gd = new GridData(GridData.FILL_HORIZONTAL);
92 gd.horizontalSpan = 3;
93 timeText.setLayoutData(gd);
94 }
95
96 @Override
97 protected boolean updateOkButton() {
98 boolean ret=super.updateOkButton();
99 if(ret==true) {
100 try {
101 Float.valueOf(timeText.getText());
102 }catch (Exception e) {
103 Button button=getButton(IDialogConstants.OK_ID);
104 if(button!=null)
105 button.setEnabled(false);
106 ret=false;
107 }
108 }
109 return ret;
110 }
111
112 @Override
113 protected void okPressed() {
114 IDialogSettings settings = Activator.getDefault().getDialogSettings();
115 // store the value of the generate sections checkbox
116 if(getCurrentConnection()==null) {
117 settings.put(IBaseConstants.CONNECTION_NAME_POWERTOP,
118 (String)null);
119 }else {
120 settings.put(IBaseConstants.CONNECTION_NAME_POWERTOP,
121 getCurrentConnection().getAliasName());
122 }
123 time=new Float(timeText.getText());
124 super.okPressed();
125 }
126}