package org.fnppl.opensdx.gui; import java.util.Vector; import javax.swing.DefaultListModel; import org.fnppl.opensdx.common.ActionHttp; import org.fnppl.opensdx.common.ActionMailTo; import org.fnppl.opensdx.common.TriggeredActions; import org.fnppl.opensdx.gui.helper.MyObservable; import org.fnppl.opensdx.gui.helper.MyObserver; /* * Copyright (C) 2010-2015 * fine people e.V. <opensdx@fnppl.org> * Henning Thieß <ht@fnppl.org> * * http://fnppl.org */ /* * Software license * * As far as this file or parts of this file is/are software, rather than documentation, this software-license applies / shall be applied. * * This file is part of openSDX * openSDX is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * openSDX is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * and GNU General Public License along with openSDX. * If not, see <http://www.gnu.org/licenses/>. * */ /* * Documentation license * * As far as this file or parts of this file is/are documentation, rather than software, this documentation-license applies / shall be applied. * * This file is part of openSDX. * Permission is granted to copy, distribute and/or modify this document * under the terms of the GNU Free Documentation License, Version 1.3 * or any later version published by the Free Software Foundation; * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. * A copy of the license is included in the section entitled "GNU * Free Documentation License" resp. in the file called "FDL.txt". * */ public class PanelActionMailTo extends javax.swing.JPanel implements MyObservable { /** Creates new form PanelActionHTTP */ public PanelActionMailTo() { initComponents(); action = ActionMailTo.make("", "",""); setActionMailTo(action); setTrigger(TriggeredActions.TRIGGER_ONFULLSUCCESS); } private ActionMailTo action = null; public void setActionMailTo(ActionMailTo action) { this.action = action; text_receiver.setText(action.getReceiver()); text_subject.setText(action.getSubject()); text_mailtext.setText(action.getText()); } public ActionMailTo getActionMailTo() { action = ActionMailTo.make(text_receiver.getText(), text_subject.getText(), text_mailtext.getText()); return action; } public void setTrigger(int triggerID) { if(triggerID>=0 && triggerID<select_trigger.getModel().getSize()) { select_trigger.setSelectedIndex(triggerID); } } public int getTrigger() { return select_trigger.getSelectedIndex(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { text_receiver = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); select_trigger = new javax.swing.JComboBox(); text_subject = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); text_mailtext = new javax.swing.JTextArea(); setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder("HTTP Action"))); jLabel1.setText("receiver"); jLabel2.setText("subject"); jLabel5.setText("Trigger"); select_trigger.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[no trigger]", "on initial receive", "on process start", "on process end", "on full success", "on error" })); text_mailtext.setColumns(20); text_mailtext.setRows(5); text_mailtext.setBorder(javax.swing.BorderFactory.createTitledBorder("Text")); jScrollPane1.setViewportView(text_mailtext); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) .addGap(32, 32, 32))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(select_trigger, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(text_receiver, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE) .addComponent(text_subject, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)) .addContainerGap()))) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(select_trigger, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(text_receiver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(text_subject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JComboBox select_trigger; private javax.swing.JTextArea text_mailtext; private javax.swing.JTextField text_receiver; private javax.swing.JTextField text_subject; // End of variables declaration//GEN-END:variables private Vector<MyObserver> observers = new Vector<MyObserver>(); public void addObserver(MyObserver observer) { observers.add(observer); } public void notifyChanges() { for (MyObserver ob : observers) { ob.notifyChange(this); } } }