use of edu.mit.blocks.codeblockutil.CLabel in project openblocks by mikaelhg.
the class FactoryManager method setupSubsets.
/**
* 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.notifyListeners(new WorkspaceEvent(workspace, 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();
}
Aggregations