X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FSwingInterface.java;h=b9eb177a7db9fba37f6400761d1f6d34769b41a4;hb=6f655f2a30d35fd6192ea86ccfd08149438011b0;hp=d00ebe1a665e45bb98012927a2c4ce8ef4cc4770;hpb=90f3a1c8e0c85f19c82130e49d7a605cb9e55286;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index d00ebe1..b9eb177 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -41,7 +41,7 @@ import net.pterodactylus.util.io.Closer; /** * The Swing user interface. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ @@ -105,12 +105,21 @@ public class SwingInterface implements CoreListener { // CONFIGURATION // - /** Whether to beautify the GUI. */ - private boolean beautify; + /** The advanced mode. */ + private boolean advancedMode; + + /** Whether to antialias the GUI. */ + private boolean antialias; + + /** The control font. */ + private String controlFont; + + /** The user font. */ + private String userFont; /** * Creates a new swing interface. - * + * * @param core * The core to operate on * @param configDirectory @@ -121,10 +130,14 @@ public class SwingInterface implements CoreListener { this.configDirectory = configDirectory; I18n.setLocale(Locale.ENGLISH); loadConfig(); - if (beautify) { + if (antialias) { System.setProperty("swing.aatext", "true"); - System.setProperty("swing.plaf.metal.controlFont", "Tahoma"); - System.setProperty("swing.plaf.metal.userFont", "Tahoma"); + } + if (controlFont != null) { + System.setProperty("swing.plaf.metal.controlFont", controlFont); + } + if (userFont != null) { + System.setProperty("swing.plaf.metal.userFont", userFont); } initActions(); initDialogs(); @@ -136,7 +149,7 @@ public class SwingInterface implements CoreListener { /** * Returns the core that is controlled by the Swing interface. - * + * * @return The core */ Core getCore() { @@ -145,7 +158,7 @@ public class SwingInterface implements CoreListener { /** * Returns the main window of the Swing interface. - * + * * @return The main window */ MainWindow getMainWindow() { @@ -154,7 +167,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “configure” action. - * + * * @return The “configure” action */ I18nAction getConfigureAction() { @@ -163,7 +176,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “import config” action. - * + * * @return The “import config” action */ I18nAction getImportConfigAction() { @@ -172,7 +185,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “quit” action. - * + * * @return The “quit” action */ I18nAction getQuitAction() { @@ -181,7 +194,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “manage nodes” action. - * + * * @return The “manage nodes” action */ I18nAction getManageNodesAction() { @@ -190,7 +203,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “connect to node” action. - * + * * @return The “connect to node” action */ I18nAction getNodeConnectAction() { @@ -199,7 +212,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “disconnect from node” action. - * + * * @return The “disconnect from node” action */ I18nAction getNodeDisconnectAction() { @@ -208,7 +221,7 @@ public class SwingInterface implements CoreListener { /** * Returns all language actions. - * + * * @return All language actions */ List getLanguageActions() { @@ -217,7 +230,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “about” action. - * + * * @return The “about” action */ I18nAction getHelpAboutAction() { @@ -226,7 +239,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “add project” action. - * + * * @return The “add project” action */ I18nAction getAddProjectAction() { @@ -235,7 +248,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “clone project” action. - * + * * @return The “clone project” action */ I18nAction getCloneProjectAction() { @@ -244,7 +257,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “delete project” action. - * + * * @return The “delete project” action */ I18nAction getDeleteProjectAction() { @@ -275,7 +288,7 @@ public class SwingInterface implements CoreListener { */ private void loadConfig() { /* initialize default stuff. */ - beautify = false; + antialias = false; /* now read config. */ File configFile = new File(configDirectory, "swing-interface.properties"); if (!configFile.exists() || !configFile.canRead() || !configFile.isFile()) { @@ -292,8 +305,20 @@ public class SwingInterface implements CoreListener { } finally { Closer.close(configInputStream); } - if (configProperties.containsKey("beautify")) { - beautify = Boolean.valueOf(configProperties.getProperty("beautify")); + if (configProperties.containsKey("advancedMode")) { + advancedMode = Boolean.valueOf(configProperties.getProperty("advancedMode")); + } + if (configProperties.containsKey("antialias")) { + antialias = Boolean.valueOf(configProperties.getProperty("antialias")); + } + if (configProperties.containsKey("controlFont")) { + controlFont = configProperties.getProperty("controlFont"); + } + if (configProperties.containsKey("userFont")) { + userFont = configProperties.getProperty("userFont"); + } + if (configProperties.containsKey("language")) { + I18n.setLocale(new Locale(configProperties.getProperty("language"))); } } @@ -314,7 +339,15 @@ public class SwingInterface implements CoreListener { } File configFile = new File(configDirectory, "swing-interface.properties"); Properties configProperties = new Properties(); - configProperties.setProperty("beautify", String.valueOf(beautify)); + configProperties.setProperty("advancedMode", String.valueOf(advancedMode)); + configProperties.setProperty("antialias", String.valueOf(antialias)); + if (controlFont != null) { + configProperties.setProperty("controlFont", controlFont); + } + if (userFont != null) { + configProperties.setProperty("userFont", userFont); + } + configProperties.setProperty("language", I18n.getLocale().getLanguage()); FileOutputStream configOutputStream = null; try { configOutputStream = new FileOutputStream(configFile); @@ -462,10 +495,19 @@ public class SwingInterface implements CoreListener { * Shows the configuration dialog. */ private void configure() { - configurationDialog.setBeautify(beautify); + configurationDialog.setAdvancedMode(advancedMode); + configurationDialog.setAntialias(antialias); + configurationDialog.setControlFont(controlFont); + configurationDialog.setUserFont(userFont); configurationDialog.setVisible(true); if (!configurationDialog.wasCancelled()) { - beautify = configurationDialog.getBeautify(); + advancedMode = configurationDialog.isAdvancedMode(); + if (!advancedMode && (nodeList.size() > 1)) { + JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.message"), I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.title"), JOptionPane.WARNING_MESSAGE); + } + antialias = configurationDialog.isAntialias(); + controlFont = configurationDialog.getControlFont(); + userFont = configurationDialog.getUserFont(); saveConfig(); } } @@ -474,6 +516,7 @@ public class SwingInterface implements CoreListener { * Imports old jSite configuration. */ private void importConfig() { + /* TODO */ } /** @@ -488,27 +531,51 @@ public class SwingInterface implements CoreListener { * Pops up the “manage nodes” dialog. */ private void manageNodes() { - manageNodesDialog.setNodeList(nodeList); - manageNodesDialog.setVisible(true); - nodeList = manageNodesDialog.getNodeList(); + if (advancedMode) { + manageNodesDialog.setNodeList(nodeList); + manageNodesDialog.setVisible(true); + nodeList = manageNodesDialog.getNodeList(); + } else { + if (nodeList.isEmpty()) { + Node newNode = new Node(); + newNode.setName(I18n.get("general.defaultNode.name")); + newNode.setHostname("localhost"); + newNode.setPort(9481); + nodeList.add(newNode); + } + Node firstNode = nodeList.get(0); + EditNodeDialog editNodeDialog = manageNodesDialog.getEditNodeDialog(); + editNodeDialog.setNodeName(firstNode.getName()); + editNodeDialog.setNodeHostname(firstNode.getHostname()); + editNodeDialog.setNodePort(firstNode.getPort()); + editNodeDialog.setVisible(true); + if (!editNodeDialog.wasCancelled()) { + firstNode.setName(editNodeDialog.getNodeName()); + firstNode.setHostname(editNodeDialog.getNodeHostname()); + firstNode.setPort(editNodeDialog.getNodePort()); + /* TODO - give to core. */ + } + } } /** * Connects to the node. */ private void nodeConnect() { + /* TODO */ } /** * Disconnects from the node. */ private void nodeDisconnect() { + /* TODO */ } /** * Changes the language of the interface. This method also disables the * action for the newly set language and enables all others. - * + * * @param newLocale * The new language * @param languageAction @@ -541,12 +608,14 @@ public class SwingInterface implements CoreListener { * Clones a project. */ private void cloneProject() { + /* TODO */ } /** * Deletes a project. */ private void deleteProject() { + /* TODO */ } // @@ -556,36 +625,60 @@ public class SwingInterface implements CoreListener { /** * {@inheritDoc} */ - public void loadingProjectsFailed(String directory) { + public void loadingProjectsFailed(String directory, Throwable throwable) { JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.projectLoadingFailed.message", directory), I18n.get("mainWindow.error.projectLoadingFailed.title"), JOptionPane.ERROR_MESSAGE); } /** * {@inheritDoc} */ + public void savingProjectsDone(String directory) { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectSavingDone")); + } + + /** + * {@inheritDoc} + */ + public void savingProjectsFailed(String directory, Throwable throwabled) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ public void coreLoaded() { this.nodeList = core.getNodes(); manageNodesDialog.setNodeList(nodeList); mainWindow.setVisible(true); - mainWindow.setStatusBarText("Core loaded."); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreLoaded")); + } + + /** + * {@inheritDoc} + */ + public void coreStopped() { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreStopped")); } /** * {@inheritDoc} */ public void nodeConnected(Node node) { + /* TODO */ } /** * {@inheritDoc} */ public void nodeConnecting(Node node) { + /* TODO */ } /** * {@inheritDoc} */ public void nodeDisconnected(Node node) { + /* TODO */ } }