Added new lists for viewing and selecting Artists and Stages
This commit is contained in:
@@ -42,6 +42,14 @@ public class Agenda implements Serializable {
|
|||||||
{
|
{
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
public ArrayList<Artist> getArtists()
|
||||||
|
{
|
||||||
|
return artists;
|
||||||
|
}
|
||||||
|
public ArrayList<Stage> getStages()
|
||||||
|
{
|
||||||
|
return stages;
|
||||||
|
}
|
||||||
|
|
||||||
public void saveAgenda()
|
public void saveAgenda()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,4 +79,9 @@ public class Artist implements Serializable{
|
|||||||
{
|
{
|
||||||
this.background = background;
|
this.background = background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import javax.swing.AbstractListModel;
|
||||||
|
|
||||||
|
|
||||||
|
public class ContentList extends AbstractListModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 9110016552017561529L;
|
||||||
|
|
||||||
|
Object[] data;
|
||||||
|
|
||||||
|
public ContentList(Object[] data)
|
||||||
|
{
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int arg0) {
|
||||||
|
return data[arg0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return data.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.AbstractListModel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
public class PanelArtSta extends JPanel implements Panel{
|
||||||
|
|
||||||
|
private Agenda a;
|
||||||
|
JList artists;
|
||||||
|
JList stages;
|
||||||
|
Object[] dataArtist;
|
||||||
|
Object[] dataStage;
|
||||||
|
|
||||||
|
public PanelArtSta(Window w)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
a = w.getAgenda();
|
||||||
|
|
||||||
|
artists = new JList();
|
||||||
|
artists.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||||
|
artists.setLayoutOrientation(JList.VERTICAL_WRAP);
|
||||||
|
artists.setVisibleRowCount(-1);
|
||||||
|
artists.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
if (e.getValueIsAdjusting() == false) {
|
||||||
|
|
||||||
|
if (artists.getSelectedIndex() == -1) {
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Artist Selected: " + a.getArtists().get(artists.getSelectedIndex()));
|
||||||
|
artists.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JScrollPane artistScroller = new JScrollPane(artists);
|
||||||
|
artistScroller.setPreferredSize(new Dimension(250, 80));
|
||||||
|
|
||||||
|
stages = new JList();
|
||||||
|
stages.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||||
|
stages.setLayoutOrientation(JList.VERTICAL_WRAP);
|
||||||
|
stages.setVisibleRowCount(-1);
|
||||||
|
stages.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
if (e.getValueIsAdjusting() == false) {
|
||||||
|
|
||||||
|
if (stages.getSelectedIndex() == -1) {
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Stage Selected: " + a.getStages().get(stages.getSelectedIndex()));
|
||||||
|
stages.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JScrollPane stageScroller = new JScrollPane(stages);
|
||||||
|
stageScroller.setPreferredSize(new Dimension(250, 80));
|
||||||
|
|
||||||
|
add(artistScroller);
|
||||||
|
add(stageScroller);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void compileData()
|
||||||
|
{
|
||||||
|
int artists = a.getArtists().size();
|
||||||
|
int stages = a.getStages().size();
|
||||||
|
dataArtist = new Object[artists];
|
||||||
|
dataStage = new Object[stages];
|
||||||
|
|
||||||
|
for(int i = 0; i < artists; i++)
|
||||||
|
{
|
||||||
|
dataArtist[i] = a.getArtists().get(i);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < stages; i++)
|
||||||
|
{
|
||||||
|
dataStage[i] = a.getStages().get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
public void update(ArrayList<Event> event) {
|
||||||
|
compileData();
|
||||||
|
AbstractListModel artistsList = new ContentList(dataArtist);
|
||||||
|
AbstractListModel stagesList = new ContentList(dataStage);
|
||||||
|
artists.setModel(artistsList);
|
||||||
|
stages.setModel(stagesList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -32,4 +32,9 @@ public class Stage implements Serializable {
|
|||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -72,6 +72,9 @@ public class Window extends JFrame {
|
|||||||
Panel tablePanel = new PanelTable();
|
Panel tablePanel = new PanelTable();
|
||||||
panels.put("table", tablePanel);
|
panels.put("table", tablePanel);
|
||||||
|
|
||||||
|
Panel art_staPanel = new PanelArtSta(this);
|
||||||
|
panels.put("art_sta", art_staPanel);
|
||||||
|
|
||||||
//Main Panels
|
//Main Panels
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
centerPanel = new JPanel(new BorderLayout());
|
centerPanel = new JPanel(new BorderLayout());
|
||||||
@@ -170,15 +173,13 @@ public class Window extends JFrame {
|
|||||||
|
|
||||||
private static void changePanel()
|
private static void changePanel()
|
||||||
{
|
{
|
||||||
if(centerPanel.getComponents().length > 0)
|
centerPanel.removeAll();
|
||||||
{
|
|
||||||
centerPanel.remove(0);
|
|
||||||
}
|
|
||||||
Panel p = panels.get(currentPanel);
|
Panel p = panels.get(currentPanel);
|
||||||
p.update(getEvents());
|
p.update(getEvents());
|
||||||
JPanel p1 = (JPanel) p;
|
JPanel p1 = (JPanel) p;
|
||||||
p1.setPreferredSize(centerPanel.getSize());
|
p1.setPreferredSize(centerPanel.getSize());
|
||||||
centerPanel.add(p1, BorderLayout.CENTER);
|
centerPanel.add(p1, BorderLayout.CENTER);
|
||||||
|
centerPanel.revalidate();
|
||||||
centerPanel.repaint();
|
centerPanel.repaint();
|
||||||
p1.repaint();
|
p1.repaint();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user