Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolan Halbrook committed Sep 6, 2002
1 parent ac65cba commit 9508893
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
57 changes: 25 additions & 32 deletions com/gallery/GalleryRemote/DroppableList.java
Expand Up @@ -45,6 +45,7 @@ public class DroppableList extends JList
MainFrame mDaddy = null;
DragSource dragSource;
DropTarget dropTarget;
PictureSelection ps;
boolean isDrag;
int lastY = -1;

Expand All @@ -53,9 +54,9 @@ public class DroppableList extends JList
*/

public DroppableList() {
dropTarget = new DropTarget(this, this);
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
dropTarget = new DropTarget(this, this);
}


Expand Down Expand Up @@ -92,6 +93,22 @@ public void dragEnter( DropTargetDragEvent dropTargetDragEvent ) {
public void dragExit( DropTargetEvent dropTargetEvent ) {
Log.log(Log.TRACE, "DROPLIST","dragExit - dtde");
isDrag = false;
if (ps != null){
//add pictures back
Log.log(Log.INFO, "DROPLIST","dragging internal selection out...");
try {
java.util.List fileList = (java.util.List) ps.getTransferData( DataFlavor.javaFileListFlavor );
if (!ps.isEmpty()){
Picture p = (Picture) ps.get(0);
mDaddy.addPictures( (File[]) fileList.toArray( new File[0] ), p.getListIndex());
}
//kill dragEvent
//need to figure out why MainFrame becomes dropTarget for internal drops??!!
} catch (Exception e){
Log.log(Log.INFO, "DROPLIST","coudn't kill drag " + e);
}
}
ps = null;
//lastY = -1;
}

Expand Down Expand Up @@ -169,16 +186,20 @@ public void dragExit(DragSourceEvent dragSourceEvent) {
public void dragGestureRecognized( DragGestureEvent event) {
Log.log(Log.TRACE, "DROPLIST","dragGestureRecognized");
int[] selIndices = this.getSelectedIndices();
PictureSelection ps = new PictureSelection();
ps = new PictureSelection();
for (int i = 0; i < selIndices.length; i++){
if (selIndices[i] != -1){
ps.add(this.getModel().getElementAt(selIndices[i]));
int selIndex = selIndices[i];
if (selIndex != -1){
Picture p = (Picture) this.getModel().getElementAt(selIndex);
p.setListIndex(selIndex);
ps.add(p);
}
}
//pull out existing pictures
if (!ps.isEmpty()) {
dragSource.startDrag(event, DragSource.DefaultMoveDrop, ps, this);
mDaddy.deleteSelectedPictures();

} else {
Log.log(Log.TRACE, "DROPLIST", "nothing was selected");
}
Expand Down Expand Up @@ -307,32 +328,4 @@ static java.util.List listFilesRecursive( File dir ) throws IOException {
return ret;
}

//final static BasicStroke stroke = new BasicStroke(1.0f);

/*public void paintComponent( Graphics g ){
super.paintComponent(g);
Log.log(Log.TRACE, MODULE, "painting component -- isDrag: " + isDrag);
if (this.getModel().getSize() > 0 && isDrag){
//Log.log(Log.TRACE, MODULE, "adding line");
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setStroke( stroke );
//Log.log(Log.TRACE, MODULE, "p:" + p);
//get index of drop spot
int curEl = this.locationToIndex(p);
//Log.log(Log.TRACE, MODULE, "curEl:" + curEl);
double lineY = 0.0;
if (curEl == -1){
curEl = this.getModel().getSize();
}
lineY = (double) curEl * this.getFixedCellHeight();
//start x, y end x, y
Line2D line = new Line2D.Double(10.0, lineY, this.getVisibleRect().getWidth() - 10.0, lineY);
//make the line red
g2.setColor(new Color(255,0,0));
g2.draw(line);
}
}*/
}
18 changes: 17 additions & 1 deletion com/gallery/GalleryRemote/model/Picture.java
Expand Up @@ -38,7 +38,8 @@ public class Picture {
String caption = null;
double fileSize = -1;
Album album = null;

private int listIndex;

/**
* Constructor for the Picture object
*/
Expand Down Expand Up @@ -130,5 +131,20 @@ public Album getAlbum() {
return album;
}

/** Getter for property listIndex.
* @return Value of property listIndex.
*
*/
public int getListIndex() {
return this.listIndex;
}

/** Setter for property listIndex.
* @param listIndex New value of property listIndex.
*
*/
public void setListIndex(int listIndex) {
}

}

0 comments on commit 9508893

Please sign in to comment.