X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fmain%2FMain.java;h=cf31c0700b3188b2346636e33cba1b16f224fdf3;hb=e7fd217d2304bc11716525992ec6c8f22ae54914;hp=0c157a8b90820f657ecc25a1f0dfb279c7bda808;hpb=373b2e1797186965bf754410dd3fadff78e9d616;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/main/Main.java b/src/net/pterodactylus/jsite/main/Main.java index 0c157a8..cf31c07 100644 --- a/src/net/pterodactylus/jsite/main/Main.java +++ b/src/net/pterodactylus/jsite/main/Main.java @@ -20,8 +20,15 @@ package net.pterodactylus.jsite.main; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; import net.pterodactylus.jsite.core.CoreImpl; +import net.pterodactylus.jsite.core.InsertManager; import net.pterodactylus.jsite.core.NodeManager; import net.pterodactylus.jsite.core.ProjectManager; import net.pterodactylus.jsite.core.RequestManager; @@ -30,15 +37,14 @@ import net.pterodactylus.util.logging.Logging; /** * Main class that is called by the VM. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ public class Main { /** * Main entry method for the VM. - * + * * @param args * The command-line arguments */ @@ -64,6 +70,10 @@ public class Main { core.setProjectManager(projectManager); projectManager.setNodeManager(nodeManager); + InsertManager insertManager = new InsertManager(); + core.setInsertManager(insertManager); + insertManager.addInsertListener(core); + RequestManager requestManager = new RequestManager(); core.setRequestManager(requestManager); nodeManager.addNodeListener(requestManager); @@ -77,4 +87,39 @@ public class Main { 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 + */ + @SuppressWarnings("unused") + private void addLookAndFeel(String name, String className) { + addLookAndFeels(new LookAndFeelInfo(name, className)); + } + + /** + * Tries to load each look & feel and adds it to the list of installed look + * & feels. + * + * @see UIManager#setInstalledLookAndFeels(LookAndFeelInfo[]) + * @param lookAndFeelInfos + * The look & feels to add + */ + private void addLookAndFeels(LookAndFeelInfo... lookAndFeelInfos) { + List allLookAndFeelInfos = new ArrayList(Arrays.asList(UIManager.getInstalledLookAndFeels())); + for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) { + try { + Class.forName(lookAndFeelInfo.getClassName()); + allLookAndFeelInfos.add(lookAndFeelInfo); + } catch (ClassNotFoundException e) { + /* okay, it doesn't exist, ignore. */ + } + } + UIManager.setInstalledLookAndFeels(allLookAndFeelInfos.toArray(new LookAndFeelInfo[0])); + } + }