home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 5.4 KB | 180 lines |
- /*
- * @(#)QueryNavigatorLink.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
- // Each QuerySynchronizer object contains one and only one
- // QueryNavigatorTree object. This tree class implements the JFC
- // swing tree interface. The parent child relationships between tree
- // nodes correspond to the master detail relationships between
- // QueryNavigators objects. Each node contains a reference to a
- // QueryNavigatorLink object. The purpose of this link is to hold
- // a spot for a QueryNavigator when the alias is known from a detail
- // QueryNavigator object before the master QueryNavigator object is
- // registered.
-
- package symantec.itools.db.beans.binding;
-
- import javax.awt.swing.tree.*;
- import java.beans.PropertyChangeListener;
- import java.beans.PropertyChangeSupport;
- import java.beans.PropertyChangeEvent;
-
- final class QueryNavigatorLink implements SynchronizerLink,PropertyChangeListener
- {
- private String m_Alias = "";
- private String m_MasterAlias = "";
- private TreeNode m_Node = null;
- private Synchronizable m_Synchronizable = null;
- private QuerySynchronizer m_Synchronizer = null;
-
- public synchronized String getAlias() { return m_Alias; }
- public synchronized String getMasterAlias() { return m_MasterAlias; }
- public synchronized TreeNode getNode() { return m_Node; }
- public synchronized Synchronizable getSynchronizable() { return m_Synchronizable; }
- public synchronized QuerySynchronizer getSynchronizer() { return m_Synchronizer; }
-
- public synchronized void setAlias(String value)
- {
- m_Alias = value;
- QuerySynchronizer.addLink(this);
- }
-
- public synchronized void setMasterAlias(String value)
- {
- m_MasterAlias = value;
- }
-
- public synchronized void setNode(TreeNode value)
- {
- m_Node = value;
- }
-
- public synchronized void setSynchronizable(Synchronizable value)
- {
- // Foo : Check for conflicts...
- m_Synchronizable = value;
- setAlias(value.getAliasName());
- setMasterAlias(value.getMasterAliasName());
- m_Synchronizable.addPropertyChangeListener(this);
- }
-
- public synchronized void setSynchronizer(QuerySynchronizer value)
- {
- m_Synchronizer = value;
- }
-
- public synchronized boolean isOpen()
- {
- return m_Synchronizable == null;
- }
-
- public String toString()
- {
- if (isOpen()) {
- return "\t\tOPEN\t\t" + m_Alias;
- }
- else {
- return m_Synchronizable.toString();
- }
- }
-
- /**
- * Invoked by the synchronizable object to perform saveAll
- */
- public void saveAll() throws RelationshipPendingException, ParentInvalidRecordException
- {
- m_Synchronizer.saveAll(this);
- }
-
- /**
- * Invoked by the synchronizable object to perform saveAllLevels
- */
- public void saveAllLevels() throws RelationshipPendingException, ParentInvalidRecordException
- {
- m_Synchronizer.saveAllLevels(this);
- }
-
- /**
- * Invoked by the synchronizable object to perform save
- */
- public void save() throws RelationshipPendingException, ParentInvalidRecordException
- {
- m_Synchronizer.save(this);
- }
-
- /**
- * Invoked by the synchronizable object to perform next,previous,
- * first,insert,goto,restart,startqbe
- */
- public void navigate(int type, Integer position)
- throws ParentInvalidRecordException, RelationshipPendingException
- {
- m_Synchronizer.navigate(this, type, position);
- }
-
- /**
- * Foo: remove connection/ remove link from tree
- */
- public void close()
- {
- m_Synchronizer.removeLink(this);
- m_Synchronizable.removePropertyChangeListener(this);
- closes.firePropertyChange("close", new Boolean(false), new Boolean(true));
- m_Synchronizable = null;
- }
-
- /*
- * Get link of parent node.
- */
- public synchronized SynchronizerLink getParentLink()
- {
- SynchronizerLink parentLink;
- SynchronizerNode node = (SynchronizerNode)getNode();
- SynchronizerNode parentNode = (SynchronizerNode)node.getParent();
-
- if (parentNode != null) {
- parentLink = (SynchronizerLink)parentNode.getUserObject();
- }
- else {
- parentLink = null;
- }
- return parentLink;
- }
-
- /**
- * javadoc comments go here...
- */
- private PropertyChangeSupport closes = new PropertyChangeSupport(this);
-
- /**
- * javadoc comments go here...
- */
- public void addPropertyChangeListener(PropertyChangeListener listener)
- {
- closes.addPropertyChangeListener(listener);
- }
-
- /**
- * javadoc comments go here...
- */
- public void removePropertyChangeListener(PropertyChangeListener listener)
- {
- closes.removePropertyChangeListener(listener);
- }
-
- /**
- * Handle the property changed event.
- * We check for property name in case someday we add another property.
- * We don't check for old and new values because regarding the close property
- * it is only used when the sender is going from an open to closed transition.
- */
- public void propertyChange(PropertyChangeEvent event)
- {
- if (event.getPropertyName() == "close") {
- close();
- }
- }
- }