Ejemplo n.º 1
0
 /**
  * Sets up the subsets by clearing all subsets and installing the new collection of subsets. If
  * "usingSys" is true, the the factory and myblocks drawers will be accessible. If "usingSubs" is
  * true, then the subset drawers will be accessible.
  *
  * @param subsets - collection of subsets
  * @param usingSys - true for factory and myblocks
  * @param usingSubs - true for subsets
  */
 public void setupSubsets(Collection<Subset> subsets, boolean usingSys, boolean usingSubs) {
   if (usingSubs) {
     this.subsetCanvases.clear();
     for (Subset subset : subsets) {
       FactoryCanvas canvas = new FactoryCanvas(subset.getName(), subset.getColor());
       for (RenderableBlock frb : subset.getBlocks()) {
         canvas.addBlock(frb);
         Workspace.getInstance()
             .notifyListeners(
                 new WorkspaceEvent(this, frb.getBlockID(), WorkspaceEvent.BLOCK_ADDED));
       }
       canvas.layoutBlocks();
       this.subsetCanvases.add(canvas);
     }
     this.navigator.setCanvas(this.subsetCanvases, SUBSETS_NAME);
     if (usingSys) {
       this.factorySwicther.removeAll();
       this.factorySwicther.add(this.navigator.getSwitcher());
     } else {
       this.factorySwicther.removeAll();
       this.factorySwicther.add(new CLabel(SUBSETS_NAME));
     }
     this.viewSubsetsDrawers();
   } else if (usingSys) {
     this.factorySwicther.removeAll();
     final CBorderlessButton factoryButton = new CBorderlessButton(STATIC_NAME);
     final CBorderlessButton myblocksButton = new CBorderlessButton(DYNAMIC_NAME);
     ActionListener listener =
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             if (factoryButton.equals(e.getSource())) {
               FactoryManager.this.viewStaticDrawers();
             } else if (myblocksButton.equals(e.getSource())) {
               FactoryManager.this.viewDynamicDrawers();
             }
           }
         };
     factoryButton.addActionListener(listener);
     myblocksButton.addActionListener(listener);
     this.factorySwicther.add(factoryButton, BorderLayout.WEST);
     this.factorySwicther.add(myblocksButton, BorderLayout.EAST);
     this.viewStaticDrawers();
   }
   this.factorySwicther.revalidate();
   this.factorySwicther.repaint();
 }
Ejemplo n.º 2
0
 public void addDynamicBlocks(Collection<RenderableBlock> blocks, String drawer) {
   // find canvas
   for (FactoryCanvas canvas : this.dynamicCanvases) {
     if (canvas.getName().equals(drawer)) {
       for (RenderableBlock block : blocks) {
         if (block == null || Block.NULL.equals(block.getBlockID())) continue;
         canvas.addBlock(block);
         Workspace.getInstance()
             .notifyListeners(
                 new WorkspaceEvent(this, block.getBlockID(), WorkspaceEvent.BLOCK_ADDED));
       }
       canvas.layoutBlocks();
       return;
     }
   }
   this.printError("Drawer not found: " + drawer);
   return;
 }
Ejemplo n.º 3
0
 /**
  * Adds the specified RenderableBlocks to the drawer with the specified drawerName. Do nothing if
  * the drawer with the specified drawerName does not exist.
  *
  * @param blocks Collection of RenderableBlocks to the drawer with name: drawerName
  * @param drawerName String name of the drawer to add blocks to
  */
 public void addSubsetBlocks(Collection<RenderableBlock> blocks, String drawerName) {
   // find canvas //TODO generalize the following code to one method where you pass in the blocks,
   // drawername, and canvas types
   for (FactoryCanvas canvas : this.subsetCanvases) {
     if (canvas.getName().equals(drawerName)) {
       for (RenderableBlock block : blocks) {
         if (block == null || Block.NULL.equals(block.getBlockID())) continue;
         canvas.addBlock(block);
         Workspace.getInstance()
             .notifyListeners(
                 new WorkspaceEvent(this, block.getBlockID(), WorkspaceEvent.BLOCK_ADDED));
       }
       canvas.layoutBlocks();
       return;
     }
   }
   this.printError("Drawer not found: " + drawerName);
   return;
 }
Ejemplo n.º 4
0
 public void addDynamicBlock(RenderableBlock block, String drawer) {
   for (FactoryCanvas canvas : this.dynamicCanvases) {
     if (canvas.getName().equals(drawer)) {
       if (block == null || Block.NULL.equals(block.getBlockID())) {
         printError("Attempting to add a null instance of block");
         return;
       } else {
         canvas.addBlock(block);
         Workspace.getInstance()
             .notifyListeners(
                 new WorkspaceEvent(this, block.getBlockID(), WorkspaceEvent.BLOCK_ADDED));
         canvas.layoutBlocks();
         return;
       }
     }
   }
   this.printError("Drawer not found: " + drawer);
   return;
 }