mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-18 23:37:12 +02:00
6.70
-FormatBytes very old bug fix -Drag and drop green border
This commit is contained in:
parent
99f344d757
commit
97b7f4ecc3
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>6.69</version>
|
||||
<version>6.70</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 tonikelope
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.tonikelope.megabasterd;
|
||||
|
||||
import static com.tonikelope.megabasterd.MainPanel.THREAD_POOL;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.TransferHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tonikelope
|
||||
*
|
||||
* Thanks to -> https://stackoverflow.com/users/6286694/abika
|
||||
*/
|
||||
class FileDropHandler extends TransferHandler {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(FileDropHandler.class.getName());
|
||||
|
||||
final FileDropHandlerNotifiable _notifiable;
|
||||
|
||||
FileDropHandler(FileDropHandlerNotifiable notifiable) {
|
||||
super();
|
||||
|
||||
_notifiable = notifiable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canImport(TransferHandler.TransferSupport support) {
|
||||
for (DataFlavor flavor : support.getDataFlavors()) {
|
||||
if (flavor.isFlavorJavaFileListType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean importData(TransferHandler.TransferSupport support) {
|
||||
if (!this.canImport(support)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<File> files;
|
||||
|
||||
try {
|
||||
files = (List<File>) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
|
||||
} catch (UnsupportedFlavorException | IOException ex) {
|
||||
// should never happen (or JDK is buggy)
|
||||
return false;
|
||||
}
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
_notifiable.file_drop_notify(files);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 tonikelope
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.tonikelope.megabasterd;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tonikelope
|
||||
*/
|
||||
public interface FileDropHandlerNotifiable {
|
||||
|
||||
public void file_drop_notify(List<File> file);
|
||||
|
||||
}
|
@ -4,12 +4,21 @@ import static com.tonikelope.megabasterd.MainPanel.*;
|
||||
import static com.tonikelope.megabasterd.MiscTools.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
@ -24,7 +33,7 @@ import javax.swing.tree.TreeNode;
|
||||
*
|
||||
* @author tonikelope
|
||||
*/
|
||||
public class FileGrabberDialog extends javax.swing.JDialog implements FileDropHandlerNotifiable {
|
||||
public class FileGrabberDialog extends javax.swing.JDialog {
|
||||
|
||||
private boolean _upload;
|
||||
private final ArrayList<File> _files;
|
||||
@ -85,7 +94,60 @@ public class FileGrabberDialog extends javax.swing.JDialog implements FileDropHa
|
||||
|
||||
translateLabels(this);
|
||||
|
||||
jPanel1.setTransferHandler(new FileDropHandler(this));
|
||||
jPanel1.setDropTarget(
|
||||
new DropTarget() {
|
||||
|
||||
public boolean canImport(DataFlavor[] flavors) {
|
||||
for (DataFlavor flavor : flavors) {
|
||||
if (flavor.isFlavorJavaFileListType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void drop(DropTargetDropEvent dtde) {
|
||||
changeToNormal();
|
||||
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
|
||||
|
||||
List<File> files;
|
||||
|
||||
try {
|
||||
|
||||
if (canImport(dtde.getTransferable().getTransferDataFlavors())) {
|
||||
files = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
_file_drop_notify(files);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (UnsupportedFlavorException | IOException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dragEnter(DropTargetDragEvent dtde) {
|
||||
changeToDrop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dragExit(DropTargetEvent dtde) {
|
||||
changeToNormal();
|
||||
}
|
||||
|
||||
private void changeToDrop() {
|
||||
jPanel1.setBorder(BorderFactory.createLineBorder(Color.green, 5));
|
||||
|
||||
}
|
||||
|
||||
private void changeToNormal() {
|
||||
jPanel1.setBorder(null);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
_total_space = 0L;
|
||||
_base_path = null;
|
||||
@ -102,7 +164,7 @@ public class FileGrabberDialog extends javax.swing.JDialog implements FileDropHa
|
||||
THREAD_POOL.execute(() -> {
|
||||
if (_drag_drop_files != null) {
|
||||
|
||||
file_drop_notify(_drag_drop_files);
|
||||
_file_drop_notify(_drag_drop_files);
|
||||
}
|
||||
if (_main_panel.getMega_accounts().size() > 0) {
|
||||
swingInvoke(() -> {
|
||||
@ -845,8 +907,7 @@ public class FileGrabberDialog extends javax.swing.JDialog implements FileDropHa
|
||||
// End of variables declaration//GEN-END:variables
|
||||
private static final Logger LOG = Logger.getLogger(FileGrabberDialog.class.getName());
|
||||
|
||||
@Override
|
||||
public void file_drop_notify(List<File> files) {
|
||||
private void _file_drop_notify(List<File> files) {
|
||||
|
||||
swingInvoke(() -> {
|
||||
add_files_button.setEnabled(false);
|
||||
|
@ -53,7 +53,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "6.69";
|
||||
public static final String VERSION = "6.70";
|
||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||
public static final int STREAMER_PORT = 1337;
|
||||
|
@ -6,6 +6,13 @@ import static com.tonikelope.megabasterd.MainPanel.*;
|
||||
import static com.tonikelope.megabasterd.MiscTools.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
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.event.WindowEvent;
|
||||
import static java.awt.event.WindowEvent.WINDOW_CLOSING;
|
||||
import java.io.File;
|
||||
@ -24,6 +31,7 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Level.SEVERE;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
@ -43,7 +51,7 @@ import javax.swing.JTabbedPane;
|
||||
*
|
||||
* @author tonikelope
|
||||
*/
|
||||
public final class MainPanelView extends javax.swing.JFrame implements FileDropHandlerNotifiable {
|
||||
public final class MainPanelView extends javax.swing.JFrame {
|
||||
|
||||
private final MainPanel _main_panel;
|
||||
|
||||
@ -336,8 +344,7 @@ public final class MainPanelView extends javax.swing.JFrame implements FileDropH
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void file_drop_notify(List<File> files) {
|
||||
private void _file_drop_notify(List<File> files) {
|
||||
|
||||
final MainPanelView tthis = this;
|
||||
|
||||
@ -404,7 +411,60 @@ public final class MainPanelView extends javax.swing.JFrame implements FileDropH
|
||||
|
||||
jTabbedPane1.setTitleAt(0, LabelTranslatorSingleton.getInstance().translate("Downloads"));
|
||||
jTabbedPane1.setTitleAt(1, LabelTranslatorSingleton.getInstance().translate("Uploads"));
|
||||
jTabbedPane1.setTransferHandler(new FileDropHandler(this));
|
||||
jTabbedPane1.setDropTarget(new DropTarget() {
|
||||
|
||||
//Thanks to -> https://stackoverflow.com/users/6286694/abika
|
||||
public boolean canImport(DataFlavor[] flavors) {
|
||||
for (DataFlavor flavor : flavors) {
|
||||
if (flavor.isFlavorJavaFileListType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void drop(DropTargetDropEvent dtde) {
|
||||
changeToNormal();
|
||||
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
|
||||
|
||||
List<File> files;
|
||||
|
||||
try {
|
||||
|
||||
if (canImport(dtde.getTransferable().getTransferDataFlavors())) {
|
||||
files = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
_file_drop_notify(files);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (UnsupportedFlavorException | IOException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dragEnter(DropTargetDragEvent dtde) {
|
||||
changeToDrop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dragExit(DropTargetEvent dtde) {
|
||||
changeToNormal();
|
||||
}
|
||||
|
||||
private void changeToDrop() {
|
||||
jTabbedPane1.setBorder(BorderFactory.createLineBorder(Color.green, 5));
|
||||
|
||||
}
|
||||
|
||||
private void changeToNormal() {
|
||||
jTabbedPane1.setBorder(null);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
String auto_close = selectSettingValue("auto_close");
|
||||
|
||||
|
@ -513,7 +513,7 @@ public class MiscTools {
|
||||
|
||||
int pow = Math.min((int) ((bytes > 0L ? Math.log(bytes) : 0) / Math.log(1024)), units.length - 1);
|
||||
|
||||
Double bytes_double = (double) bytes / (1 << (10 * pow));
|
||||
Double bytes_double = (double) bytes / (1L << (10 * pow));
|
||||
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 195 KiB |
Loading…
x
Reference in New Issue
Block a user