Skip to content

Commit 20ca293

Browse files
committed
Prepare release 1.2
1 parent 32ed0e0 commit 20ca293

File tree

14 files changed

+170
-43
lines changed

14 files changed

+170
-43
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ java -jar jstackfx-<version>.jar --pid=<pid of the process to dump>
3939

4040
**Warning:** if both `--pid` and `--file` parameters are used, `--file` is ignored.
4141

42-
# Screenshot
42+
# Screenshot````
4343

4444
![Screenshot of JStackFX](src/site/screenshots/JStackFX_01.png)
4545
![Screenshot of JStackFX](src/site/screenshots/JStackFX_02.png)
4646
![Screenshot of JStackFX](src/site/screenshots/JStackFX_03.png)
47+
![Screenshot of JStackFX](src/site/screenshots/JStackFX_04.png)
4748

4849
# Usage
4950

@@ -63,9 +64,17 @@ fieldName comparator value operand fieldName comparator value ...
6364

6465
* List all RUNNABLE threads:`state = runnable`
6566
* Display threads having number 10 or 20: `number = 10 or number = 20`
66-
* Display threads ha ving number 10 or thread having number 20 and is in state BLOCKED: `number = 10 or number = 20 and state = blocked`
67+
* Display threads having number 10 or thread having number 20 and is in state BLOCKED: `number = 10 or number = 20 and state = blocked`
6768

68-
# Changes
69+
# Release notes
70+
71+
## Version 1.2
72+
73+
**New and noteworthy:**
74+
75+
* Display the number of results in the search bar
76+
* Allow to display thread elements' source from the dump file
77+
* UX improvements
6978

7079
## Version 1.1
7180

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'io.twasyl'
2-
version '@@NEXT-VERSION@@'
2+
version '1.2'
33

44
apply plugin: 'java'
55
apply plugin: 'distribution'
@@ -12,7 +12,7 @@ repositories {
1212
}
1313

1414
dependencies {
15-
compile 'de.jensd:fontawesomefx-octicons:3.3.0-2'
15+
compile 'de.jensd:fontawesomefx-octicons:4.3.0-1'
1616
testCompile 'junit:junit:4.12'
1717
}
1818

src/main/java/io/twasyl/jstackfx/beans/ThreadElement.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
import javafx.scene.control.ContextMenu;
77
import javafx.scene.control.MenuItem;
88
import javafx.scene.input.Clipboard;
9-
import javafx.scene.input.ClipboardContent;
109
import javafx.scene.input.DataFormat;
1110
import javafx.scene.text.Font;
1211
import javafx.scene.text.FontWeight;
1312
import javafx.scene.text.Text;
14-
import javafx.scene.text.TextFlow;
1513

1614
import java.util.*;
1715

@@ -39,6 +37,7 @@ public class ThreadElement {
3937
protected final SetProperty<ThreadReference> holdingLocks = new SimpleSetProperty<>(FXCollections.observableSet());
4038
protected final SetProperty<ThreadReference> waitingToLock = new SimpleSetProperty<>(FXCollections.observableSet());
4139
protected final SetProperty<ThreadReference> parkingReasons = new SimpleSetProperty<>(FXCollections.observableSet());
40+
protected final StringProperty source = new SimpleStringProperty();
4241

4342
public ObjectProperty<Dump> dumpProperty() {
4443
return dump;
@@ -184,6 +183,18 @@ public void setParkingReasons(ObservableSet<ThreadReference> parkingReasons) {
184183
this.parkingReasons.set(parkingReasons);
185184
}
186185

186+
public String getSource() {
187+
return source.get();
188+
}
189+
190+
public StringProperty sourceProperty() {
191+
return source;
192+
}
193+
194+
public void setSource(String source) {
195+
this.source.set(source);
196+
}
197+
187198
/**
188199
* Get threads in the given {@link Dump dump} that are blocking this thread.
189200
*

src/main/java/io/twasyl/jstackfx/controllers/JStackFXController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class JStackFXController implements Initializable {
4545
@FXML
4646
private TextFlow threadElementDetails;
4747
@FXML
48+
private TextArea threadElementSource;
49+
@FXML
4850
private PieChart threadsRepartition;
4951
@FXML
5052
private PieChart mostLockedSynchronizers;
@@ -138,6 +140,7 @@ public void dumpPID(final long pid) throws DumpException {
138140

139141
public void updateUI(final Dump dump) {
140142
if (dump != null) {
143+
this.clearUI();
141144
this.updateSearchField(dump);
142145
this.updateThreadInformationsTable(dump);
143146
this.updateDumpInformations(dump);
@@ -157,6 +160,11 @@ protected void writeToDumpFile(final File dumpFile, final Dump dump) throws IOEx
157160
}
158161
}
159162

163+
protected void clearUI() {
164+
this.threadElementDetails.getChildren().clear();
165+
this.threadElementSource.setText("");
166+
}
167+
160168
protected void updateSearchField(final Dump dump) {
161169
this.searchField.setDataSet(dump.getElements());
162170
}
@@ -266,6 +274,7 @@ public void initialize(URL location, ResourceBundle resources) {
266274
this.threadElementDetails.getChildren().clear();
267275
if (newItem != null) {
268276
this.threadElementDetails.getChildren().addAll(newItem.asText());
277+
this.threadElementSource.setText(newItem.getSource());
269278
}
270279
});
271280

src/main/java/io/twasyl/jstackfx/factory/ThreadElementFactory.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* This class is responsible for creating {@link ThreadElement thread elements} properly.
1212
*
1313
* @author Thierry Wasylczenko
14-
* @since SlideshowFX 1.0
14+
* @since JStackFX 1.0
1515
*/
1616
public class ThreadElementFactory {
1717
protected static final Pattern LINE_STARTING_WITH_DASH = Pattern.compile("^\\s+-.+$");
@@ -31,6 +31,8 @@ public class ThreadElementFactory {
3131
public static ThreadElement build(final List<String> lines) {
3232
final ThreadElement element = new ThreadElement();
3333

34+
element.setSource(buildSource(lines));
35+
3436
String line = lines.get(0);
3537
element.setName(extractNameFrom(line));
3638
element.setNumber(extractThreadNumberFrom(line));
@@ -52,6 +54,12 @@ public static ThreadElement build(final List<String> lines) {
5254
return element;
5355
}
5456

57+
protected static String buildSource(final List<String> lines) {
58+
final StringJoiner source = new StringJoiner("\n");
59+
lines.forEach(source::add);
60+
return source.toString();
61+
}
62+
5563
protected static String extractNameFrom(final String line) {
5664
final Matcher matcher = THREAD_NAME_PATTERN.matcher(line);
5765

src/main/java/io/twasyl/jstackfx/ui/SearchField.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import javafx.beans.property.*;
99
import javafx.collections.FXCollections;
1010
import javafx.collections.ObservableList;
11-
import javafx.scene.control.SplitMenuButton;
1211
import javafx.scene.control.TextField;
1312
import javafx.scene.layout.StackPane;
13+
import javafx.scene.text.Text;
14+
import javafx.scene.text.TextAlignment;
1415

1516
import java.util.Collection;
1617
import java.util.Objects;
@@ -35,6 +36,7 @@ public class SearchField<T> extends StackPane {
3536

3637
protected TextField textField = new TextField();
3738
protected OctIconView icon = new OctIconView(OctIcon.SEARCH);
39+
protected Text numberOfResults = new Text();
3840

3941
protected Query<T> query;
4042
protected final DoubleProperty prefColumnCount = new SimpleDoubleProperty();
@@ -48,9 +50,10 @@ public SearchField() {
4850

4951
this.prefColumnCount.bindBidirectional(this.textField.prefColumnCountProperty());
5052

51-
this.getChildren().addAll(this.textField, this.icon);
53+
this.getChildren().addAll(this.textField, this.icon, this.numberOfResults);
5254

5355
this.initializeKeyPressed();
56+
this.initializeNumberOfResults();
5457
}
5558

5659
protected void initializeKeyPressed() {
@@ -86,6 +89,14 @@ protected void initializeKeyPressed() {
8689
});
8790
}
8891

92+
protected void initializeNumberOfResults() {
93+
this.numberOfResults.getStyleClass().add("number");
94+
this.numberOfResults.setWrappingWidth(50);
95+
this.numberOfResults.setTextAlignment(TextAlignment.RIGHT);
96+
this.numberOfResults.translateXProperty().bind(this.textField.widthProperty().subtract(this.numberOfResults.wrappingWidthProperty()).subtract(5));
97+
this.numberOfResults.textProperty().bind(this.resultsProperty().sizeProperty().asString().concat("/").concat(this.dataSetProperty().sizeProperty().asString()));
98+
}
99+
89100
public DoubleProperty prefColumnCountProperty() {
90101
return prefColumnCount;
91102
}

src/main/java/io/twasyl/jstackfx/ui/cells/ThreadElementRow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Class representing a {@link ThreadElement} within a {@link javafx.scene.control.TableView} of elements.
1313
*
1414
* @author Thierry Wasylczenko
15-
* @since SlideshowFX 1.0
15+
* @since JStackFX 1.0
1616
*/
1717
public class ThreadElementRow extends TableRow<ThreadElement> {
1818

@@ -26,6 +26,7 @@ public class ThreadElementRow extends TableRow<ThreadElement> {
2626
PSEUDO_CLASS_STATES.put(Thread.State.BLOCKED, PseudoClassState.getPseudoClass("blocked"));
2727
PSEUDO_CLASS_STATES.put(Thread.State.TERMINATED, PseudoClassState.getPseudoClass("terminated"));
2828
}
29+
2930
@Override
3031
protected void updateItem(ThreadElement item, boolean empty) {
3132
super.updateItem(item, empty);

src/main/resources/io/twasyl/jstackfx/css/default.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,14 @@
4949

5050
/** Search field */
5151
.search-field { -fx-alignment: BASELINE_LEFT; }
52-
.search-field .text-field { -fx-padding: 6px 7px 6px 30px; }
53-
.search-field .search { -fx-translate-x: 10px; }
52+
.search-field .text-field { -fx-padding: 6px 60px 6px 30px; }
53+
.search-field .search { -fx-translate-x: 10px; }
54+
.search-field .number { -fx-fill: lightgray; }
55+
56+
/** Thread element nodes */
57+
#threadElementDetails { -fx-padding: 5px ; }
58+
59+
#threadElementSource { -fx-font-family: 'Courier New'; -fx-padding: 5px; }
60+
#threadElementSource,
61+
#threadElementSource .content,
62+
#threadElementSource .scroll-pane { -fx-background-color: transparent; }

0 commit comments

Comments
 (0)