Commit c3e683b0 authored by 9731301's avatar 9731301

add actionListener for headers and json

parent 0a110cd9
...@@ -8,17 +8,8 @@ ...@@ -8,17 +8,8 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="f2dd20fb-7e97-49ef-9dfe-5631626d7912" name="Default Changelist" comment=""> <list default="true" id="f2dd20fb-7e97-49ef-9dfe-5631626d7912" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/artifacts/Insomnia_jar/Insomnia.jar" beforeDir="false" afterPath="$PROJECT_DIR$/out/artifacts/Insomnia_jar/Insomnia.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/RequestData.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/RequestData.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/ResponseData.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/ResponseData.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/Saver.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/Saver.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" beforeDir="false" afterPath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/GUI/InsomniaGUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/GUI/InsomniaGUI.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/com/insomnia/GUI/InsomniaGUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/GUI/InsomniaGUI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/GUI/LeftPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/GUI/LeftPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/GUI/RequestPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/GUI/RequestPanel.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/com/insomnia/GUI/RequestPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/GUI/RequestPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/parser/RequestData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/parser/RequestData.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/parser/ResponseData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/parser/ResponseData.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/insomnia/parser/Saver.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/parser/Saver.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -153,6 +144,7 @@ ...@@ -153,6 +144,7 @@
<workItem from="1590682418201" duration="308000" /> <workItem from="1590682418201" duration="308000" />
<workItem from="1590757579057" duration="2543000" /> <workItem from="1590757579057" duration="2543000" />
<workItem from="1590934179600" duration="31544000" /> <workItem from="1590934179600" duration="31544000" />
<workItem from="1591024948574" duration="4476000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -183,30 +175,30 @@ ...@@ -183,30 +175,30 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="402" y="167" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1590494460700" /> <state x="402" y="167" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1590494460700" />
<state width="906" height="2" key="GridCell.Tab.0.bottom" timestamp="1590967042461"> <state width="1493" height="2" key="GridCell.Tab.0.bottom" timestamp="1591028946800">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="906" height="2" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" /> <state width="1493" height="2" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1591028946800" />
<state width="906" height="2" key="GridCell.Tab.0.center" timestamp="1590967042461"> <state width="1493" height="2" key="GridCell.Tab.0.center" timestamp="1591028946800">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="906" height="2" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" /> <state width="1493" height="2" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1591028946800" />
<state width="906" height="2" key="GridCell.Tab.0.left" timestamp="1590967042461"> <state width="1493" height="2" key="GridCell.Tab.0.left" timestamp="1591028946800">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="906" height="2" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" /> <state width="1493" height="2" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1591028946800" />
<state width="906" height="2" key="GridCell.Tab.0.right" timestamp="1590967042461"> <state width="1493" height="2" key="GridCell.Tab.0.right" timestamp="1591028946800">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="906" height="2" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" /> <state width="1493" height="2" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1591028946800" />
<state x="249" y="0" key="SettingsEditor" timestamp="1590962002174"> <state x="249" y="0" key="SettingsEditor" timestamp="1590962002174">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="249" y="0" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1590962002174" /> <state x="249" y="0" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1590962002174" />
<state x="425" y="237" key="com.intellij.ide.util.TipDialog" timestamp="1590757579198"> <state x="425" y="237" key="com.intellij.ide.util.TipDialog" timestamp="1591025053132">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="425" y="237" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1590757579198" /> <state x="425" y="237" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1591025053132" />
<state x="499" y="179" key="extract.method.dialog" timestamp="1590145349556"> <state x="499" y="179" key="extract.method.dialog" timestamp="1590145349556">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
......
...@@ -63,7 +63,6 @@ public class InsomniaGUI { ...@@ -63,7 +63,6 @@ public class InsomniaGUI {
response.getTimeline().setBackground(Color.WHITE); response.getTimeline().setBackground(Color.WHITE);
response.getRow().setBackground(Color.WHITE); response.getRow().setBackground(Color.WHITE);
request.getRootPane().setBackground(Color.WHITE); request.getRootPane().setBackground(Color.WHITE);
request.getAuth().setBackground(Color.WHITE);
request.getBody().setBackground(Color.WHITE); request.getBody().setBackground(Color.WHITE);
request.getCenter_header().setBackground(Color.WHITE); request.getCenter_header().setBackground(Color.WHITE);
request.getDocs().setBackground(Color.WHITE); request.getDocs().setBackground(Color.WHITE);
...@@ -74,7 +73,6 @@ public class InsomniaGUI { ...@@ -74,7 +73,6 @@ public class InsomniaGUI {
request.getMainCenterHeader().setBackground(Color.WHITE); request.getMainCenterHeader().setBackground(Color.WHITE);
request.getScrollPane_Header_Request().setBackground(Color.WHITE); request.getScrollPane_Header_Request().setBackground(Color.WHITE);
request.getTabbedPaneCenterRequest().setBackground(Color.WHITE); request.getTabbedPaneCenterRequest().setBackground(Color.WHITE);
request.getQuery().setBackground(Color.WHITE);
leftPanel.getAddRequest().setBackground(Color.WHITE); leftPanel.getAddRequest().setBackground(Color.WHITE);
leftPanel.getMenu().setBackground(Color.WHITE); leftPanel.getMenu().setBackground(Color.WHITE);
leftPanel.getScrollRequests().setBackground(Color.WHITE); leftPanel.getScrollRequests().setBackground(Color.WHITE);
...@@ -95,7 +93,6 @@ public class InsomniaGUI { ...@@ -95,7 +93,6 @@ public class InsomniaGUI {
response.getTimeline().setBackground(Color.DARK_GRAY); response.getTimeline().setBackground(Color.DARK_GRAY);
response.getRow().setBackground(Color.DARK_GRAY); response.getRow().setBackground(Color.DARK_GRAY);
request.getRootPane().setBackground(Color.DARK_GRAY); request.getRootPane().setBackground(Color.DARK_GRAY);
request.getAuth().setBackground(Color.DARK_GRAY);
request.getBody().setBackground(Color.DARK_GRAY); request.getBody().setBackground(Color.DARK_GRAY);
request.getCenter_header().setBackground(Color.DARK_GRAY); request.getCenter_header().setBackground(Color.DARK_GRAY);
request.getDocs().setBackground(Color.DARK_GRAY); request.getDocs().setBackground(Color.DARK_GRAY);
...@@ -106,7 +103,6 @@ public class InsomniaGUI { ...@@ -106,7 +103,6 @@ public class InsomniaGUI {
request.getMainCenterHeader().setBackground(Color.DARK_GRAY); request.getMainCenterHeader().setBackground(Color.DARK_GRAY);
request.getScrollPane_Header_Request().setBackground(Color.DARK_GRAY); request.getScrollPane_Header_Request().setBackground(Color.DARK_GRAY);
request.getTabbedPaneCenterRequest().setBackground(Color.DARK_GRAY); request.getTabbedPaneCenterRequest().setBackground(Color.DARK_GRAY);
request.getQuery().setBackground(Color.DARK_GRAY);
leftPanel.getAddRequest().setBackground(Color.DARK_GRAY); leftPanel.getAddRequest().setBackground(Color.DARK_GRAY);
leftPanel.getMenu().setBackground(Color.DARK_GRAY); leftPanel.getMenu().setBackground(Color.DARK_GRAY);
leftPanel.getScrollRequests().setBackground(Color.DARK_GRAY); leftPanel.getScrollRequests().setBackground(Color.DARK_GRAY);
......
...@@ -4,6 +4,7 @@ import com.insomnia.parser.Saver; ...@@ -4,6 +4,7 @@ import com.insomnia.parser.Saver;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.text.Utilities;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
...@@ -13,6 +14,8 @@ import java.util.HashMap; ...@@ -13,6 +14,8 @@ import java.util.HashMap;
public class RequestPanel extends JPanel { public class RequestPanel extends JPanel {
private VerticalFlowLayout vfLayout = new VerticalFlowLayout(); private VerticalFlowLayout vfLayout = new VerticalFlowLayout();
private String[] ss = {"JSON","Form Data"};
private JComboBox Json_FormData = new JComboBox(ss);
private JPanel body = new JPanel(); private JPanel body = new JPanel();
private JPanel auth = new JPanel(); private JPanel auth = new JPanel();
private JPanel query = new JPanel(); private JPanel query = new JPanel();
...@@ -34,14 +37,13 @@ public class RequestPanel extends JPanel { ...@@ -34,14 +37,13 @@ public class RequestPanel extends JPanel {
private JButton sendButton = new JButton("send"); private JButton sendButton = new JButton("send");
private JPanel centerUp = new JPanel(new BorderLayout()); private JPanel centerUp = new JPanel(new BorderLayout());
JTextField field = null;
public JTabbedPane tabbedPaneCenterRequest() throws IOException { public JTabbedPane tabbedPaneCenterRequest() throws IOException {
Border border = BorderFactory.createLineBorder(Color.BLACK,3); Border border = BorderFactory.createLineBorder(Color.BLACK,3);
BufferedImage master; BufferedImage master;
master = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\Insomnia\\src\\image\\535246.png")); master = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\Insomnia\\src\\image\\535246.png"));
Image scaled = master.getScaledInstance(20,20, java.awt.Image.SCALE_SMOOTH); Image scaled = master.getScaledInstance(20,20, java.awt.Image.SCALE_SMOOTH);
body.setBackground(Color.GRAY); body.setBackground(Color.GRAY);
body.add(Json_FormData,BorderLayout.NORTH);
auth.setBackground(Color.GRAY); auth.setBackground(Color.GRAY);
query.setBackground(Color.GRAY); query.setBackground(Color.GRAY);
mainCenterHeader.setBackground(Color.GRAY); mainCenterHeader.setBackground(Color.GRAY);
...@@ -70,14 +72,14 @@ public class RequestPanel extends JPanel { ...@@ -70,14 +72,14 @@ public class RequestPanel extends JPanel {
MouseAdapter m = new MouseAdapter() { MouseAdapter m = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e!=null && !isLastComponent(((Component) e.getSource()).getParent().getParent())) return;
JTextField newHeaderField = new JTextField("header"); JTextField newHeaderField = new JTextField("header");
field.removeMouseListener(this);
field = newHeaderField;
newHeaderField.addMouseListener(this); newHeaderField.addMouseListener(this);
newHeaderField.setBorder(border); newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value"); JTextField newValueField = new JTextField("value");
newValueField.setBorder(border); newValueField.setBorder(border);
JCheckBox newCheckBox = new JCheckBox(); JCheckBox newCheckBox = new JCheckBox();
newCheckBox.setSelected(true);
JButton newDelete = new JButton(); JButton newDelete = new JButton();
newDelete.setPreferredSize(new Dimension(20,20)); newDelete.setPreferredSize(new Dimension(20,20));
newDelete.setIcon(new ImageIcon(scaled)); newDelete.setIcon(new ImageIcon(scaled));
...@@ -100,10 +102,10 @@ public class RequestPanel extends JPanel { ...@@ -100,10 +102,10 @@ public class RequestPanel extends JPanel {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
if (mainCenterHeader.getComponentCount()==0) m.mouseClicked(e); if (mainCenterHeader.getComponentCount()==0) m.mouseClicked(null);
} }
}); });
field = headerField;
headerField.addMouseListener(m); headerField.addMouseListener(m);
...@@ -112,6 +114,7 @@ public class RequestPanel extends JPanel { ...@@ -112,6 +114,7 @@ public class RequestPanel extends JPanel {
valueField.setBorder(border); valueField.setBorder(border);
delete.setIcon(new ImageIcon(scaled)); delete.setIcon(new ImageIcon(scaled));
delete.setPreferredSize(new Dimension(20,20)); delete.setPreferredSize(new Dimension(20,20));
checkBox.setSelected(true);
rightOfHeader.add(checkBox); rightOfHeader.add(checkBox);
rightOfHeader.add(delete); rightOfHeader.add(delete);
center_header.add(headerField); center_header.add(headerField);
...@@ -123,6 +126,29 @@ public class RequestPanel extends JPanel { ...@@ -123,6 +126,29 @@ public class RequestPanel extends JPanel {
} }
boolean isLastComponent(Component c){
return mainCenterHeader.getComponent(mainCenterHeader.getComponentCount()-1)==c;
}
public HashMap<String,String> getHeaders(){
HashMap<String,String> headers = new HashMap<>();
for(Component c : mainCenterHeader.getComponents()){
if (c instanceof JPanel){
JPanel nh = (JPanel) c;
JPanel r = (JPanel)nh.getComponent(0), l = (JPanel) nh.getComponent(1);
JCheckBox cb = (JCheckBox) r.getComponent(0);
if (cb.isSelected()){
JTextField h = (JTextField) l.getComponent(0);
JTextField v = (JTextField) l.getComponent(1);
if (!h.getText().trim().isEmpty()){
headers.put(h.getText().trim(),v.getText());
}
}
}
}
return headers;
}
//request_up //request_up
public JPanel centerUp(){ public JPanel centerUp(){
sendButton.addMouseListener(new MouseAdapter() { sendButton.addMouseListener(new MouseAdapter() {
...@@ -130,11 +156,17 @@ public class RequestPanel extends JPanel { ...@@ -130,11 +156,17 @@ public class RequestPanel extends JPanel {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
RequestData requestData = new RequestData(); RequestData requestData = new RequestData();
// requestData.setUploadPath(); // requestData.setUploadPath();
// requestData.setHeaders(mainCenterHeader.getComponents());
requestData.setUrl(URLTextField.getText()); requestData.setUrl(URLTextField.getText());
//requestData.setJson();
super.mouseClicked(e); super.mouseClicked(e);
Saver saver = new Saver(); Saver saver = new Saver();
//set if it is Json or not
if(Json_FormData.getActionCommand().equals("JSON"));
requestData.setJson(true);
requestData.setHeaders(getHeaders());
for(String h : requestData.getHeaders().keySet()){
System.out.println(h+" : "+requestData.getHeaders().get(h));
}
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment