Skip to content

Commit

Permalink
Prepare release 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
twasyl committed Dec 13, 2016
1 parent 32ed0e0 commit 20ca293
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 43 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ java -jar jstackfx-<version>.jar --pid=<pid of the process to dump>

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

# Screenshot
# Screenshot````

![Screenshot of JStackFX](src/site/screenshots/JStackFX_01.png)
![Screenshot of JStackFX](src/site/screenshots/JStackFX_02.png)
![Screenshot of JStackFX](src/site/screenshots/JStackFX_03.png)
![Screenshot of JStackFX](src/site/screenshots/JStackFX_04.png)

# Usage

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

* List all RUNNABLE threads:`state = runnable`
* Display threads having number 10 or 20: `number = 10 or number = 20`
* Display threads ha ving number 10 or thread having number 20 and is in state BLOCKED: `number = 10 or number = 20 and state = blocked`
* Display threads having number 10 or thread having number 20 and is in state BLOCKED: `number = 10 or number = 20 and state = blocked`

# Changes
# Release notes

## Version 1.2

**New and noteworthy:**

* Display the number of results in the search bar
* Allow to display thread elements' source from the dump file
* UX improvements

## Version 1.1

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'io.twasyl'
version '@@NEXT-VERSION@@'
version '1.2'

apply plugin: 'java'
apply plugin: 'distribution'
Expand All @@ -12,7 +12,7 @@ repositories {
}

dependencies {
compile 'de.jensd:fontawesomefx-octicons:3.3.0-2'
compile 'de.jensd:fontawesomefx-octicons:4.3.0-1'
testCompile 'junit:junit:4.12'
}

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/io/twasyl/jstackfx/beans/ThreadElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;

import java.util.*;

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

public ObjectProperty<Dump> dumpProperty() {
return dump;
Expand Down Expand Up @@ -184,6 +183,18 @@ public void setParkingReasons(ObservableSet<ThreadReference> parkingReasons) {
this.parkingReasons.set(parkingReasons);
}

public String getSource() {
return source.get();
}

public StringProperty sourceProperty() {
return source;
}

public void setSource(String source) {
this.source.set(source);
}

/**
* Get threads in the given {@link Dump dump} that are blocking this thread.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class JStackFXController implements Initializable {
@FXML
private TextFlow threadElementDetails;
@FXML
private TextArea threadElementSource;
@FXML
private PieChart threadsRepartition;
@FXML
private PieChart mostLockedSynchronizers;
Expand Down Expand Up @@ -138,6 +140,7 @@ public void dumpPID(final long pid) throws DumpException {

public void updateUI(final Dump dump) {
if (dump != null) {
this.clearUI();
this.updateSearchField(dump);
this.updateThreadInformationsTable(dump);
this.updateDumpInformations(dump);
Expand All @@ -157,6 +160,11 @@ protected void writeToDumpFile(final File dumpFile, final Dump dump) throws IOEx
}
}

protected void clearUI() {
this.threadElementDetails.getChildren().clear();
this.threadElementSource.setText("");
}

protected void updateSearchField(final Dump dump) {
this.searchField.setDataSet(dump.getElements());
}
Expand Down Expand Up @@ -266,6 +274,7 @@ public void initialize(URL location, ResourceBundle resources) {
this.threadElementDetails.getChildren().clear();
if (newItem != null) {
this.threadElementDetails.getChildren().addAll(newItem.asText());
this.threadElementSource.setText(newItem.getSource());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* This class is responsible for creating {@link ThreadElement thread elements} properly.
*
* @author Thierry Wasylczenko
* @since SlideshowFX 1.0
* @since JStackFX 1.0
*/
public class ThreadElementFactory {
protected static final Pattern LINE_STARTING_WITH_DASH = Pattern.compile("^\\s+-.+$");
Expand All @@ -31,6 +31,8 @@ public class ThreadElementFactory {
public static ThreadElement build(final List<String> lines) {
final ThreadElement element = new ThreadElement();

element.setSource(buildSource(lines));

String line = lines.get(0);
element.setName(extractNameFrom(line));
element.setNumber(extractThreadNumberFrom(line));
Expand All @@ -52,6 +54,12 @@ public static ThreadElement build(final List<String> lines) {
return element;
}

protected static String buildSource(final List<String> lines) {
final StringJoiner source = new StringJoiner("\n");
lines.forEach(source::add);
return source.toString();
}

protected static String extractNameFrom(final String line) {
final Matcher matcher = THREAD_NAME_PATTERN.matcher(line);

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/io/twasyl/jstackfx/ui/SearchField.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.SplitMenuButton;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;

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

protected TextField textField = new TextField();
protected OctIconView icon = new OctIconView(OctIcon.SEARCH);
protected Text numberOfResults = new Text();

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

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

this.getChildren().addAll(this.textField, this.icon);
this.getChildren().addAll(this.textField, this.icon, this.numberOfResults);

this.initializeKeyPressed();
this.initializeNumberOfResults();
}

protected void initializeKeyPressed() {
Expand Down Expand Up @@ -86,6 +89,14 @@ protected void initializeKeyPressed() {
});
}

protected void initializeNumberOfResults() {
this.numberOfResults.getStyleClass().add("number");
this.numberOfResults.setWrappingWidth(50);
this.numberOfResults.setTextAlignment(TextAlignment.RIGHT);
this.numberOfResults.translateXProperty().bind(this.textField.widthProperty().subtract(this.numberOfResults.wrappingWidthProperty()).subtract(5));
this.numberOfResults.textProperty().bind(this.resultsProperty().sizeProperty().asString().concat("/").concat(this.dataSetProperty().sizeProperty().asString()));
}

public DoubleProperty prefColumnCountProperty() {
return prefColumnCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Class representing a {@link ThreadElement} within a {@link javafx.scene.control.TableView} of elements.
*
* @author Thierry Wasylczenko
* @since SlideshowFX 1.0
* @since JStackFX 1.0
*/
public class ThreadElementRow extends TableRow<ThreadElement> {

Expand All @@ -26,6 +26,7 @@ public class ThreadElementRow extends TableRow<ThreadElement> {
PSEUDO_CLASS_STATES.put(Thread.State.BLOCKED, PseudoClassState.getPseudoClass("blocked"));
PSEUDO_CLASS_STATES.put(Thread.State.TERMINATED, PseudoClassState.getPseudoClass("terminated"));
}

@Override
protected void updateItem(ThreadElement item, boolean empty) {
super.updateItem(item, empty);
Expand Down
13 changes: 11 additions & 2 deletions src/main/resources/io/twasyl/jstackfx/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@

/** Search field */
.search-field { -fx-alignment: BASELINE_LEFT; }
.search-field .text-field { -fx-padding: 6px 7px 6px 30px; }
.search-field .search { -fx-translate-x: 10px; }
.search-field .text-field { -fx-padding: 6px 60px 6px 30px; }
.search-field .search { -fx-translate-x: 10px; }
.search-field .number { -fx-fill: lightgray; }

/** Thread element nodes */
#threadElementDetails { -fx-padding: 5px ; }

#threadElementSource { -fx-font-family: 'Courier New'; -fx-padding: 5px; }
#threadElementSource,
#threadElementSource .content,
#threadElementSource .scroll-pane { -fx-background-color: transparent; }
Loading

0 comments on commit 20ca293

Please sign in to comment.