GUI now uses generated code rather than binary files.

This commit is contained in:
neviyn 2016-02-24 20:06:30 +00:00
parent 4414e0b51c
commit 69c9e442fb
3 changed files with 185 additions and 20 deletions

38
pom.xml
View File

@ -23,6 +23,39 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>musicplayer.PlayerGUI</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
@ -47,6 +80,11 @@
<artifactId>gstreamer-java</artifactId> <artifactId>gstreamer-java</artifactId>
<version>1.5</version> <version>1.5</version>
</dependency> </dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>forms_rt</artifactId>
<version>7.0.3</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="musicplayer.PlayerGUI"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="musicplayer.PlayerGUI">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="mainPanel" layout-manager="GridBagLayout">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<xy x="20" y="20" width="537" height="400"/> <xy x="20" y="20" width="537" height="400"/>
</constraints> </constraints>
@ -13,6 +12,7 @@
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"> <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="760" height="500"/> <preferred-size width="760" height="500"/>
</grid> </grid>
<gridbag weightx="1.0" weighty="1.0"/>
</constraints> </constraints>
<properties> <properties>
<dividerLocation value="240"/> <dividerLocation value="240"/>
@ -68,6 +68,7 @@
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"> <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/> <preferred-size width="-1" height="20"/>
</grid> </grid>
<gridbag weightx="1.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<floatable value="false"/> <floatable value="false"/>
@ -126,12 +127,14 @@
<component id="e1626" class="javax.swing.JMenuBar" binding="menuBar"> <component id="e1626" class="javax.swing.JMenuBar" binding="menuBar">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="0.0"/>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<component id="98c55" class="javax.swing.JSlider" binding="seekBar"> <component id="98c55" class="javax.swing.JSlider" binding="seekBar">
<constraints> <constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/> <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<inverted value="false"/> <inverted value="false"/>

View File

@ -1,5 +1,7 @@
package musicplayer; package musicplayer;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import musicplayer.callbacks.LibraryCallbackInterface; import musicplayer.callbacks.LibraryCallbackInterface;
import musicplayer.callbacks.PlayerCallbackInterface; import musicplayer.callbacks.PlayerCallbackInterface;
import musicplayer.db.DatabaseManager; import musicplayer.db.DatabaseManager;
@ -11,8 +13,10 @@ import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.List;
public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterface { public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterface {
private JTree libraryView; private JTree libraryView;
@ -94,6 +98,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Set the value of seekBar. * Set the value of seekBar.
*
* @param position New seekBar value. * @param position New seekBar value.
*/ */
public void setSeekBarPosition(int position) { public void setSeekBarPosition(int position) {
@ -109,6 +114,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Populate the library with songs grouped by album. * Populate the library with songs grouped by album.
*
* @param libraryData Map of albums with a lists of associated songs. * @param libraryData Map of albums with a lists of associated songs.
*/ */
private void populateLibrary(Map<Album, List<Song>> libraryData) { private void populateLibrary(Map<Album, List<Song>> libraryData) {
@ -125,6 +131,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Populate the library with all songs. * Populate the library with all songs.
*
* @param libraryData List of songs. * @param libraryData List of songs.
*/ */
private void populateLibrary(List<Song> libraryData) { private void populateLibrary(List<Song> libraryData) {
@ -137,6 +144,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Add an item to libraryView. * Add an item to libraryView.
*
* @param parentNode Node that should be the parent of this node. * @param parentNode Node that should be the parent of this node.
* @param node This node. * @param node This node.
*/ */
@ -149,6 +157,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Add a song to the current playlist. * Add a song to the current playlist.
*
* @param song Song to be added to the playlist. * @param song Song to be added to the playlist.
*/ */
private void addToPlaylist(Song song) { private void addToPlaylist(Song song) {
@ -158,6 +167,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Get the next song in the playlist. * Get the next song in the playlist.
*
* @param currentSong The song that is currently selected. * @param currentSong The song that is currently selected.
* @return The next song to be selected. * @return The next song to be selected.
*/ */
@ -168,6 +178,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Set the highlighted song in the playlist to this song. * Set the highlighted song in the playlist to this song.
*
* @param playingSong Song to be highlighted in the playlist. * @param playingSong Song to be highlighted in the playlist.
*/ */
@Override @Override
@ -186,6 +197,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
/** /**
* Set the maximum value of the seekBar. * Set the maximum value of the seekBar.
*
* @param seconds New length of seekBar. * @param seconds New length of seekBar.
*/ */
public void setSeekBarDuration(int seconds) { public void setSeekBarDuration(int seconds) {
@ -215,6 +227,116 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
populateLibrary(new TreeMap<>(Gateway.listAllSongsGroupedByAlbum().get())); populateLibrary(new TreeMap<>(Gateway.listAllSongsGroupedByAlbum().get()));
} }
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
final JSplitPane splitPane1 = new JSplitPane();
splitPane1.setDividerLocation(240);
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(splitPane1, gbc);
playlistScroll = new JScrollPane();
splitPane1.setRightComponent(playlistScroll);
playList = new JTable();
playList.setRowSelectionAllowed(true);
playlistScroll.setViewportView(playList);
final JPanel panel1 = new JPanel();
panel1.setLayout(new BorderLayout(0, 0));
splitPane1.setLeftComponent(panel1);
libraryDisplayType = new JComboBox();
panel1.add(libraryDisplayType, BorderLayout.NORTH);
final JScrollPane scrollPane1 = new JScrollPane();
panel1.add(scrollPane1, BorderLayout.CENTER);
libraryView = new JTree();
libraryView.setRootVisible(true);
libraryView.setShowsRootHandles(false);
scrollPane1.setViewportView(libraryView);
final JToolBar toolBar1 = new JToolBar();
toolBar1.setFloatable(false);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainPanel.add(toolBar1, gbc);
playButton = new JButton();
playButton.setLabel("Play");
playButton.setText("Play");
playButton.setMnemonic('P');
playButton.setDisplayedMnemonicIndex(0);
toolBar1.add(playButton);
stopButton = new JButton();
stopButton.setLabel("Stop");
stopButton.setText("Stop");
stopButton.setMnemonic('S');
stopButton.setDisplayedMnemonicIndex(0);
toolBar1.add(stopButton);
nextButton = new JButton();
nextButton.setText("Next");
nextButton.setMnemonic('N');
nextButton.setDisplayedMnemonicIndex(0);
toolBar1.add(nextButton);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
toolBar1.add(panel2);
volumeSlider = new JSlider();
volumeSlider.setMajorTickSpacing(20);
volumeSlider.setMinorTickSpacing(10);
volumeSlider.setPaintTicks(true);
volumeSlider.setValue(100);
panel2.add(volumeSlider, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
volumeValue = new JLabel();
volumeValue.setText("100%");
panel2.add(volumeValue, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
menuBar = new JMenuBar();
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(menuBar, gbc);
seekBar = new JSlider();
seekBar.setInverted(false);
seekBar.setMinorTickSpacing(1);
seekBar.setPaintTicks(false);
seekBar.setSnapToTicks(false);
seekBar.setValue(0);
seekBar.setValueIsAdjusting(false);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainPanel.add(seekBar, gbc);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return mainPanel;
}
private class libraryMouseAdapter extends MouseAdapter { private class libraryMouseAdapter extends MouseAdapter {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
@ -232,7 +354,8 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
} }
} }
} }
} catch (NullPointerException ignored) {} } catch (NullPointerException ignored) {
}
} }
} }
@ -287,4 +410,5 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
volumeValue.setText(String.format("%d%%", value)); volumeValue.setText(String.format("%d%%", value));
} }
} }