Rebuild UI with JSwing
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Main-Class: ovh.alexisdelhaie.endpoint.Main
|
|
||||||
|
|
||||||
18
src/ovh/alexisdelhaie/endpoint/Application.java
Normal file
18
src/ovh/alexisdelhaie/endpoint/Application.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package ovh.alexisdelhaie.endpoint;
|
||||||
|
|
||||||
|
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws UnsupportedLookAndFeelException {
|
||||||
|
UIManager.setLookAndFeel(new FlatIntelliJLaf());
|
||||||
|
MainWindow dialog = new MainWindow();
|
||||||
|
dialog.pack();
|
||||||
|
dialog.setTitle("EndPoint");
|
||||||
|
dialog.setVisible(true);
|
||||||
|
dialog.centerFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package ovh.alexisdelhaie.endpoint;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import ovh.alexisdelhaie.endpoint.controllers.Controller;
|
|
||||||
|
|
||||||
public class Main extends Application {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage primaryStage) throws Exception{
|
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainwindow.fxml"));
|
|
||||||
Parent root = loader.load();
|
|
||||||
Controller controller = loader.getController();
|
|
||||||
controller.setStageAndSetupListeners(primaryStage);
|
|
||||||
primaryStage.setTitle("EndPoint");
|
|
||||||
primaryStage.setScene(new Scene(root, 1067, 644));
|
|
||||||
primaryStage.setMinWidth(1067);
|
|
||||||
primaryStage.setMinHeight(644);
|
|
||||||
primaryStage.setMaximized(true);
|
|
||||||
primaryStage.getIcons().add( new Image(
|
|
||||||
Main.class.getResourceAsStream( "icon.png" )));
|
|
||||||
primaryStage.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
61
src/ovh/alexisdelhaie/endpoint/MainWindow.form
Normal file
61
src/ovh/alexisdelhaie/endpoint/MainWindow.form
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ovh.alexisdelhaie.endpoint.MainWindow">
|
||||||
|
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="48" y="54" width="1098" height="665"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="d63fe" class="javax.swing.JComboBox" binding="comboBox1" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<model>
|
||||||
|
<item value="GET"/>
|
||||||
|
<item value="POST"/>
|
||||||
|
<item value="PUT"/>
|
||||||
|
<item value="DELETE"/>
|
||||||
|
<item value="HEAD"/>
|
||||||
|
</model>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="4f0bf" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="842fb" class="javax.swing.JButton" binding="sendButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Send"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<tabbedpane id="59105" binding="tabbedPane1" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="200" height="200"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children/>
|
||||||
|
</tabbedpane>
|
||||||
|
<component id="269e7" class="javax.swing.JButton" binding="newTabButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="+"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
95
src/ovh/alexisdelhaie/endpoint/MainWindow.java
Normal file
95
src/ovh/alexisdelhaie/endpoint/MainWindow.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package ovh.alexisdelhaie.endpoint;
|
||||||
|
|
||||||
|
import ovh.alexisdelhaie.endpoint.builder.TabBuilder;
|
||||||
|
import ovh.alexisdelhaie.endpoint.configuration.ConfigurationProperties;
|
||||||
|
import ovh.alexisdelhaie.endpoint.http.HttpClient;
|
||||||
|
import ovh.alexisdelhaie.endpoint.http.Request;
|
||||||
|
import ovh.alexisdelhaie.endpoint.http.RequestBuilder;
|
||||||
|
import ovh.alexisdelhaie.endpoint.http.Response;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class MainWindow extends JFrame {
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
public final static int WIDTH = 1280;
|
||||||
|
public final static int HEIGHT = 720;
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JComboBox<String> comboBox1;
|
||||||
|
private JTextField textField1;
|
||||||
|
private JButton sendButton;
|
||||||
|
private JTabbedPane tabbedPane1;
|
||||||
|
private JButton newTabButton;
|
||||||
|
|
||||||
|
private ConfigurationProperties props;
|
||||||
|
|
||||||
|
public MainWindow() {
|
||||||
|
props = new ConfigurationProperties();
|
||||||
|
setContentPane(contentPane);
|
||||||
|
setMinimumSize(new Dimension(WIDTH, HEIGHT));
|
||||||
|
setSize(WIDTH, HEIGHT);
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
TabBuilder.create(tabbedPane1, "New request");
|
||||||
|
newTabButton.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
super.mouseClicked(e);
|
||||||
|
TabBuilder.create(tabbedPane1, "New request");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sendButton.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
super.mouseClicked(e);
|
||||||
|
try {
|
||||||
|
sendRequest();
|
||||||
|
} catch (IOException | NoSuchAlgorithmException | KeyManagementException ioException) {
|
||||||
|
ioException.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void centerFrame() {
|
||||||
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
int y = (int)( screen.getHeight() / 2 ) - this.getHeight() / 2;
|
||||||
|
int x = (int)( screen.getWidth() / 2 ) - this.getWidth() / 2;
|
||||||
|
this.setLocation(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendRequest() throws IOException, NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
Optional<JSplitPane> possibleTab = getSelectedTab();
|
||||||
|
if (possibleTab.isPresent()) {
|
||||||
|
JSplitPane tab = possibleTab.get();
|
||||||
|
String url = textField1.getText();
|
||||||
|
HttpClient h = new HttpClient(props);
|
||||||
|
Request r = new RequestBuilder(url)
|
||||||
|
.build();
|
||||||
|
Optional<Response> possibleRes = h.get(r);
|
||||||
|
if (possibleRes.isPresent()) {
|
||||||
|
Response res = possibleRes.get();
|
||||||
|
int i = tabbedPane1.indexOfComponent(tab);
|
||||||
|
JTextArea t = TabBuilder.getResponseArea(i);
|
||||||
|
t.setText(res.getBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<JSplitPane> getSelectedTab() {
|
||||||
|
Component c = tabbedPane1.getSelectedComponent();
|
||||||
|
if (c instanceof JSplitPane) {
|
||||||
|
return Optional.of((JSplitPane) c);
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
95
src/ovh/alexisdelhaie/endpoint/builder/TabBuilder.java
Normal file
95
src/ovh/alexisdelhaie/endpoint/builder/TabBuilder.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package ovh.alexisdelhaie.endpoint.builder;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TabBuilder {
|
||||||
|
|
||||||
|
private static HashMap<String, Component> indexes = new HashMap<>();
|
||||||
|
|
||||||
|
public static void create(JTabbedPane tab, String label) {
|
||||||
|
Component c = tab.add("", buildMainPanel());
|
||||||
|
int index = tab.indexOfComponent(c);
|
||||||
|
updateIndexes(index);
|
||||||
|
tab.setTabComponentAt(index, buildTabPanel(tab, c, label));
|
||||||
|
tab.setSelectedComponent(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void updateIndexes(int index) {
|
||||||
|
indexes.put("main[" + index + "].responseTextArea", indexes.get("main[waiting].responseTextArea"));
|
||||||
|
indexes.remove("main[waiting].responseTextArea");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JPanel buildTabPanel(JTabbedPane tab, Component c, String label) {
|
||||||
|
JPanel p = new JPanel(new GridBagLayout());
|
||||||
|
p.setOpaque(false);
|
||||||
|
JLabel l = new JLabel(label);
|
||||||
|
GridBagConstraints g = new GridBagConstraints();
|
||||||
|
g.gridx = 0;
|
||||||
|
g.gridy = 0;
|
||||||
|
g.weightx = 1;
|
||||||
|
p.add(l, g);
|
||||||
|
g.gridx++;
|
||||||
|
g.weightx = 0;
|
||||||
|
p.add(buildCloseButton(tab, c), g);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JButton buildCloseButton(JTabbedPane tab, Component c) {
|
||||||
|
JButton b = new JButton("×");
|
||||||
|
b.setBorderPainted(false);
|
||||||
|
b.setFocusPainted(false);
|
||||||
|
b.setOpaque(false);
|
||||||
|
b.setContentAreaFilled(false);
|
||||||
|
b.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
super.mouseClicked(e);
|
||||||
|
tab.remove(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JSplitPane buildMainPanel() {
|
||||||
|
JTextArea t = new JTextArea();
|
||||||
|
t.setBackground(Color.WHITE);
|
||||||
|
t.setEditable(false);
|
||||||
|
JScrollPane sp = new JScrollPane(t);
|
||||||
|
indexes.put("main[waiting].responseTextArea", t);
|
||||||
|
return new JSplitPane(
|
||||||
|
JSplitPane.VERTICAL_SPLIT,
|
||||||
|
buildParametersTabbedPane(),
|
||||||
|
sp
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JTabbedPane buildParametersTabbedPane() {
|
||||||
|
JTabbedPane p = new JTabbedPane();
|
||||||
|
p.add("Params", buildTable());
|
||||||
|
p.add("Authorization", new JPanel());
|
||||||
|
p.add("Headers", buildTable());
|
||||||
|
p.add("Body", new JTextArea());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JTable buildTable() {
|
||||||
|
JTable t = new JTable();
|
||||||
|
TableColumn keyCol = new TableColumn();
|
||||||
|
keyCol.setHeaderValue("Keys");
|
||||||
|
TableColumn valCol = new TableColumn();
|
||||||
|
valCol.setHeaderValue("Values");
|
||||||
|
t.addColumn(keyCol);
|
||||||
|
t.addColumn(valCol);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JTextArea getResponseArea(int index) {
|
||||||
|
return (JTextArea) indexes.get("main[" + index + "].responseTextArea");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package ovh.alexisdelhaie.endpoint.configuration;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javafx.scene.control.Alert;
|
import ovh.alexisdelhaie.endpoint.utils.MessageDialog;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -56,11 +56,7 @@ public class ConfigurationProperties {
|
|||||||
try {
|
try {
|
||||||
mapper.writeValue(new File(filepath), properties);
|
mapper.writeValue(new File(filepath), properties);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
MessageDialog.error("Cannot save settings", "There was an error while saving settings file");
|
||||||
alert.setTitle("Cannot save settings");
|
|
||||||
alert.setHeaderText("There was an error while saving settings file");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +67,7 @@ public class ConfigurationProperties {
|
|||||||
properties = mapper.readValue(f, new TypeReference<Map<String, String>>() { });
|
properties = mapper.readValue(f, new TypeReference<Map<String, String>>() { });
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
MessageDialog.error("Cannot initialize settings", "There was an error while initializing settings file");
|
||||||
alert.setTitle("Cannot initialize settings");
|
|
||||||
alert.setHeaderText("There was an error while initializing settings file");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,11 +80,7 @@ public class ConfigurationProperties {
|
|||||||
Files.createDirectories(path);
|
Files.createDirectories(path);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
MessageDialog.error("Cannot create app folder", "There was an error while creating appdata folder");
|
||||||
alert.setTitle("Cannot create app folder");
|
|
||||||
alert.setHeaderText("There was an error while creating appdata folder");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
package ovh.alexisdelhaie.endpoint.controllers;
|
|
||||||
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Alert;
|
|
||||||
import javafx.scene.control.CheckBox;
|
|
||||||
import javafx.scene.control.ChoiceBox;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import javafx.stage.Modality;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import ovh.alexisdelhaie.endpoint.configuration.ConfigurationProperties;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ConfigurationController
|
|
||||||
{
|
|
||||||
|
|
||||||
private ConfigurationProperties configurationProperties;
|
|
||||||
private Stage primaryStage;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CheckBox allowInvalidSsl;
|
|
||||||
@FXML
|
|
||||||
private CheckBox allowDowngrade;
|
|
||||||
@FXML
|
|
||||||
private ChoiceBox<String> httpVersion;
|
|
||||||
|
|
||||||
public void setStageAndSetupListeners(Stage s) {
|
|
||||||
primaryStage = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfigurationProperties(ConfigurationProperties properties) {
|
|
||||||
String[] versions = { "HTTP/1.1", "HTTP/1.0" };
|
|
||||||
httpVersion.setItems(FXCollections.observableArrayList(versions));
|
|
||||||
configurationProperties = properties;
|
|
||||||
allowInvalidSsl.setSelected(properties.getBooleanProperty("allowInvalidSsl", false));
|
|
||||||
allowDowngrade.setSelected(properties.getBooleanProperty("allowDowngrade", true));
|
|
||||||
httpVersion.setValue(properties.getStringProperty("httpVersion", versions[0]));
|
|
||||||
httpVersion.setOnAction(this::onChoiceBoxValueChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void onBooleanValueChanged(MouseEvent event) {
|
|
||||||
CheckBox c = (CheckBox) event.getSource();
|
|
||||||
configurationProperties.setProperty(c.getId(), String.valueOf(c.isSelected()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void onChoiceBoxValueChanged(ActionEvent event) {
|
|
||||||
ChoiceBox<String> c = (ChoiceBox<String>) event.getSource();
|
|
||||||
configurationProperties.setProperty(c.getId(), c.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void showAboutDialog() {
|
|
||||||
try {
|
|
||||||
Stage dialog = new Stage();
|
|
||||||
Parent xml = FXMLLoader.load(getClass().getResource("about.fxml"));
|
|
||||||
dialog.initOwner(primaryStage);
|
|
||||||
dialog.setScene(new Scene(xml, 707, 365));
|
|
||||||
dialog.setMaxHeight(365);
|
|
||||||
dialog.setMinHeight(365);
|
|
||||||
dialog.setMaxWidth(707);
|
|
||||||
dialog.setMinWidth(707);
|
|
||||||
dialog.setResizable(false);
|
|
||||||
dialog.setTitle("About EndPoint");
|
|
||||||
dialog.getIcons().add( new Image(
|
|
||||||
Controller.class.getResourceAsStream( "icon.png" )));
|
|
||||||
dialog.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
dialog.showAndWait();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
||||||
alert.setTitle("Cannot initialize About");
|
|
||||||
alert.setHeaderText("There was an error while initializing this dialog");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,471 +0,0 @@
|
|||||||
package ovh.alexisdelhaie.endpoint.controllers;
|
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.geometry.Orientation;
|
|
||||||
import javafx.scene.Node;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.*;
|
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import javafx.stage.Modality;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import org.apache.commons.validator.routines.UrlValidator;
|
|
||||||
import ovh.alexisdelhaie.endpoint.configuration.ConfigurationProperties;
|
|
||||||
import ovh.alexisdelhaie.endpoint.http.HttpClient;
|
|
||||||
import ovh.alexisdelhaie.endpoint.http.Request;
|
|
||||||
import ovh.alexisdelhaie.endpoint.http.RequestBuilder;
|
|
||||||
import ovh.alexisdelhaie.endpoint.http.Response;
|
|
||||||
import ovh.alexisdelhaie.endpoint.impl.EditCell;
|
|
||||||
import ovh.alexisdelhaie.endpoint.model.Param;
|
|
||||||
import ovh.alexisdelhaie.endpoint.url.URLGenerator;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.KeyManagementException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class Controller implements Initializable {
|
|
||||||
|
|
||||||
private enum StatusColor {
|
|
||||||
INFORMATION("#53baf5"),
|
|
||||||
SUCCESS("#7ccf16"),
|
|
||||||
REDIRECTION("#b153f5"),
|
|
||||||
ERROR_CLIENT("#f5ca53"),
|
|
||||||
ERROR_SERVER("#f55353"),
|
|
||||||
DEFAULT("BLACK");
|
|
||||||
|
|
||||||
private final String hex;
|
|
||||||
|
|
||||||
StatusColor(String s) {
|
|
||||||
hex = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHex() {
|
|
||||||
return hex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum RequestTab {
|
|
||||||
PARAMS(0),
|
|
||||||
AUTHORIZATION(1),
|
|
||||||
HEADERS(2),
|
|
||||||
BODY(3),
|
|
||||||
RESPONSE(4);
|
|
||||||
|
|
||||||
private final int index;
|
|
||||||
|
|
||||||
RequestTab (int i) { index = i; }
|
|
||||||
public int getIndex() { return index; }
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ChoiceBox<String> httpMethod;
|
|
||||||
@FXML
|
|
||||||
private TabPane tabs;
|
|
||||||
@FXML
|
|
||||||
private TextField requestInput;
|
|
||||||
@FXML
|
|
||||||
private Pane runningIndicatorPane;
|
|
||||||
|
|
||||||
private Stage primaryStage;
|
|
||||||
private HashMap<Integer, String> requests;
|
|
||||||
private HashMap<Integer, String> methods;
|
|
||||||
|
|
||||||
private ConfigurationProperties properties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
properties = new ConfigurationProperties();
|
|
||||||
requests = new HashMap<>();
|
|
||||||
methods = new HashMap<>();
|
|
||||||
String[] method = { "GET", "POST", "HEAD", "PUT", "DELETE" };
|
|
||||||
httpMethod.setItems(FXCollections.observableArrayList(method));
|
|
||||||
httpMethod.setValue(method[0]);
|
|
||||||
httpMethod.setOnAction(actionEvent -> httpMethodChanged());
|
|
||||||
tabs.getSelectionModel().selectedItemProperty().addListener(
|
|
||||||
(ov, t, t1) -> {
|
|
||||||
requestInput.setText((t1 != null) ? requests.get(t1.hashCode()) : "");
|
|
||||||
httpMethod.setValue((t1 != null) ? methods.get(t1.hashCode()) : httpMethod.getValue());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
createNewTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Tab newTab() {
|
|
||||||
SplitPane sp = new SplitPane();
|
|
||||||
|
|
||||||
Tab params = new Tab("Params", createParamTable());
|
|
||||||
Tab auth = new Tab("Authorization");
|
|
||||||
Tab headers = new Tab("Headers", createParamTable());
|
|
||||||
Tab body = new Tab("Body", new TextArea());
|
|
||||||
Tab response = new Tab("Response", createResponseTab());
|
|
||||||
|
|
||||||
TabPane options = new TabPane();
|
|
||||||
TextArea ta = new TextArea();
|
|
||||||
ta.setEditable(false);
|
|
||||||
|
|
||||||
options.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
|
|
||||||
options.getTabs().addAll(params, auth, headers, body, response);
|
|
||||||
sp.getItems().add(options);
|
|
||||||
sp.getItems().add(ta);
|
|
||||||
sp.setOrientation(Orientation.VERTICAL);
|
|
||||||
|
|
||||||
Tab tab = new Tab("untitled", sp);
|
|
||||||
tab.setOnCloseRequest(arg0 -> {
|
|
||||||
requests.remove(tab.hashCode());
|
|
||||||
methods.remove(tab.hashCode());
|
|
||||||
});
|
|
||||||
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private ScrollPane createResponseTab() {
|
|
||||||
ScrollPane sp = new ScrollPane();
|
|
||||||
Pane p = new Pane();
|
|
||||||
sp.setContent(p);
|
|
||||||
try {
|
|
||||||
Parent xml = FXMLLoader.load(getClass().getResource("responsetab.fxml"));
|
|
||||||
p.getChildren().add(xml);
|
|
||||||
TableView<Param> headers = (TableView<Param>) p.lookup("#headers");
|
|
||||||
headers.getColumns().get(0).setCellValueFactory(new PropertyValueFactory<>("name"));
|
|
||||||
headers.getColumns().get(1).setCellValueFactory(new PropertyValueFactory<>("value"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
return sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TableView<Param> createParamTable() {
|
|
||||||
TableView<Param> paramsTable = new TableView<>();
|
|
||||||
|
|
||||||
TableColumn<Param, String> name = createColumn("Name", Param::name);
|
|
||||||
TableColumn<Param, String> value = createColumn("Value", Param::value);
|
|
||||||
|
|
||||||
name.prefWidthProperty().bind(paramsTable.widthProperty().multiply(0.5));
|
|
||||||
value.prefWidthProperty().bind(paramsTable.widthProperty().multiply(0.5));
|
|
||||||
|
|
||||||
name.setOnEditCommit(t -> {
|
|
||||||
TableView<Param> tv = t.getTableView();
|
|
||||||
t.getRowValue().name().set(t.getNewValue());
|
|
||||||
manageEmptyCells(t, tv);
|
|
||||||
});
|
|
||||||
value.setOnEditCommit(t -> {
|
|
||||||
TableView<Param> tv = t.getTableView();
|
|
||||||
t.getRowValue().value().set(t.getNewValue());
|
|
||||||
manageEmptyCells(t, tv);
|
|
||||||
});
|
|
||||||
|
|
||||||
paramsTable.getColumns().add(name);
|
|
||||||
paramsTable.getColumns().add(value);
|
|
||||||
|
|
||||||
paramsTable.setEditable(true);
|
|
||||||
paramsTable.getItems().add(new Param());
|
|
||||||
|
|
||||||
return paramsTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void manageEmptyCells(TableColumn.CellEditEvent<Param, String> t, TableView<Param> tv) {
|
|
||||||
if (t.getRowValue().isEmpty() && tv.getItems().size() > 1) {
|
|
||||||
tv.getItems().remove(t.getRowValue());
|
|
||||||
}
|
|
||||||
if (!tv.getItems().get(tv.getItems().size() - 1).isEmpty()) {
|
|
||||||
tv.getItems().add(new Param());
|
|
||||||
}
|
|
||||||
requestInput.setText(URLGenerator.processNewUrl(getParamsMap(), requestInput.getText()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private TableColumn<Param, String> createColumn(String title, Function<Param, StringProperty> property) {
|
|
||||||
TableColumn<Param, String> col = new TableColumn<>(title);
|
|
||||||
col.setCellValueFactory(cellData -> property.apply(cellData.getValue()));
|
|
||||||
|
|
||||||
col.setCellFactory(column -> EditCell.createStringEditCell());
|
|
||||||
return col ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void start() {
|
|
||||||
if (requestInput.getText().isBlank()) {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
|
||||||
alert.setTitle("URL field empty");
|
|
||||||
alert.setContentText("Enter your URL in the field at the top of the window.");
|
|
||||||
alert.showAndWait();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
runningIndicatorPane.setVisible(true);
|
|
||||||
new Thread(() -> {
|
|
||||||
final String method = httpMethod.getValue();
|
|
||||||
Optional<TextArea> textArea = getCurrentTextArea();
|
|
||||||
Optional<Response> response = Optional.empty();
|
|
||||||
if (textArea.isPresent()) {
|
|
||||||
try {
|
|
||||||
Request r = new RequestBuilder(requestInput.getText())
|
|
||||||
.setCustomHeaders(getCustomHeaders())
|
|
||||||
.build();
|
|
||||||
HttpClient hc = new HttpClient(properties);
|
|
||||||
switch (method) {
|
|
||||||
case "GET" -> response = hc.get(r);
|
|
||||||
case "POST" -> response = hc.post(r, getBody());
|
|
||||||
case "PUT" -> response = hc.put(r, getBody());
|
|
||||||
case "DELETE" -> response = hc.delete(r);
|
|
||||||
case "HEAD" -> response = hc.head(r);
|
|
||||||
}
|
|
||||||
if (response.isPresent()) {
|
|
||||||
final Response res = response.get();
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
textArea.get().setStyle(null);
|
|
||||||
textArea.get().setText(res.getBody());
|
|
||||||
updateResponseTab(res);
|
|
||||||
setSelectedTab(RequestTab.RESPONSE);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException e) {
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
textArea.ifPresent(area -> Platform.runLater(() -> {
|
|
||||||
resetResponseTab();
|
|
||||||
area.setStyle("-fx-text-fill: red");
|
|
||||||
area.setText("Somethings went wrong: " + e.getMessage());
|
|
||||||
}));
|
|
||||||
} finally {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
runningIndicatorPane.setVisible(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
runningIndicatorPane.setVisible(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void updateResponseTab(Response res) {
|
|
||||||
Optional<Tab> responseTab = getCurrentResponseTab();
|
|
||||||
if (responseTab.isPresent()) {
|
|
||||||
Label status = (Label) responseTab.get().getContent().lookup("#status");
|
|
||||||
status.setText(String.format("%s %s", res.getStatusCode(), res.getStatus()));
|
|
||||||
if (res.getStatusCode() >= 100 && res.getStatusCode() < 200) {
|
|
||||||
status.setTextFill(Color.web(StatusColor.INFORMATION.getHex()));
|
|
||||||
} else if (res.getStatusCode() >= 200 && res.getStatusCode() < 300) {
|
|
||||||
status.setTextFill(Color.web(StatusColor.SUCCESS.getHex()));
|
|
||||||
} else if (res.getStatusCode() >= 300 && res.getStatusCode() < 400) {
|
|
||||||
status.setTextFill(Color.web(StatusColor.REDIRECTION.getHex()));
|
|
||||||
} else if (res.getStatusCode() >= 400 && res.getStatusCode() < 500) {
|
|
||||||
status.setTextFill(Color.web(StatusColor.ERROR_CLIENT.getHex()));
|
|
||||||
} else if (res.getStatusCode() >= 500) {
|
|
||||||
status.setTextFill(Color.web(StatusColor.ERROR_SERVER.getHex()));
|
|
||||||
}
|
|
||||||
Label time = (Label) responseTab.get().getContent().lookup("#time");
|
|
||||||
time.setText(String.format("%s ms", res.getTime()));
|
|
||||||
TextArea raw = (TextArea) responseTab.get().getContent().lookup("#raw");
|
|
||||||
raw.setText(res.getRawResponse());
|
|
||||||
TextArea request = (TextArea) responseTab.get().getContent().lookup("#request");
|
|
||||||
request.setText(res.getRequest().getRawRequest());
|
|
||||||
GridPane downgradedIndicator = (GridPane) responseTab.get().getContent().lookup("#downgraded_indicator");
|
|
||||||
downgradedIndicator.setVisible(res.isDowngraded());
|
|
||||||
TableView<Param> headers = (TableView<Param>) responseTab.get().getContent().lookup("#headers");
|
|
||||||
headers.getItems().clear();
|
|
||||||
for (Map.Entry<String, String> entry : res.getHeaders().entrySet()) {
|
|
||||||
headers.getItems().add(new Param(entry.getKey(), entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSelectedTab(RequestTab rt) {
|
|
||||||
Optional<TabPane> options = getRequestOptionsTab();
|
|
||||||
options.ifPresent(tabPane -> tabPane.getSelectionModel().select(rt.getIndex()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void resetResponseTab() {
|
|
||||||
Optional<Tab> responseTab = getCurrentResponseTab();
|
|
||||||
if (responseTab.isPresent()) {
|
|
||||||
Label status = (Label) responseTab.get().getContent().lookup("#status");
|
|
||||||
status.setTextFill(Color.web(StatusColor.DEFAULT.getHex()));
|
|
||||||
status.setText("...");
|
|
||||||
Label time = (Label) responseTab.get().getContent().lookup("#time");
|
|
||||||
time.setText("... ms");
|
|
||||||
TextArea raw = (TextArea) responseTab.get().getContent().lookup("#raw");
|
|
||||||
raw.setText("");
|
|
||||||
TextArea request = (TextArea) responseTab.get().getContent().lookup("#request");
|
|
||||||
request.setText("");
|
|
||||||
GridPane downgradedIndicator = (GridPane) responseTab.get().getContent().lookup("#downgraded_indicator");
|
|
||||||
downgradedIndicator.setVisible(false);
|
|
||||||
TableView<Param> headers = (TableView<Param>) responseTab.get().getContent().lookup("#headers");
|
|
||||||
headers.getItems().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, String> getCustomHeaders() {
|
|
||||||
HashMap<String, String> result = new HashMap<>();
|
|
||||||
Optional<TabPane> tabs = getRequestOptionsTab();
|
|
||||||
if (tabs.isPresent()) {
|
|
||||||
Node n = tabs.get().getTabs().get(RequestTab.HEADERS.getIndex()).getContent();
|
|
||||||
toHashMap(result, n, true);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBody() {
|
|
||||||
Optional<TabPane> tabs = getRequestOptionsTab();
|
|
||||||
if (tabs.isPresent()) {
|
|
||||||
Node n = tabs.get().getTabs().get(RequestTab.BODY.getIndex()).getContent();
|
|
||||||
if (n instanceof TextArea) {
|
|
||||||
return ((TextArea) n).getText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, String> getParamsMap() {
|
|
||||||
HashMap<String, String> result = new HashMap<>();
|
|
||||||
Optional<TabPane> tabs = getRequestOptionsTab();
|
|
||||||
if (tabs.isPresent()) {
|
|
||||||
Node n = tabs.get().getTabs().get(RequestTab.PARAMS.getIndex()).getContent();
|
|
||||||
toHashMap(result, n, false);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void toHashMap(HashMap<String, String> result, Node n, boolean lowering) {
|
|
||||||
if (n instanceof TableView) {
|
|
||||||
TableView<Param> tv = (TableView<Param>) n;
|
|
||||||
for (Param p : tv.getItems()) {
|
|
||||||
if (!p.isEmpty()) {
|
|
||||||
String key = (lowering) ? p.getName().toLowerCase() : p.getName();
|
|
||||||
result.put(key, p.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<TabPane> getRequestOptionsTab() {
|
|
||||||
Optional<SplitPane> requestTab = getCurrentRequestTab();
|
|
||||||
if (requestTab.isPresent()) {
|
|
||||||
Node n = requestTab.get().getItems().get(0);
|
|
||||||
if (n instanceof TabPane) {
|
|
||||||
return Optional.of((TabPane) n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<SplitPane> getCurrentRequestTab() {
|
|
||||||
Node n = tabs.getSelectionModel().getSelectedItem().getContent();
|
|
||||||
if (n instanceof SplitPane) {
|
|
||||||
return Optional.of((SplitPane) n);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<TextArea> getCurrentTextArea() {
|
|
||||||
Optional<SplitPane> requestTab = getCurrentRequestTab();
|
|
||||||
if (requestTab.isPresent()) {
|
|
||||||
Node n = requestTab.get().getItems().get(1);//
|
|
||||||
if (n instanceof TextArea) {
|
|
||||||
return Optional.of((TextArea) n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<Tab> getCurrentResponseTab() {
|
|
||||||
Optional<TabPane> requestTab = getRequestOptionsTab();
|
|
||||||
if (requestTab.isPresent()) {
|
|
||||||
Tab n = requestTab.get().getTabs().get(RequestTab.RESPONSE.getIndex());
|
|
||||||
return Optional.of(n);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void createNewTab() {
|
|
||||||
new Thread(() -> {
|
|
||||||
Tab t = newTab();
|
|
||||||
requests.put(t.hashCode(), "");
|
|
||||||
methods.put(t.hashCode(), httpMethod.getValue());
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
tabs.getTabs().add(t);
|
|
||||||
tabs.getSelectionModel().select(t);
|
|
||||||
});
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStageAndSetupListeners(Stage s) {
|
|
||||||
primaryStage = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void showConfigurationDialog() {
|
|
||||||
try {
|
|
||||||
Stage dialog = new Stage();
|
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("configuration.fxml"));
|
|
||||||
Parent xml = loader.load();
|
|
||||||
ConfigurationController controller = loader.getController();
|
|
||||||
controller.setStageAndSetupListeners(primaryStage);
|
|
||||||
controller.setConfigurationProperties(properties);
|
|
||||||
dialog.initOwner(primaryStage);
|
|
||||||
dialog.setScene(new Scene(xml, 412, 556));
|
|
||||||
dialog.setMaxHeight(556);
|
|
||||||
dialog.setMinHeight(556);
|
|
||||||
dialog.setMaxWidth(412);
|
|
||||||
dialog.setMinWidth(412);
|
|
||||||
dialog.setResizable(false);
|
|
||||||
dialog.setTitle("Settings");
|
|
||||||
dialog.getIcons().add( new Image(
|
|
||||||
Controller.class.getResourceAsStream( "icon.png" )));
|
|
||||||
dialog.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
dialog.showAndWait();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
||||||
alert.setTitle("Cannot initialize Settings");
|
|
||||||
alert.setHeaderText("There was an error while initializing this dialog");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void httpMethodChanged() {
|
|
||||||
Tab tab = tabs.getSelectionModel().getSelectedItem();
|
|
||||||
methods.put(tab.hashCode(), httpMethod.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void requestInputOnKeyPressed() {
|
|
||||||
Tab tab = tabs.getSelectionModel().getSelectedItem();
|
|
||||||
String url = requestInput.getText();
|
|
||||||
requests.put(tab.hashCode(), url);
|
|
||||||
if (url.isBlank()) {
|
|
||||||
tab.setText("Untitled");
|
|
||||||
} else {
|
|
||||||
url = URLGenerator.addSchemaToUrl(url);
|
|
||||||
UrlValidator urlValidator = new UrlValidator();
|
|
||||||
if (urlValidator.isValid(url)) {
|
|
||||||
try {
|
|
||||||
URL u = new URL(url);
|
|
||||||
tab.setText(u.getHost());
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="365.0" prefWidth="707.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
|
||||||
<children>
|
|
||||||
<ImageView fitHeight="111.0" fitWidth="707.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<image>
|
|
||||||
<Image url="@banner.png" />
|
|
||||||
</image></ImageView>
|
|
||||||
<GridPane layoutX="32.0" layoutY="123.0" prefHeight="224.0" prefWidth="348.0">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label text="Author: Alexis Delhaie (@alexlegarnd)">
|
|
||||||
<font>
|
|
||||||
<Font size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="Software: Java 14.0.2 (GUI: JavaFX 15)" GridPane.rowIndex="2">
|
|
||||||
<font>
|
|
||||||
<Font size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="Installer: Delphi 10.3.3 Community" GridPane.rowIndex="3">
|
|
||||||
<font>
|
|
||||||
<Font size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="Installer Bootstrap: Python 3.8.5 [MSC v.1924 (AMD64)]" GridPane.rowIndex="4">
|
|
||||||
<font>
|
|
||||||
<Font size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="Version: 0.1.2 (Not finished)" GridPane.rowIndex="1">
|
|
||||||
<font>
|
|
||||||
<Font size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="428.0" layoutY="111.0" prefHeight="224.0" prefWidth="216.0" text=" (((///////////////////////( *(((///////////////////////// , /(///////////////////////// /((/////////////////////// /(((////////////////////// / ((((((/////////////////// (((((((((((( ((((((((///////////////// (((((((((((((((((( .((((((((((/////////////// ((((((((((((((((((((((. ((((((((((((((/////////// (((((((((((((((((((((((((( (((((((((((((((((//////// ((((((((((((((((((((((((((((. ((((((((((((((((((((///// ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((/ &(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((( (( .(((((((((((((((( #####((((((((((((((((((((((((((((( (((((((((((((((((( #########(((((((((((((((((((((((( *((((*. (((((((((((((((((((( #############((((((((((((( ((((((((((((((((( ((((((((((((((((((((( ##################(((((((((((* (((((((((((((((((((. ((((((((((((((((((( &#####################(((((((((((, (((((((((((((((((((( (((((((((((((((( #########################(((((((( (((((((((((((((( ((((((((((((((( #############################((. ((((((((((/ /((((((((((((( ############################## ((((( (((((((((((( ############################# *((((((((((( ############################# ((((((((((( ############################ (((((((((( ############################ (((((((((( ############################, ((((((((((( ############################### #########(((( ############################################# ##################################### ######################### " textAlignment="CENTER" AnchorPane.bottomAnchor="30.0" AnchorPane.rightAnchor="63.0" AnchorPane.topAnchor="111.0">
|
|
||||||
<font>
|
|
||||||
<Font name="Consolas" size="4.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.CheckBox?>
|
|
||||||
<?import javafx.scene.control.ChoiceBox?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="556.0" maxWidth="412.0" minHeight="556.0" minWidth="412.0" prefHeight="556.0" prefWidth="412.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ovh.alexisdelhaie.endpoint.controllers.ConfigurationController">
|
|
||||||
<Label layoutX="20.0" layoutY="14.0" text="SSL">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label layoutX="20.0" layoutY="40.0" prefHeight="18.0" prefWidth="148.0" text="Allow invalid SSL certificate" />
|
|
||||||
<CheckBox fx:id="allowInvalidSsl" layoutX="381.0" layoutY="41.0" mnemonicParsing="false" onMouseClicked="#onBooleanValueChanged" AnchorPane.rightAnchor="14.199999999999989" AnchorPane.topAnchor="41.0" />
|
|
||||||
<Label layoutX="20.0" layoutY="59.0" prefHeight="18.0" prefWidth="148.0" text="Downgrade when SSL failed" />
|
|
||||||
<CheckBox fx:id="allowDowngrade" layoutX="381.0" layoutY="60.0" mnemonicParsing="false" onMouseClicked="#onBooleanValueChanged" selected="true" AnchorPane.rightAnchor="14.333333333333332" AnchorPane.topAnchor="60.0" />
|
|
||||||
<Button layoutX="14.0" layoutY="515.0" mnemonicParsing="false" onMouseClicked="#showAboutDialog" prefHeight="26.0" prefWidth="58.0" text="About" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="14.0" />
|
|
||||||
<Label layoutX="20.0" layoutY="97.0" prefHeight="18.0" prefWidth="72.0" text="Requests">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label layoutX="20.0" layoutY="126.0" prefHeight="18.0" prefWidth="72.0" text="HTTP version" />
|
|
||||||
<ChoiceBox fx:id="httpVersion" layoutX="308.0" layoutY="123.0" prefHeight="26.0" prefWidth="90.0" />
|
|
||||||
</AnchorPane>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
@@ -1,75 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
|
|
||||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="890.0" prefWidth="1149.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="0.0" prefWidth="19.33333381017049" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="344.3333333333333" minWidth="10.0" prefWidth="55.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="648.6666781107585" minWidth="10.0" prefWidth="359.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="668.0" minWidth="5.333333333333314" prefWidth="17.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="678.0" minWidth="10.0" prefWidth="674.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="632.6666361490886" minWidth="10.0" prefWidth="23.0" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints maxHeight="128.00000762939453" minHeight="0.0" prefHeight="1.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="128.00000762939453" minHeight="0.0" prefHeight="16.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="201.0" minHeight="0.0" prefHeight="17.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="636.0" minHeight="10.0" prefHeight="461.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="188.0" minHeight="8.0" prefHeight="23.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="333.0" minHeight="10.0" prefHeight="326.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label text="Time" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
|
||||||
<Label text="Status" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
|
||||||
<Label fx:id="status" text="..." GridPane.columnIndex="2" GridPane.rowIndex="1">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font></Label>
|
|
||||||
<Label fx:id="time" text="... ms" GridPane.columnIndex="2" GridPane.rowIndex="2">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font></Label>
|
|
||||||
<TableView fx:id="headers" prefHeight="321.0" prefWidth="599.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="3">
|
|
||||||
<columns>
|
|
||||||
<TableColumn prefWidth="75.0" text="Key" />
|
|
||||||
<TableColumn prefWidth="75.0" text="Value" />
|
|
||||||
</columns>
|
|
||||||
<columnResizePolicy>
|
|
||||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
|
||||||
</columnResizePolicy>
|
|
||||||
</TableView>
|
|
||||||
<TextArea fx:id="raw" editable="false" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="4" GridPane.rowIndex="3">
|
|
||||||
<font>
|
|
||||||
<Font name="Consolas" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</TextArea>
|
|
||||||
<Label text="Raw" GridPane.columnIndex="4" GridPane.rowIndex="2" />
|
|
||||||
<TextArea fx:id="request" editable="false" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="4" GridPane.rowIndex="5">
|
|
||||||
<font>
|
|
||||||
<Font name="Consolas" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</TextArea>
|
|
||||||
<Label text="Sent request" GridPane.columnIndex="4" GridPane.rowIndex="4" />
|
|
||||||
<GridPane fx:id="downgraded_indicator" visible="false" GridPane.columnIndex="4" GridPane.rowIndex="1">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="382.0" minWidth="10.0" prefWidth="30.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="644.0" minWidth="10.0" prefWidth="644.0" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label prefHeight="17.0" prefWidth="354.0" text="This request was downgraded from SSL to plain text" textFill="#cfa600" GridPane.columnIndex="1" />
|
|
||||||
<Label alignment="CENTER" contentDisplay="CENTER" prefHeight="22.0" prefWidth="37.0" text="" textAlignment="CENTER" textFill="#cfa600">
|
|
||||||
<font>
|
|
||||||
<Font name="Segoe MDL2 Assets" size="20.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
@@ -22,7 +22,7 @@ public class HttpClient {
|
|||||||
public final static int DEFAULT_TIMEOUT = 10000;
|
public final static int DEFAULT_TIMEOUT = 10000;
|
||||||
public final static boolean DEFAULT_ALLOW_INVALID_SSL = false;
|
public final static boolean DEFAULT_ALLOW_INVALID_SSL = false;
|
||||||
public final static boolean DEFAULT_ALLOW_DOWNGRADE = true;
|
public final static boolean DEFAULT_ALLOW_DOWNGRADE = true;
|
||||||
public final static String DEFAULT_HTTP_VERSION = "HTTP/1.1";
|
public final static String DEFAULT_HTTP_VERSION = "HTTP/1.0";
|
||||||
|
|
||||||
private final boolean allowInvalidSsl;
|
private final boolean allowInvalidSsl;
|
||||||
private final boolean allowDowngrade;
|
private final boolean allowDowngrade;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
@@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
Stolen code from Github : https://gist.github.com/james-d/be5bbd6255a4640a5357#file-editcell-java-L109
|
|
||||||
*/
|
|
||||||
package ovh.alexisdelhaie.endpoint.impl;
|
|
||||||
|
|
||||||
import javafx.event.Event;
|
|
||||||
import javafx.scene.control.ContentDisplay;
|
|
||||||
import javafx.scene.control.TableCell;
|
|
||||||
import javafx.scene.control.TableColumn;
|
|
||||||
import javafx.scene.control.TableColumn.CellEditEvent;
|
|
||||||
import javafx.scene.control.TablePosition;
|
|
||||||
import javafx.scene.control.TableView;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.scene.input.KeyCode;
|
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
import javafx.util.StringConverter;
|
|
||||||
|
|
||||||
|
|
||||||
public class EditCell<S, T> extends TableCell<S, T> {
|
|
||||||
|
|
||||||
// Text field for editing
|
|
||||||
// TODO: allow this to be a plugable control.
|
|
||||||
private final TextField textField = new TextField();
|
|
||||||
|
|
||||||
// Converter for converting the text in the text field to the user type, and vice-versa:
|
|
||||||
private final StringConverter<T> converter ;
|
|
||||||
|
|
||||||
public EditCell(StringConverter<T> converter) {
|
|
||||||
this.converter = converter ;
|
|
||||||
|
|
||||||
itemProperty().addListener((obx, oldItem, newItem) -> {
|
|
||||||
if (newItem == null) {
|
|
||||||
setText(null);
|
|
||||||
} else {
|
|
||||||
setText(converter.toString(newItem));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setGraphic(textField);
|
|
||||||
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
|
||||||
|
|
||||||
textField.setOnAction(evt -> {
|
|
||||||
commitEdit(this.converter.fromString(textField.getText()));
|
|
||||||
});
|
|
||||||
textField.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> {
|
|
||||||
if (! isNowFocused) {
|
|
||||||
commitEdit(this.converter.fromString(textField.getText()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
textField.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
|
||||||
if (event.getCode() == KeyCode.ESCAPE) {
|
|
||||||
textField.setText(converter.toString(getItem()));
|
|
||||||
cancelEdit();
|
|
||||||
event.consume();
|
|
||||||
} else if (event.getCode() == KeyCode.RIGHT) {
|
|
||||||
getTableView().getSelectionModel().selectRightCell();
|
|
||||||
event.consume();
|
|
||||||
} else if (event.getCode() == KeyCode.LEFT) {
|
|
||||||
getTableView().getSelectionModel().selectLeftCell();
|
|
||||||
event.consume();
|
|
||||||
} else if (event.getCode() == KeyCode.UP) {
|
|
||||||
getTableView().getSelectionModel().selectAboveCell();
|
|
||||||
event.consume();
|
|
||||||
} else if (event.getCode() == KeyCode.DOWN) {
|
|
||||||
getTableView().getSelectionModel().selectBelowCell();
|
|
||||||
event.consume();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience converter that does nothing (converts Strings to themselves and vice-versa...).
|
|
||||||
*/
|
|
||||||
public static final StringConverter<String> IDENTITY_CONVERTER = new StringConverter<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString(String object) {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String fromString(String string) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method for creating an EditCell for a String value.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static <S> EditCell<S, String> createStringEditCell() {
|
|
||||||
return new EditCell<S, String>(IDENTITY_CONVERTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// set the text of the text field and display the graphic
|
|
||||||
@Override
|
|
||||||
public void startEdit() {
|
|
||||||
super.startEdit();
|
|
||||||
textField.setText(converter.toString(getItem()));
|
|
||||||
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
|
|
||||||
textField.requestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// revert to text display
|
|
||||||
@Override
|
|
||||||
public void cancelEdit() {
|
|
||||||
super.cancelEdit();
|
|
||||||
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// commits the edit. Update property if possible and revert to text display
|
|
||||||
@Override
|
|
||||||
public void commitEdit(T item) {
|
|
||||||
|
|
||||||
// This block is necessary to support commit on losing focus, because the baked-in mechanism
|
|
||||||
// sets our editing state to false before we can intercept the loss of focus.
|
|
||||||
// The default commitEdit(...) method simply bails if we are not editing...
|
|
||||||
if (! isEditing() && ! item.equals(getItem())) {
|
|
||||||
TableView<S> table = getTableView();
|
|
||||||
if (table != null) {
|
|
||||||
TableColumn<S, T> column = getTableColumn();
|
|
||||||
CellEditEvent<S, T> event = new CellEditEvent<>(table,
|
|
||||||
new TablePosition<S,T>(table, getIndex(), column),
|
|
||||||
TableColumn.editCommitEvent(), item);
|
|
||||||
Event.fireEvent(column, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.commitEdit(item);
|
|
||||||
|
|
||||||
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
|
|
||||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ovh.alexisdelhaie.endpoint.controllers.Controller">
|
|
||||||
<TextField fx:id="requestInput" layoutX="109.0" layoutY="39.0" onKeyTyped="#requestInputOnKeyPressed" prefHeight="25.0" prefWidth="861.0" AnchorPane.leftAnchor="109.0" AnchorPane.rightAnchor="96.99999999999989" AnchorPane.topAnchor="39.0" />
|
|
||||||
<Button layoutX="979.0" layoutY="39.0" mnemonicParsing="false" onMouseClicked="#start" prefHeight="25.0" prefWidth="73.0" text="Send" AnchorPane.rightAnchor="16.0" AnchorPane.topAnchor="39.0" />
|
|
||||||
<ChoiceBox id="httpMethod" fx:id="httpMethod" layoutX="14.0" layoutY="39.0" prefHeight="25.0" prefWidth="85.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="39.0" />
|
|
||||||
<Label layoutX="109.0" layoutY="21.0" text="Request URL" />
|
|
||||||
<TabPane fx:id="tabs" layoutX="-1.0" layoutY="104.0" prefHeight="540.0" prefWidth="1067.0" tabClosingPolicy="ALL_TABS" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="104.0">
|
|
||||||
</TabPane>
|
|
||||||
<Button layoutX="1022.0" layoutY="71.0" mnemonicParsing="false" onMouseClicked="#createNewTab" prefHeight="25.0" prefWidth="31.0" text="+" AnchorPane.rightAnchor="16.0" AnchorPane.topAnchor="71.0" />
|
|
||||||
<Button layoutX="1020.0" layoutY="8.0" mnemonicParsing="false" onMouseClicked="#showConfigurationDialog" prefHeight="25.0" prefWidth="73.0" text="Settings" AnchorPane.rightAnchor="16.0" AnchorPane.topAnchor="8.0" />
|
|
||||||
<Pane fx:id="runningIndicatorPane" layoutX="109.0" layoutY="74.0" prefHeight="17.0" prefWidth="200.0" visible="false">
|
|
||||||
<children>
|
|
||||||
<ProgressIndicator layoutX="2.0" layoutY="1.0" prefHeight="17.0" prefWidth="18.0" />
|
|
||||||
<Label layoutX="23.0" layoutY="1.0" prefHeight="17.0" prefWidth="133.0" text="Running..." />
|
|
||||||
</children>
|
|
||||||
</Pane>
|
|
||||||
</AnchorPane>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package ovh.alexisdelhaie.endpoint.model;
|
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
|
|
||||||
public class Param {
|
|
||||||
|
|
||||||
private final StringProperty _name = new SimpleStringProperty();
|
|
||||||
private final StringProperty _value = new SimpleStringProperty();
|
|
||||||
|
|
||||||
public Param() {
|
|
||||||
_name.set("");
|
|
||||||
_value.set("");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Param(String n, String v) {
|
|
||||||
_name.set(n);
|
|
||||||
_value.set(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return _name.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty name() {
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return _value.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty value() {
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return (_name.get().isBlank() && _value.get().isBlank());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
final StringBuffer sb = new StringBuffer("Param{");
|
|
||||||
sb.append("_name=").append(_name.get());
|
|
||||||
sb.append(", _value=").append(_value.get());
|
|
||||||
sb.append('}');
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
src/ovh/alexisdelhaie/endpoint/utils/MessageDialog.java
Normal file
22
src/ovh/alexisdelhaie/endpoint/utils/MessageDialog.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ovh.alexisdelhaie.endpoint.utils;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class MessageDialog {
|
||||||
|
|
||||||
|
public static void error(String title, String message) {
|
||||||
|
JOptionPane.showMessageDialog(new JFrame(), message, title,
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warning(String title, String message) {
|
||||||
|
JOptionPane.showMessageDialog(new JFrame(), message, title,
|
||||||
|
JOptionPane.WARNING_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String title, String message) {
|
||||||
|
JOptionPane.showMessageDialog(new JFrame(), message, title,
|
||||||
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user