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;
 
 
 
 public class StateManager extends Composite {
 
     private static ImagesCore images    = GWT.createImagesCore.class );
     private ConstantsCore constants = GWT.createConstantsCore.class );
 
     private ListBox       currentStatuses;
 
     public StateManager() {
         PrettyFormLayout form = new PrettyFormLayout();
         form.addHeader..Status(),
                         new HTML"<b>" + .ManageStatuses() + "</b>" ) );
 
          = new ListBox();
         .setVisibleItemCount( 7 );
         .setWidth"50%" );
 
         refreshList();
 
         form.addAttribute.CurrentStatuses(),
                             );
 
         HorizontalPanel hPanel = new HorizontalPanel();
         Button create = new Button.NewStatus() );
         //create.setTitle( constants.CreateANewCategory() );
         create.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent w) {
                 StatusEditor newCat = new StatusEditornew Command() {
                     public void execute() {
                         refreshList();
                     }
                 } );
 
                 newCat.show();
             }
         } );
 
         Button edit = new Button.RenameSelected() );
         edit.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent w) {
 
                 if ( !.isItemSelected.getSelectedIndex() ) ) {
                     Window.alert.PleaseSelectAStatusToRename() );
                     return;
                 }
                 renameSelected();
 
             }
         } );
 
         Button remove = new Button.DeleteSelected() );
         remove.addClickHandlernew ClickHandler() {
             public void onClick(ClickEvent w) {
 
                 if ( !.isItemSelected.getSelectedIndex() ) ) {
                     Window.alert.PleaseSelectAStatusToRemove() );
                     return;
                 }
 
                 removeStatus();
            }
        } );
        hPanel.addcreate );
        hPanel.addedit );
        hPanel.addremove );
        form.addAttribute("",
                           hPanel );
        form.endSection();
        initWidgetform );
    }
    private void removeStatus() {
        .removeState(name,
                new GenericCallback<java.lang.Void>() {
                    public void onSuccess(Void v) {
                        Window.alert(.StatusRemoved());
                        refreshList();
                    }
                });
    }
    private void renameSelected() {
                                        "" );
        if ( newName != null ) {
            .renameStateoldName,
                                                               newName,
                                                               new GenericCallback<Void>() {
                                                                   public void onSuccess(Void data) {
                                                                       Window.alert.StatusRenamed() );
                                                                       refreshList();
                                                                   }
                                                               } );
        }
    }
    private void refreshList() {
        LoadingPopup.showMessage.LoadingStatuses() );
        .listStatesnew GenericCallback<String[]>() {
            public void onSuccess(String[] statii) {
                .clear();
                for (String aStatii : statii) {
                    .addItem(aStatii);
                }
                LoadingPopup.close();
            }
        } );
    }
New to GrepCode? Check out our FAQ X