/[svn]/jsampler/trunk/src/org/jsampler/JSampler.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/JSampler.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (show annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 4 months ago) by iliev
File size: 3018 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2011 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
23 package org.jsampler;
24
25 import net.sf.juife.PDUtils;
26 import net.sf.juife.event.GenericEvent;
27 import net.sf.juife.event.GenericListener;
28
29 import org.jsampler.view.JSViews;
30
31 /**
32 * The main class of the application.
33 * @author Grigor Iliev
34 */
35 public class JSampler {
36 /** The application name. */
37 public final static String NAME = "JSampler";
38
39 /** The application version. */
40 public final static String VERSION = "0.9cvs2";
41
42 public static String[] scripts;
43
44
45 /**
46 * The entry point of the application.
47 * @param args The command line arguments.
48 * @see CC#cleanExit
49 */
50 public static void
51 main(String[] args) {
52 scripts = args;
53 CC.initJSampler();
54 initGUI();
55 }
56
57 /**
58 * Schedule the specified script to be run when connection is established.
59 * @param fileName The path of the script to run.
60 */
61 public static void
62 open(String fileName) {
63 CC.getLogger().warning(fileName);
64 if(fileName == null) return;
65 if(CC.getClient().isConnected()) {
66 CC.getMainFrame().runScript(fileName);
67 return;
68 }
69
70 if(scripts == null) {
71 scripts = new String[1];
72 scripts[0] = fileName;
73 CC.addConnectionEstablishedListener(new ConnectionEstablishedListener());
74 } else {
75 String[] files = new String[scripts.length + 1];
76 for(int i = 0; i < scripts.length; i++) {
77 files[i] = scripts[i];
78 }
79 files[files.length - 1] = fileName;
80 scripts = files;
81 }
82 }
83
84 private static void
85 initGUI() {
86 JSViews.parseManifest();
87
88 PDUtils.runOnUiThread(new Runnable() {
89 public void
90 run() { initGUI0(); }
91 });
92 }
93
94 private static void
95 initGUI0() {
96 JSViews.setView(JSViews.getDefaultView());
97 if(scripts != null) {
98 CC.addConnectionEstablishedListener(new ConnectionEstablishedListener());
99 }
100
101 JSUtils.checkJSamplerHome();
102 CC.loadOrchestras();
103 CC.loadServerList();
104 CC.connect();
105 }
106
107 private static class ConnectionEstablishedListener implements GenericListener, Runnable {
108 public void
109 jobDone(GenericEvent e) {
110 if(scripts == null) return;
111 for(String s : scripts) CC.getMainFrame().runScript(s);
112 scripts = null;
113 PDUtils.runOnUiThread(this);
114 }
115
116 public void
117 run() { CC.removeConnectionEstablishedListener(this); }
118 }
119 }

  ViewVC Help
Powered by ViewVC