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.explorer.navigation.admin.widget;
 
 
This controls category administration.
 
 public class CategoryManager extends Composite {
 
     private static ImagesCore images    = (ImagesCore) GWT.createImagesCore.class );
     private ConstantsCore constants = ((ConstantsCore) GWT.createConstantsCore.class ));
 
     public VerticalPanel           layout    = new VerticalPanel();
     //public String selectedPath;
     private CategoryExplorerWidget explorer;
 
     public CategoryManager() {
 
         PrettyFormLayout form = new PrettyFormLayout();
         form.addHeader..EditCategories(),
                         new HTML.EditCategories() ) );
         form.startSection.CategoriesPurposeTip() );
 
          = new CategoryExplorerWidgetnew CategorySelectHandler() {
             public void selected(String sel) {
                 //don't need this here as we don't do anything on select in this spot
             }
         } );
         SimplePanel editable = new SimplePanel();
         editable.add );
 
         form.addAttribute.CurrentCategories(),
                            editable );
 
         HorizontalPanel actions = new HorizontalPanel();
 
         form.addAttribute"",
                            actions );
 
         Button newCat = new Button.NewCategory() );
         newCat.setTitle.CreateANewCategory() );
         newCat.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent w) {
                 CategoryEditor newCat = new CategoryEditor.getSelectedPath(),
                                                             new Command() {
                                                                 public void execute() {
                                                                     .refresh();
                                                                 }
                                                             } );
 
                 newCat.show();
             }
         } );
 
         actions.addnewCat );
 
         Button rename = new Button.RenameSelected() );
         rename.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent w) {
                 if ( !.isSelected() ) {
                     Window.alert.PleaseSelectACategoryToRename() );
                     return;
                }
                renameSelected();
            }
        } );
        actions.addrename );
        Button delete = new Button.DeleteSelected() );
        delete.addClickHandlernew ClickHandler() {
            public void onClick(ClickEvent w) {
                if ( !.isSelected() ) {
                    Window.alert.PleaseSelectACategoryToDelete() );
                    return;
                }
                deleteSelected();
            }
        } );
        delete.setTitle.DeleteSelectedCat() );
        actions.adddelete );
        form.endSection();
        initWidgetform );
    }
    private void renameSelected() {
        String name = Window.prompt.CategoryNewNamePleaseEnter(),
                                     "" );
        if ( name != null ) {
            CategoryServiceAsync categoryService = GWT.create(CategoryService.class);
            categoryService.renameCategory.getSelectedPath(),
                                                                  name,
                                                                  new GenericCallback<java.lang.Void>() {
                                                                      public void onSuccess(Void v) {
                                                                          Window.alert.CategoryRenamed() );
                                                                          .refresh();
                                                                      }
                                                                  } );
        }
    }
    private void deleteSelected() {
        if ( Window.confirm.AreYouSureYouWantToDeleteCategory() + .getSelectedPath() ) ) {
            CategoryServiceAsync categoryService = GWT.create(CategoryService.class);
            categoryService.removeCategory.getSelectedPath(),
                                                                  new GenericCallback<java.lang.Void>() {
                                                                      public void onSuccess(Void v) {
                                                                          .refresh();
                                                                      }
                                                                  } );
        }
    }
New to GrepCode? Check out our FAQ X