org.netbeans.modules.settings.SaveSupport 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.settings;
import java.beans.*;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.cookies.SaveCookie;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileObject;
import org.netbeans.spi.settings.Convertor;
import org.netbeans.spi.settings.Saver;
import org.openide.util.Exceptions;
/** Support handles automatic storing/upgrading; notifies about changes in file.
*
* @author Jan Pokorsky
*/
final class SaveSupport {
/** property means setting is changed and should be changed */
public static final String PROP_SAVE = "savecookie"; //NOI18N
/** property means setting file content is changed */
public static final String PROP_FILE_CHANGED = "fileChanged"; //NOI18N
/** data object name cached in the attribute to prevent instance creation when
* its node is displayed.
* @see org.openide.loaders.InstanceDataObject#EA_NAME
*/
static final String EA_NAME = "name"; // NOI18N
/** support for PropertyChangeListeners */
private PropertyChangeSupport changeSupport;
/** convertor for possible format upgrade */
private Convertor convertor;
/** SaveCookie implementation */
private final SaveCookieImpl instToSave = new SaveCookieImpl();
/** setting is already changed */
private boolean isChanged = false;
/** .settings file */
private final FileObject file;
/** reference to setting object */
private final java.lang.ref.SoftReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy