From fe5b2a54efe233f24dc6b00e42ce2d11c813f9f4 Mon Sep 17 00:00:00 2001 From: Zino Holwerda Date: Sat, 15 Jul 2017 17:04:59 +0200 Subject: [PATCH] Added playlist popup window but no functionality yet. --- src/main/java/handiebot/HandieBot.java | 8 +-- .../interfaceActions/PlaylistAction.java | 61 +++++++++++++++++++ .../PlaylistActions/DeletePlaylistAction.java | 8 +++ .../PlaylistActions/EditPlaylistAction.java | 8 +++ .../PlaylistActions/NewPlaylistAction.java | 8 +++ .../command/commands/package-info.java | 2 +- src/main/java/handiebot/view/BotWindow.java | 11 ++-- src/main/java/handiebot/view/MenuBar.java | 18 ++++-- src/main/resources/Strings.properties | 21 +++++-- src/main/resources/Strings_nl.properties | 35 ++++++----- 10 files changed, 145 insertions(+), 35 deletions(-) create mode 100644 src/main/java/handiebot/command/commands/interfaceActions/PlaylistAction.java create mode 100644 src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/DeletePlaylistAction.java create mode 100644 src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/EditPlaylistAction.java create mode 100644 src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/NewPlaylistAction.java diff --git a/src/main/java/handiebot/HandieBot.java b/src/main/java/handiebot/HandieBot.java index 5f6a57f..ebc1448 100644 --- a/src/main/java/handiebot/HandieBot.java +++ b/src/main/java/handiebot/HandieBot.java @@ -108,10 +108,10 @@ public class HandieBot { log = new BotLog(window.getOutputArea()); } - //log.log(BotLog.TYPE.INFO, resourceBundle.getString("log.loggingIn")); - //client = new ClientBuilder().withToken(TOKEN).build(); - //client.getDispatcher().registerListener(new HandieBot()); - //client.login(); + log.log(BotLog.TYPE.INFO, resourceBundle.getString("log.loggingIn")); + client = new ClientBuilder().withToken(TOKEN).build(); + client.getDispatcher().registerListener(new HandieBot()); + client.login(); } /** diff --git a/src/main/java/handiebot/command/commands/interfaceActions/PlaylistAction.java b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistAction.java new file mode 100644 index 0000000..c22bd53 --- /dev/null +++ b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistAction.java @@ -0,0 +1,61 @@ +package handiebot.command.commands.interfaceActions; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; + +import static handiebot.HandieBot.resourceBundle; + +/** + * Author: Zino Holwerda + * Date: 7/14/2017. + */ +public class PlaylistAction extends AbstractAction { + + private static final String DEFAULT_SOURCE_CHOICE_LABEL = "Available Playlists"; + + public PlaylistAction() { + super(resourceBundle.getString("action.menu.playlist")); + } + + @Override + public void actionPerformed(ActionEvent e) { + JFrame editPlaylist = new JFrame(resourceBundle.getString("action.menu.playlist")); + editPlaylist.setLayout(new BorderLayout(5,5)); + + JPanel topSide = new JPanel(new FlowLayout()); + + JPanel leftSide = new JPanel(new BorderLayout(5,5)); + JLabel sourceLabel = new JLabel(DEFAULT_SOURCE_CHOICE_LABEL); + JList playlistList = new JList<>(); + leftSide.add(sourceLabel, BorderLayout.NORTH); + JScrollPane scrollPane = new JScrollPane(playlistList); + scrollPane.setPreferredSize(new Dimension(200, 200)); + leftSide.add(scrollPane, BorderLayout.SOUTH); + topSide.add(leftSide); + + JPanel rightSide = new JPanel(new BorderLayout(5,5)); + JButton addButton = new JButton(resourceBundle.getString("action.menu.playlist.add")); + rightSide.add(addButton, BorderLayout.NORTH); + addButton.addActionListener(null); + JButton deleteButton = new JButton(resourceBundle.getString("action.menu.playlist.delete")); + rightSide.add(deleteButton, BorderLayout.AFTER_LINE_ENDS); + deleteButton.addActionListener(null); + JButton editButton = new JButton(resourceBundle.getString("action.menu.playlist.edit")); + rightSide.add(editButton, BorderLayout.AFTER_LAST_LINE); + editButton.addActionListener(null); + topSide.add(rightSide); + editPlaylist.add(topSide, BorderLayout.PAGE_START); + + JPanel bottomSide = new JPanel(); + bottomSide.add(new JScrollPane(playlistList)); + editPlaylist.add(bottomSide, BorderLayout.PAGE_END); + + editPlaylist.pack(); + editPlaylist.setLocationRelativeTo(null); + editPlaylist.setVisible(true); + + + + } +} diff --git a/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/DeletePlaylistAction.java b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/DeletePlaylistAction.java new file mode 100644 index 0000000..198802a --- /dev/null +++ b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/DeletePlaylistAction.java @@ -0,0 +1,8 @@ +package handiebot.command.commands.interfaceActions.PlaylistActions; + +/** + * Author: Zino + * Date: 7/14/2017. + */ +public class DeletePlaylistAction { +} diff --git a/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/EditPlaylistAction.java b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/EditPlaylistAction.java new file mode 100644 index 0000000..46904c2 --- /dev/null +++ b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/EditPlaylistAction.java @@ -0,0 +1,8 @@ +package handiebot.command.commands.interfaceActions.PlaylistActions; + +/** + * Author: Zino + * Date: 7/14/2017. + */ +public class EditPlaylistAction { +} diff --git a/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/NewPlaylistAction.java b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/NewPlaylistAction.java new file mode 100644 index 0000000..e977291 --- /dev/null +++ b/src/main/java/handiebot/command/commands/interfaceActions/PlaylistActions/NewPlaylistAction.java @@ -0,0 +1,8 @@ +package handiebot.command.commands.interfaceActions.PlaylistActions; + +/** + * Author: Zino + * Date: 7/14/2017. + */ +public class NewPlaylistAction { +} diff --git a/src/main/java/handiebot/command/commands/package-info.java b/src/main/java/handiebot/command/commands/package-info.java index 6d4d2e1..db387ff 100644 --- a/src/main/java/handiebot/command/commands/package-info.java +++ b/src/main/java/handiebot/command/commands/package-info.java @@ -1,5 +1,5 @@ /** - * @author Andrew Lalis + * @author Andrew Lalis & Zino Holwerda * Contains all Commands which can be executed from a Discord server or the Console. */ package handiebot.command.commands; \ No newline at end of file diff --git a/src/main/java/handiebot/view/BotWindow.java b/src/main/java/handiebot/view/BotWindow.java index 109b87c..4724a1b 100644 --- a/src/main/java/handiebot/view/BotWindow.java +++ b/src/main/java/handiebot/view/BotWindow.java @@ -33,7 +33,6 @@ public class BotWindow extends JFrame { public BotWindow(){ super(HandieBot.APPLICATION_NAME); //Setup GUI - //Output area. outputArea = new JTextPane(); outputArea.setBackground(Color.white); @@ -45,16 +44,17 @@ public class BotWindow extends JFrame { //Playlist shower JPanel playlistSub = new JPanel(new BorderLayout()); JTextPane textPane = new JTextPane(); + textPane.setEditable(false); JScrollPane playlist = new JScrollPane(textPane); - playlist.setPreferredSize(new Dimension(200, 200)); + playlist.setPreferredSize(new Dimension(250, 200)); playlistSub.add(playlist, BorderLayout.PAGE_END); - getContentPane().add(playlistSub, BorderLayout.EAST); //PlaylistList maker JList list = setPlayListListArea(textPane); JScrollPane playlistList = new JScrollPane(list); - playlistList.setPreferredSize(new Dimension(200, 1000)); + playlistList.setPreferredSize(new Dimension(250, 1000)); playlistSub.add(playlistList, BorderLayout.CENTER); + getContentPane().add(playlistSub, BorderLayout.EAST); //Command field. JTextField commandField = new JTextField(); @@ -82,10 +82,11 @@ public class BotWindow extends JFrame { } catch (IOException e) { e.printStackTrace(); } - setJMenuBar(new MenuBar()); + setJMenuBar(new MenuBar(this)); SelectionController controller = new SelectionController(); setPreferredSize(new Dimension(800, 600)); pack(); + setLocationRelativeTo(null); setVisible(true); } diff --git a/src/main/java/handiebot/view/MenuBar.java b/src/main/java/handiebot/view/MenuBar.java index a23ebbc..7cd1c05 100644 --- a/src/main/java/handiebot/view/MenuBar.java +++ b/src/main/java/handiebot/view/MenuBar.java @@ -1,6 +1,7 @@ package handiebot.view; import handiebot.command.Commands; +import handiebot.command.commands.interfaceActions.PlaylistAction; import handiebot.view.actions.ActionItem; import handiebot.view.actions.CommandAction; @@ -9,16 +10,23 @@ import javax.swing.*; import static handiebot.HandieBot.resourceBundle; /** - * @author Andrew Lalis + * @author Andrew Lalis & Zino Holwerda * Custom menu bar to be added to the console control panel. */ public class MenuBar extends JMenuBar { - public MenuBar(){ - JMenu fileMenu = new JMenu(resourceBundle.getString("menu.filemenu.title")); - fileMenu.add(new ActionItem(resourceBundle.getString("menu.filemenu.quit"), new CommandAction(Commands.get("quit")))); - this.add(fileMenu); + private BotWindow window; + private int language; + public MenuBar(BotWindow window){ + this.window = window; + JMenu fileMenu = new JMenu(resourceBundle.getString("menu.fileMenu.title")); + fileMenu.add(new ActionItem(resourceBundle.getString("menu.fileMenu.quit"), new CommandAction(Commands.get("quit")))); + fileMenu.add(new PlaylistAction()); + this.add(fileMenu); + JMenu viewMenu = new JMenu(resourceBundle.getString("menu.viewMenu.view")); + JMenu language = new JMenu(resourceBundle.getString("menu.viewMenu.language")); + this.add(viewMenu); } } diff --git a/src/main/resources/Strings.properties b/src/main/resources/Strings.properties index c864ee9..fbb662f 100644 --- a/src/main/resources/Strings.properties +++ b/src/main/resources/Strings.properties @@ -1,5 +1,8 @@ -#Strings for HandieBot: -# The following strings are organized in a way that it should be intuitive how it will be used. +#author: Andrew Lalis & Zino Holwerda +#INFO Strings for HandieBot: +#INFO The following strings are organized in a way that it should be intuitive how it will be used. +#INFO Language: English + #Log log.loggingIn=Logging client in... log.init=HandieBot initialized. @@ -11,8 +14,16 @@ log.newVoiceChannel=No voice channel found, creating a new one. window.close.question=Are you sure you want to exit and shutdown the bot? window.close.title=Confirm shutdown #MenuBar -menu.filemenu.title=File -menu.filemenu.quit=Quit +menu.fileMenu.title=File +menu.fileMenu.quit=Quit +menu.editMenu.edit=Edit +menu.viewMenu.view=View +menu.viewMenu.language=Language +#Actions +action.menu.playlist=Edit playlists +action.menu.playlist.add=Add +action.menu.playlist.delete=Delete +action.menu.playlist.edit=Edit #Generic Command Messages commands.noPermission.message=You do not have permission to use the command `{0}`. commands.noPermission.log=User {0} does not have permission to execute {1} @@ -24,7 +35,7 @@ commands.command.setPrefix.loadedPrefixes=Loaded prefixes. commands.command.setPrefix.savedPrefixes=Saved prefixes. commands.command.help.description=Displays a list of commands and what they do. commands.command.info.description=Displays some common commands and information about the bot. -commands.command.info.embed.description=HandieBot is a Discord bot created by Andrew Lalis. It can play music, manage playlists, and provide other assistance to users. Some useful commands are shown below. +commands.command.info.embed.description=HandieBot is a Discord bot created by Andrew Lalis & Zino Holwerda. It can play music, manage playlists, and provide other assistance to users. Some useful commands are shown below. commands.command.info.embed.helpCommand=Receive a message with a detailed list of all commands and how to use them. commands.command.info.embed.playCommand=Play a song, or add it to the queue if one is already playing. A URL can be a YouTube or SoundCloud link. commands.command.info.embed.queueCommand=Show a list of songs that will soon be played. diff --git a/src/main/resources/Strings_nl.properties b/src/main/resources/Strings_nl.properties index c864ee9..b6d6aaa 100644 --- a/src/main/resources/Strings_nl.properties +++ b/src/main/resources/Strings_nl.properties @@ -1,22 +1,27 @@ -#Strings for HandieBot: -# The following strings are organized in a way that it should be intuitive how it will be used. +#author: Zino Holwerda +#INFO Strings for HandieBot: +#INFO The following strings are organized in a way that it should be intuitive how it will be used. +#INFO Language: Dutch + #Log -log.loggingIn=Logging client in... -log.init=HandieBot initialized. -log.shuttingDown=Shutting down the bot. -log.deleteMessageError=Unable to delete message. Please ensure that the bot has MANAGE_MESSAGES enabled, especially for this channel. -log.creatingChatChannel=No chat channel found, creating a new one. -log.newVoiceChannel=No voice channel found, creating a new one. +log.loggingIn=Bezig met inloggen van de client... +log.init=HandieBot geïnitialiseerd. +log.shuttingDown=Bezig met het afsluiten van de bot. +log.deleteMessageError=Niet mogelijk het bericht te vewijderen. Zorg er alstublieft voor dat de bot MANAGE_MESSAGES aan heeft, met name in dit kanaal. +log.creatingChatChannel=Geen chat gevonden. Bezig met het maken er van. +log.newVoiceChannel=Geen voice kanaal gevonden, Bezig met het maken er van. #Window -window.close.question=Are you sure you want to exit and shutdown the bot? -window.close.title=Confirm shutdown +window.close.question=Weet je zeker dat je de bot wil afsluiten? +window.close.title=Stopzetten Bevestigen. #MenuBar -menu.filemenu.title=File -menu.filemenu.quit=Quit +menu.fileMenu.title=Bestand +menu.fileMenu.quit=Verlaten +menu.fileMenu.edit=Bewerken +menu.fileMenu.view=Beeld #Generic Command Messages -commands.noPermission.message=You do not have permission to use the command `{0}`. -commands.noPermission.log=User {0} does not have permission to execute {1} -commands.noPermission.subcommand=You don't have permission to do that. +commands.noPermission.message=U hebt niet de toestemming om dit commando uit te voeren.`{0}`. +commands.noPermission.log=Gebruiker {0} heeft niet de toestemming voor het uitvoeren van {1} +commands.noPermission.subcommand=U hebt niet de toestemming om dat te doen. commands.invalidCommand.noContext=Invalid command issued: {0} commands.invalidCommand.context=Invalid command: {0} issued by: {1} #Messages for specific commands.