API 0.9.5
AppKit/Cib/CPCibConnector.j
Go to the documentation of this file.
00001 /*
00002  * CPCibConnector.j
00003  * AppKit
00004  *
00005  * Created by Francisco Tolmasky.
00006  * Copyright 2008, 280 North, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 
00024 
00025 var _CPCibConnectorSourceKey        = @"_CPCibConnectorSourceKey",
00026     _CPCibConnectorDestinationKey   = @"_CPCibConnectorDestinationKey",
00027     _CPCibConnectorLabelKey         = @"_CPCibConnectorLabelKey";
00028 
00029 @implementation CPCibConnector : CPObject
00030 {
00031     id          _source;
00032     id          _destination;
00033     CPString    _label;
00034 }
00035 
00036 - (void)replaceObject:(id)anObject withObject:(id)anotherObject
00037 {
00038     if (_source === anObject)
00039         _source = anotherObject;
00040 
00041     if (_destination === anObject)
00042         _destination = anotherObject;
00043 }
00044 
00045 - (void)replaceObjects:(Object)replacementObjects
00046 {
00047     var replacement = replacementObjects[[_source UID]];
00048 
00049     if (replacement !== undefined)
00050         _source = replacement;
00051 
00052     replacement = replacementObjects[[_destination UID]];
00053 
00054     if (replacement !== undefined)
00055         _destination = replacement;
00056 }
00057 
00058 @end
00059 
00060 @implementation CPCibConnector (CPCoding)
00061 
00062 - (id)initWithCoder:(CPCoder)aCoder
00063 {
00064     self = [super init];
00065 
00066     if (self)
00067     {
00068         _source = [aCoder decodeObjectForKey:_CPCibConnectorSourceKey];
00069         _destination = [aCoder decodeObjectForKey:_CPCibConnectorDestinationKey];
00070         _label = [aCoder decodeObjectForKey:_CPCibConnectorLabelKey];
00071     }
00072 
00073     return self;
00074 }
00075 
00076 - (void)encodeWithCoder:(CPCoder)aCoder
00077 {
00078     [aCoder encodeObject:_source forKey:_CPCibConnectorSourceKey];
00079     [aCoder encodeObject:_destination forKey:_CPCibConnectorDestinationKey];
00080     [aCoder encodeObject:_label forKey:_CPCibConnectorLabelKey];
00081 }
00082 
00083 @end
00084 
00085 // For backwards compatibility.
00086 @implementation _CPCibConnector : CPCibConnector { } @end
00087 
00088 @implementation CPCibConnector (CPSynthesizedAccessors)
00089 
00093 - (id)source
00094 {
00095     return _source;
00096 }
00097 
00101 - (void)setSource:(id)aValue
00102 {
00103     _source = aValue;
00104 }
00105 
00109 - (id)destination
00110 {
00111     return _destination;
00112 }
00113 
00117 - (void)setDestination:(id)aValue
00118 {
00119     _destination = aValue;
00120 }
00121 
00125 - (CPString)label
00126 {
00127     return _label;
00128 }
00129 
00133 - (void)setLabel:(CPString)aValue
00134 {
00135     _label = aValue;
00136 }
00137 
00138 @end
 All Classes Files Functions Variables Defines