}
private void jButtonDataSourceTestActionPerformed(ActionEvent evt) {
String tabName = jTabbedPaneDataSource.getSelectedComponent().getName();
boolean succeeed = false;
DataStore ds = null;
try {
FeatureSource<SimpleFeatureType, SimpleFeature> fs = null;
String typeName = null;
if (tabName.equals(this.jPanelFile.getName())) {
ds = this.getSelectedDataStore(jPanelFile.getName());
if (ds == null) {
String filePath = jTextFieldFilePath.getText();
String realPath = PathUtil.fakePathToReal(filePath);
File file = new File(filePath);
if (!file.exists()) {
MapToolApp app = (MapToolApp) this.getParent();
String mapDescFilePath = app.getMapDescFilePath();
File mapDescFile = new File(mapDescFilePath);
String dir = mapDescFile.getParentFile()
.getAbsolutePath();
String path = dir + File.separator + realPath;
file = new File(path);
}
if (GridCoverage2DReaderFactory
.getGridCoverage2DReaderFromFile(file) != null) {
succeeed = true;
}
} else {
if (ds.getTypeNames().length > 0) {
typeName = ds.getTypeNames()[0];
fs = ds.getFeatureSource(typeName);
succeeed = true;
}
}
} else {
ds = this.getSelectedDataStore(tabName);
typeName = this.getSelectedTypeName(tabName);
fs = ds.getFeatureSource(typeName);
if (fs != null) {
succeeed = true;
}
}
if (jTextFieldName.getText().length() <= 0 && typeName != null) {
jTextFieldName.setText(typeName);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (ds != null) {
ds.dispose();
}
if (succeeed) {
JOptionPane.showMessageDialog(this, "Succeed!");
} else {
JOptionPane.showMessageDialog(this, "Failed!");