From: David ‘Bombe’ Roden Date: Sat, 3 May 2008 16:05:01 +0000 (+0000) Subject: add advanced mode X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6f655f2a30d35fd6192ea86ccfd08149438011b0;p=jSite2.git add advanced mode git-svn-id: http://trooper/svn/projects/jSite/trunk@779 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/gui/ConfigurationDialog.java b/src/net/pterodactylus/jsite/gui/ConfigurationDialog.java index fc93c3b..a5a6c88 100644 --- a/src/net/pterodactylus/jsite/gui/ConfigurationDialog.java +++ b/src/net/pterodactylus/jsite/gui/ConfigurationDialog.java @@ -43,6 +43,12 @@ public class ConfigurationDialog extends JDialog implements I18nable { /** The “cancel” action. */ private I18nAction cancelAction; + /** The “advanced mode” action. */ + private I18nAction advancedModeAction; + + /** The “advanced mode” checkbox. */ + private JCheckBox advancedModeCheckBox; + /** The “beautify GUI” action. */ private I18nAction antialiasAction; @@ -110,6 +116,27 @@ public class ConfigurationDialog extends JDialog implements I18nable { } /** + * Returns whether the advanced mode is selected. + * + * @return true if the advanced mode is selected, + * false otherwise + */ + public boolean isAdvancedMode() { + return advancedModeCheckBox.isSelected(); + } + + /** + * Sets whether the advanced mode is selected. + * + * @param advancedMode + * true if the advanced mode is selected, + * false otherwise + */ + public void setAdvancedMode(boolean advancedMode) { + advancedModeCheckBox.setSelected(advancedMode); + } + + /** * Returns whether the “beautify” checkbox has been selected. The result of * this method should not be used if {@link #wasCancelled()} returned * true! @@ -223,6 +250,15 @@ public class ConfigurationDialog extends JDialog implements I18nable { actionCancel(); } }; + advancedModeAction = new I18nAction("configurationDialog.page.interface.item.advancedMode") { + + /** + * {@inheritDoc} + */ + public void actionPerformed(ActionEvent e) { + /* do nothing. */ + } + }; antialiasAction = new I18nAction("configurationDialog.page.interfaceTweaks.item.antialias") { /** @@ -292,6 +328,12 @@ public class ConfigurationDialog extends JDialog implements I18nable { */ private JComponent createInterfaceConfig() { JPanel interfaceConfigPanel = new JPanel(new GridBagLayout()); + interfaceConfigPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); + + advancedModeCheckBox = new JCheckBox(advancedModeAction); + interfaceConfigPanel.add(advancedModeCheckBox, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + + interfaceConfigPanel.add(new JPanel(), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return interfaceConfigPanel; } diff --git a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java index f4c4822..0ae270c 100644 --- a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java +++ b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java @@ -107,6 +107,15 @@ public class ManageNodesDialog extends JDialog implements ListSelectionListener, // /** + * Expose the edit node dialog for the simple mode. + * + * @return The edit node dialog + */ + EditNodeDialog getEditNodeDialog() { + return editNodeDialog; + } + + /** * Returns the list of nodes. * * @return The list of nodes @@ -238,7 +247,7 @@ public class ManageNodesDialog extends JDialog implements ListSelectionListener, * Adds a new node via {@link #editNodeDialog}. */ private void addNode() { - editNodeDialog.setNodeName("New Node"); + editNodeDialog.setNodeName(I18n.get("general.newNode.name")); editNodeDialog.setNodeHostname("localhost"); editNodeDialog.setNodePort(9481); editNodeDialog.setVisible(true); diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index 2f6f965..b9eb177 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -105,6 +105,9 @@ public class SwingInterface implements CoreListener { // CONFIGURATION // + /** The advanced mode. */ + private boolean advancedMode; + /** Whether to antialias the GUI. */ private boolean antialias; @@ -302,6 +305,9 @@ public class SwingInterface implements CoreListener { } finally { Closer.close(configInputStream); } + if (configProperties.containsKey("advancedMode")) { + advancedMode = Boolean.valueOf(configProperties.getProperty("advancedMode")); + } if (configProperties.containsKey("antialias")) { antialias = Boolean.valueOf(configProperties.getProperty("antialias")); } @@ -333,6 +339,7 @@ public class SwingInterface implements CoreListener { } File configFile = new File(configDirectory, "swing-interface.properties"); Properties configProperties = new Properties(); + configProperties.setProperty("advancedMode", String.valueOf(advancedMode)); configProperties.setProperty("antialias", String.valueOf(antialias)); if (controlFont != null) { configProperties.setProperty("controlFont", controlFont); @@ -488,11 +495,16 @@ public class SwingInterface implements CoreListener { * Shows the configuration dialog. */ private void configure() { + configurationDialog.setAdvancedMode(advancedMode); configurationDialog.setAntialias(antialias); configurationDialog.setControlFont(controlFont); configurationDialog.setUserFont(userFont); configurationDialog.setVisible(true); if (!configurationDialog.wasCancelled()) { + 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(); @@ -519,9 +531,31 @@ 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. */ + } + } } /** diff --git a/src/net/pterodactylus/jsite/i18n/jSite.properties b/src/net/pterodactylus/jsite/i18n/jSite.properties index d94df12..a422f0a 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite.properties @@ -30,9 +30,15 @@ general.language.de.mnemonic: VK_G general.language.de.shortDescription: Switch language to German general.language.de.longDescription: Switch language to German +general.defaultNode.name: Default Node +general.newNode.name: New Node + # main window mainWindow.toolbar.name: jSite Toolbar +mainWindow.warning.multipleNodesNotAdvancedMode.title: Multiple Nodes in Simple Mode +mainWindow.warning.multipleNodesNotAdvancedMode.message: You have enabled the simple mode but have more than one node configured.
Select advanced mode to configure all of your nodes. + mainWindow.error.projectLoadingFailed.title: Loading Projects Failed mainWindow.error.projectLoadingFailed.message: Loading the projects from \u201c{0}\u201d has failed. @@ -219,6 +225,12 @@ configurationDialog.title: Configuration configurationDialog.page.interface.name: Interface +configurationDialog.page.interface.item.advancedMode.name: Advanced mode +configurationDialog.page.interface.item.advancedMode.mnemonic: VK_A +configurationDialog.page.interface.item.advancedMode.accelerator: Alt-VK_A +configurationDialog.page.interface.item.advancedMode.shortDescription: Activates advanced mode +configurationDialog.page.interface.item.advancedMode.longDescription: Activates advanced mode which allows multiple nodes to be configured + configurationDialog.page.interfaceTweaks.name: Interface Tweaks configurationDialog.page.interfaceTweaks.item.restartRequired.name: All items on this page require a restart to take effect! diff --git a/src/net/pterodactylus/jsite/i18n/jSite_de.properties b/src/net/pterodactylus/jsite/i18n/jSite_de.properties index 7a23f78..bdee581 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite_de.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite_de.properties @@ -30,9 +30,15 @@ general.language.de.mnemonic: VK_D general.language.de.shortDescription: Sprache auf deutsch umschalten general.language.de.longDescription: Sprache auf deutsch umschalten +general.defaultNode.name: Standardnode +general.newNode.name: Neuer Node + # main window mainWindow.toolbar.name: jSite Toolbar +mainWindow.warning.multipleNodesNotAdvancedMode.title: Mehrere Nodes im einfachen Modus +mainWindow.warning.multipleNodesNotAdvancedMode.message: Der einfache Modus wurde aktiviert, obwohl mehr als ein Node konfiguriert sind.
Bitte den erweitern Modus ausw\u00e4hlen, um alle Nodes zu konfigurieren. + mainWindow.error.projectLoadingFailed.title: Laden der Projekte fehlgeschlagen mainWindow.error.projectLoadingFailed.message: Die Projekte aus \u201e{0}\u201c konnten nicht geladen werden. @@ -219,6 +225,12 @@ configurationDialog.title: Einstellungen configurationDialog.page.interface.name: GUI +configurationDialog.page.interface.item.advancedMode.name: Erweiterter Modus +configurationDialog.page.interface.item.advancedMode.mnemonic: VK_E +configurationDialog.page.interface.item.advancedMode.accelerator: Alt-VK_E +configurationDialog.page.interface.item.advancedMode.shortDescription: Aktiviert den erweiterten Modus +configurationDialog.page.interface.item.advancedMode.longDescription: Aktiviert den erweiterten Modus, welcher mehrere Nodes erlaubt + configurationDialog.page.interfaceTweaks.name: GUI Tweaks configurationDialog.page.interfaceTweaks.item.restartRequired.name: Alle Einstellungen auf dieser Seite erfordern einen Neustart, um wirksam zu werden!