3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.view
.datasource
;
13 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
14 import org
.eclipse
.jface
.viewers
.LabelProvider
;
15 import org
.eclipse
.swt
.graphics
.Image
;
17 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmMetaData
.MetaDataPropertyName
;
19 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 * <p>CdmDataSourceLabelProvider class.</p>
29 public class CdmDataSourceLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
33 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
36 public Image
getColumnImage(Object element
, int columnIndex
) {
38 ICdmDataSource dataSource
= ((CdmMetaDataAwareDataSourceContainer
) element
).getDataSource();
40 String key
= isCurrentDataSource(dataSource
) ? ImageResources
.IMG_DATASOURCE_CONNECTED
: ImageResources
.IMG_DATASOURCE_DISCONNECTED
;
42 return ImageResources
.getImage(key
);
50 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
53 public String
getColumnText(Object element
, int columnIndex
) {
54 CdmMetaDataAwareDataSourceContainer container
= (CdmMetaDataAwareDataSourceContainer
) element
;
56 ICdmDataSource dataSource
= container
.getDataSource();
60 return dataSource
.getName();
62 if(dataSource
.getServer() != null){
63 return dataSource
.getServer();
65 // h2 databases do not have server entries
68 return dataSource
.getDatabaseType().getName();
70 return dataSource
.getDatabase();
72 if (dataSource
.getNomenclaturalCode() == null) {
75 return dataSource
.getNomenclaturalCode().name();
77 return container
.isRunning() ?
"Yes" : "No";
79 return container
.getMetaData(MetaDataPropertyName
.DB_CREATE_DATE
);
81 return container
.getMetaData(MetaDataPropertyName
.DB_SCHEMA_VERSION
);
83 if(container
.getMetaDataMap().get(MetaDataPropertyName
.DB_SCHEMA_VERSION
) != null){
84 return container
.isDataSourceCompatible() ?
"Yes" : "No";
88 return container
.getMetaData(MetaDataPropertyName
.DB_CREATE_NOTE
);
90 return CdmMetaDataAwareDataSourceContainer
.DEFAULT_ENTRY
;
93 private boolean isCurrentDataSource(ICdmDataSource dataSource
){
94 ICdmDataSource currentDataSource
= CdmStore
.getDataSource();
96 return currentDataSource
!= null && currentDataSource
.getName().equals(dataSource
.getName());