![]() |
API 0.9.5
|
00001 /* 00002 * CPCibControlConnector.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 @implementation CPCibControlConnector : CPCibConnector 00023 { 00024 id __doxygen__; 00025 } 00026 00027 - (void)establishConnection 00028 { 00029 var selectorName = _label, 00030 selectorNameLength = [selectorName length]; 00031 00032 if (selectorNameLength && selectorName.charAt(selectorNameLength - 1) !== ':') 00033 selectorName += ':'; 00034 00035 var selector = CPSelectorFromString(selectorName); 00036 00037 // Not having a selector is a fatal error. 00038 if (!selector) 00039 { 00040 [CPException 00041 raise:CPInvalidArgumentException 00042 reason:@"-[" + [self className] + ' ' + _cmd + @"] selector " + selectorName + @" does not exist."]; 00043 } 00044 00045 // If the destination doesn't respond to this selector, warn but don't die. 00046 if (_destination && ![_destination respondsToSelector:selector]) 00047 CPLog.warn(@"Could not connect the action " + selector + @" to target of class " + [_destination className]); 00048 00049 // Not being able to set the action is a fatal error. 00050 if ([_source respondsToSelector:@selector(setAction:)]) 00051 objj_msgSend(_source, @selector(setAction:), selector); 00052 00053 else 00054 [CPException 00055 raise:CPInvalidArgumentException 00056 reason:@"-[" + [self className] + ' ' + _cmd + @"] " + [_source description] + @" does not respond to setAction:"]; 00057 00058 // Not being able to set the target is a fatal error. 00059 if ([_source respondsToSelector:@selector(setTarget:)]) 00060 objj_msgSend(_source, @selector(setTarget:), _destination); 00061 00062 else 00063 [CPException 00064 raise:CPInvalidArgumentException 00065 reason:@"-[" + [self className] + ' ' + _cmd + @"] " + [_source description] + @" does not respond to setTarget:"]; 00066 } 00067 00068 @end 00069 @implementation _CPCibControlConnector : CPCibControlConnector 00070 { 00071 id __doxygen__; 00072 } 00073 00074 @end 00075