org.netbeans.modules.palette.DefaultSettings Maven / Gradle / Ivy
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.netbeans.modules.palette;
import java.beans.BeanInfo;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import org.netbeans.spi.palette.PaletteController;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.NbPreferences;
import org.openide.util.RequestProcessor;
import org.openide.util.Utilities;
/**
* Palette settings to be remembered over IDE restarts.
* There's an instance of these settings for each palette model instance.
*
* @author S. Aubrecht
*/
public final class DefaultSettings implements Settings, ModelListener, CategoryListener {
private static final RequestProcessor RP = new RequestProcessor( "PaletteSettings", 1 ); //NOI18N
private static final String NODE_ATTR_PREFIX = "psa_";
private static final String NULL_VALUE = "null";
private static final String[] KNOWN_PROPERTIES = new String[] {
NODE_ATTR_PREFIX + PaletteController.ATTR_ICON_SIZE,
NODE_ATTR_PREFIX + PaletteController.ATTR_IS_EXPANDED,
NODE_ATTR_PREFIX + PaletteController.ATTR_IS_VISIBLE,
NODE_ATTR_PREFIX + PaletteController.ATTR_SHOW_ITEM_NAMES
};
private Model model;
private PropertyChangeSupport propertySupport = new PropertyChangeSupport( this );
private String prefsName;
private static final Logger ERR = Logger.getLogger("org.netbeans.modules.palette"); // NOI18N
public DefaultSettings( Model model ) {
this.model = model;
prefsName = constructPrefsFileName( model );
if( Utilities.isWindows() )
prefsName = prefsName.toLowerCase();
model.addModelListener( this );
Category[] categories = model.getCategories();
for( int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy