protected void automateAddition(Workspace workspace, char character) { TypeBlockManager typeBlockManager = workspace.getTypeBlockManager(); if (!typeBlockManager.isEnabled()) { System.err.println("AutoMateMultiplication invoked but typeBlockManager is disabled."); return; } // get focus block Long parentBlockID = typeBlockManager.focusManager.getFocusBlockID(); if (isNullBlockInstance(parentBlockID)) { // focus on canvas automateBlockInsertion(workspace, "sum", null); } else { Block parentBlock = workspace.getEnv().getBlock(parentBlockID); if (parentBlock.getGenusName().equals("string")) { // focus on string block automateBlockInsertion(workspace, "string-append", null); } else if (parentBlock.getGenusName().equals("string-append")) { // focus on string append block automateBlockInsertion(workspace, "string-append", null); } else { // focus on any other block automateBlockInsertion(workspace, "sum", null); } } }
/** assumes number and differen genus exist and number genus has ediitabel lable */ protected void automateNegationInsertion(Workspace workspace) { TypeBlockManager typeBlockManager = workspace.getTypeBlockManager(); if (!typeBlockManager.isEnabled()) { System.err.println("AutoMateNegationInsertion invoked but typeBlockManager is disabled."); return; } // ====================>>>>>>>>>>>>>>>>>>>>>>>>> // ====================focus coming in>>>>>>>>>> TODO // ====================>>>>>>>>>>>>>>>>>>>>>>>>> // get focus block Long parentBlockID = typeBlockManager.focusManager.getFocusBlockID(); if (isNullBlockInstance(parentBlockID)) { // focus on canvas automateBlockInsertion(workspace, "number", "-"); } else { Block parentBlock = workspace.getEnv().getBlock(parentBlockID); if (parentBlock.isDataBlock()) { // focus on a data block automateBlockInsertion(workspace, "difference", null); } else { // focus on a non-data block automateBlockInsertion(workspace, "number", "-"); } } }
protected void automateMultiplication(Workspace workspace, char character) { TypeBlockManager typeBlockManager = workspace.getTypeBlockManager(); if (!typeBlockManager.isEnabled()) { System.err.println("AutoMateMultiplication invoked but typeBlockManager is disabled."); return; } if (!isNullBlockInstance(typeBlockManager.focusManager.getFocusBlockID())) { Block parentBlock = workspace.getEnv().getBlock(typeBlockManager.focusManager.getFocusBlockID()); if (parentBlock.getGenusName().equals("number")) { automateBlockInsertion(workspace, "product", null); return; } } automateAutoComplete(workspace, character); return; }
/** * @requires none * @modifies focusManager.focusblock && focusManager.focuspoint && blockCanvas * @effects Do nothing if "genusName" does not map to a valid block. Otherwise, create and add a * new block with matching genus and label properties to one of the following: 1. the current * block with focus at (0,0) relative to that block. 2. the current block with focus at next * applicable socket location 3. the canvas at the last mouse click point. Then update any * focus and block connections. */ protected void automateBlockInsertion(Workspace workspace, TextualFactoryBlock block) { /*Passing in an empty label name means that the block should already have a predetermined label name that does not need to be altered to the user's preference*/ automateBlockInsertion(workspace, block, EMPTY_LABEL_NAME); }