use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class PasteAction method performAction.
/**
* Performs pasting items from the system buffer
*/
@Override
public void performAction(ActionEvent e) {
try {
Object content = Toolkit.getDefaultToolkit().getSystemClipboard().getData(CayenneTransferable.CAYENNE_FLAVOR);
Object currentObject = getProjectController().getCurrentObject();
if (content != null && currentObject != null) {
DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController().getProject().getRootNode();
DataMap map = getProjectController().getCurrentDataMap();
UndoableEdit undoableEdit;
if (content instanceof List) {
undoableEdit = new PasteCompoundUndoableEdit();
for (Object o : (List) content) {
paste(currentObject, o);
undoableEdit.addEdit(new PasteUndoableEdit(domain, map, currentObject, o));
}
} else {
paste(currentObject, content);
undoableEdit = new PasteUndoableEdit(domain, map, currentObject, content);
}
application.getUndoManager().addEdit(undoableEdit);
}
} catch (UnsupportedFlavorException ufe) {
// do nothing
} catch (Exception ex) {
ErrorDebugDialog.guiException(ex);
}
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class RemoveAction method removeLastPathComponent.
/**
* Removes an object, depending on its type
*/
private UndoableEdit removeLastPathComponent(ConfigurationNode object, ConfigurationNode parentObject) {
UndoableEdit undo = null;
if (object instanceof DataMap) {
if (parentObject != null && parentObject instanceof DataNodeDescriptor) {
undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) parentObject, (DataMap) object);
removeDataMapFromDataNode((DataNodeDescriptor) parentObject, (DataMap) object);
} else {
// Not under Data Node, remove completely
undo = new RemoveUndoableEdit(application, (DataMap) object);
removeDataMap((DataMap) object);
}
} else if (object instanceof DataNodeDescriptor) {
undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) object);
removeDataNode((DataNodeDescriptor) object);
} else if (object instanceof DbEntity) {
undo = new RemoveUndoableEdit(((DbEntity) object).getDataMap(), (DbEntity) object);
removeDbEntity(((DbEntity) object).getDataMap(), (DbEntity) object);
} else if (object instanceof ObjEntity) {
undo = new RemoveUndoableEdit(((ObjEntity) object).getDataMap(), (ObjEntity) object);
removeObjEntity(((ObjEntity) object).getDataMap(), (ObjEntity) object);
} else if (object instanceof QueryDescriptor) {
undo = new RemoveUndoableEdit(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
removeQuery(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
} else if (object instanceof Procedure) {
undo = new RemoveUndoableEdit(((Procedure) object).getDataMap(), (Procedure) object);
removeProcedure(((Procedure) object).getDataMap(), (Procedure) object);
} else if (object instanceof Embeddable) {
undo = new RemoveUndoableEdit(((Embeddable) object).getDataMap(), (Embeddable) object);
removeEmbeddable(((Embeddable) object).getDataMap(), (Embeddable) object);
}
return undo;
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class StandardModeController method createDefaults.
protected void createDefaults() {
TreeMap<DataMap, DataMapDefaults> treeMap = new TreeMap<DataMap, DataMapDefaults>();
ArrayList<DataMap> dataMaps = (ArrayList<DataMap>) getParentController().getDataMaps();
for (DataMap dataMap : dataMaps) {
DataMapDefaults preferences = getApplication().getFrameController().getProjectController().getDataMapPreferences(dataMap);
preferences.setSuperclassPackage("");
preferences.updateSuperclassPackage(dataMap, false);
treeMap.put(dataMap, preferences);
if (getOutputPath() == null) {
setOutputPath(preferences.getOutputPath());
}
}
setMapPreferences(treeMap);
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class DBGeneratorOptions method prepareGenerator.
/**
* Creates new internal DbGenerator instance.
*/
protected void prepareGenerator() {
try {
DbAdapter adapter = connectionInfo.makeAdapter(getApplication().getClassLoadingService());
generators = new ArrayList<>();
for (DataMap dataMap : dataMaps) {
this.generators.add(new DbGenerator(adapter, dataMap, tables.getExcludedTables(), null, NoopJdbcEventLogger.getInstance()));
}
} catch (Exception ex) {
reportError("Error loading adapter", ex);
}
}
use of org.apache.cayenne.map.DataMap in project cayenne by apache.
the class DbLoaderContext method prepareDataMap.
private void prepareDataMap() {
dataMap = getProjectController().getCurrentDataMap();
existingMap = dataMap != null;
if (!existingMap) {
ConfigurationNode root = getProjectController().getProject().getRootNode();
dataMap = new DataMap();
dataMap.setName(NameBuilder.builder(dataMap, root).name());
}
if (dataMap.getConfigurationSource() != null) {
getConfig().setTargetDataMap(new File(dataMap.getConfigurationSource().getURL().getPath()));
}
}
Aggregations