Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.drools.guvnor.client.explorer;
  
  import  org.drools.guvnor.client.common.GenericCallback;
  import  org.drools.guvnor.client.rpc.RepositoryServiceFactory;
  import  org.drools.guvnor.client.rulelist.AssetItemGrid;
  import  org.drools.guvnor.client.rulelist.AssetItemGridDataLoader;
  import  org.drools.guvnor.client.rulelist.EditItemEvent;
  import  org.drools.guvnor.client.messages.Constants;
 
 import  com.google.gwt.user.client.ui.VerticalPanel;
 import  com.google.gwt.user.client.Window;
 import  com.google.gwt.core.client.GWT;
 import  com.gwtext.client.core.EventObject;
 import  com.gwtext.client.widgets.Button;
 import  com.gwtext.client.widgets.Toolbar;
 import  com.gwtext.client.widgets.ToolbarMenuButton;
 import  com.gwtext.client.widgets.event.SplitButtonListenerAdapter;
 import  com.gwtext.client.widgets.tree.TreeNode;
 import  com.gwtext.client.widgets.tree.TreePanel;
 import  com.gwtext.client.widgets.tree.event.TreePanelListenerAdapter;

Author(s):
Anton Arhipov
 
 public class CategoriesPanel extends GenericPanel {
     private static Constants constants = GWT.create(Constants.class);
 
     public CategoriesPanel(ExplorerViewCenterPanel tabbedPanel) {
         super(.Assets(), tabbedPanel);
         setIconCls("nav-categories"); //NON-NLS
 
         
         Toolbar rulesToolBar = new Toolbar();
 
         final ToolbarMenuButton menuButton = new ToolbarMenuButton(.CreateNew(),
                                                             RulesNewMenu.getMenuthis ) );
         rulesToolBar.addButton( menuButton );
         menuButton.addListener( new SplitButtonListenerAdapter() {
 
             public void onClick(Button button,
                                 EventObject e) {
                 menuButton.showMenu();
             }
         } );
         
         VerticalPanel rulesPanel = new VerticalPanel();
         if (ExplorerLayoutManager.shouldShow(.)) {
             rulesPanel.add(rulesToolBar);
         }
 
         TreePanel categoryTree = basicTreeStructure(ExplorerNodeConfig
                 .getRulesStructure(), new TreePanelListenerAdapter() {
 
             public void onClick(final TreeNode self, EventObject e) {
 
                 //this refreshes the list.
                 if (self.getAttribute("id").equals(.)) {  //NON-NLS
                     self.getParentNode().replaceChild(ExplorerNodeConfig.getCategoriesStructure(), self);
                 } else if (self.getAttribute("id").equals(.)) {   //NON-NLS
                     self.getParentNode().replaceChild(ExplorerNodeConfig.getStatesStructure(), self);
                 } else if (self.getAttribute("id").equals("FIND")) {     //NON-NLS
                     .openFind();
                 } else {
                     final String key = (Stringself.getUserObject();
                     final boolean isState = key.startsWith("-");
 
                     if (!.showIfOpen(key)) {
 
                         AssetItemGrid list = new AssetItemGrid(new EditItemEvent() {
                             public void open(String uuid) {
                                 .openAsset(uuid);
                             }
                         },
                                 AssetItemGrid.RULE_LIST_TABLE_ID,
                                 new AssetItemGridDataLoader() {
                                     public void loadData(int skipint numberOfRows, GenericCallback cb) {
                                         if (isState) {
                                             RepositoryServiceFactory.getService().
                                                     loadRuleListForState(key.substring(1), skip,
                                                             numberOfRows, AssetItemGrid.RULE_LIST_TABLE_ID, cb);
                                         } else {
                                             RepositoryServiceFactory.getService().
                                                     loadRuleListForCategories(keyskipnumberOfRows,
                                                             AssetItemGrid.RULE_LIST_TABLE_ID, cb);
                                         }
                                     }
                                 },
                                 (isState) ? null : GWT.getModuleBaseURL() + "feed/category?name=" + key + "&viewUrl=" + Window.Location.getHref());
 
                         .addTab(((isState) ? .Status() : .CategoryColon()) + self.getText(), truelistkey);
                     }
 
                 }
 
             }
         });
 
 
        rulesPanel.add(categoryTree);
        rulesPanel.setWidth("100%");
        add(rulesPanel);
    }
New to GrepCode? Check out our FAQ X