Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2005 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.widgets.categorynav;
 
 
This provides a popup for editing a category (name etc). Mainly this is for creating a new category.
 
 public class CategoryEditor extends FormStylePopup {
 
     private String    path;
     private TextBox   name        = new TextBox();
     private TextArea  description = new TextArea();
     private Command   refresh;
     private ConstantsCore constants   = ((ConstantsCore) GWT.createConstantsCore.class ));
 
     public CategoryEditor(String catPath,
                           Command refresh) {
         thiscatPath );
         this. = refresh;
     }

    
This is used when creating a new category
 
     public CategoryEditor(String catPath) {
         super.setTitlegetTitlecatPath ) );
          = catPath;
 
         addAttribute.CategoryName(),
                        );
 
         Button ok = new Button.OK() );
         ok.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent event) {
                 ok();
             }
 
         } );
         addAttribute"",
                       ok );
     }
 
     private static String getTitle(String catPath) {
         if ( catPath == null ) {
             return ((ConstantsCore) GWT.createConstantsCore.class )).CreateANewTopLevelCategory();
         } else {
             return ((ConstantsCore) GWT.createConstantsCore.class )).CreateNewCategoryUnder0(catPath);
         }
     }
 
     void ok() {
 
         AsyncCallback<java.lang.Booleancb = new GenericCallback<java.lang.Boolean>() {
             public void onSuccess(Boolean booleanValue) {
                 if ( booleanValue ) {
                     if (  != null ) {
                         .execute();
                     }
                     hide();
                 } else {
                     ErrorPopup.showMessage.CategoryWasNotSuccessfullyCreated() );
 
                 }
             }
         };
 
         if ( "".equalsthis..getText() ) ) {
             ErrorPopup.showMessage.CanNotHaveAnEmptyCategoryName() );
         } else {
             CategoryServiceAsync categoryService = GWT.create(CategoryService.class);
            categoryService.createCategory,
                                                                  .getText(),
                                                                  .getText(),
                                                                  cb );
        }
    }
    void cancel() {
        hide();
    }
New to GrepCode? Check out our FAQ X