• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 12236799868

09 Dec 2024 01:37PM UTC coverage: 67.035% (+0.08%) from 66.953%
12236799868

push

github

web-flow
#799: fix zip extraction to preserve file attributes (#835)

2543 of 4142 branches covered (61.4%)

Branch coverage included in aggregate %.

6608 of 9509 relevant lines covered (69.49%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
cli/src/main/java/com/devonfw/tools/ide/io/IdeProgressBarConsole.java
1
package com.devonfw.tools.ide.io;
2

3
import com.devonfw.tools.ide.os.SystemInfo;
4

5
import me.tongfei.progressbar.ProgressBar;
6
import me.tongfei.progressbar.ProgressBarBuilder;
7
import me.tongfei.progressbar.ProgressBarStyle;
8

9
/**
10
 * Implementation of {@link IdeProgressBar}.
11
 */
12
public class IdeProgressBarConsole extends AbstractIdeProgressBar {
13

14
  private final ProgressBar progressBar;
15
  private final SystemInfo systemInfo;
16

17
  /**
18
   * The constructor.
19
   *
20
   * @param systemInfo the {@link SystemInfo}.
21
   * @param title the title (task name or activity) to display in the progress bar.
22
   * @param maxSize the maximum size of the progress bar.
23
   * @param unitName the name of the unit to display in the progress bar.
24
   * @param unitSize the size of the unit (e.g. 1000 for kilo, 1000000 for mega).
25
   */
26
  public IdeProgressBarConsole(SystemInfo systemInfo, String title, long maxSize, String unitName, long unitSize) {
27

28
    super(title, maxSize, unitName, unitSize);
6✔
29
    this.systemInfo = systemInfo;
3✔
30
    this.progressBar = createProgressBar();
4✔
31
  }
1✔
32

33
  /**
34
   * @return the {@link ProgressBar}.
35
   */
36
  protected ProgressBar getProgressBar() {
37

38
    return this.progressBar;
3✔
39
  }
40

41
  private ProgressBar createProgressBar() {
42

43
    ProgressBarBuilder pbb = new ProgressBarBuilder();
4✔
44
    String leftBracket, rightBracket, fractionSymbols;
45
    char block;
46
    if (this.systemInfo.isWindows()) {
4!
47
      // set different style for Windows systems (ASCII)
48
      leftBracket = "[";
×
49
      rightBracket = "]";
×
50
      fractionSymbols = ">";
×
51
      block = '=';
×
52
    } else {
53
      // default (COLORFUL_UNICODE_BLOCK)
54
      leftBracket = "\u001b[33m│";
2✔
55
      rightBracket = "│\u001b[0m";
2✔
56
      fractionSymbols = " ▏▎▍▌▋▊▉";
2✔
57
      block = '█';
2✔
58
    }
59
    pbb.setStyle(ProgressBarStyle.builder().refreshPrompt("\r").leftBracket(leftBracket).delimitingSequence("")
11✔
60
        .rightBracket(rightBracket).block(block).space(' ').fractionSymbols(fractionSymbols).rightSideFractionSymbol(' ')
9✔
61
        .build());
1✔
62

63
    pbb.setUnit(this.unitName, this.unitSize);
7✔
64
    if (this.maxSize <= 0) {
5✔
65
      pbb.setTaskName(this.title + " (unknown size)");
6✔
66
      pbb.setInitialMax(-1);
4✔
67
      pbb.hideEta();
4✔
68
    } else {
69
      pbb.setTaskName(this.title);
5✔
70
      pbb.showSpeed();
3✔
71
      pbb.setInitialMax(this.maxSize);
5✔
72
    }
73
    pbb.continuousUpdate();
3✔
74
    pbb.setUpdateIntervalMillis(100);
4✔
75

76
    return pbb.build();
3✔
77
  }
78

79
  @Override
80
  protected void doStepBy(long stepSize, long currentProgress) {
81
    this.progressBar.stepBy(stepSize);
5✔
82
  }
1✔
83

84
  @Override
85
  protected void doStepTo(long stepPosition) {
86
    this.progressBar.stepTo(stepPosition);
5✔
87
  }
1✔
88

89
  @Override
90
  public void close() {
91
    super.close();
2✔
92
    this.progressBar.close();
3✔
93
  }
1✔
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc