From f01867ca12edbb3fd6a34ebc3572cdde9a1f280c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Nov 2008 01:33:34 +0100 Subject: [PATCH] =?utf8?q?Create=20=E2=80=9CInsert=20Project=E2=80=9D=20ac?= =?utf8?q?tion=20on=20project=20creation.=20Let=20the=20user=20select=20a?= =?utf8?q?=20node=20on=20project=20insert=20if=20the=20project=20does=20no?= =?utf8?q?t=20contain=20a=20default=20node.=20Add=20English=20and=20German?= =?utf8?q?=20texts=20for=20node=20selection=20dialog=20and=20=E2=80=9CInse?= =?utf8?q?rt=20Project=E2=80=9D=20button.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../pterodactylus/jsite/gui/SwingInterface.java | 36 ++++++++++++++++++++++ src/net/pterodactylus/jsite/i18n/jSite.properties | 12 ++++++++ .../pterodactylus/jsite/i18n/jSite_de.properties | 12 ++++++++ 3 files changed, 60 insertions(+) diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index f8a43d0..3f2b8b4 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -41,6 +41,8 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -786,6 +788,30 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh } /** + * Inserts the given project. + * + * @param project + * The project to insert + */ + private void insertProject(Project project) { + Node targetNode = project.getNode(); + if (targetNode == null) { + JComboBox nodeComboBox = new JComboBox(); + for (Node node : nodeList) { + ((DefaultComboBoxModel) nodeComboBox.getModel()).addElement(node.getName() + " (" + node.getHostname() + ":" + node.getPort() + ")"); + } + int selectedOption = JOptionPane.showConfirmDialog(mainWindow, new Object[] { I18n.get("nodeSelectionDialog.selectNode.text"), nodeComboBox }, I18n.get("nodeSelectionDialog.noNodeSelected.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (selectedOption == JOptionPane.CANCEL_OPTION) { + return; + } + int selectedNodeIndex = nodeComboBox.getSelectedIndex(); + logger.log(Level.FINE, "selected node index: " + selectedNodeIndex); + targetNode = nodeList.get(selectedNodeIndex); + } + logger.log(Level.INFO, "Inserting project “" + project.getName() + "” to node “" + targetNode.getName() + "”..."); + } + + /** * Clones a project. * * @param project @@ -858,6 +884,16 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh * @param switchToProject */ private void projectAdded(final Project project, boolean switchToProject) { + insertProjectActions.put(project, new I18nAction("mainWindow.button.insertProject") { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("synthetic-access") + public void actionPerformed(ActionEvent actionEvent) { + insertProject(project); + } + }); cloneProjectActions.put(project, new I18nAction("mainWindow.button.cloneProject") { /** diff --git a/src/net/pterodactylus/jsite/i18n/jSite.properties b/src/net/pterodactylus/jsite/i18n/jSite.properties index 2cfa7c1..5dbe911 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite.properties @@ -170,6 +170,12 @@ mainWindow.button.addProject.accelerator: Ctrl-VK_A mainWindow.button.addProject.shortDescription: Add a project mainWindow.button.addProject.longDescription: Adds a project +mainWindow.button.insertProject.name: Insert Project +mainWindow.button.insertProject.mnemonic: VK_I +mainWindow.button.insertProject.accelerator: Ctrl-VK_I +mainWindow.button.insertProject.shortDescription: Inserts the selected project +mainWindow.button.insertProject.longDescription: Inserts the selected project + mainWindow.button.cloneProject.name: Clone Project mainWindow.button.cloneProject.mnemonic: VK_L mainWindow.button.cloneProject.accelerator: Ctrl-VK_L @@ -432,3 +438,9 @@ fileManager.dialog.mimeTypeOverride.message: Please choose an override MIME type fileManager.dialog.removeOverride.title: Remove Override? fileManager.dialog.removeOverride.message: You are about to remove the override for the {0} selected file{0,choice,0#s|1#|2#s}. + +# +# the node selection dialog +# +nodeSelectionDialog.noNodeSelected.text: No node selected +nodeSelectionDialog.selectNode.text: Please select a node. diff --git a/src/net/pterodactylus/jsite/i18n/jSite_de.properties b/src/net/pterodactylus/jsite/i18n/jSite_de.properties index c483ebc..61c2d68 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite_de.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite_de.properties @@ -170,6 +170,12 @@ mainWindow.button.addProject.accelerator: Ctrl-VK_N mainWindow.button.addProject.shortDescription: Erstellt ein neues Projekt mainWindow.button.addProject.longDescription: Erstellt ein neues Projekt +mainWindow.button.insertProject.name: Projekt hoch laden +mainWindow.button.insertProject.mnemonic: VK_H +mainWindow.button.insertProject.accelerator: Ctrl-VK_H +mainWindow.button.insertProject.shortDescription: L\u00e4dt das angezeigte Projekt hoch +mainWindow.button.insertProject.longDescription: L\u00e4dt das angezeigte Projekt hoch + mainWindow.button.cloneProject.name: Projekt klonen mainWindow.button.cloneProject.mnemonic: VK_K mainWindow.button.cloneProject.accelerator: Ctrl-VK_K @@ -432,3 +438,9 @@ fileManager.dialog.mimeTypeOverride.message: Bitte einen MIME-Typ zum \u00dcbers fileManager.dialog.removeOverride.title: \u00dcberschreibungen entfernen? fileManager.dialog.removeOverride.message: Die \u00dcberschreibungen f\u00fcr {0} Datei{0,choice,0#en|1#|2#en} werden entfernt. + +# +# the node selection dialog +# +nodeSelectionDialog.noNodeSelected.text: Kein Node ausgew\u00e4hlt +nodeSelectionDialog.selectNode.text: Bitte einen Node ausw\u00e4hlen. -- 2.7.4