Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 JBoss Inc 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.drools.guvnor.client.modeldriven.ui;
 
 import java.util.Date;
 
 import  org.drools.guvnor.client.common.ImageButton;
 
 import  com.google.gwt.i18n.client.DateTimeFormat;
 import  com.google.gwt.user.client.ui.ClickListener;
 import  com.google.gwt.user.client.ui.FocusListener;
 import  com.google.gwt.user.client.ui.TextBox;
 import  com.google.gwt.user.client.ui.Widget;
 
 public class DatePickerTextBox extends DatePicker {
 
     private ImageButton select = new ImageButton( "images/edit_tiny.gif" );
 
     public DatePickerTextBox(String selectedDate) {
         thisselectedDate,
                );
     }
 
     public DatePickerTextBox(String selectedDate,
                              String visualFormat) {
         solveVisualFormatvisualFormat );
 
          = DateTimeFormat.getFormat( this. );
 
          = new DatePickerPopUp( new ClickListener() {
                                                    public void onClick(Widget arg0) {
                                                        Date date = fillDate();
 
                                                        .setText( .format( date ) );
 
                                                        valueChanged();
                                                        makeDirty();
                                                        .hide();
                                                    }
                                                },
                                                 );
 
         .addClickListener( new ClickListener() {
             public void onClick(Widget arg0) {
                 .setPopupPosition( .getAbsoluteLeft(),
                                                   .getAbsoluteTop() + 20 );
 
                 if ( .getText() != null && "".equals.getText() ) ) {
                     .setText( .format( new Date() ) );
                 }
 
                 .setDropdowns( ,
                                               .getText() );
                 .show();
             }
         } );
 
         if ( selectedDate != null && !selectedDate.equals"" ) ) {
             .setText( selectedDate );
 
             // Check if there is a valid date set. If not, set this date.
             try {
                 .parse( selectedDate );
             } catch ( Exception e ) {
                 selectedDate = null;
             }
         }
 
         .addFocusListener( new FocusListener() {
             public void onFocus(Widget arg0) {
             }
 
             public void onLostFocus(Widget arg0) {
                 TextBox box = (TextBox) arg0;
                 .setText( box.getText() );
                 valueChanged();
                 makeDirty();
                 .hide();
             }
         } );
 
         .add(  );
         .add(  );
         initWidget(  );
     }
    public void clear() {
        .setText( "" );
    }
New to GrepCode? Check out our FAQ X