本文整理汇总了Java中ca.sqlpower.util.SQLPowerUtils.cleanupSPObject方法的典型用法代码示例。如果您正苦于以下问题:Java SQLPowerUtils.cleanupSPObject方法的具体用法?Java SQLPowerUtils.cleanupSPObject怎么用?Java SQLPowerUtils.cleanupSPObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.sqlpower.util.SQLPowerUtils
的用法示例。
在下文中一共展示了SQLPowerUtils.cleanupSPObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCleanupWabitObject
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
* Tests the cleanupWabitObject calls cleanup on the given object
* and all of its children and that it collects the errors from each
* object.
*/
public void testCleanupWabitObject() throws Exception {
TestWabitObject parent = new TestWabitObject();
parent.setName("parent");
TestWabitObject child = new TestWabitObject();
child.setName("child");
parent.addChild(child);
TestWabitObject grandchild = new TestWabitObject();
grandchild.setName("grandchild");
child.addChild(grandchild);
CleanupExceptions cleanupObject = SQLPowerUtils.cleanupSPObject(parent);
assertFalse(cleanupObject.isCleanupSuccessful());
assertEquals(3, cleanupObject.getErrorMessages().size());
assertEquals(1, parent.getCleanupCallCount());
assertEquals(1, child.getCleanupCallCount());
assertEquals(1, grandchild.getCleanupCallCount());
}
示例2: close
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public boolean close() {
CleanupExceptions cleanupObject = SQLPowerUtils.cleanupSPObject(workspace);
SQLPowerUtils.displayCleanupErrors(cleanupObject, sessionContext);
SessionLifecycleEvent<WabitSession> lifecycleEvent =
new SessionLifecycleEvent<WabitSession>(this);
for (int i = lifecycleListeners.size() - 1; i >= 0; i--) {
lifecycleListeners.get(i).sessionClosing(lifecycleEvent);
}
return true;
}
示例3: removeContentBox
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void removeContentBox(ContentBox removeme) {
if (removeme.getParent() != this) {
throw new IllegalStateException("That's not my content box!");
}
CleanupExceptions cleanupObject = SQLPowerUtils.cleanupSPObject(removeme);
SQLPowerUtils.displayCleanupErrors(cleanupObject, getSession().getContext());
int index = contentBoxes.indexOf(removeme);
if (index != -1) {
contentBoxes.remove(removeme);
fireChildRemoved(ContentBox.class, removeme, index);
removeme.setParent(null);
}
}
示例4: 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);
}
}
}
示例5: removeNode
import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
* This recursive method will remove the given node and all nodes that
* are reachable from it from their parents based on the graph given.
* <p>
* package private for testing.
*
* @param nodeToRemove
* The node to remove from its parents. The nodes reachable
* from this node based on the given graph will also be
* removed from their parents.
* @param graph
* The graph that will decide what objects are adjacent to
* this node. As this method is being used for removing a
* {@link WabitObject} and its dependencies from the tree
* this graph should contain the {@link WabitObject} being
* removed by the action and all of the {@link WabitObject}s
* depending on this object and the dependent object's
* dependencies.
* @return true if the node and its descendants were successful. False
* otherwise.
* @throws ObjectDependentException
* Thrown if the node that was being removed is still
* dependent on other objects existing. This suggests that
* there is a problem in the graph given that should connect
* all of the objects to their dependencies.
* @throws IllegalArgumentException
* Thrown if a node being removed is not a child of its
* parent. This suggests there is something wrong with the
* parent/child relationships in the workspace.
*/
boolean removeNode(SPObject nodeToRemove, WorkspaceGraphModel graph) throws IllegalArgumentException, ObjectDependentException {
boolean successfullyRemoved = true;
for (SPObject dependent : graph.getAdjacentNodes(nodeToRemove)) {
//Check if the dependency exists to prevent infinite recursion if there is
//a cycle in the graph.
if (!dependent.getDependencies().contains(nodeToRemove)) continue;
dependent.removeDependency(nodeToRemove);
successfullyRemoved = successfullyRemoved && removeNode(dependent, graph);
if (logger.isDebugEnabled() && !successfullyRemoved) {
logger.debug("Could not remove " + dependent.getName());
}
}
CleanupExceptions cleanupObject = SQLPowerUtils.cleanupSPObject(nodeToRemove);
SQLPowerUtils.displayCleanupErrors(cleanupObject, upf);
if (nodeToRemove.getParent() != null) {
successfullyRemoved = successfullyRemoved &&
nodeToRemove.getParent().removeChild(nodeToRemove);
}
if (logger.isDebugEnabled() && !successfullyRemoved) {
logger.debug("Failed to remove " + nodeToRemove.getName());
}
return successfullyRemoved;
}