Java tutorial
/** * Copyright 2013-2015 TIKAL-TECHNOLOGY * *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 org.nekorp.workflow.desktop.view; import org.nekorp.workflow.desktop.view.binding.Bindable; import org.nekorp.workflow.desktop.view.binding.BindingManager; import org.nekorp.workflow.desktop.view.model.cobranza.PagoCobranzaVB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** * @author Nekorp */ @Component("basicPagoCobranzaView") @Scope("prototype") public class BasicPagoCobranzaView extends PagoCobranzaView { @Autowired private BindingManager<Bindable> bindingManager; @Autowired private PagoCobranzaViewListener elListener; private PagoCobranzaVB modelo; /** * Creates new form EntradaBitacora */ public BasicPagoCobranzaView() { super(); } @Override public void iniciaVista() { initComponents(); this.setBindings(); } @Override public void setEditableStatus(boolean value) { this.borrar.setEnabled(value); this.fechaPago.setEnabled(value); this.responsable.setEditable(value); this.detalle.setEnabled(value); } @Override public void setModel(PagoCobranzaVB ev) { this.modelo = ev; } @Override public PagoCobranzaVB getModel() { return this.modelo; } @Override public void disposeView() { this.removeBindings(); } private void setBindings() { this.bindingManager.registerBind(modelo, "monto", (Bindable) this.monto); this.bindingManager.registerBind(modelo, "detalle", (Bindable) this.detalle); this.bindingManager.registerBind(modelo, "fecha", (Bindable) this.fechaPago); this.bindingManager.registerBind(modelo, "responsable", (Bindable) this.responsable); } private void removeBindings() { this.bindingManager.removeBind(modelo, "monto", (Bindable) this.monto); this.bindingManager.removeBind(modelo, "detalle", (Bindable) this.detalle); this.bindingManager.removeBind(modelo, "fecha", (Bindable) this.fechaPago); this.bindingManager.removeBind(modelo, "responsable", (Bindable) this.responsable); } @Override public ViewValidIndicator getValidInidicator() { return null; } @Override public void requestFocusOnMainInput() { this.detalle.requestFocusInWindow(); } /** * 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() { jPanel1 = new javax.swing.JPanel(); jToolBar1 = new javax.swing.JToolBar(); borrar = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); fechaPago = new org.nekorp.workflow.desktop.view.binding.SimpleBindableJSppiner(); jLabel2 = new javax.swing.JLabel(); responsable = new org.nekorp.workflow.desktop.view.binding.SimpleBindableJTextField(); jLabel1 = new javax.swing.JLabel(); monto = new org.nekorp.workflow.desktop.view.binding.MonedaBindableJTextField(); jScrollPane2 = new org.nekorp.workflow.desktop.view.resource.imp.MouseFreeJScrollPane(); detalle = new org.nekorp.workflow.desktop.view.binding.SimpleBindableJTextArea(); setBackground(new java.awt.Color(255, 255, 255)); setMaximumSize(new java.awt.Dimension(32767, 89)); jPanel1.setBackground(new java.awt.Color(255, 255, 255)); jToolBar1.setBorder(null); jToolBar1.setFloatable(false); jToolBar1.setRollover(true); borrar.setBackground(new java.awt.Color(255, 255, 255)); borrar.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N borrar.setText("Borrar"); borrar.setFocusable(false); borrar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); borrar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); borrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { borrarActionPerformed(evt); } }); jToolBar1.add(borrar); jLabel4.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N jLabel4.setText("Fecha pago"); fechaPago.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N fechaPago.setModel( new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.MINUTE)); jLabel2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N jLabel2.setText("Responsable"); responsable.setBackground(new java.awt.Color(224, 230, 230)); responsable.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N responsable.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(224, 230, 230), 4)); jLabel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N jLabel1.setText("monto"); monto.setBackground(new java.awt.Color(224, 230, 230)); monto.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N monto.setText("jTextField1"); monto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(224, 230, 230), 4)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(fechaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(responsable, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(monto, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); jPanel1Layout .setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(fechaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(responsable, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1).addComponent(monto, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))); jScrollPane2.setBorder(null); jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane2.setWheelScrollingEnabled(false); detalle.setBackground(new java.awt.Color(224, 230, 230)); detalle.setColumns(20); detalle.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N detalle.setLineWrap(true); detalle.setRows(2); jScrollPane2.setViewportView(detalle); 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(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane2)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); }// </editor-fold>//GEN-END:initComponents private void borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_borrarActionPerformed this.elListener.deletePago(modelo); }//GEN-LAST:event_borrarActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton borrar; private javax.swing.JTextArea detalle; private javax.swing.JSpinner fechaPago; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JToolBar jToolBar1; private javax.swing.JTextField monto; private javax.swing.JTextField responsable; // End of variables declaration//GEN-END:variables }