Package com.confluenity.jaylen

Source Code of com.confluenity.jaylen.Application

/*
* 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();
  }
}
TOP

Related Classes of com.confluenity.jaylen.Application

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.