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 java.awt.Window; import java.util.Date; import org.nekorp.workflow.desktop.view.binding.Bindable; import org.nekorp.workflow.desktop.view.binding.BindingManager; import org.nekorp.workflow.desktop.view.binding.ReadOnlyBinding; import org.nekorp.workflow.desktop.view.model.reporte.global.ParametrosReporteGlobalVB; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * @author Nekorp */ @Component public class ReporteGlobalDatePickView extends ApplicationView { private boolean iniciado = false; @Autowired private BindingManager<Bindable> bindingManager; @Autowired private ParametrosReporteGlobalVB parametrosReporteGlobal; private java.awt.Window parent; /** * Creates new form ReporteGlobalDatePickView */ public ReporteGlobalDatePickView() { super(); } @Override public void iniciaVista() { if (!iniciado) { initComponents(); iniciado = true; bindComponents(); } parametrosReporteGlobal.setEjecutar(false); } private void bindComponents() { ReadOnlyBinding maxInicial = new ReadOnlyBinding() { @Override public void notifyUpdate(Object origen, String property, Object value) { Date fecha = (Date) value; fechaInicial.setMaxSelectableDate(fecha); } }; ReadOnlyBinding minFinal = new ReadOnlyBinding() { @Override public void notifyUpdate(Object origen, String property, Object value) { Date fecha = (Date) value; fechaFinal.setMinSelectableDate(fecha); } }; bindingManager.registerBind(parametrosReporteGlobal, "fechaInicial", (Bindable) fechaInicial); bindingManager.registerBind(parametrosReporteGlobal, "fechaFinal", (Bindable) fechaFinal); bindingManager.registerBind(parametrosReporteGlobal, "fechaInicial", minFinal); bindingManager.registerBind(parametrosReporteGlobal, "fechaFinal", maxInicial); } @Override public void setEditableStatus(boolean value) { //no hacer nada. } @Override public ViewValidIndicator getValidInidicator() { return null; } public void setParent(Window parent) { this.parent = parent; } /** * 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() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); aceptar = new javax.swing.JButton(); cancelar = new javax.swing.JButton(); fechaInicial = new org.nekorp.workflow.desktop.view.binding.SimpleBindableJDateChooser(); fechaFinal = new org.nekorp.workflow.desktop.view.binding.SimpleBindableJDateChooser(); setBackground(new java.awt.Color(255, 255, 255)); jLabel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N jLabel1.setText("Fecha Inicial"); jLabel2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N jLabel2.setText("Fecha Final"); aceptar.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N aceptar.setText("Aceptar"); aceptar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { aceptarActionPerformed(evt); } }); cancelar.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N cancelar.setText("Cancelar"); cancelar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelarActionPerformed(evt); } }); fechaInicial.setBackground(new java.awt.Color(224, 230, 230)); fechaInicial.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N fechaFinal.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N 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) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1).addComponent(jLabel2)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(fechaInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) .addComponent(fechaFinal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(aceptar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelar))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(fechaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(fechaFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelar).addComponent(aceptar)) .addContainerGap())); }// </editor-fold>//GEN-END:initComponents private void aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarActionPerformed parametrosReporteGlobal.setEjecutar(true); parent.dispose(); }//GEN-LAST:event_aceptarActionPerformed private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed parent.dispose(); }//GEN-LAST:event_cancelarActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton aceptar; private javax.swing.JButton cancelar; private com.toedter.calendar.JDateChooser fechaFinal; private com.toedter.calendar.JDateChooser fechaInicial; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; // End of variables declaration//GEN-END:variables }