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

Commit 21a018c

Browse files
committed
删除上传和下载进度条
1 parent ae4d6c4 commit 21a018c

File tree

4 files changed

+25
-60
lines changed

4 files changed

+25
-60
lines changed

src/main/java/org/code4everything/qiniu/QiniuApplication.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import javafx.stage.Stage;
1111
import org.apache.log4j.Logger;
1212
import org.code4everything.qiniu.constant.QiniuValueConsts;
13-
import org.code4everything.qiniu.controller.MainController;
1413
import org.code4everything.qiniu.model.ConfigBean;
1514
import org.code4everything.qiniu.util.ConfigUtils;
1615
import org.code4everything.qiniu.util.DialogUtils;
@@ -73,15 +72,11 @@ public void start(Stage stage) {
7372
stage.setTitle(QiniuValueConsts.MAIN_TITLE);
7473
// 设置关闭窗口事件
7574
stage.setOnCloseRequest(event -> {
76-
// 判断是否有文件在上传下载
77-
MainController main = MainController.getInstance();
78-
if (main.downloadProgress.isVisible() || main.uploadProgress.isVisible()) {
79-
Optional<ButtonType> result = DialogUtils.showConfirmation(QiniuValueConsts.UPLOADING_OR_DOWNLOADING);
80-
if (result.isPresent() && result.get() != ButtonType.OK) {
81-
// 取消退出事件
82-
event.consume();
83-
return;
84-
}
75+
Optional<ButtonType> result = DialogUtils.showConfirmation(QiniuValueConsts.CONFIRM_EXIT);
76+
if (result.isPresent() && result.get() != ButtonType.OK) {
77+
// 取消退出事件
78+
event.consume();
79+
return;
8580
}
8681
// 退出程序
8782
ThreadPool.executor.shutdown();

src/main/java/org/code4everything/qiniu/constant/QiniuValueConsts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class QiniuValueConsts {
8181

8282
public static final long DATE_SPAN_OF_THIRTY_ONE = 31 * 24 * 60 * 60 * 1000L;
8383

84-
public static final String UPLOADING_OR_DOWNLOADING = "有文件正在上传或下载中,是否确认退出?";
84+
public static final String CONFIRM_EXIT = "有文件正在上传或下载中,是否确认退出?";
8585

8686
private QiniuValueConsts() {}
8787
}

src/main/java/org/code4everything/qiniu/controller/MainController.java

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ public class MainController {
8585
@FXML
8686
public TextField searchTextField;
8787

88-
@FXML
89-
public ProgressBar uploadProgress;
90-
91-
@FXML
92-
public ProgressBar downloadProgress;
93-
9488
@FXML
9589
public CheckBox folderRecursive;
9690

@@ -117,21 +111,6 @@ public class MainController {
117111
@FXML
118112
private TableColumn<FileBean, String> timeColumn;
119113

120-
@FXML
121-
private Hyperlink toCsdnBlog;
122-
123-
@FXML
124-
private Hyperlink toHexoBlog;
125-
126-
@FXML
127-
private Hyperlink toGithubSource;
128-
129-
@FXML
130-
private Hyperlink toIntro;
131-
132-
@FXML
133-
private Hyperlink toIntro1;
134-
135114
@FXML
136115
private Label totalSizeLabel;
137116

@@ -279,19 +258,21 @@ private void drawChart(boolean isFluxUnitChange, boolean isBandwidthUnitChange)
279258
// 获取开始日期和结束日期的时间差
280259
long timeSpan = localEndDate.getTime() - localStartDate.getTime();
281260
if (Checker.isNotEmpty(domainTextField.getText()) && timeSpan >= 0 && timeSpan <= QiniuValueConsts.DATE_SPAN_OF_THIRTY_ONE) {
282-
String[] domains = {domainTextField.getText()};
283-
if (isFluxUnitChange) {
284-
// 获取流量数据
285-
String fluxUnit = fluxCountUnit.getValue();
286-
bucketFluxChart.getData().clear();
287-
bucketFluxChart.getData().add(service.getBucketFlux(domains, fromDate, toDate, fluxUnit));
288-
}
289-
if (isBandwidthUnitChange) {
290-
// 获取带宽数据
291-
String bandUnit = bandCountUnit.getValue();
292-
bucketBandChart.getData().clear();
293-
bucketBandChart.getData().add(service.getBucketBandwidth(domains, fromDate, toDate, bandUnit));
294-
}
261+
Platform.runLater(() -> {
262+
String[] domains = {domainTextField.getText()};
263+
if (isFluxUnitChange) {
264+
// 获取流量数据
265+
String fluxUnit = fluxCountUnit.getValue();
266+
bucketFluxChart.getData().clear();
267+
bucketFluxChart.getData().add(service.getBucketFlux(domains, fromDate, toDate, fluxUnit));
268+
}
269+
if (isBandwidthUnitChange) {
270+
// 获取带宽数据
271+
String bandUnit = bandCountUnit.getValue();
272+
bucketBandChart.getData().clear();
273+
bucketBandChart.getData().add(service.getBucketBandwidth(domains, fromDate, toDate, bandUnit));
274+
}
275+
});
295276
}
296277
}
297278

@@ -582,11 +563,7 @@ public void uploadFile() {
582563
}
583564
// 新建一个上传文件的线程
584565
ThreadPool.executor.submit(() -> {
585-
Platform.runLater(() -> {
586-
uploadProgress.setVisible(true);
587-
uploadProgress.setProgress(0);
588-
uploadStatusTextArea.insertText(0, QiniuValueConsts.CONFIG_UPLOAD_ENVIRONMENT);
589-
});
566+
Platform.runLater(() -> uploadStatusTextArea.insertText(0, QiniuValueConsts.CONFIG_UPLOAD_ENVIRONMENT));
590567
String bucket = bucketChoiceCombo.getValue();
591568
// 默认不指定key的情况下,以文件内容的hash值作为文件名
592569
String key = Checker.checkNull(filePrefixCombo.getValue());
@@ -648,8 +625,6 @@ public void uploadFile() {
648625
Platform.runLater(() -> {
649626
uploadStatusTextArea.deleteText(0, end);
650627
uploadStatusTextArea.insertText(0, status);
651-
// 设置上传的进度
652-
uploadProgress.setProgress(++upProgress / total);
653628
});
654629
}
655630
Platform.runLater(() -> selectedFileTextArea.deleteText(0, path.length() + (paths.length > 1 ? 1 : 0)));
@@ -660,8 +635,6 @@ public void uploadFile() {
660635
uploadStatusTextArea.positionCaret(0);
661636
// 清空待上传的文件列表
662637
selectedFileTextArea.clear();
663-
// 上传完成时,设置上传进度度不可见
664-
uploadProgress.setVisible(false);
665638
});
666639
mapResourceData();
667640
// 添加文件前缀到配置文件

src/main/resources/view/Main.fxml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@
285285
<BorderPane.margin>
286286
<Insets/>
287287
</BorderPane.margin>
288-
<ProgressBar fx:id="uploadProgress" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
289-
minHeight="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="10.0" prefWidth="500.0"
290-
progress="0.0" style="-fx-border-color: transparent;" visible="false" VBox.vgrow="NEVER"/>
291288
<HBox VBox.vgrow="NEVER">
289+
<padding>
290+
<Insets top="10" bottom="10"/>
291+
</padding>
292292
<ComboBox fx:id="bucketChoiceCombo" minHeight="-Infinity" minWidth="-Infinity" prefHeight="27.0"
293293
prefWidth="205.0" promptText="还没有选择存储空间" HBox.hgrow="NEVER">
294294
<HBox.margin>
@@ -317,9 +317,6 @@
317317
</HBox.margin>
318318
</Button>
319319
</HBox>
320-
<ProgressBar fx:id="downloadProgress" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
321-
minHeight="10.0" prefHeight="10.0" prefWidth="500.0" progress="0.0"
322-
style="-fx-border-color: transparent;" visible="false" VBox.vgrow="NEVER"/>
323320
</VBox>
324321
</top>
325322
</BorderPane>

0 commit comments

Comments
 (0)