From: WiESi <wi...@us...> - 2006-02-28 12:33:13
|
Update of /cvsroot/javaamp/javaamp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2323/src Modified Files: FileInformationDialog.java Log Message: FileInformationDialog rewritten Index: FileInformationDialog.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/FileInformationDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FileInformationDialog.java 15 Feb 2006 15:32:13 -0000 1.3 +++ FileInformationDialog.java 28 Feb 2006 12:33:08 -0000 1.4 @@ -14,79 +14,50 @@ JTextField tfdFile; JTabbedPane tapType; - Container cntID3v1; - JTable tabID3v1; - Container cntID3v2; - JTable tabID3v2; - Container cntVorbis; - JTable tabVorbis; - Container cntShoutcast; - JTable tabShoutcast; - Container cntIcecast; - JTable tabIcecast; - Container cntASF; - JTable tabASF; + String[] descriptions = { "ID3v1", "ID3v2", "Vorbis", "Shoutcast", + "Icecast", "ASF" }; + int[] types = { FSound.FSOUND_TAGFIELD_ID3V1, FSound.FSOUND_TAGFIELD_ID3V2, + FSound.FSOUND_TAGFIELD_VORBISCOMMENT, FSound.FSOUND_TAGFIELD_SHOUTCAST, + FSound.FSOUND_TAGFIELD_ICECAST, FSound.FSOUND_TAGFIELD_ASF + }; + Container[] containers; + JScrollPane[] scrollPanes; + JTable[] tables; public FileInformationDialog(JavaAmp o) { + super(o.playlistDialog, "Dateiinformationen", true); owner = o; - setTitle("Dateiinformationen"); setSize(500, 400); setResizable(false); - setModal(true); + setLocation((getToolkit().getScreenSize().width - getWidth()) / 2, + (getToolkit().getScreenSize().height - getHeight()) / 2); cntContainer = new Container(); cntContainer.setLayout(null); tfdFile = new JTextField(); tfdFile.setEditable(false); - tfdFile.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); tfdFile.setBounds(10, 10, 470, 20); - cntID3v1 = new Container(); - cntID3v1.setLayout(new BorderLayout()); - tabID3v1 = new JTable(new DefaultTableModel(0, 2)); - tabID3v1.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntID3v1.add(tabID3v1); - - cntID3v2 = new Container(); - cntID3v2.setLayout(new BorderLayout()); - tabID3v2 = new JTable(new DefaultTableModel()); - tabID3v2.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntID3v2.add(tabID3v2); - - cntVorbis = new Container(); - cntVorbis.setLayout(new BorderLayout()); - tabVorbis = new JTable(new DefaultTableModel()); - tabVorbis.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntVorbis.add(tabVorbis); - - cntShoutcast = new Container(); - cntShoutcast.setLayout(new BorderLayout()); - tabShoutcast = new JTable(new DefaultTableModel()); - tabShoutcast.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntShoutcast.add(tabShoutcast); - - cntIcecast = new Container(); - cntIcecast.setLayout(new BorderLayout()); - tabIcecast = new JTable(new DefaultTableModel()); - tabIcecast.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntIcecast.add(tabIcecast); - - cntASF = new Container(); - cntASF.setLayout(new BorderLayout()); - tabASF = new JTable(new DefaultTableModel()); - tabASF.setBorder(new BevelBorder(BevelBorder.LOWERED)); - cntASF.add(tabASF); + containers = new Container[descriptions.length]; + scrollPanes = new JScrollPane[descriptions.length]; + tables = new JTable[descriptions.length]; + for(int i = 0; i < containers.length; i++) { + containers[i] = new Container(); + containers[i].setLayout(new BorderLayout()); + tables[i] = new JTable(new DefaultTableModel(new String[] { + "Schlüssel", "Wert" }, 0)); + scrollPanes[i] = new JScrollPane(tables[i], + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + containers[i].add(scrollPanes[i]); + } tapType = new JTabbedPane(); tapType.setBounds(10, 40, 470, 320); - tapType.addTab("ID3v1", cntID3v1); - tapType.addTab("ID3v2", cntID3v2); - tapType.addTab("Vorbis", cntVorbis); - tapType.addTab("Shoutcast", cntShoutcast); - tapType.addTab("Icecast", cntIcecast); - tapType.addTab("ASF", cntASF); + for(int i = 0; i < containers.length; i++) + tapType.addTab(descriptions[i], containers[i]); cntContainer.add(tfdFile); cntContainer.add(tapType); @@ -114,35 +85,15 @@ for(int i = 0; i < ti.get(0); i++) { FSoundTagField tag = new FSoundTagField(); if(FSound.FSOUND_Stream_GetTagField(stream, i, tag)) { - if(tag.getType() == FSound.FSOUND_TAGFIELD_ID3V1) - if(tag.getName().equals("GENRE")) - ((DefaultTableModel)tabID3v1.getModel()).addRow( - new String[] { "GENRE", - Genres.getGenre(tag.getValueAsString()) }); - else - ((DefaultTableModel)tabID3v1.getModel()).addRow( - new String[] { tag.getName(), - tag.getValueAsString() }); - else if(tag.getType() == FSound.FSOUND_TAGFIELD_ID3V2) - ((DefaultTableModel)tabID3v2.getModel()).addRow( - new String[] { tag.getName(), - tag.getValueAsString() }); - else if(tag.getType() == - FSound.FSOUND_TAGFIELD_VORBISCOMMENT) - ((DefaultTableModel)tabVorbis.getModel()).addRow( - new String[] { tag.getName(), - tag.getValueAsString() }); - else if(tag.getType() == - FSound.FSOUND_TAGFIELD_SHOUTCAST) - ((DefaultTableModel)tabShoutcast.getModel()).addRow( - new String[] { tag.getName(), - tag.getValueAsString() }); - else if(tag.getType() == FSound.FSOUND_TAGFIELD_ICECAST) - ((DefaultTableModel)tabIcecast.getModel()).addRow( - new String[] { tag.getName(), - tag.getValueAsString() }); - else if(tag.getType() == FSound.FSOUND_TAGFIELD_ASF) - ((DefaultTableModel)tabASF.getModel()).addRow( + if(tag.getType() == FSound.FSOUND_TAGFIELD_ID3V1 && + tag.getName().equals("GENRE")) + ((DefaultTableModel)tables[getIDfromType( + tag.getType())].getModel()).addRow( + new String[] { "GENRE", Genres.getGenre( + tag.getValueAsString()) }); + else + ((DefaultTableModel)tables[getIDfromType( + tag.getType())].getModel()).addRow( new String[] { tag.getName(), tag.getValueAsString() }); } @@ -156,4 +107,11 @@ } return false; } + + public int getIDfromType(int type) { + for(int i = 0; i < types.length; i++) + if(types[i] == type) + return i; + return -1; + } } \ No newline at end of file |