/*
* Copyright (c) 2013-2014. Confluenity
* This content is released under the Apache 2 license:
* http://www.apache.org/licenses/LICENSE-2.0
*/
package com.confluenity.jaylen;
import com.confluenity.jaylen.forms.Splash;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Properties;
public class Application {
private ApplicationContext springContext;
public Application() throws IOException {
final Properties properties = new Properties();
properties.load(this.getClass().getResourceAsStream("/app.properties"));
Splash splash = new Splash(MessageFormat.format("{0} {1}", properties.getProperty("application.name"), properties.getProperty("application.version")));
this.springContext = new ClassPathXmlApplicationContext("spring/jaylen.xml");
((ClassPathXmlApplicationContext)this.springContext).setDisplayName(properties.getProperty("application.name"));
((ClassPathXmlApplicationContext)this.springContext).setBeanName("springContext");
((AbstractApplicationContext)this.springContext).registerShutdownHook();
splash.dispose();
}
public static void main(String... args) throws IOException {
Application application = new Application();
Shell shell = application.springContext.getBean("mainShell", Shell.class);
shell.open();
Display display = application.springContext.getBean(Display.class);
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep();
}
display.dispose();
}
}