當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockStub.parentPlugChanged方法代碼示例

本文整理匯總了Java中edu.mit.blocks.codeblocks.BlockStub.parentPlugChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockStub.parentPlugChanged方法的具體用法?Java BlockStub.parentPlugChanged怎麽用?Java BlockStub.parentPlugChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.mit.blocks.codeblocks.BlockStub的用法示例。


在下文中一共展示了BlockStub.parentPlugChanged方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: finishLoad

import edu.mit.blocks.codeblocks.BlockStub; //導入方法依賴的package包/類
/**
   * After loading canvas, does a final sweep of all procedures to update
   * myProcInfo. It does this by going through each output block and seeing
   * if that output contributes any information to a procedure.
   * Then it updates the procedure's stubs if the procedure type changes.
   * 
   * Called after regular loading is finished (WorkspaceController.LoadSaveString()).
   * 
   * Updating myProcInfo depends on one crucial assumption:
   * The types of all outputs should be consistent because they were handled
   * prior to the original saving with the POM (so the loaded version is correct).
* Therefore, we DO NOT need to:
* 		change the types of empty output sockets
*		revert the types of incorrect output sockets
*		disconnect incorrect output types
   */
  public static void finishLoad() {
  	
  	// Create new output info for each procedure on the canvas.
  	for(Block p : workspace.getBlocksFromGenus("procedure")) {
  		myProcInfo.put(p.getBlockID(), new OutputInfo());
  	}
  	
  	// Update myProcInfo by checking each output.
  	for(Block b : workspace.getBlocksFromGenus("return")) {
  		// Only handle the output blocks that are connected to a procedure.
  		Long top = getTopBlockID(b.getBlockID());
  		if (top != null && workspace.getEnv().getBlock(top).isProcedureDeclBlock()) {
  			//System.out.println("procedure (top) number "+top);
  			OutputInfo info = myProcInfo.get(top);
  			
  			// Check that the output hasn't already been visited (shouldn't have but just to be safe...)
		if (!info.outputs.contains(b)) {
			
			// Change the procedure type if it has not been set and is not of the generic type poly.
  				if (info.type == null && !b.getSocketAt(0).getKind().equals("poly")) {
  					info.type = b.getSocketAt(0).getKind();
  					// Update stubs due to change in type
  					BlockStub.parentPlugChanged(workspace, top, info.type);
  				}
  				
  				// Increase the number of typed outputs (aka connected outputs without empty sockets).
  				if (b.getSocketAt(0).getBlockID() != -1) {
  					info.numTyped++;
  				}
  				
  				// Add all outputs that have not already been added (regardless of type or empty/nonempty sockets).
 					info.outputs.add(b.getBlockID());
 					
  			}
  			//System.out.println("numtyped "+info.numTyped+" type "+info.type);
  		}
  	}
  }
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:55,代碼來源:ProcedureOutputManager.java

示例2: blocksDisconnected

import edu.mit.blocks.codeblocks.BlockStub; //導入方法依賴的package包/類
/**
 * When blocks are disconnected, update the proc stack and revert any
 * affected output blocks/callers.
 */
private static void blocksDisconnected(WorkspaceWidget w, Long socket, Long plug) {
    // Don't do anything if we're not in a procedure stack.
    Long top = getTopBlockID(socket);
    if (top == null || !workspace.getEnv().getBlock(top).isProcedureDeclBlock()) return;
    
    // Revert any output blocks in the disconnected stack. 
    OutputInfo info = myProcInfo.get(top);

    if (isOutput(workspace.getEnv().getBlock(socket)) && info.type != null) {
        // PolyRule reverts this to "poly" so we have to change it 
        // back to whatever type it should be.

        info.numTyped--;
        workspace.getEnv().getBlock(socket).getSocketAt(0).setKind(info.type);
        workspace.getEnv().getBlock(socket).notifyRenderable();
    }
    else
        revertType(workspace.getEnv().getBlock(plug), info, true);        
    
    // If there are no more connected blocks in this procedure, remove
    // the type and revert current output blocks.
    if (info.numTyped == 0) {
        info.type = null;
        revertType(workspace.getEnv().getBlock(top), info, false);
        BlockStub.parentPlugChanged(workspace, top, null);
    }
}
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:32,代碼來源:ProcedureOutputManager.java

示例3: blocksConnected

import edu.mit.blocks.codeblocks.BlockStub; //導入方法依賴的package包/類
/**
 * When blocks are connected, check to see whether we are in a proc
 * stack. If so, check to see whether we should update the output type,
 * and if any existing blocks are affected by this change. 
 */
private static void blocksConnected(WorkspaceWidget w, Long socket, Long plug) {
    // Don't do anything if we're not in a procedure stack.
    Long top = getTopBlockID(socket);

    if (top == null || !workspace.getEnv().getBlock(top).isProcedureDeclBlock()) return;

    // If the proc stack already has a type, change all outputs in the
    // new part to that type and disconnect anything that doesn't fit.
    OutputInfo info = myProcInfo.get(top);
    List<WorkspaceEvent> events = new ArrayList<WorkspaceEvent>();
    Block b = workspace.getEnv().getBlock(socket);

    // If the block was added to an output block,
    // then b is the parent block (socket = output) and add is false.
    // else b is the current block (plug) and add is true.
    // in changeType, we check if b is type output before proceeding.
    boolean add = true;
    if (isOutput(b))
        add = false;    // don't add the output twice to the list
    else 
        b = workspace.getEnv().getBlock(plug);
    
    if (info.type != null)
        changeType(add, b, info.type, info, w, events);
    else {
        // Examine the type. If there is a type in the new portion of
        // the stack, reset all the previous output blocks to that type.
        examineType(add, b, info);
        if (info.type != null) {
            changeType(info, w, events);
            BlockStub.parentPlugChanged(workspace, top, info.type);
        }
    }
    
    // Fire events.
    if (!events.isEmpty()) {
        //WorkspaceController.getInstance().notifyListeners(events);
        for (WorkspaceEvent e : events) {
            workspace.notifyListeners(e);
        }
    }
    	
}
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:49,代碼來源:ProcedureOutputManager.java


注:本文中的edu.mit.blocks.codeblocks.BlockStub.parentPlugChanged方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。