/[svn]/jsampler/trunk/src/org/jsampler/view/std/StdUtils.java
ViewVC logotype

Annotation of /jsampler/trunk/src/org/jsampler/view/std/StdUtils.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1308 - (hide annotations) (download)
Tue Aug 28 17:00:19 2007 UTC (16 years, 8 months ago) by iliev
File size: 1755 byte(s)
* A lists of recently used instrument files, directories,
  database instruments, database directories are now available
  for quick access, where appropriate.

1 iliev 1308 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4     * Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5     *
6     * This file is part of JSampler.
7     *
8     * JSampler is free software; you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License version 2
10     * as published by the Free Software Foundation.
11     *
12     * JSampler is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with JSampler; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20     * MA 02111-1307 USA
21     */
22     package org.jsampler.view.std;
23    
24     import java.util.Vector;
25    
26     import org.jsampler.CC;
27     import org.jsampler.JSPrefs;
28    
29    
30     /**
31     *
32     * @author Grigor Iliev
33     */
34     public class StdUtils {
35    
36     /** Forbids the instantiation of this class */
37     private
38     StdUtils() { }
39    
40     private static JSPrefs
41     preferences() { return CC.getViewConfig().preferences(); }
42    
43     /**
44     * Updates the specified string list property by adding the specified
45     * element on the top. Also restricts the maximum number of elements to 12.
46     */
47     public static void
48     updateRecentElements(String property, String newElement) {
49     String[] elements = preferences().getStringListProperty(property);
50     Vector<String> v = new Vector<String>();
51     v.add(newElement);
52     for(String s : elements) {
53     if(!newElement.equals(s)) v.add(s);
54     }
55     if(v.size() > 12) v.setSize(12);
56    
57     elements = v.toArray(new String[v.size()]);
58     preferences().setStringListProperty(property, elements);
59     }
60     }

  ViewVC Help
Powered by ViewVC