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