本文整理汇总了Java中ca.sqlpower.object.ObjectDependentException类的典型用法代码示例。如果您正苦于以下问题:Java ObjectDependentException类的具体用法?Java ObjectDependentException怎么用?Java ObjectDependentException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectDependentException类属于ca.sqlpower.object包,在下文中一共展示了ObjectDependentException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRemoveChildTable
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testRemoveChildTable() throws SQLObjectException, IllegalArgumentException, ObjectDependentException {
assertEquals(3,database.getChildCount());
assertEquals(2,parentTable.getExportedKeys().size());
database.removeChild(childTable1);
assertEquals(2,database.getChildCount());
assertEquals(1,parentTable.getExportedKeys().size());
assertNull("Child table not removed from the database",
database.getTableByName(childTable1.getName()));
assertFalse("Parent still contains a reference to a deleted table",
parentTable.getExportedKeys().contains(rel1));
database.removeChild(childTable2);
assertNull("Child table 2 not removed from the database",
database.getTableByName(childTable2.getName()));
assertFalse("Parent still contains a reference to a deleted table",
parentTable.getExportedKeys().contains(rel2));
assertEquals(1,database.getChildCount());
assertEquals(0,parentTable.getExportedKeys().size());
}
示例2: testGetChild
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testGetChild() throws SQLObjectException, IllegalArgumentException, ObjectDependentException {
SQLDatabase db1 = new SQLDatabase();
SQLTable t1 = new SQLTable(db1,"t1","","TABLE",true);
SQLTable t2 = new SQLTable(db1,"t2","","TABLE",true);
SQLTable t3 = new SQLTable(db1,"t3","","TABLE",true);
db1.addChild(t1);
db1.addChild(t2,1);
assertEquals (db1.getChild(0), t1);
assertEquals (db1.getChild(1), t2);
db1.addChild(t3,0);
assertEquals (db1.getChild(1), t1);
assertEquals (db1.getChild(0), t3);
db1.removeChild(db1.getChild(1));
assertEquals (db1.getChild(1), t2);
db1.removeChild(t3);
assertEquals (db1.getChild(0), t2);
}
示例3: testMakeColumnsLikeOtherIndexReordersColumns
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testMakeColumnsLikeOtherIndexReordersColumns() throws SQLObjectException, IllegalArgumentException, ObjectDependentException {
SQLIndex i = new SQLIndex("Index",true,"", "BTREE","");
SQLColumn col = new SQLColumn(null,"New Column", Types.CHAR, null, 10, 0, 0, "", "", false);
i.addChild(new Column(col,AscendDescend.UNSPECIFIED));
i.addChild(new Column("index column",AscendDescend.UNSPECIFIED));
SQLIndex i2 = new SQLIndex("Index2",false,"", "HASH","asdfa");
i2.addChild(new Column("index column",AscendDescend.UNSPECIFIED));
i2.addChild(new Column(col,AscendDescend.UNSPECIFIED));
try
{
i.makeColumnsLike(i2);
} catch (Exception e) {
System.out.println("Exception: ");
e.printStackTrace();
}
assertEquals("Wrong number of children!",2,i.getChildCount());
assertEquals("Oh no wrong child!",i2.getChild(0),i.getChild(0));
assertEquals("Oh no wrong child!",i2.getChild(1),i.getChild(1));
}
示例4: testTreeNodeRemoveChildEvent
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
/**
* remove children on tree should also remove the listener on the children
* so this is for that.
*/
public void testTreeNodeRemoveChildEvent() {
folder.addChild(mmo);
try {
folder.removeChild(mmo);
}catch (ObjectDependentException e) {
throw new RuntimeException(e);
}
treeModel.addTreeModelListener(counter);
mmo.setName("newName");
assertEquals("remove event count should be 0",
0, counter.getChildrenRemovedCount());
assertEquals("total event count should be 0",
0, counter.getAllEventCounts());
assertEquals("Last event source should be mmo",
null,counter.getLastEvt());
}
示例5: testChildRemovedPassedOnCorrectly
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testChildRemovedPassedOnCorrectly(){
tgp = new TranslateGroupParent();
MatchMakerTranslateGroup tg2 = new MatchMakerTranslateGroup();
tg2.setName("Translate Group 2");
tgp.addChild(tg2);
tcbm = new TranslationComboBoxModel(tgp);
counter = new ListDataEventCounter();
tcbm.addListDataListener(counter);
try {
tgp.removeChild(tg2);
} catch (ObjectDependentException e) {
throw new RuntimeException(e);
}
assertEquals("Incorrect number of events fired ",1,counter.getAllEvents());
assertEquals("Event fired to the wrong location ",1,counter.getIntervalRemoved());
assertEquals("Wrong Type of event ",ListDataEvent.INTERVAL_REMOVED,counter.getLastEvent().getType());
assertEquals("Wrong lower bound ", 0, counter.getLastEvent().getIndex0());
assertEquals("Wrong Upper bound ", 0, counter.getLastEvent().getIndex1());
}
示例6: actionPerformed
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
int selectedRow = mergeRulesTable.getSelectedRow();
logger.debug("deleting merge rule:"+selectedRow);
int responds = JOptionPane.showConfirmDialog(
swingSession.getFrame(),
"Are you sure you want to delete the merge rule?",
"Delete Confirmation",
JOptionPane.YES_NO_OPTION);
if (responds != JOptionPane.YES_OPTION)
return;
TableMergeRules rule = mmo.getChildren(TableMergeRules.class).get(selectedRow);
try {
mmo.removeChild(rule);
} catch (ObjectDependentException e1) {
throw new RuntimeException(e1);
}
if (selectedRow >= mergeRulesTable.getRowCount()) {
selectedRow = mergeRulesTable.getRowCount() - 1;
}
if (selectedRow > 0) {
mergeRulesTable.setRowSelectionInterval(selectedRow, selectedRow);
}
}
示例7: redo
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void redo(){
super.redo();
try {
undoEvent.getSource().setMagicEnabled(false);
if (!(undoEvent.getSource() instanceof AbstractMatchMakerObject)) {
throw new CannotUndoException();
}
AbstractMatchMakerObject ammo = (AbstractMatchMakerObject) undoEvent.getSource();
if (!(undoEvent.getChild() instanceof AbstractMatchMakerObject)) {
throw new CannotUndoException();
}
AbstractMatchMakerObject child = (AbstractMatchMakerObject) undoEvent.getChild();
try {
ammo.removeChild(child);
} catch (ObjectDependentException e) {
throw new RuntimeException(e);
}
} finally {
undoEvent.getSource().setMagicEnabled(true);
}
}
示例8: undo
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void undo(){
super.undo();
try {
undoEvent.getSource().setMagicEnabled(false);
if (!(undoEvent.getSource() instanceof AbstractMatchMakerObject)) {
throw new CannotUndoException();
}
AbstractMatchMakerObject ammo = (AbstractMatchMakerObject) undoEvent.getSource();
if (!(undoEvent.getChild() instanceof MatchMakerObject)) {
throw new CannotUndoException();
}
AbstractMatchMakerObject child = (AbstractMatchMakerObject) undoEvent.getChild();
try {
ammo.removeChild(child);
} catch (ObjectDependentException e) {
throw new RuntimeException(e);
}
} finally {
undoEvent.getSource().setMagicEnabled(true);
}
}
示例9: cleanup
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
/**
* Disconnects all listeners in the query cache. Also closes any open database
* connections and updates prefs.
*/
private void cleanup() {
logger.debug("[email protected]" + System.identityHashCode(this) + " is cleaning up");
prefs.putInt(RESULTS_DIVIDER_LOCATON_KEY, mainSplitPane.getDividerLocation());
queryController.disconnect();
queryCache.removeResultSetProducerListener(rsProducerListener);
logger.debug("Removed the query panel change listener on the query cache");
queryUIComponents.closeConMap();
queryUIComponents.disconnectListeners();
try {
for (int i = rootNode.getChildren().size() - 1; i >= 0; i--) {
rootNode.removeChild(rootNode.getChildren().get(i));
}
} catch (ObjectDependentException e) {
throw new RuntimeException(e);
}
queryPen.cleanup();
logger.debug("[email protected]" + System.identityHashCode(this) + " cleanup done");
}
示例10: reset
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
/**
* Resets the workspace by removing all of the children in the workspace and
* setting all of the values in the workspace to defaults. Child removed
* events and other events will be thrown as children of the workspace are
* removed and cleaned up.
*/
public void reset() {
logger.debug("Resetting workspace " + getName() + " (" + getUUID() + ")");
setName(DEFAULT_NAME);
//Reversing the child list as the children are currently in order according
//to their dependencies. If the list of children changes in the future
//this may need to be defined more explicitly.
//TODO When we add the method that returns a list of child types the object
//supports make this list of children explicit and in the correct order.
List<SPObject> children = new ArrayList<SPObject>(getChildren());
Collections.reverse(children);
for (SPObject child : children) {
try {
removeChild(child);
} catch (ObjectDependentException e) {
throw new IllegalStateException("The child " + child.getName() + " should not " +
"have any dependencies at this point.", e);
}
child.cleanup();
}
}
示例11: testRemovingQueryWithDependency
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
/**
* Removing a child object that is a dependency should throw an exception
* when the remove operation occurs.
*/
public void testRemovingQueryWithDependency() throws Exception {
QueryCache query = new QueryCache(getContext());
query.setDataSource((JDBCDataSource)getSession().getDataSources().getDataSource("regression_test"));
workspace.addQuery(query, getSession());
Chart chart = new Chart();
chart.setName("chart");
chart.setQuery(query);
workspace.addChart(chart);
try {
workspace.removeChild(query);
fail("The child was removed while there was a chart dependent on it. " +
"Now the chart depends on an unparented object.");
} catch (ObjectDependentException e) {
//successfully caught the exception.
}
}
示例12: removeChild
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
@Override
public boolean removeChild(SPObject child) throws ObjectDependentException,
IllegalArgumentException {
if (child instanceof SQLObject) {
if (!fireDbChildPreRemove(getChildrenWithoutPopulating(child.getClass()).indexOf(child), (SQLObject) child)) {
return false;
}
}
if (!getChildrenWithoutPopulating().contains(child)) {
return false;
}
return removeChildImpl(child);
}
示例13: testAllChildHandlingMethods
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testAllChildHandlingMethods() throws SQLObjectException, IllegalArgumentException, ObjectDependentException {
if (!getSQLObjectUnderTest().allowsChildren()) return;
getSQLObjectUnderTest().populate();
NewValueMaker newValueMaker = new GenericNewValueMaker(getRootObject());
Class<? extends SPObject> childType = getSQLObjectUnderTest().getAllowedChildTypes().get(0);
int childCount = getSQLObjectUnderTest().getChildCount();
List<SPObject> children = new ArrayList<SPObject>();
children.addAll(getSQLObjectUnderTest().getChildren(childType));
SQLObject x = (SQLObject) newValueMaker.makeNewValue(childType, null, "");
getSQLObjectUnderTest().addChild(x);
assertEquals(childCount + 1, getSQLObjectUnderTest().getChildCount());
assertEquals(x, getSQLObjectUnderTest().getChildren(childType).get(
getSQLObjectUnderTest().getChildren(childType).size() - 1));
SQLObject y = (SQLObject) newValueMaker.makeNewValue(childType, null, "");
// Test addChild(SQLObject, int)
getSQLObjectUnderTest().addChild(y, 0);
assertEquals(y, getSQLObjectUnderTest().getChildren(y.getClass()).get(0));
assertEquals(x, getSQLObjectUnderTest().getChildren(childType).get(
getSQLObjectUnderTest().getChildren(childType).size() - 1));
getSQLObjectUnderTest().removeChild(x);
children.add(0, y);
assertTrue(getSQLObjectUnderTest().getChildren(childType).containsAll(children));
getSQLObjectUnderTest().removeChild(y);
assertEquals(childCount, getSQLObjectUnderTest().getChildCount());
}
示例14: testAllChildHandlingMethods
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
/**
* Overriden because the superclass version does not account for the default
* physical properties child, which must always exist and always be at index
* 0. Inserting a child at 0 results in an exception being thrown.
*/
@Override
public void testAllChildHandlingMethods() throws SQLObjectException,
IllegalArgumentException, ObjectDependentException {
if (!getSQLObjectUnderTest().allowsChildren()) return;
getSQLObjectUnderTest().populate();
NewValueMaker newValueMaker = new GenericNewValueMaker(getRootObject());
Class<? extends SPObject> childType = getSQLObjectUnderTest().getAllowedChildTypes().get(0);
int childCount = getSQLObjectUnderTest().getChildCount();
List<SPObject> children = new ArrayList<SPObject>();
children.addAll(getSQLObjectUnderTest().getChildren(childType));
SQLObject x = (SQLObject) newValueMaker.makeNewValue(childType, null, "");
getSQLObjectUnderTest().addChild(x);
assertEquals(childCount + 1, getSQLObjectUnderTest().getChildCount());
assertEquals(x, getSQLObjectUnderTest().getChildren(childType).get(
getSQLObjectUnderTest().getChildren(childType).size() - 1));
SQLObject y = (SQLObject) newValueMaker.makeNewValue(childType, null, "");
// Test addChild(SQLObject, int)
getSQLObjectUnderTest().addChild(y, 1);
assertEquals(y, getSQLObjectUnderTest().getChildren(y.getClass()).get(1));
assertEquals(x, getSQLObjectUnderTest().getChildren(childType).get(
getSQLObjectUnderTest().getChildren(childType).size() - 1));
getSQLObjectUnderTest().removeChild(x);
children.add(0, y);
assertTrue(getSQLObjectUnderTest().getChildren(childType).containsAll(children));
getSQLObjectUnderTest().removeChild(y);
assertEquals(childCount, getSQLObjectUnderTest().getChildCount());
}
示例15: testFireDbChildrenRemoved
import ca.sqlpower.object.ObjectDependentException; //导入依赖的package包/类
public void testFireDbChildrenRemoved() throws SQLObjectException, IllegalArgumentException, ObjectDependentException {
SQLTable tempTable = new SQLTable(c,"","","TABLE",true);
c.addChild(tempTable);
TestingSQLObjectListener test1 = new TestingSQLObjectListener();
c.addSPListener(test1);
c.removeChild(tempTable);
assertEquals("Children removed not fired!", 1, test1.getRemovedCount());
}