mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
Theme Editor: support saving file; added inspector
This commit is contained in:
@@ -20,6 +20,7 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation( project( ":flatlaf-core" ) )
|
implementation( project( ":flatlaf-core" ) )
|
||||||
|
implementation( project( ":flatlaf-extras" ) )
|
||||||
|
|
||||||
implementation( "com.fifesoft:rsyntaxtextarea:3.1.1" )
|
implementation( "com.fifesoft:rsyntaxtextarea:3.1.1" )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,15 @@ class FlatThemeEditorPane
|
|||||||
return font.deriveFont( (float) newFontSize );
|
return font.deriveFont( (float) newFontSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load( FileLocation loc ) throws IOException {
|
void load( FileLocation loc ) throws IOException {
|
||||||
textArea.load( loc, StandardCharsets.ISO_8859_1 );
|
textArea.load( loc, StandardCharsets.ISO_8859_1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void save() {
|
||||||
|
try {
|
||||||
|
textArea.save();
|
||||||
|
} catch( IOException ex ) {
|
||||||
|
ex.printStackTrace(); // TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,13 @@
|
|||||||
package com.formdev.flatlaf.themeeditor;
|
package com.formdev.flatlaf.themeeditor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import org.fife.ui.rsyntaxtextarea.FileLocation;
|
import org.fife.ui.rsyntaxtextarea.FileLocation;
|
||||||
import com.formdev.flatlaf.FlatLightLaf;
|
import com.formdev.flatlaf.FlatLightLaf;
|
||||||
|
import com.formdev.flatlaf.extras.FlatInspector;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +41,7 @@ public class FlatThemeFileEditor
|
|||||||
|
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatLightLaf.install();
|
FlatLightLaf.install();
|
||||||
|
FlatInspector.install( "ctrl alt shift X" );
|
||||||
|
|
||||||
FlatThemeFileEditor frame = new FlatThemeFileEditor();
|
FlatThemeFileEditor frame = new FlatThemeFileEditor();
|
||||||
|
|
||||||
@@ -48,6 +51,12 @@ public class FlatThemeFileEditor
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int menuShortcutKeyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||||
|
((JComponent)frame.getContentPane()).registerKeyboardAction(
|
||||||
|
e -> frame.themeEditorArea.save(),
|
||||||
|
KeyStroke.getKeyStroke( KeyEvent.VK_S, menuShortcutKeyMask ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
frame.setSize( Math.min( UIScale.scale( 800 ), screenSize.width ),
|
frame.setSize( Math.min( UIScale.scale( 800 ), screenSize.width ),
|
||||||
screenSize.height - UIScale.scale( 100 ) );
|
screenSize.height - UIScale.scale( 100 ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user