Search in sources :

Example 6 with DataMapDefaults

use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.

the class ProjectController method getDataMapPreferences.

/**
 * Returns preferences object for the current DataMap. If no preferences
 * exist for the current DataMap, a new Preferences object is created. If no
 * DataMap is currently selected, an exception is thrown. An optional
 * nameSuffix allows to address more than one defaults instance for a single
 * DataMap.
 */
public DataMapDefaults getDataMapPreferences(String nameSuffix) {
    DataMap map = getCurrentDataMap();
    if (map == null) {
        throw new CayenneRuntimeException("No DataMap selected");
    }
    Preferences pref;
    if (nameSuffix == null || nameSuffix.length() == 0) {
        pref = getPreferenceForDataDomain().node("DataMap").node(map.getName());
    } else {
        pref = getPreferenceForDataDomain().node("DataMap").node(map.getName()).node(nameSuffix);
    }
    return (DataMapDefaults) application.getCayenneProjectPreferences().getProjectDetailObject(DataMapDefaults.class, pref);
}
Also used : CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) Preferences(java.util.prefs.Preferences) ProjectStatePreferences(org.apache.cayenne.modeler.pref.ProjectStatePreferences) DataMap(org.apache.cayenne.map.DataMap)

Example 7 with DataMapDefaults

use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.

the class ClientModeController method createView.

protected GeneratorControllerPanel createView() {
    this.view = new StandardModePanel();
    Set<Entry<DataMap, DataMapDefaults>> entities = getMapPreferences().entrySet();
    for (Entry<DataMap, DataMapDefaults> entry : entities) {
        StandardPanelComponent dataMapLine = createDataMapLineBy(entry.getKey(), entry.getValue());
        dataMapLine.getDataMapName().setText(dataMapLine.getDataMap().getName());
        BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), dataMapLine);
        builder.bindToTextField(dataMapLine.getSuperclassPackage(), "preferences.superclassPackage").updateView();
        this.view.addDataMapLine(dataMapLine);
    }
    return view;
}
Also used : Entry(java.util.Map.Entry) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) DataMap(org.apache.cayenne.map.DataMap)

Example 8 with DataMapDefaults

use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.

the class ClientModeController method createDefaults.

protected void createDefaults() {
    TreeMap<DataMap, DataMapDefaults> map = new TreeMap<DataMap, DataMapDefaults>();
    ArrayList<DataMap> dataMaps = (ArrayList<DataMap>) getParentController().getDataMaps();
    for (DataMap dataMap : dataMaps) {
        DataMapDefaults preferences = getApplication().getFrameController().getProjectController().getDataMapPreferences(this.getClass().getName().replace(".", "/"), dataMap);
        preferences.setSuperclassPackage("");
        preferences.updateSuperclassPackage(dataMap, true);
        map.put(dataMap, preferences);
        if (getOutputPath() == null) {
            setOutputPath(preferences.getOutputPath());
        }
    }
    setMapPreferences(map);
}
Also used : ArrayList(java.util.ArrayList) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) TreeMap(java.util.TreeMap) DataMap(org.apache.cayenne.map.DataMap)

Example 9 with DataMapDefaults

use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.

the class CustomModeController method createView.

protected GeneratorControllerPanel createView() {
    this.view = new CustomModePanel();
    Set<Entry<DataMap, DataMapDefaults>> entities = getMapPreferences().entrySet();
    for (Entry<DataMap, DataMapDefaults> entry : entities) {
        StandardPanelComponent dataMapLine = createDataMapLineBy(entry.getKey(), entry.getValue());
        dataMapLine.getDataMapName().setText(dataMapLine.getDataMap().getName());
        BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), dataMapLine);
        builder.bindToTextField(dataMapLine.getSuperclassPackage(), "preferences.superclassPackage").updateView();
        this.view.addDataMapLine(dataMapLine);
    }
    return view;
}
Also used : Entry(java.util.Map.Entry) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) DataMap(org.apache.cayenne.map.DataMap)

Example 10 with DataMapDefaults

use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.

the class CustomModeController method createDefaults.

protected void createDefaults() {
    TreeMap<DataMap, DataMapDefaults> map = new TreeMap<DataMap, DataMapDefaults>();
    Collection<DataMap> dataMaps = getParentController().getDataMaps();
    for (DataMap dataMap : dataMaps) {
        DataMapDefaults preferences;
        preferences = getApplication().getFrameController().getProjectController().getDataMapPreferences(this.getClass().getName().replace(".", "/"), dataMap);
        preferences.setSuperclassPackage("");
        preferences.updateSuperclassPackage(dataMap, false);
        map.put(dataMap, preferences);
        if (getOutputPath() == null) {
            setOutputPath(preferences.getOutputPath());
        }
    }
    setMapPreferences(map);
    preferencesUpdater = new CustomPreferencesUpdater(map);
}
Also used : DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) TreeMap(java.util.TreeMap) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

DataMapDefaults (org.apache.cayenne.modeler.pref.DataMapDefaults)13 DataMap (org.apache.cayenne.map.DataMap)8 Entry (java.util.Map.Entry)3 TreeMap (java.util.TreeMap)3 BindingBuilder (org.apache.cayenne.swing.BindingBuilder)3 ArrayList (java.util.ArrayList)2 Preferences (java.util.prefs.Preferences)2 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)2 ProjectStatePreferences (org.apache.cayenne.modeler.pref.ProjectStatePreferences)2 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)1 ValidationException (org.apache.cayenne.validation.ValidationException)1