本文整理汇总了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);
}
}
}
示例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();
}
示例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));
}
示例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());
}
示例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());
}
示例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
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例13: detachListeners
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
private void detachListeners(){
if (getParent() != null) {
SQLPowerUtils.unlistenToHierarchy(getParent(), fkColumnUpdater);
}
}
示例14: childRemovedImpl
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
protected void childRemovedImpl(SPChildEvent e) {
SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
}
示例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);
}
}
}