Increase width of label in remote login dialog
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / RemotingLoginDialog.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.ui.dialog;
11
12 import java.io.File;
13 import java.io.IOException;
14 import java.text.SimpleDateFormat;
15 import java.util.Date;
16 import java.util.HashMap;
17 import java.util.List;
18 import java.util.Map;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.core.runtime.IStatus;
23 import org.eclipse.core.runtime.Status;
24 import org.eclipse.core.runtime.jobs.Job;
25 import org.eclipse.core.runtime.preferences.ConfigurationScope;
26 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
27 import org.eclipse.swt.SWT;
28 import org.eclipse.swt.custom.StyledText;
29 import org.eclipse.swt.events.MouseAdapter;
30 import org.eclipse.swt.events.MouseEvent;
31 import org.eclipse.swt.events.SelectionAdapter;
32 import org.eclipse.swt.events.SelectionEvent;
33 import org.eclipse.swt.graphics.Point;
34 import org.eclipse.swt.layout.FillLayout;
35 import org.eclipse.swt.layout.GridData;
36 import org.eclipse.swt.layout.GridLayout;
37 import org.eclipse.swt.widgets.Button;
38 import org.eclipse.swt.widgets.Combo;
39 import org.eclipse.swt.widgets.Composite;
40 import org.eclipse.swt.widgets.Dialog;
41 import org.eclipse.swt.widgets.Display;
42 import org.eclipse.swt.widgets.Label;
43 import org.eclipse.swt.widgets.Shell;
44 import org.eclipse.swt.widgets.Text;
45 import org.eclipse.ui.forms.events.ExpansionEvent;
46 import org.eclipse.ui.forms.events.IExpansionListener;
47 import org.eclipse.ui.forms.widgets.ExpandableComposite;
48 import org.eclipse.ui.progress.IProgressConstants;
49 import org.eclipse.wb.swt.SWTResourceManager;
50 import org.osgi.service.prefs.BackingStoreException;
51 import org.osgi.service.prefs.Preferences;
52 import org.springframework.security.authentication.BadCredentialsException;
53 import org.springframework.security.authentication.LockedException;
54 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
55
56 import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
57 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
58 import eu.etaxonomy.cdm.api.service.IUserService;
59 import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
60 import eu.etaxonomy.taxeditor.Messages;
61 import eu.etaxonomy.taxeditor.model.MessagingUtils;
62 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
63 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
64 import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
65 import eu.etaxonomy.taxeditor.remoting.server.CDMServerUtils;
66 import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
67 import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo;
68 import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo.CdmInstanceInfo;
69 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
70 import eu.etaxonomy.taxeditor.store.CdmStore;
71 import eu.etaxonomy.taxeditor.store.LoginManager;
72 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
73 import eu.etaxonomy.taxeditor.webapp.CDMEmbeddedServerException;
74 import eu.etaxonomy.taxeditor.webapp.CDMServer;
75 import eu.etaxonomy.taxeditor.webapp.ICDMServerError;
76
77
78 /**
79 * @author cmathew
80 * @date 20 Jan 2015
81 *
82 */
83 public class RemotingLoginDialog extends Dialog implements ICDMServerError {
84
85 private static final String UBUNTU = "Ubuntu"; //$NON-NLS-1$
86 protected Object result;
87 protected Shell shlConnect;
88 private Text txtCdmServerStatus;
89 private Text txtCdmInstanceStatus;
90 private Combo comboCdmServer;
91 private Combo comboCdmInstance;
92 private Button btnConnect;
93
94 private final Map<String, CdmServerInfo> csiiMap = new HashMap<String, CdmServerInfo>();
95
96 private final static String STATUS_AVAILABLE = Messages.RemotingLoginDialog_STATUS_AVAILABLE;
97 private final static String STATUS_NOT_AVAILABLE = Messages.RemotingLoginDialog_STATUS_NOT_AVAILABLE;
98 private final static String STATUS_STARTED = Messages.RemotingLoginDialog_STATUS_STARTED;
99 private final static String STATUS_NOT_STARTED = Messages.RemotingLoginDialog_STATUS_NOT_STARTED;
100 private final static String STATUS_RETRIEVING = Messages.RemotingLoginDialog_STATUS_RETRIEVING;
101 private final static String STATUS_CHECKING_AVAILABILITY = Messages.RemotingLoginDialog_STATUS_CHECKING;
102 private final static String STATUS_NO_INSTANCES = Messages.RemotingLoginDialog_STATUS_NO_INSTANCES_FOUND;
103 private final static String STATUS_ERROR = Messages.RemotingLoginDialog_STATUS_ERROR;
104 private final static String STATUS_REMOTING_NOT_ACTIVATED = Messages.RemotingLoginDialog_STATUS_REMOTING_NOT_ACTIVATED;
105 private final static String STATUS_NOT_COMPATIBLE = Messages.RemotingLoginDialog_STATUS_NOT_COMPATIBLE;
106
107 private final static String MESG_COMPATIBLE_EDITOR_OLD = Messages.RemotingLoginDialog_UPDATE_EDITOR;
108 private final static String MESG_COMPATIBLE_SERVER_OLD = Messages.RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER;
109
110 private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$
111
112 private final static String LOGIN_NODE = "login"; //$NON-NLS-1$
113 private final static String USERNAME_SUFFIX = "_username"; //$NON-NLS-1$
114 private final static String PASSWORD_SUFFIX = "_password"; //$NON-NLS-1$
115
116 private final static String LAST_SERVER_INSTANCE_NODE = "lastServerInstance"; //$NON-NLS-1$
117 private final static String LAST_SERVER_KEY = "lastServerKey"; //$NON-NLS-1$
118 private final static String LAST_INSTANCE_KEY = "lastInstanceKey"; //$NON-NLS-1$
119
120 private final static String REFRESH_LABEL = Messages.RemotingLoginDialog_LABEL_REFRESH;
121
122 private Composite remotingComposite;
123 private CdmServerInfo selectedCsii;
124 private CdmInstanceInfo selectedCdmInstance;
125 private Button btnCdmServerRefresh;
126 private Button btnCdmInstanceRefresh;
127 private Button btnStopServer;
128 private Composite loginComposite;
129 private Label lblLogin;
130 private Text txtLogin;
131 private Label lblPassword;
132 private Text txtPassword;
133 private Button btnRememberMe;
134 private Composite compAdvanced;
135 private Label lblPort;
136 private Text txtPort;
137 private Label lblServerVersion;
138 private Text txtServerVersion;
139 private ExpandableComposite xpndblcmpstAdvanced;
140 private StyledText styledTxtMessage;
141
142
143 private final int MIN_WIDTH = 530;
144 private final int MIN_HEIGHT = 220;
145 private final int MIN_EXP_HEIGHT = 380;
146 private final int MESSAGE_HEIGHT = 25;
147 private Label lblEditorVersion;
148 private Text txtEditorVersion;
149 private Label lblServerCDMVersion;
150 private Text txtServerCDMVersion;
151 private Label lblEditorCDMVersion;
152 private Text txtEditorCDMVersion;
153
154 private String serverName, instanceName;
155 private boolean autoConnect = false;
156 private boolean loadLoginPrefs = true;
157 private boolean isDevRemoteSource = false;
158 private Job serverJob;
159 /**
160 * Create the dialog.
161 * @param parent
162 * @param style
163 */
164 public RemotingLoginDialog(Shell parent, int style) {
165 super(parent, style);
166 setText(Messages.RemotingLoginDialog_LABEL_LOGIN);
167 }
168
169 public Object open(CdmRemoteSource source, boolean loadLoginPrefs, boolean autoConnect) {
170 this.loadLoginPrefs = loadLoginPrefs;
171 this.serverName = source.getName();
172 String contextPath = source.getContextPath();
173 this.instanceName = contextPath.substring(contextPath.lastIndexOf("/") + 1); //$NON-NLS-1$
174 return open(serverName, instanceName, loadLoginPrefs, autoConnect);
175 }
176
177
178 public Object open(String serverName, String instanceName, boolean loadLoginPrefs, boolean autoConnect) {
179 this.serverName = serverName;
180 this.instanceName = instanceName;
181 this.loadLoginPrefs = loadLoginPrefs;
182 this.autoConnect = autoConnect;
183 return open();
184 }
185
186 /**
187 * Open the dialog.
188 * @return the result
189 */
190 public Object open() {
191
192 createContents();
193 if(serverName == null && instanceName == null) {
194 readPrefLastServerInstance();
195 }
196
197 setEditorInfo();
198 populateCdmServerCombo();
199 shlConnect.open();
200 shlConnect.layout();
201
202 xpndblcmpstAdvanced.setExpanded(false);
203
204 Display display = getParent().getDisplay();
205
206 while (!shlConnect.isDisposed()) {
207 if (!display.readAndDispatch()) {
208 display.sleep();
209 }
210 }
211
212 return result;
213 }
214
215 /**
216 * Create contents of the dialog.
217 */
218 private void createContents() {
219 shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM);
220 shlConnect.setMinimumSize(new Point(MIN_WIDTH, MIN_HEIGHT));
221 shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
222 shlConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
223 shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL));
224
225 remotingComposite = new Composite(shlConnect, SWT.NONE);
226 remotingComposite.setLayout(new GridLayout(1, false));
227
228 Composite cdmServerComposite = new Composite(remotingComposite, SWT.NONE);
229 GridData gd_cdmServerComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
230 gd_cdmServerComposite.heightHint = 68;
231 cdmServerComposite.setLayoutData(gd_cdmServerComposite);
232 cdmServerComposite.setLayout(new GridLayout(4, false));
233
234 Label lblCdmServer = new Label(cdmServerComposite, SWT.NONE);
235 lblCdmServer.setText(Messages.RemotingLoginDialog_LABEL_CDM_SERVER);
236 lblCdmServer.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
237 lblCdmServer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
238
239 comboCdmServer = new Combo(cdmServerComposite, SWT.READ_ONLY);
240 comboCdmServer.addSelectionListener(new SelectionAdapter() {
241 @Override
242 public void widgetSelected(SelectionEvent e) {
243 refreshCdmServer();
244
245 }
246 });
247 GridData gd_comboCdmServer = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
248 gd_comboCdmServer.widthHint = 150;
249 comboCdmServer.setLayoutData(gd_comboCdmServer);
250 comboCdmServer.select(0);
251
252 txtCdmServerStatus = new Text(cdmServerComposite, SWT.BORDER);
253 txtCdmServerStatus.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
254 txtCdmServerStatus.setEditable(false);
255 GridData gd_txtCdmServerStatus = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
256 gd_txtCdmServerStatus.widthHint = 100;
257 txtCdmServerStatus.setLayoutData(gd_txtCdmServerStatus);
258
259 btnCdmServerRefresh = new Button(cdmServerComposite, SWT.NONE);
260 btnCdmServerRefresh.addSelectionListener(new SelectionAdapter() {
261 @Override
262 public void widgetSelected(SelectionEvent e) {
263 refreshCdmServer();
264 }
265 });
266 btnCdmServerRefresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
267 btnCdmServerRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
268
269 Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE);
270 GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
271 gd_lblCdmInstance.heightHint = 30;
272 lblCdmInstance.setLayoutData(gd_lblCdmInstance);
273 lblCdmInstance.setText(Messages.RemotingLoginDialog_LABEL_CDM_INSTANCE);
274 lblCdmInstance.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
275
276 comboCdmInstance = new Combo(cdmServerComposite, SWT.READ_ONLY);
277 comboCdmInstance.addSelectionListener(new SelectionAdapter() {
278 @Override
279 public void widgetSelected(SelectionEvent e) {
280 refreshCdmInstance();
281 }
282 });
283 GridData gd_comboCdmInstance = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
284 gd_comboCdmInstance.widthHint = 150;
285 comboCdmInstance.setLayoutData(gd_comboCdmInstance);
286 comboCdmInstance.select(0);
287
288 txtCdmInstanceStatus = new Text(cdmServerComposite, SWT.BORDER);
289 txtCdmInstanceStatus.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
290 txtCdmInstanceStatus.setEditable(false);
291 GridData gd_txtCdmInstanceStatus = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
292 gd_txtCdmInstanceStatus.widthHint = 100;
293 txtCdmInstanceStatus.setLayoutData(gd_txtCdmInstanceStatus);
294
295 btnCdmInstanceRefresh = new Button(cdmServerComposite, SWT.FLAT);
296 btnCdmInstanceRefresh.addSelectionListener(new SelectionAdapter() {
297 @Override
298 public void widgetSelected(SelectionEvent e) {
299 refreshCdmInstance();
300 }
301 });
302 GridData gd_btnCdmInstanceRefresh = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
303 gd_btnCdmInstanceRefresh.widthHint = 110;
304 gd_btnCdmInstanceRefresh.heightHint = 30;
305 btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh);
306 btnCdmInstanceRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
307
308 loginComposite = new Composite(remotingComposite, SWT.NONE);
309 GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
310 gd_loginComposite.widthHint = 487;
311 gd_loginComposite.heightHint = 70;
312 loginComposite.setLayoutData(gd_loginComposite);
313 GridLayout gl_loginComposite = new GridLayout(6, false);
314 gl_loginComposite.marginTop = 5;
315 loginComposite.setLayout(gl_loginComposite);
316
317 lblLogin = new Label(loginComposite, SWT.CENTER);
318 GridData gd_lblLogin = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
319 gd_lblLogin.widthHint = 50;
320 lblLogin.setLayoutData(gd_lblLogin);
321 lblLogin.setText(Messages.RemotingLoginDialog_LABEL_LOGIN_COLON);
322 lblLogin.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
323
324 txtLogin = new Text(loginComposite, SWT.BORDER);
325 GridData gd_txtLogin = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
326 gd_txtLogin.minimumWidth = 80;
327 gd_txtLogin.widthHint = 80;
328 gd_txtLogin.heightHint = 15;
329 txtLogin.setLayoutData(gd_txtLogin);
330
331 lblPassword = new Label(loginComposite, SWT.CENTER);
332 lblPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
333 lblPassword.setText(Messages.RemotingLoginDialog_LABEL_PASSWORD);
334 lblPassword.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
335
336 txtPassword = new Text(loginComposite, SWT.BORDER | SWT.PASSWORD);
337 GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
338 gd_txtPassword.minimumWidth = 80;
339 gd_txtPassword.widthHint = 80;
340 gd_txtPassword.heightHint = 15;
341 txtPassword.setLayoutData(gd_txtPassword);
342 new Label(loginComposite, SWT.NONE);
343
344 btnConnect = new Button(loginComposite, SWT.FLAT);
345 btnConnect.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
346 btnConnect.addMouseListener(new MouseAdapter() {
347 @Override
348 public void mouseUp(MouseEvent e) {
349 if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
350 startManagedServer();
351 } else {
352 connect();
353 }
354 }
355 });
356 btnConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
357
358 btnRememberMe = new Button(loginComposite, SWT.CHECK);
359 btnRememberMe.setSelection(true);
360 GridData gd_btnRememberMe = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
361 btnRememberMe.setLayoutData(gd_btnRememberMe);
362 btnRememberMe.setText(Messages.RemotingLoginDialog_LABEL_REMEMBER_ME);
363 new Label(loginComposite, SWT.NONE);
364 new Label(loginComposite, SWT.NONE);
365 new Label(loginComposite, SWT.NONE);
366 new Label(loginComposite, SWT.NONE);
367
368 styledTxtMessage = new StyledText(remotingComposite, SWT.NONE);
369 styledTxtMessage.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
370 styledTxtMessage.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
371 styledTxtMessage.setFont(SWTResourceManager.getFont(UBUNTU, 12, SWT.BOLD));
372 styledTxtMessage.setSelectionBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
373 styledTxtMessage.setSelectionForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
374 styledTxtMessage.setDoubleClickEnabled(false);
375 styledTxtMessage.setEditable(false);
376 GridData gd_styledTxtMessage = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
377 gd_styledTxtMessage.exclude = true;
378 gd_styledTxtMessage.minimumHeight = MESSAGE_HEIGHT;
379 gd_styledTxtMessage.heightHint = MESSAGE_HEIGHT;
380 styledTxtMessage.setLayoutData(gd_styledTxtMessage);
381
382 xpndblcmpstAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
383 GridData gd_xpndblcmpstAdvanced = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
384 gd_xpndblcmpstAdvanced.heightHint = 19;
385 xpndblcmpstAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
386 xpndblcmpstAdvanced.addExpansionListener(new IExpansionListener() {
387 @Override
388 public void expansionStateChanged(ExpansionEvent e) {
389 GridData gridData = (GridData) xpndblcmpstAdvanced.getLayoutData();
390 if(e.getState()) {
391 shlConnect.setSize(MIN_WIDTH, MIN_EXP_HEIGHT);
392 } else {
393 shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
394 }
395
396 }
397 @Override
398 public void expansionStateChanging(ExpansionEvent e) {
399 }
400 });
401 xpndblcmpstAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
402 xpndblcmpstAdvanced.setExpanded(true);
403
404 compAdvanced = new Composite(xpndblcmpstAdvanced, SWT.NONE);
405 xpndblcmpstAdvanced.setClient(compAdvanced);
406 compAdvanced.setLayout(new GridLayout(4, false));
407
408 lblPort = new Label(compAdvanced, SWT.CENTER);
409 lblPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
410 lblPort.setSize(0, 0);
411 lblPort.setText(Messages.RemotingLoginDialog_LABEL_PORT);
412 lblPort.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
413
414 txtPort = new Text(compAdvanced, SWT.BORDER);
415 GridData gd_txtPort = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
416 gd_txtPort.minimumWidth = 50;
417 gd_txtPort.widthHint = 50;
418 txtPort.setLayoutData(gd_txtPort);
419
420 lblServerVersion = new Label(compAdvanced, SWT.CENTER);
421 lblServerVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
422 lblServerVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION);
423 lblServerVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
424
425 txtServerVersion = new Text(compAdvanced, SWT.BORDER);
426 txtServerVersion.setEditable(false);
427 txtServerVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
428 btnStopServer = new Button(compAdvanced, SWT.FLAT);
429 btnStopServer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
430 btnStopServer.addMouseListener(new MouseAdapter() {
431 @Override
432 public void mouseUp(MouseEvent e) {
433 stopManagedServer();
434 }
435 });
436 btnStopServer.setText(Messages.RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER);
437
438 lblEditorVersion = new Label(compAdvanced, SWT.CENTER);
439 lblEditorVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
440 lblEditorVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION);
441 lblEditorVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
442
443 txtEditorVersion = new Text(compAdvanced, SWT.BORDER);
444 txtEditorVersion.setEditable(false);
445 txtEditorVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
446 new Label(compAdvanced, SWT.NONE);
447 new Label(compAdvanced, SWT.NONE);
448
449 lblServerCDMVersion = new Label(compAdvanced, SWT.CENTER);
450 lblServerCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
451 lblServerCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
452 lblServerCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
453
454 txtServerCDMVersion = new Text(compAdvanced, SWT.BORDER);
455 txtServerCDMVersion.setEditable(false);
456 txtServerCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
457 new Label(compAdvanced, SWT.NONE);
458 new Label(compAdvanced, SWT.NONE);
459
460 lblEditorCDMVersion = new Label(compAdvanced, SWT.CENTER);
461 lblEditorCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
462 lblEditorCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
463 lblEditorCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
464
465 txtEditorCDMVersion = new Text(compAdvanced, SWT.BORDER);
466 txtEditorCDMVersion.setEditable(false);
467 txtEditorCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
468
469 }
470
471
472
473 private void populateCdmServerCombo() {
474 Job job = new Job(Messages.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES) {
475 @Override
476 protected IStatus run(IProgressMonitor monitor) {
477 Display.getDefault().syncExec(new Runnable() {
478 @Override
479 public void run() {
480 for(CdmServerInfo csii : CdmServerInfo.getCdmServers()) {
481 csiiMap.put(csii.getName(), csii);
482 comboCdmServer.add(csii.getName());
483 }
484 int serverIndex = -1;
485 if(serverName != null) {
486 serverIndex = comboCdmServer.indexOf(serverName);
487 }
488 if(serverIndex == -1) {
489 comboCdmServer.select(0);
490 autoConnect = false;
491 } else {
492 comboCdmServer.select(serverIndex);
493 }
494 CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
495 if(devRemoteSource != null) {
496 isDevRemoteSource = true;
497 String username = System.getProperty("cdm.server.dev.username"); //$NON-NLS-1$
498 String password = System.getProperty("cdm.server.dev.password"); //$NON-NLS-1$
499 if(username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
500 txtLogin.setText(username);
501 txtPassword.setText(password);
502 CdmStore.connect(devRemoteSource, RemotingLoginDialog.this);
503 }
504 } else {
505 refreshCdmServer();
506 }
507 }
508 });
509 return Status.OK_STATUS;
510 }
511 };
512 job.schedule();
513 }
514
515
516 private void refreshCdmServer() {
517 txtCdmServerStatus.setText(STATUS_CHECKING_AVAILABILITY);
518 clearOnServerChange();
519 emptyCredentials();
520 updateSelectedCdmServer();
521 Display.getDefault().asyncExec(new Runnable() {
522 @Override
523 public void run() {
524 checkSelectedCdmServer();
525 }
526 });
527
528 }
529
530 private void updateSelectedCdmServer() {
531 int selIndex = comboCdmServer.getSelectionIndex();
532 if(selIndex != -1) {
533 selectedCsii = csiiMap.get(comboCdmServer.getItem(selIndex));
534 }
535 }
536
537 private void updatePort() {
538 txtPort.setText("");
539 if(selectedCsii != null) {
540 int port = selectedCsii.getPort();
541 if(port == CdmServerInfo.NULL_PORT) {
542 txtPort.setText(CdmServerInfo.NULL_PORT_STRING);
543 } else {
544 txtPort.setText(String.valueOf(port));
545 }
546 }
547 }
548
549 private int getPort() {
550 int port = CdmServerInfo.NULL_PORT;
551 try {
552 port = Integer.valueOf(txtPort.getText());
553 } catch (NumberFormatException nfe) {
554 if(!CdmServerInfo.NULL_PORT_STRING.equals(txtPort.getText())) {
555 setMessage(Messages.RemotingLoginDialog_MESSAGE_PORT_SHOULD_BE_INTEGER);
556 }
557 }
558 return port;
559 }
560
561 private void checkSelectedCdmServer() {
562 if(selectedCsii != null) {
563 if(selectedCsii.isLocalhost()) {
564 txtPort.setEditable(true);
565 txtPort.setEnabled(true);
566 }
567 if(selectedCsii.pingServer()) {
568 txtCdmServerStatus.setText(STATUS_AVAILABLE);
569 populateCdmInstanceCombo(true);
570 String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
571 txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
572 } else {
573 txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
574 comboCdmInstance.removeAll();
575 disableCdmInstanceControls("", "");
576 }
577 }
578 updatePort();
579 }
580
581
582 private void populateCdmInstanceCombo(final boolean forceRefresh) {
583 comboCdmInstance.removeAll();
584 comboCdmInstance.setEnabled(false);
585 btnConnect.setEnabled(false);
586 txtCdmInstanceStatus.setText(STATUS_RETRIEVING);
587 txtCdmInstanceStatus.setToolTipText("");
588
589 serverJob = new Job(Messages.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES) {
590 @Override
591 protected IStatus run(IProgressMonitor monitor) {
592 try {
593 if(selectedCsii != null) {
594 if(forceRefresh) {
595 selectedCsii.refreshInstances();
596 }
597 final List<CdmInstanceInfo> instances = selectedCsii.getInstances();
598 Display.getDefault().asyncExec(new Runnable() {
599 @Override
600 public void run() {
601 if(!instances.isEmpty()) {
602 for(CdmInstanceInfo cdmInstance : instances) {
603 comboCdmInstance.add(cdmInstance.getName());
604 }
605 int instanceIndex = -1;
606 if(instanceName != null) {
607 instanceIndex = comboCdmInstance.indexOf(instanceName);
608 }
609 if(instanceIndex == -1) {
610 comboCdmInstance.select(0);
611 autoConnect = false;
612 } else {
613 comboCdmInstance.select(instanceIndex);
614 }
615 refreshCdmInstance();
616 comboCdmInstance.setEnabled(true);
617 if(autoConnect) {
618 connect();
619 }
620
621 } else {
622 txtCdmInstanceStatus.setText(STATUS_NO_INSTANCES);
623 btnConnect.setEnabled(false);
624 }
625 }
626 });
627 }
628 } catch (final CDMServerException e) {
629 MessagingUtils.warn(getClass(), e);
630 Display.getDefault().asyncExec(new Runnable() {
631 @Override
632 public void run() {
633 disableCdmInstanceControls(STATUS_NOT_AVAILABLE, e.getMessage());
634 }
635 });
636 }
637 return Status.OK_STATUS;
638 }
639 };
640
641 if(txtCdmServerStatus.getText().equals(STATUS_AVAILABLE) && !isDevRemoteSource) {
642 // Start the Job
643 serverJob.schedule();
644 }
645 }
646
647 private void disableCdmInstanceControls(String cdmInstanceStatus, String tooltip) {
648 txtCdmInstanceStatus.setText(cdmInstanceStatus);
649 txtCdmInstanceStatus.setToolTipText(tooltip);
650 comboCdmInstance.setEnabled(false);
651 btnConnect.setEnabled(false);
652
653 }
654 private void refreshCdmInstance() {
655 txtCdmInstanceStatus.setText(STATUS_CHECKING_AVAILABILITY);
656 clearOnInstanceChange();
657 updateSelectedCdmInstance();
658 checkSelectedCdmInstance();
659 updateManagedServerControls();
660 }
661
662 private void updateSelectedCdmInstance() {
663 int selIndex = comboCdmInstance.getSelectionIndex();
664 if(selIndex != -1) {
665 selectedCdmInstance = selectedCsii.getInstanceFromName(comboCdmInstance.getItem(selIndex));
666
667 if(loadLoginPrefs && !isDevRemoteSource) {
668 readPrefCredentials();
669 }
670 }
671 }
672
673 private void updateManagedServerControls() {
674 if(selectedCsii.isLocalhostMgd()) {
675 if(isSelectedCdmInstanceRunningInManagedServer()) {
676 txtCdmInstanceStatus.setText(STATUS_STARTED);
677 } else {
678 txtCdmInstanceStatus.setText(STATUS_NOT_STARTED);
679 }
680 btnConnect.setEnabled(true);
681 selectedCsii.setPort(getManagedServerPort());
682 updatePort();
683 }
684
685
686 if(isManagedServerRunning()) {
687 btnStopServer.setEnabled(true);
688 } else {
689 btnStopServer.setEnabled(false);
690 }
691 }
692
693 private boolean isManagedServerRunning() {
694 return CdmStore.getManagedServer() != null && CdmStore.getManagedServer().isAlive();
695 }
696
697 private boolean isSelectedCdmInstanceRunningInManagedServer() {
698 return CdmStore.getManagedServer() != null &&
699 CdmStore.getManagedServer().isAlive() &&
700 selectedCsii.isLocalhostMgd() &&
701 CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName());
702 }
703
704 private void startManagedServer() {
705 if(isManagedServerRunning()) {
706 if(CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())) {
707 return;
708 } else {
709 Display.getDefault().syncExec(new Runnable() {
710 @Override
711 public void run() {
712 stopManagedServer();
713 }
714 });
715 }
716 }
717
718
719 Job job = new Job(Messages.RemotingLoginDialog_JOB_SERVER_LAUNCH) {
720
721 @Override
722 public IStatus run(IProgressMonitor monitor) {
723 String mgdServerConfigFileName = "mgd.datasources.xml"; //$NON-NLS-1$
724 String config = CDMServerUtils.convertEditorToServerConfig();
725 File managedServerConfigFile;
726 int maxUnits = 50;
727 monitor.beginTask(Messages.RemotingLoginDialog_TASK_LAUNCHING_SERVER, maxUnits);
728 try {
729 monitor.subTask(String.format(Messages.RemotingLoginDialog_GENERATING_CONFIG_FILE, selectedCdmInstance.getName()));
730 managedServerConfigFile = CDMServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
731 monitor.worked(1);
732 CdmStore.setManagedServer(new CDMServer(selectedCdmInstance.getName(), managedServerConfigFile));
733 monitor.subTask(Messages.RemotingLoginDialog_STARTING_MGD_SERVER);
734 CdmStore.getManagedServer().start(false, RemotingLoginDialog.this);
735 int serverUnits = 0;
736
737 // the following loop is a 'fake' progress monitoring where the progress
738 // bar is advanced by one unit every second until maxUnits -2
739 while(!CdmStore.getManagedServer().isStarted() && !CdmStore.getManagedServer().isFailed()) {
740 if(serverUnits < maxUnits - 2) {
741 try {
742 Thread.sleep(1000);
743 } catch (InterruptedException e) {
744 }
745 monitor.worked(1);
746 serverUnits++;
747 }
748 }
749 Display.getDefault().asyncExec(new Runnable() {
750 @Override
751 public void run() {
752 hide(false);
753 updateManagedServerControls();
754 connect();
755 }
756 });
757 } catch (IOException ioe) {
758 MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE,
759 this,
760 ioe.getMessage(),
761 TaxeditorStorePlugin.PLUGIN_ID,
762 ioe,
763 true);
764 } catch (CDMEmbeddedServerException cse) {
765 MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_STARTING_SERVER,
766 this,
767 cse.getMessage(),
768 TaxeditorStorePlugin.PLUGIN_ID,
769 cse,
770 true);
771 } finally {
772 monitor.done();
773 }
774 return Status.OK_STATUS;
775 }
776 };
777
778 // configure the job
779 job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
780 job.setUser(true);
781 // schedule job
782 hide(true);
783 job.schedule();
784 }
785
786 private void stopManagedServer() {
787 try {
788 CdmStore.getManagedServer().stop();
789 } catch (Exception e) {
790 MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_STOPPING_SERVER,
791 this,
792 String.format(Messages.RemotingLoginDialog_COULD_NOT_STOP_SERVER, CdmStore.getManagedServer().getPort()),
793 TaxeditorStorePlugin.PLUGIN_ID,
794 e,
795 true);
796 }
797 CdmStore.setManagedServer(null);
798 updateManagedServerControls();
799 }
800
801 private int getManagedServerPort() {
802 return CdmStore.getManagedServer() == null ? CdmServerInfo.NULL_PORT : CdmStore.getManagedServer().getPort();
803 }
804
805 private void checkSelectedCdmInstance() {
806 boolean available = false;
807 String status = STATUS_NOT_AVAILABLE;
808 String message = null;
809
810 if(txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) {
811 try {
812 if(selectedCsii.pingInstance(selectedCdmInstance, getPort())) {
813 status = STATUS_AVAILABLE;
814 available = true;
815 } else {
816 status = STATUS_NOT_AVAILABLE;
817 available = false;
818 }
819
820 if(available) {
821 txtServerCDMVersion.setText(selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion());
822 int compareDbSchemaVersion = selectedCsii.compareDbSchemaVersion(selectedCdmInstance, getPort());
823 int compareCdmlibServicesVersion = 0;
824 boolean disableServicesApiTimestampCheck =
825 PreferencesUtil.getPreferenceStore().getBoolean((IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK));
826 if(!disableServicesApiTimestampCheck) {
827 compareCdmlibServicesVersion = selectedCsii.compareCdmlibServicesVersion();
828 }
829 if(compareDbSchemaVersion > 0 || compareCdmlibServicesVersion > 0) {
830 status = STATUS_NOT_COMPATIBLE;
831 available = false;
832 message = MESG_COMPATIBLE_EDITOR_OLD;
833 } else if(compareDbSchemaVersion < 0 || compareCdmlibServicesVersion < 0) {
834 status = STATUS_NOT_COMPATIBLE;
835 available = false;
836 message = MESG_COMPATIBLE_SERVER_OLD;
837 } else {
838 status = STATUS_AVAILABLE;
839 available = true;
840 message = ""; //$NON-NLS-1$
841 }
842 }
843 } catch (Exception e) {
844 txtCdmInstanceStatus.setToolTipText(e.getMessage());
845 } finally {
846 btnConnect.setEnabled(available);
847 txtCdmInstanceStatus.setText(status);
848 if(!StringUtils.isBlank(message)) {
849 setMessage(message);
850 }
851 }
852 }
853 }
854
855 private void connect() {
856 checkSelectedCdmInstance();
857
858 if(!txtCdmInstanceStatus.getText().equals(STATUS_AVAILABLE)) {
859 return;
860 }
861
862 ICdmRemoteSource source = selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort());
863
864 if(!validateLogin(source)) {
865 return;
866 }
867
868 try {
869 CdmStore.connect(source, this);
870 } catch (Exception e) {
871 // Do not expect anything to go wrong at this point, so we throw a runtime exception
872 // if any problems
873 throw new RuntimeException(e);
874 }
875
876 }
877
878
879 public boolean isRememberMe() {
880 return btnRememberMe.getSelection();
881 }
882
883 private void persistPrefLastServerInstance() {
884 IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
885 Preferences lastServerInstancePrefs = preferences.node(LAST_SERVER_INSTANCE_NODE);
886
887 lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedCsii.getName());
888 lastServerInstancePrefs.put(LAST_INSTANCE_KEY, selectedCdmInstance.getName());
889
890 flushPreferences(lastServerInstancePrefs);
891 }
892
893 private void persistPrefCredentials() {
894 IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
895 Preferences credentialsPrefs = preferences.node(LOGIN_NODE);
896 credentialsPrefs.put(getUsernamePrefKey(), txtLogin.getText());
897 credentialsPrefs.put(getPasswordPrefKey(), txtPassword.getText());
898 flushPreferences(credentialsPrefs);
899 }
900
901 private void flushPreferences(Preferences prefs) {
902 try {
903 prefs.flush();
904 } catch (BackingStoreException bse) {
905 setMessage(bse.getMessage());
906 }
907 }
908
909 private void readPrefCredentials() {
910 String username, password;
911 IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
912 Preferences credentialsPrefs = preferences.node(LOGIN_NODE);
913 username = credentialsPrefs.get(getUsernamePrefKey(), ""); //$NON-NLS-1$
914 txtLogin.setText(username);
915 password = credentialsPrefs.get(getPasswordPrefKey(),""); //$NON-NLS-1$
916 txtPassword.setText(password);
917 if(username.isEmpty() || password.isEmpty()) {
918 autoConnect = false;
919 }
920 }
921
922 private void readPrefLastServerInstance() {
923 IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
924 Preferences lastServerInstancePrefs = preferences.node(LAST_SERVER_INSTANCE_NODE);
925
926 serverName = lastServerInstancePrefs.get(LAST_SERVER_KEY, null);
927 instanceName = lastServerInstancePrefs.get(LAST_INSTANCE_KEY, null);
928 }
929
930 private void emptyCredentials() {
931 txtLogin.setText("");
932 txtPassword.setText("");
933 }
934
935 private String getUsernamePrefKey() {
936 return selectedCsii.toString(selectedCdmInstance.getName(), getPort()) + USERNAME_SUFFIX;
937 }
938
939 private String getPasswordPrefKey() {
940 return selectedCsii.toString(selectedCdmInstance.getName(), getPort()) + PASSWORD_SUFFIX;
941 }
942
943 private boolean validateLogin(ICdmRemoteSource remoteSource) {
944 if(getUsername() == null || getUsername().isEmpty()) {
945 setMessage(Messages.RemotingLoginDialog_LOGIN_CANNOT_BE_EMPTY);
946 return false;
947 }
948 if(getPassword() == null || getPassword().isEmpty()) {
949 setMessage(Messages.RemotingLoginDialog_PASSWORD_CANNOT_BE_EMPTY);
950 return false;
951 }
952
953
954 try {
955 IUserService userService = CdmApplicationRemoteConfiguration.getUserService(remoteSource);
956 UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(getUsername(), getPassword());
957 CdmApplicationRemoteConfiguration.getAuthenticationManager(userService).authenticate(token);
958 } catch(BadCredentialsException e){
959 setMessage(LoginManager.INCORRECT_CREDENTIALS_MESSAGE);
960 return false;
961 } catch(LockedException e){
962 setMessage(LoginManager.ACCOUNT_LOCKED_MESSAGE);
963 return false;
964 } catch(IllegalArgumentException e){
965 setMessage(LoginManager.INCORRECT_CREDENTIALS_MESSAGE);
966 return false;
967 }
968 return true;
969 }
970
971 public String getUsername() {
972 return txtLogin.getText();
973 }
974
975 public String getPassword() {
976 return txtPassword.getText();
977 }
978
979 public void setMessage(String message) {
980 if(message != null && !message.isEmpty()) {
981 if(message.length() > 60) {
982 styledTxtMessage.setToolTipText(message);
983 message = message.substring(0, 60) + "..."; //$NON-NLS-1$
984 }
985 styledTxtMessage.setText(message);
986 styledTxtMessage.setVisible(true);
987 ((GridData)styledTxtMessage.getLayoutData()).exclude = false;
988 shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
989 shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
990 } else {
991 styledTxtMessage.setText(""); //$NON-NLS-1$
992 styledTxtMessage.setVisible(false);
993 ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
994 shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
995 shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
996 }
997 remotingComposite.layout();
998 }
999
1000 private int getHeightWithoutMessage() {
1001 if(xpndblcmpstAdvanced.isExpanded()) {
1002 return MIN_EXP_HEIGHT;
1003 } else {
1004 return MIN_HEIGHT;
1005 }
1006 }
1007
1008
1009 public void hide(boolean isHidden) {
1010 if(shlConnect != null && shlConnect.getDisplay() != null) {
1011 shlConnect.setVisible(!isHidden);
1012 }
1013 }
1014 public void dispose() {
1015 if(shlConnect != null && shlConnect.getDisplay() != null) {
1016 shlConnect.dispose();
1017 }
1018 }
1019
1020 public void onComplete() {
1021 Display.getDefault().asyncExec(new Runnable() {
1022 @Override
1023 public void run() {
1024 if(!isDevRemoteSource) {
1025 if(isRememberMe()) {
1026 persistPrefCredentials();
1027 }
1028 persistPrefLastServerInstance();
1029 }
1030 dispose();
1031 }
1032 });
1033 }
1034
1035 private String generateLastModifiedTooltip(String cdmlibLastModified) {
1036 if(StringUtils.isBlank(cdmlibLastModified)) {
1037 return ""; //$NON-NLS-1$
1038 }
1039 SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.z"); //$NON-NLS-1$
1040 Date cdmlibLastModifiedDate;
1041 String cdmlibLastModifiedTimestamp = ""; //$NON-NLS-1$
1042
1043 cdmlibLastModifiedDate = new Date(Long.valueOf(cdmlibLastModified));
1044 cdmlibLastModifiedTimestamp = sdf.format(cdmlibLastModifiedDate);
1045
1046 return cdmlibLastModifiedTimestamp;
1047 }
1048
1049 private void setEditorInfo() {
1050 txtEditorCDMVersion.setText(CdmMetaData.getDbSchemaVersion());
1051 String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified());
1052 txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$
1053 }
1054
1055 private void clearOnServerChange() {
1056 setMessage(""); //$NON-NLS-1$
1057 txtServerCDMVersion.setText(""); //$NON-NLS-1$
1058 txtServerVersion.setText(""); //$NON-NLS-1$
1059 txtServerVersion.setToolTipText(""); //$NON-NLS-1$
1060 txtServerCDMVersion.setText(""); //$NON-NLS-1$
1061 comboCdmInstance.removeAll();
1062 txtCdmInstanceStatus.setText(""); //$NON-NLS-1$
1063 txtPort.setEditable(false);
1064 txtPort.setEnabled(false);
1065 }
1066
1067 private void clearOnInstanceChange() {
1068 setMessage(""); //$NON-NLS-1$
1069 txtServerCDMVersion.setText(""); //$NON-NLS-1$
1070 }
1071
1072 /**
1073 * {@inheritDoc}
1074 */
1075 @Override
1076 public void handleError(final Throwable t) {
1077
1078 Display.getDefault().syncExec(new Runnable() {
1079 @Override
1080 public void run() {
1081 serverJob.cancel();
1082
1083 String title = Messages.RemotingLoginDialog_SERVER_LAUNCH_ERROR;
1084 String message = t.getMessage();
1085
1086
1087 MessagingUtils.errorDialog(title,
1088 this,
1089 message,
1090 TaxeditorStorePlugin.PLUGIN_ID,
1091 t,
1092 true);
1093 }
1094 });
1095 }
1096
1097
1098 }