mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Theme Editor: added basic auto-complete for keys
This commit is contained in:
@@ -120,6 +120,9 @@ public class UIDefaultsDump
|
||||
// }
|
||||
|
||||
// dumpIntelliJThemes( dir );
|
||||
|
||||
// dump UI keys
|
||||
UIDefaultsKeysDump.main( new String[0] );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unused" )
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2020 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
|
||||
*
|
||||
* https://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.testing.uidefaults;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.*;
|
||||
|
||||
/**
|
||||
* Collects all FlatLaf UI defaults keys and dumps them to a file.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class UIDefaultsKeysDump
|
||||
{
|
||||
public static void main( String[] args ) {
|
||||
Locale.setDefault( Locale.ENGLISH );
|
||||
System.setProperty( "sun.java2d.uiScale", "1x" );
|
||||
System.setProperty( FlatSystemProperties.UI_SCALE, "1x" );
|
||||
|
||||
File keysFile = new File( "../flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt" );
|
||||
|
||||
HashSet<String> keys = new HashSet<>();
|
||||
|
||||
collectKeys( FlatLightLaf.class.getName(), keys );
|
||||
collectKeys( FlatDarkLaf.class.getName(), keys );
|
||||
collectKeys( FlatIntelliJLaf.class.getName(), keys );
|
||||
collectKeys( FlatDarculaLaf.class.getName(), keys );
|
||||
|
||||
try( Writer fileWriter = new BufferedWriter( new FileWriter( keysFile ) ) ) {
|
||||
String[] sortedKeys = keys.toArray( new String[keys.size()] );
|
||||
Arrays.sort( sortedKeys );
|
||||
for( String key : sortedKeys ) {
|
||||
fileWriter.write( key );
|
||||
fileWriter.write( "\n" );
|
||||
}
|
||||
} catch( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void collectKeys( String lookAndFeelClassName, HashSet<String> keys ) {
|
||||
try {
|
||||
UIManager.setLookAndFeel( lookAndFeelClassName );
|
||||
} catch( Exception ex ) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
UIDefaults defaults = UIManager.getLookAndFeel().getDefaults();
|
||||
|
||||
for( Object key : defaults.keySet() ) {
|
||||
if( key instanceof String )
|
||||
keys.add( (String) key );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user