Adding banner, Response tab, fix method combobox

This commit is contained in:
Alexis Delhaie
2020-10-27 22:02:13 +01:00
parent cf9aff4242
commit c4910722e9
10 changed files with 201 additions and 47 deletions

View File

@@ -6,6 +6,7 @@
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow)
{ {
int return_code = 0;
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
@@ -16,17 +17,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam
LPTSTR command = _tcsdup(TEXT(".\\runtime\\bin\\javaw.exe -cp .\\app\\EndPoint.jar ovh.alexisdelhaie.endpoint.Application")); LPTSTR command = _tcsdup(TEXT(".\\runtime\\bin\\javaw.exe -cp .\\app\\EndPoint.jar ovh.alexisdelhaie.endpoint.Application"));
if (!CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if (!CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
CloseHandle(&pi.hProcess);
CloseHandle(&pi.hThread);
int msgboxID = MessageBox( int msgboxID = MessageBox(
NULL, NULL,
TEXT("Unable to start the JVM. Try reinstalling the program to fix this problem."), TEXT("Unable to start the JVM. Try reinstalling the program to fix this problem."),
TEXT("EndPoint bootstrap"), TEXT("EndPoint bootstrap"),
MB_ICONHAND | MB_OK | MB_DEFBUTTON1 MB_ICONHAND | MB_OK | MB_DEFBUTTON1
); );
return -1; return_code = -1;
} }
CloseHandle(&pi.hProcess); CloseHandle(&pi.hProcess);
CloseHandle(&pi.hThread); CloseHandle(&pi.hThread);
return 0; return return_code;
} }

View File

@@ -116,7 +116,7 @@
</hspacer> </hspacer>
<component id="45ca1" class="javax.swing.JButton" binding="settingsButton" default-binding="true"> <component id="45ca1" class="javax.swing.JButton" binding="settingsButton" default-binding="true">
<constraints> <constraints>
<grid row="1" column="14" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="3" column="15" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Settings"/> <text value="Settings"/>

View File

@@ -8,6 +8,7 @@ import ovh.alexisdelhaie.endpoint.http.Request;
import ovh.alexisdelhaie.endpoint.http.RequestBuilder; import ovh.alexisdelhaie.endpoint.http.RequestBuilder;
import ovh.alexisdelhaie.endpoint.http.Response; import ovh.alexisdelhaie.endpoint.http.Response;
import ovh.alexisdelhaie.endpoint.utils.MessageDialog; import ovh.alexisdelhaie.endpoint.utils.MessageDialog;
import ovh.alexisdelhaie.endpoint.utils.RequestTab;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
@@ -17,9 +18,10 @@ import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -47,6 +49,7 @@ public class MainWindow extends JFrame {
// Constants // Constants
public final static int WIDTH = 1280; public final static int WIDTH = 1280;
public final static int HEIGHT = 720; public final static int HEIGHT = 720;
public final static String NEW_TAB_NAME = "New request";
private JPanel contentPane; private JPanel contentPane;
private JComboBox<String> methodBox; private JComboBox<String> methodBox;
@@ -59,25 +62,17 @@ public class MainWindow extends JFrame {
private JButton settingsButton; private JButton settingsButton;
private final ConfigurationProperties props; private final ConfigurationProperties props;
private final HashMap<Integer, String> urls; private final ConcurrentHashMap<Integer, RequestTab> tabs;
private final ConcurrentHashMap<Integer, Boolean> controlState;
private final ConcurrentHashMap<Integer, Response> responses;
public MainWindow() throws IOException { public MainWindow() throws IOException {
props = new ConfigurationProperties(); props = new ConfigurationProperties();
controlState = new ConcurrentHashMap<>(); tabs = new ConcurrentHashMap<>();
responses = new ConcurrentHashMap<>();
urls = new HashMap<>();
setIconImage(ImageIO.read(MainWindow.class.getResource("/icon.png"))); setIconImage(ImageIO.read(MainWindow.class.getResource("/icon.png")));
setContentPane(contentPane); setContentPane(contentPane);
setMinimumSize(new Dimension(WIDTH, HEIGHT)); setMinimumSize(new Dimension(WIDTH, HEIGHT));
setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TabBuilder.create(tabbedPane1, "New request", urls, urlField); newTab();
Component tab = tabbedPane1.getSelectedComponent();
urls.put(tab.hashCode(), "");
enableControl(true, tab.hashCode());
settingsButton.addMouseListener(new MouseAdapter() { settingsButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@@ -89,11 +84,7 @@ public class MainWindow extends JFrame {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
TabBuilder.create(tabbedPane1, "New request", urls, urlField); newTab();
Component tab = tabbedPane1.getSelectedComponent();
urls.put(tab.hashCode(), "");
enableControl(true, tab.hashCode());
showStatus(tab.hashCode());
} }
}); });
sendButton.addMouseListener(new MouseAdapter() { sendButton.addMouseListener(new MouseAdapter() {
@@ -110,9 +101,22 @@ public class MainWindow extends JFrame {
tabbedPane1.addChangeListener(e -> { tabbedPane1.addChangeListener(e -> {
if (tabbedPane1.getSelectedIndex() != -1) { if (tabbedPane1.getSelectedIndex() != -1) {
int hashCode = tabbedPane1.getSelectedComponent().hashCode(); int hashCode = tabbedPane1.getSelectedComponent().hashCode();
urlField.setText(urls.get(hashCode)); RequestTab requestTab = tabs.get(hashCode);
enableControl(controlState.get(hashCode), hashCode); if (Objects.nonNull(requestTab)) {
showStatus(tab.hashCode()); urlField.setText(requestTab.getUrl());
methodBox.setSelectedItem(requestTab.getMethod());
enableControl(requestTab.isRunning(), hashCode);
showStatus(hashCode);
}
}
});
methodBox.addItemListener((e) -> {
if (tabbedPane1.getSelectedIndex() != -1) {
int hashCode = tabbedPane1.getSelectedComponent().hashCode();
RequestTab requestTab = tabs.get(hashCode);
if (Objects.nonNull(requestTab)) {
requestTab.setMethod((String) methodBox.getSelectedItem());
}
} }
}); });
urlField.getDocument().addDocumentListener(new DocumentListener() { urlField.getDocument().addDocumentListener(new DocumentListener() {
@@ -128,23 +132,58 @@ public class MainWindow extends JFrame {
public void warn() { public void warn() {
if (tabbedPane1.getSelectedIndex() != -1) { if (tabbedPane1.getSelectedIndex() != -1) {
urls.put(tabbedPane1.getSelectedComponent().hashCode(), urlField.getText()); int i = tabbedPane1.indexOfComponent(tabbedPane1.getSelectedComponent());
JLabel title = TabBuilder.getLabel(i);
tabs.get(tabbedPane1.getSelectedComponent().hashCode()).setUrl(urlField.getText());
if (Objects.nonNull(title)) {
if (!urlField.getText().isBlank()) {
try {
URL u = new URL((!urlField.getText().toLowerCase().startsWith("http://") &&
!urlField.getText().toLowerCase().startsWith("https://")) ?
"http://" + urlField.getText() : urlField.getText());
if (u.getPath().isBlank()) {
title.setText(u.getHost());
} else {
title.setText(String.format("%s (%s)", u.getPath(), u.getHost()));
}
} catch (MalformedURLException e) {
title.setText(urlField.getText());
}
} else {
title.setText(NEW_TAB_NAME);
}
}
} }
} }
}); });
} }
private void newTab() {
RequestTab requestTab = new RequestTab((String) methodBox.getSelectedItem());
TabBuilder.create(tabbedPane1, NEW_TAB_NAME, tabs, urlField);
Component tab = tabbedPane1.getSelectedComponent();
tabs.put(tab.hashCode(), requestTab);
enableControl(true, tab.hashCode());
showStatus(tab.hashCode());
urlField.setText("");
}
private void sendRequest() { private void sendRequest() {
Optional<JSplitPane> possibleTab = getSelectedTab(); Optional<JSplitPane> possibleTab = getSelectedTab();
if (possibleTab.isPresent()) { if (possibleTab.isPresent()) {
JSplitPane tab = possibleTab.get(); JSplitPane tab = possibleTab.get();
int tabHashCode = tab.hashCode(); int tabHashCode = tab.hashCode();
RequestTab requestTab = tabs.get(tabHashCode);
statusLabel.setVisible(false); statusLabel.setVisible(false);
enableControl(false, tabHashCode); enableControl(false, tabHashCode);
int i = tabbedPane1.indexOfComponent(tab); int i = tabbedPane1.indexOfComponent(tab);
JTextArea responseBody = TabBuilder.getResponseArea(i); JTextArea responseBody = TabBuilder.getResponseArea(i);
JTextArea responseHeader = TabBuilder.getResponseHeaderTextArea(i);
JTextArea requestHeader = TabBuilder.getRequestHeaderTextArea(i);
responseBody.setForeground(Color.black); responseBody.setForeground(Color.black);
responseBody.setText(""); responseBody.setText("");
responseHeader.setText("");
requestHeader.setText("");
JTextArea bodyField = TabBuilder.getBody(i); JTextArea bodyField = TabBuilder.getBody(i);
new Thread(() -> { new Thread(() -> {
try { try {
@@ -163,14 +202,16 @@ public class MainWindow extends JFrame {
} }
if (possibleRes.isPresent()) { if (possibleRes.isPresent()) {
Response res = possibleRes.get(); Response res = possibleRes.get();
responses.put(tabHashCode, res); requestTab.setRes(res);
responseBody.setText(res.getBody()); responseBody.setText(res.getBody());
requestHeader.setText(res.getRequest().getRawRequest());
responseHeader.setText(res.getRawHeaders());
} }
} catch (KeyManagementException | IOException | NoSuchAlgorithmException e) { } catch (KeyManagementException | IOException | NoSuchAlgorithmException e) {
responseBody.setForeground(Color.red); responseBody.setForeground(Color.red);
responseBody.setText(e.getMessage()); responseBody.setText(e.getMessage());
if (responses.containsKey(tabHashCode)) { if (Objects.nonNull(requestTab.getRes())) {
responses.remove(tabHashCode); requestTab.setRes(null);
showStatus(tabHashCode); showStatus(tabHashCode);
} }
} finally { } finally {
@@ -185,7 +226,7 @@ public class MainWindow extends JFrame {
private void enableControl(Boolean state, int hashCode) { private void enableControl(Boolean state, int hashCode) {
if (Objects.nonNull(state)) { if (Objects.nonNull(state)) {
controlState.put(hashCode, state); tabs.get(hashCode).setRunning(state);
if (tabbedPane1.getSelectedComponent().hashCode() == hashCode) { if (tabbedPane1.getSelectedComponent().hashCode() == hashCode) {
sendButton.setEnabled(state); sendButton.setEnabled(state);
urlField.setEnabled(state); urlField.setEnabled(state);
@@ -196,10 +237,11 @@ public class MainWindow extends JFrame {
} }
private void showStatus(int hashCode) { private void showStatus(int hashCode) {
if (controlState.get(hashCode) && responses.containsKey(hashCode) && RequestTab requestTab = tabs.get(hashCode);
if (requestTab.isRunning() && Objects.nonNull(requestTab.getRes()) &&
tabbedPane1.getSelectedComponent().hashCode() == hashCode) { tabbedPane1.getSelectedComponent().hashCode() == hashCode) {
statusLabel.setForeground(Color.BLACK); statusLabel.setForeground(Color.BLACK);
Response res = responses.get(hashCode); Response res = requestTab.getRes();
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (res.getStatusCode() != -1) { if (res.getStatusCode() != -1) {
sb.append(res.getStatusCode()) sb.append(res.getStatusCode())

View File

@@ -1,5 +1,6 @@
package ovh.alexisdelhaie.endpoint.builder; package ovh.alexisdelhaie.endpoint.builder;
import ovh.alexisdelhaie.endpoint.utils.RequestTab;
import ovh.alexisdelhaie.endpoint.utils.Tools; import ovh.alexisdelhaie.endpoint.utils.Tools;
import ovh.alexisdelhaie.endpoint.utils.adapter.CustomDeleteMouseAdapter; import ovh.alexisdelhaie.endpoint.utils.adapter.CustomDeleteMouseAdapter;
import ovh.alexisdelhaie.endpoint.utils.adapter.CustomNewMouseAdapter; import ovh.alexisdelhaie.endpoint.utils.adapter.CustomNewMouseAdapter;
@@ -12,17 +13,18 @@ import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
public class TabBuilder { public class TabBuilder {
private static final HashMap<String, Component> indexes = new HashMap<>(); public static final ConcurrentHashMap<String, Component> indexes = new ConcurrentHashMap<>();
public static void create(JTabbedPane tab, String label, HashMap<Integer, String> urls, JTextField urlField) { public static void create(JTabbedPane tab, String label, ConcurrentHashMap<Integer, RequestTab> tabs, JTextField urlField) {
Component c = tab.add("", buildMainPanel(urlField)); Component c = tab.add("", buildMainPanel(urlField));
int index = tab.indexOfComponent(c); int index = tab.indexOfComponent(c);
updateIndexes(index); tab.setTabComponentAt(index, buildTabPanel(tab, c, label, tabs));
tab.setTabComponentAt(index, buildTabPanel(tab, c, label, urls));
tab.setSelectedComponent(c); tab.setSelectedComponent(c);
updateIndexes(index);
} }
private static void updateIndexes(int index) { private static void updateIndexes(int index) {
@@ -30,16 +32,23 @@ public class TabBuilder {
indexes.put("main[" + index + "].body", indexes.get("main[waiting].body")); indexes.put("main[" + index + "].body", indexes.get("main[waiting].body"));
indexes.put("main[" + index + "].params", indexes.get("main[waiting].params")); indexes.put("main[" + index + "].params", indexes.get("main[waiting].params"));
indexes.put("main[" + index + "].headers", indexes.get("main[waiting].headers")); indexes.put("main[" + index + "].headers", indexes.get("main[waiting].headers"));
indexes.put("main[" + index + "].tabTitle", indexes.get("main[waiting].tabTitle"));
indexes.put("main[" + index + "].requestHeaderTextArea", indexes.get("main[waiting].requestHeaderTextArea"));
indexes.put("main[" + index + "].responseHeaderTextArea", indexes.get("main[waiting].responseHeaderTextArea"));
indexes.remove("main[waiting].responseTextArea"); indexes.remove("main[waiting].responseTextArea");
indexes.remove("main[waiting].body"); indexes.remove("main[waiting].body");
indexes.remove("main[waiting].params"); indexes.remove("main[waiting].params");
indexes.remove("main[waiting].headers"); indexes.remove("main[waiting].headers");
indexes.remove("main[waiting].tabTitle");
indexes.remove("main[waiting].requestHeaderTextArea");
indexes.remove("main[waiting].responseHeaderTextArea");
} }
private static JPanel buildTabPanel(JTabbedPane tab, Component c, String label, HashMap<Integer, String> urls) { private static JPanel buildTabPanel(JTabbedPane tab, Component c, String label, ConcurrentHashMap<Integer, RequestTab> tabs) {
JPanel p = new JPanel(new GridBagLayout()); JPanel p = new JPanel(new GridBagLayout());
p.setOpaque(false); p.setOpaque(false);
JLabel l = new JLabel(label); JLabel l = new JLabel(label);
indexes.put("main[waiting].tabTitle", l);
GridBagConstraints g = new GridBagConstraints(); GridBagConstraints g = new GridBagConstraints();
g.gridx = 0; g.gridx = 0;
g.gridy = 0; g.gridy = 0;
@@ -47,11 +56,11 @@ public class TabBuilder {
p.add(l, g); p.add(l, g);
g.gridx++; g.gridx++;
g.weightx = 0; g.weightx = 0;
p.add(buildCloseButton(tab, c, urls), g); p.add(buildCloseButton(tab, c, tabs), g);
return p; return p;
} }
private static JButton buildCloseButton(JTabbedPane tab, Component c, HashMap<Integer, String> urls) { private static JButton buildCloseButton(JTabbedPane tab, Component c, ConcurrentHashMap<Integer, RequestTab> tabs) {
JButton b = new JButton("×"); JButton b = new JButton("×");
b.setBorderPainted(false); b.setBorderPainted(false);
b.setFocusPainted(false); b.setFocusPainted(false);
@@ -61,7 +70,7 @@ public class TabBuilder {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
urls.remove(c.hashCode()); tabs.remove(c.hashCode());
tab.remove(c); tab.remove(c);
} }
}); });
@@ -89,6 +98,22 @@ public class TabBuilder {
JTextArea body = new JTextArea(); JTextArea body = new JTextArea();
indexes.put("main[waiting].body", body); indexes.put("main[waiting].body", body);
p.add("Body", body); p.add("Body", body);
// Response tab
JTextArea repHeader = new JTextArea();
repHeader.setBackground(Color.WHITE);
repHeader.setEditable(false);
JScrollPane rep = new JScrollPane(repHeader);
JTextArea reqHeader = new JTextArea();
reqHeader.setBackground(Color.WHITE);
reqHeader.setEditable(false);
JScrollPane req = new JScrollPane(reqHeader);
indexes.put("main[waiting].requestHeaderTextArea", reqHeader);
indexes.put("main[waiting].responseHeaderTextArea", repHeader);
p.add("Response", new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
rep,
req
));
return p; return p;
} }
@@ -100,6 +125,14 @@ public class TabBuilder {
return (JTextArea) indexes.get("main[" + index + "].body"); return (JTextArea) indexes.get("main[" + index + "].body");
} }
public static JTextArea getRequestHeaderTextArea(int index) {
return (JTextArea) indexes.get("main[" + index + "].requestHeaderTextArea");
}
public static JTextArea getResponseHeaderTextArea(int index) {
return (JTextArea) indexes.get("main[" + index + "].responseHeaderTextArea");
}
public static HashMap<String, String> getParams(int index) { public static HashMap<String, String> getParams(int index) {
JTable t = (JTable) indexes.get("main[" + index + "].params"); JTable t = (JTable) indexes.get("main[" + index + "].params");
return Tools.tableToHashMap(t); return Tools.tableToHashMap(t);
@@ -110,6 +143,10 @@ public class TabBuilder {
return Tools.tableToHashMap(t); return Tools.tableToHashMap(t);
} }
public static JLabel getLabel(int index) {
return (JLabel) indexes.get("main[" + index + "].tabTitle");
}
private static JPanel buildParamsTab(boolean isParam, JTextField urlField) { private static JPanel buildParamsTab(boolean isParam, JTextField urlField) {
String[] headers = {"Keys", "Values"}; String[] headers = {"Keys", "Values"};
DefaultTableModel model = new DefaultTableModel(new Object[][]{}, headers); DefaultTableModel model = new DefaultTableModel(new Object[][]{}, headers);

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ovh.alexisdelhaie.endpoint.configuration.AboutDialog"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ovh.alexisdelhaie.endpoint.configuration.AboutDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/> <margin top="10" left="10" bottom="10" right="10"/>
<constraints> <constraints>
<xy x="48" y="54" width="451" height="414"/> <xy x="48" y="54" width="864" height="414"/>
</constraints> </constraints>
<properties/> <properties/>
<border type="none"/> <border type="none"/>
@@ -11,7 +11,7 @@
<grid id="e3588" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="e3588" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties/> <properties/>
<border type="none"/> <border type="none"/>
@@ -58,6 +58,18 @@
</component> </component>
</children> </children>
</grid> </grid>
<component id="21f05" class="javax.swing.JLabel" binding="banner">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="2"/>
<text value=""/>
<verticalAlignment value="1"/>
<verticalTextPosition value="1"/>
</properties>
</component>
</children> </children>
</grid> </grid>
</form> </form>

View File

@@ -1,20 +1,24 @@
package ovh.alexisdelhaie.endpoint.configuration; package ovh.alexisdelhaie.endpoint.configuration;
import ovh.alexisdelhaie.endpoint.MainWindow;
import ovh.alexisdelhaie.endpoint.utils.Tools; import ovh.alexisdelhaie.endpoint.utils.Tools;
import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.IOException;
public class AboutDialog extends JDialog { public class AboutDialog extends JDialog {
public static final int WIDTH = 450; public static final int WIDTH = 740;
public static final int HEIGHT = 500; public static final int HEIGHT = 500;
public static final String VERSION = "0.1.3"; public static final String VERSION = "0.1.4";
private JPanel contentPane; private JPanel contentPane;
private JLabel version; private JLabel version;
private JLabel javaVersion; private JLabel javaVersion;
private JLabel banner;
private AboutDialog() { private AboutDialog() {
setContentPane(contentPane); setContentPane(contentPane);
@@ -22,6 +26,11 @@ public class AboutDialog extends JDialog {
setTitle("About EndPoint"); setTitle("About EndPoint");
version.setText("Version: " + VERSION + " (NOT FINISHED)"); version.setText("Version: " + VERSION + " (NOT FINISHED)");
javaVersion.setText("Software: Java " + System.getProperty("java.version") + " (GUI: Java Swing)"); javaVersion.setText("Software: Java " + System.getProperty("java.version") + " (GUI: Java Swing)");
try {
banner.setIcon(new ImageIcon(ImageIO.read(MainWindow.class.getResource("/banner.png"))));
} catch (IOException e) {
e.printStackTrace();
}
} }
public static void showDialog() { public static void showDialog() {

View File

@@ -51,13 +51,13 @@ public class Response {
} }
private void parseStatus(String l) { private void parseStatus(String l) {
Pattern p = Pattern.compile("^(HTTP/1.1)\\s([0-9]{3})\\s(.+)$"); Pattern p = Pattern.compile("^(HTTP/[0-2].[0-1])\\s([0-9]{3})\\s(.+)$");
Matcher m = p.matcher(l); Matcher m = p.matcher(l);
if (m.matches()) { if (m.matches()) {
statusCode = Integer.parseInt(m.group(2)); statusCode = Integer.parseInt(m.group(2));
status = m.group(3); status = m.group(3);
} else { } else {
p = Pattern.compile("^(HTTP/1.1)\\s([0-9]{3})?(.*)$"); p = Pattern.compile("^(HTTP/[0-2].[0-1])\\s([0-9]{3})?(.*)$");
m = p.matcher(l); m = p.matcher(l);
if (m.matches()) { if (m.matches()) {
statusCode = Integer.parseInt(m.group(2)); statusCode = Integer.parseInt(m.group(2));

View File

@@ -0,0 +1,55 @@
package ovh.alexisdelhaie.endpoint.utils;
import ovh.alexisdelhaie.endpoint.http.Response;
public class RequestTab {
private String url;
private boolean running;
private Response res;
private String method;
public RequestTab(String method) {
url = "";
running = false;
res = null;
this.method = method;
}
public String getUrl() {
return url;
}
public RequestTab setUrl(String url) {
this.url = url;
return this;
}
public boolean isRunning() {
return running;
}
public RequestTab setRunning(boolean running) {
this.running = running;
return this;
}
public Response getRes() {
return res;
}
public RequestTab setRes(Response res) {
this.res = res;
return this;
}
public String getMethod() {
return method;
}
public RequestTab setMethod(String method) {
this.method = method;
return this;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB