/*
 * 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.core.ui.options.general;

import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;


/**
 * Implementation of one panel in Options Dialog.
 *
 * @author Jan Jancura
 */
@OptionsPanelController.TopLevelRegistration(
    categoryName="#CTL_General_Options",
    iconBase="org/netbeans/core/ui/options/general/generalOptions.png",
    keywords="#KW_General",
    keywordsCategory="General",
    id=OptionsDisplayer.GENERAL, // #172844; XXX effectively an undocumented API
//    title="#CTL_General_Options_Title",
//    description="#CTL_General_Options_Description",
    position=100
)
public final class GeneralOptionsPanelController extends OptionsPanelController {


    public void update () {
        getGeneralOptionsPanel ().update ();
    }

    public void applyChanges () {
        getGeneralOptionsPanel ().applyChanges ();
    }
    
    public void cancel () {
        getGeneralOptionsPanel ().cancel ();
    }
    
    public boolean isValid () {
        return getGeneralOptionsPanel ().dataValid ();
    }
    
    public boolean isChanged () {
        return getGeneralOptionsPanel ().isChanged ();
    }
    
    public HelpCtx getHelpCtx () {
        return new HelpCtx ("netbeans.optionsDialog.general");
    }
    
    public JComponent getComponent (Lookup masterLookup) {
        return getGeneralOptionsPanel ();
    }

    public void addPropertyChangeListener (PropertyChangeListener l) {
        getGeneralOptionsPanel ().addPropertyChangeListener (l);
    }

    public void removePropertyChangeListener (PropertyChangeListener l) {
        getGeneralOptionsPanel ().removePropertyChangeListener (l);
    }

    
    private GeneralOptionsPanel generalOptionsPanel;
    
    private GeneralOptionsPanel getGeneralOptionsPanel () {
        if (generalOptionsPanel == null)
            generalOptionsPanel = new GeneralOptionsPanel ();
        return generalOptionsPanel;
    }
}
