本文整理汇总了Java中edu.mit.blocks.workspace.PageChangeEventManager类的典型用法代码示例。如果您正苦于以下问题:Java PageChangeEventManager类的具体用法?Java PageChangeEventManager怎么用?Java PageChangeEventManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageChangeEventManager类属于edu.mit.blocks.workspace包,在下文中一共展示了PageChangeEventManager类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: automateBlockDeletion
import edu.mit.blocks.workspace.PageChangeEventManager; //导入依赖的package包/类
/**
* @requires the current block with focus must exist with non-null
* ID in a non-null widget with a non-null parent
* @modifies the current block with focus
* @effects removes the current block with focus and all
* its children from the GUI and destroys the link
* between the block with focus and it's parent
* block if one exists
*/
protected void automateBlockDeletion(Workspace workspace) {
TypeBlockManager typeBlockManager = workspace.getTypeBlockManager();
if (!typeBlockManager.isEnabled()) {
System.err.println("AutoMateBlockDeletion invoked but typeBlockManager is disabled.");
return;
}
if (!isNullBlockInstance(typeBlockManager.focusManager.getFocusBlockID())) {
typeBlockManager.deleteBlockAndChildren();
PageChangeEventManager.notifyListeners();
}
}
示例2: actionPerformed
import edu.mit.blocks.workspace.PageChangeEventManager; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
if (childBlock.getLocation().distance(focusPoint) < 75) {
//if parent block exist, then preform automatic linking
childBlock.setLocation(focusPoint);
if (parentBlock != null && parentBlock.getBlockID() != null && !parentBlock.getBlockID().equals(Block.NULL)) {
BlockLink link = LinkFinderUtil.connectBlocks(workspace, workspace.getEnv().getBlock(childBlock.getBlockID()), workspace.getEnv().getBlock(parentBlock.getBlockID()));
if (link == null) {
dropBlock(childBlock);
childBlock.repaintBlock();
childBlock.repaint();
} else {
// drop and link the new block
link.connect();
dropBlock(childBlock);
workspace.notifyListeners(new WorkspaceEvent(
workspace,
workspace.getEnv().getRenderableBlock(link.getPlugBlockID()).getParentWidget(),
link, WorkspaceEvent.BLOCKS_CONNECTED));
workspace.getEnv().getRenderableBlock(link.getSocketBlockID()).moveConnectedBlocks();
workspace.getEnv().getRenderableBlock(link.getSocketBlockID()).repaintBlock();
workspace.getEnv().getRenderableBlock(link.getSocketBlockID()).repaint();
}
} else {
dropBlock(childBlock);
childBlock.repaintBlock();
childBlock.repaint();
}
//stop the timer
timer.stop();
if (workspace.getEnv().getBlock(childBlock.getBlockID()).getGenusName().equals("number")) {
childBlock.switchToLabelEditingMode(false);
} else {
childBlock.switchToLabelEditingMode(true);
}
//TODO: check if focumanager's before parent is same as
//the parent we have here and check if new focusblock is child block
PageChangeEventManager.notifyListeners();
} else {
//childBlock.setLocation(focusPoint);
// TODO: This needs to change if the parent block doesn't have any more sockets for children
// Need to adjust focusPoint somehow.
childBlock.setLocation(
(int) (focusPoint.getX() * 0.67) + (int) (childBlock.getX() * 0.34),
(int) (focusPoint.getY() * 0.67) + (int) (childBlock.getY() * 0.34));
}
}