当前位置: 首页>>代码示例>>Java>>正文


Java SQLPowerUtils.unlistenToHierarchy方法代码示例

本文整理汇总了Java中ca.sqlpower.util.SQLPowerUtils.unlistenToHierarchy方法的典型用法代码示例。如果您正苦于以下问题:Java SQLPowerUtils.unlistenToHierarchy方法的具体用法?Java SQLPowerUtils.unlistenToHierarchy怎么用?Java SQLPowerUtils.unlistenToHierarchy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.sqlpower.util.SQLPowerUtils的用法示例。


在下文中一共展示了SQLPowerUtils.unlistenToHierarchy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setParentHelper

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * See the comment on {@link #setParent(SQLTable)} for why this method
 * exists if it seems goofy.
 */
private void setParentHelper(SPObject parent) {
	SPObject oldVal = getParent();
	super.setParent(parent);
	if (parent != null) {
		if (isMagicEnabled() && parent != oldVal) {
			try {
				attachRelationship(true);
			} catch (SQLObjectException e) {
				throw new RuntimeException(e);
			}
		} else {
			//Column manager is removed first in case it has already been
			//added before. One case is when the relationship is being re-added 
			//to the same table it was removed from by the undo system. 
			SQLPowerUtils.unlistenToHierarchy(getParent(), fkColumnUpdater);
			
			SQLPowerUtils.listenToHierarchy(getParent(), fkColumnUpdater);
		}
	}
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:25,代码来源:SQLRelationship.java

示例2: childRemoved

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
public void childRemoved(SPChildEvent e) {
       hasChanged = true;
       SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
   	
   	logger.debug("Child: " + e.getChild() + " is removed from: " + e.getSource().toString());
   	if (e.getSource().isMagicEnabled()) {
   		UndoableEdit ue = new MMOChildrenRemoveUndoableEdit(e);
   		addEdit(ue);
   	}
   	if (!undo.canUndo()) {
		hasChanged = false;
	}
   	swingSession.refreshUndoAction();
	
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:17,代码来源:MMOChangeUndoWatcher.java

示例3: childRemoved

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void childRemoved(SPChildEvent e) {
    if (SPObjectUndoManager.this.isUndoOrRedoing())
        return;
    
    if (addListenerToChildren) {
    	if (compoundEditStackCount == 0) {
    		SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
    	} else {
    		removedObjects.add(e.getChild());
    	}
    }

    addEdit(new SPObjectChildEdit(e));
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:15,代码来源:SPObjectUndoManager.java

示例4: testChangeSFifthColumnIdxToSecond

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void testChangeSFifthColumnIdxToSecond() throws Exception {
    EventLogger l = new EventLogger();
    SQLObjectSnapshot original = l.makeSQLObjectSnapshot(table);
    
    SQLPowerUtils.listenToHierarchy(table, l);
    table.changeColumnIndex(4, 1, true);        
    SQLPowerUtils.unlistenToHierarchy(table, l);

    assertEquals(4, table.getPkSize());
    
    assertEquals(0, table.getColumnIndex(table.getColumnByName("one")));
    assertEquals(1, table.getColumnIndex(table.getColumnByName("five")));
    assertEquals(2, table.getColumnIndex(table.getColumnByName("two")));
    assertEquals(3, table.getColumnIndex(table.getColumnByName("three")));
    assertEquals(4, table.getColumnIndex(table.getColumnByName("four")));       
    assertEquals(5, table.getColumnIndex(table.getColumnByName("six")));

    System.out.println("Event log:\n"+l);

    SQLObjectSnapshot afterChange = l.makeSQLObjectSnapshot(table);

    System.out.println("Original: "+original);
    System.out.println("After: "+afterChange);
    
    l.rollBack(afterChange);
    
    assertEquals(original.toString(), afterChange.toString());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:29,代码来源:TestSQLTable.java

示例5: testChangeSFifthColumnIdxToTop

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void testChangeSFifthColumnIdxToTop() throws Exception {
    EventLogger l = new EventLogger();
    SQLObjectSnapshot original = l.makeSQLObjectSnapshot(table);
    
    SQLPowerUtils.listenToHierarchy(table, l);
    table.changeColumnIndex(4, 0, true);        
    SQLPowerUtils.unlistenToHierarchy(table, l);

    assertEquals(4, table.getPkSize());
    
    assertEquals(0, table.getColumnIndex(table.getColumnByName("five")));
    assertEquals(1, table.getColumnIndex(table.getColumnByName("one")));
    assertEquals(2, table.getColumnIndex(table.getColumnByName("two")));
    assertEquals(3, table.getColumnIndex(table.getColumnByName("three")));
    assertEquals(4, table.getColumnIndex(table.getColumnByName("four")));       
    assertEquals(5, table.getColumnIndex(table.getColumnByName("six")));

    System.out.println("Event log:\n"+l);

    SQLObjectSnapshot afterChange = l.makeSQLObjectSnapshot(table);

    System.out.println("Original: "+original);
    System.out.println("After: "+afterChange);
    
    l.rollBack(afterChange);
    
    assertEquals(original.toString(), afterChange.toString());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:29,代码来源:TestSQLTable.java

示例6: testChangeFifthColumnKey

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void testChangeFifthColumnKey() throws Exception {
    EventLogger l = new EventLogger();
    SQLColumn col5 = table.getColumnByName("five");
    assertNotNull(col5);

    SQLObjectSnapshot original = l.makeSQLObjectSnapshot(table);
    
    SQLPowerUtils.listenToHierarchy(table, l);
    table.changeColumnIndex(table.getColumnIndex(col5), 1, true);
    SQLPowerUtils.unlistenToHierarchy(table, l);

    System.out.println("Event log:\n"+l);

    SQLObjectSnapshot afterChange = l.makeSQLObjectSnapshot(table);

    assertEquals(4, table.getPkSize());
    
    assertEquals(0, table.getColumnIndex(table.getColumnByName("one")));
    assertEquals(1, table.getColumnIndex(table.getColumnByName("five")));
    assertEquals(2, table.getColumnIndex(table.getColumnByName("two")));
    assertEquals(3, table.getColumnIndex(table.getColumnByName("three")));
    assertEquals(4, table.getColumnIndex(table.getColumnByName("four")));
    assertEquals(5, table.getColumnIndex(table.getColumnByName("six")));
    
    System.out.println("Original: "+original);
    System.out.println("After: "+afterChange);
    
    l.rollBack(afterChange);
    
    assertEquals(original.toString(), afterChange.toString());
    
    // also roll forward original and compare to afterChange
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:34,代码来源:TestSQLTable.java

示例7: childRemoved

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
public void childRemoved(SPChildEvent e) {
	//sets the current editor pane to null if object is removed.
	if (oldPane instanceof MatchMakerEditorPane) {
		MatchMakerObject removedChild = (MatchMakerObject) e.getChild();
		MatchMakerObject editorMMO = ((MatchMakerEditorPane)oldPane).getCurrentEditingMMO();
		if (removedChild.equals(editorMMO) || SQLPowerUtils.hierarchyContains(removedChild, editorMMO)) {
			MatchMakerTreeModel treeModel = (MatchMakerTreeModel)getTree().getModel();
			TreePath treePath = treeModel.getPathForNode((MatchMakerObject)e.getSource());
			getTree().setSelectionPath(treePath);
		}
	}
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:15,代码来源:MatchMakerSwingSession.java

示例8: cleanup

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
  * Make the undoWatcher stop listening to the matchmaker objects and
  * clears the undo stack
  */
 public void cleanup() {
 	if (undo != null) {
 		logger.debug("Cleaning up undo watcher: " + this);
 		undo.die();
SQLPowerUtils.unlistenToHierarchy(mmo, this);
mmo = null;
pane = null;
swingSession.refreshUndoAction();
 	}
 }
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:15,代码来源:MMOChangeUndoWatcher.java

示例9: childRemoved

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
public void childRemoved(SPChildEvent e) {
	if (!session.isUnsaved() && ((MatchMakerObject)e.getChild()).isMagicEnabled()) {
		logger.error("Child remove happened! On " + e.getSource().getClass().getSimpleName() +"'s " + e.getChild().getClass().getSimpleName());
		changeHappened();
	}
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:9,代码来源:MMOSaveChangesListener.java

示例10: childRemovedImpl

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
public void childRemovedImpl(SPChildEvent e) {
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
    unsavedChangesExist = true;
    
    // Add the RS producer listener
    if (e.getChild() instanceof ResultSetProducer) {
    	((ResultSetProducer)e.getChild())
    			.removeResultSetProducerListener(rsProducerListener);
    }
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:12,代码来源:WabitSwingSessionImpl.java

示例11: childRemovedImpl

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
protected void childRemovedImpl(SPChildEvent e) {
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
          if (!appearsInTree(e.getChild())) {
              return;
          }
    
          TreePath treePath = createTreePathForObject(e.getChild());
    
          if (treePath == null) {
          	// This object is not part of this tree.
          	return;
          }
          
    int index;
	if (e.getChild() instanceof OlapQuery) {
		index = e.getIndex() + workspace.getChildren(QueryCache.class).size();
	} else if (e.getSource() instanceof Report
			&& e.getChild() instanceof Selector) {
		index = e.getIndex() - 1 + ((Report)e.getSource()).getPage().getContentBoxes().size();
	} else {
		index = e.getIndex();
	}
	
	TreeModelEvent treeEvent = new TreeModelEvent(this, treePath.getParentPath(),
			new int[] { index }, new Object[] { e.getChild() });
	
	fireTreeNodesRemoved(treeEvent);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:29,代码来源:WorkspaceTreeModel.java

示例12: setContentRenderer

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Sets the given content renderer as this box's provider of rendered
 * content.
 * <p>
 * Although content renderers are considered children of the content box
 * (and this method does cause child added/removed events), a content box
 * can only have one content renderer at a time, so if you call this method
 * when the current content renderer is non-null, the old renderer will be
 * replaced by the new one.
 * 
 * @param contentRenderer
 *            The new content renderer to use. Can be null, which means to
 *            remove the content render and render this content box
 *            incontent.
 */
public void setContentRenderer(ReportContentRenderer contentRenderer) {
	//not setting the content renderer if it is already set as it would
	//clean up the content renderer.
	if (contentRenderer == this.contentRenderer)  return;
	
    ReportContentRenderer oldContentRenderer = this.contentRenderer;
    if (oldContentRenderer != null) {
    	CleanupExceptions cleanupObject = SQLPowerUtils.cleanupSPObject(oldContentRenderer);
    	SQLPowerUtils.displayCleanupErrors(cleanupObject, getSession().getContext());
    	SQLPowerUtils.unlistenToHierarchy(oldContentRenderer, childListener);
        oldContentRenderer.setParent(null);
        fireChildRemoved(ReportContentRenderer.class, oldContentRenderer, 0);
    }
    this.contentRenderer = contentRenderer;
    WabitWorkspace workspace = WabitUtils.getWorkspace(this);
    if (contentRenderer != null) {
    	if (workspace == null || workspace.isMagicEnabled()) {
    		if (getParent() != null) {
    			getParent().setUniqueName(ContentBox.this,
    					"Content from " + contentRenderer.getName());
    		} else {
    			setName("Content from " + contentRenderer.getName());
    		}
    	}
        contentRenderer.setParent(this);
        SQLPowerUtils.listenToHierarchy(contentRenderer, childListener);
        fireChildAdded(ReportContentRenderer.class, contentRenderer, 0);
    } else {
    	if (workspace == null || workspace.isMagicEnabled()) {
    		setName(EMPTY_BOX_NAME);
    	}
    }
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:49,代码来源:ContentBox.java

示例13: detachListeners

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
private void detachListeners(){
       if (getParent() != null) {
           SQLPowerUtils.unlistenToHierarchy(getParent(), fkColumnUpdater);
       }
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:6,代码来源:SQLRelationship.java

示例14: childRemovedImpl

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
protected void childRemovedImpl(SPChildEvent e) {
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:5,代码来源:ForeignKeyColumnUpdaterPoolingSPListener.java

示例15: childRemoved

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void childRemoved(SPChildEvent e) {
      if (!e.getSource().getRunnableDispatcher().isForegroundThread()) {
           throw new RuntimeException("Removed child event " + e + " not fired on the foreground.");
       }
      
      String parentUUID = e.getSource().getUUID();
	int index = e.getIndex();
	List<PersistedSPObject> toBeUpdated = new ArrayList<PersistedSPObject>();
	// Get all the sibling under the same parent
	//TODO make this work like childAdded
	for (PersistedSPObject persisterSibling : parentPeristedObjects.get(getParentPersistedObjectsId(parentUUID, e.getChildType().getName()))) {
		
		if (persisterSibling.getIndex() > index && persisterSibling.getType().equals(e.getChildType().getName())) {
			toBeUpdated.add(persisterSibling);
		}
	}
	
	for (PersistedSPObject psp : toBeUpdated) {
		// Update the sibling's index
		PersistedSPObject newIndexedSibling = new PersistedSPObject(psp.getParentUUID(), psp.getType(), psp.getUUID(), psp.getIndex()-1);
		persistedObjects.remove(psp.getUUID());
		persistedObjects.put(psp.getUUID(), newIndexedSibling);
		parentPeristedObjects.remove(getParentPersistedObjectsId(psp), psp);
		parentPeristedObjects.put(getParentPersistedObjectsId(newIndexedSibling), newIndexedSibling);
	} 
      
      
      
	SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
	if (wouldEcho()) return;
	String uuid = e.getChild().getUUID();
	if (getRemovedObject(uuid) != null && getPersistedObject(uuid) == null) {
	    throw new IllegalStateException("Cannot add object of type " 
                   + e.getChildType() + " with UUID " + uuid + " because an object with "
                   + " the same UUID has already been removed");     
	}
	PersistedSPObject pso = getPersistedObject(uuid);
	if (pso == null) {
	    transactionStarted(TransactionEvent.createStartTransactionEvent(this, 
	    "Start of transaction triggered by childRemoved event"));
	    objectsToRemove.put(e.getChild().getUUID(),
	            new RemovedObjectEntry(
	                    e.getSource().getUUID(),
	                    e.getChild(),
	                    e.getIndex()));
	    removedObjectsUUIDs.addAll(getDescendantUUIDs(e.getChild()));
	    transactionEnded(TransactionEvent.createEndTransactionEvent(this));
	}
	//When a remove comes in we need to remove all of the persist calls for the
	//object being removed and its descendants regardless if a remove event is included.
    persistedProperties.removeAll(uuid);
    if (pso != null) {
    	persistedObjects.remove(pso.getUUID());
    	parentPeristedObjects.remove(getParentPersistedObjectsId(pso), pso);
    }
    List<String> descendantUUIDs = new ArrayList<String>(getDescendantUUIDs(e.getChild()));
    descendantUUIDs.remove(uuid);
    for (String uuidToRemove : descendantUUIDs) {
        persistedProperties.removeAll(uuidToRemove);
        PersistedSPObject childPSO = persistedObjects.get(uuidToRemove);
        persistedObjects.remove(uuidToRemove);
        if (childPSO != null) {
        	parentPeristedObjects.remove(getParentPersistedObjectsId(childPSO), childPSO);
        }
    }
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:67,代码来源:SPPersisterListener.java


注:本文中的ca.sqlpower.util.SQLPowerUtils.unlistenToHierarchy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。