Skip to content

Commit

Permalink
Undoing changes I accidentally made to this branch in rev 252...
Browse files Browse the repository at this point in the history
  • Loading branch information
firewyre committed Mar 10, 2011
1 parent a12401e commit f7e57f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 188 deletions.
2 changes: 1 addition & 1 deletion dev/listfix/model/Playlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private List<PlaylistEntry> getEntriesForFiles(File[] files, IProgressObserver<S
List<PlaylistEntry> ents = new ArrayList<PlaylistEntry>();
for (File file : files)
{
if (observer == null || !observer.getCancelled())
if (!observer.getCancelled())
{
if (Playlist.isPlaylist(file))
{
Expand Down
6 changes: 6 additions & 0 deletions dev/listfix/view/GUIScreen.form
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@
<Property name="text" type="java.lang.String" value="Open A Playlist"/>
<Property name="toolTipText" type="java.lang.String" value="Open A Playlist"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="iconTextGap" type="int" value="-2"/>
Expand Down Expand Up @@ -751,6 +754,9 @@
<Property name="text" type="java.lang.String" value="New Playlist"/>
<Property name="toolTipText" type="java.lang.String" value="New Playlist"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="iconTextGap" type="int" value="3"/>
Expand Down
77 changes: 3 additions & 74 deletions dev/listfix/view/GUIScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -84,6 +77,7 @@
import listfix.model.BatchRepair;
import listfix.model.BatchRepairItem;
import listfix.model.Playlist;
import listfix.model.PlaylistEntry;
import listfix.model.PlaylistHistory;

import listfix.util.ArrayFunctions;
Expand All @@ -100,14 +94,13 @@
import listfix.view.support.ICloseableTabManager;
import listfix.view.support.ProgressWorker;

public final class GUIScreen extends JFrame implements ICloseableTabManager, DropTargetListener
public final class GUIScreen extends JFrame implements ICloseableTabManager
{
private static final long serialVersionUID = 7691786927987534889L;
private final JFileChooser jM3UChooser;
private final JFileChooser jMediaDirChooser;
private final JFileChooser jSaveFileChooser;
private GUIDriver guiDriver = null;
private DropTarget dropTarget = null;

/** Creates new form GUIScreen */
public GUIScreen()
Expand Down Expand Up @@ -174,7 +167,7 @@ public GUIScreen()

syncJMenuFonts();

// drag-n-drop support for the playlist directory tree
// drag-n-drop support
_playlistDirectoryTree.setTransferHandler(new TransferHandler()
{
@Override
Expand All @@ -183,7 +176,6 @@ public boolean canImport(TransferHandler.TransferSupport info)
return false;
}

@Override
public boolean importData(TransferHandler.TransferSupport info)
{
return false;
Expand Down Expand Up @@ -212,69 +204,6 @@ protected Transferable createTransferable(JComponent c)

}
});

dropTarget = new DropTarget(this, this);
}

public void dragEnter(DropTargetDragEvent dtde)
{

}

public void dragExit(DropTargetEvent dte)
{

}

public void dragOver(DropTargetDragEvent dtde)
{

}

public void dropActionChanged(DropTargetDragEvent dtde)
{

}

public void drop(DropTargetDropEvent dtde)
{
try
{
// Ok, get the dropped object and try to figure out what it is
Transferable tr = dtde.getTransferable();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++)
{
System.out.println("Possible flavor: " + flavors[i].getMimeType());
// Check for file lists specifically
if (flavors[i].isFlavorJavaFileListType())
{
// Great! Accept copy drops...
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

// And add the list of file names to our text area
java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
for (int j = 0; j < list.size(); j++)
{
if (list.get(j) instanceof File)
{
openPlaylist((File) list.get(j));
}
}

// If we made it this far, everything worked.
dtde.dropComplete(true);
return;
}
}
// Hmm, the user must not have dropped a file list
dtde.rejectDrop();
}
catch (Exception e)
{
e.printStackTrace();
dtde.rejectDrop();
}
}

public AppOptions getOptions()
Expand Down
124 changes: 11 additions & 113 deletions dev/listfix/view/PlaylistEditCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -1558,9 +1557,7 @@ else if ((isOverItem && _uiTable.getSelectedRowCount() == 0)
@Override
public boolean canImport(TransferHandler.TransferSupport info)
{
if (!info.isDataFlavorSupported(_playlistEntryListFlavor)
&& !info.isDataFlavorSupported(DataFlavor.stringFlavor)
&& !info.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
if (!info.isDataFlavorSupported(_playlistEntryListFlavor) && !info.isDataFlavorSupported(DataFlavor.stringFlavor))
{
return false;
}
Expand All @@ -1582,9 +1579,7 @@ public boolean importData(TransferHandler.TransferSupport info)
}

// Check for custom PlaylistEntryList flavor
if (!info.isDataFlavorSupported(_playlistEntryListFlavor)
&& !info.isDataFlavorSupported(DataFlavor.stringFlavor)
&& !info.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
if (!info.isDataFlavorSupported(_playlistEntryListFlavor) && !info.isDataFlavorSupported(DataFlavor.stringFlavor))
{
return false;
}
Expand Down Expand Up @@ -1624,114 +1619,16 @@ public boolean importData(TransferHandler.TransferSupport info)
return false;
}
}
else if (info.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
{
return HandleFileListFlavor(info, dl);
}
else
{
return HandleStringFlavor(info, dl);
}
}

private boolean HandleFileListFlavor(TransferSupport info, final JTable.DropLocation dl)
{
Transferable t = info.getTransferable();
DataFlavor[] flavors = t.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++)
{
// Currently we're only dealing w/ a string that represents the path to a playlist
// Get the entries that are being dropped.
Transferable t = info.getTransferable();
final String data;
try
{
int insertAt = dl.getRow();
final List list;
list = (List)t.getTransferData(flavors[i]);
for (int j = 0; j < list.size(); j++)
{
final File tempFile = (File)list.get(j);
if (tempFile instanceof File)
{
if (Playlist.isPlaylist(tempFile))
{
final String[] libraryFiles;
if (GUIDriver.getInstance().getAppOptions().getAutoLocateEntriesOnPlaylistLoad())
{
libraryFiles = GUIDriver.getInstance().getMediaLibraryFileList();
}
else
{
libraryFiles = null;
}
ProgressWorker<Playlist, Void> worker = new ProgressWorker<Playlist, Void>()
{
@Override
protected Playlist doInBackground() throws Exception
{
Playlist list = new Playlist(tempFile, this);
if (libraryFiles != null)
{
list.repair(libraryFiles, this);
}
return list;
}

@Override
protected void done()
{
Playlist list;
try
{
list = get();
_playlist.addAll(dl.getRow(), list.getEntries());
}
catch (CancellationException ex)
{
return;
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(PlaylistEditCtrl.this.getParentFrame(), ex, "Open Playlist Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
};
ProgressDialog pd = new ProgressDialog((GUIScreen) getParentFrame(), true, worker, "Loading...");
int plistSize = _playlist.size();
pd.setVisible(true);
insertAt += _playlist.size() - plistSize;
}
else
{
// add it to the playlist!
_playlist.add(insertAt, new File[] {tempFile}, null);
insertAt++;
}
}
}
resizeAllColumns();
return true;
}
catch (UnsupportedFlavorException ex)
{
Logger.getLogger(PlaylistEditCtrl.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex)
{
Logger.getLogger(PlaylistEditCtrl.class.getName()).log(Level.SEVERE, null, ex);
}
}
return false;
}
data = (String) t.getTransferData(DataFlavor.stringFlavor);

private boolean HandleStringFlavor(TransferSupport info, final JTable.DropLocation dl)
{
Transferable t = info.getTransferable();
DataFlavor[] flavors = t.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++)
{
try
{
final String data;
data = (String) t.getTransferData(flavors[i]);
final String[] libraryFiles;
if (GUIDriver.getInstance().getAppOptions().getAutoLocateEntriesOnPlaylistLoad())
{
Expand All @@ -1741,6 +1638,7 @@ private boolean HandleStringFlavor(TransferSupport info, final JTable.DropLocati
{
libraryFiles = null;
}

ProgressWorker<Playlist, Void> worker = new ProgressWorker<Playlist, Void>()
{
@Override
Expand All @@ -1762,6 +1660,7 @@ protected void done()
{
list = get();
_playlist.addAll(dl.getRow(), list.getEntries());

if (_playlist.size() == list.size())
{
resizeAllColumns();
Expand Down Expand Up @@ -1790,10 +1689,9 @@ protected void done()
{
Logger.getLogger(PlaylistEditCtrl.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
return false;
}
;
};

@Override
public int getSourceActions(JComponent c)
Expand Down

0 comments on commit f7e57f1

Please sign in to comment.