Search in sources :

Example 6 with UpdateMonitor

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);
    }
}
Also used : UpdateMonitor(easik.ui.datamanip.UpdateMonitor) QueryNode(easik.view.vertex.QueryNode) EntityNode(easik.sketch.vertex.EntityNode)

Aggregations

EntityNode (easik.sketch.vertex.EntityNode)6 UpdateMonitor (easik.ui.datamanip.UpdateMonitor)6 QueryNode (easik.view.vertex.QueryNode)3 SketchEdge (easik.sketch.edge.SketchEdge)1 ArrayList (java.util.ArrayList)1