builder.bindToAction(view.getSyncWithLocal(), "syncDataSourceAction()");
}
public void syncDataSourceAction() {
CayenneModelerController mainController = getApplication().getFrameController();
if (getNode() == null || getNode().getDataSource() == null) {
return;
}
ProjectDataSource projectDS = (ProjectDataSource) getNode().getDataSource();
ProjectController parent = (ProjectController) getParent();
String key = parent.getDataNodePreferences().getLocalDataSource();
if (key == null) {
mainController.updateStatus("No Local DataSource selected for node...");
return;
}
DBConnectionInfo dataSource = (DBConnectionInfo) parent
.getApplicationPreferenceDomain()
.getDetail(key, DBConnectionInfo.class, false);
if (dataSource != null) {
if (dataSource.copyTo(projectDS.getDataSourceInfo())) {
refreshView();
super.nodeChangeProcessor.modelUpdated(null, null, null);
mainController.updateStatus(null);
}
else {
mainController.updateStatus("DataNode is up to date...");
}
}
else {
mainController.updateStatus("Invalid Local DataSource selected for node...");
}
}