/[svn]/jsampler/trunk/src/org/jsampler/view/classic/ClassicPrefs.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/classic/ClassicPrefs.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 910 by iliev, Fri Mar 17 12:08:46 2006 UTC revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005 Grigor Kirilov Iliev   *   Copyright (C) 2005, 2006 Grigor Kirilov Iliev
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 34  import java.util.prefs.Preferences; Line 34  import java.util.prefs.Preferences;
34  public class ClassicPrefs {  public class ClassicPrefs {
35          private final static String prefNode = "org.jsampler.view.classic";          private final static String prefNode = "org.jsampler.view.classic";
36                    
37          public final static String SHOW_TOOLBAR = "Toolbar.visible";          private final static String WINDOW_SIZE_AND_LOCATION = "Mainframe.sizeAndLocation";
38          public final static boolean DEF_SHOW_TOOLBAR = true;          private final static String DEF_WINDOW_SIZE_AND_LOCATION = null;
39                    
40          public final static String SHOW_STATUSBAR = "Statusbar.visible";          private final static String WINDOW_MAXIMIZED = "Mainframe.maximized";
41          public final static boolean DEF_SHOW_STATUSBAR = true;          private final static boolean DEF_WINDOW_MAXIMIZED = false;
42                    
43          public final static String SHOW_LEFT_PANE = "LeftPane.visible";          private final static String SAVE_WINDOW_PROPERTIES = "Mainframe.saveProperties";
44          public final static boolean DEF_SHOW_LEFT_PANE = true;          private final static boolean DEF_SAVE_WINDOW_PROPERTIES = true;
45                    
46          public final static String CHANNEL_BORDER_COLOR = "Channel.borderColor";          private final static String HSPLIT_DIVIDER_LOCATION = "HSplit.dividerLocation";
47          public final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5;          private final static int DEF_HSPLIT_DIVIDER_LOCATION = 180;
48                    
49          public final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor";          private final static String SAVE_LEFT_PANE_STATE = "LeftPane.saveState";
50          public final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false;          private final static boolean DEF_SAVE_LEFT_PANE_STATE = true;
51            
52            private final static String LEFT_PANE_PAGE_IDX = "LeftPane.pageIndex";
53            private final static int DEF_LEFT_PANE_PAGE_IDX = 0;
54            
55            private final static String SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = "showLSConsoleWhenRunScript";
56            private final static boolean DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = true;
57            
58            private final static String SHOW_TOOLBAR = "Toolbar.visible";
59            private final static boolean DEF_SHOW_TOOLBAR = true;
60            
61            private final static String SHOW_STATUSBAR = "Statusbar.visible";
62            private final static boolean DEF_SHOW_STATUSBAR = true;
63            
64            private final static String SHOW_LEFT_PANE = "LeftPane.visible";
65            private final static boolean DEF_SHOW_LEFT_PANE = true;
66            
67            private final static String RECENT_SCRIPTS = "recentScripts";
68            private final static String DEF_RECENT_SCRIPTS = "";
69            
70            private final static String RECENT_SCRIPTS_SIZE = "recentScripts.maxNumber";
71            private final static int DEF_RECENT_SCRIPTS_SIZE = 7;
72            
73            private final static String SHOW_LS_CONSOLE = "LSConsole.visible";
74            private final static boolean DEF_SHOW_LS_CONSOLE = false;
75            
76            private final static String LS_CONSOLE_POPOUT = "LSConsole.popout";
77            private final static boolean DEF_LS_CONSOLE_POPOUT = false;
78            
79            private final static String LS_CONSOLE_HISTORY = "LSConsole.history";
80            private final static String DEF_LS_CONSOLE_HISTORY = "";
81            
82            private final static String LS_CONSOLE_HISTSIZE = "LSConsole.histsize";
83            private final static int DEF_LS_CONSOLE_HISTSIZE = 1000;
84            
85            private final static String LS_CONSOLE_TEXT_COLOR = "LSConsole.textColor";
86            private final static int DEF_LS_CONSOLE_TEXT_COLOR = 0x000000;
87            
88            private final static String LS_CONSOLE_BACKGROUND_COLOR = "LSConsole.backgroundColor";
89            private final static int DEF_LS_CONSOLE_BACKGROUND_COLOR = 0xffffff;
90            
91            private final static String LS_CONSOLE_NOTIFY_COLOR = "LSConsole.notifyColor";
92            private final static int DEF_LS_CONSOLE_NOTIFY_COLOR = 0xcccccc;
93            
94            private final static String LS_CONSOLE_WARNING_COLOR = "LSConsole.warningColor";
95            private final static int DEF_LS_CONSOLE_WARNING_COLOR = 0x6699ff;
96            
97            private final static String LS_CONSOLE_ERROR_COLOR = "LSConsole.errorColor";
98            private final static int DEF_LS_CONSOLE_ERROR_COLOR = 0xff0000;
99            
100            private final static String CHANNEL_BORDER_COLOR = "Channel.borderColor";
101            private final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5;
102            
103            private final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor";
104            private final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false;
105            
106            private final static String VSPLIT_DIVIDER_LOCATION = "VSplit.dividerLocation";
107            private final static int DEF_VSPLIT_DIVIDER_LOCATION = 200;
108            
109            private final static String CURRENT_ORCHESTRA_IDX = "OrchestrasPage.currentOrchestraIndex";
110            private final static int DEF_CURRENT_ORCHESTRA_IDX = 0;
111                    
112          private static Preferences userPrefs = Preferences.userRoot().node(prefNode);          private static Preferences userPrefs = Preferences.userRoot().node(prefNode);
113                    
# Line 55  public class ClassicPrefs { Line 115  public class ClassicPrefs {
115          user() { return userPrefs; }          user() { return userPrefs; }
116                    
117          /**          /**
118             * Gets a string representation of the main window's size and location.
119             * The string representation is a comma-separated list
120             * of x and y coordinates, and width and height of the window.
121             * @return A string representation of the main window's size and location,
122             * or <code>null</code> if the value is not set.
123             */
124            public static String
125            getWindowSizeAndLocation() {
126                    return user().get(WINDOW_SIZE_AND_LOCATION, DEF_WINDOW_SIZE_AND_LOCATION);
127            }
128            
129            /**
130             * Sets the main window's size and location.
131             * Use <code>null</code> to remove the current value.
132             * @param s A string representation of the main window's size and location.
133             */
134            public static void
135            setWindowSizeAndLocation(String s) {
136                    if(s == null) {
137                            user().remove(WINDOW_SIZE_AND_LOCATION);
138                            return;
139                    }
140                    
141                    user().put(WINDOW_SIZE_AND_LOCATION, s);
142            }
143            
144            /**
145             * Determines whether the main window should be maximized.
146             * @return <code>true</code> if the main window should be maximized,
147             * <code>false</code> otherwise.
148             */
149            public static boolean
150            getWindowMaximized() {
151                    return user().getBoolean(WINDOW_MAXIMIZED, DEF_WINDOW_MAXIMIZED);
152            }
153            
154            /**
155             * Sets whether the main window should be maximized.
156             * @param b If <code>true</code> the main window should be maximized.
157             */
158            public static void
159            setWindowMaximized(boolean b) {
160                    if(b == getWindowMaximized()) return;
161                    user().putBoolean(WINDOW_MAXIMIZED, b);
162            }
163            
164            /**
165             * Gets the divider location of the horizontal split pane.
166             * @return The divider location of the horizontal split pane.
167             */
168            public static int
169            getHSplitDividerLocation() {
170                    return user().getInt(HSPLIT_DIVIDER_LOCATION, DEF_HSPLIT_DIVIDER_LOCATION);
171            }
172            
173            /**
174             * Sets the divider location of the horizontal split pane.
175             * @param i The new divider location of the horizontal split pane.
176             */
177            public static void
178            setHSplitDividerLocation(int i) {
179                    if(i == getHSplitDividerLocation()) return;
180                    user().putInt(HSPLIT_DIVIDER_LOCATION, i);
181            }
182            
183            /**
184             * Determines whether the window properties (like size and location) should be saved.
185             * @return <code>true</code> if the window properties should be saved,
186             * <code>false</code> otherwise.
187             */
188            public static boolean
189            getSaveWindowProperties() {
190                    return user().getBoolean(SAVE_WINDOW_PROPERTIES, DEF_SAVE_WINDOW_PROPERTIES);
191            }
192            
193            /**
194             * Sets whether the window properties (like size and location) should be saved.
195             * @param b If <code>true</code> the window properties will be saved.
196             */
197            public static void
198            setSaveWindowProperties(boolean b) {
199                    if(b == getSaveWindowProperties()) return;
200                    user().putBoolean(SAVE_WINDOW_PROPERTIES, b);
201            }
202            
203            /**
204             * Determines whether the Left Pane state should be saved.
205             * @return <code>true</code> if the Left Pane state should be saved,
206             * <code>false</code> otherwise.
207             */
208            public static boolean
209            getSaveLeftPaneState() {
210                    return user().getBoolean(SAVE_LEFT_PANE_STATE, DEF_SAVE_LEFT_PANE_STATE);
211            }
212            
213            /**
214             * Sets whether the Left Pane state should be saved.
215             * @param b If <code>true</code> the Left Pane state will be saved.
216             */
217            public static void
218            setSaveLeftPaneState(boolean b) {
219                    if(b == getSaveLeftPaneState()) return;
220                    user().putBoolean(SAVE_LEFT_PANE_STATE, b);
221            }
222            
223            /**
224             * Gets the index of the page to be shown in the Left Pane.
225             * @return The index of the page to be shown in the Left Pane.
226             */
227            public static int
228            getLeftPanePageIndex() {
229                    return user().getInt(LEFT_PANE_PAGE_IDX, DEF_LEFT_PANE_PAGE_IDX);
230            }
231            
232            /**
233             * Sets the maximum number of recent scripts to be kept.
234             * @param i Determines the maximum number of recent scripts to be kept.
235             */
236            public static void
237            setLeftPanePageIndex(int i) {
238                    if(i == getLeftPanePageIndex()) return;
239                    user().putInt(LEFT_PANE_PAGE_IDX, i);
240            }
241            
242            /**
243             * Determines whether to show the LS Console when script is run.
244             * @return <code>true</code> if the LS Console should be shown when script is run,
245             * <code>false</code> otherwise.
246             */
247            public static boolean
248            getShowLSConsoleWhenRunScript() {
249                    return user().getBoolean (
250                            SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT
251                    );
252            }
253            
254            /**
255             * Sets whether to show the LS Console when script is run.
256             * @param b Specify <code>true</code> to show LS Console when script is run,
257             * <code>false</code> otherwise.
258             */
259            public static void
260            setShowLSConsoleWhenRunScript(boolean b) {
261                    if(b == getShowLSConsoleWhenRunScript()) return;
262                    user().putBoolean(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
263            }
264            
265            /**
266           * Determines whether the toolbar should be visible.           * Determines whether the toolbar should be visible.
267           * @return <code>true</code> if the toolbar should be visible,           * @return <code>true</code> if the toolbar should be visible,
268           * <code>false</code> otherwise.           * <code>false</code> otherwise.
# Line 91  public class ClassicPrefs { Line 299  public class ClassicPrefs {
299          }          }
300                    
301          /**          /**
302             * Gets the recent script list.
303             * @return The recent script list.
304             */
305            public static String
306            getRecentScripts() {
307                    return user().get(RECENT_SCRIPTS, DEF_RECENT_SCRIPTS);
308            }
309            
310            /**
311             * Sets the recent script list.
312             * @param s The recent script list.
313             */
314            public static void
315            setRecentScripts(String s) {
316                    if(s == null) {
317                            user().remove(RECENT_SCRIPTS);
318                            return;
319                    }
320                    
321                    user().put(RECENT_SCRIPTS, s);
322            }
323            
324            /**
325             * Determines the maximum number of recent scripts to be kept.
326             * @return The maximum number of recent scripts to be kept.
327             */
328            public static int
329            getRecentScriptsSize() {
330                    return user().getInt(RECENT_SCRIPTS_SIZE, DEF_RECENT_SCRIPTS_SIZE);
331            }
332            
333            /**
334             * Sets the maximum number of recent scripts to be kept.
335             * @param i Determines the maximum number of recent scripts to be kept.
336             */
337            public static void
338            setRecentScriptstSize(int i) {
339                    if(i == getRecentScriptsSize()) return;
340                    user().putInt(RECENT_SCRIPTS_SIZE, i);
341            }
342            
343            /**
344             * Determines whether the LS Console should be visible.
345             * @return <code>true</code> if the LS Console should be visible,
346             * <code>false</code> otherwise.
347             */
348            public static boolean
349            shouldShowLSConsole() { return user().getBoolean(SHOW_LS_CONSOLE, DEF_SHOW_LS_CONSOLE); }
350            
351            /**
352             * Sets whether the LS Console should be visible.
353             * @param b If <code>true</code> the LS Console will be visible at startup.
354             */
355            public static void
356            setShowLSConsole(boolean b) {
357                    if(b == shouldShowLSConsole()) return;
358                    user().putBoolean(SHOW_LS_CONSOLE, b);
359            }
360            
361            /**
362             * Determines whether the LS Console should be shown in a new window or
363             * docked in the main frame.
364             * @return <code>true</code> if the LS Console should be shown in a new window,
365             * <code>false</code> if the LS Console should be docked in the main frame.
366             */
367            public static boolean
368            isLSConsolePopOut() { return user().getBoolean(LS_CONSOLE_POPOUT, DEF_LS_CONSOLE_POPOUT); }
369            
370            /**
371             * Sets whether the LS Console should be shown in a new window or
372             * docked in the main frame.
373             * @param b code>true</code> means that the LS Console will be shown in a new window;
374             * <code>false</code> means that the LS Console will be docked in the main frame.
375             */
376            public static void
377            setLSConsolePopOut(boolean b) {
378                    if(b == isLSConsolePopOut()) return;
379                    user().putBoolean(LS_CONSOLE_POPOUT, b);
380            }
381            
382            /**
383             * Gets the LS Console's command history.
384             * @return The LS Console's command history.
385             */
386            public static String
387            getLSConsoleHistory() {
388                    return user().get(LS_CONSOLE_HISTORY, DEF_LS_CONSOLE_HISTORY);
389            }
390            
391            /**
392             * Sets the LS Console's command history.
393             * @param s The LS Console's command history.
394             */
395            public static void
396            setLSConsoleHistory(String s) {
397                    if(s == null) {
398                            user().remove(LS_CONSOLE_HISTORY);
399                            return;
400                    }
401                    
402                    user().put(LS_CONSOLE_HISTORY, s);
403            }
404            
405            /**
406             * Gets the LS Console's command history size.
407             * @return The maximum number of lines to be kept in the command history.
408             */
409            public static int
410            getLSConsoleHistSize() {
411                    return user().getInt(LS_CONSOLE_HISTSIZE, DEF_LS_CONSOLE_HISTSIZE);
412            }
413            
414            /**
415             * Sets the LS Console's command history size.
416             * @param i The maximum number of lines to be kept in the command history.
417             */
418            public static void
419            setLSConsoleHistSize(int i) {
420                    if(i == getLSConsoleHistSize()) return;
421                    user().putInt(LS_CONSOLE_HISTSIZE, i);
422            }
423            
424            /**
425             * Gets the text color of the LS Console.
426             * @return The text color of the LS Console.
427             */
428            public static Color
429            getLSConsoleTextColor() {
430                    int c = user().getInt(LS_CONSOLE_TEXT_COLOR, DEF_LS_CONSOLE_TEXT_COLOR);
431                    return new Color(c);
432            }
433            
434            /**
435             * Sets the text color of the LS Console.
436             * Use <code>null</code> to remove the current value.
437             * @param color The text color of the LS Console.
438             */
439            public static void
440            setLSConsoleTextColor(Color c) {
441                    if(c == null) {
442                            user().remove(LS_CONSOLE_TEXT_COLOR);
443                            return;
444                    }
445                    
446                    if(c.getRGB() == getLSConsoleTextColor().getRGB()) return;
447                    
448                    user().putInt(LS_CONSOLE_TEXT_COLOR, c.getRGB());
449            }
450            
451            /**
452             * Gets the background color of the LS Console.
453             * @return The background color of the LS Console.
454             */
455            public static Color
456            getLSConsoleBackgroundColor() {
457                    int c = user().getInt(LS_CONSOLE_BACKGROUND_COLOR, DEF_LS_CONSOLE_BACKGROUND_COLOR);
458                    return new Color(c);
459            }
460            
461            /**
462             * Sets the background color of the LS Console.
463             * Use <code>null</code> to remove the current value.
464             * @param color The background color of the LS Console.
465             */
466            public static void
467            setLSConsoleBackgroundColor(Color c) {
468                    if(c == null) {
469                            user().remove(LS_CONSOLE_BACKGROUND_COLOR);
470                            return;
471                    }
472                    
473                    if(c.getRGB() == getLSConsoleBackgroundColor().getRGB()) return;
474                    
475                    user().putInt(LS_CONSOLE_BACKGROUND_COLOR, c.getRGB());
476            }
477            
478            /**
479             * Gets the notification messages' color.
480             * @return The notification messages' color.
481             */
482            public static Color
483            getLSConsoleNotifyColor() {
484                    int c = user().getInt(LS_CONSOLE_NOTIFY_COLOR, DEF_LS_CONSOLE_NOTIFY_COLOR);
485                    return new Color(c);
486            }
487            
488            /**
489             * Sets the notification messages' color.
490             * Use <code>null</code> to remove the current value.
491             * @param color The notification messages' color.
492             */
493            public static void
494            setLSConsoleNotifyColor(Color c) {
495                    if(c == null) {
496                            user().remove(LS_CONSOLE_NOTIFY_COLOR);
497                            return;
498                    }
499                    
500                    if(c.getRGB() == getLSConsoleNotifyColor().getRGB()) return;
501                    
502                    user().putInt(LS_CONSOLE_NOTIFY_COLOR, c.getRGB());
503            }
504            
505            /**
506             * Gets the warning messages' color.
507             * @return The warning messages' color.
508             */
509            public static Color
510            getLSConsoleWarningColor() {
511                    int c = user().getInt(LS_CONSOLE_WARNING_COLOR, DEF_LS_CONSOLE_WARNING_COLOR);
512                    return new Color(c);
513            }
514            
515            /**
516             * Sets the warning messages' color.
517             * Use <code>null</code> to remove the current value.
518             * @param color The warning messages' color.
519             */
520            public static void
521            setLSConsoleWarningColor(Color c) {
522                    if(c == null) {
523                            user().remove(LS_CONSOLE_WARNING_COLOR);
524                            return;
525                    }
526                    
527                    if(c.getRGB() == getLSConsoleWarningColor().getRGB()) return;
528                    
529                    user().putInt(LS_CONSOLE_WARNING_COLOR, c.getRGB());
530            }
531            
532            /**
533             * Gets the error messages' color.
534             * @return The error messages' color.
535             */
536            public static Color
537            getLSConsoleErrorColor() {
538                    int c = user().getInt(LS_CONSOLE_ERROR_COLOR, DEF_LS_CONSOLE_ERROR_COLOR);
539                    return new Color(c);
540            }
541            
542            /**
543             * Sets the error messages' color.
544             * Use <code>null</code> to remove the current value.
545             * @param color The error messages' color.
546             */
547            public static void
548            setLSConsoleErrorColor(Color c) {
549                    if(c == null) {
550                            user().remove(LS_CONSOLE_ERROR_COLOR);
551                            return;
552                    }
553                    
554                    if(c.getRGB() == getLSConsoleErrorColor().getRGB()) return;
555                    
556                    user().putInt(LS_CONSOLE_ERROR_COLOR, c.getRGB());
557            }
558            
559            /**
560           * Determines whether the left pane should be visible.           * Determines whether the left pane should be visible.
561           * @return <code>true</code> if the left pane should be visible,           * @return <code>true</code> if the left pane should be visible,
562           * <code>false</code> otherwise.           * <code>false</code> otherwise.
# Line 164  public class ClassicPrefs { Line 630  public class ClassicPrefs {
630                  if(b == getCustomChannelBorderColor()) return;                  if(b == getCustomChannelBorderColor()) return;
631                  user().putBoolean(CUSTOM_CHANNEL_BORDER_COLOR, b);                  user().putBoolean(CUSTOM_CHANNEL_BORDER_COLOR, b);
632          }          }
633            
634            /**
635             * Gets the divider location of the vertical split pane.
636             * @return The divider location of the vertical split pane.
637             */
638            public static int
639            getVSplitDividerLocation() {
640                    return user().getInt(VSPLIT_DIVIDER_LOCATION, DEF_VSPLIT_DIVIDER_LOCATION);
641            }
642            
643            /**
644             * Sets the divider location of the vertical split pane.
645             * @param i The new divider location of the vertical split pane.
646             */
647            public static void
648            setVSplitDividerLocation(int i) {
649                    if(i == getVSplitDividerLocation()) return;
650                    user().putInt(VSPLIT_DIVIDER_LOCATION, i);
651            }
652            
653            /**
654             * Gets the current orchestra index of the last session.
655             * @return The current orchestra index of the last session.
656             */
657            public static int
658            getCurrentOrchestraIndex() {
659                    return user().getInt(CURRENT_ORCHESTRA_IDX, DEF_CURRENT_ORCHESTRA_IDX);
660            }
661            
662            /**
663             * Sets the current orchestra index.
664             * @param i The orchestra index to be set as current.
665             */
666            public static void
667            setCurrentOrchestraIndex(int i) {
668                    if(i == getCurrentOrchestraIndex()) return;
669                    user().putInt(CURRENT_ORCHESTRA_IDX, i);
670            }
671  }  }

Legend:
Removed from v.910  
changed lines
  Added in v.911

  ViewVC Help
Powered by ViewVC