use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class FindAction method jumpToAttributeResult.
private static void jumpToAttributeResult(SearchResultEntry searchResultEntry, EditorView editor, DataChannelDescriptor domain) {
DataMap map;
Entity entity;
if (searchResultEntry.getObject() instanceof Attribute) {
map = ((Attribute) searchResultEntry.getObject()).getEntity().getDataMap();
entity = ((Attribute) searchResultEntry.getObject()).getEntity();
} else {
map = ((Relationship) searchResultEntry.getObject()).getSourceEntity().getDataMap();
entity = ((Relationship) searchResultEntry.getObject()).getSourceEntity();
}
buildAndSelectTreePath(map, entity, editor);
if (searchResultEntry.getObject() instanceof Attribute) {
AttributeDisplayEvent event = new AttributeDisplayEvent(editor.getProjectTreeView(), (Attribute) searchResultEntry.getObject(), entity, map, domain);
event.setMainTabFocus(true);
if (searchResultEntry.getObject() instanceof DbAttribute) {
editor.getDbDetailView().currentDbAttributeChanged(event);
} else {
editor.getObjDetailView().currentObjAttributeChanged(event);
}
} else if (searchResultEntry.getObject() instanceof Relationship) {
RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor.getProjectTreeView(), (Relationship) searchResultEntry.getObject(), entity, map, domain);
event.setMainTabFocus(true);
if (searchResultEntry.getObject() instanceof DbRelationship) {
editor.getDbDetailView().currentDbRelationshipChanged(event);
} else {
editor.getObjDetailView().currentObjRelationshipChanged(event);
}
}
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class GenerateCodeAction method performAction.
public void performAction(ActionEvent e) {
Collection<DataMap> dataMaps;
DataMap dataMap = getProjectController().getCurrentDataMap();
if (dataMap != null) {
dataMaps = new ArrayList<>();
dataMaps.add(dataMap);
new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
} else if (getProjectController().getCurrentDataNode() != null) {
Collection<String> nodeMaps = getProjectController().getCurrentDataNode().getDataMapNames();
Project project = getProjectController().getProject();
dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
Collection<DataMap> resultMaps = new ArrayList<>();
for (DataMap map : dataMaps) {
if (nodeMaps.contains(map.getName())) {
resultMaps.add(map);
}
}
new CodeGeneratorController(getApplication().getFrameController(), resultMaps).startup();
} else {
Project project = getProjectController().getProject();
dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
}
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class GenerateDBAction method performAction.
public void performAction(ActionEvent e) {
Collection<DataMap> dataMaps;
DataMap dataMap = getProjectController().getCurrentDataMap();
if (dataMap != null) {
dataMaps = new ArrayList<>();
dataMaps.add(dataMap);
} else {
Project project = getProjectController().getProject();
dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
}
new DBGeneratorOptions(getProjectController(), "Generate DB Schema: Options", dataMaps).startupAction();
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class LinkDataMapsAction method performAction.
@Override
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) mediator.getProject().getRootNode();
Collection<String> linkedDataMaps = new ArrayList<>();
DataNodeDescriptor dataNodeDescriptor = mediator.getCurrentDataNode();
for (DataNodeDescriptor dataNodeDesc : dataChannelDescriptor.getNodeDescriptors()) {
linkedDataMaps.addAll(dataNodeDesc.getDataMapNames());
}
for (DataMap dataMap : dataChannelDescriptor.getDataMaps()) {
if (!linkedDataMaps.contains(dataMap.getName())) {
dataNodeDescriptor.getDataMapNames().add(dataMap.getName());
mediator.fireDataNodeEvent(new DataNodeEvent(this, dataNodeDescriptor));
}
}
application.getUndoManager().addEdit(new LinkDataMapsUndoableEdit(dataNodeDescriptor, linkedDataMaps, mediator));
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class MigrateAction method performAction.
public void performAction(ActionEvent e) {
DataSourceWizard connectWizard = dataSourceWizardDialog("Migrate DB Schema: Connect to Database");
if (connectWizard == null) {
return;
}
DataMap map = getProjectController().getCurrentDataMap();
if (map == null) {
throw new IllegalStateException("No current DataMap selected.");
}
dialogShown = false;
DbActionOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
if (dialogShown && optionsDialog == null) {
return;
}
String selectedCatalog = optionsDialog == null ? null : optionsDialog.getSelectedCatalog();
String selectedSchema = optionsDialog == null ? null : optionsDialog.getSelectedSchema();
MergerTokenFactoryProvider mergerTokenFactoryProvider = getApplication().getInjector().getInstance(MergerTokenFactoryProvider.class);
// ... show dialog...
new MergerOptions(getProjectController(), "Migrate DB Schema: Options", connectWizard.getConnectionInfo(), map, selectedCatalog, selectedSchema, mergerTokenFactoryProvider).startupAction();
}
Aggregations