
org.bidib.wizard.main.BiDiBWizard Maven / Gradle / Ivy
package org.bidib.wizard.main;
import java.io.File;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.bidib.wizard.mvc.common.view.BidibDefaultDockableContainerFactory;
import org.bidib.wizard.mvc.error.controller.ErrorController;
import org.bidib.wizard.mvc.main.controller.MainController;
import org.bidib.wizard.mvc.preferences.model.Preferences;
import org.bushe.swing.event.EventServiceExistsException;
import org.bushe.swing.event.EventServiceLocator;
import org.bushe.swing.event.ThreadSafeEventService;
import org.jdesktop.swingx.plaf.windows.WindowsLookAndFeelAddons;
import org.jdesktop.swingx.util.OS;
import org.slf4j.LoggerFactory;
import com.vlsolutions.swing.docking.DockableContainerFactory;
import com.vlsolutions.swing.docking.ui.DockingUISettings;
public final class BiDiBWizard {
private BiDiBWizard() {
DefaultApplicationContext.getInstance();
}
public void startApp(String[] args) {
// get the preferences path from a jvm property (set with -Dbidib.preferencesPath=....
String preferencesPath = System.getProperty("bidib.preferencesPath");
// if the path is not set, use the value from the environment
if (StringUtils.isBlank(preferencesPath)) {
preferencesPath = System.getenv("bidib.preferencesPath");
// if the path is not set use the user.home
if (StringUtils.isBlank(preferencesPath)) {
preferencesPath = System.getProperty("user.home");
System.setProperty("bidib.preferencesPath", preferencesPath);
}
}
// set path to preferences
Preferences.setPath(new File(preferencesPath).getPath());
Preferences.getInstance().reloadLoggerConfiguration(true);
Preferences.getInstance().printPreferences();
try {
EventServiceLocator.setEventService(EventServiceLocator.SERVICE_NAME_SWING_EVENT_SERVICE,
new ThreadSafeEventService());
}
catch (EventServiceExistsException ex) {
LoggerFactory.getLogger(BiDiBWizard.class).warn("Configure event service failed.", ex);
}
// set system look and feel only under windows
try {
if (SystemUtils.IS_OS_LINUX) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
}
catch (Exception ex) {
LoggerFactory.getLogger(BiDiBWizard.class).warn("Set GTKLookAndFeel failed.", ex);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
}
else {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException ex) {
LoggerFactory.getLogger(BiDiBWizard.class).warn("Set the system L&F failed.", ex);
}
if (OS.isUsingWindowsVisualStyles()) {
String xpStyle = OS.getWindowsVisualStyle();
if (WindowsLookAndFeelAddons.SILVER_VISUAL_STYLE.equalsIgnoreCase(xpStyle)
|| WindowsLookAndFeelAddons.VISTA_VISUAL_STYLE.equalsIgnoreCase(xpStyle)) {
UIManager.put("StatusBar.rightImage", "/icons/silver-statusbar-right.png");
}
else {
UIManager.put("StatusBar.rightImage", "/icons/statusbar-right.png");
}
}
DockableContainerFactory.setFactory(new BidibDefaultDockableContainerFactory());
DockingUISettings.getInstance().installUI();
new ErrorController().start();
new MainController().start();
}
public static void main(final String[] args) {
// open GUI
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new BiDiBWizard().startApp(args);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy