Skip to content

Commit

Permalink
PduEditor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Warxim committed Sep 6, 2020
1 parent 2af7049 commit b290a48
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [1.2.3] - 2020-09-01
### Added
- PduEditor bug fix

## [1.2.2] - 2020-08-05
### Added
- minor bug fixes
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/warxim/petep/common/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@PetepAPI
public final class Constant {
// PETEP version
public static final String VERSION = "1.2.2";
public static final String VERSION = "1.2.3";

// PETEP web
public static final String WEB = "http://petep.warxim.com/";
Expand All @@ -44,9 +44,8 @@ public final class Constant {
public static final String INTERCEPTORS_S2C_CONFIG_FILE = "interceptors-S2C.json";

// Internal extensions
public static final List<String> INTERNAL_EXTENSIONS =
Collections.unmodifiableList(Arrays.asList("logger", "tcp", "http", "external_http_proxy",
"test", "connection_view", "tagger", "catcher", "modifier"));
public static final List<String> INTERNAL_EXTENSIONS = Collections.unmodifiableList(Arrays.asList("logger", "tcp",
"http", "external_http_proxy", "test", "connection_view", "tagger", "catcher", "modifier"));

// Configuration items
public static final String CONFIG_ITEM_FACTORY = "factory";
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/warxim/petep/core/PETEP.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ private boolean runPrepare() {
Logger.getGlobal().info("PETEP preparing...");
state = PetepState.PREPARING;

if (!proxyExecutor.prepare() || !interceptorExecutorC2S.prepare()
|| !interceptorExecutorS2C.prepare()) {
if (!proxyExecutor.prepare() || !interceptorExecutorC2S.prepare() || !interceptorExecutorS2C.prepare()) {
return false;
}

Expand Down Expand Up @@ -195,16 +194,14 @@ public void processS2C(PDU pdu) {
}

/**
* Processes PDU internally in direction C2S and start in specified interceptor. (Client ->
* Server)
* Processes PDU internally in direction C2S and start in specified interceptor. (Client -> Server)
*/
public void processC2S(PDU pdu, int interceptorId) {
interceptorExecutorC2S.intercept(pdu, interceptorId);
}

/**
* Processes PDU internally in direction S2C and start in specified interceptor. (Client <-
* Server)
* Processes PDU internally in direction S2C and start in specified interceptor. (Client <- Server)
*/
public void processS2C(PDU pdu, int interceptorId) {
interceptorExecutorS2C.intercept(pdu, interceptorId);
Expand Down
32 changes: 12 additions & 20 deletions src/main/java/com/warxim/petep/gui/control/PduEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public PduEditor() throws IOException {
loader.setClassLoader(getClass().getClassLoader());
loader.load();

destinationInput
.setItems(FXCollections.observableArrayList(PduDestination.CLIENT, PduDestination.SERVER));
destinationInput.setItems(FXCollections.observableArrayList(PduDestination.CLIENT, PduDestination.SERVER));

connectionInput.focusedProperty().addListener(this::onConnectionFocusChange);
proxyInput.valueProperty().addListener(this::onProxyChange);
Expand All @@ -110,18 +109,14 @@ public PduEditor() throws IOException {
}

/** Loads selected proxy interface. */
private void onProxyChange(
ObservableValue<? extends Proxy> observable,
Proxy oldValue,
Proxy newValue) {
private void onProxyChange(ObservableValue<? extends Proxy> observable, Proxy oldValue, Proxy newValue) {
if (newValue == null) {
return;
}

connectionInput.getSelectionModel().clearSelection();

if (oldValue == null
|| oldValue.getModule().getFactory() != newValue.getModule().getFactory()) {
if (oldValue == null || oldValue.getModule().getFactory() != newValue.getModule().getFactory()) {
loadMetadataPane(newValue);
}
}
Expand All @@ -144,10 +139,7 @@ private void onConnectionFocusChange(
}

/** Shows/hides flow editor. */
private void onFlowChange(
ObservableValue<? extends Boolean> observable,
boolean oldValue,
boolean newValue) {
private void onFlowChange(ObservableValue<? extends Boolean> observable, boolean oldValue, boolean newValue) {
proxyInput.setDisable(oldValue);
destinationInput.setDisable(oldValue);
connectionInput.setDisable(oldValue);
Expand All @@ -160,9 +152,9 @@ private void onDestinationChange(
PduDestination oldValue,
PduDestination newValue) {
if (newValue == PduDestination.CLIENT) {
interceptorInput.setItems(interceptorsC2S);
} else {
interceptorInput.setItems(interceptorsS2C);
} else {
interceptorInput.setItems(interceptorsC2S);
}
}

Expand Down Expand Up @@ -219,11 +211,11 @@ public PDU getPdu() {

if (!metadataPane.getChildren().isEmpty()) {
PduMetadataPane pane = ((PduMetadataPane) metadataPane.getChildren().get(0));
pdu = pane.getPdu(proxyInput.getValue(), connectionInput.getValue(),
destinationInput.getValue(), dataInput.getBytes(), dataInput.getBytes().length);
pdu = pane.getPdu(proxyInput.getValue(), connectionInput.getValue(), destinationInput.getValue(),
dataInput.getBytes(), dataInput.getBytes().length);
} else {
pdu = new DefaultPdu(proxyInput.getValue(), connectionInput.getValue(),
destinationInput.getValue(), dataInput.getBytes(), dataInput.getBytes().length);
pdu = new DefaultPdu(proxyInput.getValue(), connectionInput.getValue(), destinationInput.getValue(),
dataInput.getBytes(), dataInput.getBytes().length);
}

pdu.setCharset(dataInput.getCharset());
Expand Down Expand Up @@ -256,9 +248,9 @@ public void setPdu(PDU pdu) {
connectionInput.getSelectionModel().select(pdu.getConnection());

if (pdu.getDestination() == PduDestination.CLIENT) {
interceptorInput.setItems(interceptorsC2S);
} else {
interceptorInput.setItems(interceptorsS2C);
} else {
interceptorInput.setItems(interceptorsC2S);
}

if (pdu.getLastInterceptor() == null) {
Expand Down

0 comments on commit b290a48

Please sign in to comment.