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


Java SQLPowerUtils.listenToHierarchy方法代码示例

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


在下文中一共展示了SQLPowerUtils.listenToHierarchy方法的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: childAdded

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void childAdded(SPChildEvent e) {
		    if (!e.getSource().getRunnableDispatcher().isForegroundThread()) {
           throw new RuntimeException("New child event " + e + " not fired on the foreground.");
       }
	int index = e.getIndex();
	// Get all the sibling under the same parent
	PersistedSPObject minValue = new PersistedSPObject(
			e.getSource().getUUID(), e.getChildType().getName(), e.getChild().getUUID(), index);
	Set<PersistedSPObject> toBeUpdated = new HashSet<PersistedSPObject>(parentPeristedObjects.get(getParentPersistedObjectsId(minValue)).tailSet(minValue));
	
	for (PersistedSPObject psp : toBeUpdated) {
		// Update the sibling's index
		PersistedSPObject newIndexedSibling = new PersistedSPObject(psp.getParentUUID(), psp.getType(), psp.getUUID(), psp.getIndex()+1);
		parentPeristedObjects.remove(getParentPersistedObjectsId(psp), psp);
		parentPeristedObjects.put(getParentPersistedObjectsId(newIndexedSibling), newIndexedSibling);
		psp.setIndex(psp.getIndex() + 1);
	} 
		    
	SQLPowerUtils.listenToHierarchy(e.getChild(), this);
	if (wouldEcho()) return;
	if (logger.isDebugEnabled()) {
		logger.debug("Child added: " + e);
	}
	persistObject(e.getChild(), index);
	removedObjectsUUIDs.removeAll(getDescendantUUIDs(e.getChild()));
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:27,代码来源:SPPersisterListener.java

示例3: childAdded

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
@Override
public void childAdded(SPChildEvent e) {// selects the new child on the tree if one new child is added
	if (selectNewChild) {
		final MatchMakerObject insertedMMO = (MatchMakerObject)e.getChild();
		if (!(insertedMMO instanceof SQLInputStep
				|| insertedMMO instanceof MungeResultStep
				|| insertedMMO instanceof MungeStepOutput) && insertedMMO.isMagicEnabled()) {
			SwingUtilities.invokeLater(new Runnable(){
				public void run() {
					MatchMakerTreeModel treeModel = (MatchMakerTreeModel)getTree().getModel();
					TreePath treePath = treeModel.getPathForNode(insertedMMO);
					getTree().setSelectionPath(treePath);
				}
			});
		}
	}
	SQLPowerUtils.listenToHierarchy(e.getChild(), this);
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:19,代码来源:MatchMakerSwingSession.java

示例4: childAdded

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void childAdded(SPChildEvent e) {
    if (SPObjectUndoManager.this.isUndoOrRedoing())
        return;

    addEdit(new SPObjectChildEdit(e));

    if (addListenerToChildren) {
    	SQLPowerUtils.listenToHierarchy(e.getChild(), this);
    	removedObjects.remove(e.getChild());
    }

}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:13,代码来源:SPObjectUndoManager.java

示例5: 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

示例6: 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

示例7: 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

示例8: testRemoveIndexWhenColsRemovedSingleUndoEvent

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Tests if we remove all of the columns in an index from its table
 * that the index is removed from the table as well, and the whole operation
 * is a single compound operation.
 */
public void testRemoveIndexWhenColsRemovedSingleUndoEvent() throws Exception {
    assertEquals(index2, table.getIndexByName("Test Index 2"));
    CountingCompoundEventListener l = new CountingCompoundEventListener();
    SQLPowerUtils.listenToHierarchy(table, l);
    table.removeColumn(2);
    assertEquals(0, l.getEditsBeforeLastGroup());
    table.removeColumn(0);
    assertEquals(0, l.getEditsBeforeLastGroup());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:15,代码来源:TestSQLIndex.java

示例9: MatchMakerSwingSession

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
    * Creates a new MatchMaker session, complete with Swing GUI. Normally you
    * would use a LoginDialog instead of calling this constructor directly.
    *
    * @param context
    *            the Swing-specific session context
    * @param sessionImpl
    *            The session that actually does the dirty work (ORM and stuff
    *            like that).
 * @throws SQLException
    */
public MatchMakerSwingSession(SwingSessionContext context, MatchMakerSession sessionImpl) {
       this.sessionImpl = sessionImpl;
       this.sessionContext = context;
       this.smallMMIcon = MMSUtils.getFrameImageIcon();
       
       sessionImpl.getRootNode().setSession(this);
       
       matchEnginePanels = new HashMap<MatchEngineImpl, EngineSettingsPanel>();
       mergeEnginePanels = new HashMap<MergeEngineImpl, EngineSettingsPanel>();
       cleanseEnginePanels = new HashMap<CleanseEngineImpl, EngineSettingsPanel>();
       addressCorrectionEnginePanels = new HashMap<AddressCorrectionEngine, EngineSettingsPanel>();
       
       lifecycleListener = new ArrayList<SessionLifecycleListener<MatchMakerSession>>();
       
       // this grabs warnings from the business model and DAO's and lets us handle them.
       sessionImpl.addWarningListener(new WarningListener() {
		public void handleWarning(String message) {
			MatchMakerSwingSession.this.handleWarning(message);
		}
	});

       frame = new JFrame("SQL Power DQguru");
       statusLabel = new JLabel();
       warningDialog = new JDialog(frame, "DQguru Warnings");
       warningTextArea = new JTextArea(6, 40);
       JComponent cp = (JComponent) warningDialog.getContentPane();
       cp.setLayout(new BorderLayout(0, 10));
       cp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
       cp.add(new JScrollPane(warningTextArea), BorderLayout.CENTER);
       JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
       buttonPanel.add(new JButton(clearWarningsAction));
       buttonPanel.add(new JButton(closeWarningDialogAction));
       cp.add(buttonPanel, BorderLayout.SOUTH);
       
       SQLPowerUtils.listenToHierarchy(getCurrentFolderParent(), removeEditorListener);
       SQLPowerUtils.listenToHierarchy(getTranslateGroupParent(), removeEditorListener);
       
       buildMenuBar();
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:51,代码来源:MatchMakerSwingSession.java

示例10: MMOChangeUndoWatcher

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Creates a new MMO Change Watcher for the matchmaker object subtree rooted
 * at the given node.
 * 
 * @param mmo The root node of the subtree to monitor.
 */
public MMOChangeUndoWatcher(MatchMakerObject mmo, AbstractUndoableEditorPane pane, MatchMakerSwingSession session) {
	this.swingSession = session;
	this.mmo = mmo;
	this.pane = pane;
	
	logger.debug("Initializing undo watcher: " + this);
    SQLPowerUtils.listenToHierarchy(mmo, this);
    undo = new UndoManager();
    swingSession.setUndo(undo);
    undoCount = 0;
    ce = null;
    hasChanged = false;
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:20,代码来源:MMOChangeUndoWatcher.java

示例11: WorkspaceTreeModel

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * This is the tree model which contains a workspace
 * 
 * @param workspace
 * 		This is the root node of the tree 
 */
public WorkspaceTreeModel(WabitWorkspace workspace) {
    this.workspace = workspace;
    this.folderList = new ArrayList<FolderNode>();
    generateFolderList();
    
    listener = new WabitTreeModelEventAdapter();
    SQLPowerUtils.listenToHierarchy(workspace, listener);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:15,代码来源:WorkspaceTreeModel.java

示例12: childAdded

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

示例13: childAddedImpl

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
protected void childAddedImpl(SPChildEvent e) {
	SQLPowerUtils.listenToHierarchy(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 = ((Report)e.getSource()).getSelectors().indexOf(e.getChild()) + ((Report)e.getSource()).getPage().getContentBoxes().size();
	} else {
		index = e.getIndex();
	}
	
    TreeModelEvent treeEvent = new TreeModelEvent(this, treePath.getParentPath(), 
    		new int[] {index},
    		new Object[] {e.getChild()});
	fireTreeNodesInserted(treeEvent);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:29,代码来源:WorkspaceTreeModel.java

示例14: 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

示例15: attachListeners

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public void attachListeners() throws SQLObjectException {
	SQLPowerUtils.listenToHierarchy(getParent(), fkColumnUpdater);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:4,代码来源:SQLRelationship.java


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