Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0787664
commit 81422e4
Showing
6 changed files
with
160 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/src/main/java/org/adoptopenjdk/jitwatch/parser/ParserType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
package org.adoptopenjdk.jitwatch.parser; | |||
|
|||
public enum ParserType | |||
{ | |||
HOTSPOT, J9, ZING; | |||
|
|||
public String getDisplayName() | |||
{ | |||
switch (this) | |||
{ | |||
case HOTSPOT: | |||
return "HotSpot"; | |||
case J9: | |||
return "J9"; | |||
case ZING: | |||
return "Zing"; | |||
default: | |||
throw new RuntimeException("Unknown parser type"); | |||
} | |||
} | |||
|
|||
public static ParserType fromString(String input) | |||
{ | |||
if (input != null) | |||
{ | |||
switch (input.toLowerCase()) | |||
{ | |||
case "hotspot": | |||
return HOTSPOT; | |||
case "j9": | |||
return J9; | |||
case "zing": | |||
return ZING; | |||
} | |||
} | |||
|
|||
throw new RuntimeException("Unknown parser type: " + input); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
ui/src/main/java/org/adoptopenjdk/jitwatch/ui/parserchooser/IParserSelectedListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
package org.adoptopenjdk.jitwatch.ui.parserchooser; | |||
|
|||
import org.adoptopenjdk.jitwatch.parser.ParserType; | |||
|
|||
public interface IParserSelectedListener | |||
{ | |||
void parserSelected(ParserType parserType); | |||
} |
53 changes: 53 additions & 0 deletions
53
ui/src/main/java/org/adoptopenjdk/jitwatch/ui/parserchooser/ParserChooser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
/* | |||
* Copyright (c) 2018 Chris Newland. | |||
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD | |||
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki | |||
*/ | |||
|
|||
package org.adoptopenjdk.jitwatch.ui.parserchooser; | |||
|
|||
import org.adoptopenjdk.jitwatch.parser.ParserType; | |||
import javafx.beans.value.ChangeListener; | |||
import javafx.beans.value.ObservableValue; | |||
import javafx.collections.FXCollections; | |||
import javafx.collections.ObservableList; | |||
import javafx.scene.control.ComboBox; | |||
|
|||
public class ParserChooser | |||
{ | |||
private ObservableList<ParserType> parserTypeList = FXCollections.observableArrayList(); | |||
|
|||
private ComboBox<ParserType> comboParser; | |||
|
|||
public ParserChooser(final IParserSelectedListener selectionListener) | |||
{ | |||
comboParser = new ComboBox<>(parserTypeList); | |||
|
|||
clear(); | |||
|
|||
comboParser.setStyle("-fx-font-size: 10px"); | |||
|
|||
comboParser.valueProperty().addListener(new ChangeListener<ParserType>() | |||
{ | |||
@Override | |||
public void changed(ObservableValue<? extends ParserType> ov, ParserType oldVal, ParserType newVal) | |||
{ | |||
selectionListener.parserSelected(newVal); | |||
} | |||
}); | |||
} | |||
|
|||
public synchronized void clear() | |||
{ | |||
parserTypeList.clear(); | |||
|
|||
parserTypeList.addAll(ParserType.values()); | |||
|
|||
comboParser.getSelectionModel().clearSelection(); | |||
} | |||
|
|||
public ComboBox<ParserType> getCombo() | |||
{ | |||
return comboParser; | |||
} | |||
} |