Search in sources :

Example 56 with DataMap

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);
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) PasteUndoableEdit(org.apache.cayenne.modeler.undo.PasteUndoableEdit) PasteUndoableEdit(org.apache.cayenne.modeler.undo.PasteUndoableEdit) UndoableEdit(javax.swing.undo.UndoableEdit) PasteCompoundUndoableEdit(org.apache.cayenne.modeler.undo.PasteCompoundUndoableEdit) PasteCompoundUndoableEdit(org.apache.cayenne.modeler.undo.PasteCompoundUndoableEdit) List(java.util.List) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) DataMap(org.apache.cayenne.map.DataMap)

Example 57 with DataMap

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;
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) RemoveAttributeUndoableEdit(org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit) RemoveCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit) UndoableEdit(javax.swing.undo.UndoableEdit) RemoveRelationshipUndoableEdit(org.apache.cayenne.modeler.undo.RemoveRelationshipUndoableEdit) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) RemoveCompoundUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCompoundUndoableEdit) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) Procedure(org.apache.cayenne.map.Procedure) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Example 58 with DataMap

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);
}
Also used : ArrayList(java.util.ArrayList) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) TreeMap(java.util.TreeMap) DataMap(org.apache.cayenne.map.DataMap)

Example 59 with DataMap

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);
    }
}
Also used : DbAdapter(org.apache.cayenne.dba.DbAdapter) DbGenerator(org.apache.cayenne.access.DbGenerator) IOException(java.io.IOException) DataMap(org.apache.cayenne.map.DataMap)

Example 60 with DataMap

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()));
    }
}
Also used : ConfigurationNode(org.apache.cayenne.configuration.ConfigurationNode) File(java.io.File) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

DataMap (org.apache.cayenne.map.DataMap)233 Test (org.junit.Test)88 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)48 DbEntity (org.apache.cayenne.map.DbEntity)48 ObjEntity (org.apache.cayenne.map.ObjEntity)45 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)22 URL (java.net.URL)21 URLResource (org.apache.cayenne.resource.URLResource)20 ArrayList (java.util.ArrayList)19 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)19 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)17 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)16 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)15 File (java.io.File)14 Procedure (org.apache.cayenne.map.Procedure)14 Embeddable (org.apache.cayenne.map.Embeddable)13 Injector (org.apache.cayenne.di.Injector)12 DbAttribute (org.apache.cayenne.map.DbAttribute)11 EntityResolver (org.apache.cayenne.map.EntityResolver)11 Entity (org.apache.cayenne.map.Entity)10