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
;
172 public RemotingLoginDialog(Shell parent
, int style
) {
173 super(parent
, style
);
174 setText(Messages
.RemotingLoginDialog_LABEL_LOGIN
);
177 public Object
open(CdmRemoteSource source
, boolean loadLoginPrefs
, boolean autoConnect
) {
178 this.loadLoginPrefs
= loadLoginPrefs
;
179 this.serverName
= source
.getName();
180 String contextPath
= source
.getContextPath();
181 this.instanceName
= contextPath
.substring(contextPath
.lastIndexOf("/") + 1); //$NON-NLS-1$
182 return open(serverName
, instanceName
, loadLoginPrefs
, autoConnect
);
186 public Object
open(String serverName
, String instanceName
, boolean loadLoginPrefs
, boolean autoConnect
) {
187 this.serverName
= serverName
;
188 this.instanceName
= instanceName
;
189 this.loadLoginPrefs
= loadLoginPrefs
;
190 this.autoConnect
= autoConnect
;
198 public Object
open() {
201 if(serverName
== null && instanceName
== null) {
202 readPrefLastServerInstance();
206 populateCdmServerCombo();
207 shlConnect
.pack(true);
210 xpndblcmpstAdvanced
.setExpanded(false);
212 Display display
= getParent().getDisplay();
214 while (!shlConnect
.isDisposed()) {
215 if (!display
.isDisposed()){
216 if (!display
.readAndDispatch()) {
226 * Create contents of the dialog.
228 private void createContents() {
229 shlConnect
= new Shell(getParent(), SWT
.DIALOG_TRIM
| SWT
.APPLICATION_MODAL
| SWT
.RESIZE
);
230 shlConnect
.setText(Messages
.RemotingLoginDialog_LABEL_CONNECT
);
231 shlConnect
.setLayout(new FillLayout(SWT
.HORIZONTAL
));
233 remotingComposite
= new Composite(shlConnect
, SWT
.NONE
);
234 remotingComposite
.setLayout(new GridLayout(1, false));
236 Composite cdmServerComposite
= new Composite(remotingComposite
, SWT
.NONE
);
237 GridData gd_cdmServerComposite
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 1, 1);
238 cdmServerComposite
.setLayoutData(gd_cdmServerComposite
);
239 cdmServerComposite
.setLayout(new GridLayout(4, false));
241 Label lblCdmServer
= new Label(cdmServerComposite
, SWT
.NONE
);
242 lblCdmServer
.setText(Messages
.RemotingLoginDialog_LABEL_CDM_SERVER
);
243 lblCdmServer
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
244 lblCdmServer
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
246 comboCdmServer
= new Combo(cdmServerComposite
, SWT
.READ_ONLY
);
247 comboCdmServer
.addSelectionListener(new SelectionAdapter() {
249 public void widgetSelected(SelectionEvent e
) {
254 GridData gd_comboCdmServer
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
255 comboCdmServer
.setLayoutData(gd_comboCdmServer
);
256 comboCdmServer
.select(0);
258 txtCdmServerStatus
= new Text(cdmServerComposite
, SWT
.BORDER
);
259 txtCdmServerStatus
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
260 txtCdmServerStatus
.setEditable(false);
261 GridData gd_txtCdmServerStatus
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
263 txtCdmServerStatus
.setLayoutData(gd_txtCdmServerStatus
);
265 btnCdmServerRefresh
= new Button(cdmServerComposite
, SWT
.NONE
);
266 btnCdmServerRefresh
.addSelectionListener(new SelectionAdapter() {
268 public void widgetSelected(SelectionEvent e
) {
272 btnCdmServerRefresh
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1));
273 btnCdmServerRefresh
.setText(Messages
.RemotingLoginDialog_LABEL_REFRESH
);
275 Label lblCdmInstance
= new Label(cdmServerComposite
, SWT
.NONE
);
276 GridData gd_lblCdmInstance
= new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1);
277 //gd_lblCdmInstance.heightHint = 30;
278 lblCdmInstance
.setLayoutData(gd_lblCdmInstance
);
279 lblCdmInstance
.setText(Messages
.RemotingLoginDialog_LABEL_CDM_INSTANCE
);
280 lblCdmInstance
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
282 comboCdmInstance
= new Combo(cdmServerComposite
, SWT
.READ_ONLY
);
283 comboCdmInstance
.addSelectionListener(new SelectionAdapter() {
285 public void widgetSelected(SelectionEvent e
) {
286 refreshCdmInstance();
289 GridData gd_comboCdmInstance
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
290 comboCdmInstance
.setLayoutData(gd_comboCdmInstance
);
291 comboCdmInstance
.select(0);
293 txtCdmInstanceStatus
= new Text(cdmServerComposite
, SWT
.BORDER
);
294 txtCdmInstanceStatus
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
295 txtCdmInstanceStatus
.setEditable(false);
296 GridData gd_txtCdmInstanceStatus
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
297 txtCdmInstanceStatus
.setLayoutData(gd_txtCdmInstanceStatus
);
299 btnCdmInstanceRefresh
= new Button(cdmServerComposite
, SWT
.FLAT
);
300 btnCdmInstanceRefresh
.addSelectionListener(new SelectionAdapter() {
302 public void widgetSelected(SelectionEvent e
) {
303 refreshCdmInstance();
306 GridData gd_btnCdmInstanceRefresh
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1);
307 btnCdmInstanceRefresh
.setLayoutData(gd_btnCdmInstanceRefresh
);
308 btnCdmInstanceRefresh
.setText(Messages
.RemotingLoginDialog_LABEL_REFRESH
);
310 loginComposite
= new Composite(remotingComposite
, SWT
.NONE
);
311 GridData gd_loginComposite
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 1, 1);
312 loginComposite
.setLayoutData(gd_loginComposite
);
313 GridLayout gl_loginComposite
= new GridLayout(6, false);
314 gl_loginComposite
.marginTop
= 5;
315 loginComposite
.setLayout(gl_loginComposite
);
317 lblLogin
= new Label(loginComposite
, SWT
.CENTER
);
318 GridData gd_lblLogin
= new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1);
319 lblLogin
.setLayoutData(gd_lblLogin
);
320 lblLogin
.setText(Messages
.RemotingLoginDialog_LABEL_LOGIN_COLON
);
321 lblLogin
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
323 txtLogin
= new Text(loginComposite
, SWT
.BORDER
);
324 GridData gd_txtLogin
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
325 gd_txtLogin
.minimumWidth
= 80;
326 txtLogin
.setLayoutData(gd_txtLogin
);
328 lblPassword
= new Label(loginComposite
, SWT
.CENTER
);
329 lblPassword
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
330 lblPassword
.setText(Messages
.RemotingLoginDialog_LABEL_PASSWORD
);
331 lblPassword
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
333 txtPassword
= new Text(loginComposite
, SWT
.BORDER
| SWT
.PASSWORD
);
334 GridData gd_txtPassword
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
335 gd_txtPassword
.minimumWidth
= 80;
336 txtPassword
.setLayoutData(gd_txtPassword
);
337 new Label(loginComposite
, SWT
.NONE
);
338 txtPassword
.addKeyListener(new KeyAdapter() {
340 public void keyPressed(KeyEvent e
) {
341 if(e
.character
==SWT
.CR
){
342 connectButtonPressed();
347 btnConnect
= new Button(loginComposite
, SWT
.FLAT
);
348 btnConnect
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1));
349 btnConnect
.addSelectionListener(new SelectionAdapter() {
351 public void widgetSelected(SelectionEvent e
) {
352 connectButtonPressed();
355 btnConnect
.setText(Messages
.RemotingLoginDialog_LABEL_CONNECT
);
357 btnRememberMe
= new Button(loginComposite
, SWT
.CHECK
);
358 btnRememberMe
.setSelection(true);
359 GridData gd_btnRememberMe
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 2, 1);
360 btnRememberMe
.setLayoutData(gd_btnRememberMe
);
361 btnRememberMe
.setText(Messages
.RemotingLoginDialog_LABEL_REMEMBER_ME
);
363 Label lblDefaultLogin
= new Label(loginComposite
, SWT
.NONE
);
364 GridDataFactory
.fillDefaults().span(4, 1).align(SWT
.TRAIL
, SWT
.CENTER
).applyTo(lblDefaultLogin
);
365 lblDefaultLogin
.setText(String
.format(Messages
.RemotingLoginDialog_DEFAULT_LOGIN
, DEFAULT_USER
, DEFAULT_PASS
));
367 styledTxtMessage
= new StyledText(remotingComposite
, SWT
.NONE
);
368 styledTxtMessage
.setBackground(SWTResourceManager
.getColor(SWT
.COLOR_INFO_BACKGROUND
));
369 styledTxtMessage
.setForeground(SWTResourceManager
.getColor(SWT
.COLOR_DARK_RED
));
370 styledTxtMessage
.setFont(SWTResourceManager
.getFont(UBUNTU
, 12, SWT
.BOLD
));
371 styledTxtMessage
.setSelectionBackground(SWTResourceManager
.getColor(SWT
.COLOR_LIST_SELECTION_TEXT
));
372 styledTxtMessage
.setSelectionForeground(SWTResourceManager
.getColor(SWT
.COLOR_DARK_RED
));
373 styledTxtMessage
.setDoubleClickEnabled(false);
374 styledTxtMessage
.setEditable(false);
375 styledTxtMessage
.setWordWrap(true);
377 GridData gd_styledTxtMessage
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1);
378 gd_styledTxtMessage
.exclude
= true;
379 gd_styledTxtMessage
.minimumHeight
= MESSAGE_HEIGHT
;
381 styledTxtMessage
.setLayoutData(gd_styledTxtMessage
);
383 xpndblcmpstAdvanced
= new ExpandableComposite(remotingComposite
, SWT
.NONE
, ExpandableComposite
.TWISTIE
);
384 GridData gd_xpndblcmpstAdvanced
= new GridData(SWT
.FILL
, SWT
.FILL
, false, true, 1, 1);
385 xpndblcmpstAdvanced
.setLayoutData(gd_xpndblcmpstAdvanced
);
386 xpndblcmpstAdvanced
.addExpansionListener(new IExpansionListener() {
388 public void expansionStateChanged(ExpansionEvent e
) {
389 shlConnect
.pack(true);
392 public void expansionStateChanging(ExpansionEvent e
) {
395 xpndblcmpstAdvanced
.setText(Messages
.RemotingLoginDialog_LABEL_ADVANCED
);
396 xpndblcmpstAdvanced
.setExpanded(true);
398 compAdvanced
= new Composite(xpndblcmpstAdvanced
, SWT
.NONE
);
399 xpndblcmpstAdvanced
.setClient(compAdvanced
);
400 compAdvanced
.setLayout(new GridLayout(4, false));
402 lblPort
= new Label(compAdvanced
, SWT
.CENTER
);
403 lblPort
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
404 lblPort
.setText(Messages
.RemotingLoginDialog_LABEL_PORT
);
405 lblPort
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
407 txtPort
= new Text(compAdvanced
, SWT
.BORDER
);
408 GridData gd_txtPort
= new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1);
409 gd_txtPort
.minimumWidth
= 50;
410 txtPort
.setLayoutData(gd_txtPort
);
412 lblServerVersion
= new Label(compAdvanced
, SWT
.CENTER
);
413 lblServerVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
414 lblServerVersion
.setText(Messages
.RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION
);
415 lblServerVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
417 txtServerVersion
= new Text(compAdvanced
, SWT
.BORDER
);
418 txtServerVersion
.setEditable(false);
419 txtServerVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1));
420 btnStopServer
= new Button(compAdvanced
, SWT
.FLAT
);
421 btnStopServer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1));
422 btnStopServer
.addMouseListener(new MouseAdapter() {
424 public void mouseUp(MouseEvent e
) {
428 btnStopServer
.setText(Messages
.RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER
);
430 lblEditorVersion
= new Label(compAdvanced
, SWT
.CENTER
);
431 lblEditorVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
432 lblEditorVersion
.setText(Messages
.RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION
);
433 lblEditorVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
435 txtEditorVersion
= new Text(compAdvanced
, SWT
.BORDER
);
436 txtEditorVersion
.setEditable(false);
437 txtEditorVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
438 // new Label(compAdvanced, SWT.NONE);
439 // new Label(compAdvanced, SWT.NONE);
441 lblServerCDMVersion
= new Label(compAdvanced
, SWT
.CENTER
);
442 lblServerCDMVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
443 lblServerCDMVersion
.setText(Messages
.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION
);
444 lblServerCDMVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
446 txtServerCDMVersion
= new Text(compAdvanced
, SWT
.BORDER
);
447 txtServerCDMVersion
.setEditable(false);
448 txtServerCDMVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
449 // new Label(compAdvanced, SWT.NONE);
450 // new Label(compAdvanced, SWT.NONE);
452 lblEditorCDMVersion
= new Label(compAdvanced
, SWT
.CENTER
);
453 lblEditorCDMVersion
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
454 lblEditorCDMVersion
.setText(Messages
.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION
);
455 lblEditorCDMVersion
.setFont(SWTResourceManager
.getFont(UBUNTU
, 9, SWT
.NORMAL
));
457 txtEditorCDMVersion
= new Text(compAdvanced
, SWT
.BORDER
);
458 txtEditorCDMVersion
.setEditable(false);
459 txtEditorCDMVersion
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
464 private void connectButtonPressed() {
465 if(selectedCsii
.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
466 startManagedServer();
469 if (CdmStore
.isActive() && CdmStore
.currentAuthentiationHasOneOfRoles(Role
.ROLE_REMOTING
)){
470 PreferencesUtil
.setNomenclaturalCodePreferences();
476 private void populateCdmServerCombo() {
477 Job job
= new Job(Messages
.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES
) {
479 protected IStatus
run(IProgressMonitor monitor
) {
480 Display
.getDefault().syncExec(new Runnable() {
483 for(CdmServerInfo csii
: CdmServerInfo
.getCdmServers()) {
484 csiiMap
.put(csii
.getName(), csii
);
485 comboCdmServer
.add(csii
.getName());
487 int serverIndex
= -1;
488 if(serverName
!= null) {
489 serverIndex
= comboCdmServer
.indexOf(serverName
);
491 if(serverIndex
== -1) {
492 comboCdmServer
.select(0);
495 comboCdmServer
.select(serverIndex
);
497 CdmRemoteSource devRemoteSource
= CdmServerInfo
.getDevServerRemoteSource();
498 if(devRemoteSource
!= null) {
499 isDevRemoteSource
= true;
500 String username
= System
.getProperty("cdm.server.dev.username"); //$NON-NLS-1$
501 String password
= System
.getProperty("cdm.server.dev.password"); //$NON-NLS-1$
502 if(username
!= null && !username
.isEmpty() && password
!= null && !password
.isEmpty()) {
503 txtLogin
.setText(username
);
504 txtPassword
.setText(password
);
505 CdmStore
.connect(devRemoteSource
, RemotingLoginDialog
.this);
512 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$