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