Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 package org.apache.cayenne.modeler;
 import  org.apache.cayenne.project.CayenneUserDir;
ModelerPreferences class supports persistent user preferences. Preferences are saved in the user home directory in "$HOME/.cayenne/modeler.preferences" file.

This class is obsolete; its users will be migrated to use preference service.

 public class ModelerPreferences extends ExtendedProperties {
     private static final Log logObj = LogFactory.getLog(ModelerPreferences.class);

Name of the preferences file.
     public static final String PREFERENCES_NAME = "modeler.preferences";

Name of the log file.
     public static final String LOGFILE_NAME = "modeler.log";
     // Keys for the preference file.
List of the last 12 opened project files.
     public static final String LAST_PROJ_FILES = "Editor.lastSeveralProjectFiles";
     public static final int LAST_PROJ_FILES_SIZE = 12;

GUI layout
     public static final String EDITOR_LAFNAME = "Editor.lookAndFeel";
     public static final String EDITOR_THEMENAME = "Editor.theme";

Log file
     public static final String EDITOR_LOGFILE_ENABLED = "Editor.logfileEnabled";
     public static final String EDITOR_LOGFILE = "Editor.logfile";
      * Number of items in combobox visible without scrolling 
     public static final int COMBOBOX_MAX_VISIBLE_SIZE = 12;
     protected static ModelerPreferences sharedInstance;
     protected ModelerPreferences() {

Returns Cayenne preferences singleton.
     public static ModelerPreferences getPreferences() {
         if ( == null) {
              = new ModelerPreferences();
         return ;

Returns preferences directory $HOME/.cayenne. If such directory does not exist, it is created as a side effect of this method.
     public File preferencesDirectory() {
         return CayenneUserDir.getInstance().getDirectory();

Saves preferences. Preferences stored in $HOME/.cayenne/modeler.preferences file.
     public void storePreferences() {
         File prefFile = new File(preferencesDirectory(), );
         try {
            if (!prefFile.exists()) {
                .debug("Cannot save preferences - file "
                        + prefFile
                        + " does not exist");
            save(new FileOutputStream(prefFile), "");
        catch (IOException e) {
            .debug("Error saving preferences: "e);

Loads preferences from $HOME/.cayenne/modeler.preferences file.
    public void loadPreferences() {
        try {
            File prefsFile = new File(preferencesDirectory(), );
            if (!prefsFile.exists()) {
                if (!prefsFile.createNewFile()) {
                    .warn("Can't create preferences file " + prefsFile);
            load(new FileInputStream(prefsFile));
        catch (IOException e) {
            .warn("Error creating preferences file."e);
New to GrepCode? Check out our FAQ X