4343import org .editor .panels .FileTreePanel ;
4444import org .editor .panels .PluginsPanel ;
4545import org .editor .panels .VCPanel ;
46+ import org .editor .theme .ThemeManager ;
4647
4748import org .fife .rsta .ui .CollapsibleSectionPanel ;
4849//import org.fife.rsta.ui.DocumentMap;
@@ -72,8 +73,9 @@ public final class EditorWindow extends JFrame implements SearchListener {
7273 private CollapsibleSectionPanel csp ;
7374 public static FindDialog findDialog ;
7475 public static ReplaceDialog replaceDialog ;
75- private DockingDesktop desk = new DockingDesktop ();
76+ public static DockingDesktop desk = new DockingDesktop ();
7677 private static CodeEditor selected = null ;
78+ public static boolean dark = true ;
7779
7880 public static EditorWindow the () {
7981 if (win == null ) {
@@ -87,17 +89,13 @@ public static EditorWindow the() {
8789 public EditorWindow () {
8890 super ("Piccode - DashBoard" );
8991
92+ ThemeManager .setFlatLaf (dark );
9093 DockingUISettings .getInstance ().installUI ();
9194 customizeDock ();
9295
9396 UIManager .put ("Tree.collapsedIcon" , UIManager .getIcon ("Tree.collapsedIcon" ));
9497 UIManager .put ("Tree.expandedIcon" , UIManager .getIcon ("Tree.expandedIcon" ));
9598
96- try {
97- UIManager .setLookAndFeel (new FlatLightLaf ());
98- } catch (Exception ex ) {
99- System .err .println ("Failed to initialize LaF" );
100- }
10199
102100 new CodeEditor ();
103101 root = getRootPane ();
@@ -118,7 +116,7 @@ public EditorWindow() {
118116
119117 if (current .getDockable () instanceof CodeEditor ed ) {
120118 if (event .getFutureState ().isClosed ()) {
121- if (removeIfDirty (ed .tabIndex , ed ) == false ) {
119+ if (removeIfNotDirty (ed .tabIndex , ed ) == false ) {
122120 event .cancel ();
123121 }
124122 }
@@ -229,6 +227,8 @@ public EditorWindow() {
229227
230228 win = this ;
231229
230+ ThemeManager .updateThemes (dark );
231+
232232 this .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
233233 this .setSize (width , height );
234234 this .setLocationRelativeTo (null );
@@ -251,6 +251,8 @@ public static void addTab(ActionEvent e) {
251251 editor .requestFocusInWindow ();
252252 current_file .setText (file != null ? file .toString () : "[NONE]" );
253253 tabEditors .put (index , editor );
254+ ThemeManager .registerEditor (editor );
255+ ThemeManager .updateThemes (dark );
254256
255257 // Add first editor normally
256258 if (index == 0 ) {
@@ -271,6 +273,8 @@ public static void addTab(Path path, Void e) {
271273 editor .requestFocusInWindow ();
272274 tabEditors .put (index , editor );
273275
276+ ThemeManager .registerEditor (editor );
277+ ThemeManager .updateThemes (dark );
274278 // Add first editor normally
275279 if (index == 0 ) {
276280 win .getContentPane ().add (editor );
@@ -339,7 +343,7 @@ private static Component makeTabHeader(JTabbedPane tabs, String title) {
339343 int index = tabs .indexOfTabComponent (tabHeader );
340344 if (index != -1 ) {
341345 var ed = tabEditors .get (index );
342- removeIfDirty (index , ed );
346+ removeIfNotDirty (index , ed );
343347 }
344348 });
345349
@@ -364,21 +368,21 @@ public static void removeTab() {
364368 return ;
365369 }
366370
367- removeIfDirty (index , focused );
371+ removeIfNotDirty (index , focused );
368372 }
369373
370374 public static void removeAllTabs () {
371375 var editors = new HashMap <>(tabEditors ); // Copy to avoid ConcurrentModificationException
372376 for (var entry : editors .entrySet ()) {
373- removeIfDirty (entry .getKey (), entry .getValue ());
377+ removeIfNotDirty (entry .getKey (), entry .getValue ());
374378 }
375379 }
376380
377381 public static int tabsCount () {
378382 return tabEditors .size ();
379383 }
380384
381- private static boolean removeIfDirty (Integer index , CodeEditor ed ) {
385+ private static boolean removeIfNotDirty (Integer index , CodeEditor ed ) {
382386 if (ed .textArea .isDirty ()) {
383387 int result = JOptionPane .showConfirmDialog (win , "File " + ed .filePathTruncated () + " is modified. Save?" );
384388 if (result == JOptionPane .OK_OPTION ) {
@@ -387,6 +391,7 @@ private static boolean removeIfDirty(Integer index, CodeEditor ed) {
387391 }
388392 win .desk .remove ((Dockable ) ed ); // Actual removal from docking layout
389393 tabEditors .remove (index );
394+ ThemeManager .removeEditor (ed );
390395 migrateIndexes ();
391396
392397 return true ;
0 commit comments