diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java')
| -rw-r--r-- | Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java new file mode 100644 index 0000000..31ca1c2 --- /dev/null +++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java @@ -0,0 +1,187 @@ +package main; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; + +import de.h_da.fbi.dsi.ws0910.camelprototype.InputNewOrder; +import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpoint; +import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpointServiceLocator; +import de.h_da.fbi.dsi.ws0910.camelprototype.OrderPosition; +import de.h_da.fbi.dsi.ws0910.camelprototype.OutputNewOrder; + + +/** +* This code was edited or generated using CloudGarden's Jigloo +* SWT/Swing GUI Builder, which is free for non-commercial +* use. If Jigloo is being used commercially (ie, by a corporation, +* company or business for any purpose whatever) then you +* should purchase a license for each developer using Jigloo. +* Please visit www.cloudgarden.com for details. +* Use of Jigloo implies acceptance of these licensing terms. +* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR +* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED +* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. +*/ +public class WsClientMainFrame extends javax.swing.JFrame { + private static final long serialVersionUID = 1L; + private OrderPosTableModel orderPosTableModel; + private OrderPosEditor orderPosCellEditor; + private JButton submitBtn; + private JButton cancelButton; + private JTable orderPosTable; + private JScrollPane jScrollPane1; + private JLabel posLabel; + private JTextField custNoField; + private JLabel custNoLabel; + private JTextField msgField; + private JTextField statusField; + private JLabel msgLabel; + private JLabel statusLabel; + + /** + * Auto-generated main method to display this JFrame + */ + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + WsClientMainFrame inst = new WsClientMainFrame(); + inst.setLocationRelativeTo(null); + inst.setVisible(true); + } + }); + } + + public WsClientMainFrame() { + super(); + initGUI(); + } + + private void initGUI() { + try { + orderPosTableModel = new OrderPosTableModel(); + orderPosCellEditor = new OrderPosEditor(); + FormLayout thisLayout = new FormLayout( + "5dlu, 54dlu, 5dlu, 64dlu, 64dlu, 64dlu", + "5dlu, max(p;5dlu), 5dlu, 48dlu, 5dlu, max(p;15dlu), 5dlu, 14dlu, 5dlu, max(p;15dlu), 5dlu, max(p;5dlu)"); + getContentPane().setLayout(thisLayout); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setTitle("DSI WS09/10 CamelPrototype WS Client"); + this.setPreferredSize(new java.awt.Dimension(520, 300)); + { + submitBtn = new JButton(); + getContentPane().add(submitBtn, new CellConstraints("4, 12, 1, 1, default, default")); + submitBtn.setText("Submit"); + submitBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(orderPosTable.isEditing()) { + if(!orderPosTable.getCellEditor().stopCellEditing()) { + return; + } + } + if(custNoField.getText().isEmpty()) { + statusField.setText("Not OK!"); + msgField.setText("Customer No. empty!"); + return; + } + OrderPosition[] orderPos = orderPosTableModel.getOrderPositions(); + if(orderPos.length == 0) { + statusField.setText("Not OK!"); + msgField.setText("No valid order positions!"); + return; + } + InputNewOrder in = new InputNewOrder(); + in.setCustomerNo(custNoField.getText()); + in.setOrderpositions(orderPos); + OrderEndpointServiceLocator loc = new OrderEndpointServiceLocator(); + try { + OrderEndpoint client = loc.getOrderService(); + OutputNewOrder out = client.createOrder(in); + String status = "0".equals(out.getStatus())?"OK":"Not OK"; + statusField.setText(status); + msgField.setText("Received Order No.: "+out.getMessage()); + } catch (Exception e1) { + e1.printStackTrace(); + } + + } + }); + } + { + cancelButton = new JButton(); + getContentPane().add(cancelButton, new CellConstraints("6, 12, 1, 1, default, default")); + cancelButton.setText("Cancel"); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + orderPosTableModel.clear(); + custNoField.setText(""); + statusField.setText(""); + msgField.setText(""); + } + }); + } + { + jScrollPane1 = new JScrollPane(); + getContentPane().add(jScrollPane1, new CellConstraints("4, 4, 3, 3, default, default")); + { + orderPosTable = new JTable(); + jScrollPane1.setViewportView(orderPosTable); + orderPosTable.setModel(orderPosTableModel); + orderPosTable.setColumnSelectionAllowed(true); + orderPosTable.setCellEditor(orderPosCellEditor); + orderPosTable.getColumnModel().getColumn(2).setCellEditor(new OrderPosAmountEditor(new JTextField(), new OrderPosInputVerifier())); + orderPosTable.getTableHeader().setLocale(new java.util.Locale("de")); + } + } + { + statusLabel = new JLabel(); + getContentPane().add(statusLabel, new CellConstraints("2, 8, 1, 1, default, default")); + statusLabel.setText("Status"); + } + { + msgLabel = new JLabel(); + getContentPane().add(msgLabel, new CellConstraints("2, 10, 1, 1, default, default")); + msgLabel.setText("Message"); + } + { + statusField = new JTextField(); + getContentPane().add(statusField, new CellConstraints("4, 8, 3, 1, default, default")); + statusField.setEditable(false); + } + { + msgField = new JTextField(); + getContentPane().add(msgField, new CellConstraints("4, 10, 3, 1, default, default")); + msgField.setEditable(false); + } + { + custNoLabel = new JLabel(); + getContentPane().add(custNoLabel, new CellConstraints("2, 2, 1, 1, default, default")); + custNoLabel.setText("Customer No."); + } + { + custNoField = new JTextField(); + getContentPane().add(custNoField, new CellConstraints("4, 2, 1, 1, default, default")); + } + { + posLabel = new JLabel(); + getContentPane().add(posLabel, new CellConstraints("2, 4, 1, 1, default, top")); + posLabel.setText("Order Positions"); + } + pack(); + this.setSize(540, 300); + } catch (Exception e) { + e.printStackTrace(); + } + } +} |
