From: David ‘Bombe’ Roden Date: Thu, 13 Nov 2008 00:33:34 +0000 (+0100) Subject: Create “Insert Project” action on project creation. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f01867ca12edbb3fd6a34ebc3572cdde9a1f280c;p=jSite2.git Create “Insert Project” action on project creation. Let the user select a node on project insert if the project does not contain a default node. Add English and German texts for node selection dialog and “Insert Project” button. --- 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.