/[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 911 by iliev, Mon Aug 7 18:25:58 2006 UTC revision 1143 by iliev, Mon Apr 2 21:18:31 2007 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, 2006 Grigor Kirilov Iliev   *   Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 26  import java.awt.Color; Line 26  import java.awt.Color;
26    
27  import java.util.prefs.Preferences;  import java.util.prefs.Preferences;
28    
29    import org.jsampler.CC;
30    
31    
32  /**  /**
33   * This class represents the preferences of the JS Classic package.   * This class represents the preferences of the JS Classic package.
# Line 55  public class ClassicPrefs { Line 57  public class ClassicPrefs {
57          private final static String SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = "showLSConsoleWhenRunScript";          private final static String SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = "showLSConsoleWhenRunScript";
58          private final static boolean DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = true;          private final static boolean DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = true;
59                    
60          private final static String SHOW_TOOLBAR = "Toolbar.visible";          private final static String SHOW_CHANNELS_BAR = "ChannelsBar.visible";
61          private final static boolean DEF_SHOW_TOOLBAR = true;          private final static boolean DEF_SHOW_CHANNELS_BAR = true;
62                    
63          private final static String SHOW_STATUSBAR = "Statusbar.visible";          private final static String SHOW_STATUSBAR = "Statusbar.visible";
64          private final static boolean DEF_SHOW_STATUSBAR = true;          private final static boolean DEF_SHOW_STATUSBAR = true;
# Line 64  public class ClassicPrefs { Line 66  public class ClassicPrefs {
66          private final static String SHOW_LEFT_PANE = "LeftPane.visible";          private final static String SHOW_LEFT_PANE = "LeftPane.visible";
67          private final static boolean DEF_SHOW_LEFT_PANE = true;          private final static boolean DEF_SHOW_LEFT_PANE = true;
68                    
69            private final static String SHOW_STANDARD_BAR = "StandardBar.visible";
70            private final static boolean DEF_SHOW_STANDARD_BAR = true;
71            
72          private final static String RECENT_SCRIPTS = "recentScripts";          private final static String RECENT_SCRIPTS = "recentScripts";
73          private final static String DEF_RECENT_SCRIPTS = "";          private final static String DEF_RECENT_SCRIPTS = "";
74                    
# Line 76  public class ClassicPrefs { Line 81  public class ClassicPrefs {
81          private final static String LS_CONSOLE_POPOUT = "LSConsole.popout";          private final static String LS_CONSOLE_POPOUT = "LSConsole.popout";
82          private final static boolean DEF_LS_CONSOLE_POPOUT = false;          private final static boolean DEF_LS_CONSOLE_POPOUT = false;
83                    
         private final static String LS_CONSOLE_HISTORY = "LSConsole.history";  
         private final static String DEF_LS_CONSOLE_HISTORY = "";  
           
84          private final static String LS_CONSOLE_HISTSIZE = "LSConsole.histsize";          private final static String LS_CONSOLE_HISTSIZE = "LSConsole.histsize";
85          private final static int DEF_LS_CONSOLE_HISTSIZE = 1000;          private final static int DEF_LS_CONSOLE_HISTSIZE = 1000;
86                    
# Line 97  public class ClassicPrefs { Line 99  public class ClassicPrefs {
99          private final static String LS_CONSOLE_ERROR_COLOR = "LSConsole.errorColor";          private final static String LS_CONSOLE_ERROR_COLOR = "LSConsole.errorColor";
100          private final static int DEF_LS_CONSOLE_ERROR_COLOR = 0xff0000;          private final static int DEF_LS_CONSOLE_ERROR_COLOR = 0xff0000;
101                    
102            private final static String SAVE_LS_CONSOLE_HISTORY = "LSConsole.saveCommandHistory";
103            private final static boolean DEF_SAVE_LS_CONSOLE_HISTORY = true;
104            
105          private final static String CHANNEL_BORDER_COLOR = "Channel.borderColor";          private final static String CHANNEL_BORDER_COLOR = "Channel.borderColor";
106          private final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5;          private final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5;
107                    
108          private final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor";          private final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor";
109          private final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false;          private final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false;
110                    
111            private final static String CHANNEL_BORDER_HL_COLOR = "Channel.borderMouseOverColor";
112            private final static int DEF_CHANNEL_BORDER_HL_COLOR = 0xb8cfe5;
113            
114            private final static String CUSTOM_CHANNEL_BORDER_HL_COLOR = "Channel.customHlColor";
115            private final static boolean DEF_CUSTOM_CHANNEL_BORDER_HL_COLOR = false;
116            
117            private final static String SEL_CHANNEL_BG_COLOR = "Channel.sel.BgColor";
118            private final static int DEF_SEL_CHANNEL_BG_COLOR = 0xe0e6eb;
119            
120            private final static String CUSTOM_SEL_CHANNEL_BG_COLOR = "Channel.sel.customBgColor";
121            private final static boolean DEF_CUSTOM_SEL_CHANNEL_BG_COLOR = false;
122            
123            private final static String HL_CHANNEL_BG_COLOR = "Channel.hl.BgColor";
124            private final static int DEF_HL_CHANNEL_BG_COLOR = -1;
125            
126            private final static String CUSTOM_HL_CHANNEL_BG_COLOR = "Channel.hl.customBgColor";
127            private final static boolean DEF_CUSTOM_HL_CHANNEL_BG_COLOR = false;
128            
129          private final static String VSPLIT_DIVIDER_LOCATION = "VSplit.dividerLocation";          private final static String VSPLIT_DIVIDER_LOCATION = "VSplit.dividerLocation";
130          private final static int DEF_VSPLIT_DIVIDER_LOCATION = 200;          private final static int DEF_VSPLIT_DIVIDER_LOCATION = 200;
131                    
132          private final static String CURRENT_ORCHESTRA_IDX = "OrchestrasPage.currentOrchestraIndex";          private final static String CURRENT_ORCHESTRA_IDX = "OrchestrasPage.currentOrchestraIndex";
133          private final static int DEF_CURRENT_ORCHESTRA_IDX = 0;          private final static int DEF_CURRENT_ORCHESTRA_IDX = 0;
134                    
135            private final static String LAST_SCRIPT_LOCATION = "lastScriptLocation";
136            private final static String DEF_LAST_SCRIPT_LOCATION = null;
137            
138            private final static String NEW_MIDI_INSTR_WIZARD_SKIP1 = "NewMidiInstrumentWizard.skip1";
139            private final static boolean DEF_NEW_MIDI_INSTR_WIZARD_SKIP1 = false;
140            
141            private final static String INSTR_LOCATION_METHOD = "InstrLocationMethod";
142            private final static int DEF_INSTR_LOCATION_METHOD = 0;
143            
144          private static Preferences userPrefs = Preferences.userRoot().node(prefNode);          private static Preferences userPrefs = Preferences.userRoot().node(prefNode);
145                    
146          public static Preferences          public static Preferences
# Line 263  public class ClassicPrefs { Line 295  public class ClassicPrefs {
295          }          }
296                    
297          /**          /**
298           * Determines whether the toolbar should be visible.           * Determines whether the <b>Channels</b> toolbar should be visible.
299           * @return <code>true</code> if the toolbar should be visible,           * @return <code>true</code> if the <b>Channels</b> toolbar should be visible,
300           * <code>false</code> otherwise.           * <code>false</code> otherwise.
301           */           */
302          public static boolean          public static boolean
303          shouldShowToolbar() { return user().getBoolean(SHOW_TOOLBAR, DEF_SHOW_TOOLBAR); }          shouldShowChannelsBar() {
304                    return user().getBoolean(SHOW_CHANNELS_BAR, DEF_SHOW_CHANNELS_BAR);
305            }
306                    
307          /**          /**
308           * Sets whether the toolbar should be visible.           * Sets whether the <b>Channels</b> toolbar should be visible.
309           * @param b If <code>true</code> the toolbar will be visible at startup.           * @param b If <code>true</code> the <b>Channels</b> toolbar will be visible at startup.
310           */           */
311          public static void          public static void
312          setShowToolbar(boolean b) {          setShowChannelsBar(boolean b) {
313                  if(b == shouldShowToolbar()) return;                  if(b == shouldShowChannelsBar()) return;
314                  user().putBoolean(SHOW_TOOLBAR, b);                  user().putBoolean(SHOW_CHANNELS_BAR, b);
315          }          }
316                    
317          /**          /**
# Line 380  public class ClassicPrefs { Line 414  public class ClassicPrefs {
414          }          }
415                    
416          /**          /**
          * Gets the LS Console's command history.  
          * @return The LS Console's command history.  
          */  
         public static String  
         getLSConsoleHistory() {  
                 return user().get(LS_CONSOLE_HISTORY, DEF_LS_CONSOLE_HISTORY);  
         }  
           
         /**  
          * Sets the LS Console's command history.  
          * @param s The LS Console's command history.  
          */  
         public static void  
         setLSConsoleHistory(String s) {  
                 if(s == null) {  
                         user().remove(LS_CONSOLE_HISTORY);  
                         return;  
                 }  
                   
                 user().put(LS_CONSOLE_HISTORY, s);  
         }  
           
         /**  
417           * Gets the LS Console's command history size.           * Gets the LS Console's command history size.
418           * @return The maximum number of lines to be kept in the command history.           * @return The maximum number of lines to be kept in the command history.
419           */           */
# Line 557  public class ClassicPrefs { Line 568  public class ClassicPrefs {
568          }          }
569                    
570          /**          /**
571             * Determines whether the command history should be saved on exit.
572             * @return <code>true</code> if the command history should be saved on exit,
573             * <code>false</code> otherwise.
574             */
575            public static boolean
576            getSaveConsoleHistory() {
577                    return user().getBoolean(SAVE_LS_CONSOLE_HISTORY, DEF_SAVE_LS_CONSOLE_HISTORY);
578            }
579            
580            /**
581             * Sets whether the command history should be saved on exit.
582             * @param b If <code>true</code> the command history will be saved on exit.
583             */
584            public static void
585            setSaveConsoleHistory(boolean b) {
586                    if(b == getSaveConsoleHistory()) return;
587                    user().putBoolean(SAVE_LS_CONSOLE_HISTORY, b);
588            }
589            
590            /**
591           * Determines whether the left pane should be visible.           * Determines whether the left pane should be visible.
592           * @return <code>true</code> if the left pane should be visible,           * @return <code>true</code> if the left pane should be visible,
593           * <code>false</code> otherwise.           * <code>false</code> otherwise.
# Line 575  public class ClassicPrefs { Line 606  public class ClassicPrefs {
606          }          }
607                    
608          /**          /**
609             * Determines whether the <b>Standard</b> toolbar should be visible.
610             * @return <code>true</code> if the <b>Standard</b> toolbar should be visible,
611             * <code>false</code> otherwise.
612             */
613            public static boolean
614            shouldShowStandardBar() {
615                    return user().getBoolean(SHOW_STANDARD_BAR, DEF_SHOW_STANDARD_BAR);
616            }
617            
618            /**
619             * Sets whether the <b>Standard</b> toolbar should be visible.
620             * @param b If <code>true</code> the <b>Standard</b> toolbar will be visible at startup.
621             */
622            public static void
623            setShowStandardBar(boolean b) {
624                    if(b == shouldShowStandardBar()) return;
625                    user().putBoolean(SHOW_STANDARD_BAR, b);
626            }
627            
628            /**
629           * Gets the default border color that is used for the selected channels.           * Gets the default border color that is used for the selected channels.
630           * @return The default border color that is used for the selected channels.           * @return The default border color that is used for the selected channels.
631           */           */
# Line 583  public class ClassicPrefs { Line 634  public class ClassicPrefs {
634                    
635          /**          /**
636           * Gets the custom border color to be used for the selected channels.           * Gets the custom border color to be used for the selected channels.
637           * @return The custom border color to be used for the selected channels.           * @return The custom border color to be used for the selected
638             * channels or <code>null</code> if the color is not specified.
639           */           */
640          public static Color          public static Color
641          getChannelBorderColor() {          getChannelBorderColor() {
# Line 632  public class ClassicPrefs { Line 684  public class ClassicPrefs {
684          }          }
685                    
686          /**          /**
687             * Gets the default highlighted border color that
688             * is used when the mouse pointer is over a channel.
689             * @return The default highlighted border color.
690             */
691            public static Color
692            getDefaultChannelBorderHlColor() { return new Color(DEF_CHANNEL_BORDER_HL_COLOR); }
693            
694            /**
695             * Gets the custom highlighted border color that
696             * is used when the mouse pointer is over a channel.
697             * @return The custom highlighted border color.
698             */
699            public static Color
700            getChannelBorderHlColor() {
701                    int c = user().getInt(CHANNEL_BORDER_HL_COLOR, DEF_CHANNEL_BORDER_HL_COLOR);
702                    return new Color(c);
703            }
704            
705            /**
706             * Sets the highlighted border color that
707             * is used when the mouse pointer is over a channel.
708             * Use <code>null</code> to remove the current value.
709             * @param color The new highlighted border color.
710             */
711            public static void
712            setChannelBorderHlColor(Color c) {
713                    if(c == null) {
714                            user().remove(CHANNEL_BORDER_HL_COLOR);
715                            return;
716                    }
717                    
718                    if(c.getRGB() == getChannelBorderHlColor().getRGB()) return;
719                    
720                    user().putInt(CHANNEL_BORDER_HL_COLOR, c.getRGB());
721            }
722            
723            /**
724             * Determines whether to use a custom highlighted border color.
725             * @return <code>true</code> if custom highlighted border color
726             * must be used, <code>false</code> otherwise.
727             */
728            public static boolean
729            getCustomChannelBorderHlColor() {
730                    return user().getBoolean (
731                            CUSTOM_CHANNEL_BORDER_HL_COLOR, DEF_CUSTOM_CHANNEL_BORDER_HL_COLOR
732                    );
733            }
734            
735            /**
736             * Sets whether to use a custom highlighted border color.
737             * @param b specify <code>true</code> to use a custom highlighted
738             * border color, <code>false</code> otherwise.
739             */
740            public static void
741            setCustomChannelBorderHlColor(boolean b) {
742                    if(b == getCustomChannelBorderHlColor()) return;
743                    user().putBoolean(CUSTOM_CHANNEL_BORDER_HL_COLOR, b);
744            }
745            
746            /**
747             * Gets the custom background color that
748             * is used when the channel is selected.
749             * @return The custom background color that
750             * is used when the channel is selected.
751             */
752            public static Color
753            getSelectedChannelBgColor() {
754                    int c = user().getInt(SEL_CHANNEL_BG_COLOR, DEF_SEL_CHANNEL_BG_COLOR);
755                    return c == -1 ? null : new Color(c);
756            }
757            
758            /**
759             * Sets the custom background color to
760             * be used when the channel is selected.
761             * Use <code>null</code> to remove the current value.
762             * @param color The new background color to
763             * be used when the channel is selected.
764             */
765            public static void
766            setSelectedChannelBgColor(Color c) {
767                    if(c == null) {
768                            user().remove(SEL_CHANNEL_BG_COLOR);
769                            return;
770                    }
771                    
772                    if(getSelectedChannelBgColor() != null) {
773                            if(c.getRGB() == getSelectedChannelBgColor().getRGB()) return;
774                    }
775                    
776                    user().putInt(SEL_CHANNEL_BG_COLOR, c.getRGB());
777            }
778            
779            /**
780             * Determines whether to use a custom background color when a channel is selected.
781             * @return <code>true</code> if custom background color
782             * should be used, <code>false</code> otherwise.
783             */
784            public static boolean
785            getCustomSelectedChannelBgColor() {
786                    return user().getBoolean (
787                            CUSTOM_SEL_CHANNEL_BG_COLOR, DEF_CUSTOM_SEL_CHANNEL_BG_COLOR
788                    );
789            }
790            
791            /**
792             * Sets whether to use a custom background color when a channel is selected.
793             * @param b specify <code>true</code> to use a custom
794             * background color, <code>false</code> otherwise.
795             */
796            public static void
797            setCustomSelectedChannelBgColor(boolean b) {
798                    if(b == getCustomSelectedChannelBgColor()) return;
799                    user().putBoolean(CUSTOM_SEL_CHANNEL_BG_COLOR, b);
800            }
801            
802            /**
803             * Gets the custom background color that
804             * is used when the mouse pointer is over a channel.
805             * @return The custom background color that
806             * is used when the mouse pointer is over a channel.
807             */
808            public static Color
809            getHighlightedChannelBgColor() {
810                    int c = user().getInt(HL_CHANNEL_BG_COLOR, DEF_HL_CHANNEL_BG_COLOR);
811                    return c == -1 ? null : new Color(c);
812            }
813            
814            /**
815             * Sets the custom background color to
816             * be used when the mouse pointer is over a channel.
817             * Use <code>null</code> to remove the current value.
818             * @param color The new background color to
819             * be used when the mouse pointer is over a channel.
820             */
821            public static void
822            setHighlightedChannelBgColor(Color c) {
823                    if(c == null) {
824                            user().remove(HL_CHANNEL_BG_COLOR);
825                            return;
826                    }
827                    
828                    if(getHighlightedChannelBgColor() != null) {
829                            if(c.getRGB() == getHighlightedChannelBgColor().getRGB()) return;
830                    }
831                    
832                    user().putInt(HL_CHANNEL_BG_COLOR, c.getRGB());
833            }
834            
835            /**
836             * Determines whether to use a custom background
837             * color when the mouse pointer is over a channel.
838             * @return <code>true</code> if custom background color
839             * should be used, <code>false</code> otherwise.
840             */
841            public static boolean
842            getCustomHighlightedChannelBgColor() {
843                    return user().getBoolean (
844                            CUSTOM_HL_CHANNEL_BG_COLOR, DEF_CUSTOM_HL_CHANNEL_BG_COLOR
845                    );
846            }
847            
848            /**
849             * Sets whether to use a custom background
850             * color when the mouse pointer is over a channel.
851             * @param b specify <code>true</code> to use a custom
852             * background color, <code>false</code> otherwise.
853             */
854            public static void
855            setCustomHighlightedChannelBgColor(boolean b) {
856                    if(b == getCustomHighlightedChannelBgColor()) return;
857                    user().putBoolean(CUSTOM_HL_CHANNEL_BG_COLOR, b);
858            }
859            
860            /**
861           * Gets the divider location of the vertical split pane.           * Gets the divider location of the vertical split pane.
862           * @return The divider location of the vertical split pane.           * @return The divider location of the vertical split pane.
863           */           */
# Line 668  public class ClassicPrefs { Line 894  public class ClassicPrefs {
894                  if(i == getCurrentOrchestraIndex()) return;                  if(i == getCurrentOrchestraIndex()) return;
895                  user().putInt(CURRENT_ORCHESTRA_IDX, i);                  user().putInt(CURRENT_ORCHESTRA_IDX, i);
896          }          }
897            
898            /**
899             * Gets the absolute path of the directory containing the last saved script.
900             * @return The absolute path of the directory containing the last saved script or
901             * <code>null</code>.
902             */
903            public static String
904            getLastScriptLocation() {
905                    return user().get(LAST_SCRIPT_LOCATION, DEF_LAST_SCRIPT_LOCATION);
906            }
907            
908            /**
909             * Sets the absolute path of the directory containing the last saved script.
910             * @param s The absolute path of the directory containing the last saved script.
911             */
912            public static void
913            setLastScriptLocation(String s) {
914                    if(s == null) {
915                            user().remove(LAST_SCRIPT_LOCATION);
916                            return;
917                    }
918                    
919                    user().put(LAST_SCRIPT_LOCATION, s);
920            }
921            
922            /**
923             * Determines whether the first step in the
924             * <b>New MIDI Instrument Wizard</b> should be skipped.
925             * @return <code>true</code> if the first step should be skipped,
926             * <code>false</code> otherwise.
927             */
928            public static boolean
929            getNewMidiInstrWizardSkip1() {
930                    return user().getBoolean (
931                            NEW_MIDI_INSTR_WIZARD_SKIP1, DEF_NEW_MIDI_INSTR_WIZARD_SKIP1
932                    );
933            }
934            
935            /**
936             * Sets whether the first step in the
937             * <b>New MIDI Instrument Wizard</b> should be skipped.
938             * @param b If <code>true</code> the first step will be skipped.
939             */
940            public static void
941            setNewMidiInstrWizardSkip1(boolean b) {
942                    if(b == getNewMidiInstrWizardSkip1()) return;
943                    user().putBoolean(NEW_MIDI_INSTR_WIZARD_SKIP1, b);
944            }
945            
946            /**
947             * Gets the instrument location method (locating an instrument by
948             * choosing from orchestra, etc).
949             * @return The index of the instrument location method.
950             */
951            public static int
952            getInstrLocationMethod() {
953                    return user().getInt(INSTR_LOCATION_METHOD, DEF_INSTR_LOCATION_METHOD);
954            }
955            
956            /**
957             * Sets the instrument location method.
958             * @param i Determines the instrument location method.
959             */
960            public static void
961            setInstrLocationMethod(int i) {
962                    if(i == getInstrLocationMethod()) return;
963                    user().putInt(INSTR_LOCATION_METHOD, i);
964            }
965            
966            
967  }  }

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

  ViewVC Help
Powered by ViewVC