Skip to content

Commit

Permalink
wiztools#72 body tab implementation added
Browse files Browse the repository at this point in the history
  • Loading branch information
subwiz committed Aug 27, 2018
1 parent 457e3ee commit ca15f71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wiztools.restclient.util;

import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -8,6 +9,7 @@
import java.util.regex.Pattern;
import org.wiztools.commons.Charsets;
import org.wiztools.commons.MultiValueMap;
import org.wiztools.commons.MultiValueMapLinkedHashSet;
import org.wiztools.commons.StringUtil;
import org.wiztools.restclient.bean.ContentType;
import org.wiztools.restclient.bean.ContentTypeBean;
Expand Down Expand Up @@ -197,4 +199,19 @@ public static boolean isEntityEnclosingMethod(final String method) {
public static boolean isEntityEnclosingMethod(final HTTPMethod method) {
return isEntityEnclosingMethod(method.name());
}

public static MultiValueMap<String, String> getXWwwFormUrlEncoded2Map(String str) {
MultiValueMap<String, String> out = new MultiValueMapLinkedHashSet<>();
String[] pairs = str.split("\\&");
for(String pair: pairs) {
String[] fields = pair.split("=");
if(fields.length != 2) {
continue;
}
String key = URLDecoder.decode(fields[0], Charsets.UTF_8);
String value = URLDecoder.decode(fields[1], Charsets.UTF_8);
out.put(key, value);
}
return out;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public void actionPerformed(ActionEvent event) {
this.setContentPane(jp);
pack();
}

public void setData(MultiValueMap<String, String> data) {
jp_2col_center.setData(data);
}

@Override
public void doEscape(AWTEvent event){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.wiztools.restclient.ui.component.BodyPopupMenu;
import org.wiztools.restclient.ui.component.BodyPopupMenuListener;
import org.wiztools.restclient.ui.dnd.FileDropTargetListener;
import org.wiztools.restclient.util.HttpUtil;

/**
*
Expand Down Expand Up @@ -65,6 +66,7 @@ protected void init() {
jb_body_params.addActionListener((ActionEvent ae) -> {
if(canSetReqBodyText()) {
checkAndSetParameterContentType();
jd_req_paramDialog.setData(HttpUtil.getXWwwFormUrlEncoded2Map(se_req_body.getText()));
jd_req_paramDialog.setLocationRelativeTo(rest_ui.getFrame());
jd_req_paramDialog.setVisible(true);
}
Expand Down

0 comments on commit ca15f71

Please sign in to comment.