Skip to content

Commit

Permalink
#13 ctrl+f to iterate focus between the filter fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Till committed Aug 12, 2015
1 parent c47753e commit 392f828
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ Tested on Ubuntu and Windows 7/8. Also seen on [OS X](http://t.co/kzXppo5GEt).

### Shortcuts

| Keys | Action |
| -------- | :----------------------------------------------------------: |
| `ctrl+m` | Toggle visibility of modules and functions. |
| `ctrl+p` | Toggle visibility of processes. |
| `ctrl+t` | Toggle tracing for the selected function in the module tree. |
| Keys | Action |
| -------- | :----------------------------------------------------------------------------: |
| `ctrl+f` | Focus on the last focused filter field, or the next if one is already focused. |
| `ctrl+m` | Toggle visibility of modules and functions. |
| `ctrl+p` | Toggle visibility of processes. |
| `ctrl+t` | Toggle tracing for the selected function in the module tree. |


### How to get it
Expand All @@ -142,7 +143,7 @@ erlyberly must have epmd running on the machine as it is running. Otherwise it

You will need JDK 8 and Maven to compile. erlyberly loads an erlang module to the remote node and then uses RPC to run traces and collect stats. For convenience I have bundled the beam code in the source as well as the original erlang source. If you want to recompile the beam code for yourself run the following command from the project directory:

erlc -o src/main/resources/erlyberly/beam/ src/main/resources/erlyberly/beam/erlyberly.erl
erlc +debug_info -o src/main/resources/erlyberly/beam/ src/main/resources/erlyberly/beam/erlyberly.erl

Install Maven dependencies that are not in Maven Central.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>andytill</groupId>
<artifactId>erlyberly</artifactId>
<version>0.6.4</version>
<version>0.6.5</version>
<packaging>jar</packaging>

<name>erlyberly</name>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/erlyberly/DbgTraceView.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package erlyberly;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.WeakChangeListener;
Expand All @@ -15,6 +16,7 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.OverrunStyle;
import javafx.scene.control.SelectionMode;
Expand Down Expand Up @@ -284,6 +286,10 @@ private FxmlLoadable addTraceLogFloatySearchControl(HBox traceLogSearchBox) {

ffView.textProperty().addListener((o, ov, nv) -> { onTraceFilterChange(nv); });

Platform.runLater(() -> {
FilterFocusManager.addFilter((Control) loader.fxmlNode.getChildrenUnmodifiable().get(1), 2);
});

return loader;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/erlyberly/DbgView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.ResourceBundle;

import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
Expand All @@ -15,6 +16,7 @@
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
import javafx.scene.control.SplitPane.Divider;
Expand Down Expand Up @@ -115,6 +117,9 @@ private FxmlLoadable addModulesFloatySearchControl() {

ffView.textProperty().addListener(this::onFunctionSearchChange);

Platform.runLater(() -> {
FilterFocusManager.addFilter((Control) loader.fxmlNode.getChildrenUnmodifiable().get(1), 1);
});

return loader;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/erlyberly/ErlyBerly.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void start(Stage primaryStage) {
primaryStage.show();

displayConnectionPopup(primaryStage);

FilterFocusManager.init(scene);
}

public static void applyCssToWIndow(Scene scene) {
Expand Down
90 changes: 90 additions & 0 deletions src/main/java/erlyberly/FilterFocusManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package erlyberly;

import java.util.ArrayList;

import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Control;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;

public class FilterFocusManager {

private static final KeyCodeCombination REFRESH_MODULES_SHORTCUT = new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN);

private static final ArrayList<Control> filters = new ArrayList<>();

private static int lastFocusedIndex = -1;

public static void init(Scene scene) {
filters.add(null);
filters.add(null);
filters.add(null);

Platform.runLater(() -> {
scene.getAccelerators().put(REFRESH_MODULES_SHORTCUT, () -> { nextFilter(); });
});
}

private static void nextFilter() {
if(filters.isEmpty())
return;

Control control = findNextFilter();

requestFocus(control);
}

private static Control findNextFilter() {
if(lastFocusedIndex != -1) {
Control lastFocused = filters.get(lastFocusedIndex);
if(!lastFocused.isFocused()) {
return lastFocused;
}
}

int focused = findCurrentFilter();

if(focused == -1) {
focused = 0;
}
else {
focused++;
if(focused >= filters.size()) {
focused = 0;
}
}

return filters.get(focused);
}

private static int findCurrentFilter() {
int focused = -1;
for (int i = 0; i < filters.size(); i++) {
Control control = filters.get(i);
if(control != null && control.isFocused()) {
focused = i;
break;
}
}
return focused;
}

private static void requestFocus(Control control) {
if(control != null)
Platform.runLater(() -> { control.requestFocus(); });
}

public static void addFilter(Control control, int order) {
assert control != null;
assert order >= 0;
assert Platform.isFxApplicationThread();

filters.set(order, control);

control.focusedProperty().addListener((o, oldFocus, newFocus) -> {
lastFocusedIndex = order;
});
}
}
6 changes: 6 additions & 0 deletions src/main/java/erlyberly/ProcView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.net.URL;
import java.util.ResourceBundle;

import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.binding.BooleanBinding;
Expand All @@ -17,6 +18,7 @@
import javafx.scene.chart.PieChart.Data;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Control;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.Separator;
Expand Down Expand Up @@ -159,6 +161,10 @@ private FxmlLoadable addFloatySearchControl() {

procController.filterProperty().bind(ffView.textProperty());

Platform.runLater(() -> {
FilterFocusManager.addFilter((Control) loader.fxmlNode.getChildrenUnmodifiable().get(1), 0);
});

return loader;
}

Expand Down

0 comments on commit 392f828

Please sign in to comment.