X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fmain%2FMain.java;h=93d42811d74da48b02673c42c9ee0c4c77beeacb;hb=823fd4e213314c2b925efddf633924b315f39b87;hp=1ee88a00f34a4caed5dcf0830311b3995d119eb4;hpb=dc79f593c85267db340e09c23d4e7c4b6d35043b;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/main/Main.java b/src/net/pterodactylus/jsite/main/Main.java index 1ee88a0..93d4281 100644 --- a/src/net/pterodactylus/jsite/main/Main.java +++ b/src/net/pterodactylus/jsite/main/Main.java @@ -20,6 +20,9 @@ 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; @@ -27,21 +30,19 @@ 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. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ public class Main { /** * Main entry method for the VM. - * + * * @param args * The command-line arguments */ @@ -55,9 +56,6 @@ public class Main { private void start() { 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"; @@ -70,12 +68,6 @@ public class Main { 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); Logging.addLoggingListener(swingInterface); @@ -86,23 +78,36 @@ public class Main { /** * 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. */ + @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])); } }