Theme Editor:

- support multi-line styles in overlay color preview
- minor preview improvements
This commit is contained in:
Karl Tauber
2022-01-03 21:51:02 +01:00
parent 831b3d851a
commit a8d98ced61
4 changed files with 28 additions and 7 deletions

View File

@@ -686,12 +686,14 @@ class FlatThemePreviewAll
//---- scrollBar1 ----
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
scrollBar1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-scrollbar");
scrollBar1.setVisibleAmount(50);
add(scrollBar1, "cell 1 12 2 1");
//---- scrollBar5 ----
scrollBar5.setOrientation(Adjustable.HORIZONTAL);
scrollBar5.setShowButtons(true);
scrollBar5.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-scrollbar");
scrollBar5.setVisibleAmount(50);
add(scrollBar5, "cell 1 13 2 1");
//---- separatorLabel ----
@@ -707,7 +709,6 @@ class FlatThemePreviewAll
add(sliderLabel, "cell 0 15");
//---- slider1 ----
slider1.setValue(30);
slider1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-slider");
add(slider1, "cell 1 15 2 1,width 100");
@@ -716,7 +717,6 @@ class FlatThemePreviewAll
slider3.setPaintTicks(true);
slider3.setMajorTickSpacing(50);
slider3.setPaintLabels(true);
slider3.setValue(30);
slider3.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-slider");
slider3.addChangeListener(e -> changeProgress());
add(slider3, "cell 1 16 2 1,width 100");
@@ -726,7 +726,7 @@ class FlatThemePreviewAll
add(progressBarLabel, "cell 0 17");
//---- progressBar1 ----
progressBar1.setValue(60);
progressBar1.setValue(50);
progressBar1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-progressbar");
add(progressBar1, "cell 1 17 2 1");

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "999.9.9.9.9999" Java: "1.8.0_202" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.5.0.404" Java: "17" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -444,6 +444,7 @@ new FormModel {
name: "scrollBar1"
"orientation": 0
"$client.FlatLaf.styleClass": "flatlaf-preview-scrollbar"
"visibleAmount": 50
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 12 2 1"
} )
@@ -452,6 +453,7 @@ new FormModel {
"orientation": 0
"showButtons": true
"$client.FlatLaf.styleClass": "flatlaf-preview-scrollbar"
"visibleAmount": 50
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 13 2 1"
} )
@@ -475,7 +477,6 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider1"
"value": 30
"$client.FlatLaf.styleClass": "flatlaf-preview-slider"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -489,7 +490,6 @@ new FormModel {
"paintTicks": true
"majorTickSpacing": 50
"paintLabels": true
"value": 30
"$client.FlatLaf.styleClass": "flatlaf-preview-slider"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -506,7 +506,7 @@ new FormModel {
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) {
name: "progressBar1"
"value": 60
"value": 50
"$client.FlatLaf.styleClass": "flatlaf-preview-progressbar"
auxiliary() {
"JavaCodeGenerator.variableLocal": false

View File

@@ -117,6 +117,21 @@ class FlatThemePropertiesSupport
int endOffset = textArea.getLineEndOffset( line );
String text = textArea.getText( startOffset, endOffset - startOffset );
// remove trailing backslash from multi-line properties usually used for styles
if( text.endsWith( "\\\n" ) )
text = text.substring( 0, text.length() - 2 ).trim();
// remove trailing semicolon from styles
if( text.endsWith( ";" ) )
text = text.substring( 0, text.length() - 1 ).trim();
// remove key starting with "[style]" so that first property name
// in CSS styled value is used as key to detect value type
if( text.startsWith( "[style]" ) ) {
int sepIndex = text.indexOf( '=' );
if( sepIndex >= 0 )
text = text.substring( sepIndex + 1 );
}
Properties properties = new Properties();
properties.load( new StringReader( text ) );
if( properties.isEmpty() )

View File

@@ -122,3 +122,9 @@ Prop.7.selectionForeground = contrast($Prop.7.selectionBackground,#000,#fff)
@varStyle1 = #f0f
[style].style1 = background: @varStyle1
[style].style2 = background: darken(#f00,10%); \
foreground: #0f0; \
foreground: darken(@background,30%); \
toolbar.hoverBackground: fade(Actions.GreyInline,30%,lazy); \
toolbar.selectedBackground: fade(Actions.GreyInline,50%,lazy)