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 | 126 |
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 | *******************************************************************************/ | ||
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 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 | } | ||