Commit 87963623 authored by 9731301's avatar 9731301

complete save request buttton and load headers

parent 2b7258bf
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
</component> </component>
<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 afterPath="$PROJECT_DIR$/Requests/test.insomnia" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Requests/test2.insomnia" afterDir="false" />
<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$/Requests/test.insomnia" beforeDir="false" afterPath="$PROJECT_DIR$/Requests/test.insomnia" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Requests/test2.insomnia" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$1.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$2.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$3.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/InsomniaGUI$3.class" afterDir="false" />
...@@ -29,17 +29,21 @@ ...@@ -29,17 +29,21 @@
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$12.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$12.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$12.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$12.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$13.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$13.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$13.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$13.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$2.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$3.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$4.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$4.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$5.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$5.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$6.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$6.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$7.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$7.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$7.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$7.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$8.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$8.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$8.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$8.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$9.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$9.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$9.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel$9.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/GUI/RequestPanel.class" 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/RequestLoader.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/RequestLoader.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/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$/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/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/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/RequestLoader.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/parser/RequestLoader.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/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" /> <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>
...@@ -177,7 +181,7 @@ ...@@ -177,7 +181,7 @@
<workItem from="1590757579057" duration="2543000" /> <workItem from="1590757579057" duration="2543000" />
<workItem from="1590934179600" duration="31544000" /> <workItem from="1590934179600" duration="31544000" />
<workItem from="1591024948574" duration="21598000" /> <workItem from="1591024948574" duration="21598000" />
<workItem from="1591127468443" duration="6374000" /> <workItem from="1591127468443" duration="7799000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -188,6 +192,10 @@ ...@@ -188,6 +192,10 @@
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="518" y="216" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1591133961860">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="518" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1591133961860" />
<state x="472" y="159" key="#com.intellij.ide.util.MemberChooser" timestamp="1591034675582"> <state x="472" y="159" key="#com.intellij.ide.util.MemberChooser" timestamp="1591034675582">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -208,22 +216,22 @@ ...@@ -208,22 +216,22 @@
<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="1493" height="105" key="GridCell.Tab.0.bottom" timestamp="1591133602250"> <state width="1493" height="105" key="GridCell.Tab.0.bottom" timestamp="1591135156379">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="105" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1591133602250" /> <state width="1493" height="105" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1591135156379" />
<state width="1493" height="105" key="GridCell.Tab.0.center" timestamp="1591133602250"> <state width="1493" height="105" key="GridCell.Tab.0.center" timestamp="1591135156379">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="105" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1591133602250" /> <state width="1493" height="105" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1591135156379" />
<state width="1493" height="105" key="GridCell.Tab.0.left" timestamp="1591133602247"> <state width="1493" height="105" key="GridCell.Tab.0.left" timestamp="1591135156379">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="105" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1591133602247" /> <state width="1493" height="105" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1591135156379" />
<state width="1493" height="105" key="GridCell.Tab.0.right" timestamp="1591133602250"> <state width="1493" height="105" key="GridCell.Tab.0.right" timestamp="1591135156379">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="105" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1591133602250" /> <state width="1493" height="105" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1591135156379" />
<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>
......
No preview for this file type
...@@ -83,12 +83,9 @@ public class InsomniaGUI { ...@@ -83,12 +83,9 @@ public class InsomniaGUI {
response.getRow().setBackground(Color.WHITE); response.getRow().setBackground(Color.WHITE);
request.getRootPane().setBackground(Color.WHITE); request.getRootPane().setBackground(Color.WHITE);
request.getBody().setBackground(Color.WHITE); request.getBody().setBackground(Color.WHITE);
request.getCenter_header().setBackground(Color.WHITE);
request.getDocs().setBackground(Color.WHITE); request.getDocs().setBackground(Color.WHITE);
request.getCenterMenu().setBackground(Color.WHITE); request.getCenterMenu().setBackground(Color.WHITE);
request.getCenterUp().setBackground(Color.WHITE); request.getCenterUp().setBackground(Color.WHITE);
request.getHeader().setBackground(Color.WHITE);
request.getRightOfHeader().setBackground(Color.WHITE);
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);
...@@ -112,12 +109,9 @@ public class InsomniaGUI { ...@@ -112,12 +109,9 @@ public class InsomniaGUI {
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.getBody().setBackground(Color.DARK_GRAY); request.getBody().setBackground(Color.DARK_GRAY);
request.getCenter_header().setBackground(Color.DARK_GRAY);
request.getDocs().setBackground(Color.DARK_GRAY); request.getDocs().setBackground(Color.DARK_GRAY);
request.getCenterMenu().setBackground(Color.DARK_GRAY); request.getCenterMenu().setBackground(Color.DARK_GRAY);
request.getCenterUp().setBackground(Color.DARK_GRAY); request.getCenterUp().setBackground(Color.DARK_GRAY);
request.getHeader().setBackground(Color.DARK_GRAY);
request.getRightOfHeader().setBackground(Color.DARK_GRAY);
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);
......
...@@ -57,12 +57,13 @@ public class LeftPanel extends JPanel { ...@@ -57,12 +57,13 @@ public class LeftPanel extends JPanel {
newRequestFrame.add(panel); newRequestFrame.add(panel);
newRequestFrame.setPreferredSize(new Dimension(200,200)); newRequestFrame.setPreferredSize(new Dimension(200,200));
newRequestFrame.setVisible(true); newRequestFrame.setVisible(true);
newRequestFrame.pack();
create.addMouseListener(new MouseAdapter() { create.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
String name = textField.getText(); String name = textField.getText();
//Check Request exist newRequestFrame.setVisible(false);
//Save Request //Save Request
ResponseData data = main_class.data_req; ResponseData data = main_class.data_req;
......
...@@ -31,13 +31,7 @@ public class RequestPanel extends JPanel { ...@@ -31,13 +31,7 @@ public class RequestPanel extends JPanel {
private HashMap<String , String> headers_values= new HashMap<>(); private HashMap<String , String> headers_values= new HashMap<>();
private JPanel docs = new JPanel(); private JPanel docs = new JPanel();
private JTabbedPane tabbedPaneCenterRequest = new JTabbedPane(); private JTabbedPane tabbedPaneCenterRequest = new JTabbedPane();
private JTextField headerField = new JTextField("header");
private JTextField valueField = new JTextField("value");
private JCheckBox checkBox = new JCheckBox();
private JButton delete = new JButton();
private JPanel rightOfHeader = new JPanel();
private JPanel center_header = new JPanel(new GridLayout(1,2));
private JPanel header = new JPanel(new BorderLayout());
private String s []={"Get","Post","Put","Delete"}; private String s []={"Get","Post","Put","Delete"};
private JComboBox centerMenu = new JComboBox(s); private JComboBox centerMenu = new JComboBox(s);
private JTextField URLTextField = new JTextField("http://api.myproduct.com/v1/users"); private JTextField URLTextField = new JTextField("http://api.myproduct.com/v1/users");
...@@ -51,10 +45,7 @@ public class RequestPanel extends JPanel { ...@@ -51,10 +45,7 @@ public class RequestPanel extends JPanel {
} }
public JTabbedPane tabbedPaneCenterRequest() throws IOException { public JTabbedPane tabbedPaneCenterRequest() throws IOException {
Border border = BorderFactory.createLineBorder(Color.BLACK,3);
BufferedImage master;
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);
body.setBackground(Color.GRAY); body.setBackground(Color.GRAY);
body.add(Json_FormData,BorderLayout.NORTH); body.add(Json_FormData,BorderLayout.NORTH);
...@@ -80,52 +71,14 @@ public class RequestPanel extends JPanel { ...@@ -80,52 +71,14 @@ public class RequestPanel extends JPanel {
tabbedPaneCenterRequest.add("Header" , scrollPane_Header_Request); tabbedPaneCenterRequest.add("Header" , scrollPane_Header_Request);
tabbedPaneCenterRequest.add("Docs" , docs); tabbedPaneCenterRequest.add("Docs" , docs);
MouseAdapter deleteClick = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JButton Btn = (JButton) e.getSource();
//to repair showing
mainCenterHeader.remove(((JPanel) Btn.getParent()).getParent());
mainCenterHeader.revalidate();
mainCenterHeader.repaint();
}
};
delete.addMouseListener(deleteClick); addHeader();
MouseAdapter m = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e!=null && !isLastComponent(((Component) e.getSource()).getParent().getParent())) return;
JTextField newHeaderField = new JTextField("header");
newHeaderField.addMouseListener(this);
newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value");
newValueField.setBorder(border);
JCheckBox newCheckBox = new JCheckBox();
newCheckBox.setSelected(true);
JButton newDelete = new JButton();
newDelete.setPreferredSize(new Dimension(20,20));
newDelete.setIcon(new ImageIcon(scaled));
newDelete.addMouseListener(deleteClick);
JPanel newRightOfHeader = new JPanel();
newRightOfHeader.add(newCheckBox);
newRightOfHeader.add(newDelete);
JPanel new_center_header = new JPanel(new GridLayout(1, 2));
new_center_header.add(newHeaderField);
new_center_header.add(newValueField);
JPanel newHeader = new JPanel(new BorderLayout());
newHeader.add(newRightOfHeader, BorderLayout.EAST);
newHeader.add(new_center_header, BorderLayout.CENTER);
mainCenterHeader.add(newHeader );
mainCenterHeader.validate();
}
};
mainCenterHeader.addMouseListener(new MouseAdapter() { mainCenterHeader.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
if (mainCenterHeader.getComponentCount()==0) m.mouseClicked(null); if (mainCenterHeader.getComponentCount()==0) addHeader();
} }
}); });
...@@ -137,25 +90,64 @@ public class RequestPanel extends JPanel { ...@@ -137,25 +90,64 @@ public class RequestPanel extends JPanel {
} }
}); });
headerField.addMouseListener(m);
headerField.setFocusable(true);
headerField.setBorder(border);
valueField.setBorder(border);
delete.setIcon(new ImageIcon(scaled));
delete.setPreferredSize(new Dimension(20,20));
checkBox.setSelected(true);
rightOfHeader.add(checkBox);
rightOfHeader.add(delete);
center_header.add(headerField);
center_header.add(valueField);
header.add(rightOfHeader,BorderLayout.EAST);
header.add(center_header,BorderLayout.CENTER);
mainCenterHeader.add(header);
return tabbedPaneCenterRequest; return tabbedPaneCenterRequest;
} }
private void addHeader(String... args){
try {
Border border = BorderFactory.createLineBorder(Color.BLACK, 3);
BufferedImage master;
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);
JTextField newHeaderField = new JTextField("header");
newHeaderField.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e!=null && !isLastComponent(((Component) e.getSource()).getParent().getParent())) return;
addHeader();
}
});
newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value");
newValueField.setBorder(border);
if (args.length>0){
newHeaderField.setText(args[0]);
newValueField.setText(args[1]);
}
JCheckBox newCheckBox = new JCheckBox();
newCheckBox.setSelected(true);
JButton newDelete = new JButton();
newDelete.setPreferredSize(new Dimension(20, 20));
newDelete.setIcon(new ImageIcon(scaled));
newDelete.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JButton Btn = (JButton) e.getSource();
//to repair showing
mainCenterHeader.remove(((JPanel) Btn.getParent()).getParent());
mainCenterHeader.revalidate();
mainCenterHeader.repaint();
}
});
JPanel newRightOfHeader = new JPanel();
newRightOfHeader.add(newCheckBox);
newRightOfHeader.add(newDelete);
JPanel new_center_header = new JPanel(new GridLayout(1, 2));
new_center_header.add(newHeaderField);
new_center_header.add(newValueField);
JPanel newHeader = new JPanel(new BorderLayout());
newHeader.add(newRightOfHeader, BorderLayout.EAST);
newHeader.add(new_center_header, BorderLayout.CENTER);
mainCenterHeader.add(newHeader);
mainCenterHeader.validate();
}catch (IOException e){
e.printStackTrace();
}
}
boolean isLastComponent(Component c){ boolean isLastComponent(Component c){
return isLastComponent(c,mainCenterHeader); return isLastComponent(c,mainCenterHeader);
...@@ -417,6 +409,12 @@ public class RequestPanel extends JPanel { ...@@ -417,6 +409,12 @@ public class RequestPanel extends JPanel {
} }
} }
} }
if (r.getHeaders()!=null && r.getHeaders().size()>0){
for (String key : r.getHeaders().keySet()){
addHeader(key,r.getHeaders().get(key));
}
}
} }
public void createRequestPanel() throws IOException { public void createRequestPanel() throws IOException {
...@@ -430,13 +428,6 @@ public class RequestPanel extends JPanel { ...@@ -430,13 +428,6 @@ public class RequestPanel extends JPanel {
} }
public JPanel getRightOfHeader() {
return rightOfHeader;
}
public JPanel getCenter_header() {
return center_header;
}
public JPanel getBody() { public JPanel getBody() {
return body; return body;
...@@ -459,9 +450,6 @@ public class RequestPanel extends JPanel { ...@@ -459,9 +450,6 @@ public class RequestPanel extends JPanel {
return tabbedPaneCenterRequest; return tabbedPaneCenterRequest;
} }
public JPanel getHeader() {
return header;
}
public JComboBox getCenterMenu() { public JComboBox getCenterMenu() {
return centerMenu; return centerMenu;
......
...@@ -148,7 +148,6 @@ public class RequestLoader { ...@@ -148,7 +148,6 @@ public class RequestLoader {
if (status == HttpURLConnection.HTTP_OK) { if (status == HttpURLConnection.HTTP_OK) {
InputStream responseStream = new InputStream responseStream = new
BufferedInputStream(con.getInputStream()); BufferedInputStream(con.getInputStream());
responseData.setInputStream(responseStream);
responseData.setResponseHeaders(con.getHeaderFields()); responseData.setResponseHeaders(con.getHeaderFields());
responseData.setSuccessful(true); responseData.setSuccessful(true);
...@@ -170,7 +169,7 @@ public class RequestLoader { ...@@ -170,7 +169,7 @@ public class RequestLoader {
responseData.res = new String(Files.readAllBytes(Paths.get(f.getAbsolutePath())), Charset.forName("utf-8")); responseData.res = new String(Files.readAllBytes(Paths.get(f.getAbsolutePath())), Charset.forName("utf-8"));
f.delete(); f.delete();
}else { }else {
Saver.saveResponse(responseData); Saver.saveResponse(responseData,responseStream);
} }
if (data.isSaveRequest()) Saver.saveRequest(data); if (data.isSaveRequest()) Saver.saveRequest(data);
......
...@@ -15,7 +15,6 @@ public class ResponseData implements Serializable { ...@@ -15,7 +15,6 @@ public class ResponseData implements Serializable {
private String syntaxErrorLog = ""; private String syntaxErrorLog = "";
private boolean successful = false; private boolean successful = false;
private int status = -1; private int status = -1;
private InputStream inputStream = null;
private Map<String, List<String>> responseHeaders; private Map<String, List<String>> responseHeaders;
private String errorMessage = ""; private String errorMessage = "";
private long size; private long size;
...@@ -92,29 +91,6 @@ public class ResponseData implements Serializable { ...@@ -92,29 +91,6 @@ public class ResponseData implements Serializable {
return res; return res;
} }
String convertStreamToString(InputStream is,boolean close) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line ;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (close) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return sb.toString();
}
public void setSyntaxError(boolean syntaxError) { public void setSyntaxError(boolean syntaxError) {
this.syntaxError = syntaxError; this.syntaxError = syntaxError;
...@@ -126,14 +102,6 @@ public class ResponseData implements Serializable { ...@@ -126,14 +102,6 @@ public class ResponseData implements Serializable {
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
public void setErrorMessage(String errorMessage) { public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
...@@ -142,5 +110,5 @@ public class ResponseData implements Serializable { ...@@ -142,5 +110,5 @@ public class ResponseData implements Serializable {
public void setStatus(int status) { public void setStatus(int status) {
this.status = status; this.status = status;
} }
} }
package com.insomnia.parser; package com.insomnia.parser;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
...@@ -98,7 +93,7 @@ public class Saver { ...@@ -98,7 +93,7 @@ public class Saver {
return null; return null;
} }
public static void saveResponse(ResponseData data) { public static void saveResponse(ResponseData data, InputStream stream) {
if (!data.getRequestData().getOutput().equals("-null")){ if (!data.getRequestData().getOutput().equals("-null")){
String fileName; String fileName;
if (data.getRequestData().getOutput().equals("-t")){ if (data.getRequestData().getOutput().equals("-t")){
...@@ -113,7 +108,7 @@ public class Saver { ...@@ -113,7 +108,7 @@ public class Saver {
int read; int read;
byte[] bytes = new byte[1024]; byte[] bytes = new byte[1024];
while ((read = data.getInputStream().read(bytes)) != -1) { while ((read = stream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read); outputStream.write(bytes, 0, read);
} }
......
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