Commit b153bff8 authored by 9731301's avatar 9731301

complete request and respond pard and add some buttons and features

parent a23a0a5d
......@@ -75,6 +75,8 @@
<workItem from="1588425228961" duration="8554000" />
<workItem from="1588437622203" duration="6269000" />
<workItem from="1588522915548" duration="9323000" />
<workItem from="1589030581229" duration="11616000" />
<workItem from="1589063831974" duration="14071000" />
</task>
<servers />
</component>
......@@ -82,30 +84,30 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="309" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1588443249650">
<state x="309" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1589071976072">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="309" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1588443249650" />
<state width="799" height="75" key="GridCell.Tab.0.bottom" timestamp="1588535347969">
<state x="309" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1589071976072" />
<state width="1493" height="13" key="GridCell.Tab.0.bottom" timestamp="1589078975612">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="799" height="75" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1588535347969" />
<state width="799" height="75" key="GridCell.Tab.0.center" timestamp="1588535347968">
<state width="1493" height="13" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1589078975612" />
<state width="1493" height="13" key="GridCell.Tab.0.center" timestamp="1589078975612">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="799" height="75" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1588535347968" />
<state width="799" height="75" key="GridCell.Tab.0.left" timestamp="1588535347968">
<state width="1493" height="13" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1589078975612" />
<state width="1493" height="13" key="GridCell.Tab.0.left" timestamp="1589078975612">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="799" height="75" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1588535347968" />
<state width="799" height="75" key="GridCell.Tab.0.right" timestamp="1588535347969">
<state width="1493" height="13" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1589078975612" />
<state width="1493" height="13" key="GridCell.Tab.0.right" timestamp="1589078975612">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="799" height="75" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1588535347969" />
<state x="425" y="237" key="com.intellij.ide.util.TipDialog" timestamp="1588522979439">
<state width="1493" height="13" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1589078975612" />
<state x="425" y="237" key="com.intellij.ide.util.TipDialog" timestamp="1589064073545">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="425" y="237" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1588522979439" />
<state x="425" y="237" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1589064073545" />
<state x="46" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1588333540387">
<screen x="0" y="0" width="1536" height="824" />
</state>
......
import javafx.scene.transform.Shear;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class InsomniaGUI {
JFrame frame ;
......@@ -12,6 +18,8 @@ public class InsomniaGUI {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
VerticalFlowLayout vfLayout = new VerticalFlowLayout();
Border border = BorderFactory.createLineBorder(Color.BLACK,3);
JMenuBar upperMenuBar = new JMenuBar();
......@@ -34,8 +42,10 @@ public class InsomniaGUI {
auth.setBackground(Color.GRAY);
JPanel query = new JPanel();
query.setBackground(Color.GRAY);
JPanel header = new JPanel(new BorderLayout());
header.setBackground(Color.GRAY);
JPanel mainCenterHeader = new JPanel(vfLayout);
mainCenterHeader.setBackground(Color.GRAY);
JScrollPane scrollPane_Header_Request = new JScrollPane(mainCenterHeader);
scrollPane_Header_Request.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JPanel docs = new JPanel();
docs.setBackground(Color.GRAY);
......@@ -46,20 +56,73 @@ public class InsomniaGUI {
tabbedPaneCenterRequest.add("Body" , body);
tabbedPaneCenterRequest.add("Auth" , auth);
tabbedPaneCenterRequest.add("Query" , query);
tabbedPaneCenterRequest.add("Header" , header);
tabbedPaneCenterRequest.add("Header" , scrollPane_Header_Request);
tabbedPaneCenterRequest.add("Docs" , docs);
JTextField headerField = new JTextField("header");
headerField.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
JTextField newHeaderField = new JTextField("header");
newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value");
newValueField.setBorder(border);
JCheckBox newCheckBox = new JCheckBox();
ImageIcon newQuitIcon = new ImageIcon();
JButton newDelete = new JButton(newQuitIcon);
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 );
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
TextFieldHandler textFieldHandler = new TextFieldHandler(headerField,mainCenterHeader,border);//create a actionListener
headerField.setFocusable(true);
headerField.addActionListener( textFieldHandler);
headerField.setBorder(border);
JTextField valueField = new JTextField("value");
valueField.setBorder(border);
JCheckBox checkBox = new JCheckBox();
JButton delete = new JButton();
ImageIcon quitIcon = new ImageIcon();
JButton delete = new JButton(quitIcon);
JPanel rightOfHeader = new JPanel();
rightOfHeader.add(checkBox);
rightOfHeader.add(delete);
JPanel center_header = new JPanel(new GridLayout(1,2));
center_header.add(headerField);
center_header.add(valueField);
header.add(checkBox,BorderLayout.EAST);
JPanel header = new JPanel(new BorderLayout());
header.add(rightOfHeader,BorderLayout.EAST);
header.add(center_header,BorderLayout.CENTER);
header.add(delete,BorderLayout.WEST);
mainCenterHeader.add(header);
//request_up
......@@ -83,8 +146,15 @@ public class InsomniaGUI {
//respond
JPanel row = new JPanel();
row.setBackground(Color.GRAY);
JPanel header2 = new JPanel();
header2.setBackground(Color.GRAY);
JPanel mainCenterHeader_respond = new JPanel(vfLayout);
JScrollPane scrollPane_Header_Request2 = new JScrollPane(mainCenterHeader_respond);
scrollPane_Header_Request.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
mainCenterHeader_respond.setBackground(Color.GRAY);
JPanel header_MainPanel = new JPanel(new BorderLayout());
header_MainPanel.setBackground(Color.GRAY);
JButton copyToClipBoard = new JButton("copy to clip board");
header_MainPanel.add(scrollPane_Header_Request2 , BorderLayout.CENTER);
header_MainPanel.add(copyToClipBoard,BorderLayout.SOUTH);
JPanel cookie = new JPanel();
cookie.setBackground(Color.GRAY);
JPanel timeline = new JPanel(new BorderLayout());
......@@ -92,16 +162,65 @@ public class InsomniaGUI {
JTabbedPane tabbedPaneCenterResponse = new JTabbedPane();
tabbedPaneCenterResponse.setBackground(Color.GRAY);
tabbedPaneCenterResponse.add("Row" , row);
tabbedPaneCenterResponse.add("Header" ,header2);
tabbedPaneCenterResponse.add("Header" , header_MainPanel);
tabbedPaneCenterResponse.add("Cookie", cookie);
tabbedPaneCenterResponse.add("Timeline" , timeline);
JPanel response = new JPanel(new BorderLayout());
JTextField headerField2 = new JTextField("header");
headerField2.setEditable(false);
headerField2.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(")))))))))))");
// if (!headerField2.getText().equals("") ) {
JTextField newHeaderField = new JTextField("header");
newHeaderField.setEditable(false);
newHeaderField.setBorder(border);
JTextField newValueField = new JTextField("value");
newValueField.setEditable(false);
newValueField.setBorder(border);
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(new_center_header, BorderLayout.CENTER);
mainCenterHeader_respond.add(newHeader );
// }
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
headerField2.setBorder(border);
JTextField valueField2 = new JTextField("value");
valueField2.setEditable(false);
valueField2.setBorder(border);
JPanel center_header2 = new JPanel(new GridLayout(1,2));
center_header2.add(headerField2);
center_header2.add(valueField2);
header2.add(center_header2);
JPanel header2 = new JPanel(new BorderLayout());
header2.add(center_header2,BorderLayout.CENTER);
mainCenterHeader_respond.add(header2);
JPanel up_response = new JPanel();
JLabel label1 = new JLabel("ok");
......@@ -126,8 +245,44 @@ public class InsomniaGUI {
menu.setFont(new Font("Arial",20,15 ));
menu.setBorder(border);
menu.setPreferredSize(new Dimension(200,60));
JButton addRequest = new JButton("Add Request");
JPanel up_left = new JPanel(new GridLayout(2,1));
up_left.add(menu);
up_left.add(addRequest);
JPanel requestList = new JPanel(vfLayout);
JScrollPane scrollRequests = new JScrollPane(requestList);
addRequest.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
int i = 1;
JLabel jLabel= new JLabel("request"+i);
requestList.add(jLabel);
i++;
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
JPanel panelLeft = new JPanel(new BorderLayout());
panelLeft.add(menu , BorderLayout.NORTH);
panelLeft.add(up_left , BorderLayout.NORTH);
panelLeft.add(scrollRequests, BorderLayout.CENTER);
panelLeft.setBackground(Color.LIGHT_GRAY);
JPanel panel = new JPanel(new BorderLayout());
......@@ -137,4 +292,38 @@ public class InsomniaGUI {
frame.getContentPane().add(panel);
}
private 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();
ImageIcon newQuitIcon = new ImageIcon();
JButton newDelete = new JButton(newQuitIcon);
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);
}
}
}
}
/**
* @author Pasban
*/
import java.awt.*;
import java.util.*;
class VerticalFlowLayout implements LayoutManager {
public final static int CENTER = 0;
public final static int RIGHT = 1;
public final static int LEFT = 2;
public final static int BOTH = 3;
public final static int TOP = 1;
public final static int BOTTOM = 2;
private int vgap;
private int alignment;
private int anchor;
private Hashtable comps;
public VerticalFlowLayout() {
this(5, CENTER, TOP);
}
public VerticalFlowLayout(int vgap) {
this(vgap, CENTER, TOP);
}
public VerticalFlowLayout(int vgap, int alignment) {
this(vgap, alignment, TOP);
}
public VerticalFlowLayout(int vgap, int alignment, int anchor) {
this.vgap = vgap;
this.alignment = alignment;
this.anchor = anchor;
}
private Dimension layoutSize(Container parent, boolean minimum) {
Dimension dim = new Dimension(0, 0);
Dimension d;
synchronized (parent.getTreeLock()) {
int n = parent.getComponentCount();
for (int i = 0; i < n; i++) {
Component c = parent.getComponent(i);
if (c.isVisible()) {
d = minimum ? c.getMinimumSize() : c.getPreferredSize();
dim.width = Math.max(dim.width, d.width);
dim.height += d.height;
if (i > 0) {
dim.height += vgap;
}
}
}
}
Insets insets = parent.getInsets();
dim.width += insets.left + insets.right;
dim.height += insets.top + insets.bottom + vgap + vgap;
return dim;
}
public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();
synchronized (parent.getTreeLock()) {
int n = parent.getComponentCount();
Dimension pd = parent.getSize();
int y = 0;
for (int i = 0; i < n; i++) {
Component c = parent.getComponent(i);
Dimension d = c.getPreferredSize();
if (c.isVisible()) {
y += d.height + vgap;
}
}
y -= vgap;
if (anchor == TOP) {
y = insets.top;
} else if (anchor == CENTER) {
y = (pd.height - y) / 2;
} else {
y = pd.height - y - insets.bottom;
}
for (int i = 0; i < n; i++) {
Component c = parent.getComponent(i);
Dimension d = c.getPreferredSize();
if (!c.isVisible()) {
continue;
}
int x = 1;
int wid = pd.width - 3;
c.setBounds(x, y, wid, d.height);
y += d.height + vgap;
}
}
}
public Dimension minimumLayoutSize(Container parent) {
return layoutSize(parent, false);
}
public Dimension preferredLayoutSize(Container parent) {
return layoutSize(parent, false);
}
public void addLayoutComponent(String name, Component comp) {
}
public void removeLayoutComponent(Component comp) {
}
public String toString() {
return getClass().getName() + "[vgap=" + vgap + " align=" + alignment + " anchor=" + anchor + "]";
}
}
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