2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
12 import java
.io
.IOException
;
13 import java
.net
.SocketTimeoutException
;
14 import java
.text
.SimpleDateFormat
;
15 import java
.util
.Date
;
16 import java
.util
.HashMap
;
17 import java
.util
.List
;
20 import org
.apache
.commons
.lang
.StringUtils
;
21 import org
.apache
.log4j
.Logger
;
22 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
23 import org
.eclipse
.core
.runtime
.IStatus
;
24 import org
.eclipse
.core
.runtime
.Status
;
25 import org
.eclipse
.core
.runtime
.jobs
.Job
;
26 import org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
;
27 import org
.eclipse
.core
.runtime
.preferences
.IEclipsePreferences
;
28 import org
.eclipse
.jface
.layout
.GridDataFactory
;
29 import org
.eclipse
.swt
.SWT
;
30 import org
.eclipse
.swt
.SWTException
;
31 import org
.eclipse
.swt
.custom
.StyledText
;
32 import org
.eclipse
.swt
.events
.KeyAdapter
;
33 import org
.eclipse
.swt
.events
.KeyEvent
;
34 import org
.eclipse
.swt
.events
.MouseAdapter
;
35 import org
.eclipse
.swt
.events
.MouseEvent
;
36 import org
.eclipse
.swt
.events
.SelectionAdapter
;
37 import org
.eclipse
.swt
.events
.SelectionEvent
;
38 import org
.eclipse
.swt
.layout
.FillLayout
;
39 import org
.eclipse
.swt
.layout
.GridData
;
40 import org
.eclipse
.swt
.layout
.GridLayout
;
41 import org
.eclipse
.swt
.widgets
.Button
;
42 import org
.eclipse
.swt
.widgets
.Combo
;
43 import org
.eclipse
.swt
.widgets
.Composite
;
44 import org
.eclipse
.swt
.widgets
.Dialog
;
45 import org
.eclipse
.swt
.widgets
.Display
;
46 import org
.eclipse
.swt
.widgets
.Label
;
47 import org
.eclipse
.swt
.widgets
.Shell
;
48 import org
.eclipse
.swt
.widgets
.Text
;
49 import org
.eclipse
.ui
.forms
.events
.ExpansionEvent
;
50 import org
.eclipse
.ui
.forms
.events
.IExpansionListener
;
51 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
52 import org
.eclipse
.ui
.progress
.IProgressConstants
;
53 import org
.eclipse
.wb
.swt
.SWTResourceManager
;
54 import org
.osgi
.service
.prefs
.BackingStoreException
;
55 import org
.osgi
.service
.prefs
.Preferences
;
56 import org
.springframework
.security
.authentication
.BadCredentialsException
;
57 import org
.springframework
.security
.authentication
.LockedException
;
58 import org
.springframework
.security
.authentication
.UsernamePasswordAuthenticationToken
;
60 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationRemoteConfiguration
;
61 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
62 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
63 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
;
64 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
.Role
;
65 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
66 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
67 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
68 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
69 import eu
.etaxonomy
.taxeditor
.remoting
.server
.CDMServerException
;
70 import eu
.etaxonomy
.taxeditor
.remoting
.server
.CDMServerUtils
;
71 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmRemoteSource
;
72 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmServerInfo
;
73 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmServerInfo
.CdmInstanceInfo
;
74 import eu
.etaxonomy
.taxeditor
.remoting
.source
.ICdmRemoteSource
;
75 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
76 import eu
.etaxonomy
.taxeditor
.store
.LoginManager
;
77 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
78 import eu
.etaxonomy
.taxeditor
.webapp
.CDMEmbeddedServerException
;
79 import eu
.etaxonomy
.taxeditor
.webapp
.CDMServer
;
80 import eu
.etaxonomy
.taxeditor
.webapp
.ICDMServerError
;
88 public class RemotingLoginDialog
extends Dialog
implements ICDMServerError
{
90 private Logger logger
= Logger
.getLogger(getClass());
92 private static final String DEFAULT_PASS
= "00000"; //$NON-NLS-1$
93 private static final String DEFAULT_USER
= "admin"; //$NON-NLS-1$
94 private static final String UBUNTU
= "Ubuntu"; //$NON-NLS-1$
95 protected Object result
;
96 protected Shell shlConnect
;
97 private Text txtCdmServerStatus
;
98 private Text txtCdmInstanceStatus
;
99 private Combo comboCdmServer
;
100 private Combo comboCdmInstance
;
101 private Button btnConnect
;
103 private final Map
<String
, CdmServerInfo
> csiiMap
= new HashMap
<String
, CdmServerInfo
>();
105 private final static String STATUS_AVAILABLE
= Messages
.RemotingLoginDialog_STATUS_AVAILABLE
;
106 private final static String STATUS_NOT_AVAILABLE
= Messages
.RemotingLoginDialog_STATUS_NOT_AVAILABLE
;
107 private final static String STATUS_STARTED
= Messages
.RemotingLoginDialog_STATUS_STARTED
;
108 private final static String STATUS_NOT_STARTED
= Messages
.RemotingLoginDialog_STATUS_NOT_STARTED
;
109 private final static String STATUS_RETRIEVING
= Messages
.RemotingLoginDialog_STATUS_RETRIEVING
;
110 private final static String STATUS_CHECKING_AVAILABILITY
= Messages
.RemotingLoginDialog_STATUS_CHECKING
;
111 private final static String STATUS_NO_INSTANCES
= Messages
.RemotingLoginDialog_STATUS_NO_INSTANCES_FOUND
;
112 private final static String STATUS_NOT_COMPATIBLE
= Messages
.RemotingLoginDialog_STATUS_NOT_COMPATIBLE
;
114 private final static String MESG_COMPATIBLE_EDITOR_OLD
= Messages
.RemotingLoginDialog_UPDATE_EDITOR
;
115 private final static String MESG_COMPATIBLE_SERVER_OLD
= Messages
.RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER
;
117 private final static String STORE_PREFERENCES_NODE
= "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$
119 private final static String LOGIN_NODE
= "login"; //$NON-NLS-1$
120 private final static String USERNAME_SUFFIX
= "_username"; //$NON-NLS-1$
121 private final static String PASSWORD_SUFFIX
= "_password"; //$NON-NLS-1$
123 private final static String LAST_SERVER_INSTANCE_NODE
= "lastServerInstance"; //$NON-NLS-1$
124 private final static String LAST_SERVER_KEY
= "lastServerKey"; //$NON-NLS-1$
125 private final static String LAST_INSTANCE_KEY
= "lastInstanceKey"; //$NON-NLS-1$
128 private Composite remotingComposite
;
129 private CdmServerInfo selectedCsii
;
130 private CdmInstanceInfo selectedCdmInstance
;
131 private Button btnCdmServerRefresh
;
132 private Button btnCdmInstanceRefresh
;
133 private Button btnStopServer
;
134 private Composite loginComposite
;
135 private Label lblLogin
;
136 private Text txtLogin
;
137 private Label lblPassword
;
138 private Text txtPassword
;
139 private Button btnRememberMe
;
140 private Composite compAdvanced
;
141 private Label lblPort
;
142 private Text txtPort
;
143 private Label lblServerVersion
;
144 private Text txtServerVersion
;
145 private ExpandableComposite xpndblcmpstAdvanced
;
146 private StyledText styledTxtMessage
;
149 // private final int MIN_WIDTH = 530;
150 // private final int MIN_HEIGHT = 220;
151 // private final int MIN_EXP_HEIGHT = 380;
153 private final int MESSAGE_HEIGHT
= 50;
154 private Label lblEditorVersion
;
155 private Text txtEditorVersion
;
156 private Label lblServerCDMVersion
;
157 private Text txtServerCDMVersion
;
158 private Label lblEditorCDMVersion
;
159 private Text txtEditorCDMVersion
;
161 private String serverName
, instanceName
;
162 private boolean autoConnect
= false;
163 private boolean loadLoginPrefs
= true;
164 private boolean isDevRemoteSource
= false;
165 private Job serverJob
;
171 public RemotingLoginDialog(Shell parent
, int style
) {
172 super(parent
, style
);
173 setText(Messages
.RemotingLoginDialog_LABEL_LOGIN
);
176 public Object
open(CdmRemoteSource source
, boolean loadLoginPrefs
, boolean autoConnect
) {
177 this.loadLoginPrefs
= loadLoginPrefs
;
178 this.serverName
= source
.getName();
179 String contextPath
= source
.getContextPath();
180 this.instanceName
= contextPath
.substring(contextPath
.lastIndexOf("/") + 1); //$NON-NLS-1$
181 return open(serverName
, instanceName
, loadLoginPrefs
, autoConnect
);
185 public Object
open(String serverName
, String instanceName
, boolean loadLoginPrefs
, boolean autoConnect
) {
186 this.serverName
= serverName
;
187 this.instanceName
= instanceName
;
188 this.loadLoginPrefs
= loadLoginPrefs
;
189 this.autoConnect
= autoConnect
;
197 public Object
open() {
200 if(serverName
== null && instanceName
== null) {
201 readPrefLastServerInstance();
205 populateCdmServerCombo();
206 shlConnect
.pack(true);
209 xpndblcmpstAdvanced
.setExpanded(false);
211 Display display
= getParent().getDisplay();
213 while (!shlConnect
.isDisposed()) {
214 if (!display
.isDisposed()){
215 if (!display
.readAndDispatch()) {
225 * Create contents of the dialog.
227 private void createContents() {
228 shlConnect
= new Shell(getParent(), SWT
.DIALOG_TRIM
| SWT
.APPLICATION_MODAL
| SWT
.RESIZE
);
229 shlConnect
.setText(Messages
.RemotingLoginDialog_LABEL_CONNECT
);
230 shlConnect
.setLayout(new FillLayout(SWT
.HORIZONTAL
));
232 remotingComposite
= new Composite(shlConnect
, SWT
.NONE
);
233 remotingComposite
.setLayout(new GridLayout(1, false));
235 Composite cdmServerComposite
= new Composite(remotingComposite
, SWT
.NONE
);
236 GridData gd_cdmServerComposite
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 1, 1);
237 cdmServerComposite
.setLayoutData(gd_cdmServerComposite
);
238 cdmServerComposite
.setLayout(new GridLayout(4, false));
240 Label lblCdmServer
= new Label(cdmServerComposite
, SWT
.NONE
);
241 lblCdmServer
.setText(Messages
.RemotingLoginDialog_LABEL_CDM_SERVER
);
242 lblCdmServer
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
243 lblCdmServer
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
245 comboCdmServer
= new Combo(cdmServerComposite
, SWT
.READ_ONLY
);
246 comboCdmServer
.addSelectionListener(new SelectionAdapter() {
248 public void widgetSelected(SelectionEvent e
) {
253 GridData gd_comboCdmServer
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
254 comboCdmServer
.setLayoutData(gd_comboCdmServer
);
255 comboCdmServer
.select(0);
257 txtCdmServerStatus
= new Text(cdmServerComposite
, SWT
.BORDER
);
258 txtCdmServerStatus
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
259 txtCdmServerStatus
.setEditable(false);
260 GridData gd_txtCdmServerStatus
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
262 txtCdmServerStatus
.setLayoutData(gd_txtCdmServerStatus
);
264 btnCdmServerRefresh
= new Button(cdmServerComposite
, SWT
.NONE
);
265 btnCdmServerRefresh
.addSelectionListener(new SelectionAdapter() {
267 public void widgetSelected(SelectionEvent e
) {
271 btnCdmServerRefresh
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1));
272 btnCdmServerRefresh
.setText(Messages
.RemotingLoginDialog_LABEL_REFRESH
);
274 Label lblCdmInstance
= new Label(cdmServerComposite
, SWT
.NONE
);
275 GridData gd_lblCdmInstance
= new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1);
276 //gd_lblCdmInstance.heightHint = 30;
277 lblCdmInstance
.setLayoutData(gd_lblCdmInstance
);
278 lblCdmInstance
.setText(Messages
.RemotingLoginDialog_LABEL_CDM_INSTANCE
);
279 lblCdmInstance
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
281 comboCdmInstance
= new Combo(cdmServerComposite
, SWT
.READ_ONLY
);
282 comboCdmInstance
.addSelectionListener(new SelectionAdapter() {
284 public void widgetSelected(SelectionEvent e
) {
285 refreshCdmInstance();
288 GridData gd_comboCdmInstance
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
289 comboCdmInstance
.setLayoutData(gd_comboCdmInstance
);
290 comboCdmInstance
.select(0);
292 txtCdmInstanceStatus
= new Text(cdmServerComposite
, SWT
.BORDER
);
293 txtCdmInstanceStatus
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
294 txtCdmInstanceStatus
.setEditable(false);
295 GridData gd_txtCdmInstanceStatus
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
296 txtCdmInstanceStatus
.setLayoutData(gd_txtCdmInstanceStatus
);
298 btnCdmInstanceRefresh
= new Button(cdmServerComposite
, SWT
.FLAT
);
299 btnCdmInstanceRefresh
.addSelectionListener(new SelectionAdapter() {
301 public void widgetSelected(SelectionEvent e
) {
302 refreshCdmInstance();
305 GridData gd_btnCdmInstanceRefresh
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
306 btnCdmInstanceRefresh
.setLayoutData(gd_btnCdmInstanceRefresh
);
307 btnCdmInstanceRefresh
.setText(Messages
.RemotingLoginDialog_LABEL_REFRESH
);
309 loginComposite
= new Composite(remotingComposite
, SWT
.NONE
);
310 GridData gd_loginComposite
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 1, 1);
311 loginComposite
.setLayoutData(gd_loginComposite
);
312 GridLayout gl_loginComposite
= new GridLayout(6, false);
313 gl_loginComposite
.marginTop
= 5;
314 loginComposite
.setLayout(gl_loginComposite
);
316 lblLogin
= new Label(loginComposite
, SWT
.CENTER
);
317 GridData gd_lblLogin
= new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1);
318 lblLogin
.setLayoutData(gd_lblLogin
);
319 lblLogin
.setText(Messages
.RemotingLoginDialog_LABEL_LOGIN_COLON
);
320 lblLogin
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
322 txtLogin
= new Text(loginComposite
, SWT
.BORDER
);
323 GridData gd_txtLogin
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
324 gd_txtLogin
.minimumWidth
= 80;
325 txtLogin
.setLayoutData(gd_txtLogin
);
327 lblPassword
= new Label(loginComposite
, SWT
.CENTER
);
328 lblPassword
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
329 lblPassword
.setText(Messages
.RemotingLoginDialog_LABEL_PASSWORD
);
330 lblPassword
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
332 txtPassword
= new Text(loginComposite
, SWT
.BORDER
| SWT
.PASSWORD
);
333 GridData gd_txtPassword
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
334 gd_txtPassword
.minimumWidth
= 80;
335 txtPassword
.setLayoutData(gd_txtPassword
);
336 new Label(loginComposite
, SWT
.NONE
);
337 txtPassword
.addKeyListener(new KeyAdapter() {
339 public void keyPressed(KeyEvent e
) {
340 if(e
.character
==SWT
.CR
){
341 connectButtonPressed();
346 btnConnect
= new Button(loginComposite
, SWT
.FLAT
);
347 btnConnect
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1));
348 btnConnect
.addSelectionListener(new SelectionAdapter() {
350 public void widgetSelected(SelectionEvent e
) {
351 connectButtonPressed();
354 btnConnect
.setText(Messages
.RemotingLoginDialog_LABEL_CONNECT
);
356 btnRememberMe
= new Button(loginComposite
, SWT
.CHECK
);
357 btnRememberMe
.setSelection(true);
358 GridData gd_btnRememberMe
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 2, 1);
359 btnRememberMe
.setLayoutData(gd_btnRememberMe
);
360 btnRememberMe
.setText(Messages
.RemotingLoginDialog_LABEL_REMEMBER_ME
);
362 Label lblDefaultLogin
= new Label(loginComposite
, SWT
.NONE
);
363 GridDataFactory
.fillDefaults().span(4, 1).align(SWT
.TRAIL
, SWT
.CENTER
).applyTo(lblDefaultLogin
);
364 lblDefaultLogin
.setText(String
.format(Messages
.RemotingLoginDialog_DEFAULT_LOGIN
, DEFAULT_USER
, DEFAULT_PASS
));
366 styledTxtMessage
= new StyledText(remotingComposite
, SWT
.NONE
);
367 styledTxtMessage
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
368 styledTxtMessage
.setForeground(SWTResourceManager
.getColor(SWT
.COLOR_DARK_RED
));
369 styledTxtMessage
.setFont(SWTResourceManager
.getFont(UBUNTU
, 12, SWT
.BOLD
));
370 styledTxtMessage
.setSelectionBackground(SWTResourceManager
.getColor(SWT
.COLOR_LIST_SELECTION_TEXT
));
371 styledTxtMessage
.setSelectionForeground(SWTResourceManager
.getColor(SWT
.COLOR_DARK_RED
));
372 styledTxtMessage
.setDoubleClickEnabled(false);
373 styledTxtMessage
.setEditable(false);
374 styledTxtMessage
.setWordWrap(true);
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
;
380 styledTxtMessage
.setLayoutData(gd_styledTxtMessage
);
382 xpndblcmpstAdvanced
= new ExpandableComposite(remotingComposite
, SWT
.NONE
, ExpandableComposite
.TWISTIE
);
383 GridData gd_xpndblcmpstAdvanced
= new GridData(SWT
.FILL
, SWT
.FILL
, false, true, 1, 1);
384 xpndblcmpstAdvanced
.setLayoutData(gd_xpndblcmpstAdvanced
);
385 xpndblcmpstAdvanced
.addExpansionListener(new IExpansionListener() {
387 public void expansionStateChanged(ExpansionEvent e
) {
388 shlConnect
.pack(true);
391 public void expansionStateChanging(ExpansionEvent e
) {
394 xpndblcmpstAdvanced
.setText(Messages
.RemotingLoginDialog_LABEL_ADVANCED
);
395 xpndblcmpstAdvanced
.setExpanded(true);
397 compAdvanced
= new Composite(xpndblcmpstAdvanced
, SWT
.NONE
);
398 xpndblcmpstAdvanced
.setClient(compAdvanced
);
399 compAdvanced
.setLayout(new GridLayout(4, false));
401 lblPort
= new Label(compAdvanced
, SWT
.CENTER
);
402 lblPort
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
403 lblPort
.setText(Messages
.RemotingLoginDialog_LABEL_PORT
);
404 lblPort
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
406 txtPort
= new Text(compAdvanced
, SWT
.BORDER
);
407 GridData gd_txtPort
= new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1);
408 gd_txtPort
.minimumWidth
= 50;
409 txtPort
.setLayoutData(gd_txtPort
);
411 lblServerVersion
= new Label(compAdvanced
, SWT
.CENTER
);
412 lblServerVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
413 lblServerVersion
.setText(Messages
.RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION
);
414 lblServerVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
416 txtServerVersion
= new Text(compAdvanced
, SWT
.BORDER
);
417 txtServerVersion
.setEditable(false);
418 txtServerVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1));
419 btnStopServer
= new Button(compAdvanced
, SWT
.FLAT
);
420 btnStopServer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1));
421 btnStopServer
.addMouseListener(new MouseAdapter() {
423 public void mouseUp(MouseEvent e
) {
427 btnStopServer
.setText(Messages
.RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER
);
429 lblEditorVersion
= new Label(compAdvanced
, SWT
.CENTER
);
430 lblEditorVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
431 lblEditorVersion
.setText(Messages
.RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION
);
432 lblEditorVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
434 txtEditorVersion
= new Text(compAdvanced
, SWT
.BORDER
);
435 txtEditorVersion
.setEditable(false);
436 txtEditorVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
437 // new Label(compAdvanced, SWT.NONE);
438 // new Label(compAdvanced, SWT.NONE);
440 lblServerCDMVersion
= new Label(compAdvanced
, SWT
.CENTER
);
441 lblServerCDMVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
442 lblServerCDMVersion
.setText(Messages
.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION
);
443 lblServerCDMVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
445 txtServerCDMVersion
= new Text(compAdvanced
, SWT
.BORDER
);
446 txtServerCDMVersion
.setEditable(false);
447 txtServerCDMVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
448 // new Label(compAdvanced, SWT.NONE);
449 // new Label(compAdvanced, SWT.NONE);
451 lblEditorCDMVersion
= new Label(compAdvanced
, SWT
.CENTER
);
452 lblEditorCDMVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
453 lblEditorCDMVersion
.setText(Messages
.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION
);
454 lblEditorCDMVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
456 txtEditorCDMVersion
= new Text(compAdvanced
, SWT
.BORDER
);
457 txtEditorCDMVersion
.setEditable(false);
458 txtEditorCDMVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
463 private void connectButtonPressed() {
464 if(selectedCsii
.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
465 startManagedServer();
468 if (CdmStore
.isActive() && CdmStore
.currentAuthentiationHasOneOfRoles(Role
.ROLE_REMOTING
)){
469 PreferencesUtil
.setNomenclaturalCodePreferences();
475 private void populateCdmServerCombo() {
476 Job job
= new Job(Messages
.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES
) {
478 protected IStatus
run(IProgressMonitor monitor
) {
479 Display
.getDefault().syncExec(new Runnable() {
482 for(CdmServerInfo csii
: CdmServerInfo
.getCdmServers()) {
483 csiiMap
.put(csii
.getName(), csii
);
484 comboCdmServer
.add(csii
.getName());
486 int serverIndex
= -1;
487 if(serverName
!= null) {
488 serverIndex
= comboCdmServer
.indexOf(serverName
);
490 if(serverIndex
== -1) {
491 comboCdmServer
.select(0);
494 comboCdmServer
.select(serverIndex
);
496 CdmRemoteSource devRemoteSource
= CdmServerInfo
.getDevServerRemoteSource();
497 if(devRemoteSource
!= null) {
498 isDevRemoteSource
= true;
499 String username
= System
.getProperty("cdm.server.dev.username"); //$NON-NLS-1$
500 String password
= System
.getProperty("cdm.server.dev.password"); //$NON-NLS-1$
501 if(username
!= null && !username
.isEmpty() && password
!= null && !password
.isEmpty()) {
502 txtLogin
.setText(username
);
503 txtPassword
.setText(password
);
504 CdmStore
.connect(devRemoteSource
, RemotingLoginDialog
.this);
511 return Status
.OK_STATUS
;
518 private void refreshCdmServer() {
520 txtCdmServerStatus
.setText(STATUS_CHECKING_AVAILABILITY
);
521 clearOnServerChange();
523 updateSelectedCdmServer();
524 Display
.getDefault().asyncExec(new Runnable() {
527 checkSelectedCdmServer();
531 catch(SWTException e
){
532 //catch widget is disposed exception which may occurr if
533 //dialog is closed but the runnable tries to update
537 private void updateSelectedCdmServer() {
538 int selIndex
= comboCdmServer
.getSelectionIndex();
540 selectedCsii
= csiiMap
.get(comboCdmServer
.getItem(selIndex
));
544 private void updatePort() {
545 txtPort
.setText(""); //$NON-NLS-1$
546 if(selectedCsii
!= null) {
547 int port
= selectedCsii
.getPort();
548 if(port
== CdmServerInfo
.NULL_PORT
) {
549 txtPort
.setText(CdmServerInfo
.NULL_PORT_STRING
);
551 txtPort
.setText(String
.valueOf(port
));
556 private int getPort() {
557 int port
= CdmServerInfo
.NULL_PORT
;
559 port
= Integer
.valueOf(txtPort
.getText());
560 } catch (NumberFormatException nfe
) {
561 if(!CdmServerInfo
.NULL_PORT_STRING
.equals(txtPort
.getText())) {
562 setMessage(Messages
.RemotingLoginDialog_MESSAGE_PORT_SHOULD_BE_INTEGER
);
568 private void checkSelectedCdmServer() {
570 if(selectedCsii
!= null) {
571 if(selectedCsii
.isLocalhost()) {
572 txtPort
.setEditable(true);
573 txtPort
.setEnabled(true);
576 if(selectedCsii
.pingServer()) {
577 txtCdmServerStatus
.setText(STATUS_AVAILABLE
);
578 populateCdmInstanceCombo(true);
579 String serverVersionTimestamp
= generateLastModifiedTooltip(selectedCsii
.getCdmlibLastModified());
580 txtServerVersion
.setText(selectedCsii
.getCdmlibServicesVersion() + ":" + serverVersionTimestamp
); //$NON-NLS-1$
582 txtCdmServerStatus
.setText(STATUS_NOT_AVAILABLE
);
583 comboCdmInstance
.removeAll();
584 disableCdmInstanceControls("", ""); //$NON-NLS-1$ //$NON-NLS-2$
586 } catch (CDMServerException
| IOException e
) {
587 txtCdmServerStatus
.setText(STATUS_NOT_AVAILABLE
);
588 // TODO distinguish java.net.ConnectException: Connection refused, java.net.SocketTimeoutException: Read timed out
590 if(e
instanceof CDMServerException
&& e
.getCause() != null){
591 cause
= e
.getCause();
593 String message
= Messages
.RemotingLoginDialog_CONNECTION_FAILED_MESSAGE
;
594 if(cause
instanceof SocketTimeoutException
){
595 message
= Messages
.RemotingLoginDialog_CONNECTION_TIMEOUT_MESSAGE
;
597 MessagingUtils
.warningDialog(Messages
.RemotingLoginDialog_CONNECTION_FAILED_TITLE
, this,
599 logger
.warn(Messages
.RemotingLoginDialog_CONNECTION_FAILED_TITLE
, e
);
604 catch(SWTException e
){
605 //catch widget is disposed exception which may occurr if
606 //dialog is closed but the runnable tries to update
611 private void populateCdmInstanceCombo(final boolean forceRefresh
) {
612 comboCdmInstance
.removeAll();
613 comboCdmInstance
.setEnabled(false);
614 btnConnect
.setEnabled(false);
615 txtCdmInstanceStatus
.setText(STATUS_RETRIEVING
);
616 txtCdmInstanceStatus
.setToolTipText(""); //$NON-NLS-1$
618 serverJob
= new Job(Messages
.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES
) {
620 protected IStatus
run(IProgressMonitor monitor
) {
622 if(selectedCsii
!= null) {
624 selectedCsii
.refreshInstances();
626 final List
<CdmInstanceInfo
> instances
= selectedCsii
.getInstances();
627 Display
.getDefault().asyncExec(new Runnable() {
630 if(!instances
.isEmpty()) {
631 for(CdmInstanceInfo cdmInstance
: instances
) {
632 comboCdmInstance
.add(cdmInstance
.getName());
634 int instanceIndex
= -1;
635 if(instanceName
!= null) {
636 instanceIndex
= comboCdmInstance
.indexOf(instanceName
);
638 if(instanceIndex
== -1) {
639 comboCdmInstance
.select(0);
642 comboCdmInstance
.select(instanceIndex
);
644 refreshCdmInstance();
645 comboCdmInstance
.setEnabled(true);
651 txtCdmInstanceStatus
.setText(STATUS_NO_INSTANCES
);
652 btnConnect
.setEnabled(false);
657 } catch (final CDMServerException e
) {
658 MessagingUtils
.warn(getClass(), e
);
659 Display
.getDefault().asyncExec(new Runnable() {
662 disableCdmInstanceControls(STATUS_NOT_AVAILABLE
, e
.getMessage());
666 return Status
.OK_STATUS
;
670 if(txtCdmServerStatus
.getText().equals(STATUS_AVAILABLE
) && !isDevRemoteSource
) {
672 serverJob
.schedule();
676 private void disableCdmInstanceControls(String cdmInstanceStatus
, String tooltip
) {
677 txtCdmInstanceStatus
.setText(cdmInstanceStatus
);
678 txtCdmInstanceStatus
.setToolTipText(tooltip
);
679 comboCdmInstance
.setEnabled(false);
680 btnConnect
.setEnabled(false);
683 private void refreshCdmInstance() {
684 txtCdmInstanceStatus
.setText(STATUS_CHECKING_AVAILABILITY
);
685 clearOnInstanceChange();
686 updateSelectedCdmInstance();
687 checkSelectedCdmInstance();
688 updateManagedServerControls();
691 private void updateSelectedCdmInstance() {
692 int selIndex
= comboCdmInstance
.getSelectionIndex();
694 selectedCdmInstance
= selectedCsii
.getInstanceFromName(comboCdmInstance
.getItem(selIndex
));
697 readPrefCredentials();
702 private void updateManagedServerControls() {
703 if(selectedCsii
.isLocalhostMgd()) {
704 if(isSelectedCdmInstanceRunningInManagedServer()) {
705 txtCdmInstanceStatus
.setText(STATUS_STARTED
);
707 txtCdmInstanceStatus
.setText(STATUS_NOT_STARTED
);
709 btnConnect
.setEnabled(true);
710 selectedCsii
.setPort(getManagedServerPort());
715 if(isManagedServerRunning()) {
716 btnStopServer
.setEnabled(true);
718 btnStopServer
.setEnabled(false);
722 private boolean isManagedServerRunning() {
723 return CdmStore
.getManagedServer() != null && CdmStore
.getManagedServer().isAlive();
726 private boolean isSelectedCdmInstanceRunningInManagedServer() {
727 return CdmStore
.getManagedServer() != null &&
728 CdmStore
.getManagedServer().isAlive() &&
729 selectedCsii
.isLocalhostMgd() &&
730 CdmStore
.getManagedServer().getDataSourceName().equals(selectedCdmInstance
.getName());
733 private void startManagedServer() {
734 if(isManagedServerRunning()) {
735 if(CdmStore
.getManagedServer().getDataSourceName().equals(selectedCdmInstance
.getName())) {
738 Display
.getDefault().syncExec(new Runnable() {
748 Job job
= new Job(Messages
.RemotingLoginDialog_JOB_SERVER_LAUNCH
) {
751 public IStatus
run(IProgressMonitor monitor
) {
752 String mgdServerConfigFileName
= "mgd.datasources.xml"; //$NON-NLS-1$
753 String config
= CDMServerUtils
.convertEditorToServerConfig();
754 File managedServerConfigFile
;
756 monitor
.beginTask(Messages
.RemotingLoginDialog_TASK_LAUNCHING_SERVER
, maxUnits
);
758 monitor
.subTask(String
.format(Messages
.RemotingLoginDialog_GENERATING_CONFIG_FILE
, selectedCdmInstance
.getName()));
759 managedServerConfigFile
= CDMServerUtils
.writeManagedServerConfig(config
, mgdServerConfigFileName
);
761 boolean forceSchemaCreate
= CdmStore
.getManagedServer() != null
762 && CdmStore
.getManagedServer().getDataSourceName().equals(selectedCdmInstance
.getName())
763 && CdmStore
.getManagedServer().isForceSchemaCreate();
764 CdmStore
.setManagedServer(new CDMServer(selectedCdmInstance
.getName(), managedServerConfigFile
));
765 CdmStore
.getManagedServer().setForceSchemaCreate(forceSchemaCreate
);
766 monitor
.subTask(Messages
.RemotingLoginDialog_STARTING_MGD_SERVER
);
767 CdmStore
.getManagedServer().start(false, RemotingLoginDialog
.this);
770 // the following loop is a 'fake' progress monitoring where the progress
771 // bar is advanced by one unit every second until maxUnits -2
772 while(!CdmStore
.getManagedServer().isStarted() && !CdmStore
.getManagedServer().isFailed()) {
773 if(serverUnits
< maxUnits
- 2) {
776 } catch (InterruptedException e
) {
782 Display
.getDefault().asyncExec(new Runnable() {
786 updateManagedServerControls();
790 } catch (IOException ioe
) {
791 MessagingUtils
.errorDialog(Messages
.RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE
,
794 TaxeditorStorePlugin
.PLUGIN_ID
,
797 } catch (CDMEmbeddedServerException cse
) {
798 MessagingUtils
.errorDialog(Messages
.RemotingLoginDialog_ERROR_STARTING_SERVER
,
801 TaxeditorStorePlugin
.PLUGIN_ID
,
807 // NOTE: Errors thrown during server startup are passed to the handleError() implementation
808 // TODO: is the above catch clause for CDMEmbeddedServerException still valuable?
810 return Status
.OK_STATUS
;
815 job
.setProperty(IProgressConstants
.KEEP_PROPERTY
, true);
824 public void handleError(final Throwable t
) {
826 if(CdmStore
.getManagedServer().isFailed() && CdmStore
.getManagedServer().isPotentiallyMissingSchema()) {
827 CdmStore
.getManagedServer().setForceSchemaCreate(true);
828 // we are in a separate thread here, thus update the screen via
829 Display
.getDefault().asyncExec(new Runnable() {
832 btnConnect
.setEnabled(true);
833 btnConnect
.setText("Create Schema");
834 btnConnect
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_RED
));
835 btnConnect
.requestLayout();
839 Display
.getDefault().syncExec(new Runnable() {
844 String title
= Messages
.RemotingLoginDialog_SERVER_LAUNCH_ERROR
;
845 String message
= t
.getMessage();
848 MessagingUtils
.errorDialog(title
,
851 TaxeditorStorePlugin
.PLUGIN_ID
,
859 private void stopManagedServer() {
861 CdmStore
.getManagedServer().stop();
862 } catch (Exception e
) {
863 MessagingUtils
.errorDialog(Messages
.RemotingLoginDialog_ERROR_STOPPING_SERVER
,
865 String
.format(Messages
.RemotingLoginDialog_COULD_NOT_STOP_SERVER
, CdmStore
.getManagedServer().getPort()),
866 TaxeditorStorePlugin
.PLUGIN_ID
,
870 CdmStore
.setManagedServer(null);
871 updateManagedServerControls();
874 private int getManagedServerPort() {
875 return CdmStore
.getManagedServer() == null ? CdmServerInfo
.NULL_PORT
: CdmStore
.getManagedServer().getPort();
878 private void checkSelectedCdmInstance() {
879 boolean available
= false;
880 String status
= STATUS_NOT_AVAILABLE
;
881 String message
= null;
883 if(txtCdmServerStatus
.getText().equals(STATUS_AVAILABLE
)) {
885 if(selectedCsii
.pingInstance(selectedCdmInstance
, getPort())) {
886 status
= STATUS_AVAILABLE
;
889 status
= STATUS_NOT_AVAILABLE
;
894 txtServerCDMVersion
.setText(selectedCsii
.getCdmRemoteSource(selectedCdmInstance
, getPort()).getDbSchemaVersion());
895 int compareDbSchemaVersion
= selectedCsii
.compareDbSchemaVersion(selectedCdmInstance
, getPort());
896 int compareCdmlibServicesVersion
= 0;
897 boolean disableServicesApiTimestampCheck
=
898 PreferencesUtil
.getBooleanValue((IPreferenceKeys
.DISABLE_SERVICES_API_TIMESTAMP_CHECK
));
899 if(!disableServicesApiTimestampCheck
) {
900 compareCdmlibServicesVersion
= selectedCsii
.compareCdmlibServicesVersion();
902 if(compareDbSchemaVersion
> 0 || compareCdmlibServicesVersion
> 0) {
903 status
= STATUS_NOT_COMPATIBLE
;
905 message
= MESG_COMPATIBLE_EDITOR_OLD
;
906 } else if(compareDbSchemaVersion
< 0 || compareCdmlibServicesVersion
< 0) {
907 status
= STATUS_NOT_COMPATIBLE
;
909 message
= MESG_COMPATIBLE_SERVER_OLD
;
911 status
= STATUS_AVAILABLE
;
913 message
= ""; //$NON-NLS-1$
916 } catch (Exception e
) {
917 txtCdmInstanceStatus
.setToolTipText(e
.getMessage());
919 btnConnect
.setEnabled(available
);
920 txtCdmInstanceStatus
.setText(status
);
921 if(!StringUtils
.isBlank(message
)) {
928 private void connect() {
929 checkSelectedCdmInstance();
931 if(!txtCdmInstanceStatus
.getText().equals(STATUS_AVAILABLE
)) {
935 ICdmRemoteSource source
= selectedCsii
.getCdmRemoteSource(selectedCdmInstance
, getPort());
937 if(!validateLogin(source
)) {
942 CdmStore
.connect(source
, this);
943 } catch (Exception e
) {
944 // Do not expect anything to go wrong at this point, so we throw a runtime exception
946 throw new RuntimeException(e
);
951 public boolean isRememberMe() {
952 return btnRememberMe
.getSelection();
955 private void persistPrefLastServerInstance() {
956 IEclipsePreferences preferences
= ConfigurationScope
.INSTANCE
.getNode(STORE_PREFERENCES_NODE
);
957 Preferences lastServerInstancePrefs
= preferences
.node(LAST_SERVER_INSTANCE_NODE
);
959 lastServerInstancePrefs
.put(LAST_SERVER_KEY
, selectedCsii
.getName());
960 lastServerInstancePrefs
.put(LAST_INSTANCE_KEY
, selectedCdmInstance
.getName());
962 flushPreferences(lastServerInstancePrefs
);
965 private void persistPrefCredentials() {
966 IEclipsePreferences preferences
= ConfigurationScope
.INSTANCE
.getNode(STORE_PREFERENCES_NODE
);
967 Preferences credentialsPrefs
= preferences
.node(LOGIN_NODE
);
968 credentialsPrefs
.put(getUsernamePrefKey(), txtLogin
.getText());
969 credentialsPrefs
.put(getPasswordPrefKey(), txtPassword
.getText());
970 flushPreferences(credentialsPrefs
);
973 private void removePrefCredentials() {
974 IEclipsePreferences preferences
= ConfigurationScope
.INSTANCE
.getNode(STORE_PREFERENCES_NODE
);
975 Preferences credentialsPrefs
= preferences
.node(LOGIN_NODE
);
976 credentialsPrefs
.put(getUsernamePrefKey(), txtLogin
.getText());
977 credentialsPrefs
.put(getPasswordPrefKey(), txtPassword
.getText());
978 removePreferences(credentialsPrefs
);
980 private void removePreferences(Preferences prefs
) {
983 } catch (BackingStoreException bse
) {
984 setMessage(bse
.getMessage());
987 private void flushPreferences(Preferences prefs
) {
990 } catch (BackingStoreException bse
) {
991 setMessage(bse
.getMessage());
997 private void readPrefCredentials() {
998 String username
, password
;
999 IEclipsePreferences preferences
= ConfigurationScope
.INSTANCE
.getNode(STORE_PREFERENCES_NODE
);
1000 Preferences credentialsPrefs
= preferences
.node(LOGIN_NODE
);
1001 username
= credentialsPrefs
.get(getUsernamePrefKey(), ""); //$NON-NLS-1$
1002 txtLogin
.setText(username
);
1003 password
= credentialsPrefs
.get(getPasswordPrefKey(),""); //$NON-NLS-1$
1004 txtPassword
.setText(password
);
1005 if(username
.isEmpty() || password
.isEmpty()) {
1006 autoConnect
= false;
1010 private void readPrefLastServerInstance() {
1011 IEclipsePreferences preferences
= ConfigurationScope
.INSTANCE
.getNode(STORE_PREFERENCES_NODE
);
1012 Preferences lastServerInstancePrefs
= preferences
.node(LAST_SERVER_INSTANCE_NODE
);
1014 serverName
= lastServerInstancePrefs
.get(LAST_SERVER_KEY
, null);
1015 instanceName
= lastServerInstancePrefs
.get(LAST_INSTANCE_KEY
, null);
1018 private void emptyCredentials() {
1019 txtLogin
.setText(""); //$NON-NLS-1$
1020 txtPassword
.setText(""); //$NON-NLS-1$
1023 private String
getUsernamePrefKey() {
1024 return selectedCsii
.toString(selectedCdmInstance
.getName(), isDevRemoteSource?
getPort():-1) + USERNAME_SUFFIX
;
1027 private String
getPasswordPrefKey() {
1028 return selectedCsii
.toString(selectedCdmInstance
.getName(), isDevRemoteSource?
getPort():-1) + PASSWORD_SUFFIX
;
1031 private boolean validateLogin(ICdmRemoteSource remoteSource
) {
1032 if(getUsername() == null || getUsername().isEmpty()) {
1033 setMessage(Messages
.RemotingLoginDialog_LOGIN_CANNOT_BE_EMPTY
);
1036 if(getPassword() == null || getPassword().isEmpty()) {
1037 setMessage(Messages
.RemotingLoginDialog_PASSWORD_CANNOT_BE_EMPTY
);
1043 IUserService userService
= CdmApplicationRemoteConfiguration
.getUserService(remoteSource
);
1044 UsernamePasswordAuthenticationToken token
= new UsernamePasswordAuthenticationToken(getUsername(), getPassword());
1045 CdmApplicationRemoteConfiguration
.getAuthenticationManager(userService
).authenticate(token
);
1046 } catch(BadCredentialsException e
){
1047 setMessage(LoginManager
.INCORRECT_CREDENTIALS_MESSAGE
);
1049 } catch(LockedException e
){
1050 setMessage(LoginManager
.ACCOUNT_LOCKED_MESSAGE
);
1052 } catch(IllegalArgumentException e
){
1053 setMessage(LoginManager
.INCORRECT_CREDENTIALS_MESSAGE
);
1059 public String
getUsername() {
1060 return txtLogin
.getText();
1063 public String
getPassword() {
1064 return txtPassword
.getText();
1067 public void setMessage(String message
) {
1068 if(message
!= null && !message
.isEmpty()) {
1069 // if(message.length() > 50) {
1070 // styledTxtMessage.setToolTipText(message);
1071 // message = message.substring(0,50) + "..."; //$NON-NLS-1$
1073 styledTxtMessage
.setText(message
);
1074 styledTxtMessage
.setVisible(true);
1075 ((GridData
)styledTxtMessage
.getLayoutData()).exclude
= false;
1076 // shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1077 shlConnect
.pack(true);
1079 if (!styledTxtMessage
.isDisposed()){
1080 styledTxtMessage
.setText(""); //$NON-NLS-1$
1081 styledTxtMessage
.setVisible(false);
1082 ((GridData
)styledTxtMessage
.getLayoutData()).exclude
= true;
1084 if(!shlConnect
.isDisposed()){
1085 shlConnect
.pack(true);
1088 if (!remotingComposite
.isDisposed()){
1089 remotingComposite
.layout();
1093 // private int getHeightWithoutMessage() {
1094 // if(xpndblcmpstAdvanced.isExpanded()) {
1095 // return MIN_EXP_HEIGHT;
1097 // return MIN_HEIGHT;
1102 public void hide(boolean isHidden
) {
1103 if (!shlConnect
.isDisposed()){
1104 if(shlConnect
!= null && shlConnect
.getDisplay() != null) {
1105 shlConnect
.setVisible(!isHidden
);
1109 public void dispose() {
1110 if (!shlConnect
.isDisposed()){
1111 if(shlConnect
!= null && shlConnect
.getDisplay() != null) {
1112 shlConnect
.dispose();
1117 public void onComplete() {
1118 Display
.getDefault().asyncExec(new Runnable() {
1121 if(selectedCdmInstance
!=null){
1122 if(isRememberMe()) {
1123 persistPrefCredentials();
1125 removePrefCredentials();
1127 persistPrefLastServerInstance();
1134 private String
generateLastModifiedTooltip(String cdmlibLastModified
) {
1135 if(StringUtils
.isBlank(cdmlibLastModified
)) {
1136 return ""; //$NON-NLS-1$
1138 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy.MM.dd.HH.mm.z"); //$NON-NLS-1$
1139 Date cdmlibLastModifiedDate
;
1140 String cdmlibLastModifiedTimestamp
= ""; //$NON-NLS-1$
1142 cdmlibLastModifiedDate
= new Date(Long
.valueOf(cdmlibLastModified
));
1143 cdmlibLastModifiedTimestamp
= sdf
.format(cdmlibLastModifiedDate
);
1145 return cdmlibLastModifiedTimestamp
;
1148 private void setEditorInfo() {
1149 txtEditorCDMVersion
.setText(CdmMetaData
.getDbSchemaVersion());
1150 String editorVersionTimestamp
= generateLastModifiedTooltip(CdmApplicationState
.getCdmlibLastModified());
1151 txtEditorVersion
.setText(CdmApplicationState
.getCdmlibVersion() + ":" + editorVersionTimestamp
); //$NON-NLS-1$
1154 private void clearOnServerChange() {
1155 setMessage(""); //$NON-NLS-1$
1156 txtServerCDMVersion
.setText(""); //$NON-NLS-1$
1157 txtServerVersion
.setText(""); //$NON-NLS-1$
1158 txtServerVersion
.setToolTipText(""); //$NON-NLS-1$
1159 txtServerCDMVersion
.setText(""); //$NON-NLS-1$
1160 comboCdmInstance
.removeAll();
1161 txtCdmInstanceStatus
.setText(""); //$NON-NLS-1$
1162 txtPort
.setEditable(false);
1163 txtPort
.setEnabled(false);
1166 private void clearOnInstanceChange() {
1167 setMessage(""); //$NON-NLS-1$
1168 txtServerCDMVersion
.setText(""); //$NON-NLS-1$