import java.io.File;
-import net.pterodactylus.jsite.core.Core;
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
+import net.pterodactylus.jsite.core.CoreImpl;
+import net.pterodactylus.jsite.core.NodeManager;
import net.pterodactylus.jsite.core.ProjectManager;
+import net.pterodactylus.jsite.core.RequestManager;
import net.pterodactylus.jsite.gui.SwingInterface;
+import net.pterodactylus.util.logging.Logging;
/**
* Main class that is called by the VM.
* Starts the core and the default {@link SwingInterface}.
*/
private void start() {
- Core core = new Core();
+ Logging.setup("jSite");
+
+ /* include a couple known Look & Feels. */
+ maybeAddLookAndFeel("Substance", "org.jvnet.substance.SubstanceLookAndFeel");
+
+ CoreImpl core = new CoreImpl();
String configDirectory = System.getProperty("user.home") + File.separator + ".jSite";
-
+
+ NodeManager nodeManager = new NodeManager("jSite-" + Version.getVersion(), configDirectory);
+ core.setNodeManager(nodeManager);
+ nodeManager.addNodeListener(core);
+
ProjectManager projectManager = new ProjectManager(configDirectory);
core.setProjectManager(projectManager);
+ projectManager.setNodeManager(nodeManager);
+
+ RequestManager requestManager = new RequestManager();
+ core.setRequestManager(requestManager);
+ nodeManager.addNodeListener(requestManager);
+ requestManager.setNodeManager(nodeManager);
+ requestManager.addRequestListener(core);
SwingInterface swingInterface = new SwingInterface(core, configDirectory);
core.addCoreListener(swingInterface);
- swingInterface.start();
+ Logging.addLoggingListener(swingInterface);
core.start();
}
+ /**
+ * Tries to load the class with the given name and includes the look & feel
+ * in the UIManager, if it exists.
+ *
+ * @param name
+ * The name of the look & feel
+ * @param className
+ * The name of the look & feel’s main class
+ */
+ private void maybeAddLookAndFeel(String name, String className) {
+ try {
+ Class.forName(className);
+ LookAndFeelInfo[] installedLookAndFeelds = UIManager.getInstalledLookAndFeels();
+ LookAndFeelInfo[] newLookAndFeels = new LookAndFeelInfo[installedLookAndFeelds.length + 1];
+ System.arraycopy(installedLookAndFeelds, 0, newLookAndFeels, 0, installedLookAndFeelds.length);
+ newLookAndFeels[installedLookAndFeelds.length] = new UIManager.LookAndFeelInfo(name, className);
+ UIManager.setInstalledLookAndFeels(newLookAndFeels);
+ } catch (ClassNotFoundException e) {
+ /* okay, it doesn't exist, ignore. */
+ }
+ }
+
}