Skip to content

Commit

Permalink
Merge pull request #29 from usdAG/develop
Browse files Browse the repository at this point in the history
Merge Develop into Master
  • Loading branch information
qtc-de authored Jul 10, 2020
2 parents 27b1762 + 498d810 commit 48b8fd2
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 67 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.2.1] - 2020-07-10

### Changed

* Fix bug in the *Save* function that prevented certain recipes from being saved
* Fix SoapMultiSignature operation (was not displayed in operations tree)
* Remove notifyChange listeners from *Button* objects
* Remove empty tooltipps from operation categories


## [1.2.0] - 2020-06-28

### Added
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.usd.CSTC</groupId>
<artifactId>CSTC</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<name>CSTC</name>
<description>CSTC</description>
<properties>
Expand Down
3 changes: 2 additions & 1 deletion src/de/usd/cstchef/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import de.usd.cstchef.operations.setter.JsonSetter;
import de.usd.cstchef.operations.setter.LineSetter;
import de.usd.cstchef.operations.signature.RsaSignature;
import de.usd.cstchef.operations.signature.SoapMultiSignature;
import de.usd.cstchef.operations.signature.XmlFullSignature;
import de.usd.cstchef.operations.signature.XmlMultiSignature;
import de.usd.cstchef.operations.string.Length;
Expand Down Expand Up @@ -237,7 +238,7 @@ public static Class<? extends Operation>[] getOperationsDev() {
Suffix.class, Sum.class, StringContains.class, StringMatch.class, Tiger.class,
ToBase64.class, ToHex.class, UnixTimestamp.class, UrlDecode.class, UrlEncode.class,
Whirlpool.class, WriteFile.class, XmlFullSignature.class, XmlMultiSignature.class,
Xor.class
Xor.class, SoapMultiSignature.class
};
}

Expand Down
65 changes: 43 additions & 22 deletions src/de/usd/cstchef/operations/Operation.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
package de.usd.cstchef.operations;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.EOFException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.HashMap;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextField;
Expand All @@ -25,23 +44,6 @@
import de.usd.cstchef.view.ui.VariableTextArea;
import de.usd.cstchef.view.ui.VariableTextField;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.EOFException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.HashMap;
import java.util.Map;

public abstract class Operation extends JPanel {

private static Color defaultBgColor = new Color(223, 240, 216);
Expand Down Expand Up @@ -176,15 +178,20 @@ public void actionPerformed(ActionEvent e) {
public Map<String, Object> getState() {
Map<String, Object> properties = new HashMap<>();
for (String key : this.uiElements.keySet()) {
properties.put(key, getUiValues(this.uiElements.get(key)));
if( key.startsWith("noupdate") )
properties.put(key, null);
else
properties.put(key, getUiValues(this.uiElements.get(key)));
}

return properties;
}

private Object getUiValues(Component comp) {
Object result = null;
if (comp instanceof VariableTextArea) {
if (comp instanceof JPasswordField) {
result = "";
} else if (comp instanceof VariableTextArea) {
result = ((VariableTextArea) comp).getRawText();
} else if (comp instanceof VariableTextField) {
result = ((VariableTextField) comp).getRawText();
Expand All @@ -200,6 +207,8 @@ private Object getUiValues(Component comp) {
result = ((JCheckBox) comp).isSelected();
} else if (comp instanceof FormatTextField) {
result = ((FormatTextField) comp).getValues();
} else if (comp instanceof JFileChooser) {
result = ((JFileChooser) comp).getName();
}

return result;
Expand All @@ -213,7 +222,7 @@ public void load(Map<String, Object> parameters) {
}

private void setUiValue(Component comp, Object value) {
if (comp == null) {
if (comp == null || value == null) {
return;
}

Expand All @@ -229,6 +238,8 @@ private void setUiValue(Component comp, Object value) {
((JCheckBox) comp).setSelected((boolean) value);
} else if (comp instanceof FormatTextField) {
((FormatTextField) comp).setValues((Map<String, String>) value);
} else if (comp instanceof JFileChooser) {
((JFileChooser) comp).setName((String)value);
}
}

Expand Down Expand Up @@ -275,10 +286,18 @@ private void changeFontColor(Container container, Color color) {
}

protected void addUIElement(String caption, Component comp) {
this.addUIElement(caption, comp, true);
this.addUIElement(caption, comp, true, null);
}

protected void addUIElement(String caption, Component comp, boolean notifyChange) {
this.addUIElement(caption, comp, notifyChange, null);
}

protected void addUIElement(String caption, Component comp, String identifier) {
this.addUIElement(caption, comp, true, identifier);
}

protected void addUIElement(String caption, Component comp, boolean notifyChange, String identifier) {
comp.setCursor(Cursor.getDefaultCursor());

Box box = Box.createHorizontalBox();
Expand All @@ -292,7 +311,9 @@ protected void addUIElement(String caption, Component comp, boolean notifyChange
box.add(comp);
this.contentBox.add(box);
this.contentBox.add(Box.createVerticalStrut(10));
this.uiElements.put(caption, comp);
if( identifier == null )
identifier = caption;
this.uiElements.put(identifier, comp);

if (notifyChange) {
if (notifyChangeListener == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/dataformat/HtmlEncode.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ protected byte[] perform(byte[] input) throws Exception {
public void createUI() {
this.checkbox = new JCheckBox("Encode all");
this.checkbox.setSelected(false);
this.addUIElement(null, this.checkbox);
this.addUIElement(null, this.checkbox, "checkbox1");
}
}
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/dataformat/UrlEncode.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ protected byte[] perform(byte[] input) throws Exception {
public void createUI() {
this.checkbox = new JCheckBox("Encode all");
this.checkbox.setSelected(false);
this.addUIElement(null, this.checkbox);
this.addUIElement(null, this.checkbox, "checkbox1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HttpUriExtractor extends Operation {
public void createUI() {
this.checkbox = new JCheckBox("With parameters");
this.checkbox.setSelected(true);
this.addUIElement(null, this.checkbox);
this.addUIElement(null, this.checkbox, "checkbox1");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/misc/ReadFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void createUI() {

JButton chooseFileButton = new JButton("Select file");
chooseFileButton.addActionListener(this);
this.addUIElement(null, chooseFileButton);
this.addUIElement(null, chooseFileButton, false, "button1");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/misc/WriteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void createUI() {

JButton chooseFileButton = new JButton("Select file");
chooseFileButton.addActionListener(this);
this.addUIElement(null, chooseFileButton);
this.addUIElement(null, chooseFileButton, false, "button1");
}


Expand Down
6 changes: 3 additions & 3 deletions src/de/usd/cstchef/operations/setter/HttpGetSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public void createUI() {

this.urlEncode = new JCheckBox("URL encode");
this.urlEncode.setSelected(false);
this.addUIElement(null, this.urlEncode);
this.addUIElement(null, this.urlEncode, "checkbox1");

this.urlEncodeAll = new JCheckBox("URL encode all");
this.urlEncodeAll.setSelected(false);
this.addUIElement(null, this.urlEncodeAll);
this.addUIElement(null, this.urlEncodeAll, "checkbox2");

this.addIfNotPresent = new JCheckBox("Add if not present");
this.addIfNotPresent.setSelected(true);
this.addUIElement(null, this.addIfNotPresent);
this.addUIElement(null, this.addIfNotPresent, "checkbox3");
}
}
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/setter/HttpHeaderSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void createUI() {
super.createUI();
this.addIfNotPresent = new JCheckBox("Add if not present");
this.addIfNotPresent.setSelected(true);
this.addUIElement(null, this.addIfNotPresent);
this.addUIElement(null, this.addIfNotPresent, "checkbox1");
}

}
6 changes: 3 additions & 3 deletions src/de/usd/cstchef/operations/setter/HttpPostSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public void createUI() {

this.urlEncode = new JCheckBox("URL encode");
this.urlEncode.setSelected(false);
this.addUIElement(null, this.urlEncode);
this.addUIElement(null, this.urlEncode, "checkbox1");

this.urlEncodeAll = new JCheckBox("URL encode all");
this.urlEncodeAll.setSelected(false);
this.addUIElement(null, this.urlEncodeAll);
this.addUIElement(null, this.urlEncodeAll, "checkbox2");

this.addIfNotPresent = new JCheckBox("Add if not present");
this.addIfNotPresent.setSelected(true);
this.addUIElement(null, this.addIfNotPresent);
this.addUIElement(null, this.addIfNotPresent, "checkbox3");
}

}
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/setter/HttpSetCookie.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void createUI() {
super.createUI();
this.addIfNotPresent = new JCheckBox("Add if not present");
this.addIfNotPresent.setSelected(true);
this.addUIElement(null, this.addIfNotPresent);
this.addUIElement(null, this.addIfNotPresent, "checkbox1");
}

}
2 changes: 1 addition & 1 deletion src/de/usd/cstchef/operations/setter/HttpSetUri.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void createUI() {

this.checkbox = new JCheckBox("Keep parameters");
this.checkbox.setSelected(false);
this.addUIElement(null, this.checkbox);
this.addUIElement(null, this.checkbox, "checkbox1");
}


Expand Down
10 changes: 5 additions & 5 deletions src/de/usd/cstchef/operations/setter/JsonSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public void createUI() {
this.addIfNotPresent = new JCheckBox("Add if not present");
this.addIfNotPresent.setSelected(true);
this.addIfNotPresent.addActionListener(this);
this.addUIElement(null, this.addIfNotPresent);
this.addUIElement(null, this.addIfNotPresent, "checkbox1");

this.path = new VariableTextField();
this.path.setText("Insert-Path");
this.path.setForeground(Color.GRAY);
this.path.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (path.getText().equals("Insert-Path")) {
if (path.getText().equals("Insertion Path")) {
path.setText("");
path.setForeground(null);
}
Expand All @@ -71,13 +71,13 @@ public void focusGained(FocusEvent e) {
public void focusLost(FocusEvent e) {
if (path.getText().isEmpty()) {
path.setForeground(Color.GRAY);
path.setText("Insert-Path");
path.setText("Insertion Path");
}
}
});
this.addUIElement(null, this.path);
this.addUIElement(null, this.path, "textbox1");
}

@Override
public void actionPerformed(ActionEvent arg0) {
if( arg0.getSource() == this.addIfNotPresent ) {
Expand Down
3 changes: 2 additions & 1 deletion src/de/usd/cstchef/operations/setter/LineSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public void createUI() {
super.createUI();
this.append = new JCheckBox("Insert below");
this.append.setSelected(false);
this.addUIElement(null, this.append);
this.addUIElement(null, this.append, "checkbox1");

this.formatBox = new JComboBox<>(new String[] {"\\r\\n", "\\r", "\\n"});
this.formatBox.setSelectedItem("\\r\\n");
this.addUIElement("Lineseperator", this.formatBox);
Expand Down
Loading

0 comments on commit 48b8fd2

Please sign in to comment.