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.common;
 
 
A rule package selector widget.
 
 public class RulePackageSelector extends Composite {

    
Used to remember what the "current package" we are working in is... Should be the one the user has most recently dealt with...
 
     public static String currentlySelectedPackage;
 
     private ListBox      packageList;
     private boolean      loadGlobalArea = false;
 
     public RulePackageSelector() {
         thisfalse );
     }
 
     public RulePackageSelector(boolean loadGlobalArea) {
         this. = loadGlobalArea;
 
          = new ListBox();
 
         Scheduler scheduler = Scheduler.get();
 
         scheduler.scheduleDeferrednew ScheduledCommand() {
             public void execute() {
                 loadPackageList();
             }
         } );
 
         initWidget );
     }
 
     private void loadPackageList() {
         ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
         moduleService.listModulesnew GenericCallback<Module[]>() {
 
             public void onSuccess(Module[] list) {
                 for ( int i = 0; i < list.lengthi++ ) {
                     .addItemlist[i].getName(),
                                          list[i].getUuid() );
                     if (  != null && list[i].getName().equals ) ) {
                         .setSelectedIndexi );
                     }
                 }
 
                 if (  ) {
                     .addItem"globalArea",
                                          "nouuidavailable" );
                 }
 
                 .addChangeHandlernew ChangeHandler() {
                     public void onChange(ChangeEvent event) {
                          = getSelectedPackage();
                     }
                 } );
             }
         } );
     }

    
Returns the selected package.
 
     public String getSelectedPackage() {
         int index = .getSelectedIndex();
         return .getItemTextindex );
     }
     
     public String getSelectedPackageUUID() {
         int index = .getSelectedIndex();
        return .getValue(index);
    }
New to GrepCode? Check out our FAQ X