/* * Copyright 2011 Research In Motion Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package eclserver.panels; /** * * @author rbalsewich */ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.event.EventListenerList; import javax.swing.JOptionPane; public class EmergencyNotificationPanel extends javax.swing.JPanel implements ActionListener { /** Creates new form EmergencyNotificationPanel */ public EmergencyNotificationPanel() { initComponents(); listeners = new EventListenerList(); } @Override public void actionPerformed(ActionEvent e) { } private void fireActionEvent(ActionEvent evt) { ActionListener[] listenerList = listeners.getListeners(ActionListener.class); for (int i = listenerList.length-1; i>=0; --i) { listenerList[i].actionPerformed(evt); } } public void addActionListener(ActionListener listener) { listeners.add(ActionListener.class, listener); } public void removeActionListener(ActionListener listener) { if (listeners != null) { listeners.remove(ActionListener.class, listener); } } public String getNotifyDetails(){ return txtNotificationDetails.getText(); } public void printToResults(String message){ notifyResultsArea.append(message); } public void resetButtons(){ this.btnCancelNotification.setEnabled(false); this.btnSendNotification.setEnabled(true); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel33 = new javax.swing.JPanel(); jScrollPane9 = new javax.swing.JScrollPane(); notifyResultsArea = new javax.swing.JTextArea(); jPanel9 = new javax.swing.JPanel(); btnSendNotification = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); txtNotificationDetails = new javax.swing.JTextArea(); btnCancelNotification = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jPanel33.setBorder(javax.swing.BorderFactory.createTitledBorder("Results")); notifyResultsArea.setColumns(20); notifyResultsArea.setLineWrap(true); notifyResultsArea.setRows(5); jScrollPane9.setViewportView(notifyResultsArea); javax.swing.GroupLayout jPanel33Layout = new javax.swing.GroupLayout(jPanel33); jPanel33.setLayout(jPanel33Layout); jPanel33Layout.setHorizontalGroup( jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel33Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 777, Short.MAX_VALUE) .addContainerGap()) ); jPanel33Layout.setVerticalGroup( jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel33Layout.createSequentialGroup() .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE) .addContainerGap()) ); jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Notification Details")); btnSendNotification.setText("Send Notification"); btnSendNotification.setActionCommand("SEND_NOTIFICATION"); btnSendNotification.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSendNotificationActionPerformed(evt); } }); txtNotificationDetails.setColumns(20); txtNotificationDetails.setRows(5); txtNotificationDetails.setWrapStyleWord(true); txtNotificationDetails.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); jScrollPane2.setViewportView(txtNotificationDetails); btnCancelNotification.setText("Cancel Notification"); btnCancelNotification.setActionCommand("CANCEL_NOTIFICATION"); btnCancelNotification.setEnabled(false); btnCancelNotification.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelNotificationActionPerformed(evt); } }); javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup( jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(btnSendNotification, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnCancelNotification, javax.swing.GroupLayout.PREFERRED_SIZE, 85, Short.MAX_VALUE)) .addContainerGap()) ); jPanel9Layout.setVerticalGroup( jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel9Layout.createSequentialGroup() .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel9Layout.createSequentialGroup() .addContainerGap() .addComponent(btnSendNotification, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnCancelNotification))) .addContainerGap(43, Short.MAX_VALUE)) ); jLabel1.setText("You can send a notification to the Recipients"); jLabel2.setText("loaded on the Recipients Editor tab."); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2)) .addGap(18, 18, 18) .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(46, Short.MAX_VALUE)) ); layout.setVerticalGroup( 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.createSequentialGroup() .addGap(36, 36, 36) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel2)) .addGroup(layout.createSequentialGroup() .addGap(17, 17, 17) .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addComponent(jPanel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); }// </editor-fold>//GEN-END:initComponents private void btnSendNotificationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendNotificationActionPerformed // TODO add your handling code here: if(txtNotificationDetails.getText().length() > 0){ notifyResultsArea.append("\nSend Notification Button selected"); btnCancelNotification.setEnabled(true); fireActionEvent(evt); } else { JOptionPane.showMessageDialog(this, "Notification Details must have something."); } }//GEN-LAST:event_btnSendNotificationActionPerformed private void btnCancelNotificationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelNotificationActionPerformed // TODO add your handling code here: btnSendNotification.setEnabled(true); btnCancelNotification.setEnabled(false); }//GEN-LAST:event_btnCancelNotificationActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCancelNotification; private javax.swing.JButton btnSendNotification; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel33; private javax.swing.JPanel jPanel9; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane9; private javax.swing.JTextArea notifyResultsArea; private javax.swing.JTextArea txtNotificationDetails; // End of variables declaration//GEN-END:variables EventListenerList listeners; }