summaryrefslogtreecommitdiff
path: root/cmpcj/src/de/schwarzrot/control/support
diff options
context:
space:
mode:
Diffstat (limited to 'cmpcj/src/de/schwarzrot/control/support')
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/GenreSelector.java46
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/MediaList2TypeList.java61
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/MediaTextFilterator.java41
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/MediaTypeSelector.java157
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/MediatypeMatcher.java55
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/SelectedMedia.java85
-rw-r--r--cmpcj/src/de/schwarzrot/control/support/TreeSelectionFilter.java59
7 files changed, 504 insertions, 0 deletions
diff --git a/cmpcj/src/de/schwarzrot/control/support/GenreSelector.java b/cmpcj/src/de/schwarzrot/control/support/GenreSelector.java
new file mode 100644
index 0000000..9566ae8
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/GenreSelector.java
@@ -0,0 +1,46 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: GenreSelector.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import ca.odell.glazedlists.matchers.Matcher;
+import de.schwarzrot.media.domain.Genre;
+import de.schwarzrot.media.domain.Media;
+
+
+public class GenreSelector implements Matcher<Media> {
+ public GenreSelector(Genre genre) {
+ g = genre;
+ }
+
+
+ @Override
+ public boolean matches(Media m) {
+ return m.getRealPath().getAbsolutePath().startsWith(g.getRealPath().getAbsolutePath());
+ }
+
+ private Genre g;
+} \ No newline at end of file
diff --git a/cmpcj/src/de/schwarzrot/control/support/MediaList2TypeList.java b/cmpcj/src/de/schwarzrot/control/support/MediaList2TypeList.java
new file mode 100644
index 0000000..8445db8
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/MediaList2TypeList.java
@@ -0,0 +1,61 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: MediaList2TypeList.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.TransformedList;
+import ca.odell.glazedlists.event.ListEvent;
+import de.schwarzrot.media.domain.AbstractMediaNode;
+import de.schwarzrot.media.domain.Media;
+
+
+public class MediaList2TypeList extends TransformedList<Media, AbstractMediaNode.SupportedMediaType> {
+ public MediaList2TypeList(EventList<Media> source) {
+ super(source);
+ source.addListEventListener(this);
+ }
+
+
+ @Override
+ public Media.SupportedMediaType get(int index) {
+ Media m = source.get(index);
+
+ return m.getType();
+ }
+
+
+ @Override
+ public void listChanged(ListEvent<Media> listChanges) {
+ updates.forwardEvent(listChanges);
+ }
+
+
+ @Override
+ protected boolean isWritable() {
+ return false;
+ }
+}
diff --git a/cmpcj/src/de/schwarzrot/control/support/MediaTextFilterator.java b/cmpcj/src/de/schwarzrot/control/support/MediaTextFilterator.java
new file mode 100644
index 0000000..b36f582
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/MediaTextFilterator.java
@@ -0,0 +1,41 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: MediaTextFilterator.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import java.util.List;
+import ca.odell.glazedlists.TextFilterator;
+import de.schwarzrot.media.domain.Media;
+
+
+public class MediaTextFilterator implements TextFilterator<Media> {
+ @Override
+ public void getFilterStrings(List<String> baseList, Media m) {
+ baseList.add(m.getName());
+ baseList.add(m.getRealPath().getAbsolutePath());
+ baseList.add(m.getSearch());
+ }
+}
diff --git a/cmpcj/src/de/schwarzrot/control/support/MediaTypeSelector.java b/cmpcj/src/de/schwarzrot/control/support/MediaTypeSelector.java
new file mode 100644
index 0000000..f60ddc4
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/MediaTypeSelector.java
@@ -0,0 +1,157 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: MediaTypeSelector.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListCellRenderer;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.UniqueList;
+import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
+import ca.odell.glazedlists.matchers.Matcher;
+import ca.odell.glazedlists.swing.DefaultEventListModel;
+import ca.odell.glazedlists.swing.DefaultEventSelectionModel;
+import de.schwarzrot.base.util.ApplicationServiceProvider;
+import de.schwarzrot.base.util.ImageFactory;
+import de.schwarzrot.media.domain.Media;
+
+
+public class MediaTypeSelector extends AbstractMatcherEditor<Media> implements ListSelectionListener {
+ public class MediaTypeCellRenderer extends JLabel implements ListCellRenderer {
+ private static final long serialVersionUID = 713L;
+
+
+ public MediaTypeCellRenderer() {
+ loadImages();
+ }
+
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
+ boolean cellHasFocus) {
+ ImageIcon icon = null;
+
+ if (isSelected) {
+ setBackground(list.getSelectionBackground());
+ setForeground(list.getSelectionForeground());
+ icon = selImages[((Media.SupportedMediaType) value).ordinal()];
+ } else {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ icon = stdImages[((Media.SupportedMediaType) value).ordinal()];
+ }
+ setSize(110, 110);
+ setHorizontalAlignment(JLabel.CENTER);
+
+ if (icon != null) {
+ setIcon(icon);
+ setText("");
+ } else {
+ setText(value.toString());
+ }
+ return this;
+ }
+
+
+ protected void loadImages() {
+ ImageFactory imgFak = ApplicationServiceProvider.getService(ImageFactory.class);
+ int i = 0;
+
+ stdImages = new ImageIcon[Media.SupportedMediaType.values().length];
+ for (Media.SupportedMediaType smt : Media.SupportedMediaType.values()) {
+ StringBuilder sb = new StringBuilder(smt.getClass().getSimpleName());
+
+ sb.append(".").append(smt.name()).append(".default");
+ stdImages[i++] = imgFak.getIcon(sb.toString(), 110, 110);
+ }
+
+ i = 0;
+ selImages = new ImageIcon[Media.SupportedMediaType.values().length];
+ for (Media.SupportedMediaType smt : Media.SupportedMediaType.values()) {
+ StringBuilder sb = new StringBuilder(smt.getClass().getSimpleName());
+
+ sb.append(".").append(smt.name()).append(".active");
+ selImages[i++] = imgFak.getIcon(sb.toString(), 110, 110);
+ }
+ }
+
+ ImageIcon[] stdImages;
+ ImageIcon[] selImages;
+ }
+
+
+ public MediaTypeSelector(EventList<Media> source) {
+ EventList<Media.SupportedMediaType> mediaTypeNonUnique = new MediaList2TypeList(source);
+
+ mediaTypeList = new UniqueList<Media.SupportedMediaType>(mediaTypeNonUnique);
+ DefaultEventListModel<Media.SupportedMediaType> mediaTypeListModel = new DefaultEventListModel<Media.SupportedMediaType>(
+ mediaTypeList);
+
+ mediaTypeJList = new JList(mediaTypeListModel);
+ DefaultEventSelectionModel<Media.SupportedMediaType> mediaTypeSelectionModel = new DefaultEventSelectionModel<Media.SupportedMediaType>(
+ mediaTypeList);
+
+ mediaTypeJList.setSelectionModel(mediaTypeSelectionModel);
+ selectedTypes = mediaTypeSelectionModel.getSelected();
+ mediaTypeJList.addListSelectionListener(this);
+ mediaTypeJList.setCellRenderer(new MediaTypeCellRenderer());
+ mediaTypeJList.setBackground(Color.BLACK);
+ mediaTypeJList.setMinimumSize(new Dimension(100, 100));
+ mediaTypeComponent = new JScrollPane(mediaTypeJList);
+ }
+
+
+ public JComponent getComponent() {
+ return mediaTypeComponent;
+ }
+
+
+ public JList getJList() {
+ return mediaTypeJList;
+ }
+
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ Matcher<Media> newMatcher = new MediatypeMatcher(selectedTypes);
+
+ fireChanged(newMatcher);
+ }
+
+ private EventList<Media.SupportedMediaType> mediaTypeList;
+ private EventList<Media.SupportedMediaType> selectedTypes;
+ private JList mediaTypeJList;
+ private JScrollPane mediaTypeComponent;
+}
diff --git a/cmpcj/src/de/schwarzrot/control/support/MediatypeMatcher.java b/cmpcj/src/de/schwarzrot/control/support/MediatypeMatcher.java
new file mode 100644
index 0000000..a01b43a
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/MediatypeMatcher.java
@@ -0,0 +1,55 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: MediatypeMatcher.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import ca.odell.glazedlists.matchers.Matcher;
+import de.schwarzrot.media.domain.AbstractMediaNode;
+import de.schwarzrot.media.domain.Media;
+
+
+public class MediatypeMatcher implements Matcher<Media> {
+ public MediatypeMatcher(Collection<AbstractMediaNode.SupportedMediaType> mediaTypes) {
+ this.mediaTypes.addAll(mediaTypes);
+ }
+
+
+ @Override
+ public boolean matches(Media m) {
+ if (m == null)
+ return false;
+ if (mediaTypes.isEmpty())
+ return true;
+ Media.SupportedMediaType mt = m.getType();
+
+ return mediaTypes.contains(mt);
+ }
+
+ private Set<AbstractMediaNode.SupportedMediaType> mediaTypes = new HashSet<Media.SupportedMediaType>();
+}
diff --git a/cmpcj/src/de/schwarzrot/control/support/SelectedMedia.java b/cmpcj/src/de/schwarzrot/control/support/SelectedMedia.java
new file mode 100644
index 0000000..efde378
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/SelectedMedia.java
@@ -0,0 +1,85 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: SelectedMedia.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.swing.DefaultEventSelectionModel;
+import de.schwarzrot.media.domain.Media;
+
+
+public class SelectedMedia implements ListSelectionListener {
+ public static final String MEDIA_PROPERTY = "media";
+
+
+ public SelectedMedia(EventList<Media> source) {
+ pcs = new PropertyChangeSupport(this);
+ mediaList = source;
+ }
+
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+
+ public void clear() {
+ pcs.firePropertyChange(MEDIA_PROPERTY, this.media, this.media = null);
+ }
+
+
+ public Media getMedia() {
+ return media;
+ }
+
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ if (e.getValueIsAdjusting())
+ return;
+ if (e.getSource() instanceof DefaultEventSelectionModel) {
+ @SuppressWarnings("unchecked")
+ DefaultEventSelectionModel<Media> sm = (DefaultEventSelectionModel<Media>) e.getSource();
+
+ if (sm.isSelectionEmpty())
+ return;
+ pcs.firePropertyChange(MEDIA_PROPERTY, this.media, this.media = mediaList.get(sm.getLeadSelectionIndex()));
+ }
+ }
+
+ private Media media;
+ private PropertyChangeSupport pcs;
+ private EventList<Media> mediaList;
+}
diff --git a/cmpcj/src/de/schwarzrot/control/support/TreeSelectionFilter.java b/cmpcj/src/de/schwarzrot/control/support/TreeSelectionFilter.java
new file mode 100644
index 0000000..99d1646
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/control/support/TreeSelectionFilter.java
@@ -0,0 +1,59 @@
+/**
+ * ======================== legal notice ======================
+ *
+ * File: TreeSelectionFilter.java
+ * Created: 13. June 2012, 04:57
+ * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
+ * Project: cmpc - a java frontend (client) part of compound media player
+ * uses external players to play the media
+ *
+ * CMP - compound media player
+ *
+ * is a client/server mediaplayer intended to play any media from any workstation
+ * without the need to export or mount shares. cmps is an easy to use backend
+ * with a (ready to use) HTML-interface. Additionally the backend supports
+ * authentication via HTTP-digest authorization.
+ * cmpc is a client with vdr-like osd-menues.
+ *
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
+ * published under Creative Commons by-sa
+ * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ *
+ * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ *
+ * --------------------------------------------------------------
+ */
+package de.schwarzrot.control.support;
+
+
+import javax.swing.JTree;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
+import ca.odell.glazedlists.matchers.Matcher;
+import de.schwarzrot.media.domain.Genre;
+import de.schwarzrot.media.domain.Media;
+
+
+public class TreeSelectionFilter extends AbstractMatcherEditor<Media> implements TreeSelectionListener {
+ public TreeSelectionFilter(JTree tree) {
+ this.tree = tree;
+ tree.addTreeSelectionListener(this);
+ }
+
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+
+ if (node == null)
+ return;
+ Genre g = (Genre) node.getUserObject();
+ Matcher<Media> newMatcher = new GenreSelector(g);
+
+ fireChanged(newMatcher);
+ }
+
+ private JTree tree;
+}