diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:36:50 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 15:25:03 +0100 |
commit | 41ac47d732eed8392d60d0f6773e5a279d49b999 (patch) | |
tree | cf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java | |
download | eclipse-poky-juno-41ac47d732eed8392d60d0f6773e5a279d49b999.tar.gz |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java')
-rw-r--r-- | plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java new file mode 100644 index 0000000..7845959 --- /dev/null +++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java | |||
@@ -0,0 +1,216 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2006, 2010 PalmSource, Inc. and others. | ||
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 | * Ewa Matejska (PalmSource) - initial API and implementation | ||
10 | * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry | ||
11 | * Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo | ||
12 | * Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded | ||
13 | * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code | ||
14 | * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path | ||
15 | * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement | ||
16 | * Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch | ||
17 | * Anna Dushistova (MontaVista) - [223728] [remotecdt] connection combo is not populated until RSE is activated | ||
18 | * Anna Dushistova (MontaVista) - [267951] [remotecdt] Support systemTypes without files subsystem | ||
19 | * Lianhao Lu (Intel) - Modified for internal use | ||
20 | *******************************************************************************/ | ||
21 | |||
22 | package org.yocto.sdk.remotetools.actions; | ||
23 | |||
24 | import org.yocto.remote.utils.RSEHelper; | ||
25 | import org.yocto.sdk.remotetools.Messages; | ||
26 | import org.yocto.sdk.remotetools.SWTFactory; | ||
27 | import org.eclipse.jface.dialogs.Dialog; | ||
28 | import org.eclipse.jface.dialogs.IDialogConstants; | ||
29 | import org.eclipse.rse.core.model.IHost; | ||
30 | import org.eclipse.rse.ui.actions.SystemNewConnectionAction; | ||
31 | import org.eclipse.swt.SWT; | ||
32 | import org.eclipse.swt.events.ModifyEvent; | ||
33 | import org.eclipse.swt.events.ModifyListener; | ||
34 | import org.eclipse.swt.events.SelectionAdapter; | ||
35 | import org.eclipse.swt.events.SelectionEvent; | ||
36 | import org.eclipse.swt.layout.GridData; | ||
37 | import org.eclipse.swt.layout.GridLayout; | ||
38 | import org.eclipse.swt.widgets.Button; | ||
39 | import org.eclipse.swt.widgets.Combo; | ||
40 | import org.eclipse.swt.widgets.Composite; | ||
41 | import org.eclipse.swt.widgets.Control; | ||
42 | import org.eclipse.swt.widgets.Label; | ||
43 | import org.eclipse.swt.widgets.Shell; | ||
44 | |||
45 | public class BaseSettingDialog extends Dialog { | ||
46 | |||
47 | protected String title; | ||
48 | protected String curConn; //current rse connection name | ||
49 | protected IHost conn;//rse IHost | ||
50 | |||
51 | protected Button newRemoteConnectionButton; | ||
52 | protected Label connectionLabel; | ||
53 | protected Combo connectionCombo; | ||
54 | protected SystemNewConnectionAction action = null; | ||
55 | |||
56 | |||
57 | protected BaseSettingDialog(Shell parentShell,String title, String connection) { | ||
58 | super(parentShell); | ||
59 | this.title=title; | ||
60 | this.curConn=connection; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | protected void configureShell(Shell newShell) { | ||
65 | super.configureShell(newShell); | ||
66 | newShell.setText(title); | ||
67 | } | ||
68 | |||
69 | @Override | ||
70 | protected Control createDialogArea(Composite parent) { | ||
71 | Composite comp = (Composite)super.createDialogArea(parent); | ||
72 | GridLayout topLayout = new GridLayout(); | ||
73 | comp.setLayout(topLayout); | ||
74 | |||
75 | /* The RSE Connection dropdown with New button. */ | ||
76 | SWTFactory.createVerticalSpacer(comp, 1); | ||
77 | createRemoteConnectionGroup(comp); | ||
78 | |||
79 | return comp; | ||
80 | } | ||
81 | |||
82 | |||
83 | @Override | ||
84 | protected void createButtonsForButtonBar(Composite parent) { | ||
85 | super.createButtonsForButtonBar(parent); | ||
86 | updateCurConn(); | ||
87 | } | ||
88 | |||
89 | protected void createRemoteConnectionGroup(Composite parent) { | ||
90 | Composite projComp = new Composite(parent, SWT.NONE); | ||
91 | GridLayout projLayout = new GridLayout(); | ||
92 | projLayout.numColumns = 6; | ||
93 | projLayout.marginHeight = 0; | ||
94 | projLayout.marginWidth = 0; | ||
95 | projComp.setLayout(projLayout); | ||
96 | GridData gd = new GridData(GridData.FILL_HORIZONTAL); | ||
97 | projComp.setLayoutData(gd); | ||
98 | |||
99 | connectionLabel = new Label(projComp, SWT.NONE); | ||
100 | connectionLabel.setText(Messages.BaseSettingDialog_Connection); | ||
101 | gd = new GridData(); | ||
102 | gd.horizontalSpan = 1; | ||
103 | connectionLabel.setLayoutData(gd); | ||
104 | |||
105 | connectionCombo = new Combo(projComp, SWT.DROP_DOWN | SWT.READ_ONLY); | ||
106 | gd = new GridData(GridData.FILL_HORIZONTAL); | ||
107 | gd.horizontalSpan = 4; | ||
108 | connectionCombo.setLayoutData(gd); | ||
109 | connectionCombo.addModifyListener(new ModifyListener() { | ||
110 | |||
111 | public void modifyText(ModifyEvent e) { | ||
112 | //setDirty(true); | ||
113 | //updateLaunchConfigurationDialog(); | ||
114 | //useDefaultsFromConnection(); | ||
115 | updateCurConn(); | ||
116 | } | ||
117 | }); | ||
118 | |||
119 | newRemoteConnectionButton = SWTFactory.createPushButton(projComp, | ||
120 | Messages.BaseSettingDialog_New, null); | ||
121 | newRemoteConnectionButton.addSelectionListener(new SelectionAdapter() { | ||
122 | |||
123 | public void widgetSelected(SelectionEvent evt) { | ||
124 | handleNewRemoteConnectionSelected(); | ||
125 | //updateLaunchConfigurationDialog(); | ||
126 | updateConnectionPulldown(); | ||
127 | } | ||
128 | }); | ||
129 | gd = new GridData(); | ||
130 | gd.horizontalSpan = 1; | ||
131 | newRemoteConnectionButton.setLayoutData(gd); | ||
132 | |||
133 | updateConnectionPulldown(); | ||
134 | } | ||
135 | |||
136 | protected boolean updateOkButton() { | ||
137 | boolean ret=false; | ||
138 | Button button=getButton(IDialogConstants.OK_ID); | ||
139 | if(button!=null) | ||
140 | button.setEnabled(false); | ||
141 | IHost currentConnectionSelected = getCurrentConnection(); | ||
142 | if (currentConnectionSelected != null) { | ||
143 | if (RSEHelper.isHostViable(currentConnectionSelected) && button != null){ | ||
144 | button.setEnabled(true); | ||
145 | ret=true; | ||
146 | } | ||
147 | } | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | protected void updateCurConn() { | ||
152 | IHost currentConnectionSelected = getCurrentConnection(); | ||
153 | if (currentConnectionSelected != null) { | ||
154 | if (RSEHelper.isHostViable(currentConnectionSelected)) | ||
155 | curConn=currentConnectionSelected.getAliasName(); | ||
156 | } | ||
157 | updateOkButton(); | ||
158 | } | ||
159 | |||
160 | protected IHost getCurrentConnection() { | ||
161 | int currentSelection = connectionCombo.getSelectionIndex(); | ||
162 | String remoteConnection = currentSelection >= 0 ? connectionCombo | ||
163 | .getItem(currentSelection) : null; | ||
164 | return RSEHelper.getRemoteConnectionByName(remoteConnection); | ||
165 | } | ||
166 | |||
167 | protected void handleNewRemoteConnectionSelected() { | ||
168 | if (action == null) { | ||
169 | action = new SystemNewConnectionAction(getShell(), | ||
170 | false, false, null); | ||
171 | } | ||
172 | |||
173 | try { | ||
174 | action.run(); | ||
175 | } catch (Exception e) { | ||
176 | // Ignore | ||
177 | } | ||
178 | } | ||
179 | |||
180 | protected void updateConnectionPulldown() { | ||
181 | int index=-1; | ||
182 | RSEHelper.waitForRSEInitCompletition(); | ||
183 | // already initialized | ||
184 | connectionCombo.removeAll(); | ||
185 | IHost[] connections = RSEHelper.getSuitableConnections(); | ||
186 | for (int i = 0; i < connections.length; i++) { | ||
187 | connectionCombo.add(connections[i].getAliasName()); | ||
188 | if(connections[i].getAliasName().equals(curConn)) | ||
189 | index=i; | ||
190 | } | ||
191 | |||
192 | if(index>=0) { | ||
193 | connectionCombo.select(index); | ||
194 | }else if (connections.length > 0) { | ||
195 | connectionCombo.select(connections.length - 1); | ||
196 | } | ||
197 | |||
198 | //TODO | ||
199 | //connectionCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT,true); | ||
200 | connectionCombo.pack(true); | ||
201 | connectionCombo.layout(); | ||
202 | connectionCombo.getParent().layout(); | ||
203 | |||
204 | updateCurConn(); | ||
205 | } | ||
206 | |||
207 | @Override | ||
208 | protected void okPressed() { | ||
209 | conn=getCurrentConnection(); | ||
210 | super.okPressed(); | ||
211 | } | ||
212 | |||
213 | public IHost getHost() { | ||
214 | return conn; | ||
215 | } | ||
216 | } | ||