use of easik.ui.datamanip.UpdateMonitor in project fql by CategoricalData.
the class ViewDeleteAction method actionPerformed.
/**
* @param e
* The action event
* @author Sarah van der Laan
*/
@Override
public void actionPerformed(ActionEvent e) {
Object[] currentSelection = _ourView.getSelectionCells();
QueryNode currNode = (QueryNode) currentSelection[0];
String queryString = currNode.getQuery();
String entityNodeName = null;
// find corresponding entity node name
String[] tokens = queryString.split("\\s+");
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equalsIgnoreCase("from")) {
entityNodeName = tokens[i + 1];
}
}
EntityNode _ourEntityNode = null;
// set corresponding node in order to use
for (EntityNode node : _ourSketch.getEntities()) {
if (node.getName().equalsIgnoreCase(entityNodeName)) {
_ourEntityNode = node;
}
}
if (!_ourSketch.hasDatabase()) {
JOptionPane.showMessageDialog(null, "Not currently connected to a database.");
return;
} else {
UpdateMonitor um = _ourSketch.getDatabase().newUpdateMonitor();
if (um == null) {
JOptionPane.showMessageDialog(null, "Could not perform update: problem accessing db driver");
return;
}
if (_ourEntityNode != null)
um.deleteFrom(_ourEntityNode);
}
}
Aggregations