--- jsampler/trunk/src/org/jsampler/CC.java 2007/05/24 21:43:45 1204 +++ jsampler/trunk/src/org/jsampler/CC.java 2007/09/07 12:09:59 1327 @@ -59,6 +59,7 @@ import org.jsampler.view.JSMainFrame; import org.jsampler.view.JSProgress; +import org.jsampler.view.JSViewConfig; import org.jsampler.view.InstrumentsDbTreeModel; import org.linuxsampler.lscp.AudioOutputChannel; @@ -87,6 +88,7 @@ private static Handler handler; private static FileOutputStream fos; + private static JSViewConfig viewConfig = null; private static JSMainFrame mainFrame = null; private static JSProgress progress = null; @@ -138,6 +140,18 @@ } /** + * Gets the configuration of the current view. + */ + public static JSViewConfig + getViewConfig() { return viewConfig; } + + /** + * Sets the configuration of the current view. + */ + public static void + setViewConfig(JSViewConfig viewConfig) { CC.viewConfig = viewConfig; } + + /** * Returns the main window of this application. * @return The main window of this application. */ @@ -293,7 +307,9 @@ checkJSamplerHome() { if(getJSamplerHome() != null) { File f = new File(getJSamplerHome()); - if(f.isDirectory()) return; + if(f.exists() && f.isDirectory()) { + return; + } } CC.getMainFrame().installJSamplerHome(); @@ -309,12 +325,12 @@ public static void changeJSamplerHome(String path) { File fNew = new File(path); - if(fNew.isFile()) { + if(fNew.exists() && fNew.isFile()) { HF.showErrorMessage(i18n.getError("CC.JSamplerHomeIsNotDir!")); return; } - if(!fNew.isDirectory()) { + if(!fNew.exists()) { if(!fNew.mkdir()) { String s = fNew.getAbsolutePath(); HF.showErrorMessage(i18n.getError("CC.mkdirFailed", s)); @@ -322,13 +338,13 @@ } } - if(getJSamplerHome() == null) { + if(getJSamplerHome() == null || path.equals(getJSamplerHome())) { setJSamplerHome(fNew.getAbsolutePath()); return; } File fOld = new File(getJSamplerHome()); - if(!fOld.isDirectory()) { + if(!fOld.exists() || !fOld.isDirectory()) { setJSamplerHome(fNew.getAbsolutePath()); return; } @@ -360,7 +376,7 @@ * database support the tree model is initialized on first use. * @return The tree model of the instruments database or * null if the backend doesn't have instruments database support. - * @see org.jsampler.view.JSMainFrame#getInstrumentsDbSupport + * @see org.jsampler.view.JSViewConfig#getInstrumentsDbSupport */ public static InstrumentsDbTreeModel getInstrumentsDbTreeModel() { @@ -549,7 +565,7 @@ model.setServerInfo(gsi.getResult()); - if(CC.getMainFrame().getInstrumentsDbSupport()) { + if(CC.getViewConfig().getInstrumentsDbSupport()) { getInstrumentsDbTreeModel(); } } @@ -1012,15 +1028,7 @@ case TASK_DONE: EnhancedTask t = (EnhancedTask)e.getSource(); if(t.doneWithErrors() && !t.isStopped()) { - if(t.getErrorDetails() == null) { - HF.showErrorMessage(t.getErrorMessage()); - } else { - getMainFrame().showDetailedErrorMessage ( - getMainFrame(), - t.getErrorMessage(), - t.getErrorDetails() - ); - } + showError(t); } break; case NOT_IDLE: @@ -1033,6 +1041,24 @@ } } + private void + showError(final Task t) { + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void + run() { + if(t.getErrorDetails() == null) { + HF.showErrorMessage(t.getErrorMessage()); + } else { + getMainFrame().showDetailedErrorMessage ( + getMainFrame(), + t.getErrorMessage(), + t.getErrorDetails() + ); + } + } + }); + } + /** Invoked when the name of orchestra is changed. */ public void nameChanged(OrchestraEvent e) { saveOrchestras(); }