table.addMouseListener(new JumpToResultActionListener());
table.getSelectionModel().setSelectionInterval(0, 0);
}
public static void jumpToResult(Object path) {
EditorView editor = ((CayenneModelerFrame) Application
.getInstance()
.getFrameController()
.getView()).getView();
DataChannelDescriptor domain = (DataChannelDescriptor) Application
.getInstance()
.getProject()
.getRootNode();
if (path instanceof Entity) {
Object[] o = new Object[3];
o[0] = domain;
o[1] = ((Entity) path).getDataMap();
o[2] = (Entity) path;
/** Make selection in a project tree, open correspondent entity tab */
editor.getProjectTreeView().getSelectionModel().setSelectionPath(
buildTreePath(o, editor));
EntityDisplayEvent event = new EntityDisplayEvent(
editor.getProjectTreeView(),
(Entity) path,
((Entity) path).getDataMap(),
domain);
event.setMainTabFocus(true);
if (path instanceof ObjEntity)
editor.getObjDetailView().currentObjEntityChanged(event);
if (path instanceof DbEntity)
editor.getDbDetailView().currentDbEntityChanged(event);
}
else if (path instanceof Query) {
DataMap dmForQuery = null;
if (path instanceof EJBQLQuery) {
dmForQuery = ((EJBQLQuery) path).getDataMap();
}
if (path instanceof AbstractQuery) {
dmForQuery = ((AbstractQuery) path).getDataMap();
}
Object[] o = new Object[3];
o[0] = domain;
o[1] = dmForQuery;
o[2] = (Query) path;
/** Make selection in a project tree, open correspondent entity tab */
editor.getProjectTreeView().getSelectionModel().setSelectionPath(
buildTreePath(o, editor));
QueryDisplayEvent event = new QueryDisplayEvent(
editor.getProjectTreeView(),
(Query) path,
(DataMap) dmForQuery,
domain);
editor.currentQueryChanged(event);
}
else if (path instanceof Embeddable) {
Object[] o = new Object[3];
o[0] = domain;
o[1] = ((Embeddable) path).getDataMap();
o[2] = (Embeddable) path;
/** Make selection in a project tree, open correspondent entity tab */
editor.getProjectTreeView().getSelectionModel().setSelectionPath(
buildTreePath(o, editor));
EmbeddableDisplayEvent event = new EmbeddableDisplayEvent(editor
.getProjectTreeView(), (Embeddable) path, ((Embeddable) path)
.getDataMap(), domain);
event.setMainTabFocus(true);
editor.currentEmbeddableChanged(event);
}
else if (path instanceof EmbeddableAttribute) {
/** Make selection in a project tree, open correspondent embeddable tab */
Object[] o = new Object[3];
o[0] = domain;
o[1] = ((EmbeddableAttribute) path).getEmbeddable().getDataMap();
o[2] = ((EmbeddableAttribute) path).getEmbeddable();
editor.getProjectTreeView().getSelectionModel().setSelectionPath(
buildTreePath(o, editor));
EmbeddableAttributeDisplayEvent event = new EmbeddableAttributeDisplayEvent(
editor.getProjectTreeView(),
((EmbeddableAttribute) path).getEmbeddable(),
(EmbeddableAttribute) path,
((EmbeddableAttribute) path).getEmbeddable().getDataMap(),
domain);
event.setMainTabFocus(true);
editor.getEmbeddableView().currentEmbeddableAttributeChanged(event);
}
else if (path instanceof Attribute || path instanceof Relationship) {
/** Make selection in a project tree, open correspondent attributes tab */
Object[] o = new Object[3];
o[0] = domain;
if (path instanceof Attribute) {
o[1] = ((Attribute) path).getEntity().getDataMap();
o[2] = ((Attribute) path).getEntity();
}
else {
o[1] = ((Relationship) path).getSourceEntity().getDataMap();
o[2] = ((Relationship) path).getSourceEntity();
}
editor.getProjectTreeView().getSelectionModel().setSelectionPath(
buildTreePath(o, editor));
if (path instanceof DbAttribute) {
AttributeDisplayEvent event = new AttributeDisplayEvent(editor
.getProjectTreeView(), (Attribute) path, ((Attribute) path)
.getEntity(), ((Attribute) path).getEntity().getDataMap(), domain);
event.setMainTabFocus(true);
editor.getDbDetailView().currentDbAttributeChanged(event);
}
if (path instanceof ObjAttribute) {
AttributeDisplayEvent event = new AttributeDisplayEvent(editor
.getProjectTreeView(), (Attribute) path, ((Attribute) path)
.getEntity(), ((Attribute) path).getEntity().getDataMap(), domain);
event.setMainTabFocus(true);
editor.getObjDetailView().currentObjAttributeChanged(event);
}
if (path instanceof DbRelationship) {
RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor
.getProjectTreeView(), (Relationship) path, ((Relationship) path)
.getSourceEntity(), ((Relationship) path)
.getSourceEntity()
.getDataMap(), domain);
event.setMainTabFocus(true);
editor.getDbDetailView().currentDbRelationshipChanged(event);
}
if (path instanceof ObjRelationship) {
RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor
.getProjectTreeView(), (Relationship) path, ((Relationship) path)
.getSourceEntity(), ((Relationship) path)
.getSourceEntity()
.getDataMap(), domain);
event.setMainTabFocus(true);
editor.getObjDetailView().currentObjRelationshipChanged(event);
}
}
}