Search in sources :

Example 1 with ProjectStatePreferences

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

the class ProjectStateUtil method saveLastState.

public void saveLastState(ProjectController controller) {
    EventObject displayEvent = controller.getLastDisplayEvent();
    ConfigurationNode[] multiplyObjects = controller.getCurrentPaths();
    if (displayEvent == null && multiplyObjects == null) {
        return;
    }
    ProjectStatePreferences preferences = controller.getProjectStatePreferences();
    if (preferences.getCurrentPreference() == null) {
        return;
    }
    try {
        preferences.getCurrentPreference().clear();
    } catch (BackingStoreException e) {
    // ignore exception
    }
    if (displayEvent != null) {
        DisplayEventTypes.valueOf(displayEvent.getClass().getSimpleName()).createDisplayEventType(controller).saveLastDisplayEvent();
    } else if (multiplyObjects.length != 0) {
        new MultipleObjectsDisplayEventType(controller).saveLastDisplayEvent();
    }
}
Also used : ConfigurationNode(org.apache.cayenne.configuration.ConfigurationNode) ProjectStatePreferences(org.apache.cayenne.modeler.pref.ProjectStatePreferences) BackingStoreException(java.util.prefs.BackingStoreException) EventObject(java.util.EventObject)

Example 2 with ProjectStatePreferences

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

the class ProjectStateUtil method fireLastState.

public void fireLastState(ProjectController controller) {
    ProjectStatePreferences preferences = controller.getProjectStatePreferences();
    String displayEventName = preferences.getEvent();
    if (!displayEventName.isEmpty()) {
        DisplayEventTypes.valueOf(displayEventName).createDisplayEventType(controller).fireLastDisplayEvent();
    }
}
Also used : ProjectStatePreferences(org.apache.cayenne.modeler.pref.ProjectStatePreferences)

Aggregations

ProjectStatePreferences (org.apache.cayenne.modeler.pref.ProjectStatePreferences)2 EventObject (java.util.EventObject)1 BackingStoreException (java.util.prefs.BackingStoreException)1 ConfigurationNode (org.apache.cayenne.configuration.ConfigurationNode)1