diff options
6 files changed, 32 insertions, 17 deletions
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java b/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java index e784924..2958121 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java +++ b/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java @@ -51,7 +51,7 @@ public class Media { } - public int getType() { + public SupportedMediaType getType() { return type; } @@ -72,11 +72,24 @@ public class Media { public void setType(int type) { - this.type = type; + if (type == SupportedMediaType.Audio.ordinal()) + this.type = SupportedMediaType.Audio; + else if (type == SupportedMediaType.Movie.ordinal()) + this.type = SupportedMediaType.Movie; + else if (type == SupportedMediaType.DVDImage.ordinal()) + this.type = SupportedMediaType.DVDImage; + else if (type == SupportedMediaType.LegacyVdrRecording.ordinal()) + this.type = SupportedMediaType.LegacyVdrRecording; + else if (type == SupportedMediaType.VdrRecording.ordinal()) + this.type = SupportedMediaType.VdrRecording; + else if (type == SupportedMediaType.Picture.ordinal()) + this.type = SupportedMediaType.Picture; + else + this.type = SupportedMediaType.Invalid; } private String name; - private int type; + private SupportedMediaType type; private String path; private String search; } diff --git a/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java b/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java index f51e635..9237106 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java +++ b/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java @@ -189,7 +189,7 @@ public class MediaClient extends JComponent implements MediaClientExecutor { }); mediaTypesScrollPane.setPreferredSize(new Dimension(100, 100)); mediaTypesScrollPane.setBackground(Color.BLACK); - mediaJTable.getColumnModel().getColumn(0).setMaxWidth(40); + mediaJTable.getColumnModel().getColumn(0).setMaxWidth(80); mediaJTable.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer()); mediaJTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer()); mediaJTable.addMouseListener(new MediaExecutor(mediaJTable, textFilteredMedia, this)); diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java index 8e9ce48..a719032 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java +++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java @@ -35,6 +35,6 @@ public class MediaComparator implements Comparator<Media> { public int compare(Media a, Media b) { if (a.getType() == b.getType()) return a.getName().compareToIgnoreCase(b.getName()); - return a.getType() - b.getType(); + return a.getType().ordinal() - b.getType().ordinal(); } } diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java index c3a3469..18820cf 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java +++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java @@ -34,7 +34,7 @@ import de.schwarzrot.cmpc.domain.Media; public class MediaForTypeMatcher implements Matcher<Media> { - public MediaForTypeMatcher(Collection<Integer> mediaTypes) { + public MediaForTypeMatcher(Collection<Media.SupportedMediaType> mediaTypes) { this.mediaTypes.addAll(mediaTypes); } @@ -45,10 +45,10 @@ public class MediaForTypeMatcher implements Matcher<Media> { return false; if (mediaTypes.isEmpty()) return true; - Integer mt = m.getType(); + Media.SupportedMediaType mt = m.getType(); return mediaTypes.contains(mt); } - private Set<Integer> mediaTypes = new HashSet<Integer>(); + private Set<Media.SupportedMediaType> mediaTypes = new HashSet<Media.SupportedMediaType>(); } diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java index ce541ac..de93246 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java +++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java @@ -32,7 +32,7 @@ import ca.odell.glazedlists.event.ListEvent; import de.schwarzrot.cmpc.domain.Media; -public class MediaPool2TypeList extends TransformedList<Media, Integer> { +public class MediaPool2TypeList extends TransformedList<Media, Media.SupportedMediaType> { public MediaPool2TypeList(EventList<Media> source) { super(source); source.addListEventListener(this); @@ -40,13 +40,14 @@ public class MediaPool2TypeList extends TransformedList<Media, Integer> { @Override - public Integer get(int index) { + public Media.SupportedMediaType get(int index) { Media m = source.get(index); return m.getType(); } + @Override public void listChanged(ListEvent<Media> listChanges) { updates.forwardEvent(listChanges); } diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java index 9ba948e..033ee53 100644 --- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java +++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java @@ -67,7 +67,7 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis setBackground(list.getBackground()); setForeground(list.getForeground()); } - ImageIcon icon = images[(Integer) value]; + ImageIcon icon = images[((Media.SupportedMediaType) value).ordinal()]; setSize(110, 110); setHorizontalAlignment(JLabel.CENTER); @@ -105,13 +105,14 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis public MediaTypeSelect(EventList<Media> source) { - EventList<Integer> mediaTypeNonUnique = new MediaPool2TypeList(source); + EventList<Media.SupportedMediaType> mediaTypeNonUnique = new MediaPool2TypeList(source); - mediaTypeList = new UniqueList<Integer>(mediaTypeNonUnique); - DefaultEventListModel<Integer> mediaTypeListModel = new DefaultEventListModel<Integer>(mediaTypeList); + mediaTypeList = new UniqueList<Media.SupportedMediaType>(mediaTypeNonUnique); + DefaultEventListModel<Media.SupportedMediaType> mediaTypeListModel = new DefaultEventListModel<Media.SupportedMediaType>( + mediaTypeList); mediaTypeJList = new JList(mediaTypeListModel); - DefaultEventSelectionModel<Integer> mediaTypeSelectionModel = new DefaultEventSelectionModel<Integer>( + DefaultEventSelectionModel<Media.SupportedMediaType> mediaTypeSelectionModel = new DefaultEventSelectionModel<Media.SupportedMediaType>( mediaTypeList); mediaTypeJList.setSelectionModel(mediaTypeSelectionModel); @@ -134,8 +135,8 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis fireChanged(newMatcher); } - private EventList<Integer> mediaTypeList; - private EventList<Integer> selectedTypes; + private EventList<Media.SupportedMediaType> mediaTypeList; + private EventList<Media.SupportedMediaType> selectedTypes; private JList mediaTypeJList; private static final String[] iconFiles; static { |