try {
final Operator rootNode = this.parseQuery(content);
this.visualGraphs.get(0).addToRootList(
new GraphWrapperOperator(rootNode));
this.visualGraphs.get(0).arrange(Arrange.values()[0]);
} catch (final Throwable e) {
this.statusBar.clear();
try {
final LinkedList<Object> result = new LinkedList<Object>();
final LinkedHashMap<Item, QueryRDFTerm> rdfHash = new LinkedHashMap<Item, QueryRDFTerm>();
// TODO if insertion into data editor or into an existing
// TripleContainer, then all existing items (of the
// TripleContainer
// or from the whole DataEditor) must be first inserted!
final ASTGroupConstraint node = SPARQL1_1Parser.parseGroupGraphPatternsAndRDFTerms(content);
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
final Node child = node.jjtGetChild(i);
if (child instanceof ASTGroupConstraint) {
final VisualQueryGenerator vqg = new VisualQueryGenerator(
((VisualGraphOperatorWithPrefix) this.visualGraphs
.get(0)).prefix);
final Object data = child.jjtAccept(
(SPARQL1_1ParserVisitor) vqg, rdfHash);
result.add(data);
final Operator newOp = (Operator) data;
newOp.setParents();
final GraphBox graphBox = this.visualGraphs.get(0).graphBoxCreator.createGraphBox(
this.visualGraphs.get(0),
new GraphWrapperOperator(newOp));
graphBox.setY(rowY);
graphBox.arrange(Arrange.values()[0]);
this.visualGraphs.get(0).addOperator(graphBox.getX(),
rowY, newOp);
// TODO: update x position of last box...
if (data instanceof OperatorContainer) {
final OperatorContainer tc = (OperatorContainer) data;
((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);
if (tc.getGUIComponent().getLocation().x < 0) {
this.visualGraphs
.get(0)
.getBoxes()
.get(new GraphWrapperOperator(tc))
.setX((int) this.visualGraphs.get(0).PADDING);
}
}
} else {
// it is an RDF term!
final Item item = SPARQLCoreParserVisitorImplementation.getItem(child);
rdfHash.put(
item,
new QueryRDFTerm(
((VisualGraphOperatorWithPrefix) this.visualGraphs
.get(0)).prefix, item));
}
}
if (result.size() == 1
&& result.get(0) instanceof OperatorContainer) {
final OperatorContainer tc = (OperatorContainer) result
.get(0);
final LinkedHashSet<Operator> hop = new LinkedHashSet<Operator>();
for (final Operator op : tc.getOperators()) {
hop.add(op);
op.visit(new SimpleOperatorGraphVisitor() {
private static final long serialVersionUID = -350730291684630002L;
public Object visit(final Operator basicOperator) {
hop.add(basicOperator);
return null;
}
});
}
for (final Operator op : rdfHash.values()) {
if (!hop.contains(op)) {
tc.addOperator(op);
op.setParents();
}
}
((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);
if (tc.getGUIComponent().getLocation().x < 0) {
this.visualGraphs.get(0).getBoxes()
.get(new GraphWrapperOperator(tc))
.setX((int) this.visualGraphs.get(0).PADDING);
}
} else if (rdfHash.size() > 0) {
// only single RDF terms are pasted...
// => collect them in a TripleContainer!
final LinkedHashSet<Operator> lhso = new LinkedHashSet<Operator>();
lhso.addAll(rdfHash.values());
final TripleContainer tc = new TripleContainer(lhso);
tc.setParents();
final GraphBox graphBox = this.visualGraphs.get(0).graphBoxCreator.createGraphBox(
this.visualGraphs.get(0), new GraphWrapperOperator(
tc));
graphBox.setY(rowY);
graphBox.arrange(Arrange.values()[0]);
this.visualGraphs.get(0).addOperator(graphBox.getX(), rowY,
tc);
((ContainerPanel) tc.getGUIComponent()).arrange(Arrange.values()[0]);
if (tc.getGUIComponent().getLocation().x < 0) {
this.visualGraphs.get(0).getBoxes()
.get(new GraphWrapperOperator(tc))
.setX((int) this.visualGraphs.get(0).PADDING);
}
}
} catch (final Throwable pe) {
JOptionPane.showOptionDialog(this, pe.getMessage(), "Error",