Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
支持拖曳文件,窗口自适应
Browse files Browse the repository at this point in the history
  • Loading branch information
easepan committed Oct 19, 2017
1 parent b956269 commit 12c9ea6
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 311 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
**4. 其他**

- [**下载可执行的jar包**](http://oq3iwfipo.bkt.clouddn.com/tools/zhazhapan/qiniu.jar?v=4 "七牛云——对象存储管理工具jar包下载地址")
- [**下载可执行的jar包**](http://oq3iwfipo.bkt.clouddn.com/tools/zhazhapan/qiniu.jar?v=5 "七牛云——对象存储管理工具jar包下载地址")

- [**历史版本**](https://github.com/zhazhapan/qiniu/releases)

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/zhazhapan/qiniu/QiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.model.BatchStatus;
import com.zhazhapan.qiniu.config.QiConfig;
import com.zhazhapan.qiniu.config.QiConfiger;
import com.zhazhapan.qiniu.controller.MainWindowController;
import com.zhazhapan.qiniu.model.FileInfo;
import com.zhazhapan.qiniu.modules.constant.Values;
Expand Down Expand Up @@ -265,7 +265,7 @@ public boolean moveFile(String fromBucket, String fromKey, String toBucket, Stri
* 移动或复制文件
*/
public boolean moveOrCopyFile(String fromBucket, String fromKey, String toBucket, String toKey, FileAction action) {
if (new QiConfig().checkNet()) {
if (new QiConfiger().checkNet()) {
String log = "move file '" + fromKey + "' from bucket '" + fromBucket + "' to bucket '" + toBucket
+ "', and rename file '" + toKey + "'";
try {
Expand All @@ -290,7 +290,7 @@ public boolean moveOrCopyFile(String fromBucket, String fromKey, String toBucket
* 修改文件类型
*/
public boolean changeType(String fileName, String newType, String bucket) {
if (new QiConfig().checkNet()) {
if (new QiConfiger().checkNet()) {
String log = "change file '" + fileName + "' type '" + newType + "' on bucket '" + bucket;
try {
QiniuApplication.bucketManager.changeMime(bucket, fileName, newType);
Expand All @@ -309,7 +309,7 @@ public boolean changeType(String fileName, String newType, String bucket) {
* 批量删除文件,单次批量请求的文件数量不得超过1000
*/
public void deleteFiles(ObservableList<FileInfo> fileInfos, String bucket) {
if (Checker.isNotEmpty(fileInfos) && new QiConfig().checkNet()) {
if (Checker.isNotEmpty(fileInfos) && new QiConfiger().checkNet()) {
// 生成待删除的文件列表
String[] files = new String[fileInfos.size()];
ArrayList<FileInfo> seletecFileInfos = new ArrayList<FileInfo>();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zhazhapan/qiniu/config/ConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void loadConfig() {
String ak = json.get("accesskey").getAsString();
String sk = json.get("secretkey").getAsString();
QiniuApplication.key = new Key(ak, sk);
new QiConfig().createAuth(ak, sk);
new QiConfiger().createAuth(ak, sk);
} catch (Exception e) {
logger.error("read key from configuration failed, message: " + e.getMessage());
Dialogs.showException(Values.LOAD_CONFIG_ERROR, e);
Expand Down Expand Up @@ -144,7 +144,7 @@ public static void showInputKeyDialog() {
}

public static void writeKey(String accessKey, String secretKey) {
new QiConfig().createAuth(accessKey, secretKey);
new QiConfiger().createAuth(accessKey, secretKey);
QiniuApplication.key = new Key(accessKey, secretKey);
writeConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
*
*/

public class QiConfig {
public class QiConfiger {

private Logger logger = Logger.getLogger(QiConfig.class);
private Logger logger = Logger.getLogger(QiConfiger.class);

/**
* 创建上传需要的Auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.zhazhapan.qiniu.ThreadPool;
import com.zhazhapan.qiniu.QiManager.FileAction;
import com.zhazhapan.qiniu.config.ConfigLoader;
import com.zhazhapan.qiniu.config.QiConfig;
import com.zhazhapan.qiniu.config.QiConfiger;
import com.zhazhapan.qiniu.model.FileInfo;
import com.zhazhapan.qiniu.modules.constant.Values;
import com.zhazhapan.qiniu.util.Checker;
Expand All @@ -51,7 +51,9 @@
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.input.DragEvent;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TransferMode;
import javafx.stage.FileChooser;
import javafx.util.Pair;

Expand Down Expand Up @@ -208,7 +210,7 @@ private void initialize() {
bucketDomainTextField.setText(Values.DOMAIN_CONFIG_ERROR);
}
ThreadPool.executor.submit(() -> {
if (new QiConfig().configUploadEnv(zones[0], newValue)) {
if (new QiConfiger().configUploadEnv(zones[0], newValue)) {
// 加载文件列表
setResTableData();
// 刷新流量带宽统计
Expand All @@ -227,6 +229,22 @@ private void initialize() {
toIntro1.setOnAction(e -> Utils.openLink("http://blog.csdn.net/qq_26954773/article/details/78245100"));
}

/**
* 拖曳文件至TextArea
*/
public void dragFileOver(DragEvent event) {
logger.info("drog file in textarea");
event.acceptTransferModes(TransferMode.ANY);
}

/**
* 拖曳文件松开鼠标
*/
public void dragFileDropped(DragEvent event) {
logger.info("drag file dropped");
setFiles(event.getDragboard().getFiles());
}

/**
* 开始日期或结束日期改变,刷新流量、带宽统计
*/
Expand Down Expand Up @@ -461,7 +479,7 @@ public void setBucketCount() {
* 刷新资源列表
*/
public void refreshResTable() {
if (!new QiConfig().checkNet()) {
if (!new QiConfiger().checkNet()) {
Dialogs.showWarning(Values.NET_ERROR);
return;
}
Expand Down Expand Up @@ -525,10 +543,15 @@ public void selectFile() {
FileChooser chooser = new FileChooser();
chooser.setTitle(Values.FILE_CHOOSER_TITLE);
chooser.setInitialDirectory(new File(System.getProperty("user.home")));
List<File> files = chooser.showOpenMultipleDialog(QiniuApplication.stage);
setFiles(chooser.showOpenMultipleDialog(QiniuApplication.stage));
}

public void setFiles(List<File> files) {
if (Checker.isNotEmpty(files)) {
for (File file : files) {
selectedFileTextArea.insertText(0, file.getAbsolutePath() + "\r\n");
if (!selectedFileTextArea.getText().contains(file.getAbsolutePath())) {
selectedFileTextArea.insertText(0, file.getAbsolutePath() + "\r\n");
}
}
}
}
Expand Down Expand Up @@ -641,7 +664,7 @@ public void openConfigFile() {
public void resetKey() {
boolean ok = new Dialogs().showInputKeyDialog();
if (ok && Checker.isNotEmpty(zoneText.getText())) {
new QiConfig().configUploadEnv(zoneText.getText(), bucketChoiceCombo.getValue());
new QiConfiger().configUploadEnv(zoneText.getText(), bucketChoiceCombo.getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Values {

public static final String UPLOAD_SUCCESS = "上传文件成功";

public static final String UPLOADING = "文件上传中。。。。。。\r\n";
public static final String UPLOADING = "文件上传中,请耐心等待。。。。。。\r\n";

public static final String NEED_SCHOOSE_BUCKET_OR_FILE = "请先选择一个存储空间或文件";

Expand Down
Loading

0 comments on commit 12c9ea6

Please sign in to comment.