Commit 0a110cd9 authored by 9731301's avatar 9731301

add some changes and actionListeners

parent 80f032e6
...@@ -7,14 +7,18 @@ ...@@ -7,14 +7,18 @@
</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$/src/com/insomnia/GUI/Insomnia.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/com/insomnia/parser/Insomnia.java" 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$/out/production/Insomnia/Run.class" beforeDir="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/Parser.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Insomnia/com/insomnia/parser/Parser.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/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/Run.java" beforeDir="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/parser/RequestLoader.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/insomnia/parser/RequestLoader.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/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" />
...@@ -68,7 +72,7 @@ ...@@ -68,7 +72,7 @@
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" /> <property name="project.structure.side.proportion" value="0.2" />
</component> </component>
<component name="RunManager" selected="Application.Insomnia (2)"> <component name="RunManager" selected="Application.Insomnia (1)">
<configuration name="Insomnia (1)" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Insomnia (1)" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.insomnia.GUI.Insomnia" /> <option name="MAIN_CLASS_NAME" value="com.insomnia.GUI.Insomnia" />
<module name="Insomnia" /> <module name="Insomnia" />
...@@ -111,8 +115,8 @@ ...@@ -111,8 +115,8 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Application.Insomnia (2)" />
<item itemvalue="Application.Insomnia (1)" /> <item itemvalue="Application.Insomnia (1)" />
<item itemvalue="Application.Insomnia (2)" />
<item itemvalue="Application.Insomnia" /> <item itemvalue="Application.Insomnia" />
<item itemvalue="Application.Run" /> <item itemvalue="Application.Run" />
</list> </list>
...@@ -148,7 +152,7 @@ ...@@ -148,7 +152,7 @@
<workItem from="1590623093663" duration="5335000" /> <workItem from="1590623093663" duration="5335000" />
<workItem from="1590682418201" duration="308000" /> <workItem from="1590682418201" duration="308000" />
<workItem from="1590757579057" duration="2543000" /> <workItem from="1590757579057" duration="2543000" />
<workItem from="1590934179600" duration="245000" /> <workItem from="1590934179600" duration="31544000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -159,14 +163,14 @@ ...@@ -159,14 +163,14 @@
<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="472" y="159" key="#com.intellij.ide.util.MemberChooser" timestamp="1590591835027"> <state x="472" y="159" key="#com.intellij.ide.util.MemberChooser" timestamp="1590962459070">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="472" y="159" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1590591835027" /> <state x="472" y="159" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1590962459070" />
<state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1590496648787"> <state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1590961999762">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog/0.0.1536.824@0.0.1536.824" timestamp="1590496648787" /> <state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog/0.0.1536.824@0.0.1536.824" timestamp="1590961999762" />
<state x="499" y="160" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1590603376669"> <state x="499" y="160" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1590603376669">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -179,26 +183,26 @@ ...@@ -179,26 +183,26 @@
<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="174" key="GridCell.Tab.0.bottom" timestamp="1590934462040"> <state width="906" height="2" key="GridCell.Tab.0.bottom" timestamp="1590967042461">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="174" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1590934462040" /> <state width="906" height="2" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" />
<state width="1493" height="174" key="GridCell.Tab.0.center" timestamp="1590934462040"> <state width="906" height="2" key="GridCell.Tab.0.center" timestamp="1590967042461">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="174" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1590934462040" /> <state width="906" height="2" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" />
<state width="1493" height="174" key="GridCell.Tab.0.left" timestamp="1590934462040"> <state width="906" height="2" key="GridCell.Tab.0.left" timestamp="1590967042461">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="174" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1590934462040" /> <state width="906" height="2" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" />
<state width="1493" height="174" key="GridCell.Tab.0.right" timestamp="1590934462040"> <state width="906" height="2" key="GridCell.Tab.0.right" timestamp="1590967042461">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="174" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1590934462040" /> <state width="906" height="2" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1590967042461" />
<state x="249" y="0" key="SettingsEditor" timestamp="1590496679192"> <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="1590496679192" /> <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="1590757579198">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -211,13 +215,13 @@ ...@@ -211,13 +215,13 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="209" y="33" key="new project wizard/0.0.1536.824@0.0.1536.824" timestamp="1590495277464" /> <state x="209" y="33" key="new project wizard/0.0.1536.824@0.0.1536.824" timestamp="1590495277464" />
<state x="163" y="189" key="run.anything.popup" timestamp="1590759062213"> <state x="163" y="189" key="run.anything.popup" timestamp="1590953965770">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="163" y="189" key="run.anything.popup/0.0.1536.824@0.0.1536.824" timestamp="1590759062213" /> <state x="163" y="189" key="run.anything.popup/0.0.1536.824@0.0.1536.824" timestamp="1590953965770" />
<state x="46" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589292677842"> <state x="46" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1590952691529">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="46" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1589292677842" /> <state x="46" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1590952691529" />
</component> </component>
</project> </project>
\ No newline at end of file
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: Insomnia Main-Class: com.insomnia.GUI.Insomnia
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: Insomnia Main-Class: com.insomnia.GUI.Insomnia
...@@ -6,7 +6,6 @@ package com.insomnia.GUI; ...@@ -6,7 +6,6 @@ package com.insomnia.GUI;
*/ */
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.IOException; import java.io.IOException;
...@@ -17,10 +16,11 @@ import static java.awt.Frame.*; ...@@ -17,10 +16,11 @@ import static java.awt.Frame.*;
public class InsomniaGUI { public class InsomniaGUI {
JFrame frame ; JFrame frame ;
public InsomniaGUI() throws IOException { public InsomniaGUI() throws IOException {
frame = new JFrame(); frame = new JFrame();
frame.setTitle("Insomnia"); frame.setTitle("Insomnia");
frame.setSize(900,600); // frame.setSize(900,600);
frame.setLocation(200,100); frame.setLocation(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); frame.setVisible(true);
...@@ -227,6 +227,7 @@ public class InsomniaGUI { ...@@ -227,6 +227,7 @@ public class InsomniaGUI {
panel.add(panelRight , BorderLayout.CENTER); panel.add(panelRight , BorderLayout.CENTER);
frame.getContentPane().add(panel); frame.getContentPane().add(panel);
frame.pack();
} }
...@@ -276,4 +277,5 @@ public class InsomniaGUI { ...@@ -276,4 +277,5 @@ public class InsomniaGUI {
System.exit(0); System.exit(0);
} }
} }
} }
package com.insomnia.GUI; package com.insomnia.GUI;
import com.insomnia.parser.RequestData;
import com.insomnia.parser.ResponseData;
import com.insomnia.parser.Saver;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
...@@ -25,31 +30,37 @@ public class LeftPanel extends JPanel { ...@@ -25,31 +30,37 @@ public class LeftPanel extends JPanel {
up_left.add(addRequest); up_left.add(addRequest);
up_left.setBackground(Color.GRAY); up_left.setBackground(Color.GRAY);
requestList.setBackground(Color.GRAY); requestList.setBackground(Color.GRAY);
addRequest.addMouseListener(new MouseListener() { addRequest.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int i = 1; RequestData requestData = new RequestData();
JLabel jLabel= new JLabel("request"+i); ResponseData responseData = new ResponseData(requestData);
requestList.add(jLabel); JFrame newRequestFrame = new JFrame("request name");
i++; JLabel label = new JLabel("new request");
} JTextField textField = new JTextField();
@Override JPanel panel = new JPanel();
public void mousePressed(MouseEvent e) { label.setBounds(40,40,40,30);
} textField.setBounds(100, 40, 100,30);
JButton create = new JButton("create");
@Override textField.setPreferredSize(new Dimension(70,50));
public void mouseReleased(MouseEvent e) { panel.add(label);
panel.add(textField);
} panel.add(create);
newRequestFrame.add(panel);
@Override newRequestFrame.setPreferredSize(new Dimension(200,200));
public void mouseEntered(MouseEvent e) { newRequestFrame.setVisible(true);
requestData.setName(textField.getText());
} create.addMouseListener(new MouseAdapter() {
@Override
@Override public void mouseClicked(MouseEvent e) {
public void mouseExited(MouseEvent e) { super.mouseClicked(e);
requestData.setName(textField.getText());
JButton newRequest = new JButton(requestData.getName());
newRequest.addMouseListener(new MouseRequestClick(requestData , responseData ));
requestList.add(newRequest);
//ToDo:add action listener to button requests
}
});
} }
}); });
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
...@@ -78,4 +89,19 @@ public class LeftPanel extends JPanel { ...@@ -78,4 +89,19 @@ public class LeftPanel extends JPanel {
public JPanel getUp_left() { public JPanel getUp_left() {
return up_left; return up_left;
} }
private class MouseRequestClick extends MouseAdapter {
Saver saver = new Saver();
RequestData requestData = new RequestData();
ResponseData responseData = new ResponseData(requestData);
MouseRequestClick(RequestData requestData , ResponseData responseData){
this.requestData = requestData;
this.responseData = responseData;
}
@Override
public void mouseClicked(MouseEvent e){
super.mouseClicked(e);
}
}
} }
package com.insomnia.GUI; package com.insomnia.GUI;
import com.insomnia.parser.RequestData;
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 java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
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 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();
private JPanel mainCenterHeader = new JPanel(vfLayout); private JPanel mainCenterHeader = new JPanel(vfLayout);
private JScrollPane scrollPane_Header_Request = new JScrollPane(mainCenterHeader); private JScrollPane scrollPane_Header_Request = new JScrollPane(mainCenterHeader);
JPanel docs = new JPanel(); private HashMap<String , String> headers_values= new HashMap<>();
JTabbedPane tabbedPaneCenterRequest = new JTabbedPane(); private JPanel docs = new JPanel();
JTextField headerField = new JTextField("header"); private JTabbedPane tabbedPaneCenterRequest = new JTabbedPane();
JTextField valueField = new JTextField("value"); private JTextField headerField = new JTextField("header");
JCheckBox checkBox = new JCheckBox(); private JTextField valueField = new JTextField("value");
JButton delete = new JButton(); private JCheckBox checkBox = new JCheckBox();
JPanel rightOfHeader = new JPanel(); private JButton delete = new JButton();
JPanel center_header = new JPanel(new GridLayout(1,2)); private JPanel rightOfHeader = new JPanel();
JPanel header = new JPanel(new BorderLayout()); private JPanel center_header = new JPanel(new GridLayout(1,2));
String s []={"Patch","Put","Post","Delete","Get"}; private JPanel header = new JPanel(new BorderLayout());
JComboBox centerMenu = new JComboBox(s); private String s []={"Patch","Put","Post","Delete","Get"};
JTextField URLTextField = new JTextField("http://api.myproduct.com/v1/users"); private JComboBox centerMenu = new JComboBox(s);
JButton sendButton = new JButton("send"); private JTextField URLTextField = new JTextField("http://api.myproduct.com/v1/users");
JPanel centerUp = new JPanel(new BorderLayout()); private JButton sendButton = new JButton("send");
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);
...@@ -54,10 +54,26 @@ public class RequestPanel extends JPanel { ...@@ -54,10 +54,26 @@ public class RequestPanel extends JPanel {
tabbedPaneCenterRequest.add("Query" , query); tabbedPaneCenterRequest.add("Query" , query);
tabbedPaneCenterRequest.add("Header" , scrollPane_Header_Request); tabbedPaneCenterRequest.add("Header" , scrollPane_Header_Request);
tabbedPaneCenterRequest.add("Docs" , docs); tabbedPaneCenterRequest.add("Docs" , docs);
headerField.addMouseListener(new MouseListener() {
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);
MouseAdapter m = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
JTextField newHeaderField = new JTextField("header"); JTextField newHeaderField = new JTextField("header");
field.removeMouseListener(this);
field = newHeaderField;
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);
...@@ -65,6 +81,7 @@ public class RequestPanel extends JPanel { ...@@ -65,6 +81,7 @@ public class RequestPanel extends JPanel {
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));
newDelete.addMouseListener(deleteClick);
JPanel newRightOfHeader = new JPanel(); JPanel newRightOfHeader = new JPanel();
newRightOfHeader.add(newCheckBox); newRightOfHeader.add(newCheckBox);
newRightOfHeader.add(newDelete); newRightOfHeader.add(newDelete);
...@@ -75,32 +92,22 @@ public class RequestPanel extends JPanel { ...@@ -75,32 +92,22 @@ public class RequestPanel extends JPanel {
newHeader.add(newRightOfHeader, BorderLayout.EAST); newHeader.add(newRightOfHeader, BorderLayout.EAST);
newHeader.add(new_center_header, BorderLayout.CENTER); newHeader.add(new_center_header, BorderLayout.CENTER);
mainCenterHeader.add(newHeader ); mainCenterHeader.add(newHeader );
mainCenterHeader.validate();
}
@Override
public void mousePressed(MouseEvent e) {
} }
};
mainCenterHeader.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
} if (mainCenterHeader.getComponentCount()==0) m.mouseClicked(e);
@Override
public void mouseEntered(MouseEvent e) {
} }
});
field = headerField;
headerField.addMouseListener(m);
@Override
public void mouseExited(MouseEvent e) {
}
});
RequestPanel.TextFieldHandler textFieldHandler = new TextFieldHandler(headerField,mainCenterHeader,border);//create a actionListener
headerField.setFocusable(true); headerField.setFocusable(true);
headerField.addActionListener( textFieldHandler);
headerField.setBorder(border); headerField.setBorder(border);
valueField.setBorder(border); valueField.setBorder(border);
delete.setIcon(new ImageIcon(scaled)); delete.setIcon(new ImageIcon(scaled));
...@@ -115,8 +122,22 @@ public class RequestPanel extends JPanel { ...@@ -115,8 +122,22 @@ public class RequestPanel extends JPanel {
return tabbedPaneCenterRequest; return tabbedPaneCenterRequest;
} }
//request_up //request_up
public JPanel centerUp(){ public JPanel centerUp(){
sendButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
RequestData requestData = new RequestData();
// requestData.setUploadPath();
// requestData.setHeaders(mainCenterHeader.getComponents());
requestData.setUrl(URLTextField.getText());
//requestData.setJson();
super.mouseClicked(e);
Saver saver = new Saver();
}
});
centerMenu.setFont(new Font("Arial",20,15 )); centerMenu.setFont(new Font("Arial",20,15 ));
centerUp.add(centerMenu , BorderLayout.WEST); centerUp.add(centerMenu , BorderLayout.WEST);
...@@ -125,38 +146,7 @@ public class RequestPanel extends JPanel { ...@@ -125,38 +146,7 @@ public class RequestPanel extends JPanel {
return centerUp; return centerUp;
} }
class TextFieldHandler implements ActionListener {
JTextField headerField ;
JPanel mainCenterHeader;
Border border;
private TextFieldHandler(JTextField headerField , JPanel mainCenterHeader , Border border){
this.headerField = headerField;
this.mainCenterHeader = mainCenterHeader;
this.border = border;
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("++++++++++++");
if (!headerField.getText().equals("") ) {
JTextField newHeaderField = new JTextField("header");
newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value");
newValueField.setBorder(border);
JCheckBox newCheckBox = new JCheckBox();
JButton newDelete = new JButton(new ImageIcon("C:\\Users\\Lenovo\\IdeaProjects\\Insomnia\\src\\image\\1000582.png"));
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);
}
}
}
public void createRequestPanel() throws IOException { public void createRequestPanel() throws IOException {
addToMainRequestPanel(centerUp() , tabbedPaneCenterRequest()); addToMainRequestPanel(centerUp() , tabbedPaneCenterRequest());
...@@ -181,13 +171,6 @@ public class RequestPanel extends JPanel { ...@@ -181,13 +171,6 @@ public class RequestPanel extends JPanel {
return body; return body;
} }
public JPanel getAuth() {
return auth;
}
public JPanel getQuery() {
return query;
}
public JPanel getMainCenterHeader() { public JPanel getMainCenterHeader() {
return mainCenterHeader; return mainCenterHeader;
......
...@@ -8,6 +8,7 @@ package com.insomnia.parser; ...@@ -8,6 +8,7 @@ package com.insomnia.parser;
import java.util.HashMap; import java.util.HashMap;
public class RequestData { public class RequestData {
private String name;
//methods requests //methods requests
public static String GET = "GET", POST = "POST", DELETE="DELETE", PUT="PUT"; public static String GET = "GET", POST = "POST", DELETE="DELETE", PUT="PUT";
//address of request //address of request
...@@ -23,6 +24,14 @@ public class RequestData { ...@@ -23,6 +24,14 @@ public class RequestData {
private String body = ""; private String body = "";
private String uploadPath = ""; private String uploadPath = "";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isJson() { public boolean isJson() {
return isJson; return isJson;
} }
......
...@@ -90,7 +90,7 @@ public class ResponseData { ...@@ -90,7 +90,7 @@ public class ResponseData {
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String line = null; String line ;
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
sb.append(line); sb.append(line);
...@@ -109,18 +109,6 @@ public class ResponseData { ...@@ -109,18 +109,6 @@ public class ResponseData {
return sb.toString(); return sb.toString();
} }
public void setRequestData(RequestData requestData) {
this.requestData = requestData;
}
public void setFinalTime(long finalTime) {
this.finalTime = finalTime;
}
public boolean isSyntaxError() {
return syntaxError;
}
public void setSyntaxError(boolean syntaxError) { public void setSyntaxError(boolean syntaxError) {
this.syntaxError = syntaxError; this.syntaxError = syntaxError;
......
...@@ -32,7 +32,7 @@ public class Saver { ...@@ -32,7 +32,7 @@ public class Saver {
/** /**
* @return saved file name or empty if file didn't save * @return saved file name or empty if file didn't save
*/ */
public static String saveRequest (RequestData data) { public static String saveRequest(RequestData data) {
int size = new File(getRequestsDir()).list().length + 1; int size = new File(getRequestsDir()).list().length + 1;
String fileName = "Request "+size+".insomnia"; String fileName = "Request "+size+".insomnia";
File file = new File(getRequestsDir(),fileName); File file = new File(getRequestsDir(),fileName);
...@@ -60,7 +60,26 @@ public class Saver { ...@@ -60,7 +60,26 @@ public class Saver {
} }
} }
public static RequestData readRequest (String fileName){ public void saveRequest2 (RequestData data) {
String fileName = data.getName()+".insomnia";
File file = new File(getRequestsDir(),fileName);
try {
file.createNewFile();
FileOutputStream fo = new FileOutputStream(file);
ObjectOutputStream out = new ObjectOutputStream(fo);
out.writeObject(data);
out.close();
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public RequestData readRequest (String fileName){
try { try {
FileInputStream file = new FileInputStream(new File(getRequestsDir(),fileName)); FileInputStream file = new FileInputStream(new File(getRequestsDir(),fileName));
ObjectInputStream in = new ObjectInputStream(file); ObjectInputStream in = new ObjectInputStream(file);
...@@ -76,7 +95,7 @@ public class Saver { ...@@ -76,7 +95,7 @@ public class Saver {
return null; return null;
} }
public static void saveResponse (ResponseData data){ public static void saveResponse(ResponseData data){
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")){
......
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