Projet

Général

Profil

Bug #757 » paste.patch

Emmanuel Hugonnet, 03/08/2010 14:17

Voir les différences:

src/test/java/wjhk/jupload2/testhelpers/JUploadPanelTestHelper.java (copie de travail)
package wjhk.jupload2.testhelpers;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
......
throw new UnsupportedOperationException(this.getClass()
+ ".getMouseListener() is not implemented in tests cases");
}
/**
* @see wjhk.jupload2.gui.JUploadPanel#getKeyListener()
*/
public KeyListener getKeyListener() {
throw new UnsupportedOperationException(this.getClass()
+ ".getKeyListener() is not implemented in tests cases");
}
/**
* @see wjhk.jupload2.gui.JUploadPanel#getPreparationProgressBar()
src/main/java/wjhk/jupload2/gui/JUploadPanelImpl.java (copie de travail)
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
......
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.TransferHandler;
......
* @version $Revision$
*/
public class JUploadPanelImpl extends JPanel implements ActionListener,
JUploadPanel, MouseListener {
JUploadPanel, MouseListener, KeyListener {
/** A generated serialVersionUID, to avoid warning during compilation */
private static final long serialVersionUID = -1212601012568225757L;
......
this.uploadPolicy, this);
this.setTransferHandler(jUploadTransfertHandler);
this.filePanel.setTransferHandler(jUploadTransfertHandler);
((FilePanelTableImp) this.filePanel).addKeyListener(this);
((FilePanelTableImp) this.filePanel).setFocusable(true);
ActionMap map = this.getActionMap();
map.put(TransferHandler.getPasteAction().getValue(Action.NAME),
TransferHandler.getPasteAction());
map.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction());
// The JUploadPanelImpl will listen to Mouse messages for the standard
// component. The current only application of this, it the CTRL+Righ
......
this.uploadButton.addMouseListener(this);
this.jLogWindowPane.addMouseListener(this);
logWindow.addMouseListener(this);
this.jLogWindowPane.setFocusable(true);
this.logWindow.addMouseListener(this);
this.logWindow.setFocusable(true);
this.preparationProgressBar.addMouseListener(this);
this.uploadProgressBar.addMouseListener(this);
this.uploadProgressBar.addKeyListener(this);
this.uploadProgressBar.setFocusable(true);
this.statusLabel.addMouseListener(this);
this.statusLabel.addKeyListener(this);
// Then: display them on the applet
this.uploadPolicy.addComponentsToJUploadPanel(this);
}
......
.getValue(Action.NAME);
if (e.getActionCommand().equals(actionPaste)) {
Action a = getActionMap().get(actionPaste);
if (a != null) {
a.actionPerformed(new ActionEvent(this.filePanel,
ActionEvent.ACTION_PERFORMED, e.getActionCommand()));
this.uploadPolicy.afterFileDropped(new DropTargetDropEvent(new DropTarget(
this.filePanel.getDropComponent(), this.dndListener).getDropTargetContext(),
new Point(), DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY_OR_MOVE ));
}
processPasteAction(e.getActionCommand());
} else if (e.getActionCommand() == this.browseButton.getActionCommand()) {
doBrowse();
} else if (e.getActionCommand() == this.removeButton.getActionCommand()) {
......
doStopUpload();
}
// focus the table. This is necessary in order to enable mouse
// events
// for triggering tooltips.
// events for triggering tooltips.
this.filePanel.focusTable();
}
......
}
}
}
this.filePanel.focusTable();
return false;
}
......
public ActionListener getActionListener() {
return this;
}
/** {@inheritDoc} */
public KeyListener getKeyListener() {
return this;
}
/** {@inheritDoc} */
public JButton getBrowseButton() {
......
return fileUploadManagerThread;
}
public void keyTyped(KeyEvent e) {
if(e.isControlDown() && (e.getKeyChar() == 'c' || e.getKeyChar() == 'C' || e.getKeyChar() == '\u0016')) {
processPasteAction("paste");
this.filePanel.focusTable();
}
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
protected void processPasteAction(String command) {
Action a = getActionMap().get(TransferHandler.getPasteAction().getValue(Action.NAME));
if (a != null) {
a.actionPerformed(new ActionEvent(this.filePanel, ActionEvent.ACTION_PERFORMED, command));
this.uploadPolicy.afterFileDropped(new DropTargetDropEvent(new DropTarget(
this.filePanel.getDropComponent(), this.dndListener).getDropTargetContext(),
new Point(), DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY_OR_MOVE ));
}
}
}
src/main/java/wjhk/jupload2/gui/JUploadPanel.java (copie de travail)
package wjhk.jupload2.gui;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
......
* @return the MouseListener
*/
public MouseListener getMouseListener();
/**
* The component that manages the keyboard.
*
* @return the KeyListener
*/
public KeyListener getKeyListener();
/**
* @return the preparationProgressBar
src/main/java/wjhk/jupload2/gui/filepanel/FilePanelTableImp.java (copie de travail)
/**
* The main panel of the applet.
*/
private JUploadPanel juploadPanel = null;;
private JUploadPanel juploadPanel = null;
/**
* Creates a new instance.
......
setLayout(new BorderLayout());
addMouseListener(juploadPanel.getMouseListener());
addKeyListener(juploadPanel.getKeyListener());
setTransferHandler(juploadPanel.getTransferHandler());
this.jtable = new FilePanelJTable(juploadPanel, uploadPolicy);
......
JScrollPane scrollPane = new JScrollPane(this.jtable);
add(scrollPane, BorderLayout.CENTER);
scrollPane.addMouseListener(juploadPanel.getMouseListener());
scrollPane.addKeyListener(juploadPanel.getKeyListener());
}
/**
src/main/java/wjhk/jupload2/policies/DefaultUploadPolicy.java (copie de travail)
// Then, we display it to the user.
String alertMsg = errorText;
// Then, the message body can be completed by the exception message.
if (exception != null && (errorText == null || errorText.equals(""))) {
if (exception != null && (errorText == null || "".equals(errorText))) {
// Ok, we have an exception.
if (exception.getCause() != null) {
alertMsg = exception.getCause().getMessage();
    (1-1/1)