Project

General

Profile

« Previous | Next » 

Revision 8034ad47

Added by Andreas Müller almost 4 years ago

revert unwanted RemotingLoginDialog changes

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
60 60
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
61 61
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
62 62
import eu.etaxonomy.cdm.api.service.IUserService;
63
import eu.etaxonomy.cdm.common.CdmUtils;
64
import eu.etaxonomy.cdm.config.CdmSourceException;
65 63
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
66 64
import eu.etaxonomy.cdm.persistence.permission.Role;
67 65
import eu.etaxonomy.taxeditor.l10n.Messages;
......
113 111

  
114 112
    private final static String MESG_COMPATIBLE_EDITOR_OLD = Messages.RemotingLoginDialog_UPDATE_EDITOR;
115 113
    private final static String MESG_COMPATIBLE_SERVER_OLD = Messages.RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER;
116
    private final static String MESG_SCHEMA_MISSING = Messages.RemotingLoginDialog_SCHEMA_MISSING;
117
    private final static String MESG_NO_SCHEMA = Messages.RemotingLoginDialog_NO_SCHEMA;
118

  
119
    private final static String LABEL_CONNECT = Messages.RemotingLoginDialog_LABEL_CONNECT;
120
    private final static String LABEL_CREATE_SCHEMA = Messages.RemotingLoginDialog_LABEL_CREATE_SCHEMA;
121
    private final static String LABEL_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION;
122
    private final static String MESG_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION;
123 114

  
124 115
    private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$
125 116

  
......
132 123
    private final static String LAST_INSTANCE_KEY = "lastInstanceKey"; //$NON-NLS-1$
133 124

  
134 125
    private Composite remotingComposite;
135
    private CdmServerInfo selectedServerInfo;
126
    private CdmServerInfo selectedCsii;
136 127
    private CdmInstanceInfo selectedCdmInstance;
137 128
    private Button btnCdmServerRefresh;
138 129
    private Button btnCdmInstanceRefresh;
......
148 139
    private Text txtPort;
149 140
    private Label lblServerVersion;
150 141
    private Text txtServerVersion;
151
    private ExpandableComposite expandableCompositeAdvanced;
142
    private ExpandableComposite xpndblcmpstAdvanced;
152 143
    private StyledText styledTxtMessage;
153 144

  
154 145
//    private final int MIN_WIDTH = 530;
......
158 149
    private final int MESSAGE_HEIGHT = 50;
159 150
    private Label lblEditorVersion;
160 151
    private Text txtEditorVersion;
161
    private Label lblServerCdmVersion;
162
    private Text txtServerCdmVersion;
163
    private Label lblEditorCdmVersion;
164
    private Text txtEditorCdmVersion;
152
    private Label lblServerCDMVersion;
153
    private Text txtServerCDMVersion;
154
    private Label lblEditorCDMVersion;
155
    private Text txtEditorCDMVersion;
165 156

  
166 157
    private String serverName, instanceName;
167 158
    private boolean autoConnect = false;
......
187 178
        return open(serverName, instanceName, loadLoginPrefs, autoConnect);
188 179
    }
189 180

  
181

  
190 182
    public Object open(String serverName, String instanceName, boolean loadLoginPrefs, boolean autoConnect) {
191 183
        this.serverName = serverName;
192 184
        this.instanceName = instanceName;
......
211 203
        shlConnect.pack(true);
212 204
        shlConnect.open();
213 205

  
214
        expandableCompositeAdvanced.setExpanded(false);
206
        xpndblcmpstAdvanced.setExpanded(false);
215 207

  
216 208
        Display display = getParent().getDisplay();
217 209

  
......
231 223
     */
232 224
    private void createContents() {
233 225
        shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
234
        shlConnect.setText(LABEL_CONNECT);
226
        shlConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
235 227
        shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL));
236 228

  
237 229
        remotingComposite = new Composite(shlConnect, SWT.NONE);
238 230
        remotingComposite.setLayout(new GridLayout(1, false));
239 231

  
240
        //server
241 232
        Composite cdmServerComposite = new Composite(remotingComposite, SWT.NONE);
242 233
        GridData gd_cdmServerComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
243 234
        cdmServerComposite.setLayoutData(gd_cdmServerComposite);
......
276 267
        btnCdmServerRefresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
277 268
        btnCdmServerRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
278 269

  
279
        //instance
280 270
        Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE);
281 271
        GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
282 272
        //gd_lblCdmInstance.heightHint = 30;
......
312 302
        btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh);
313 303
        btnCdmInstanceRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
314 304

  
315
        //login
316 305
        loginComposite = new Composite(remotingComposite, SWT.NONE);
317 306
        GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
318 307
        loginComposite.setLayoutData(gd_loginComposite);
......
340 329
        GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
341 330
        gd_txtPassword.minimumWidth = 80;
342 331
        txtPassword.setLayoutData(gd_txtPassword);
343
        @SuppressWarnings("unused")
344
        Label nope = new Label(loginComposite, SWT.NONE);
332
        new Label(loginComposite, SWT.NONE);
345 333
        txtPassword.addKeyListener(new KeyAdapter() {
346 334
        	@Override
347 335
        	public void keyPressed(KeyEvent e) {
......
359 347
				connectButtonPressed();
360 348
			}
361 349
		});
362
        btnConnect.setText(LABEL_CONNECT);
350
        btnConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
363 351

  
364 352
        btnRememberMe = new Button(loginComposite, SWT.CHECK);
365 353
        btnRememberMe.setSelection(true);
......
387 375

  
388 376
        styledTxtMessage.setLayoutData(gd_styledTxtMessage);
389 377

  
390
        //Advanced
391
        expandableCompositeAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
378
        xpndblcmpstAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
392 379
        GridData gd_xpndblcmpstAdvanced = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
393
        expandableCompositeAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
394
        expandableCompositeAdvanced.addExpansionListener(new IExpansionListener() {
380
        xpndblcmpstAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
381
        xpndblcmpstAdvanced.addExpansionListener(new IExpansionListener() {
395 382
            @Override
396 383
            public void expansionStateChanged(ExpansionEvent e) {
397 384
                shlConnect.pack(true);
......
400 387
            public void expansionStateChanging(ExpansionEvent e) {
401 388
            }
402 389
        });
403
        expandableCompositeAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
404
        expandableCompositeAdvanced.setExpanded(true);
390
        xpndblcmpstAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
391
        xpndblcmpstAdvanced.setExpanded(true);
405 392

  
406
        compAdvanced = new Composite(expandableCompositeAdvanced, SWT.NONE);
407
        expandableCompositeAdvanced.setClient(compAdvanced);
393
        compAdvanced = new Composite(xpndblcmpstAdvanced, SWT.NONE);
394
        xpndblcmpstAdvanced.setClient(compAdvanced);
408 395
        compAdvanced.setLayout(new GridLayout(4, false));
409 396

  
410 397
        lblPort = new Label(compAdvanced, SWT.CENTER);
......
445 432
        txtEditorVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
446 433
        addEmptyCells(2);
447 434

  
448
        lblServerCdmVersion = new Label(compAdvanced, SWT.CENTER);
449
        lblServerCdmVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
450
        lblServerCdmVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
451
        lblServerCdmVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
435
        lblServerCDMVersion = new Label(compAdvanced, SWT.CENTER);
436
        lblServerCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
437
        lblServerCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
438
        lblServerCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
452 439

  
453
        txtServerCdmVersion = new Text(compAdvanced, SWT.BORDER);
454
        txtServerCdmVersion.setEditable(false);
455
        txtServerCdmVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
440
        txtServerCDMVersion = new Text(compAdvanced, SWT.BORDER);
441
        txtServerCDMVersion.setEditable(false);
442
        txtServerCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER , true, false, 1, 1));
456 443
        addEmptyCells(2);
457 444

  
458
        lblEditorCdmVersion = new Label(compAdvanced, SWT.CENTER);
459
        lblEditorCdmVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
460
        lblEditorCdmVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
461
        lblEditorCdmVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
445
        lblEditorCDMVersion = new Label(compAdvanced, SWT.CENTER);
446
        lblEditorCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
447
        lblEditorCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
448
        lblEditorCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
462 449

  
463
        txtEditorCdmVersion = new Text(compAdvanced, SWT.BORDER);
464
        txtEditorCdmVersion.setEditable(false);
465
        txtEditorCdmVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
450
        txtEditorCDMVersion = new Text(compAdvanced, SWT.BORDER);
451
        txtEditorCDMVersion.setEditable(false);
452
        txtEditorCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
466 453
    }
467 454

  
468 455
    @SuppressWarnings("unused")
......
473 460
    }
474 461

  
475 462
	private void connectButtonPressed() {
476
		if(selectedServerInfo.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
463
		if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
477 464
			startManagedServer();
478 465
		} else {
479 466
			connect();
......
547 534
    private void updateSelectedCdmServer() {
548 535
        int selIndex = comboCdmServer.getSelectionIndex();
549 536
        if(selIndex != -1) {
550
            selectedServerInfo = csiiMap.get(comboCdmServer.getItem(selIndex));
537
            selectedCsii = csiiMap.get(comboCdmServer.getItem(selIndex));
551 538
        }
552 539
    }
553 540

  
554 541
    private void updatePort() {
555 542
        txtPort.setText(""); //$NON-NLS-1$
556
        if(selectedServerInfo != null) {
557
            int port = selectedServerInfo.getPort();
543
        if(selectedCsii != null) {
544
            int port = selectedCsii.getPort();
558 545
            if(port == CdmServerInfo.NULL_PORT) {
559 546
                txtPort.setText(CdmServerInfo.NULL_PORT_STRING);
560 547
            } else {
......
577 564

  
578 565
    private void checkSelectedCdmServer() {
579 566
        try{
580
            if(selectedServerInfo != null) {
581
                if(selectedServerInfo.isLocalhost()) {
567
            if(selectedCsii != null) {
568
                if(selectedCsii.isLocalhost()) {
582 569
                    txtPort.setEditable(true);
583 570
                    txtPort.setEnabled(true);
584 571
                }
585 572
                try {
586
                    if(selectedServerInfo.pingServer()) {
573
                    if(selectedCsii.pingServer()) {
587 574
                        txtCdmServerStatus.setText(STATUS_AVAILABLE);
588 575
                        populateCdmInstanceCombo(true);
589
                        String serverVersionTimestamp = generateLastModifiedTooltip(selectedServerInfo.getCdmlibLastModified());
590
                        txtServerVersion.setText(selectedServerInfo.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
576
                        String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
577
                        txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
591 578
                    } else {
592 579
                        txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
593 580
                        comboCdmInstance.removeAll();
......
628 615
            @Override
629 616
            protected IStatus run(IProgressMonitor monitor) {
630 617
                try {
631
                    if(selectedServerInfo != null) {
618
                    if(selectedCsii != null) {
632 619
                        if(forceRefresh) {
633
                            selectedServerInfo.refreshInstances();
620
                            selectedCsii.refreshInstances();
634 621
                        }
635
                        final List<CdmInstanceInfo> instances = selectedServerInfo.getInstances();
622
                        final List<CdmInstanceInfo> instances = selectedCsii.getInstances();
636 623
                        Display.getDefault().asyncExec(new Runnable() {
637 624
                            @Override
638 625
                            public void run() {
......
701 688
    private void updateSelectedCdmInstance() {
702 689
        int selIndex = comboCdmInstance.getSelectionIndex();
703 690
        if(selIndex != -1) {
704
            selectedCdmInstance = selectedServerInfo.getInstanceFromName(comboCdmInstance.getItem(selIndex));
691
            selectedCdmInstance = selectedCsii.getInstanceFromName(comboCdmInstance.getItem(selIndex));
692

  
705 693
            if(loadLoginPrefs) {
706 694
                readPrefCredentials();
707 695
            }
......
709 697
    }
710 698

  
711 699
    private void updateManagedServerControls() {
712
        if(selectedServerInfo.isLocalhostMgd()) {
700
        if(selectedCsii.isLocalhostMgd()) {
713 701
            if(isSelectedCdmInstanceRunningInManagedServer()) {
714 702
                txtCdmInstanceStatus.setText(STATUS_STARTED);
715 703
            } else {
716 704
                txtCdmInstanceStatus.setText(STATUS_NOT_STARTED);
717 705
            }
718 706
            btnConnect.setEnabled(true);
719
            selectedServerInfo.setPort(getManagedServerPort());
707
            selectedCsii.setPort(getManagedServerPort());
720 708
            updatePort();
721 709
        }
722 710

  
......
734 722
    private boolean isSelectedCdmInstanceRunningInManagedServer() {
735 723
        return CdmStore.getManagedServer() != null &&
736 724
                CdmStore.getManagedServer().isAlive() &&
737
                selectedServerInfo.isLocalhostMgd() &&
725
                selectedCsii.isLocalhostMgd() &&
738 726
                CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName());
739 727
    }
740 728

  
......
752 740
            }
753 741
        }
754 742

  
755
        boolean forceSchemaCreate = !schemaExists(selectedCdmInstance);
756
        boolean forceSchemaUpdate = LABEL_UPDATE_SCHEMA_VERSION.equals(btnConnect.getText());
757

  
758 743
        Job job = new Job(Messages.RemotingLoginDialog_JOB_SERVER_LAUNCH) {
759 744

  
760 745
            @Override
......
767 752
                    monitor.subTask(String.format(Messages.RemotingLoginDialog_GENERATING_CONFIG_FILE, selectedCdmInstance.getName()));
768 753
                    File managedServerConfigFile = CdmServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
769 754
                    monitor.worked(1);
770
                    CdmServer cdmServer = new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile);
771
//                    boolean forceSchemaCreate = CdmStore.getManagedServer() != null
772
//                            && CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())
773
//                            && CdmStore.getManagedServer().isForceSchemaCreate();
774
                    cdmServer.setForceSchemaCreate(forceSchemaCreate);
775
                    cdmServer.setForceSchemaUpdate(forceSchemaUpdate);
776
                    CdmStore.setManagedServer(cdmServer);
755
                    boolean forceSchemaCreate = CdmStore.getManagedServer() != null
756
                            && CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())
757
                            && CdmStore.getManagedServer().isForceSchemaCreate();
758
                    CdmStore.setManagedServer(new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile));
759
                    CdmStore.getManagedServer().setForceSchemaCreate(forceSchemaCreate);
777 760
                    monitor.subTask(Messages.RemotingLoginDialog_STARTING_MGD_SERVER);
778
                    cdmServer.start(false, RemotingLoginDialog.this);
761
                    CdmStore.getManagedServer().start(false, RemotingLoginDialog.this);
779 762
                    int serverUnits = 0;
780 763

  
781 764
                    // the following loop is a 'fake' progress monitoring where the progress
......
820 803

  
821 804
                return Status.OK_STATUS;
822 805
            }
823

  
824
       };
806
        };
825 807

  
826 808
        // configure the job
827 809
        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
......
831 813
        job.schedule();
832 814
    }
833 815

  
834
    private boolean schemaExists(CdmInstanceInfo instanceInfo) {
835
        if (instanceInfo.getDataSource() != null){
836
            try {
837
                //TODO we need a new method in cdmlib to check for existing schema
838
                String schemaVersion = instanceInfo.getDataSource().getDbSchemaVersion();
839
                return schemaVersion != null;
840
            } catch (CdmSourceException e) {
841
                return false;
842
            }
843
        }else{
844
            return true;
845
        }
846
    }
847

  
848
    private String managedSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException{
849
        if (instanceInfo.getDataSource() != null){
850
            return instanceInfo.getDataSource().getDbSchemaVersion();
851
        }else{
852
            throw new RuntimeException("ManagedSchemaVersion only available for managed server instances.");
853
        }
854
    }
855
    private int compareSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException {
856
        return CdmMetaData.compareVersion(managedSchemaVersion(instanceInfo), CdmMetaData.getDbSchemaVersion(), 3, null);
857
    }
858

  
859 816
    @Override
860 817
    public void handleError(final Throwable t) {
861 818

  
862 819
        if(CdmStore.getManagedServer().isFailed() && CdmStore.getManagedServer().isPotentiallyMissingSchema()) {
863 820
            CdmStore.getManagedServer().setForceSchemaCreate(true);
864 821
            // we are in a separate thread here, thus update the screen via
865
            checkManagedSelectedInstance();
822
            Display.getDefault().asyncExec(new Runnable() {
823
                @Override
824
                public void run() {
825
                    btnConnect.setEnabled(true);
826
                    btnConnect.setText("Create Schema");
827
                    btnConnect.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
828
                    btnConnect.requestLayout();
829
                }
830
             });
866 831
        } else {
867 832
            Display.getDefault().syncExec(new Runnable() {
868 833
                @Override
......
903 868
    }
904 869

  
905 870
    private void checkSelectedCdmInstance() {
871
        boolean available = false;
872
        String status = STATUS_NOT_AVAILABLE;
873
        String message = null;
906 874

  
907
        if (selectedServerInfo.isLocalhostMgd()){
908
            checkManagedSelectedInstance();
909
        }else if (txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) {
910
            boolean available = false;
911
            String instanceStatus = STATUS_NOT_AVAILABLE;
912
            String message = null;
875
        if(txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) {
913 876
            try {
914
                if(selectedServerInfo.pingInstance(selectedCdmInstance, getPort())) {
915
                    instanceStatus = STATUS_AVAILABLE;
877
                if(selectedCsii.pingInstance(selectedCdmInstance, getPort())) {
878
                    status = STATUS_AVAILABLE;
916 879
                    available = true;
917 880
                } else {
918
                    instanceStatus = STATUS_NOT_AVAILABLE;
881
                    status = STATUS_NOT_AVAILABLE;
919 882
                    available = false;
920 883
                }
921 884

  
922 885
                if(available) {
923
                    txtServerCdmVersion.setText(selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion());
924

  
925
                    int compareDbSchemaVersion = selectedServerInfo.compareDbSchemaVersion(selectedCdmInstance, getPort());
926

  
886
                    txtServerCDMVersion.setText(selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion());
887
                    int compareDbSchemaVersion = selectedCsii.compareDbSchemaVersion(selectedCdmInstance, getPort());
927 888
                    int compareCdmlibServicesVersion = 0;
928 889
                    boolean disableServicesApiTimestampCheck =
929 890
                            PreferencesUtil.getBooleanValue((IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK));
930 891
                    if(!disableServicesApiTimestampCheck) {
931
                        compareCdmlibServicesVersion = selectedServerInfo.compareCdmlibServicesVersion();
892
                        compareCdmlibServicesVersion = selectedCsii.compareCdmlibServicesVersion();
932 893
                    }
933

  
934 894
                    if(compareDbSchemaVersion > 0 || compareCdmlibServicesVersion > 0) {
935
                        instanceStatus = STATUS_NOT_COMPATIBLE;
895
                        status =  STATUS_NOT_COMPATIBLE;
936 896
                        available = false;
937 897
                        message = MESG_COMPATIBLE_EDITOR_OLD;
938 898
                    } else if(compareDbSchemaVersion < 0 || compareCdmlibServicesVersion < 0) {
939
                        instanceStatus = STATUS_NOT_COMPATIBLE;
899
                        status = STATUS_NOT_COMPATIBLE;
940 900
                        available = false;
941 901
                        message = MESG_COMPATIBLE_SERVER_OLD;
942 902
                    } else {
943
                        instanceStatus =  STATUS_AVAILABLE;
903
                        status =  STATUS_AVAILABLE;
944 904
                        available = true;
945 905
                        message = ""; //$NON-NLS-1$
946 906
                    }
......
949 909
                txtCdmInstanceStatus.setToolTipText(e.getMessage());
950 910
            } finally {
951 911
                btnConnect.setEnabled(available);
952
                txtCdmInstanceStatus.setText(instanceStatus);
912
                txtCdmInstanceStatus.setText(status);
953 913
                if(!StringUtils.isBlank(message)) {
954 914
                    setMessage(message);
955 915
                }
......
957 917
        }
958 918
    }
959 919

  
960
    private void checkManagedSelectedInstance() {
961
        boolean available = false;
962
        String instanceStatus = STATUS_NOT_AVAILABLE;
963
        String message = null;
964
        String connect = LABEL_CONNECT;
965
        int color = SWT.COLOR_BLACK;
966
        String schemaVersion = CdmMetaData.getDbSchemaVersion();
967

  
968
        if (!schemaExists(selectedCdmInstance)){
969
            message = MESG_SCHEMA_MISSING;
970
            connect = LABEL_CREATE_SCHEMA;
971
            color = SWT.COLOR_RED;
972
            schemaVersion = MESG_NO_SCHEMA;
973
        } else {
974
            int compare;
975
            try {
976
                schemaVersion = managedSchemaVersion(selectedCdmInstance);
977
                compare = compareSchemaVersion(selectedCdmInstance);
978
                if (compare > 0){
979
                    instanceStatus = STATUS_NOT_COMPATIBLE;
980
                    message = MESG_COMPATIBLE_EDITOR_OLD;
981
                    available = false;
982
                }else if (compare < 0){
983
                    instanceStatus = STATUS_NOT_COMPATIBLE;
984
                    message = MESG_UPDATE_SCHEMA_VERSION;
985
                    available = true;
986
                    connect = LABEL_UPDATE_SCHEMA_VERSION;
987
                    color = SWT.COLOR_RED;
988
                }else{
989
                    available = true;
990
                }
991
            } catch (CdmSourceException e) {
992
                available = false;
993
            }
994
        }
995

  
996
//        Display.getDefault().asyncExec(()->{
997
            btnConnect.setEnabled(available);
998
            btnConnect.setText(connect);
999
            btnConnect.setBackground(Display.getCurrent().getSystemColor(color));
1000
            btnConnect.requestLayout();
1001
            txtCdmInstanceStatus.setText(instanceStatus);
1002
            txtServerCdmVersion.setText(schemaVersion);
1003

  
1004
//         });
1005

  
1006
//        if(!StringUtils.isBlank(message)) {
1007
            setMessage(message);
1008
//        }
1009
    }
1010

  
1011 920
    private void connect() {
1012 921
        checkSelectedCdmInstance();
1013 922

  
......
1015 924
            return;
1016 925
        }
1017 926

  
1018
        ICdmRemoteSource source = selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort());
927
        ICdmRemoteSource source = selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort());
1019 928

  
1020 929
        if(!validateLogin(source)) {
1021 930
            return;
......
1038 947
        IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
1039 948
        Preferences lastServerInstancePrefs = preferences.node(LAST_SERVER_INSTANCE_NODE);
1040 949

  
1041
        lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedServerInfo.getName());
950
        lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedCsii.getName());
1042 951
        lastServerInstancePrefs.put(LAST_INSTANCE_KEY, selectedCdmInstance.getName());
1043 952

  
1044 953
        flushPreferences(lastServerInstancePrefs);
......
1103 1012
    }
1104 1013

  
1105 1014
    private String getUsernamePrefKey() {
1106
        return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
1015
        return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
1107 1016
    }
1108 1017

  
1109 1018
    private String getPasswordPrefKey() {
1110
        return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
1019
        return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
1111 1020
    }
1112 1021

  
1113 1022
    private boolean validateLogin(ICdmRemoteSource remoteSource) {
......
1146 1055
    }
1147 1056

  
1148 1057
    public void setMessage(String message) {
1149
        if(CdmUtils.isNotBlank(message)) {
1058
        if(message != null && !message.isEmpty()) {
1150 1059
//            if(message.length() > 50) {
1151 1060
//                styledTxtMessage.setToolTipText(message);
1152 1061
//                message = message.substring(0,50) + "..."; //$NON-NLS-1$
......
1227 1136
    }
1228 1137

  
1229 1138
    private void setEditorInfo() {
1230
        txtEditorCdmVersion.setText(CdmMetaData.getDbSchemaVersion());
1139
        txtEditorCDMVersion.setText(CdmMetaData.getDbSchemaVersion());
1231 1140
        String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified());
1232 1141
        txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$
1233 1142
    }
1234 1143

  
1235 1144
    private void clearOnServerChange() {
1236 1145
        setMessage(""); //$NON-NLS-1$
1237
        txtServerCdmVersion.setText(""); //$NON-NLS-1$
1146
        txtServerCDMVersion.setText(""); //$NON-NLS-1$
1238 1147
        txtServerVersion.setText(""); //$NON-NLS-1$
1239 1148
        txtServerVersion.setToolTipText(""); //$NON-NLS-1$
1240
        txtServerCdmVersion.setText(""); //$NON-NLS-1$
1149
        txtServerCDMVersion.setText(""); //$NON-NLS-1$
1241 1150
        comboCdmInstance.removeAll();
1242 1151
        txtCdmInstanceStatus.setText(""); //$NON-NLS-1$
1243 1152
        txtPort.setEditable(false);
......
1246 1155

  
1247 1156
    private void clearOnInstanceChange() {
1248 1157
        setMessage(""); //$NON-NLS-1$
1249
        txtServerCdmVersion.setText(""); //$NON-NLS-1$
1158
        txtServerCDMVersion.setText(""); //$NON-NLS-1$
1250 1159
    }
1251 1160
}

Also available in: Unified diff