/* * Copyright 2016 SIB Visions GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * * History * * 11.08.2016 - [JR] - creation */ package javax.rad.application; import javax.rad.ui.IComponent; import javax.rad.ui.container.IDesktopPanel; import javax.rad.util.IRunnable; import javax.swing.JComponent; import javax.swing.SwingUtilities; import com.sibvisions.rad.application.Application; import com.sibvisions.rad.ui.swing.impl.SwingApplication; /** * The SimpleTestLauncher starts a {@link SwingApplication} and shows * a specific content in the application pane. * * @author René Jahn */ public class SimpleTestLauncher { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Initialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Creates a new instance of SimpleTestLauncher. * * @param pComponent the component to show */ public SimpleTestLauncher(final IComponent pComponent) { final SwingApplication app = new SwingApplication(); app.startup(SimpleTestApplication.class.getName(), null, null); app.setSystemExitOnDispose(false); app.eventWindowClosed().addListener(new IRunnable() { public void run() { synchronized (SimpleTestLauncher.this) { SimpleTestLauncher.this.notify(); } } }); SwingUtilities.invokeLater(new Runnable() { public void run() { IDesktopPanel desktop = ((Application)app.getApplication()).getDesktopPane(); desktop.removeAll(); desktop.add(pComponent); //because test was created before LaF was set! SwingUtilities.updateComponentTreeUI((JComponent)pComponent.getResource()); } }); synchronized(this) { try { wait(); } catch (InterruptedException ie) { //ignore } } } } // SimpleTestLauncher