com.formdev.flatlaf.jideoss.FlatJideOssDefaultsAddon Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flatlaf-jide-oss Show documentation
Show all versions of flatlaf-jide-oss Show documentation
Flat Look and Feel addon for JIDE Common Layer
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed 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 com.formdev.flatlaf.jideoss;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.UIDefaults.ActiveValue;
import com.formdev.flatlaf.FlatDefaultsAddon;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.jideoss.ui.FlatJidePainter;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.UIDefaultsLookup;
import com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsCustomizer;
import com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsInitializer;
/**
* JIDE Common Layer addon for FlatLaf.
*
* @author Karl Tauber
*/
public class FlatJideOssDefaultsAddon
extends FlatDefaultsAddon
{
/**
* Finds JIDE Common Layer addon .properties file for the given LaF class
* in the same package as this class.
*/
@Override
public InputStream getDefaults( Class> lafClass ) {
LookAndFeelFactory.registerDefaultInitializer( FlatLaf.class.getName(), FlatJideUIDefaultsCustomizer.class.getName() );
LookAndFeelFactory.registerDefaultCustomizer( FlatLaf.class.getName(), FlatJideUIDefaultsCustomizer.class.getName() );
return super.getDefaults( lafClass );
}
@Override
public void afterDefaultsLoading( LookAndFeel laf, UIDefaults defaults ) {
// TristateCheckBox
defaults.put( "TristateCheckBox.icon", null );
defaults.put( "TristateCheckBox.setMixed.clientProperty", new Object[] { "JButton.selectedState", "indeterminate" } );
defaults.put( "TristateCheckBox.clearMixed.clientProperty", new Object[] { "JButton.selectedState", null } );
}
@Override
public int getPriority() {
return 11;
}
//---- class FlatJideUIDefaultsCustomizer ---------------------------------
/**
* Because JIDE overwrites our UI defaults (from properties files) with its
* own UI defaults, we have to first remember our UI defaults in the initializer
* (invoked before JIDE overwrites UI defaults) and then restore them in the customizer.
*
* Do not register this class yourself with JIDE.
* It is automatically registered.
*
* Invoked from {@link LookAndFeelFactory#installJideExtension()}.
*/
public static class FlatJideUIDefaultsCustomizer
implements UIDefaultsInitializer, UIDefaultsCustomizer
{
private static HashMap