use of easik.ui.ViewFrame in project fql by CategoricalData.
the class DefineQueryNodeFromTreeAction method updateNode.
/**
* Prompts user for name and query values and make appropriate updates on
* query node.
*
* @param ourNode
*/
public static void updateNode(QueryNode ourNode) {
ViewFrame ourFrame = ourNode.getMModel().getFrame();
View ourView = ourFrame.getMModel();
String originalName = ourNode.getName();
DefineQueryNodeDialog dqnd = new DefineQueryNodeDialog(ourFrame, "Define Query Node", ourNode);
if (!dqnd.isAccepted()) {
return;
}
String errorMess = null;
String name = dqnd.getName();
if (name.equals("")) {
errorMess = "Blank name field: did not update.";
} else if (ourView.isNameUsed(name) && !originalName.equals(name)) {
errorMess = "Name already in use: not update.";
}
if (errorMess != null) {
JOptionPane.showMessageDialog(ourView.getParent(), errorMess, "Error", JOptionPane.ERROR_MESSAGE);
} else if (!name.equals(originalName)) {
ourNode.setName(name);
ourFrame.getInfoTreeUI().refreshTree();
ourView.getGraphLayoutCache().reload();
ourView.repaint();
ourView.setDirty();
}
String query = dqnd.getQuery();
try {
ourNode.setQuery(query);
} catch (QueryException e) {
JOptionPane.showMessageDialog(ourView.getParent(), "New Query not set. Not valid query.", "Error", JOptionPane.ERROR_MESSAGE);
}
ourView.clearSelection();
}
use of easik.ui.ViewFrame in project fql by CategoricalData.
the class View method initialiseModel.
/**
* When we initialize the sketch, we flush out all the data concerning the
* sketch itself. Even the modelAdapter is reinitialized.
*
* This methods serves as a "new sketch" function.
*/
@Override
public void initialiseModel() {
clearSelection();
model = new ViewGraphModel(this);
final GraphLayoutCache glc = new GraphLayoutCache(model, new ModelViewFactory<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>());
setModel(model);
setGraphLayoutCache(glc);
_nodes = new LinkedHashMap<>();
_edges = new LinkedHashMap<>();
if (_Frame.getInfoTreeUI() != null) {
// Wipe
_Frame.setInfoTreeUI(new ModelInfoTreeUI<>(_Frame));
// Tree
_Frame.getInfoTreeUI().refreshTree();
}
_docInfo.reset();
model.discardUndo();
}
use of easik.ui.ViewFrame in project fql by CategoricalData.
the class DefineQueryNodeAction method updateNode.
/**
* Prompts user for name and query values and make appropriate updates on
* query node.
*
* @param ourNode
*/
public static void updateNode(QueryNode ourNode) {
boolean hadWhere = !ourNode.getWhere().isEmpty();
boolean hadEntityNode = !(ourNode.getQueriedEntity() == null);
ViewFrame ourFrame = ourNode.getMModel().getFrame();
View ourView = ourFrame.getMModel();
String originalName = ourNode.getName();
String originalQuery = ourNode.getQuery();
DefineQueryNodeDialog dqnd = new DefineQueryNodeDialog(ourFrame, "Define Query Node", ourNode);
if (!dqnd.isAccepted()) {
return;
}
String errorMess = null;
String name = dqnd.getName();
if (name.equals("")) {
errorMess = "Blank name field: did not update.";
} else if (ourView.isNameUsed(name) && !originalName.equals(name)) {
errorMess = "Name already in use: not update.";
}
if (errorMess != null) {
JOptionPane.showMessageDialog(ourView.getParent(), errorMess, "Error", JOptionPane.ERROR_MESSAGE);
} else if (!name.equals(originalName)) {
ourNode.setName(name);
ourFrame.getInfoTreeUI().refreshTree();
ourView.getGraphLayoutCache().reload();
ourView.repaint();
ourView.setDirty();
} else if (!dqnd.getQuery().equals(originalQuery)) {
String query = dqnd.getQuery();
// Any malformed sql should be rejected here.
try {
ourNode.setQuery(query);
} catch (QueryException e) {
JOptionPane.showMessageDialog(ourView.getParent(), "New Query not set. Not valid query.\n" + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
if (hadWhere && ourNode.getWhere().isEmpty()) {
// remove constraints that this queryNode used to be a part of
ourView.updateConstraints(ourNode, hadWhere);
} else if (!hadWhere && !ourNode.getWhere().isEmpty()) {
ourView.updateConstraints(ourNode, hadWhere);
}
if (!hadEntityNode && !(ourNode.getQueriedEntity() == null)) {
ourView.autoAddExistingEdges();
}
}
ourView.clearSelection();
}
Aggregations