Initial Version of EOModelEditor.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30502 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Dave Wetzel 2010-05-31 00:04:49 +00:00
parent 1935fd8e22
commit 9acc7d11cd
119 changed files with 10899 additions and 0 deletions

View file

@ -0,0 +1,48 @@
#ifndef __AdaptorsPanel_H_
#define __AdaptorsPanel_H_
/*
AdaptorsPanel.h
Author: Matt Rice <ratmice@gmail.com>
Date: Apr 2005
This file is part of DBModeler.
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <AppKit/AppKit.h>
#include <EOAccess/EOAdaptor.h>
@interface AdaptorsPanel : NSObject
{
NSWindow *_window;
NSBrowser *brws_adaptors;
NSButton *btn_ok;
NSButton *btn_cancel;
NSBox *_box;
NSTextField *_label;
}
-(NSString *)runAdaptorsPanel;
@end
#endif // __AdaptorsPanel_H

View file

@ -0,0 +1,173 @@
/**
AdaptorsPanel.m
Author: Matt Rice <ratmice@gmail.com>
Date: Apr 2005
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include "AdaptorsPanel.h"
#include <AppKit/AppKit.h>
#include <GNUstepBase/GNUstep.h>
static NSArray *_adaptorNames;
@implementation AdaptorsPanel
- (void) dealloc
{
DESTROY(_window);
DESTROY(_adaptorNames);
/* released by window
_label
brws_adaptors
btn_ok
btn_cancel
*/
[super dealloc];
}
- (id) init
{
if ((self = [super init]))
{
NSRect fr1, fr2;
_adaptorNames = RETAIN([EOAdaptor availableAdaptorNames]);
/* redo all these numbers so buttons and labels are on the right? */
_window = [[NSWindow alloc]
initWithContentRect: NSMakeRect(200,200,200,300)
styleMask: NSBorderlessWindowMask | NSTitledWindowMask
backing: NSBackingStoreBuffered
defer: YES];
[_window setTitle: @"Select adaptor"];
[_window setReleasedWhenClosed:NO];
brws_adaptors = [[NSBrowser alloc] initWithFrame: NSMakeRect(5,30,190,240)];
[brws_adaptors setDelegate: self];
[brws_adaptors addColumn];
[brws_adaptors setTitle: @"Available adaptors" ofColumn: 0];
[brws_adaptors setAllowsEmptySelection: NO];
[brws_adaptors setTarget:self];
[brws_adaptors setDoubleAction:@selector(ok:)];
btn_ok = [[NSButton alloc] initWithFrame: NSMakeRect(5,5,50,20)];
[btn_ok setTitle: @"ok"];
[btn_ok setTarget: self];
[btn_ok setAction: @selector(ok:)];
btn_cancel = [[NSButton alloc] initWithFrame: NSMakeRect(60,5,50,20)];
[btn_cancel setTitle: @"cancel"];
[btn_cancel setTarget: self];
[btn_cancel setAction: @selector(cancel:)];
[[_window contentView] addSubview: brws_adaptors];
[[_window contentView] addSubview: btn_ok];
[[_window contentView] addSubview: btn_cancel];
[_window setInitialFirstResponder:brws_adaptors];
[brws_adaptors setNextResponder:btn_ok];
[btn_ok setNextResponder:btn_cancel];
// hmm.. this seems to cause an infinate loop in the responder chain somehow
// when in the modal loop.
// [btn_cancel setNextResponder:brws_adaptors];
[btn_ok setKeyEquivalent:@"\r"];
[btn_ok setImage:[NSImage imageNamed:@"common_ret"]];
[btn_ok setAlternateImage:[NSImage imageNamed:@"common_retH"]];
[btn_ok setImagePosition:NSImageRight];
[btn_ok sizeToFit];
fr1 = [btn_ok frame];
fr2 = [btn_cancel frame];
fr1.size.width = fr2.size.width = fr1.size.width > fr2.size.width
? fr1.size.width
: fr2.size.width;
fr1.size.height = fr2.size.height = fr1.size.height > fr2.size.height
? fr1.size.height
: fr2.size.height;
fr2.origin.x = NSMaxX(fr1) + 8;
[btn_ok setFrame:fr1];
[btn_cancel setFrame:fr2];
fr2 = [brws_adaptors frame];
fr2.origin.y = NSMaxY(fr1) + 8;
[brws_adaptors setFrame:fr2];
RELEASE(_label);
RELEASE(brws_adaptors);
RELEASE(btn_ok);
RELEASE(btn_cancel);
}
return self;
}
- (NSString *) runAdaptorsPanel
{
NSString *selection;
if ([NSApp runModalForWindow:_window] == NSRunAbortedResponse)
{
selection = nil;
[_window orderOut:self];
}
else
{
selection = [[brws_adaptors selectedCell] stringValue];
[_window orderOut:self];
}
return selection;
}
/* button actions */
- (void) ok: (id)sender
{
[NSApp stopModalWithCode:NSRunStoppedResponse];
}
- (void) cancel: (id)sender
{
[NSApp stopModalWithCode:NSRunAbortedResponse];
}
/* NSBrowser delegate stuff */
- (int) browser:(id)sender numberOfRowsInColumn:(int)column
{
return [_adaptorNames count];
}
- (void)browser:(NSBrowser*)sender
willDisplayCell:(NSBrowserCell*)cell
atRow:(int)row
column:(int)column
{
[cell setLeaf:YES];
[cell setTitle: [_adaptorNames objectAtIndex:row]];
}
@end

674
Apps/EOModelEditor/COPYING Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View file

@ -0,0 +1,49 @@
/**
CodeGenerator.h
Created by David Wetzel on 16.11.2008.
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#import <Cocoa/Cocoa.h>
#import <EOAccess/EOModel.h>
#ifndef CodeGenerator_h
#define CodeGenerator_h
@interface NSString (GeneratorAddtions)
- (NSString *)initialCapitalString;
- (NSString *)initialLowercaseString;
@end
@interface CodeGenerator : NSObject
{
NSString * _generatedClassPath;
NSString * _subclassPath;
NSString * _superclassName;
EOModel * _model;
}
- (void) generate;
@end
#endif

View file

@ -0,0 +1,737 @@
/**
CodeGenerator.m
Created by David Wetzel on 16.11.2008.
This file is part of EOModelEditor.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#import "CodeGenerator.h"
#import <Foundation/NSUserDefaults.h>
#import <EOAccess/EOEntity.h>
#import <EOAccess/EORelationship.h>
#import <EOAccess/EOAttribute.h>
#import <EOModeler/EOModelerApp.h>
#import <EOModeler/EOModelExtensions.h>
#import <AppKit/AppKit.h>
@implementation NSString (GeneratorAddtions)
// those 2 methods are from EOGenerator
/*-
* Copyright (c) 2002-2006 Carl Lindberg and Mike Gentry
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
- (NSString *)initialCapitalString
{
NSRange firstLetterRange;
NSString *firstLetterString;
NSString *restOfString;
if ([self length] == 0) return self;
firstLetterRange = [self rangeOfComposedCharacterSequenceAtIndex:0];
firstLetterString = [[self substringWithRange:firstLetterRange] uppercaseString];
restOfString = [self substringFromIndex:NSMaxRange(firstLetterRange)];
return [firstLetterString stringByAppendingString:restOfString];
}
- (NSString *)initialLowercaseString
{
NSRange firstLetterRange;
NSString *firstLetterString;
NSString *restOfString;
if ([self length] == 0) return self;
firstLetterRange = [self rangeOfComposedCharacterSequenceAtIndex:0];
firstLetterString = [[self substringWithRange:firstLetterRange] lowercaseString];
restOfString = [self substringFromIndex:NSMaxRange(firstLetterRange)];
return [firstLetterString stringByAppendingString:restOfString];
}
@end
@implementation CodeGenerator
- (id) init
{
self = [super init];
// if (self != nil) {
// NSUserDefaults *defs;
//
// defs = [NSUserDefaults standardUserDefaults];
// _generatedClassPath = [defs stringForKey:GENERATED_CLASS_PATH];
// _subclassPath = [defs stringForKey:SUBCLASS_PATH];
// _superclassName = [defs stringForKey:SUPERCLASS_NAME];
//
// }
return self;
}
- (NSString*) copyright
{
return @"";
}
/*
those are NOT added as '@class XXX;' lines to the _MyClass.h EO file.
*/
- (NSSet*) knownBaseClassNames
{
return [NSSet setWithObjects:@"NSArray", @"NSNumber", @"NSDecimalNumber", @"NSCalendarDate",
@"NSData", @"NSString", nil];
}
- (NSMutableString*) interfacePrologueForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSString * copy = [self copyright];
NSString * className = [entity className];
[cs appendFormat:@"// _%@.h\n", className];
if ((copy != nil) && ([copy length])) {
[cs appendString:copy];
}
[cs appendString:@"//\n"];
[cs appendString:@"// Created by EOModelEditor.\n"];
[cs appendFormat:@"// DO NOT EDIT. Make changes to %@.h instead.\n\n", className];
[cs appendFormat:@"#ifndef ___%@_h_\n#define ___%@_h_\n\n", className, className];
[cs appendString:@"#import <EOControl/EOControl.h>\n\n"];
return cs;
}
- (NSMutableString*) superclassPrologueForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSString * copy = [self copyright];
NSString * className = [entity className];
[cs appendFormat:@"// _%@.m\n", className];
if ((copy != nil) && ([copy length])) {
[cs appendString:copy];
}
[cs appendString:@"//\n"];
[cs appendString:@"// Created by EOModelEditor.\n"];
[cs appendFormat:@"// DO NOT EDIT. Make changes to %@.m instead.\n\n", className];
[cs appendFormat:@"#import \"_%@.h\"\n", className];
return cs;
}
- (NSString*) superInterfaceEpilogueForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSString * className = [entity className];
// [cs appendString:@"// \n"];
[cs appendFormat:@"#endif //___%@_h_\n", className];
return cs;
}
- (NSString*) superclassEpilogueForEntity:(EOEntity*) entity
{
return @"@end\n";
}
- (BOOL) updateNeededForFileAtPath:(NSString*) aPath content:(NSString*)aString canOverwrite:(BOOL) overwrite
{
NSFileManager * fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:aPath]) {
NSString * myStr = [NSString stringWithContentsOfFile:aPath
encoding:NSUTF8StringEncoding
error:NULL];
if ([myStr isEqual:aString]) {
return NO;
}
if (overwrite) {
return YES;
}
}
return YES;
}
void addToUsedClasses(NSMutableArray * mutArray,NSSet * knownNames, NSArray * otherArray)
{
NSEnumerator * enumer = [otherArray objectEnumerator];
NSString * className = nil;
id currentObj = nil;
while ((currentObj = [enumer nextObject])) {
if ([currentObj isKindOfClass:[NSString class]]) {
className = currentObj;
} else if ([currentObj isKindOfClass:[EORelationship class]]) {
className = [[(EORelationship*) currentObj destinationEntity] className];
} else if ([currentObj isKindOfClass:[EOAttribute class]]) {
className = [(EOAttribute*) currentObj valueClassName];
}
if ((className) && ((([mutArray containsObject:className] == NO)) && ((!knownNames) || (([knownNames containsObject:className] == NO))))) {
[mutArray addObject:className];
}
}
}
- (NSString*) classDummysForEntity:(EOEntity*) entity
{
NSSet * knownNames = [self knownBaseClassNames];
NSMutableString * ms = [NSMutableString string];
NSEnumerator * enumer = nil;
NSString * className = nil;
NSArray * classNonScalarAttributes = [[entity classNonScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToOneRelationships = [[entity classToOneRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToManyRelationships = [[entity classToManyRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSMutableArray * mutArray = [NSMutableArray array];
addToUsedClasses(mutArray, knownNames, classNonScalarAttributes);
addToUsedClasses(mutArray, knownNames, classToOneRelationships);
addToUsedClasses(mutArray, knownNames, classToManyRelationships);
enumer = [mutArray objectEnumerator];
while ((className = [enumer nextObject])) {
[ms appendFormat:@"@class %@;\n", className];
}
[ms appendFormat:@"\n"];
return ms;
}
- (NSString*) superIncludesForEntity:(EOEntity*) entity
{
NSSet * knownNames = [self knownBaseClassNames];
NSMutableString * ms = [NSMutableString string];
NSEnumerator * enumer = nil;
NSString * className = nil;
NSArray * classNonScalarAttributes = [[entity classNonScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToOneRelationships = [[entity classToOneRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToManyRelationships = [[entity classToManyRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSMutableArray * mutArray = [NSMutableArray array];
addToUsedClasses(mutArray, knownNames, classNonScalarAttributes);
addToUsedClasses(mutArray, knownNames, classToOneRelationships);
addToUsedClasses(mutArray, knownNames, classToManyRelationships);
enumer = [mutArray objectEnumerator];
while ((className = [enumer nextObject])) {
[ms appendFormat:@"#import \"%@.h\"\n", className];
}
[ms appendFormat:@"\n"];
return ms;
}
- (NSString*) superInterfaceForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSArray * classScalarAttributes = [[entity classScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classNonScalarAttributes = [[entity classNonScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToOneRelationships = [[entity classToOneRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToManyRelationships = [[entity classToManyRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
EOAttribute * eoAttr = nil;
EORelationship * eoRel = nil;
NSEnumerator * enumer = [classScalarAttributes objectEnumerator];
NSString * className = [entity className];
[cs appendString:[self classDummysForEntity:entity]];
[cs appendFormat:@"@interface _%@ : EOCustomObject <NSCoding>\n{\n", className];
while ((eoAttr = [enumer nextObject])) {
[cs appendFormat:@" %@ _%@;\n", [eoAttr cScalarTypeString], [eoAttr name]];
}
enumer = [classNonScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
[cs appendFormat:@" %@ *_%@;\n", [eoAttr valueClassName], [eoAttr name]];
}
enumer = [classToOneRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[cs appendFormat:@" %@ *_%@;\n", [[eoRel destinationEntity] className], [eoRel name]];
}
enumer = [classToManyRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[cs appendFormat:@" %@ *_%@s;\n", [[eoRel destinationEntity] className], [eoRel name]];
}
[cs appendFormat:@"}\n\n"];
enumer = [classScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
[cs appendFormat:@"- (void) set%@:(%@) aValue;\n", [[eoAttr name] initialCapitalString],
[eoAttr cScalarTypeString]];
[cs appendFormat:@"- (%@) %@;\n\n", [eoAttr cScalarTypeString], [eoAttr name]];
}
enumer = [classNonScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
[cs appendFormat:@"- (void) set%@:(%@ *) aValue;\n", [[eoAttr name] initialCapitalString],
[eoAttr valueClassName]];
[cs appendFormat:@"- (%@ *) %@;\n\n", [eoAttr valueClassName], [eoAttr name]];
}
enumer = [classToOneRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[cs appendFormat:@"- (void) set%@:(%@ *) aValue;\n", [[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className]];
[cs appendFormat:@"- (%@ *) %@;\n\n", [[eoRel destinationEntity] className], [eoRel name]];
}
enumer = [classToManyRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[cs appendFormat:@"- (NSArray *) %@;\n\n", [eoRel name]];
[cs appendFormat:@"- (void) addTo%@:(%@ *) aValue;\n", [[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className]];
[cs appendFormat:@"- (void) removeFrom%@:(%@ *) aValue;\n", [[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className]];
}
[cs appendFormat:@"@end\n\n"];
return cs;
}
- (NSArray*) retainableAttributesInEntity:(EOEntity*) entity
{
NSArray * classNonScalarAttributes = [[entity classNonScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToOneRelationships = [[entity classToOneRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToManyRelationships = [[entity classToManyRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSMutableArray * mutArray = [NSMutableArray array];
NSEnumerator * enumer;
EORelationship * eoRel;
EOAttribute * eoAttr;
enumer = [classNonScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
[mutArray addObject:[[eoAttr name] initialLowercaseString]];
}
enumer = [classToOneRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[mutArray addObject:[[eoRel name] initialLowercaseString]];
}
enumer = [classToManyRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
[mutArray addObject:[[eoRel name] initialLowercaseString]];
}
return mutArray;
}
- (NSString*) deallocForAttributes:(NSArray*) attrs
{
NSMutableString * cs = [NSMutableString string];
NSEnumerator * enumer = [attrs objectEnumerator];
NSString * anIvar = nil;
[cs appendFormat:@"\n- (void) dealloc\n{\n"];
while ((anIvar = [enumer nextObject])) {
[cs appendFormat:@" [_%@ release];\n", anIvar];
}
[cs appendFormat:@"\n [super dealloc];\n}\n\n"];
return cs;
}
- (NSString*) superclassGettersAndSettersForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSArray * classScalarAttributes = [[entity classScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classNonScalarAttributes = [[entity classNonScalarAttributes]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToOneRelationships = [[entity classToOneRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
NSArray * classToManyRelationships = [[entity classToManyRelationships]
sortedArrayUsingSelector:@selector(eoCompareOnName:)];
EOAttribute * eoAttr = nil;
EORelationship * eoRel = nil;
NSEnumerator * enumer = [classScalarAttributes objectEnumerator];
enumer = [classScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
NSString * lowStr = [[eoAttr name] initialLowercaseString];
[cs appendFormat:@"- (void) set%@:(%@) aValue\n{\n if ((_%@ == aValue)) {\n return;\n }\n\n",
[[eoAttr name] initialCapitalString],
[eoAttr cScalarTypeString], lowStr];
[cs appendFormat:@" [self willChange];\n _%@ = aValue;\n}\n\n",
lowStr];
[cs appendFormat:@"- (%@) %@\n{\n return _%@;\n}\n\n", [eoAttr cScalarTypeString], [eoAttr name], lowStr];
}
enumer = [classNonScalarAttributes objectEnumerator];
while ((eoAttr = [enumer nextObject])) {
NSString * lowStr = [[eoAttr name] initialLowercaseString];
[cs appendFormat:@"- (void) set%@:(%@ *) aValue\n{\n if ((_%@ == aValue)) {\n return;\n }\n\n",
[[eoAttr name] initialCapitalString],
[eoAttr valueClassName], lowStr];
[cs appendFormat:@" [self willChange];\n ASSIGN(_%@, aValue);\n}\n\n",
lowStr, lowStr];
[cs appendFormat:@"- (%@ *) %@\n{\n return _%@;\n}\n\n", [eoAttr valueClassName], [eoAttr name], lowStr];
}
if ([classToOneRelationships count]) {
[cs appendString:@"// to-one relationships\n\n"];
}
enumer = [classToOneRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
NSString * lowStr = [[eoRel name] initialLowercaseString];
[cs appendFormat:@"- (void) set%@:(%@ *) aValue\n{\n if ((_%@ == aValue)) {\n return;\n }\n\n",
[[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className], lowStr];
[cs appendFormat:@" [self willChange];\n ASSIGN(_%@, aValue);\n}\n\n",
lowStr, lowStr];
[cs appendFormat:@"- (%@ *)%@\n{\n return _%@;\n}\n\n", [[eoRel destinationEntity] className], [eoRel name], lowStr];
}
enumer = [classToManyRelationships objectEnumerator];
while ((eoRel = [enumer nextObject])) {
NSString * lowStr = [[eoRel name] initialLowercaseString];
[cs appendFormat:@"- (NSArray *) %@\n{\n",
[eoRel name]];
[cs appendFormat:@" return _%@;\n}\n\n",
lowStr];
[cs appendFormat:@"- (void) addTo%@:(%@ *) aValue\n{\n", [[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className]];
[cs appendFormat:@" [self willChange];\n [_%@ addObject:aValue];\n}\n\n",
lowStr];
[cs appendFormat:@"- (void) removeFrom%@:(%@ *) aValue\n{\n", [[eoRel name] initialCapitalString],
[[eoRel destinationEntity] className]];
[cs appendFormat:@" [self willChange];\n [_%@ removeObject:aValue];\n}\n\n",
lowStr];
}
return cs;
}
- (NSString*) superclassForEntity:(EOEntity*) entity
{
NSMutableString * cs = [NSMutableString string];
NSString * className = [entity className];
NSArray * retainableAttrs = [self retainableAttributesInEntity:entity];
[cs appendFormat:@"@implementation _%@\n", className];
[cs appendString:[self deallocForAttributes:retainableAttrs]];
[cs appendString:[self superclassGettersAndSettersForEntity:entity]];
return cs;
}
- (void) generateSuperInterfaceFileForEntity:(EOEntity*) entity
{
NSMutableString * codeString = [self interfacePrologueForEntity:entity];
NSString * path = _generatedClassPath;
NSString * className = [entity className];
NSString * currentPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"_%@.h",
className]];
[codeString appendString:[self superInterfaceForEntity:entity]];
[codeString appendString:[self superInterfaceEpilogueForEntity:entity]];
if ([self updateNeededForFileAtPath:currentPath
content:codeString
canOverwrite:YES]) {
[codeString writeToFile:currentPath
atomically:NO
encoding:NSUTF8StringEncoding
error:NULL];
}
}
- (void) generateSubInterfaceFileForEntity:(EOEntity*) entity
{
NSMutableString * codeString = [NSMutableString string];
NSString * path = _subclassPath;
NSString * className = [entity className];
NSString * currentPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.h",
className]];
[codeString appendFormat:@"// %@.h\n\n", className];
[codeString appendFormat:@"#ifndef __%@_h_\n#define __%@_h_\n\n", className, className];
[codeString appendFormat:@"#import \"_%@.h\"\n\n", className];
[codeString appendFormat:@"@interface %@: _%@\n", className, className];
[codeString appendString:@"{\n // Custom instance variables go here\n}\n\n"];
[codeString appendString:@"// Business logic methods go here\n\n@end\n"];
[codeString appendFormat:@"\n#endif //__%@_h_\n", className];
if ([self updateNeededForFileAtPath:currentPath
content:codeString
canOverwrite:NO]) {
[codeString writeToFile:currentPath
atomically:NO
encoding:NSUTF8StringEncoding
error:NULL];
}
}
- (void) generateSuperclassFileForEntity:(EOEntity*) entity
{
NSMutableString * codeString = [self superclassPrologueForEntity:entity];
NSString * path = _generatedClassPath;
NSString * className = [entity className];
NSString * currentPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"_%@.m",
className]];
[codeString appendString:[self superIncludesForEntity:entity]];
[codeString appendString:[self superclassForEntity:entity]];
[codeString appendString:[self superclassEpilogueForEntity:entity]];
if ([self updateNeededForFileAtPath:currentPath
content:codeString
canOverwrite:YES]) {
[codeString writeToFile:currentPath
atomically:NO
encoding:NSUTF8StringEncoding
error:NULL];
}
}
- (void) generateSubclassFileForEntity:(EOEntity*) entity
{
NSMutableString * codeString = [NSMutableString string];
NSString * path = _subclassPath;
NSString * className = [entity className];
NSString * currentPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.m",
className]];
[codeString appendFormat:@"// %@.m\n\n#import \"%@.h\"\n\n", className, className];
[codeString appendFormat:@"@implementation %@\n\n", className];
[codeString appendString:@"- (void)dealloc\n{\n [super dealloc];\n}\n\n"];
[codeString appendString:@"// Business logic methods go here\n\n@end\n"];
if ([self updateNeededForFileAtPath:currentPath
content:codeString
canOverwrite:NO]) {
[codeString writeToFile:currentPath
atomically:NO
encoding:NSUTF8StringEncoding
error:NULL];
}
}
- (BOOL) getPaths
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
BOOL ok = NO;
[panel setTitle:@"Select path for super classes"];
[panel setCanCreateDirectories:YES];
[panel setCanChooseFiles:NO];
[panel setCanChooseDirectories:YES];
if ([panel runModal] == NSOKButton)
{
NSURL * url = [panel directoryURL];
[_generatedClassPath release];
_generatedClassPath = [[url path] retain];
[panel setTitle:@"Select path for sub classes"];
if ([panel runModal] == NSOKButton)
{
NSURL * suburl = [panel directoryURL];
[_subclassPath release];
_subclassPath = [[suburl path] retain];
ok = YES;
}
}
return ok;
}
- (void) generate
{
NSEnumerator * entityEnumer = nil;
EOEntity * currentEntity = nil;
_model = [[[NSDocumentController sharedDocumentController] currentDocument] eomodel];
if (!_model) {
return;
}
if ([self getPaths]) {
entityEnumer = [[_model entities] objectEnumerator];
while ((currentEntity = [entityEnumer nextObject])) {
[self generateSuperInterfaceFileForEntity:currentEntity];
[self generateSuperclassFileForEntity:currentEntity];
[self generateSubInterfaceFileForEntity:currentEntity];
[self generateSubclassFileForEntity:currentEntity];
}
}
}
- (void) dealloc
{
[_generatedClassPath release];
[_subclassPath release];
//[_superclassName release];
//[_model release];
[super dealloc];
}
@end

View file

@ -0,0 +1,35 @@
/**
ConsistencyChecker.h
Author: Matt Rice <ratmice@gmail.com>
Date: Jul 2005
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSObject.h>
#endif
@class NSNotification;
@interface ConsistencyChecker : NSObject
@end

View file

@ -0,0 +1,437 @@
/**
ConsistencyChecker.m
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include "ConsistencyChecker.h"
#include "Preferences.h"
#include <EOModeler/EOModelExtensions.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EORelationship.h>
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSNotification.h>
#endif
#import "EOMEDocument.h"
#define MY_PRETTY NSMutableAttributedString \
mutableAttributedStringWithBoldSubstitutionsWithFormat
static NSMutableArray *successText;
static EOMEDocument *doc;
@implementation ConsistencyChecker
+(void) initialize
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(beginConsistencyCheck:)
name:EOMCheckConsistencyBeginNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(endConsistencyCheck:)
name:EOMCheckConsistencyEndNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(modelConsistencyCheck:)
name:EOMCheckConsistencyForModelNotification
object:nil];
successText = [[NSMutableArray alloc] initWithCapacity:8];
}
+ (void) beginConsistencyCheck:(NSNotification *)notif
{
}
+ (void) endConsistencyCheck:(NSNotification *)notif
{
unsigned i,c;
doc = [notif object];
for (i = 0, c = [successText count]; i < c; i++)
{
[doc appendConsistencyCheckSuccessText:[successText objectAtIndex:i]];
}
doc = nil;
[successText removeAllObjects];
}
/* helper functions */
static void pass(BOOL flag, NSAttributedString *as)
{
if (flag)
{
[successText addObject:as];
}
else
[doc appendConsistencyCheckErrorText: as];
}
static BOOL isInvalid(NSString *str)
{
return (str == nil) || ([str length] == 0) ? YES : NO;
}
+ (void) attributeDetailsCheckForModel:(EOModel *)model
{
NSArray *ents = [model entities];
unsigned i, c;
BOOL flag = YES;
for (i = 0, c = [ents count]; i < c; i++)
{
EOEntity *entity = [ents objectAtIndex:i];
NSArray *arr = [entity attributes];
unsigned j, d;
for (j = 0, d = [arr count]; j < d; j++)
{
EOAttribute *attrib = [arr objectAtIndex:j];
NSString *className = [attrib valueClassName];
if ([[attrib className] isEqualToString:@"NSNumber"])
{
if (isInvalid([attrib externalType]))
{
pass(NO,[MY_PRETTY: @"Fail: %@ of type 'NSNumber has no external type\n",[(EOAttribute *)attrib name]]);
flag = NO;
}
}
/* TODO check whether NSCalendarDate/NSData require valueFactory...*/
if ((!isInvalid(className))
&& (![className isEqual:@"NSString"]
&& ![className isEqual:@"NSNumber"]
&& ![className isEqual:@"NSDecimalNumber"]
&& ![className isEqual:@"NSDate"]
&& ![className isEqual:@"NSData"])
&& (isInvalid([attrib valueFactoryMethodName])))
{
pass(NO,[MY_PRETTY: @"Fail: attribute '%@' of type '%@' requires a value factory method name\n",[(EOAttribute *)attrib name], className]);
flag = NO;
}
}
/* relationship primary key propagation */
arr = [entity relationships];
for (j = 0, d = [arr count]; j < d; j++)
{
EORelationship *rel = [arr objectAtIndex:j];
if ([rel propagatesPrimaryKey] == YES)
{
NSArray *attribs = [rel sourceAttributes];
NSArray *pkAttribs = [[rel entity] primaryKeyAttributes];
unsigned k, e;
id pkey;
BOOL ok = YES;
for (k = 0, e = [pkAttribs count]; ok == YES && k < e; k++)
{
pkey = [pkAttribs objectAtIndex:k];
ok = [attribs containsObject:pkey];
}
if (ok == NO)
{
pass(NO,[MY_PRETTY: @"Fail: relationship '%@' propagates primary key but its source attributes does not contain the source entity's primary key attributes\n",[(EORelationship *)rel name]]);
flag = NO;
}
ok = YES;
attribs = [rel destinationAttributes];
pkAttribs = [[rel destinationEntity] primaryKeyAttributes];
for (k = 0, e = [pkAttribs count]; ok == YES && k < e; k++)
{
pkey = [pkAttribs objectAtIndex:k];
ok = [attribs containsObject:pkey];
}
if (ok == NO)
{
pass(NO, [MY_PRETTY: @"Fail: relationship '%@' propagates primary key but its destination attributes does not contain the destination entity's primary key attributes\n",[(EORelationship *)rel name]]);
flag = NO;
}
}
}
}
if (flag == YES)
pass(YES, [MY_PRETTY: @"Success: attribute detail check\n"]);
}
+ (void) entityStoredProcedureCheckForModel:(EOModel *)model
{
/* TODO */
}
+ (void) storedProcedureCheckForModel:(EOModel *)model
{
/* TODO */
}
+ (void) inheritanceCheckForModel:(EOModel *)model
{
BOOL flag = YES;
NSArray *ents = [model entities];
unsigned i,c;
for (i = 0, c = [ents count]; i < c; i++)
{
EOEntity *ent = [ents objectAtIndex:i];
NSArray *subEnts = [ent subEntities];
unsigned j, d;
for (j = 0, d = [subEnts count]; j < d; j++)
{
EOEntity *subEnt = [subEnts objectAtIndex:j];
NSArray *arr = [ent attributes];
NSArray *subArr = [subEnt attributes];
unsigned k, e;
for (k = 0, e = [arr count]; k < e; k++)
{
EOAttribute *attrib = [arr objectAtIndex:k];
if (![subArr containsObject:[(EOAttribute *)attrib name]])
{
pass(NO, [MY_PRETTY: @"FAIL: sub entity '%@' missing parent's '%@' attribute",[(EOEntity *)subEnt name], [(EOAttribute *)attrib name]]);
flag = NO;
}
}
arr = [ent relationships];
for (k = 0, e = [arr count]; k < e; k++)
{
EORelationship *rel = [arr objectAtIndex:k];
EORelationship *subRel = [subEnt relationshipNamed:[(EORelationship *)rel name]];
if (!subRel || ![[rel definition] isEqual:[subRel definition]])
{
pass(NO, [MY_PRETTY: @"FAIL: sub entity '%@' missing relationship '%@' or definitions do not match", [(EOEntity *)subEnt name], [(EORelationship *)rel name]]);
flag = NO;
}
}
arr = [ent primaryKeyAttributes];
subArr = [subEnt primaryKeyAttributes];
if (![arr isEqual:subArr])
{
pass(NO, [MY_PRETTY: @"FAIL: sub entity '%@' and parent entities primary keys do not match", [(EOEntity *)subEnt name]]);
flag = NO;
}
if ([[subEnt externalName] isEqual:[ent externalName]]
&& (![subEnt restrictingQualifier] || ![ent restrictingQualifier]))
{
pass(NO, [MY_PRETTY: @"FAIL: sub entity '%@' and parent entity in same table must contain a restricting qualifier", [(EOEntity *)subEnt name]]);
flag = NO;
}
}
}
if (flag == YES)
{
pass(YES, [MY_PRETTY: @"Success: inheritance check"]);
}
}
+ (void) relationshipCheckForModel:(EOModel *)model
{
/* TODO */
NSArray *ents = [model entities];
unsigned i, c;
BOOL flag = YES;
for (i = 0, c = [ents count]; i < c; i++)
{
EOEntity *ent = [ents objectAtIndex:i];
NSArray *arr = [ent relationships];
unsigned j, d;
for (j = 0, d = [arr count]; j < d; j++)
{
id rel = [arr objectAtIndex:j];
if (![[rel joins] count])
{
pass(NO,[MY_PRETTY: @"Fail: relationship '%@' does not contain a join\n", [(EORelationship *)rel name]]);
flag = NO;
}
if ([rel isToMany] == NO)
{
NSArray *pkAttribs = [[rel destinationEntity] primaryKeyAttributes];
NSArray *attribs = [rel destinationAttributes];
if (![pkAttribs isEqual:attribs])
{
pass(NO, [MY_PRETTY: @"Fail: destination attributes of relationship '%@' are not the destination entity primary keys\n",[(EORelationship *)rel name]]);
flag = NO;
}
}
if ([rel propagatesPrimaryKey])
{
NSArray *pkAttribs = [[rel entity] primaryKeyAttributes];
NSArray *attribs = [rel sourceAttributes];
unsigned k, e;
BOOL ok = YES;
for (k = 0, e = [pkAttribs count]; ok == YES && k < e; k++)
{
ok = [attribs containsObject: [pkAttribs objectAtIndex:k]];
}
if (ok == NO)
{
pass(NO, [MY_PRETTY: @"Fail: relationship '%@' propagates primary keys but does not contain source entities primary key attributes\n", [(EORelationship *)rel name]]);
flag = NO;
}
pkAttribs = [[rel destinationEntity] primaryKeyAttributes];
attribs = [rel destinationAttributes];
for (k = 0, e = [pkAttribs count]; ok == YES && k < e; k++)
{
ok = [attribs containsObject: [pkAttribs objectAtIndex:k]];
}
if (ok == NO)
{
pass(NO, [MY_PRETTY: @"Fail: relationship '%@' propagates primary keys but does not contain destination entities primary key attributes\n", [(EORelationship *)rel name]]);
flag = NO;
}
if ([[rel inverseRelationship] propagatesPrimaryKey])
{
pass(NO,[MY_PRETTY: @"Fail: both relationship '%@' and inverse relationship '%@' should not propagate primary keys\n", [(EORelationship *)rel name], [(EORelationship *)[rel inverseRelationship] name]]);
flag = NO;
}
}
}
}
if (flag == YES)
pass(YES, [MY_PRETTY: @"Success: relationship check\n"]);
}
+ (void) primaryKeyCheckForModel:(EOModel *)model
{
NSArray *ents = [model entities];
unsigned i,c;
BOOL flag = YES;
for (i = 0, c = [ents count]; i < c; i++)
{
EOEntity *entity = [ents objectAtIndex:i];
NSArray *arr = [entity primaryKeyAttributes];
if (![arr count])
{
pass(NO,[MY_PRETTY: @"Fail: Entity '%@' does not have a primary key.\n", [(EOEntity *)entity name]]);
flag = NO;
}
}
if (flag == YES)
pass(YES, [MY_PRETTY:@"Success: primary key check\n"]);
}
+ (void) externalNameCheckForModel:(EOModel *)model
{
NSArray *ents = [model entities];
NSArray *arr;
unsigned i, c, j, d;
BOOL flag = YES;
for (i = 0,c = [ents count]; i < c; i++)
{
EOEntity *entity = [ents objectAtIndex:i];
NSString *extName = [entity externalName];
if (isInvalid(extName))
{
pass(NO,[MY_PRETTY: @"Fail: Entity '%@' does not have an external name\n",
[(EOEntity *)entity name]]);
flag = NO;
}
arr = [entity attributes];
for (j = 0, d = [arr count]; j<d; j++)
{
EOAttribute *attrib = [arr objectAtIndex:j];
extName = [attrib columnName];
if (isInvalid(extName))
{
pass(NO,[MY_PRETTY: @"Fail: Attribute '%@' does not have an external name\n",
[(EOAttribute *)attrib name]]);
flag = NO;
}
extName = [attrib valueClassName];
if (isInvalid(extName))
{
pass(NO,[MY_PRETTY: @"Fail: Attribute '%@' does not have a value class name\n", [(EOAttribute *)attrib name]]);
flag = NO;
}
}
}
if (flag == YES)
pass(YES, [MY_PRETTY: @"Success: external name check\n"]);
}
+ (void) modelConsistencyCheck:(NSNotification *)notif
{
EOModel *model = [[notif userInfo] objectForKey:EOMConsistencyModelObjectKey];
doc = [notif object];
if ([[DBModelerPrefs sharedPreferences] attributeDetailsCheck])
[self attributeDetailsCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] primaryKeyCheck])
[self primaryKeyCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] externalNameCheck])
[self externalNameCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] relationshipCheck])
[self relationshipCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] inheritanceCheck])
[self inheritanceCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] storedProcedureCheck])
[self storedProcedureCheckForModel:model];
if ([[DBModelerPrefs sharedPreferences] entityStoredProcedureCheck])
[self entityStoredProcedureCheckForModel:model];
doc = nil;
}
@end

View file

@ -0,0 +1,53 @@
/**
ConsistencyResults.h
Author: Matt Rice <ratmice@gmail.com>
Date: Jul 2005
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSObject.h>
#endif
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSNibDeclarations.h>
#endif
@class NSPanel;
@class NSButton;
@class NSTextView;
@interface ConsistencyResults : NSObject
{
IBOutlet NSPanel *_panel;
IBOutlet NSButton *okButton;
IBOutlet NSButton *cancelButton;
IBOutlet NSTextView *results;
BOOL successful;
}
+ (id) sharedConsistencyPanel;
- (int) showConsistencyCheckResults:(id)sender cancelButton:(BOOL)useCancel
showOnSuccess:(BOOL)flag;
@end

View file

@ -0,0 +1,104 @@
/**
ConsistencyResults.m
Author: Matt Rice <ratmice@gmail.com>
Date: Jul 2005
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include <ConsistencyResults.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSApplication.h>
#include <AppKit/NSButton.h>
#include <AppKit/NSNibLoading.h>
#include <AppKit/NSPanel.h>
#include <AppKit/NSTextView.h>
#include <AppKit/NSTextStorage.h>
#endif
#include <Renaissance/Renaissance.h>
static ConsistencyResults *_sharedResults;
@implementation ConsistencyResults
+ (id) sharedConsistencyPanel;
{
if (!_sharedResults)
_sharedResults = [[self allocWithZone:NSDefaultMallocZone()] init];
return _sharedResults;
}
- (id) init
{
self = [super init];
[NSBundle loadGSMarkupNamed:@"ConsistencyResults" owner:self];
successful = YES;
return self;
}
- (int) showConsistencyCheckResults:(id)sender cancelButton:(BOOL)useCancel
showOnSuccess:(BOOL)flag
{
int foo = NSRunStoppedResponse;
[cancelButton setEnabled:useCancel];
if (!flag && successful)
{
}
else
{
foo = [NSApp runModalForWindow:_panel];
}
/* reset this.. */
successful = YES;
return foo;
}
- (void) appendConsistencyCheckErrorText:(NSAttributedString *)errorText
{
successful = NO;
[[results textStorage] appendAttributedString:errorText];
}
- (void) appendConsistencyCheckSuccessText:(NSAttributedString *)successText
{
[[results textStorage] appendAttributedString:successText];
}
- (void) cancel:(id)sender
{
[NSApp abortModal];
[_panel orderOut:self];
[results setString:@""];
}
- (void) ok:(id)sender
{
[NSApp stopModal];
[_panel orderOut:self];
[results setString:@""];
}
@end

View file

@ -0,0 +1,54 @@
/**
DataBrowser.h <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifndef __DataBrowser_h
#define __DataBrowser_h
#import <AppKit/AppKit.h>
#import <EOAccess/EOAccess.h>
@class TableViewController;
@class EOEditingContext;
@interface DataBrowser : NSObject
{
IBOutlet NSWindow * _window;
IBOutlet NSTextField * _entityNameField;
IBOutlet NSTextField * _fetchLimitText;
IBOutlet NSTextField * _qualifierText;
IBOutlet NSTableView * _tableView;
EOEntity * _currentEntity;
TableViewController *_tableViewController;
EOEditingContext *_editingContext;
}
+ (DataBrowser *) sharedBrowser;
- (void) setEntity:(EOEntity*) aValue;
@end
#endif

View file

@ -0,0 +1,198 @@
/**
DataBrowser.h <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#import "DataBrowser.h"
#import <Renaissance/Renaissance.h>
#import "TableViewController.h"
#import <EOContol/EOContol.h>
static DataBrowser *sharedDataBrowser = nil;
@implementation DataBrowser
- (NSWindow*) _window
{
return _window;
}
+ (DataBrowser *) sharedBrowser;
{
if (!sharedDataBrowser)
sharedDataBrowser = [[self alloc] init];
[[sharedDataBrowser _window] makeKeyAndOrderFront:nil];
return sharedDataBrowser;
}
- (id) init
{
if (sharedDataBrowser)
{
[[NSException exceptionWithName:NSInternalInconsistencyException
reason: @"singleton initialized multiple times"
userInfo:nil] raise];
return nil;
}
self = [super init];
[NSBundle loadGSMarkupNamed: @"DataBrowser" owner: self];
[_window setFrameUsingName:NSStringFromClass([self class])];
_tableViewController = [TableViewController new];
[_tableView setDataSource:_tableViewController];
[_tableView setDelegate:_tableViewController];
return self;
}
- (void) removeTableColumns
{
NSArray * columns = [_tableView tableColumns];
NSEnumerator * colEnumer = [[NSArray arrayWithArray:columns] objectEnumerator];
NSTableColumn * column;
while ((column = [colEnumer nextObject])) {
if ([[column identifier] isEqual:@"_#number"] == NO) {
[_tableView removeTableColumn:column];
}
}
}
- (void) setEntity:(EOEntity*) aValue
{
ASSIGN(_currentEntity, aValue);
if (_currentEntity) {
NSEnumerator * attributeEnumer = [[_currentEntity attributes] objectEnumerator];
EOAttribute * currentAttribute = nil;
[_tableViewController setRepresentedObject:[NSArray array]];
[_tableView reloadData];
[self removeTableColumns];
[_entityNameField setStringValue:[_currentEntity name]];
while ((currentAttribute = [attributeEnumer nextObject])) {
NSString * attributeName = [currentAttribute name];
NSTableColumn * column = [[NSTableColumn alloc] initWithIdentifier:attributeName];
[[column headerCell] setStringValue:attributeName];
[column setEditable:NO];
[_tableView addTableColumn:column];
RELEASE(column);
}
}
}
- (void) dealloc
{
sharedDataBrowser = nil;
DESTROY(_tableViewController);
DESTROY(_currentEntity);
DESTROY(_editingContext);
[super dealloc];
}
- (void) awakeFromGSMarkup
{
}
- (IBAction) fetch:(id) sender
{
EOFetchSpecification *fetchSpec;
EOQualifier *qual = nil;
NSArray *results;
NSMutableArray *keyPaths = [NSMutableArray array];
NSEnumerator *attributeEnumer = [[_currentEntity attributes] objectEnumerator];
EOAttribute *attribute;
while ((attribute = [attributeEnumer nextObject])) {
[keyPaths addObject:[attribute name]];
}
[[EOModelGroup defaultGroup] addModel:[_currentEntity model]];
NS_DURING {
if (!_editingContext) {
ASSIGN(_editingContext, [EOEditingContext new]);
RELEASE(_editingContext);
[_editingContext setInvalidatesObjectsWhenFreed:YES];
} else {
[_editingContext invalidateAllObjects];
}
fetchSpec = [EOFetchSpecification fetchSpecificationWithEntityName:[_currentEntity name]
qualifier:qual
sortOrderings:nil];
[fetchSpec setRawRowKeyPaths:keyPaths];
results = [_editingContext objectsWithFetchSpecification:fetchSpec];
[_tableViewController setRepresentedObject:results];
[_tableView reloadData];
} NS_HANDLER {
NSRunCriticalAlertPanel (@"Problem fetching from Database",
@"%@",
@"Ok",
nil,
nil,
localException);
} NS_ENDHANDLER;
[[EOModelGroup defaultGroup] removeModel:[_currentEntity model]];
}
- (BOOL)windowShouldClose:(id)sender
{
[_window endEditingFor:self];
[_window saveFrameUsingName:NSStringFromClass([self class])];
[_window setDelegate:nil];
[_window orderOut:self];
[self performSelector:@selector(release) withObject:self afterDelay:0.001];
return YES;
}
@end

View file

@ -0,0 +1,36 @@
#ifndef __EOAdditions_H_
#define __EOAdditions_H_
/*
EOAdditions.h
Author: Matt Rice <ratmice@gmail.com>
Date: Apr 2005
This file is part of DBModeler.
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOAccess/EOAttribute.h>
/* these use NSNumbers because they are used in key value coding. */
@interface EOAttribute (ModelerAdditions)
- (NSNumber *) isPrimaryKey;
- (void) setIsPrimaryKey:(NSNumber *)flag;
- (NSNumber *) isClassProperty;
- (void) setIsClassProperty:(NSNumber *)flag;
@end
#endif // __EOAdditions_H_

View file

@ -0,0 +1,190 @@
/**
EOAdditions.m
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSArray.h>
#include <Foundation/NSValue.h>
#endif
#include <GNUstepBase/GNUstep.h>
/* this is all stuff for key value coding.. */
static inline NSNumber * isClassProperty(id self)
{
return [NSNumber numberWithBool:
[[[self entity] classProperties] containsObject:self]];
}
static inline void setIsClassProperty(id self, NSNumber *flag)
{
BOOL isProp = [flag boolValue];
NSArray *props = [[self entity] classProperties];
if (isProp)
{
if (!props)
{
if (![[self entity] setClassProperties: [NSArray arrayWithObject:self]])
NSLog(@"invalid class property");
}
else if (![props containsObject:self])
{
[[self entity] setClassProperties: [props arrayByAddingObject:self]];
}
}
else
{
if ([props containsObject:self])
{
NSMutableArray *newProps = [NSMutableArray arrayWithArray:props];
[newProps removeObject: self];
[[self entity] setClassProperties: newProps];
}
}
}
@implementation EOAttribute (ModelerAdditions)
- (NSNumber *) isPrimaryKey
{
BOOL flag = [[[self entity] primaryKeyAttributes] containsObject:self];
return [NSNumber numberWithBool: flag];
}
- (void) setIsPrimaryKey:(NSNumber *)flag
{
BOOL isKey = [flag boolValue];
NSArray *pka = [[self entity] primaryKeyAttributes];
if (isKey)
{
if (!pka)
{
[[self entity]
setPrimaryKeyAttributes: [NSArray arrayWithObject:self]];
}
else if (![pka containsObject:self])
{
[[self entity]
setPrimaryKeyAttributes: [pka arrayByAddingObject:self]];
}
}
else
{
if ([pka containsObject:self])
{
NSMutableArray *newPks = [NSMutableArray arrayWithArray:pka];
[newPks removeObject: self];
[[self entity] setPrimaryKeyAttributes: newPks];
}
}
}
- (NSNumber *) isClassProperty
{
id flag = isClassProperty(self);
return flag;
}
- (void) setIsClassProperty:(NSNumber *)flag
{
setIsClassProperty(self, flag);
}
- (NSNumber *) isUsedForLocking
{
BOOL flag;
flag = [[[self entity] attributesUsedForLocking] containsObject:self];
return [NSNumber numberWithBool:flag];
}
- (void) setIsUsedForLocking:(NSNumber *)flag
{
BOOL yn = [flag boolValue];
NSArray *la = RETAIN([[self entity] attributesUsedForLocking]);
if (yn)
{
if (la == nil)
{
[[self entity]
setAttributesUsedForLocking:[NSArray arrayWithObject:self]];
}
else if (![la containsObject:self])
{
[[self entity]
setAttributesUsedForLocking:[la arrayByAddingObject:self]];
}
}
else
{
if ([la containsObject:self])
{
NSMutableArray *newLA = [NSMutableArray arrayWithArray:la];
[newLA removeObject:self];
[[self entity] setAttributesUsedForLocking:newLA];
}
}
}
- (NSNumber *)allowNull
{
BOOL flag = [self allowsNull];
return [NSNumber numberWithBool:flag];
}
- (void) setAllowNull:(NSNumber *)flag
{
[self setAllowsNull:[flag boolValue]];
}
@end
@implementation EORelationship (ModelerAdditions)
- (NSNumber *) isClassProperty
{
id flag = isClassProperty(self);
return flag;
}
- (void) setIsClassProperty:(NSNumber *)flag
{
setIsClassProperty(self, flag);
}
@end

View file

@ -0,0 +1,74 @@
/**
EOMEDocument.h <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of DBModeler.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifndef __EOMEDocument_h
#define __EOMEDocument_h
#include <AppKit/NSDocument.h>
#include <Renaissance/Renaissance.h>
#include <EOAccess/EOModel.h>
#include <EOModeler/EODefines.h>
GDL2MODELER_EXPORT NSString *EOMCheckConsistencyBeginNotification;
GDL2MODELER_EXPORT NSString *EOMCheckConsistencyEndNotification;
GDL2MODELER_EXPORT NSString *EOMCheckConsistencyForModelNotification;
GDL2MODELER_EXPORT NSString *EOMConsistencyModelObjectKey;
@class TableViewController;
@interface EOMEDocument : GSMarkupDocument
{
IBOutlet NSOutlineView * _outlineView;
IBOutlet NSTableView * _topTableView;
IBOutlet NSTableView * _bottomTableView;
IBOutlet NSTableView * _storedProcedureTableView;
IBOutlet NSPopUpButton * _topVisibleColumnsPopUp;
IBOutlet NSPopUpButton * _bottomVisibleColumnsPopUp;
IBOutlet NSPopUpButton * _storedProcVisibleColumnsPopUp;
IBOutlet NSPopUpButton * _storedProcDirectionUp;
IBOutlet NSTabView * _tabView;
EOModel * _eomodel;
id _outlineSelection;
TableViewController * _topTableViewController;
TableViewController * _bottomTableViewController;
TableViewController * _procTableViewController;
NSArray * _entityNames;
NSArray * _selectedObjects;
}
- (id) selectedObject;
- (id) outlineSelection;
- (EOModel*) eomodel;
- (void) setEomodel:(EOModel*) model;
- (void) setAdaptor:(id)sender;
@end
#endif

View file

@ -0,0 +1,899 @@
/**
EOMEDocument.m <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#import "EOMEDocument.h"
#import "EOMEEOAccessAdditions.h"
#import "TableViewController.h"
#import "SQLGenerator.h"
#import "AdaptorsPanel.h"
#import "CodeGenerator.h"
#import <EOModeler/EOMInspectorController.h>
#import "DataBrowser.h"
static NSString * entitiesItem = @"Entities";
static NSString * storedProceduresItem = @"Procedures";
/** Notification sent when beginning consistency checks.
* The notifications object is the EOModelerDocument.
* The receiver should call -appendConsistencyCheckErrorText:
* on the notifications object for any consistency check failures */
NSString *EOMCheckConsistencyBeginNotification =
@"EOMCheckConsistencyBeginNotification";
/** Notification sent when ending consistency checks.
* The notifications object is the EOModelerDocument.
* The receiver should call -appendConsistencyCheckSuccessText:
* on the notifications object for any consistency checks that passed. */
NSString *EOMCheckConsistencyEndNotification =
@"EOMCheckConsistencyEndNotification";
/** Notification sent when beginning EOModel consistency checks.
* The notifications object is the EOModelerDocument.
* The receiver should call -appendConsistencyCheckErrorText:
* on the notifications object for any consistency check failures
* the userInfo dictionary contains an EOModel instance for the
* EOMConsistencyModelObjectKey key. */
NSString *EOMCheckConsistencyForModelNotification =
@"EOMCheckConsistencyForModelNotification";
NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
@implementation EOMEDocument
+ (void) initialize
{
// [entitiesItem retain];
// [storedProceduresItem retain];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
// stop observing
[self setSelectedObjects:nil];
DESTROY(_outlineSelection);
DESTROY(_eomodel);
DESTROY(_topTableViewController);
DESTROY(_bottomTableViewController);
DESTROY(_procTableViewController);
DESTROY(_entityNames);
DESTROY(_selectedObjects);
[super dealloc];
}
- (EOModel*) eomodel
{
return _eomodel;
}
- (void) setEomodel:(EOModel*) model
{
ASSIGN(_eomodel, model);
}
- (NSString *)windowNibName
{
// Implement this to return a nib to load OR implement -makeWindowControllers to manually create your controllers.
return @"EOMEDocument";
}
- (NSButtonCell*) _cellWithImageNamed:(NSString*) aName
{
NSButtonCell *cell = [[NSButtonCell alloc] initImageCell:nil];
[cell setButtonType:NSSwitchButton];
[cell setImagePosition:NSImageOnly];
[cell setBordered:NO];
[cell setBezeled:NO];
[cell setAlternateImage:[NSImage imageNamed:aName]];
[cell setControlSize: NSSmallControlSize];
[cell setEditable:NO];
return AUTORELEASE(cell);
}
- (void) initTopColumns
{
NSTableColumn * column;
NSButtonCell * cell;
column = [_topTableView tableColumnWithIdentifier:@"isPrimaryKey"];
if (column) {
cell = [self _cellWithImageNamed:@"Key_On"];
[column setEditable: NO];
[column setDataCell:cell];
}
column = [_topTableView tableColumnWithIdentifier:@"isClassProperty"];
if (column) {
cell = [self _cellWithImageNamed:@"ClassProperty_On"];
[column setEditable: NO];
[column setDataCell:cell];
}
column = [_topTableView tableColumnWithIdentifier:@"allowNull"];
if (column) {
cell = [self _cellWithImageNamed:@"AllowsNull_On"];
[column setEditable: NO];
[column setDataCell:cell];
}
column = [_topTableView tableColumnWithIdentifier:@"isUsedForLocking"];
if (column) {
cell = [self _cellWithImageNamed:@"Locking_On"];
[column setEditable: NO];
[column setDataCell:cell];
}
}
- (void) initBottomColumns
{
NSTableColumn * column;
NSButtonCell * cell;
column = [_bottomTableView tableColumnWithIdentifier:@"isToMany"];
if (column) {
cell = [self _cellWithImageNamed:@"toMany"];
[cell setImage:[NSImage imageNamed:@"toOne"]];
[cell setImageDimsWhenDisabled:NO];
[cell setEnabled:NO];
[column setEditable: NO];
[column setDataCell:cell];
}
column = [_bottomTableView tableColumnWithIdentifier:@"isClassProperty"];
if (column) {
cell = [self _cellWithImageNamed:@"ClassProperty_On"];
[column setEditable: NO];
[column setDataCell:cell];
}
}
- (void) initStoredProcedureColumns
{
NSTableColumn * column;
NSButtonCell * cell;
column = [_storedProcedureTableView tableColumnWithIdentifier:@"parameterDirection"];
if (column) {
cell = [_storedProcDirectionUp cell];
[column setEditable: NO];
[column setDataCell:cell];
}
}
- (void) updateItemsInPopUp:(NSPopUpButton*) popUpB forEOClass:(Class) eoclass tableView:(NSTableView*) tableView
{
NSDictionary * columnDict = [eoclass allColumnNames];
NSArray * sortedTags = [[columnDict allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSEnumerator * enumer = [sortedTags objectEnumerator];
NSString * currentKey = nil;
NSDictionary * currentDict = nil;
NSMenu * menu = [popUpB menu];
[popUpB removeAllItems];
NSMenuItem * item = [NSMenuItem alloc];
[item initWithTitle:@""
action:NULL
keyEquivalent:@""];
[item setTag:1000];
[item setImage:[NSImage imageNamed:@"NSAddTemplate"]]; // @"gear"
[menu addItem:item];
[item release];
// [[[NSImage imageNamed:@"NSAddTemplate"] TIFFRepresentation] writeToFile:@"/tmp/NSAddTemplate.tiff" atomically:NO];
while ((currentKey = [enumer nextObject])) {
currentDict = [columnDict objectForKey:currentKey];
NSTableColumn * col = [tableView tableColumnWithIdentifier:[currentDict objectForKey:@"key"]];
item = [NSMenuItem alloc];
[item initWithTitle:[currentDict objectForKey:@"name"]
action:NULL
keyEquivalent:@""];
[item setTag:[currentKey integerValue]];
if ([col isHidden]) {
[item setState:NSOffState];
} else {
[item setState:NSOnState];
}
[menu addItem:item];
[item release];
}
}
- (void) makeCornerViews
{
NSView * cornerView = [_topTableView cornerView];
[[_topVisibleColumnsPopUp cell] setArrowPosition:NSPopUpNoArrow];
[_topVisibleColumnsPopUp setFrame:[cornerView frame]];
[_topVisibleColumnsPopUp setImagePosition:NSImageOnly];
[_topVisibleColumnsPopUp setBezelStyle:NSShadowlessSquareBezelStyle];
[_topTableView setCornerView:_topVisibleColumnsPopUp];
// bottom table view
cornerView = [_bottomTableView cornerView];
[[_bottomVisibleColumnsPopUp cell] setArrowPosition:NSPopUpNoArrow];
[_bottomVisibleColumnsPopUp setFrame:[cornerView frame]];
[_bottomVisibleColumnsPopUp setImagePosition:NSImageOnly];
[_bottomVisibleColumnsPopUp setBezelStyle:NSShadowlessSquareBezelStyle];
[_bottomTableView setCornerView:_bottomVisibleColumnsPopUp];
// stored proc table view
cornerView = [_storedProcedureTableView cornerView];
[[_storedProcVisibleColumnsPopUp cell] setArrowPosition:NSPopUpNoArrow];
[_storedProcVisibleColumnsPopUp setFrame:[cornerView frame]];
[_storedProcVisibleColumnsPopUp setImagePosition:NSImageOnly];
[_storedProcVisibleColumnsPopUp setBezelStyle:NSShadowlessSquareBezelStyle];
[_storedProcedureTableView setCornerView:_storedProcVisibleColumnsPopUp];
}
- (void) awakeFromGSMarkup
{
//NSImage * smartImage = [NSImage imageNamed:@"gear"];
// [[smartImage TIFFRepresentation] writeToFile:@"/tmp/NSSmartBadgeTemplate.tiff" atomically:NO];
[_outlineView setHeaderView:nil];
[self makeCornerViews];
[self updateItemsInPopUp:_topVisibleColumnsPopUp
forEOClass:[EOAttribute class]
tableView:_topTableView];
[self updateItemsInPopUp:_bottomVisibleColumnsPopUp
forEOClass:[EORelationship class]
tableView:_bottomTableView];
[self updateItemsInPopUp:_storedProcVisibleColumnsPopUp
forEOClass:[EOStoredProcedure class]
tableView:_storedProcedureTableView];
// [_storedProcDirectionUp setBezelStyle: NSRegularSquareBezelStyle];
[_storedProcDirectionUp setBordered: NO];
[self initTopColumns];
[self initBottomColumns];
[self initStoredProcedureColumns];
_topTableViewController = [TableViewController new];
_bottomTableViewController = [TableViewController new];
_procTableViewController = [TableViewController new];
[_topTableView setDataSource:_topTableViewController];
[_topTableView setDelegate:_topTableViewController];
[_bottomTableView setDataSource:_bottomTableViewController];
[_bottomTableView setDelegate:_bottomTableViewController];
[_storedProcedureTableView setDataSource:_procTableViewController];
[_storedProcedureTableView setDelegate:_procTableViewController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(outlineViewSelectionDidChange:)
name:NSOutlineViewSelectionDidChangeNotification
object:_outlineView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(outlineViewItemWillCollapse:)
name:NSOutlineViewItemWillCollapseNotification
object:_outlineView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewSelectionDidChange:)
name:NSTableViewSelectionDidChangeNotification
object:_topTableView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewSelectionDidChange:)
name:NSTableViewSelectionDidChangeNotification
object:_bottomTableView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewSelectionDidChange:)
name:NSTableViewSelectionDidChangeNotification
object:_storedProcedureTableView];
}
- (void) setSelectedObjects:(NSArray*) aValue
{
[self stopObserving];
ASSIGN(_selectedObjects, aValue);
[self startObserving];
// we will probably have the definition of EOModelerSelectionChanged somewhere else
// so we just use a string for now
[[NSNotificationCenter defaultCenter] postNotificationName:@"EOModelerSelectionChanged"
object:self];
}
- (NSArray*) selectedObjects
{
return _selectedObjects;
}
- (void) startObserving
{
if ((_selectedObjects) && ([_selectedObjects count])) {
NSEnumerator * objEnumer = [_selectedObjects objectEnumerator];
id currentObj = nil;
while ((currentObj = [objEnumer nextObject])) {
NSEnumerator * keyEnumer = [[currentObj observerKeys] objectEnumerator];
NSString * currentKey;
while ((currentKey = [keyEnumer nextObject])) {
[currentObj addObserver:self
forKeyPath:currentKey
options:(NSKeyValueObservingOptionNew |
NSKeyValueObservingOptionOld)
context:NULL];
}
}
}
}
- (void) stopObserving
{
if ((_selectedObjects) && ([_selectedObjects count])) {
NSEnumerator * objEnumer = [_selectedObjects objectEnumerator];
id currentObj = nil;
while ((currentObj = [objEnumer nextObject])) {
NSEnumerator * keyEnumer = [[currentObj observerKeys] objectEnumerator];
NSString * currentKey;
while ((currentKey = [keyEnumer nextObject])) {
[currentObj removeObserver:self
forKeyPath:currentKey];
}
}
}
}
- (void) setOutlineSelection:(id) aValue
{
ASSIGN(_outlineSelection, aValue);
if ([_outlineSelection class] == [EOStoredProcedure class]) {
[_tabView selectTabViewItemAtIndex:1];
[_procTableViewController setRepresentedObject:[(EOStoredProcedure*)_outlineSelection arguments]];
NSLog(@"%s:%@",__PRETTY_FUNCTION__, [(EOStoredProcedure*)_outlineSelection arguments]);
[_storedProcedureTableView reloadData];
} else {
[_tabView selectTabViewItemAtIndex:0];
[_topTableViewController setRepresentedObject:[_outlineSelection attributes]];
[_topTableView reloadData];
[_bottomTableViewController setRepresentedObject:[_outlineSelection relationships]];
[_bottomTableView reloadData];
}
if (!aValue) {
[self setSelectedObjects:[NSArray arrayWithObject:_eomodel]];
} else {
[self setSelectedObjects:[NSArray arrayWithObject:aValue]];
}
}
- (id) outlineSelection
{
return _outlineSelection;
}
- (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError
{
NSLog(@"%s:%@", __PRETTY_FUNCTION__, typeName);
NS_DURING {
[_eomodel writeToFile: [absoluteURL path]];
} NS_HANDLER {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[localException reason]
forKey:NSLocalizedDescriptionKey];
*outError = [NSError errorWithDomain:@"EOModel"
code:1
userInfo:userInfo];
return NO;
} NS_ENDHANDLER;
return YES;
}
//- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
//{
// NSLog(@"%s:%@", __PRETTY_FUNCTION__, typeName);
// Insert code here to write your document to data of the specified type. If the given outError != NULL,
// ensure that you set *outError when returning nil.
// You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or
// -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
// For applications targeted for Panther or earlier systems,
// you should use the deprecated API -dataRepresentationOfType:.
// In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
// return nil;
//}
//- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
//{
// NSLog(@"%s:%@", __PRETTY_FUNCTION__, typeName);
//
// // Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO.
//
// // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
//
// // For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType.
// // In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead.
//
// return YES;
//}
- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError
{
NSString * newUSLStr = nil;
ASSIGN(_eomodel, [EOModel modelWithContentsOfFile: [absoluteURL path]]);
ASSIGN(_entityNames,[_eomodel entityNames]);
return YES;
}
#pragma mark -
#pragma mark Outline
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
if (!item) {
// top level entities and storedProcedures
return 2;
}
if ((item == entitiesItem)) {
return [[_eomodel entityNames] count];
}
if ((item == storedProceduresItem)) {
return [[_eomodel storedProcedureNames] count];
}
return 0;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if (!item) {
return YES;
}
if (((item == entitiesItem)) || ((item == storedProceduresItem))) {
return YES;
}
return NO;
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (!item) {
if ((index == 0)) {
return entitiesItem;
}
if ((index == 1)) {
return storedProceduresItem;
}
}
if ((item == entitiesItem)) {
return [[_eomodel entityNames] objectAtIndex:index];
}
if ((item == storedProceduresItem)) {
return [[_eomodel storedProcedureNames] objectAtIndex:index];
}
return nil;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if (!item) {
// top level entities and storedProcedures
// return @"EOModel";
return nil;
}
if ((item == entitiesItem)) {
return entitiesItem;
}
if ((item == storedProceduresItem)) {
return storedProceduresItem;
}
//
// NSLog(@"%s (%d)", __PRETTY_FUNCTION__, [outlineView rowForItem:item]);
//
// if ([item respondsToSelector:@selector(name)]) {
// return [item name];
// }
//
return item;
// return nil;
}
#pragma mark -
- (NSString*) pathForOutlineSelection
{
NSMutableArray * myArray = [NSMutableArray array];
id parentItem = [_outlineView itemAtRow:[_outlineView selectedRow]];
if ((parentItem)) {
[myArray addObject:parentItem];
while (YES) {
parentItem = [_outlineView parentForItem:parentItem];
if (parentItem) {
[myArray insertObject:parentItem atIndex:0];
} else {
break;
}
}
}
return [myArray componentsJoinedByString:@"."];
}
/// KVC
- (id) eomObjectForKeyPath:(NSString*) path
{
NSString * newPath = nil;
if (([path hasPrefix:entitiesItem]) && ([path length] > ([entitiesItem length] + 1))) {
newPath = [path substringFromIndex:[entitiesItem length]+1];
return [_eomodel entityNamed:newPath];
} else if ((([path hasPrefix:storedProceduresItem]) && ([path length] > ([storedProceduresItem length] + 1)))) {
newPath = [path substringFromIndex:[storedProceduresItem length]+1];
return [_eomodel storedProcedureNamed:newPath];
}
return nil;
}
#pragma mark -
#pragma mark delegates
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
id newSelection = nil;
newSelection = [self eomObjectForKeyPath:[self pathForOutlineSelection]];
[self setOutlineSelection:newSelection];
}
- (void)outlineViewItemWillCollapse:(NSNotification *)notification
{
NSOutlineView * outlineView = [notification object];
NSUInteger index = 0;
NSInteger intIndex = 0;
NSString * collapseObj = [[notification userInfo] objectForKey:@"NSObject"];
intIndex = [outlineView rowForItem:collapseObj];
if (intIndex > -1) {
index = intIndex;
}
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: index]
byExtendingSelection:NO];
}
- (void)tableViewSelectionDidChange:(NSNotification *) notification
{
NSArray * selectedObjects = nil;
if (([notification object] == _topTableView)) {
selectedObjects = [_topTableViewController selectedObjects];
if ([selectedObjects count] > 0) {
[self setSelectedObjects:selectedObjects];
[_bottomTableView selectRowIndexes:[NSIndexSet indexSet]
byExtendingSelection:NO];
}
}
if (([notification object] == _bottomTableView)) {
selectedObjects = [_bottomTableViewController selectedObjects];
if ([selectedObjects count] > 0) {
[self setSelectedObjects:selectedObjects];
[_topTableView selectRowIndexes:[NSIndexSet indexSet]
byExtendingSelection:NO];
}
}
if (([notification object] == _storedProcedureTableView)) {
selectedObjects = [_procTableViewController selectedObjects];
if ([selectedObjects count] > 0) {
[self setSelectedObjects:selectedObjects];
}
}
}
- (IBAction) tableViewClicked:(NSTableView*) tv
{
// NSLog(@"%s:%@",__PRETTY_FUNCTION__, tv);
}
#pragma mark -
#pragma mark Pop ups
- (IBAction) visibleColumnsChanged:(id) sender
{
NSMenuItem * item = [sender selectedItem];
NSDictionary * dict = nil;
NSString * identifier = nil;
NSTableColumn * col = nil;
if (sender == _topVisibleColumnsPopUp) {
dict = [[EOAttribute allColumnNames] objectForKey:[NSNumber numberWithInteger:[item tag]]];
identifier = [dict objectForKey:@"key"];
col = [_topTableView tableColumnWithIdentifier:identifier];
}
if (sender == _bottomVisibleColumnsPopUp) {
dict = [[EORelationship allColumnNames] objectForKey:[NSNumber numberWithInteger:[item tag]]];
identifier = [dict objectForKey:@"key"];
col = [_bottomTableView tableColumnWithIdentifier:identifier];
}
if (sender == _storedProcVisibleColumnsPopUp) {
dict = [[EOStoredProcedure allColumnNames] objectForKey:[NSNumber numberWithInteger:[item tag]]];
identifier = [dict objectForKey:@"key"];
col = [_storedProcedureTableView tableColumnWithIdentifier:identifier];
}
if (([item state] == NSOnState)) {
[item setState:NSOffState];
[col setHidden:YES];
} else {
[item setState:NSOnState];
[col setHidden:NO];
}
}
- (IBAction) directionChanged:(id) sender
{
NSMenuItem * item = [_storedProcDirectionUp selectedItem];
NSLog(@"%s:%d", __PRETTY_FUNCTION__, [item tag]);
}
#pragma mark -
#pragma mark Menu Items
- (void) showInspector:(id)sender
{
[EOMInspectorController showInspector];
}
- (void) generateSQL:(id)sender
{
[[SQLGenerator sharedGenerator] openSQLGeneratorForDocument:self];
}
- (void) setAdaptor:(id)sender
{
NSString *adaptorName;
EOAdaptor *adaptor;
AdaptorsPanel *adaptorsPanel = [[AdaptorsPanel alloc] init];
adaptorName = [adaptorsPanel runAdaptorsPanel];
RELEASE(adaptorsPanel);
if (!adaptorName)
return;
[_eomodel setAdaptorName: adaptorName];
adaptor = [EOAdaptor adaptorWithName: adaptorName];
[_eomodel setConnectionDictionary:[adaptor runLoginPanel]];
}
- (void)createTemplates:(id)sender
{
CodeGenerator * codeGen = [[CodeGenerator new] autorelease];
[codeGen generate];
}
- (void)addAttribute:(id)sender
{
EOAttribute *attrb;
EOEntity *entity;
EOStoredProcedure *sProc = nil;
NSMutableArray *attributes;
NSUInteger count;
if ((!_outlineSelection) ||
(([_outlineSelection class] != [EOEntity class]) && ([_outlineSelection class] != [EOStoredProcedure class]))) {
return;
}
if (([_outlineSelection class] == [EOStoredProcedure class])) {
sProc = (EOStoredProcedure*) _outlineSelection;
attributes = (NSMutableArray*)[sProc arguments];
if (!attributes) {
attributes = [NSMutableArray array];
} else {
attributes = [NSMutableArray arrayWithArray:attributes];
}
NSLog(@"%s:%@",__PRETTY_FUNCTION__, attributes);
} else {
entity = (EOEntity*) _outlineSelection;
attributes = (NSMutableArray*) [entity attributes];
}
count = [attributes count];
attrb = [[EOAttribute alloc] init];
[attrb setName: [NSString stringWithFormat: @"Attribute%d", count]];
[attrb setColumnName: [attrb name]];
[attrb setValueClassName: @"NSString"];
[attrb setExternalType: @""];
if (sProc) {
[attributes addObject:attrb];
[sProc setArguments:attributes];
[_procTableViewController setRepresentedObject:[sProc arguments]];
[_storedProcedureTableView reloadData];
}else {
[entity addAttribute:attrb];
[_topTableView reloadData];
}
RELEASE(attrb);
}
- (IBAction)addProcedure:(id)sender
{
EOStoredProcedure * sProc;
NSUInteger count;
count = [[_eomodel storedProcedureNames] count];
sProc = [[EOStoredProcedure alloc] initWithName:[NSString stringWithFormat:@"Procedure%d", count]];
[_eomodel addStoredProcedure:sProc];
RELEASE(sProc);
[_outlineView reloadData];
}
- (IBAction)dataBrowser:(id)sender
{
EOEntity * entity = [self outlineSelection];
if ((entity) && ([entity class] == [EOEntity class])) {
DataBrowser * sharedBrowser = [DataBrowser sharedBrowser];
[sharedBrowser setEntity:entity];
}
}
#pragma mark -
#pragma mark key value observing
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([object isKindOfClass:[EOAttribute class]]) {
// optimize this?
[_topTableView reloadData];
[_storedProcedureTableView reloadData];
}
if ([object isKindOfClass:[EORelationship class]]) {
[_bottomTableView reloadData];
}
if ([object isKindOfClass:[EOEntity class]]) {
[_outlineView reloadData];
}
if ([object isKindOfClass:[EOStoredProcedure class]]) {
[_outlineView reloadData];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"EOModelerSelectionChanged"
object:self];
// NSLog(@"%s: %@, %@, %@", __PRETTY_FUNCTION__, keyPath, object, change);
}
@end

View file

@ -0,0 +1,94 @@
/**
EOMEEOAccessAdditions.h <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of DBModeler.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifndef __EOMEEOAccessAdditions_h
#define __EOMEEOAccessAdditions_h
#import <EOAccess/EOAccess.h>
@interface EOMEEOAccessAdditions:NSObject
{
}
+ (void)initialize;
@end
@interface EOAttribute (EOMEEOAccessAdditions)
+ (NSDictionary*) defaultColumnNames;
+ (NSDictionary*) allColumnNames;
- (NSArray*) observerKeys;
@end
@interface EORelationship (EOMEEOAccessAdditions)
+ (NSDictionary*) allColumnNames;
- (NSArray*) defaultColumnNames;
- (NSArray*) observerKeys;
- (NSArray*) sourceAttributeNames;
- (NSString*) humanReadableSourceAttributes;
- (NSArray*) destinationAttributeNames;
- (NSString*) humanReadableDestinationAttributes;
- (EOJoin*) joinFromAttributeNamed:(NSString*) atrName;
- (EOJoin*) joinToAttributeNamed:(NSString*) atrName;
@end
@interface EOEntity (EOMEEOAccessAdditions)
- (NSArray*) attributeNames;
- (NSArray*) observerKeys;
@end
@interface EOStoredProcedure (EOMEEOAccessAdditions)
+ (NSDictionary*) allColumnNames;
- (NSArray*) observerKeys;
@end
@interface EOModel (EOMEEOAccessAdditions)
- (NSArray*) observerKeys;
@end
#endif

View file

@ -0,0 +1,385 @@
/**
EOMEEOAccessAdditions.m <title>EOMEDocument Class</title>
Copyright (C) Free Software Foundation, Inc.
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
<license>
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#import "EOMEEOAccessAdditions.h"
NSMutableArray *DefaultEntityColumns;
NSMutableArray *DefaultAttributeColumns;
NSMutableArray *DefaultRelationshipColumns;
static NSDictionary * defaultEOAttributeColumnNamesDict = nil;
static NSDictionary * allEOAttributeColumnNamesDict = nil;
static NSDictionary * allEORelationshipColumnNamesDict = nil;
static NSDictionary * allEOStoredProcedureColumnNamesDict = nil;
static NSArray * EOAttributeObserverKeys = nil;
static NSArray * EORelationshipObserverKeys = nil;
static NSArray * EOStoredProcedureObserverKeys = nil;
static NSArray * EOEOModelObserverKeys = nil;
struct column_info {
NSString *key;
NSInteger tag;
NSString *name;
BOOL isDefault;
};
static struct column_info attribute_columns[] = {
{@"isPrimaryKey", 0, @"Primary key", YES},
{@"isClassProperty", 1, @"Class property", YES},
{@"allowNull", 2, @"Allows null", YES},
{@"isUsedForLocking", 3, @"Locking", YES},
{@"name", 4, @"Name", YES},
{@"columnName", 5, @"Column name", YES},
{@"valueClassName", 6, @"Value class name", YES},
{@"externalType", 7, @"External Type", YES},
{@"width", 8, @"Width", YES},
{@"definition", 9, @"Definition", NO},
{@"precision", 10, @"Precision", NO},
{@"readFormat", 11, @"Read format", NO},
{@"scale", 12, @"Scale", NO},
{@"valueType", 13, @"Value type", NO},
{@"writeFormat", 14, @"Write format", NO},
{nil, 1000, nil, NO}
};
static struct column_info relationship_columns[]= {
{@"isToMany", 0, @"Cardinality", YES},
{@"isClassProperty", 1, @"Class property", YES},
{@"name", 2, @"Name", YES},
{@"destinationEntity.name", 3, @"Destination Entity", YES},
{@"humanReadableSourceAttributes", 4, @"Source Attribute", YES},
{@"humanReadableDestinationAttributes",5, @"Destination Attribute", YES},
{@"definition", 6, @"Definition", NO},
{nil, 1000, nil, NO}
};
static struct column_info entity_columns[] = {
{@"name", 0, @"Name", YES},
{@"className", 1, @"Class name", YES},
{@"externalName", 2, @"External name", YES},
{@"externalQuery", 4, @"External query", NO},
{@"parentEntity.name", 5, @"Parent", NO},
{nil, 1000, nil, NO}
};
static struct column_info procedure_columns[] = {
{@"name", 0, @"Name", YES},
{@"parameterDirection", 1, @"Direction", YES},
{@"columnName", 2, @"Column name", YES},
{@"valueClassName", 3, @"Value class name",NO},
{@"externalType", 4, @"External type", NO},
{@"width", 5, @"Width", NO},
{@"precision", 6, @"Precision", NO},
{@"scale", 7, @"Scale", NO},
{@"valueType", 8, @"Value type", NO},
{nil, 1000, nil, NO}
};
@implementation EOMEEOAccessAdditions
+ (void)initialize
{
if (DefaultRelationshipColumns) {
// nothing to do
return;
}
NSLog(@"%s", __PRETTY_FUNCTION__);
DefaultRelationshipColumns = [[NSMutableArray alloc] init];
// _sharedDefaultColumnProvider = [[self alloc] init];
// _aspectsAndKeys = [[NSMutableDictionary alloc] init];
}
+ (NSDictionary*) defaultColumnNamesForDict:(struct column_info*) staticDict onlyDefault:(BOOL) onlyDefault
{
NSInteger i = 0;
NSMutableDictionary * mDict = [NSMutableDictionary new];
for (i = 0; staticDict[i].key != nil; i++)
{
if ((onlyDefault == NO) || (staticDict[i].isDefault == YES))
{
NSDictionary * sDict = [NSDictionary dictionaryWithObjectsAndKeys:staticDict[i].name, @"name",
staticDict[i].key, @"key", nil];
[mDict setObject: sDict
forKey: [NSNumber numberWithInteger:staticDict[i].tag]];
}
}
return mDict;
}
+ (NSArray*) keysFromDict:(struct column_info*) staticDict
{
NSMutableArray * mArray = [NSMutableArray array];
NSInteger i = 0;
for (i = 0; staticDict[i].key != nil; i++)
{
[mArray addObject:staticDict[i].key];
}
return mArray;
}
@end
@implementation EOAttribute (EOMEEOAccessAdditions)
+ (NSDictionary*) defaultColumnNames
{
if (!defaultEOAttributeColumnNamesDict) {
defaultEOAttributeColumnNamesDict = [EOMEEOAccessAdditions defaultColumnNamesForDict:&attribute_columns[0]
onlyDefault:YES];
}
return defaultEOAttributeColumnNamesDict;
}
+ (NSDictionary*) allColumnNames
{
if (!allEOAttributeColumnNamesDict) {
allEOAttributeColumnNamesDict = [EOMEEOAccessAdditions defaultColumnNamesForDict:&attribute_columns[0]
onlyDefault:NO];
}
return allEOAttributeColumnNamesDict;
}
- (NSArray*) observerKeys
{
if (!EOAttributeObserverKeys) {
NSMutableArray * mutArray;
NSArray * tmpArray = [NSArray arrayWithArray:[EOMEEOAccessAdditions
keysFromDict:&attribute_columns[0]]];
mutArray = [NSMutableArray arrayWithArray:tmpArray];
tmpArray = [NSArray arrayWithObjects:@"isReadOnly",
@"allowsNull",
@"parameterDirection",
nil];
[mutArray addObjectsFromArray:tmpArray];
EOAttributeObserverKeys = mutArray;
[EOAttributeObserverKeys retain];
}
return EOAttributeObserverKeys;
}
@end
@implementation EORelationship (EOMEEOAccessAdditions)
+ (NSDictionary*) allColumnNames
{
if (!allEORelationshipColumnNamesDict) {
allEORelationshipColumnNamesDict = [EOMEEOAccessAdditions defaultColumnNamesForDict:&relationship_columns[0]
onlyDefault:NO];
}
return allEORelationshipColumnNamesDict;
}
- (NSArray*) observerKeys
{
if (!EORelationshipObserverKeys) {
EORelationshipObserverKeys = [NSArray arrayWithObjects:@"toMany",
@"classProperty",
@"name",
@"destinationEntity",
@"definition",
@"joins",
@"joinSemantic",
@"isMandatory",
@"numberOfToManyFaultsToBatchFetch",
@"deleteRule",
@"ownsDestination",
@"propagatesPrimaryKey",
nil];
[EORelationshipObserverKeys retain];
}
return EORelationshipObserverKeys;
}
- (NSArray*) sourceAttributeNames
{
NSMutableArray * mArray = [NSMutableArray array];
NSEnumerator * enumer = [[self sourceAttributes] objectEnumerator];
EOAttribute * currentAttr = nil;
while ((currentAttr = [enumer nextObject])) {
[mArray addObject:[currentAttr name]];
}
return mArray;
}
- (NSString*) humanReadableSourceAttributes
{
return [[self sourceAttributeNames] componentsJoinedByString:@", "];
}
- (NSArray*) destinationAttributeNames
{
NSMutableArray * mArray = [NSMutableArray array];
NSEnumerator * enumer = [[self destinationAttributes] objectEnumerator];
EOAttribute * currentAttr = nil;
while ((currentAttr = [enumer nextObject])) {
[mArray addObject:[currentAttr name]];
}
return mArray;
}
- (NSString*) humanReadableDestinationAttributes
{
return [[self destinationAttributeNames] componentsJoinedByString:@", "];
}
- (EOJoin*) joinFromAttributeNamed:(NSString*) atrName
{
NSArray * joins = [self joins];
NSEnumerator * enumer;
EOJoin * currentJoin;
if ([joins count] < 1) {
return nil;
}
enumer = [joins objectEnumerator];
while ((currentJoin = [enumer nextObject])) {
if (([[[currentJoin sourceAttribute] name] isEqual:atrName])) {
return currentJoin;
}
}
return nil;
}
- (EOJoin*) joinToAttributeNamed:(NSString*) atrName
{
NSArray * joins = [self joins];
NSEnumerator * enumer;
EOJoin * currentJoin;
if ([joins count] < 1) {
return nil;
}
enumer = [joins objectEnumerator];
while ((currentJoin = [enumer nextObject])) {
if (([[[currentJoin destinationAttribute] name] isEqual:atrName])) {
return currentJoin;
}
}
return nil;
}
@end
@implementation EOEntity (EOMEEOAccessAdditions)
- (NSArray*) attributeNames
{
NSMutableArray * mArray = [NSMutableArray array];
NSEnumerator * enumer = [[self attributes] objectEnumerator];
EOAttribute * currentAttr = nil;
while ((currentAttr = [enumer nextObject])) {
[mArray addObject:[currentAttr name]];
}
return mArray;
}
- (NSArray*) observerKeys
{
if (!EORelationshipObserverKeys) {
EORelationshipObserverKeys = [NSArray arrayWithObjects:@"externalName",
@"className",
@"name",
@"maxNumberOfInstancesToBatchFetch",
@"externalQuery",
nil];
[EORelationshipObserverKeys retain];
}
return EORelationshipObserverKeys;
}
@end
@implementation EOStoredProcedure (EOMEEOAccessAdditions)
+ (NSDictionary*) allColumnNames
{
if (!allEOStoredProcedureColumnNamesDict) {
allEOStoredProcedureColumnNamesDict = [EOMEEOAccessAdditions defaultColumnNamesForDict:&procedure_columns[0]
onlyDefault:NO];
}
return allEOStoredProcedureColumnNamesDict;
}
- (NSArray*) observerKeys
{
if (!EOStoredProcedureObserverKeys) {
EOStoredProcedureObserverKeys = [NSArray arrayWithObjects:@"externalName",
@"name",
@"parameterDirection",
nil];
[EOStoredProcedureObserverKeys retain];
}
return EOStoredProcedureObserverKeys;
}
@end
@implementation EOModel (EOMEEOAccessAdditions)
- (NSArray*) observerKeys
{
if (!EOEOModelObserverKeys) {
EOEOModelObserverKeys = [NSArray arrayWithObjects:@"connectionDictionary",
@"userInfo",
nil];
[EOEOModelObserverKeys retain];
}
return EOEOModelObserverKeys;
}
@end

View file

@ -0,0 +1,40 @@
/*
EOModelEditorApp.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __EOModelEditorApp_h
#define __EOModelEditorApp_h
#include <AppKit/NSApplication.h>
@class EOMEDocument;
@interface EOModelEditorApp : NSApplication
{
}
- (EOMEDocument *) activeDocument;
@end
#endif

View file

@ -0,0 +1,126 @@
/*
EOModelEditorApp.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#import "EOModelEditorApp.h"
#import "EOMEEOAccessAdditions.h"
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "AdaptorsPanel.h"
#import "EOMEDocument.h"
@implementation EOModelEditorApp
/*
on Interface Builder the DocumentController is created by loading the NIB after it has been added to.
We don't have a NIB file so we have to do this manually -- dw
*/
- (void)finishLaunching
{
//NSDocumentController * dc = [NSDocumentController sharedDocumentController];
// [dc retain];
[EOMEEOAccessAdditions class];
[super finishLaunching];
}
- (void)orderFrontStandardAboutPanel:(id)sender
{
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:@"Credits", @"Credits.rtf",
@"Version", @"0.1 (2010)", nil];
[self orderFrontStandardAboutPanelWithOptions: dict];
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
return NO;
}
- (void) newDocumentWithModel:(EOModel *)newModel
{
EOMEDocument *newModelerDoc;
NSError *outError = nil;
NSDocumentController * sharedDocController = [NSDocumentController sharedDocumentController];
newModelerDoc = [sharedDocController openUntitledDocumentAndDisplay:YES
error:&outError];
if (newModelerDoc) {
[newModelerDoc setEomodel:newModel];
}
}
- (void) newFromDatabase:(id)sender
{
NSString *adaptorName;
AdaptorsPanel *adaptorsPanel = [[AdaptorsPanel alloc] init];
adaptorName = [adaptorsPanel runAdaptorsPanel];
RELEASE(adaptorsPanel);
if (adaptorName)
{
NS_DURING {
EOAdaptor *adaptor;
EOAdaptorChannel *channel;
EOAdaptorContext *ctxt;
EOModel *newModel;
NSDictionary *connDict;
adaptor = [EOAdaptor adaptorWithName:adaptorName];
connDict = [adaptor runLoginPanel];
if (connDict)
{
[adaptor setConnectionDictionary:connDict];
ctxt = [adaptor createAdaptorContext];
channel = [ctxt createAdaptorChannel];
[channel openChannel];
newModel = [channel describeModelWithTableNames:[channel describeTableNames]];
[newModel setConnectionDictionary:[adaptor connectionDictionary]];
[newModel setName: [[adaptor connectionDictionary] objectForKey:@"databaseName"]];
[channel closeChannel];
[self newDocumentWithModel:newModel];
}
} NS_HANDLER {
NSRunCriticalAlertPanel (@"Problem creating model from Database",
@"%@",
@"Ok",
nil,
nil,
localException);
} NS_ENDHANDLER;
}
}
- (EOMEDocument *) activeDocument
{
return (EOMEDocument *) [[NSDocumentController sharedDocumentController] currentDocument];
}
@end

View file

@ -0,0 +1,63 @@
{
ApplicationDescription = "GDL2 EOModel editor";
ApplicationIcon = EOModelEditor;
ApplicationName = EOModelEditor;
ApplicationRelease = "1.0.0 (Alpha)";
ApplicationURL = "http://mediawiki.gnustep.org/index.php/EOModelEditor";
Authors = ("David Wetzel");
Copyright = "Copyright \U00A9 2005, 2006 Free Software Foundation";
CopyrightDescription = "Released under the GNU GPL. See COPYING for details.";
CFBundleGetInfoString = "1.0.0 \U00A9 Free Software Foundation";
CFBundleShortVersionString = "1.0.0";
GSMainMarkupFile = "";
NSExecutable = EOModelEditor;
NSIcon = EOModelEditor.tiff;
CFBundleIconFile = "EOModelEditor";
CFBundleIdentifier = "org.gnustep.eomodeleditor";
NSRole = "Editor";
CFBundleDocumentTypes = (
/* {
CFBundleTypeName = "EOModel Format";
NSHumanReadableName = "EOModel Format";
CFBundleTypeRole = Editor;
CFBundleTypeExtensions = ("eomodel", "eomodeld");
CFBundleTypeIconFile = "EOModel";
CFBundleTypeOSTypes = ("EOMO");
XXLSItemContentTypes = ("org.gnustep.eomodeleditor.document");
XXXNSExportableAs = ("NSTIFFPboardType");
NSDocumentClass = "EOMEDocument";
},*/
{
CFBundleTypeIconFile = "EOModel";
CFBundleTypeName = "EOModel Format";
CFBundleTypeExtensions = ("eomodeld");
CFBundleTypeRole = Editor;
CFBundleTypeOSTypes = ("EOMO");
LSItemContentTypes = ("org.gnustep.eomodeleditor.document");
LSIsAppleDefaultForType = "true";
LSTypeIsPackage = "true";
NSDocumentClass = "EOMEDocument";
}
);
UTExportedTypeDeclarations = (
{
UTTypeIdentifier = "org.gnustep.eomodeleditor.document";
UTTypeDescription = "EOModel Format";
UTTypeIconFile = "EOModel.icns";
UTTypeConformsTo = ("com.apple.package");
UTTypeTagSpecification = {
"com.apple.ostype" = "EOMO";
"public.filename-extension" = "eomodeld";
"public.mime-type" = "document/eomodel";
};
}
);
NSMainNibFile = "";
NSPrincipalClass = EOModelEditorApp;
}

View file

@ -0,0 +1,90 @@
#
# EOModelEditor makefile for GNUstep Database Library.
#
# Copyright (C) 2005,2006 Free Software Foundation, Inc.
#
# Author: Matt Rice <ratmice@gmail.com>
#
# This file is part of the GNUstep Database Library.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
include ../../common.make
include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = EOModelEditor
EOModelEditor_NEEDS_GUI = yes
EOModelEditor_SUBPROJECTS=Inspectors
ifeq ($(GUI_LIB),apple)
EOModelEditor_APPLICATION_ICON = EOModelEditor.icns
else
EOModelEditor_APPLICATION_ICON = EOModelEditor.tiff
endif
ADDITIONAL_INCLUDE_DIRS+=-I../
ADDITIONAL_NATIVE_LIB_DIRS+=../EOAccess ../EOControl ../EOInterface ../EOModeler
ADDITIONAL_NATIVE_LIBS += EOAccess EOControl EOInterface EOModeler Renaissance
$(APP_NAME)_RESOURCE_FILES = \
Resources/ModelDrag.tiff \
Resources/SQLGenerator.gsmarkup \
Resources/EOMEDocument.gsmarkup \
Resources/EOModelEditorInfo.plist \
Resources/Key_Diagram.tiff \
Resources/Key_Header.tiff \
Resources/toOne.tiff \
Resources/toMany.tiff \
Resources/Key_On.tiff \
Resources/gear.tiff \
Resources/Locking_Diagram.tiff \
Resources/Locking_Header.tiff \
Resources/Locking_On.tiff \
Resources/ClassProperty_Diagram.tiff \
Resources/ClassProperty_Header.tiff \
Resources/ClassProperty_On.tiff \
Resources/Preferences.gorm \
Resources/EOModelEditor.tiff \
Resources/EOModelEditor.icns \
Resources/EOModel.icns \
Resources/AllowsNull_On.tiff \
Resources/dimple.tiff \
Resources/nodimple.tiff \
Resources/AllowsNull_Header.tiff \
Resources/Menu-Cocoa.gsmarkup \
Resources/Menu-GNUstep.gsmarkup \
Resources/Credits.rtf \
Resources/ConsistencyResults.gsmarkup \
Resources/DataBrowser.gsmarkup
$(APP_NAME)_OBJC_FILES = \
main.m \
EOModelEditorApp.m \
TableViewController.m \
EOMEEOAccessAdditions.m \
EOMEDocument.m \
AdaptorsPanel.m \
EOAdditions.m \
SQLGenerator.m \
ConsistencyResults.m \
Preferences.m \
ConsistencyChecker.m \
CodeGenerator.m \
DataBrowser.m
include $(GNUSTEP_MAKEFILES)/application.make

View file

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box title="Options" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<button title="Read Only" type="switch"
action="readOnlyClicked:" target="#NSOwner" id="readOnlySwitch" />
<button title="Allow Null Value" type="switch"
action="allowNullClicked:" target="#NSOwner" id="allowNullSwitch" />
</gridRow>
</grid>
</box>
<box title="Custom Formatting" topPadding="10" leftPadding="4" rightPadding="4">
<grid>
<gridRow>
<label halign="right" selectable="no">Read:</label>
<textField id="readField" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Write:</label>
<textField id="writeField" delegate="#NSOwner"></textField>
</gridRow>
</grid>
</box>
<hbox height="220" />
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#readOnlySwitch" key="readOnlySwitch"/>
<outlet source="#NSOwner" target="#allowNullSwitch" key="allowNullSwitch"/>
<outlet source="#NSOwner" target="#readField" key="readField"/>
<outlet source="#NSOwner" target="#writeField" key="writeField"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,45 @@
/*
AdvancedAttributeInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/AppKit.h>
#endif
@class EOAttribute;
@interface AdvancedAttributeInspector : EOMInspector
{
IBOutlet NSTextField *readField;
IBOutlet NSTextField *writeField;
IBOutlet NSButton *readOnlySwitch;
IBOutlet NSButton *allowNullSwitch;
EOAttribute *_currentAttribute;
}
@end

View file

@ -0,0 +1,138 @@
/*
AdvancedAttributeInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "AdvancedAttributeInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSArray.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation AdvancedAttributeInspector
- (NSString *) displayName
{
return @"Advanced Attribute";
}
- (void) dealloc
{
DESTROY(_currentAttribute);
[super dealloc];
}
- (void) awakeFromGSMarkup
{
}
- (float) displayOrder
{
return 2;
}
- (BOOL) canInspectObject:(id)anObject
{
BOOL weCan = [anObject isKindOfClass:[EOAttribute class]];
// avoid the AdvancedAttributeInspector on Stored Procedures.
if (weCan) {
id outlineSel = [[NSApp activeDocument] outlineSelection];
if ((outlineSel) && ([outlineSel class] == [EOEntity class])) {
return YES;
}
return NO;
}
return weCan;
}
- (void) refresh
{
NSString * tmpStr;
ASSIGN(_currentAttribute, (EOAttribute *) [self selectedObject]);
[readOnlySwitch setIntValue:[_currentAttribute isReadOnly]];
[allowNullSwitch setIntValue:[_currentAttribute allowsNull]];
tmpStr = [_currentAttribute readFormat];
if (!tmpStr) {
[readField setStringValue:@""];
} else {
[readField setStringValue:tmpStr];
}
tmpStr = [_currentAttribute writeFormat];
if (!tmpStr) {
[writeField setStringValue:@""];
} else {
[writeField setStringValue:tmpStr];
}
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
if (obj == readField) {
[_currentAttribute setReadFormat:[readField stringValue]];
return;
}
if (obj == writeField) {
[_currentAttribute setWriteFormat:[writeField stringValue]];
return;
}
}
- (IBAction) readOnlyClicked:(id) sender
{
[_currentAttribute setReadOnly:[sender intValue]];
}
- (IBAction) allowNullClicked:(id) sender
{
[_currentAttribute setAllowsNull:[sender intValue]];
}
@end

View file

@ -0,0 +1,73 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box topPadding="0" bottomPadding="3" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<label halign="right" selectable="no">Batch Faulting Size:</label>
<textField id="batchFaultingSizeText" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">External Query:</label>
<textField id="externalQueryText" delegate="#NSOwner"
toolTip="Any valid SQL statement that you want to be executed when unqualified fetches are performed on the entity."></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Qualifier:</label>
<textField id="qualifierText" delegate="#NSOwner"></textField>
</gridRow>
</grid>
</box>
<box title="Parent" topPadding="0" bottomPadding="0" leftPadding="4" rightPadding="4">
<vbox>
<scrollView hasHorizontalScroller="no" height="115">
<tableView id="parentTableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="no" allowsColumnSelection="no" target="#NSOwner" action="tableViewClicked:">
<tableColumn editable="no" identifier="selected" title="" minWidth="16" maxWidth="16" width="16"/>
<tableColumn editable="no" identifier="name" title="Entity Name" minWidth="85"/>
<tableColumn editable="no" identifier="className" title="Class" minWidth="85"/>
</tableView>
</scrollView>
<button id="parentButton" type="toggle" halign="right" title="Set Parent"
alternateTitle="Unset Parent"
target="#NSOwner" action="parentButtonClicked:" />
</vbox>
</box>
<box title="Options" topPadding="0" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<button halign="left" title="Read Only" type="switch"
action="readOnlyClicked:" target="#NSOwner" id="readOnlySwitch" />
</gridRow>
<gridRow>
<button halign="left" title="Cache in Memory" type="switch"
action="cacheClicked:" target="#NSOwner" id="cacheSwitch" />
</gridRow>
<gridRow>
<button halign="left" title="Abstract" type="switch"
action="abstractClicked:" target="#NSOwner" id="abstactSwitch" />
</gridRow>
</grid>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#batchFaultingSizeText" key="batchFaultingSizeText"/>
<outlet source="#NSOwner" target="#externalQueryText" key="externalQueryText"/>
<outlet source="#NSOwner" target="#qualifierText" key="qualifierText"/>
<outlet source="#NSOwner" target="#parentTableView" key="parentTableView"/>
<outlet source="#NSOwner" target="#parentButton" key="parentButton"/>
<outlet source="#NSOwner" target="#readOnlySwitch" key="readOnlySwitch"/>
<outlet source="#NSOwner" target="#cacheSwitch" key="cacheSwitch"/>
<outlet source="#NSOwner" target="#abstactSwitch" key="abstactSwitch"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,55 @@
/*
AdvancedEntityInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSNibDeclarations.h>
#endif
#include <EOModeler/EOMInspector.h>
@class NSButton;
@class NSTableView;
@class NSTextField;
@class EOEntity;
@class TableViewController;
@interface AdvancedEntityInspector : EOMInspector
{
IBOutlet NSTextField *batchFaultingSizeText;
IBOutlet NSTextField *externalQueryText;
IBOutlet NSTextField *qualifierText;
IBOutlet NSTableView *parentTableView;
IBOutlet NSButton *parentButton;
IBOutlet NSButton *readOnlySwitch;
IBOutlet NSButton *cacheSwitch;
IBOutlet NSButton *abstactSwitch;
EOEntity *_currentEntity;
TableViewController *_tableViewController;
NSMutableArray *_allEntites;
EOEntity *_parentEntity;
}
@end

View file

@ -0,0 +1,251 @@
/*
AdvancedEntityInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "AdvancedEntityInspector.h"
#include <EOModeler/EOMInspector.h>
#import <EOAccess/EOAccess.h>
#include <AppKit/AppKit.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
#import "../TableViewController.h"
@implementation AdvancedEntityInspector
- (void) dealloc
{
DESTROY(_tableViewController);
DESTROY(_allEntites);
DESTROY(_parentEntity);
DESTROY(_currentEntity);
[super dealloc];
}
- (float) displayOrder
{
return 3;
}
- (void) buildAllEntities
{
NSMutableArray * entArray = [NSMutableArray array];
NSEnumerator * enumer = [[[[NSApp activeDocument] eomodel] entities] objectEnumerator];
EOEntity * entity;
while ((entity = [enumer nextObject])) {
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:[entity name], @"name",
[entity className], @"className",
[NSNumber numberWithInt:0], @"selected",
nil];
if ((_parentEntity) && ([_parentEntity isEqual:entity])) {
[dict setObject:[NSNumber numberWithInt:1]
forKey:@"selected"];
}
[entArray addObject:dict];
}
ASSIGN(_allEntites, entArray);
[_tableViewController setRepresentedObject:_allEntites];
[parentTableView reloadData];
}
- (NSButtonCell*) _cellWithImageNamed:(NSString*) aName
{
NSButtonCell *cell = [[NSButtonCell alloc] initImageCell:nil];
[cell setButtonType:NSSwitchButton];
[cell setImagePosition:NSImageOnly];
[cell setBordered:NO];
[cell setBezeled:NO];
[cell setAlternateImage:[NSImage imageNamed:aName]];
[cell setControlSize: NSSmallControlSize];
[cell setEditable:NO];
return AUTORELEASE(cell);
}
- (void) initColums
{
NSTableColumn * column;
NSButtonCell * cell;
column = [parentTableView tableColumnWithIdentifier:@"selected"];
if (column) {
cell = [self _cellWithImageNamed:@"dimple"];
[cell setEnabled:NO];
[cell setImageDimsWhenDisabled:NO];
[column setEditable: NO];
[column setDataCell:cell];
}
}
- (void) awakeFromGSMarkup
{
[self initColums];
_tableViewController = [TableViewController new];
[parentTableView setDataSource:_tableViewController];
[parentTableView setDelegate:_tableViewController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewSelectionDidChange:)
name:NSTableViewSelectionDidChangeNotification
object:parentTableView];
}
- (NSString *)displayName
{
return @"Advanced Entity";
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EOEntity class]];
}
- (IBAction) readOnlyClicked:(id) sender
{
[_currentEntity setReadOnly:[sender state]];
}
- (IBAction) cacheClicked:(id) sender
{
[_currentEntity setCachesObjects:[sender state]];
}
- (IBAction) abstractClicked:(id) sender
{
[_currentEntity setIsAbstractEntity:[sender state]];
}
- (IBAction) parentButtonClicked:(id) sender
{
EOEntity *selectedParent;
NSInteger selectedRow = [parentTableView selectedRow];
selectedParent = [[[_currentEntity model] entities] objectAtIndex:selectedRow];
if (_parentEntity)
{
[_parentEntity removeSubEntity:_currentEntity];
DESTROY(_parentEntity);
}
else
{
[selectedParent addSubEntity:_currentEntity];
ASSIGN(_parentEntity, selectedParent);
}
[self buildAllEntities];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id sender = [notif object];
if (sender == batchFaultingSizeText) {
int iValue = [sender intValue];
[_currentEntity setMaxNumberOfInstancesToBatchFetch:(iValue > 0) ? iValue:1];
return;
}
if (sender == externalQueryText) {
[_currentEntity setExternalQuery:[externalQueryText stringValue]];
return;
}
if (sender == qualifierText) {
// checkme!
[_currentEntity setRestrictingQualifier:[externalQueryText stringValue]];
return;
}
}
- (IBAction) tableViewClicked:(id) sender
{
}
- (void) refresh
{
NSString * tmpStr;
EOModel *activeModel = [[NSApp activeDocument] eomodel];
ASSIGN(_currentEntity, (EOEntity *) [self selectedObject]);
[batchFaultingSizeText setIntValue:[_currentEntity maxNumberOfInstancesToBatchFetch]];
tmpStr = [_currentEntity externalQuery];
[externalQueryText setStringValue:(tmpStr != nil) ? tmpStr : @""];
// I am not sure if this is correct. How to convert a Qualifier to / from a string?
tmpStr = [_currentEntity restrictingQualifier];
[qualifierText setStringValue:(tmpStr != nil) ? tmpStr : @""];
[readOnlySwitch setState:[_currentEntity isReadOnly]];
[cacheSwitch setState:[_currentEntity cachesObjects]];
[abstactSwitch setState:[_currentEntity isAbstractEntity]];
ASSIGN(_parentEntity,[_currentEntity parentEntity]);
if (_parentEntity) {
[parentButton setState: NSOnState];
[parentButton setEnabled:NO];
} else {
[parentButton setState: NSOffState];
[parentButton setEnabled:YES];
}
[self buildAllEntities];
}
- (void)tableViewSelectionDidChange:(NSNotification *) notification
{
NSArray * selectedObjects = nil;
selectedObjects = [_tableViewController selectedObjects];
if ([selectedObjects count] > 0) {
NSMutableDictionary * dict = [selectedObjects objectAtIndex:0];
if ((_parentEntity) && ([[dict objectForKey:@"name"] isEqual:[_parentEntity name]])) {
[parentButton setState: NSOnState];
[parentButton setEnabled:YES];
return;
}
if ((!_parentEntity)) {
[parentButton setState: NSOffState];
[parentButton setEnabled:YES];
} else {
[parentButton setEnabled:NO];
}
}
}
@end

View file

@ -0,0 +1,56 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box title="Batch Faulting" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<label halign="right" selectable="no">Batch Size:</label>
<textField id="batchSizeField" delegate="#NSOwner"></textField>
</gridRow>
</grid>
</box>
<box title="Optionality" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<matrix type="radio" autoenabledItems="no" target="#NSOwner" action="optionalityClicked:"
id="optionalityMatrix">
<matrixRow><matrixCell tag="0" title="Optional" /></matrixRow>
<matrixRow><matrixCell tag="1" title="Mandatory" /></matrixRow>
</matrix>
</box>
<box title="Delete Rule" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<matrix type="radio" autoenabledItems="no" target="#NSOwner" action="deleteRuleClicked:"
id="deleteRuleMatrix">
<matrixRow><matrixCell tag="0" title="Nullify" /></matrixRow>
<matrixRow><matrixCell tag="1" title="Cascade" /></matrixRow>
<matrixRow><matrixCell tag="2" title="Deny" /></matrixRow>
<matrixRow><matrixCell tag="3" title="No Action" /></matrixRow>
</matrix>
</box>
<box topPadding="10" leftPadding="4" rightPadding="4" width="260">
<vbox>
<button title="Owns Destination" type="switch" halign="wexpand"
action="ownsDestinationClicked:" target="#NSOwner" id="ownsDestinationSwitch" />
<button title="Propagade Primary Key" type="switch" halign="wexpand"
action="propagadePrimaryKeyClicked:" target="#NSOwner" id="propagadePrimaryKeySwitch"/>
</vbox>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#batchSizeField" key="batchSizeField"/>
<outlet source="#NSOwner" target="#optionalityMatrix" key="optionalityMatrix"/>
<outlet source="#NSOwner" target="#deleteRuleMatrix" key="deleteRuleMatrix"/>
<outlet source="#NSOwner" target="#ownsDestinationSwitch" key="ownsDestinationSwitch"/>
<outlet source="#NSOwner" target="#propagadePrimaryKeySwitch" key="propagadePrimaryKeySwitch"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,48 @@
/*
AdvancedRelationshipInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of DBModeler.
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/AppKit.h>
#endif
@class EOModel;
@class EOEntity;
@class EORelationship;
@interface AdvancedRelationshipInspector : EOMInspector
{
IBOutlet NSTextField *batchSizeField;
IBOutlet NSMatrix *optionalityMatrix;
IBOutlet NSMatrix *deleteRuleMatrix;
IBOutlet NSButton *ownsDestinationSwitch;
IBOutlet NSButton *propagadePrimaryKeySwitch;
EORelationship *_currentRelation;
}
@end

View file

@ -0,0 +1,142 @@
/*
AdvancedRelationshipInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of DBModeler.
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "AdvancedRelationshipInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSArray.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation AdvancedRelationshipInspector
- (NSString *) displayName
{
return @"Advanced Relationship";
}
- (void) dealloc
{
DESTROY(_currentRelation);
[super dealloc];
}
- (EOEntity *)selectedEntity
{
NSInteger row;
return nil;
// NSInteger row = [destinationEntityBrowser selectedRow];
if ((row == -1))
return nil;
return [[[[NSApp activeDocument] eomodel] entities] objectAtIndex:row];
}
- (void) awakeFromGSMarkup
{
}
- (float) displayOrder
{
return 1;
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EORelationship class]];
}
- (void) refresh
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
ASSIGN(_currentRelation, (EORelationship *) [self selectedObject]);
[batchSizeField setIntValue:[_currentRelation numberOfToManyFaultsToBatchFetch]];
[optionalityMatrix selectCellWithTag:[_currentRelation isMandatory]];
[deleteRuleMatrix selectCellWithTag:[_currentRelation deleteRule]];
[ownsDestinationSwitch setIntValue:[_currentRelation ownsDestination]];
[propagadePrimaryKeySwitch setIntValue:[_currentRelation propagatesPrimaryKey]];
}
- (IBAction) optionalityClicked:(id)sender
{
[_currentRelation setIsMandatory:[[sender selectedCell] tag]];
}
- (IBAction) deleteRuleClicked:(id)sender
{
[_currentRelation setDeleteRule:[[sender selectedCell] tag]];
}
- (IBAction) ownsDestinationClicked:(id)sender
{
[_currentRelation setOwnsDestination:[sender intValue]];
}
- (IBAction) propagadePrimaryKeyClicked:(id)sender
{
[_currentRelation setPropagatesPrimaryKey:[sender intValue]];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
if (obj == batchSizeField) {
int batchsize = [batchSizeField intValue];
if (batchsize<1) {
batchsize = 0;
}
[_currentRelation setNumberOfToManyFaultsToBatchFetch:batchsize];
}
}
@end

View file

@ -0,0 +1,180 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window title="Inspector" width="268.0" heigth="365.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<label backgroundColor="white" selectable="no" textColor="555555">Nothing to Inspect</label>
</vbox>
</window>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<grid rowType="proportional" columnType="proportional">
<gridRow>
<label halign="right" selectable="no">Name:</label> <textField id="nameField" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<popUpButton autoenabledItems="no" target="#NSOwner" id="derivedPopUp" action="setDerived:" halign="right">
<popUpButtonItem tag="0" title="Column" />
<popUpButtonItem tag="1" title="Derived" />
</popUpButton>
<textField delegate="#NSOwner" id="extNameField" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">External Type:</label> <textField id="extTypeField" delegate="#NSOwner" />
</gridRow>
</grid>
<box title="Internal Data Type" topPadding="10" leftPadding="4" rightPadding="4" id="internalData">
<vbox>
<popUpButton target="#NSOwner" action="selectInternalDataType:" id="valueClassSelect">
<popUpButtonItem tag="0" title="String" />
<popUpButtonItem tag="1" title="Decimal Number" />
<popUpButtonItem tag="2" title="Number" />
<popUpButtonItem tag="3" title="Date" />
<popUpButtonItem tag="4" title="Data" />
<popUpButtonItem tag="5" title="Custom" />
</popUpButton>
<!-- width="254" halign="center" -->
<view id="flipView" halign="wexpand" height="180" >
<view/>
</view>
</vbox>
</box>
</vbox>
</window>
<window title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box title="Custom Flip" topPadding="10" leftPadding="15" rightPadding="15" id="customFlip">
<grid rowType="proportional" columnType="proportional">
<gridRow>
<label halign="right" selectable="no">External Width:</label> <textField id="custom_width" delegate="#NSOwner" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">Class:</label> <textField id="custom_class" delegate="#NSOwner" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">Factory Method:</label> <textField id="custom_factory" delegate="#NSOwner" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">Conversion Meth.:</label> <textField id="custom_conversion" delegate="#NSOwner" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">Init argument:</label>
<popUpButton halign="left" target="#NSOwner" action="changeLevel:" id="custom_arg">
<popUpButtonItem tag="0" title="NSData" />
<popUpButtonItem tag="1" title="NSString" />
<popUpButtonItem tag="2" title="Bytes" />
</popUpButton>
</gridRow>
</grid>
</box>
<box title="Data Flip" topPadding="10" leftPadding="15" rightPadding="15" id="dataFlip">
<grid rowType="proportional" columnType="proportional">
<gridRow>
<label halign="right" selectable="no">External Width:</label> <textField id="data_width" delegate="#NSOwner" />
</gridRow>
</grid>
</box>
<box title="String Flip" width="250.0" heigth="50" topPadding="10" leftPadding="15" rightPadding="15" id="stringFlip">
<grid rowType="proportional" columnType="proportional">
<gridRow>
<label halign="right" selectable="no">External Width:</label> <textField id="string_width" delegate="#NSOwner" />
</gridRow>
</grid>
</box>
<box title="Decimal Flip" topPadding="10" leftPadding="15" rightPadding="15" id="decimalFlip">
<vbox>
<grid rowType="proportional" columnType="proportional">
<gridRow>
<label halign="right" selectable="no">External Precision:</label> <textField id="decimal_precision" delegate="#NSOwner" />
</gridRow>
<gridRow>
<label halign="right" selectable="no">External Scale:</label> <textField id="decimal_scale" delegate="#NSOwner" />
</gridRow>
</grid>
<label color="grey">12345.67 has a precision of 7</label>
<label color="grey">and a scale of 2.</label>
</vbox>
</box>
<box title="Number Flip" topPadding="10" leftPadding="15" rightPadding="15" id="numberFlip">
<vbox>
<grid rowType="proportional">
<gridRow>
<label halign="right" selectable="no">Value Type:</label>
<popUpButton halign="left" target="#NSOwner" action="changeValueType:" id="valueTypePopUp">
<popUpButtonItem tag="0" title="int" />
<popUpButtonItem tag="1" title="double" />
<popUpButtonItem tag="2" title="float" />
<popUpButtonItem tag="3" title="char" />
<popUpButtonItem tag="4" title="short" />
<popUpButtonItem tag="5" title="unsigned int" />
<popUpButtonItem tag="6" title="unsigned char" />
<popUpButtonItem tag="7" title="unsigned short" />
<popUpButtonItem tag="8" title="long" />
<popUpButtonItem tag="9" title="unsigned long" />
<popUpButtonItem tag="10" title="long long" />
<popUpButtonItem tag="11" title="uns. long long" />
</popUpButton>
</gridRow>
</grid>
<vbox>
<label textColor="red">Never use float or double for</label>
<label textColor="red">monetary values as rounding will</label>
<label textColor="red">lead to non-expected results.</label>
</vbox>
</vbox>
</box>
<box title="Date Flip" topPadding="10" leftPadding="15" rightPadding="15" id="dateFlip">
<vbox>
<label textColor="red">Nothing here right now.</label>
</vbox>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#derivedPopUp" key="derivedPopUp"/>
<outlet source="#NSOwner" target="#nameField" key="nameField"/>
<outlet source="#NSOwner" target="#extNameField" key="extNameField"/>
<outlet source="#NSOwner" target="#extTypeField" key="extTypeField"/>
<outlet source="#NSOwner" target="#internalData" key="internalData"/>
<outlet source="#NSOwner" target="#customFlip" key="customFlip"/>
<outlet source="#NSOwner" target="#decimalFlip" key="decimalFlip"/>
<outlet source="#NSOwner" target="#data_width" key="data_width"/>
<outlet source="#NSOwner" target="#dataFlip" key="dataFlip"/>
<outlet source="#NSOwner" target="#stringFlip" key="stringFlip"/>
<outlet source="#NSOwner" target="#valueClassSelect" key="valueClassSelect"/>
<outlet source="#NSOwner" target="#flipView" key="flipView"/>
<outlet source="#NSOwner" target="#decimal_scale" key="decimal_scale"/>
<outlet source="#NSOwner" target="#decimal_precision" key="decimal_precision"/>
<outlet source="#NSOwner" target="#string_width" key="string_width"/>
<outlet source="#NSOwner" target="#numberFlip" key="numberFlip"/>
<outlet source="#NSOwner" target="#valueTypePopUp" key="valueTypePopUp"/>
<outlet source="#NSOwner" target="#dateFlip" key="dateFlip"/>
<outlet source="#NSOwner" target="#custom_width" key="custom_width"/>
<outlet source="#NSOwner" target="#custom_class" key="custom_class"/>
<outlet source="#NSOwner" target="#custom_factory" key="custom_factory"/>
<outlet source="#NSOwner" target="#custom_conversion" key="custom_conversion"/>
<outlet source="#NSOwner" target="#custom_arg" key="custom_arg"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,99 @@
/*
AttributesInspector.h
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSBox.h>
#include <AppKit/NSTextField.h>
#include <AppKit/NSPopUpButton.h>
#include <AppKit/NSNibDeclarations.h>
#endif
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSDictionary.h>
#endif
@interface AttributeInspector : EOMInspector
{
IBOutlet NSTextField *_extNameField;
IBOutlet NSTextField *_extTypeField;
IBOutlet NSPopUpButton *_derivedPopUp; // or column
IBOutlet NSPopUpButton *_valueClassSelect;
IBOutlet NSPopUpButton *_valueTypePopUp; // int, float, ...
IBOutlet NSPopUpButton *_flipSelect;// select which valueClassName/flip
IBOutlet NSBox *_flipView; // gets replaced with a *Flip...
IBOutlet NSBox *_internalData;
IBOutlet NSBox *_numberFlip; // to edit number properties
IBOutlet NSTextField *_nameField;
IBOutlet NSBox *_customFlip; // default
IBOutlet NSBox *_dataFlip;
IBOutlet NSBox *_dateFlip;
IBOutlet NSBox *_decimalFlip;
IBOutlet NSBox *_stringFlip;
IBOutlet NSTextField *_custom_width;
IBOutlet NSTextField *_custom_class;
IBOutlet NSTextField *_custom_factory;
IBOutlet NSTextField *_custom_conversion;
IBOutlet NSPopUpButton *_custom_arg;
IBOutlet NSTextField *_string_width;
IBOutlet NSTextField *_decimal_precision;
IBOutlet NSTextField *_decimal_scale;
IBOutlet NSTextField *_data_width;
IBOutlet NSButton *_date_tz;
NSDictionary *_flipDict;
NSDictionary *_classTitleDict;
NSDictionary *_valueTypeDict;
}
/* generic */
- (IBAction) selectInternalDataType:(id)sender;
- (IBAction) setName:(id)sender;
- (IBAction) setExternalName:(id)sender;
- (IBAction) setExternalType:(id)sender;
/* dependent on value class name */
- (IBAction) setWidth:(id)sender;
- (IBAction) setPrecision:(id)sender;
- (IBAction) setClassName:(id)sender;
- (IBAction) setFactoryMethod:(id)sender;
- (IBAction) setConversionMethod:(id)sender;
- (IBAction) setValueType:(id)sender;
- (IBAction) setTimeZone:(id)sender;
@end

View file

@ -0,0 +1,507 @@
/*
AttributesInspector.m
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "AttributeInspector.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSObjCRuntime.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
#define NO_ZEROS(x, i) i ? [x setIntValue:i] : [x setStringValue:@""];
@implementation AttributeInspector
- (void) awakeFromGSMarkup //awakeFromNib
{
RETAIN(_internalData);
_flipDict =
[[NSDictionary alloc] initWithObjectsAndKeys:
[_stringFlip contentView], @"NSString",
[_customFlip contentView], @"Custom",
[_dataFlip contentView], @"NSData",
[_dateFlip contentView], @"NSCalendarDate",
[_decimalFlip contentView], @"NSDecimalNumber",
[_numberFlip contentView], @"NSNumber",
nil];
_valueTypeDict =
[[NSDictionary alloc] initWithObjectsAndKeys:
@"i", @"int",
@"d", @"double",
@"f", @"float",
@"c", @"char",
@"s", @"short",
@"I", @"unsigned int",
@"C", @"unsigned char",
@"S", @"unsigned short",
@"l", @"long",
@"L", @"unsigned long",
@"u", @"long long",
@"U", @"unsigned long long",
@"char", @"c",
@"unsigned char", @"C",
@"short", @"s",
@"unsigned short", @"S",
@"int", @"i",
@"unsigned int", @"I",
@"long", @"l",
@"unsigned long", @"L",
@"long long", @"u",
@"unsigned long long", @"U",
@"float", @"f",
@"double", @"d",
nil];
_classTitleDict =
[[NSDictionary alloc] initWithObjectsAndKeys:
@"0", @"NSString",
@"1", @"NSDecimalNumber",
@"2", @"NSNumber",
@"3", @"NSCalendarDate",
@"4", @"NSData",
nil];
}
- (NSString *) displayName
{
return @"Attribute";
}
- (NSString *) _titleForPopUp
{
NSString *vcn = [(EOAttribute *)[self selectedObject] valueClassName];
NSString *ret;
ret = [_classTitleDict objectForKey:vcn];
if (!ret)
return @"Custom";
return ret;
}
- (NSString *)_classNameForTitle:(NSString *)title
{
return [_classTitleDict objectForKey:title];
}
- (NSBox *) _viewForTitle:(NSString *)title
{
NSBox * myview = [_flipDict objectForKey:title];
if (!myview) {
myview = [_flipDict objectForKey:@"Custom"];
}
return myview;
}
- (float) displayOrder
{
return 0;
}
- (IBAction) setName:(id)sender;
{
[(EOAttribute *)[self selectedObject] setName:[sender stringValue]];
}
- (IBAction) setExternalName:(id)sender;
{
[(EOAttribute *)[self selectedObject] setColumnName:[sender stringValue]];
}
- (IBAction) setExternalType:(id)sender;
{
[(EOAttribute *)[self selectedObject] setExternalType:[sender stringValue]];
}
- (IBAction) selectInternalDataType:(id)sender;
{
EOAttribute *attr = [self selectedObject];
switch ([[sender selectedItem] tag]) {
case 0:
[attr setValueClassName:@"NSString"];
break;
case 1:
[attr setValueClassName:@"NSDecimalNumber"];
break;
case 2:
[attr setValueClassName:@"NSNumber"];
break;
case 3:
[attr setValueClassName:@"NSCalendarDate"];
break;
case 4:
[attr setValueClassName:@"NSData"];
break;
case 5:
[attr setValueClassName:@"Custom"];
break;
default:
break;
}
[self refresh];
}
- (void) putSubViewBack
{
NSView * subView = nil;
if ([[_flipView subviews] count] > 0) {
subView = [[_flipView subviews] objectAtIndex:0];
[subView removeFromSuperviewWithoutNeedingDisplay];
}
}
- (IBAction) changeValueType:(NSPopUpButton*) sender
{
EOAttribute * attr = [self selectedObject];
switch ([[sender selectedItem] tag]) {
case 0: /* int */
[attr setValueType:@"i"];
break;
case 1: /* double */
[attr setValueType:@"d"];
break;
case 2: /* float */
[attr setValueType:@"f"];
break;
case 3: /* char */
[attr setValueType:@"c"];
break;
case 4: /* short */
[attr setValueType:@"s"];
break;
case 5: /* unsigned int */
[attr setValueType:@"I"];
break;
case 6: /* unsigned char */
[attr setValueType:@"C"];
break;
case 7: /* unsigned short */
[attr setValueType:@"S"];
break;
case 8: /* long */
[attr setValueType:@"l"];
break;
case 9: /* unsigned long */
[attr setValueType:@"L"];
break;
case 10: /* long long */
[attr setValueType:@"u"];
break;
case 11: /* unsigned long long */
[attr setValueType:@"U"];
break;
default:
break;
}
}
- (void) _updateValueTypePopUpWithAttribute:(EOAttribute*) attr
{
NSString *valueType = [attr valueType];
unichar valueTypeChar;
if ((valueType) && ([valueType length])) {
valueTypeChar = [valueType characterAtIndex:0];
} else {
return;
}
NSInteger tagValue = 0;
switch (valueTypeChar) {
case 'i':
tagValue = 0;
break;
case 'd':
tagValue = 1;
break;
case 'f':
tagValue = 2;
break;
case 'c':
tagValue = 3;
break;
case 's':
tagValue = 4;
break;
case 'I':
tagValue = 5;
break;
case 'C':
tagValue = 6;
break;
case 'S':
tagValue = 7;
break;
case 'l':
tagValue = 8;
break;
case 'L':
tagValue = 9;
break;
case 'u':
tagValue = 10;
break;
case 'U':
tagValue = 11;
break;
default:
break;
}
[_valueTypePopUp selectItemWithTag:tagValue];
}
- (void) _updateStringViewWithAttribute:(EOAttribute*) attr
{
NO_ZEROS(_string_width, [attr width]);
}
- (void) _updateDecimalNumberViewWithAttribute:(EOAttribute*) attr
{
NO_ZEROS(_decimal_scale, [attr scale]);
NO_ZEROS(_decimal_precision, [attr precision]);
}
- (void) _updateDataViewWithAttribute:(EOAttribute*) attr
{
NO_ZEROS(_data_width, [attr width]);
}
- (void) _updateCustomViewWithAttribute:(EOAttribute*) attr
{
NSString * tmpStr = nil;
NO_ZEROS(_custom_width, [attr width]);
[_custom_class setStringValue:[attr valueClassName]];
tmpStr = [attr valueFactoryMethodName];
if (!tmpStr) {
[attr setValueFactoryMethodName:@""];
}
tmpStr = [attr adaptorValueConversionMethodName];
if (!tmpStr) {
[attr setAdaptorValueConversionMethodName:@""];
}
[_custom_factory setStringValue:[attr valueFactoryMethodName]];
[_custom_conversion setStringValue:[attr adaptorValueConversionMethodName]];
[_custom_arg selectItemWithTag:[attr factoryMethodArgumentType]];
}
- (void) _updateValueClassPopUpWithAttribute:(EOAttribute*) attr
{
NSString * tagString = [_classTitleDict objectForKey:[attr valueClassName]];
NSInteger tagValue = 0;
if (!tagString) {
tagValue = 5; // custom
[self _updateCustomViewWithAttribute:attr];
} else {
tagValue = [tagString integerValue];
switch (tagValue) {
case 0: // NSString
[self _updateStringViewWithAttribute:attr];
break;
case 1: // NSDecimalNumber
[self _updateDecimalNumberViewWithAttribute:attr];
break;
case 2: // NSNumber
[self _updateValueTypePopUpWithAttribute:attr];
break;
case 3: // NSCalendarDate
// nothing for now
break;
case 4: // NSData
[self _updateDataViewWithAttribute:attr];
break;
default:
break;
}
}
[_valueClassSelect selectItemWithTag:tagValue];
}
- (void) refresh
{
EOAttribute *obj = [self selectedObject];
NSString *title = [obj valueClassName];
NSBox *flipTo = [self _viewForTitle:title];
[_nameField setStringValue:[obj name]];
[_extNameField setStringValue:[obj columnName]];
[_extTypeField setStringValue:[obj externalType]];
if ([obj isDerived]) {
[_derivedPopUp selectItemWithTag:1];
} else {
[_derivedPopUp selectItemWithTag:0];
}
[self putSubViewBack];
[_flipView setNeedsDisplay:YES];
[_flipView addSubview:flipTo];
[self _updateValueClassPopUpWithAttribute:obj];
}
- (void) updateNumber
{
EOAttribute *obj = [self selectedObject];
NSString *valType = [obj valueType];
NSString *valueTypeName;
valueTypeName = [_valueTypeDict objectForKey: valType];
[_valueClassSelect selectItemWithTitle:valueTypeName];
}
- (BOOL) canInspectObject:(id)obj
{
return [obj isKindOfClass:[EOAttribute class]];
}
- (IBAction) setValueType:(id)sender
{
EOAttribute *obj = [self selectedObject];
NSString *valueType = nil;
[obj setValueType:valueType];
}
- (IBAction) setDerived:(id)sender
{
NSLog(@"%s:%@",__PRETTY_FUNCTION__, sender);
// EOAttribute *obj = [self selectedObject];
// if ([sender tag] == 0) { // Column
// [obj setIsDerived:NO];
// } else {
// [obj setIsDerived:YES];
// }
}
- (IBAction) setTimeZone:(id)sender;
{
// fixme
}
- (IBAction) changeLevel:(id)sender;
{
[(EOAttribute *)[self selectedObject] setFactoryMethodArgumentType:[[sender selectedItem] tag]];
}
- (IBAction) setWidth:(id)sender;
{
[(EOAttribute *)[self selectedObject] setWidth:[sender intValue]];
}
- (IBAction) setPrecision:(id)sender;
{
[(EOAttribute *)[self selectedObject] setPrecision:[sender intValue]];
}
- (IBAction) setScale:(id)sender;
{
[(EOAttribute *)[self selectedObject] setScale:[sender intValue]];
}
- (IBAction) setClassName:(id)sender;
{
[(EOAttribute *)[self selectedObject] setValueClassName:[sender stringValue]];
}
- (IBAction) setFactoryMethod:(id)sender;
{
[[self selectedObject] setValueFactoryMethodName:[sender stringValue]];
}
- (IBAction) setConversionMethod:(id)sender;
{
[[self selectedObject] setAdaptorValueConversionMethodName:[sender stringValue]];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
if (obj == _extNameField)
[self setExternalName:_extNameField];
else if (obj == _extTypeField)
[self setExternalType:_extTypeField];
else if (obj == _nameField)
[self setName:_nameField];
else if (obj == _custom_width
|| obj == _data_width
|| obj == _string_width)
[self setWidth:obj];
else if (obj == _decimal_scale)
[self setScale:obj];
else if (obj == _decimal_precision)
[self setPrecision:_decimal_precision];
else if (obj == _custom_class)
[self setClassName:_custom_class];
else if (obj == _custom_factory)
[self setFactoryMethod:_custom_factory];
else if (obj == _custom_conversion)
[self setConversionMethod:_custom_conversion];
}
@end

Binary file not shown.

View file

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<splitView vertical="no" autosaveName="verticalsplit">
<vbox>
<scrollView height="220" hasHorizontalScroller="no">
<tableView id="tableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="no" allowsColumnSelection="no">
<tableColumn identifier="key" title="Key" minWidth="100"/>
<tableColumn editable="yes" identifier="value" title="Value" minWidth="100"/>
</tableView>
</scrollView>
</vbox>
<vbox>
<scrollView height="100" hasHorizontalScroller="no">
<textView id="textView">
</textView>
</scrollView>
</vbox>
</splitView>
<grid>
<gridRow>
<button title="Add" target="#NSOwner" action="add:"/>
<button title="Remove" target="#NSOwner" action="remove:"/>
</gridRow>
</grid>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#tableView" key="tableView"/>
<outlet source="#NSOwner" target="#textView" key="textView"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,48 @@
/*
ConnectionDictionaryInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/AppKit.h>
#endif
@class EOAttribute;
@class TableViewController;
@interface ConnectionDictionaryInspector : EOMInspector
{
IBOutlet NSTableView *_tableView;
IBOutlet NSTextView *_textView;
NSMutableArray *_dataArray;
TableViewController *_tableViewController;
NSMutableDictionary *_selectedDict;
}
- (void) commitChanges;
@end

View file

@ -0,0 +1,224 @@
/*
ConnectionDictionaryInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ConnectionDictionaryInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#include <Foundation/Foundation.h>
#import "../TableViewController.h"
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation ConnectionDictionaryInspector
- (NSString *) displayName
{
return @"Connection Dictionary";
}
- (void) dealloc
{
DESTROY(_dataArray);
DESTROY(_tableViewController);
DESTROY(_selectedDict);
[super dealloc];
}
- (void) awakeFromGSMarkup
{
_tableViewController = [TableViewController new];
[_tableView setDataSource:_tableViewController];
[_tableView setDelegate:_tableViewController];
[_textView setRichText:NO];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewSelectionDidChange:)
name:NSTableViewSelectionDidChangeNotification
object:_tableView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:_textView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableViewDataDidChange:)
name:TableViewDataHasChangedNotification
object:_tableViewController];
}
- (float) displayOrder
{
return 1;
}
- (BOOL) canInspectObject:(id)anObject
{
BOOL weCan = [anObject isKindOfClass:[EOModel class]];
return weCan;
}
- (void) commitChanges
{
NSMutableDictionary * mDict = [NSMutableDictionary dictionary];
if ((_dataArray) && ([_dataArray count])) {
NSEnumerator * aEnumer = [_dataArray objectEnumerator];
NSDictionary * myDict = nil;
while ((myDict = [aEnumer nextObject])) {
[mDict setObject:[myDict objectForKey:@"value"]
forKey:[myDict objectForKey:@"key"]];
}
}
[(EOModel *)[self selectedObject] setConnectionDictionary:mDict];
}
- (void) setDataFromDictionary:(NSDictionary*) aDictionary
{
NSEnumerator * keyEnumer;
NSString * currentKey;
DESTROY(_dataArray);
_dataArray = [NSMutableArray array];
RETAIN(_dataArray);
// make sure we are using ordered keys.
keyEnumer = [[[aDictionary allKeys] sortedArrayUsingSelector:@selector(compare:)] objectEnumerator];
while ((currentKey = [keyEnumer nextObject])) {
NSMutableDictionary * mDict;
mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[aDictionary objectForKey:currentKey], @"value",
currentKey,@"key", nil];
[_dataArray addObject:mDict];
}
[_tableViewController setRepresentedObject:_dataArray];
[_tableView reloadData];
[_textView setString:@""];
}
- (void) refresh
{
[self setDataFromDictionary:[(EOModel *)[self selectedObject] connectionDictionary]];
DESTROY(_selectedDict);
}
- (void) textDidChange:(NSNotification *)notif
{
id obj = [notif object];
if (_selectedDict) {
if ((obj == _textView)) {
// I dont know why that stringWithString is needed here,
// but it seems to fix an OSX bug that messes up values -- dw
[_selectedDict setObject:[NSString stringWithString:[_textView string]]
forKey:@"value"];
[_tableView reloadData];
[self commitChanges];
}
}
}
- (IBAction) add:(id) sender
{
NSMutableDictionary * mDict;
NSUInteger aCount = [_dataArray count];
mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"newValue", @"value",
[NSString stringWithFormat:@"newKey%d", aCount],@"key", nil];
[_dataArray addObject:mDict];
[_tableView reloadData];
}
- (IBAction) remove:(id) sender
{
[_dataArray removeObjectsInArray:[_tableViewController selectedObjects]];
[_tableView reloadData];
[self commitChanges];
}
- (IBAction) tableViewClicked:(id) sender
{
}
- (void)tableViewSelectionDidChange:(NSNotification *) notification
{
NSArray * selectedObjects = nil;
selectedObjects = [_tableViewController selectedObjects];
if ([selectedObjects count] > 0) {
NSMutableDictionary * dict = [selectedObjects objectAtIndex:0];
NSString * value = [dict objectForKey:@"value"];
ASSIGN(_selectedDict, dict);
[_textView setString:(value) ? value : @""];
} else {
DESTROY(_selectedDict);
}
}
- (void) tableViewDataDidChange: (NSNotification*) notification
{
NSDictionary * userInfo = [notification userInfo];
if ([[userInfo objectForKey:@"keyPath"] isEqual:@"value"]) {
[_textView setString:[userInfo objectForKey:@"newValue"]];
}
[self commitChanges];
}
@end

View file

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box title="Names" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<label halign="right" selectable="no">Name:</label>
<textField id="nameField" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Table Name:</label>
<textField id="tableNameField" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Class:</label>
<textField id="classNameField" delegate="#NSOwner"></textField>
</gridRow>
</grid>
</box>
<box title="Properties" topPadding="10" leftPadding="4" rightPadding="4" height="250" width="260">
<label font="small" halign="center" selectable="no">Not in this version</label>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#nameField" key="nameField"/>
<outlet source="#NSOwner" target="#tableNameField" key="tableNameField"/>
<outlet source="#NSOwner" target="#classNameField" key="classNameField"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,42 @@
/*
EntityInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#include <AppKit/AppKit.h>
@class EOModel;
@class EOEntity;
@class EORelationship;
@interface EntityInspector : EOMInspector
{
IBOutlet NSTextField *nameField;
IBOutlet NSTextField *tableNameField;
IBOutlet NSTextField *classNameField;
EOEntity *_currentEntity;
}
@end

View file

@ -0,0 +1,121 @@
/*
EntityInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "EntityInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSArray.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation EntityInspector
- (NSString *) displayName
{
return @"Entity";
}
- (void) dealloc
{
DESTROY(_currentEntity);
[super dealloc];
}
- (EOEntity *)selectedEntity
{
NSInteger row;
return nil;
// NSInteger row = [destinationEntityBrowser selectedRow];
if ((row == -1))
return nil;
return [[[[NSApp activeDocument] eomodel] entities] objectAtIndex:row];
}
- (void) awakeFromGSMarkup
{
}
- (float) displayOrder
{
return 1;
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EOEntity class]];
}
- (void) refresh
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
ASSIGN(_currentEntity, (EOEntity *) [self selectedObject]);
[nameField setStringValue:[_currentEntity name]];
[tableNameField setStringValue:[_currentEntity externalName]];
[classNameField setStringValue:[_currentEntity className]];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
if (obj == nameField) {
[_currentEntity setName:[nameField stringValue]];
return;
}
if (obj == tableNameField) {
[_currentEntity setExternalName:[tableNameField stringValue]];
return;
}
if (obj == classNameField) {
[_currentEntity setClassName:[classNameField stringValue]];
return;
}
}
@end

Binary file not shown.

View file

@ -0,0 +1,52 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box topPadding="4" bottomPadding="200" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<label halign="right" selectable="no">Insert:</label>
<textField id="insertField" delegate="#NSOwner"
toolTip="Name of procedure to insert a record."></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Delete:</label>
<textField id="deleteField" delegate="#NSOwner"
toolTip="Name of procedure to delete a record."></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Fetch All:</label>
<textField id="fetchAllField" delegate="#NSOwner"
toolTip="Name of procedure to fetch all records."></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Fetch w/PK:</label>
<textField id="fetchWithPKField" delegate="#NSOwner"
toolTip="Name of procedure to fetch by primary key."></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">Get PK:</label>
<textField id="pkGetField" delegate="#NSOwner"
toolTip="Name of procedure to generate a new primary key."></textField>
</gridRow>
</grid>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#insertField" key="insertField"/>
<outlet source="#NSOwner" target="#deleteField" key="deleteField"/>
<outlet source="#NSOwner" target="#fetchAllField" key="fetchAllField"/>
<outlet source="#NSOwner" target="#fetchWithPKField" key="fetchWithPKField"/>
<outlet source="#NSOwner" target="#pkGetField" key="pkGetField"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,42 @@
/*
EntityStoredProcedureInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#include <AppKit/AppKit.h>
@class EOEntity;
@interface EntityStoredProcedureInspector : EOMInspector
{
IBOutlet NSTextField *_insertField;
IBOutlet NSTextField *_deleteField;
IBOutlet NSTextField *_fetchAllField;
IBOutlet NSTextField *_fetchWithPKField;
IBOutlet NSTextField *_pkGetField;
EOEntity *_currentEntity;
}
@end

View file

@ -0,0 +1,142 @@
/*
EntityStoredProcedureInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "EntityStoredProcedureInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#include <Foundation/Foundation.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation EntityStoredProcedureInspector
- (NSString *) displayName
{
return @"Stored Procedure";
}
- (void) dealloc
{
DESTROY(_currentEntity);
[super dealloc];
}
- (void) awakeFromGSMarkup
{
}
- (float) displayOrder
{
return 4;
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EOEntity class]];
}
/*
EOModel storedProcedureNamed:
(NSArray *)storedProcedureNames
EOStoredProcedure name
*/
- (void) refresh
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
NSString *tmpStr;
ASSIGN(_currentEntity, (EOEntity *) [self selectedObject]);
tmpStr = [[_currentEntity storedProcedureForOperation:EOInsertProcedureOperation] name];
[_insertField setStringValue:(tmpStr != nil) ? tmpStr : @""];
tmpStr = [[_currentEntity storedProcedureForOperation:EODeleteProcedureOperation] name];
[_deleteField setStringValue:(tmpStr != nil) ? tmpStr : @""];
tmpStr = [[_currentEntity storedProcedureForOperation:EOFetchAllProcedureOperation] name];
[_fetchAllField setStringValue:(tmpStr != nil) ? tmpStr : @""];
tmpStr = [[_currentEntity storedProcedureForOperation:EOFetchWithPrimaryKeyProcedureOperation] name];
[_fetchWithPKField setStringValue:(tmpStr != nil) ? tmpStr : @""];
tmpStr = [[_currentEntity storedProcedureForOperation:EONextPrimaryKeyProcedureOperation] name];
[_pkGetField setStringValue:(tmpStr != nil) ? tmpStr : @""];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
NSString * tmpStr = [obj stringValue];
EOModel * model = [_currentEntity model];
EOStoredProcedure * sProc = [model storedProcedureNamed:tmpStr];
if (obj == _insertField) {
[_currentEntity setStoredProcedure:sProc
forOperation:EOInsertProcedureOperation];
return;
}
if (obj == _deleteField) {
[_currentEntity setStoredProcedure:sProc
forOperation:EODeleteProcedureOperation];
return;
}
if (obj == _fetchAllField) {
[_currentEntity setStoredProcedure:sProc
forOperation:EOFetchAllProcedureOperation];
return;
}
if (obj == _fetchWithPKField) {
[_currentEntity setStoredProcedure:sProc
forOperation:EOFetchWithPrimaryKeyProcedureOperation];
return;
}
if (obj == _pkGetField) {
[_currentEntity setStoredProcedure:sProc
forOperation:EONextPrimaryKeyProcedureOperation];
return;
}
}
@end

View file

@ -0,0 +1,71 @@
#
# DBModeler/Inspectors makefile for GNUstep Database Library.
#
# Copyright (C) 2005,2006 Free Software Foundation, Inc.
#
# Author: Matt Rice <ratmice@gmail.com>
#
# This file is part of the GNUstep Database Library.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
include ../../../common.make
include $(GNUSTEP_MAKEFILES)/common.make
SUBPROJECT_NAME=Inspectors
ADDITIONAL_INCLUDE_DIRS+=-I../../
Inspectors_NEEDS_GUI=yes
Inspectors_HAS_RESOURCE_BUNDLE=yes
Inspectors_RESOURCE_FILES+= \
RelationshipInspector.gsmarkup \
RelationshipInspector.tiff \
EntityInspector.tiff \
AdvancedRelationshipInspector.tiff \
AttributeInspector.tiff \
AdvancedAttributeInspector.tiff \
AdvancedEntityInspector.tiff \
StoredProcedureInspector.tiff \
ConnectionDictionaryInspector.tiff \
UserInfoInspector.tiff
Inspectors_OBJC_FILES+=RelationshipInspector.m
Inspectors_RESOURCE_FILES+=AttributeInspector.gsmarkup \
AdvancedRelationshipInspector.gsmarkup \
AdvancedEntityInspector.gsmarkup \
EntityInspector.gsmarkup \
AdvancedAttributeInspector.gsmarkup \
StoredProcedureInspector.gsmarkup \
ConnectionDictionaryInspector.gsmarkup \
UserInfoInspector.gsmarkup \
EntityStoredProcedureInspector.gsmarkup
Inspectors_OBJC_FILES+=AttributeInspector.m
Inspectors_OBJC_FILES+=AdvancedEntityInspector.m \
AdvancedRelationshipInspector.m \
EntityInspector.m \
AdvancedAttributeInspector.m \
StoredProcedureInspector.m \
ConnectionDictionaryInspector.m \
UserInfoInspector.m \
EntityStoredProcedureInspector.m
include $(GNUSTEP_MAKEFILES)/subproject.make

View file

@ -0,0 +1,80 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<grid>
<gridRow>
<hbox leftPadding="4" rightPadding="4" topPadding="4">
<label halign="right" selectable="no">Name:</label> <textField id="name_textField" delegate="#NSOwner"></textField>
</hbox>
</gridRow>
</grid>
<box title="Destination" topPadding="10" leftPadding="4" rightPadding="4" width="260" id="xxx">
<grid>
<gridRow>
<label halign="right" selectable="no">Model:</label>
<popUpButton autoenabledItems="no" target="#NSOwner" id="model_popup" action="connectionChanged:" halign="right">
<popUpButtonItem tag="0" title="FOOBAR" />
</popUpButton>
</gridRow>
<gridRow>
<vbox halign="right">
<label halign="right" selectable="no">Entity:</label>
<matrix type="radio" autoenabledItems="no" target="#NSOwner" action="cardinalityChanged:" id="joinCardinality_matrix">
<matrixRow><matrixCell tag="0" title="To One" /></matrixRow>
<matrixRow><matrixCell tag="1" title="To Many" /></matrixRow>
</matrix>
<popUpButton autoenabledItems="no" target="#NSOwner" id="joinSemantic_popup" action="joinChanged:" halign="right">
<popUpButtonItem tag="0" title="Inner" />
<popUpButtonItem tag="1" title="Full Outer" />
<popUpButtonItem tag="2" title="Left Outer" />
<popUpButtonItem tag="3" title="Right Outer" />
</popUpButton>
</vbox>
<vbox halign="left">
<browser id="destinationEntityBrowser" delegate="#NSOwner" maxVisibleColumns="1"
allowsEmptySelection="no" target="#NSOwner" action="destinationEntityBrowserClicked:">
</browser>
</vbox>
</gridRow>
</grid>
</box>
<box title="Joins" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<grid width="244">
<gridRow><label selectable="no">Source</label> <label selectable="no">Destination</label></gridRow>
<gridRow>
<browser width="110" height="70" id="sourceBrowser" action="sourceBrowserClicked:" delegate="#NSOwner"
target="#NSOwner" maxVisibleColumns="1" allowsEmptySelection="no"/>
<browser width="110" height="70" id="destBrowser" action="destBrowserClicked:" delegate="#NSOwner"
target="#NSOwner" maxVisibleColumns="1" allowsEmptySelection="no"/>
</gridRow>
<gridRow>
<gridEmptyCell /><button id="connectButton" type="toggle" halign="right" title="Connect"
alternateTitle="Disconnect"
target="#NSOwner" action="connectButtonClicked:" />
</gridRow>
</grid>
</box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#model_popup" key="model_popup"/>
<outlet source="#NSOwner" target="#name_textField" key="name_textField"/>
<outlet source="#NSOwner" target="#joinCardinality_matrix" key="joinCardinality_matrix"/>
<outlet source="#NSOwner" target="#joinSemantic_popup" key="joinSemantic_popup"/>
<outlet source="#NSOwner" target="#destinationEntityBrowser" key="destinationEntityBrowser"/>
<outlet source="#NSOwner" target="#sourceBrowser" key="sourceBrowser"/>
<outlet source="#NSOwner" target="#destBrowser" key="destBrowser"/>
<outlet source="#NSOwner" target="#connectButton" key="connectButton"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,58 @@
/*
RelationshipInspector.h
Author: Matt Rice <ratmice@gmail.com>
Date: Apr 2005
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/AppKit.h>
#endif
@class EOModel;
@class EOEntity;
@class EORelationship;
@interface RelationshipInspector : EOMInspector
{
IBOutlet NSTextField *name_textField;
IBOutlet NSPopUpButton *model_popup;
IBOutlet NSMatrix *joinCardinality_matrix;
IBOutlet NSPopUpButton *joinSemantic_popup;
IBOutlet NSBrowser *destinationEntityBrowser;
IBOutlet NSBrowser *sourceBrowser;
IBOutlet NSBrowser *destBrowser;
IBOutlet NSButton *connectButton;
NSArray *_attributes;
NSImage *_dimpleImg;
NSImage *_noDimpleImg;
EORelationship *_currentRelation;
}
- (IBAction) connectButtonClicked:(id)sender;
- (IBAction) nameChanged:(id)sender;
@end

View file

@ -0,0 +1,423 @@
/*
RelationshipInspector.m
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "RelationshipInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSArray.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation RelationshipInspector
- (NSString *) displayName
{
return @"Relationship";
}
- (void) dealloc
{
DESTROY(_attributes);
DESTROY(_dimpleImg);
DESTROY(_noDimpleImg);
DESTROY(_currentRelation);
[super dealloc];
}
//- (EOEntity *)selectedEntity
//{
// NSInteger row;
// return nil;
//
// if ((row == -1))
// return nil;
//
// return [[[[NSApp activeDocument] eomodel] entities] objectAtIndex:row];
//}
//
- (void) awakeFromGSMarkup
{
[destinationEntityBrowser setAllowsEmptySelection:NO];
[sourceBrowser setAllowsEmptySelection:NO];
// [destAttrib_tableView setAllowsEmptySelection:NO];
ASSIGN(_dimpleImg, [NSImage imageNamed:@"dimple"]);
ASSIGN(_noDimpleImg, [NSImage imageNamed:@"nodimple"]);
}
- (float) displayOrder
{
return 0;
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EORelationship class]];
}
- (void) refresh
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
// EORelationship * relation = (EORelationship *) [self selectedObject];
EOEntity *destEntity;
EOAttribute *srcAttrib, *destAttrib;
NSArray *joins;
NSInteger row = 0;
if (_attributes) {
DESTROY(_attributes);
}
ASSIGN(_currentRelation, (EORelationship *) [self selectedObject]);
[name_textField setStringValue:[_currentRelation name]];
[sourceBrowser loadColumnZero];
[destBrowser loadColumnZero];
[destinationEntityBrowser loadColumnZero];
destEntity = [[self selectedObject] destinationEntity];
if (destEntity)
{
NSUInteger idx = [[activeModel entities] indexOfObject:destEntity];
if (idx != NSNotFound) {
[destinationEntityBrowser selectRow:idx
inColumn:0];
[destinationEntityBrowser setEnabled:NO];
}
} else {
[destinationEntityBrowser setEnabled:YES];
}
joins = [_currentRelation joins];
if ([joins count])
{
EOJoin *join = [joins objectAtIndex:0];
srcAttrib = [join sourceAttribute];
destAttrib = [join destinationAttribute];
[connectButton setEnabled:NO];
[joinCardinality_matrix selectCellWithTag:[[self selectedObject] isToMany]];
[joinSemantic_popup selectItemWithTag: [_currentRelation joinSemantic]];
}
}
- (IBAction) connectButtonClicked:(id)sender
{
NSString *srcName = [[sourceBrowser selectedCell] title];
EOJoin *join;
if ([sender state] == NSOnState)
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
NSString *dstName = [[destBrowser selectedCell] title];
NSString *dstEntityName = [[destinationEntityBrowser selectedCell] title];
EOAttribute *srcAttrib = [[_currentRelation entity] attributeNamed:srcName];
EOAttribute *destAttrib = [[activeModel entityNamed:dstEntityName] attributeNamed:dstName];
join = [[EOJoin alloc] initWithSourceAttribute:srcAttrib
destinationAttribute:destAttrib];
[_currentRelation addJoin:join];
[join release];
} else {
// disconnect
join = [_currentRelation joinFromAttributeNamed:srcName];
[_currentRelation removeJoin:join];
}
[destBrowser loadColumnZero];
[sourceBrowser loadColumnZero];
}
- (void) nameChanged:(id)sender
{
NSString *name = [name_textField stringValue];
[(EORelationship *)[self selectedObject] setName:name];
}
- (void) joinChanged:(id)sender
{
/* the tag in the nib must match the values in the EOJoinSemantic enum */
[(EORelationship *)[self selectedObject] setJoinSemantic: [[sender selectedItem] tag]];
}
- (void) cardinalityChanged:(id)sender
{
/* the tag in the nib for to-one must be 0 to-many 1 */
[(EORelationship *) [self selectedObject] setToMany: [[sender selectedCell] tag]];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id sender = [notif object];
if (sender == name_textField)
[self nameChanged:sender];
}
- (NSArray*) attributes
{
if (!_attributes) {
_attributes = [[[[self selectedObject] entity] attributes] retain];
}
return _attributes;
}
#pragma mark -
#pragma mark browser
- (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column
{
NSInteger intVal = 0;
EOModel *activeModel = nil;
if ((sender == destinationEntityBrowser)) {
activeModel = [[NSApp activeDocument] eomodel];
return [[activeModel entityNames] count];
}
if ((sender == sourceBrowser)) {
EOEntity * selectedEntity = [_currentRelation entity];
NSArray * attributes = [selectedEntity attributes];
return [attributes count];
}
if ((sender == destBrowser)) {
EOEntity * destinationEntity = [_currentRelation destinationEntity];
NSArray * dstAttributes = nil;
if (!destinationEntity) {
NSString * name = [[destinationEntityBrowser selectedCell] title];
activeModel = [[NSApp activeDocument] eomodel];
destinationEntity = [activeModel entityNamed:name];
}
dstAttributes = [destinationEntity attributes];
return [dstAttributes count];
}
return 0;
}
- (void)browser:(NSBrowser *)sender willDisplayCell:(NSBrowserCell *)cell atRow:(NSInteger)row column:(NSInteger)column
{
EOModel * activeModel = nil;
EOEntity * selectedEntity = nil;
EOEntity * destinationEntity = nil;
if ((sender == destinationEntityBrowser)) {
activeModel = [[NSApp activeDocument] eomodel];
[cell setLeaf:YES];
//entityNames is better
[cell setTitle:[[activeModel entityNames] objectAtIndex:row]];
//[cell setTitle:[(EOEntity *)[[activeModel entities] objectAtIndex:row] name]];
return;
}
selectedEntity = [_currentRelation entity];
if (((sender == sourceBrowser)) && (selectedEntity)) {
NSArray * attributes = [selectedEntity attributes];
NSString * name = [[attributes objectAtIndex:row] name];
NSUInteger idx;
[cell setLeaf:YES];
[cell setTitle:name];
idx = [[_currentRelation sourceAttributeNames] indexOfObject: name];
if ((idx != NSNotFound)) {
[cell setImage:_dimpleImg];
} else {
[cell setImage:_noDimpleImg];
}
return;
}
destinationEntity = [_currentRelation destinationEntity];
if (!destinationEntity) {
NSString * name = [[destinationEntityBrowser selectedCell] title];
activeModel = [[NSApp activeDocument] eomodel];
destinationEntity = [activeModel entityNamed:name];
}
if (((sender == destBrowser)) && (destinationEntity)) {
NSArray * dstAttributes = [destinationEntity attributes];
NSString * name = [[dstAttributes objectAtIndex:row] name];
NSUInteger idx;
[cell setLeaf:YES];
[cell setTitle:name];
idx = [[_currentRelation destinationAttributeNames] indexOfObject: name];
if ((idx != NSNotFound)) {
[cell setImage:_dimpleImg];
} else {
[cell setImage:_noDimpleImg];
}
}
}
- (IBAction)sourceBrowserClicked:(NSBrowser *)sender
{
NSString * name = [[sender selectedCell] title];
EOEntity * destinationEntity = nil;
EOJoin * join = nil;
NSInteger row = NSNotFound;
destinationEntity = [_currentRelation destinationEntity];
join = [_currentRelation joinFromAttributeNamed:name];
if (join) {
row = [[destinationEntity attributeNames] indexOfObject:[[join destinationAttribute] name]];
}
if ((row != NSNotFound)) {
[destBrowser selectRow:row
inColumn:0];
[destBrowser scrollRowToVisible:row
inColumn:0];
[connectButton setState: NSOnState];
[connectButton setEnabled:YES];
} else {
NSString * otherName = [[destBrowser selectedCell] title];
EOJoin * otherJoin = [_currentRelation joinToAttributeNamed:otherName];
if (otherJoin) {
[connectButton setEnabled:NO];
} else {
[connectButton setEnabled:YES];
}
[connectButton setState: NSOffState];
}
}
- (IBAction)destBrowserClicked:(NSBrowser *)sender
{
NSString * name = [[sender selectedCell] title];
EOEntity * srcEntity = nil;
EOJoin * join = nil;
NSInteger row = NSNotFound;
srcEntity = [_currentRelation entity];
join = [_currentRelation joinToAttributeNamed:name];
if (join) {
row = [[srcEntity attributeNames] indexOfObject:[[join sourceAttribute] name]];
}
if ((row != NSNotFound)) {
[sourceBrowser selectRow:row
inColumn:0];
[sourceBrowser scrollRowToVisible:row
inColumn:0];
[connectButton setState: NSOnState];
[connectButton setEnabled:YES];
} else {
NSString * otherName = [[sourceBrowser selectedCell] title];
EOJoin * otherJoin = [_currentRelation joinFromAttributeNamed:otherName];
if (otherJoin) {
[connectButton setEnabled:NO];
} else {
[connectButton setEnabled:YES];
}
[connectButton setState: NSOffState];
}
}
- (IBAction)destinationEntityBrowserClicked:(NSBrowser *)sender
{
[destBrowser loadColumnZero];
[destBrowser selectRow:0
inColumn:0];
}
#pragma mark -
@end

View file

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<box title="Names" topPadding="10" leftPadding="4" rightPadding="4" width="260">
<grid>
<gridRow>
<label halign="right" selectable="no">Name:</label>
<textField id="nameField" delegate="#NSOwner"></textField>
</gridRow>
<gridRow>
<label halign="right" selectable="no">External Name:</label>
<textField id="externalNameField" delegate="#NSOwner"></textField>
</gridRow>
</grid>
</box>
<hbox height="290"/>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#nameField" key="nameField"/>
<outlet source="#NSOwner" target="#externalNameField" key="externalNameField"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,39 @@
/*
StoredProcedureInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#include <AppKit/AppKit.h>
@class EOStoredProcedure;
@interface StoredProcedureInspector : EOMInspector
{
IBOutlet NSTextField *nameField;
IBOutlet NSTextField *externalNameField;
EOStoredProcedure *_currentProcedure;
}
@end

View file

@ -0,0 +1,101 @@
/*
StoredProcedureInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "StoredProcedureInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#include <Foundation/Foundation.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation StoredProcedureInspector
- (NSString *) displayName
{
return @"Stored Procedure";
}
- (void) dealloc
{
DESTROY(_currentProcedure);
[super dealloc];
}
- (void) awakeFromGSMarkup
{
}
- (float) displayOrder
{
return 1;
}
- (BOOL) canInspectObject:(id)anObject
{
return [anObject isKindOfClass:[EOStoredProcedure class]];
}
- (void) refresh
{
EOModel *activeModel = [[NSApp activeDocument] eomodel];
NSString *tmpStr;
ASSIGN(_currentProcedure, (EOStoredProcedure *) [self selectedObject]);
[nameField setStringValue:[_currentProcedure name]];
tmpStr = [_currentProcedure externalName];
[externalNameField setStringValue:(tmpStr != nil) ? tmpStr : @""];
}
- (void) controlTextDidEndEditing:(NSNotification *)notif
{
id obj = [notif object];
if (obj == nameField) {
[_currentProcedure setName:[nameField stringValue]];
return;
}
if (obj == externalNameField) {
[_currentProcedure setExternalName:[externalNameField stringValue]];
return;
}
}
@end

View file

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="window" title="Inspector" width="268.0" resizable="no" autosaveName="Inspector" visible="no">
<vbox>
<splitView vertical="no" autosaveName="verticalsplit">
<vbox>
<scrollView height="220" hasHorizontalScroller="no">
<tableView id="tableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="no" allowsColumnSelection="no">
<tableColumn identifier="key" title="Key" minWidth="100"/>
<tableColumn editable="yes" identifier="value" title="Value" minWidth="100"/>
</tableView>
</scrollView>
</vbox>
<vbox>
<scrollView height="100" hasHorizontalScroller="no">
<textView id="textView">
</textView>
</scrollView>
</vbox>
</splitView>
<grid>
<gridRow>
<button title="Add" target="#NSOwner" action="add:"/>
<button title="Remove" target="#NSOwner" action="remove:"/>
</gridRow>
</grid>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#tableView" key="tableView"/>
<outlet source="#NSOwner" target="#textView" key="textView"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,45 @@
/*
UserInfoInspector.h
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <EOModeler/EOMInspector.h>
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/AppKit.h>
#endif
#include "ConnectionDictionaryInspector.h"
@class EOAttribute;
@class TableViewController;
@interface UserInfoInspector: ConnectionDictionaryInspector
{
}
- (void) commitChanges;
@end

View file

@ -0,0 +1,100 @@
/*
UserInfoInspector.m
Author: David Wetzel <dave@turbocat.de>
Date: 2010
This file is part of EOModelEditor.
EOModelEditor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
EOModelEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EOModelEditor; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "UserInfoInspector.h"
#include <EOAccess/EOEntity.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOModeler/EOModelerApp.h>
#include "../EOMEDocument.h"
#include "../EOMEEOAccessAdditions.h"
#include <Foundation/Foundation.h>
#import "../TableViewController.h"
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#endif
@implementation UserInfoInspector
- (NSString *) displayName
{
return @"User Info";
}
- (void) dealloc
{
[super dealloc];
}
- (float) displayOrder
{
return 5;
}
- (BOOL) canInspectObject:(id)anObject
{
BOOL weCan = YES; //[anObject isKindOfClass:[EOModel class]];
return weCan;
}
- (void) commitChanges
{
NSMutableDictionary * mDict = [NSMutableDictionary dictionary];
if ((_dataArray) && ([_dataArray count])) {
NSEnumerator * aEnumer = [_dataArray objectEnumerator];
NSDictionary * myDict = nil;
while ((myDict = [aEnumer nextObject])) {
[mDict setObject:[myDict objectForKey:@"value"]
forKey:[myDict objectForKey:@"key"]];
}
}
[[self selectedObject] setUserInfo:mDict];
}
- (void) refresh
{
[self setDataFromDictionary:[[self selectedObject] userInfo]];
DESTROY(_selectedDict);
}
@end

Binary file not shown.

View file

@ -0,0 +1,73 @@
/**
Preferences.h
Author: Matt Rice <ratmice@gmail.com>
Date: Mar 2006
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSObject.h>
#endif
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSNibDeclarations.h>
#endif
@class NSArray;
@class NSWindow;
@class NSButton;
@class NSTableView;
@class NSMatrix;
@class NSMutableArray;
@interface DBModelerPrefs : NSObject
{
IBOutlet NSWindow *prefsWindow;
IBOutlet NSButton *consistencyCheckOnSave;
IBOutlet NSTableView *bundlesToLoad;
/* consistency checks */
IBOutlet NSMatrix *check_matrix;
NSMutableArray *_bundles;
}
+ (DBModelerPrefs *) sharedPreferences;
- (void) showPreferences:(id)sender;
- (BOOL) consistencyCheckOnSave;
- (BOOL) attributeDetailsCheck;
- (BOOL) storedProcedureCheck;
- (BOOL) relationshipCheck;
- (BOOL) primaryKeyCheck;
- (BOOL) inheritanceCheck;
- (BOOL) externalNameCheck;
- (BOOL) entityStoredProcedureCheck;
- (NSArray *)bundlesToLoad;
- (IBAction) switchButtonChanged:(id)sender;
- (IBAction) checkOnSaveChanged:(id)sender;
- (IBAction) addBundle:(id)sender;
- (IBAction) removeBundle:(id)sender;
@end

View file

@ -0,0 +1,221 @@
/**
Preferences.m
Author: Matt Rice <ratmice@gmail.com>
Date: 2005, 2006
This file is part of DBModeler.
<license>
DBModeler is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
DBModeler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DBModeler; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include "Preferences.h"
#ifdef NeXT_Foundation_LIBRARY
#include <Foundation/Foundation.h>
#else
#include <Foundation/NSInvocation.h>
#include <Foundation/NSUserDefaults.h>
#endif
#ifdef NeXT_GUI_LIBRARY
#include <AppKit/AppKit.h>
#else
#include <AppKit/NSNibLoading.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSButton.h>
#include <AppKit/NSTableView.h>
#include <AppKit/NSMatrix.h>
#endif
#define DisableAttributeDetailsCheck @"DisableAttributeDetailsCheck"
#define DisableEntityStoredProcedureCheck @"DisableEntityStoredProcedureCheck"
#define DisableExternalNameCheck @"DisableExternalNameCheck"
#define DisableInheritanceCheck @"DisableInheritanceCheck"
#define DisablePrimaryKeyCheck @"DisablePrimaryKeyCheck"
#define DisableRelationshipCheck @"DisableRelationshipCheck"
#define DisableStoredProcedureCheck @"DisableStoredProcedureCheck"
static NSString *BundlesToLoad = @"BundlesToLoad";
static NSString *DisableConsistencyCheckOnSave=@"DisableConsistencyCheckOnSave";
static NSUserDefaults *ud;
static DBModelerPrefs *_sharedPrefs;
/* do it this way so i can add the switch title later instead of being
* hard coded into the .gorm */
static NSString *_switches[][2] =
{
{DisableAttributeDetailsCheck, @"Attribute details"},
{DisableExternalNameCheck, @"External name"},
{DisablePrimaryKeyCheck, @"Primary key"},
{DisableRelationshipCheck, @"Relationship"},
{DisableEntityStoredProcedureCheck, @"Entity stored procedure"},
{DisableStoredProcedureCheck, @"Stored procedure"},
{DisableInheritanceCheck, @"Inheritance"}
};
#define FROBKEY(key) [ud boolForKey:key] ? NO : YES
#define COUNT(key) sizeof(key) / sizeof(key[0])
@implementation DBModelerPrefs : NSObject
+ (DBModelerPrefs *) sharedPreferences
{
if (_sharedPrefs == nil)
{
_sharedPrefs = [self new];
}
return _sharedPrefs;
}
- (id) init
{
self = [super init];
/* setup ud before -awakeFromNib is called... */
ud = [NSUserDefaults standardUserDefaults];
_bundles = [[NSMutableArray alloc] init];
[_bundles addObjectsFromArray:[self bundlesToLoad]];
[NSBundle loadNibNamed:@"Preferences" owner:self];
return self;
}
- (void) awakeFromNib
{
int i, c = COUNT(_switches);
[check_matrix renewRows:c columns:1];
for (i = 0; i < c; i++)
{
NSButtonCell *cell = [check_matrix cellAtRow:i column:0];
BOOL flag;
flag = [ud boolForKey:_switches[i][0]];
[cell setState: (flag == NO) ? NSOnState : NSOffState];
[cell setTitle: _switches[i][1]];
}
[check_matrix sizeToCells];
[consistencyCheckOnSave
setState:[ud boolForKey:DisableConsistencyCheckOnSave]
? NSOffState
: NSOnState];
[bundlesToLoad reloadData];
}
- (void) showPreferences:(id)sender
{
[prefsWindow makeKeyAndOrderFront:self];
}
- (void) switchButtonChanged:(id)sender
{
int selRow;
if ((selRow = [sender selectedRow]) != -1)
[ud setBool:([[sender selectedCell] state] == NSOffState)
forKey:_switches[selRow][0]];
}
- (void) checkOnSaveChanged:(id)sender
{
[ud setBool:([sender state] == NSOffState)
forKey:DisableConsistencyCheckOnSave];
}
- (NSArray *)bundlesToLoad
{
return [ud arrayForKey:BundlesToLoad];
}
- (BOOL) consistencyCheckOnSave
{
return FROBKEY(DisableConsistencyCheckOnSave);
}
- (BOOL) attributeDetailsCheck
{
return FROBKEY(DisableAttributeDetailsCheck);
}
- (BOOL) entityStoredProcedureCheck
{
return FROBKEY(DisableEntityStoredProcedureCheck);
}
- (BOOL) externalNameCheck
{
return FROBKEY(DisableExternalNameCheck);
}
- (BOOL) inheritanceCheck
{
return FROBKEY(DisableInheritanceCheck);
}
- (BOOL) primaryKeyCheck
{
return FROBKEY(DisablePrimaryKeyCheck);
}
- (BOOL) relationshipCheck
{
return FROBKEY(DisableRelationshipCheck);
}
- (BOOL) storedProcedureCheck
{
return FROBKEY(DisableStoredProcedureCheck);
}
- (int) numberOfRowsInTableView:(NSTableView *)tv
{
int num = [_bundles count];
return num;
}
- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tc row:(int)rowIndex
{
id ov = [_bundles objectAtIndex:rowIndex];
return ov;
}
- (void) tableView:(NSTableView *)tv
setObjectValue:(id)newVal
forTableColumn:(NSTableColumn *)tc
row:(int)rowIndex
{
[_bundles replaceObjectAtIndex:rowIndex withObject:newVal];
[ud setObject:_bundles forKey:BundlesToLoad];
}
- (void) addBundle:(id)sender
{
[_bundles addObject:@""];
[bundlesToLoad reloadData];
[bundlesToLoad selectRow:[_bundles count] - 1 byExtendingSelection:NO];
[bundlesToLoad editColumn:0 row:[_bundles count] - 1 withEvent:nil select:YES];
}
- (void) removeBundle:(id)sender
{
[_bundles removeObjectAtIndex:[bundlesToLoad selectedRow]];
[bundlesToLoad reloadData];
[ud setObject:_bundles forKey:BundlesToLoad];
}
@end

20
Apps/EOModelEditor/README Normal file
View file

@ -0,0 +1,20 @@
This is the new (non EOInterface based) Model application.
It will work on GNUstep and OS X
It is based on previous work especially David Ayers (Frameworks) and Matt Rice (old version).
Please be careful when testing this software, make backups before you modify any files!
David Wetzel
------------
ConnectionDictionary and UserInfo Images:
License: GPL
Name: Silvestre Herrera
Nickname: ertz
Location: La Plata, Buenos Aires. ARGENTINA.
E-mail: silvestre.herrera(at)gmail.com

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<panel id="resultsPanel" title="Consistency Results">
<vbox>
<scrollView width="500" height="200">
<textView id="resultsTextView"></textView>
</scrollView>
<hbox halign="right">
<button id="cancelBut" title="Cancel"
target="#NSOwner" action="cancel:" />
<button id="okBut" title="Ok" target="#NSOwner" action="ok:" />
</hbox>
</vbox>
</panel>
</objects>
<connectors>
<outlet source="#NSOwner" target="#resultsPanel" key="panel" />
<outlet source="#NSOwner" target="#okBut" key="okButton" />
<outlet source="#NSOwner" target="#cancelBut" key="cancelButton" />
<outlet source="#NSOwner" target="#resultsTextView" key="results" />
</connectors>
</gsmarkup>

View file

@ -0,0 +1,38 @@
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf290
{\fonttbl\f0\fnil\fcharset0 Verdana;}
{\colortbl;\red255\green255\blue255;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}
{\list\listtemplateid3\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid201\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid3}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}}
\paperw11900\paperh16840\margl1440\margr1440\vieww5960\viewh7840\viewkind0
\deftab720
\pard\pardeftab720\sa240\qc
\f0\b\fs24 \cf0 By\
\pard\tx220\tx720\pardeftab720\li720\fi-720\qc
\ls1\ilvl0
\b0 \cf0 David Wetzel\
dave@turbocat.de\
\
\pard\pardeftab720\sa240\qc
\b \cf0 GDL2 Frameworks
\b0 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\qc
\ls2\ilvl0\cf0 David Ayers\
Matt Rice\
David Wetzel\
Manuel Guesdon\
Gerald Siebke\
Mirko Viviani\
\pard\tx220\tx720\pardeftab720\li720\fi-720\qc
\ls3\ilvl0\cf0 \
\pard\tx0\tx220\pardeftab720\qj
\ls3\ilvl0
\fs16 \cf0 EOModelEditor is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\
\
EOModelEditor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\
\
You should have received a copy of the GNU General Public License along with DBModeler; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\
}

View file

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window title="Data Browser" id="window" delegate="#NSOwner" releasedWhenClosed="yes"
resizable="yes">
<vbox>
<box topPadding="2" bottomPadding="2" leftPadding="4" rightPadding="4">
<grid>
<gridRow>
<label halign="right" selectable="no">Entity:</label>
<label id="entityNameField" halign="left" selectable="no">XXXXXXXXXXXX</label>
<gridEmptyCell />
<label halign="right" selectable="no">Fetch Limit:</label>
<textField id="fetchLimitText" width="50" delegate="#NSOwner">10</textField>
<gridEmptyCell />
<label halign="right" selectable="no">Qualifier:</label>
<textField id="qualifierText" width="350" delegate="#NSOwner"></textField>
<gridEmptyCell />
<button title="Fetch" target="#NSOwner" action="fetch:"/>
</gridRow>
</grid>
</box>
<scrollView hasHorizontalScroller="yes" height="200">
<tableView id="tableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="yes" allowsColumnSelection="yes">
<tableColumn editable="no" identifier="_#number" title="Row #" minWidth="30" width="30" maxWidth="80"/>
</tableView>
</scrollView>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#window" key="window"/>
<outlet source="#NSOwner" target="#entityNameField" key="entityNameField"/>
<outlet source="#NSOwner" target="#fetchLimitText" key="fetchLimitText"/>
<outlet source="#NSOwner" target="#qualifierText" key="qualifierText"/>
<outlet source="#NSOwner" target="#tableView" key="tableView"/>
</connectors>
</gsmarkup>

View file

@ -0,0 +1,151 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window id="foobar" visible="no">
<hbox>
<popUpButton target="#NSOwner" pullsDown="yes" bordered="yes" action="visibleColumnsChanged:" id="topVisibleColumnsPopUp">
<!-- this is just a dummy for autolayout -->
<popUpButtonItem tag="100" title="" />
</popUpButton>
<popUpButton target="#NSOwner" pullsDown="yes" bordered="yes" action="visibleColumnsChanged:" id="bottomVisibleColumnsPopUp">
<!-- this is just a dummy for autolayout -->
<popUpButtonItem tag="100" title="" />
</popUpButton>
<popUpButton target="#NSOwner" pullsDown="yes" bordered="yes" action="visibleColumnsChanged:" id="storedProcVisibleColumnsPopUp">
<!-- this is just a dummy for autolayout -->
<popUpButtonItem tag="100" title="" />
</popUpButton>
<popUpButton pullsDown="no" bordered="no" id="storedProcDirectionUp">
<popUpButtonItem tag="0" title="Void" />
<popUpButtonItem tag="1" title="In" />
<popUpButtonItem tag="2" title="Out" />
<popUpButtonItem tag="3" title="In/Out" />
</popUpButton>
</hbox>
</window>
<window id="window" minWidth="200" minHeight="300" autosaveName="EOMEDocument" visible="no">
<vbox>
<splitView vertical="yes" autosaveName="verticalsplit">
<vbox>
<scrollView width="170" hasHorizontalScroller="no">
<outlineView id="outlineView" dataSource="#NSOwner" XXautosaveName="Outline" outlineColumn="0" usesAlternatingRowBackgroundColors="yes">
<tableColumn identifier="name" title="Class Name" editable="no" minWidth="120"/>
</outlineView>
</scrollView>
</vbox>
<vbox>
<tabView id="tabView" viewType="noTabsNoBorder">
<tabViewItem label="EOEntity">
<splitView vertical="no" autosaveName="horizontalsplit">
<vbox>
<scrollView width="350" height="expand">
<tableView id="topTableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="yes" allowsColumnSelection="no" target="#NSOwner" action="tableViewClicked:"
autosaveName="TopTableView">
<tableColumn hidden="yes" identifier="isPrimaryKey" title="Primary key" minWidth="16" width="16"/>
<tableColumn hidden="yes" identifier="isClassProperty" title="Class property" minWidth="16" width="16"/>
<tableColumn hidden="yes" identifier="allowNull" title="Allows null" minWidth="16" width="16"/>
<tableColumn hidden="yes" identifier="isUsedForLocking" title="Locking" minWidth="16" width="16"/>
<tableColumn identifier="name" title="Name" minWidth="100"/>
<tableColumn hidden="yes" identifier="columnName" title="Column name" minWidth="100"/>
<tableColumn hidden="yes" identifier="valueClassName" title="Value class name" minWidth="100"/>
<tableColumn hidden="yes" identifier="externalType" title="External Type" minWidth="100"/>
<tableColumn hidden="yes" identifier="width" title="Width" minWidth="30"/>
<tableColumn hidden="yes" identifier="definition" title="Definition" minWidth="50"/>
<tableColumn hidden="yes" identifier="precision" title="Precision" minWidth="30"/>
<tableColumn hidden="yes" identifier="readFormat" title="Read format" minWidth="50"/>
<tableColumn hidden="yes" identifier="scale" title="Scale" minWidth="30"/>
<tableColumn hidden="yes" identifier="valueType" title="Value type" minWidth="30"/>
<tableColumn hidden="yes" identifier="writeFormat" title="Write format" minWidth="50"/>
</tableView>
</scrollView>
</vbox>
<vbox>
<scrollView width="350" height="expand">
<tableView id="bottomTableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="yes" allowsColumnSelection="no" target="#NSOwner" action="tableViewClicked:"
autosaveName="BottomTableView">
<tableColumn hidden="no" editable="no" identifier="isToMany" title="Cardinality" minWidth="16" width="16"/>
<tableColumn hidden="yes" identifier="isClassProperty" title="Class property" minWidth="16" width="16"/>
<tableColumn hidden="no" identifier="name" title="Name" minWidth="100"/>
<tableColumn hidden="no" editable="no" identifier="destinationEntity.name" title="Destination" minWidth="100"/>
<tableColumn hidden="no" editable="no" identifier="humanReadableSourceAttributes" title="Source Attributes" minWidth="100"/>
<tableColumn hidden="no" editable="no" identifier="humanReadableDestinationAttributes" title="Destination Attributes" minWidth="100"/>
<tableColumn hidden="yes" identifier="definition" title="Definition" minWidth="50"/>
</tableView>
</scrollView>
</vbox>
</splitView>
</tabViewItem>
<tabViewItem label="Second">
<vbox>
<scrollView width="350" height="expand">
<tableView id="storedProcedureTableView" usesAlternatingRowBackgroundColors="yes" drawsGrid="yes"
allowsEmptySelection="yes" allowsColumnSelection="no" target="#NSOwner" action="tableViewClicked:"
autosaveName="StoredProcedureView">
<tableColumn identifier="name" title="Name" minWidth="100"/>
<tableColumn identifier="parameterDirection" title="Direction" minWidth="50"/>
<tableColumn hidden="no" identifier="columnName" title="Column name" minWidth="100"/>
<tableColumn hidden="yes" identifier="valueClassName" title="Value class name" minWidth="100"/>
<tableColumn hidden="yes" identifier="externalType" title="External type" minWidth="100"/>
<tableColumn hidden="yes" identifier="width" title="Width" minWidth="30"/>
<tableColumn hidden="yes" identifier="precision" title="Precision" minWidth="30"/>
<tableColumn hidden="yes" identifier="scale" title="Scale" minWidth="30"/>
<tableColumn hidden="yes" identifier="valueType" title="Value type" minWidth="30"/>
</tableView>
</scrollView>
</vbox>
</tabViewItem>
</tabView>
</vbox>
</splitView>
</vbox>
</window>
</objects>
<!-- outlets -->
<connectors>
<!-- This outlet is compulsory in Document-based applications -->
<outlet source="#NSOwner" target="#window" key="window"/>
<!-- These outlets are our own custom outlets -->
<outlet source="#NSOwner" target="#topTableView" key="topTableView"/>
<outlet source="#NSOwner" target="#bottomTableView" key="bottomTableView"/>
<outlet source="#NSOwner" target="#outlineView" key="outlineView"/>
<outlet source="#NSOwner" target="#topVisibleColumnsPopUp" key="topVisibleColumnsPopUp"/>
<outlet source="#NSOwner" target="#bottomVisibleColumnsPopUp" key="bottomVisibleColumnsPopUp"/>
<outlet source="#NSOwner" target="#tabView" key="tabView"/>
<outlet source="#NSOwner" target="#storedProcedureTableView" key="storedProcedureTableView"/>
<outlet source="#NSOwner" target="#storedProcVisibleColumnsPopUp" key="storedProcVisibleColumnsPopUp"/>
<outlet source="#NSOwner" target="#storedProcDirectionUp" key="storedProcDirectionUp"/>
</connectors>
</gsmarkup>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,35 @@
{
ApplicationDescription = "GDL2 EOModel editor";
ApplicationIcon = EOModelEditor;
ApplicationName = EOModelEditor;
ApplicationRelease = "0.0.0 (Alpha)";
ApplicationURL = "http://mediawiki.gnustep.org/index.php/EOModelEditor";
Authors = (
"David Wetzel"
);
Copyright = "Copyright \U00A9 2005, 2006 Free Software Foundation";
CopyrightDescription = "Released under the GNU GPL. See COPYING for details.";
FullVersionID = 0.0.0;
GSMainMarkupFile = "";
NSPrincipalClass = EOModelEditorApp;
NSExecutable = EOModelEditor;
NSIcon = EOModelEditor.tiff;
NSRole = "Editor";
NSTypes = (
{
NSUnixExtensions = ( "eomodeld", "eomodel" );
NSIcon = "EOModel.tiff";
CFBundleTypeIconFile = "EOModel.icns";
NSHumanReadableName = "EO Model";
NSRole = Editor;
NSDocumentClass = "EOModelerDocument";
NSName = "EOModel";
NSDOSExtensions = ( "eomodel", "eomodeld");
NSDOSExtensions = ( "eomodel", "eomodeld");
NSRole = Editor;
}
);
}

View file

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFAppleHelpAnchor</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>eomodeld</string>
<string>eomodel</string>
</array>
<key>CFBundleTypeName</key>
<string>EOModel</string>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.xcode.dsym</string>
</array>
<key>LSTypeIsPackage</key>
<true/>
<key>PBXFileTypeIdentifiers</key>
<array>
<string>wrapper.dsym</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>EOModelEditor</string>
<key>CFBundleGetInfoString</key>
<string>EOModelEditor version 1.0.0</string>
<key>CFBundleIconFile</key>
<string>appicon</string>
<key>CFBundleIdentifier</key>
<string>org.gnustep.gdl.EOModelEditor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>EOModelEditor</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>eomo</string>
<key>CFBundleVersion</key>
<string>1650</string>
<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
<string>i386</string>
<string>ppc</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>10.5.0</string>
<key>LSRequiresNativeExecution</key>
<true/>
<key>NSAppleScriptEnabled</key>
<false/>
<key>NSMainNibFile</key>
<string></string>
<key>NSPrincipalClass</key>
<string>EOModelEditorApp</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.package</string>
</array>
<key>UTTypeDescription</key>
<string>EOModel</string>
<key>UTTypeIconName</key>
<string>EOModel</string>
<key>UTTypeIdentifier</key>
<string>org.gnustep.gdl.eomodel</string>
<key>UTTypeReferenceURL</key>
<string>http://www.gnustep.org/tools/eomodeleditor/</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>eomodeld</string>
<string>eomodel</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,100 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<menu type="main" autoenablesItems="yes">
<menu title="Info" type="apple" autoenablesItems="yes">
<menuItem title="About EOModelEditor"
action="orderFrontStandardAboutPanel:" />
<menuSeparator/>
<menuItem title="Preferences..." keyEquivalent=","
action="openPrefs:" />
<menuSeparator/>
<menu title="Services" type="services"/>
<menuSeparator/>
<menuItem title="Hide EOModelEditor" keyEquivalent="h"
action="hide:" />
<menuItem title="Hide Others"
action="hideOtherApplications:" />
<menuItem title="Show All"
action="unhideAllApplications:" />
<menuSeparator/>
<menuItem title="Quit EOModelEditor" keyEquivalent="q"
action="terminate:" />
</menu>
<menu title="Model" autoenablesItems="yes">
<menuItem title="New..." keyEquivalent="n"
action="new:" />
<menuItem title="New From Database..."
action="newFromDatabase:" />
<menuItem title="Open" keyEquivalent="o" action="openDocument:"/>
<!-- This does not seem to work. we get 2 menus then
<menu title="Open Recent">
<menuItem title="Clear Menu" action="clearRecentDocuments:"/>
</menu>
-->
<menuSeparator/>
<menuItem title="Save" keyEquivalent="s"
action="saveDocument:" />
<menuItem title="Save As..." keyEquivalent="S"
action="saveDocumentAs:" />
<menuItem title="Revert to Saved" keyEquivalent="u"
action="revert:" />
<menuSeparator/>
<menuItem title="Set Adaptor Info..." keyEquivalent="I"
action="setAdaptor:" />
<menuItem title="Switch Adaptor..."
action="switchAdaptor:" />
<menuItem title="Check Consistency..."
action="checkConsistency:" />
</menu>
<menu title="Edit" autoenablesItems="yes">
<menuItem title="Undo" keyEquivalent="z" action="undo:" />
<menuItem title="Redo" keyEquivalent="Z" action="redo:" />
<menuSeparator/>
<menuItem title="Cut" keyEquivalent="x"
action="cut:" />
<menuItem title="Copy" keyEquivalent="c"
action="copy:" />
<menuItem title="Paste" keyEquivalent="v"
action="paste:" />
<menuItem title="SelectAll" keyEquivalent="a"
action="selectAll:" />
</menu>
<menu title="Property" autoenablesItems="yes">
<menuItem title="Add Entity" keyEquivalent="E"
action="addEntity:" />
<menuItem title="Add Attribute" keyEquivalent="A"
action="addAttribute:" />
<menuItem title="Add Relationship" keyEquivalent="R"
action="addRelationship:" />
<menuItem title="Add Procedure" keyEquivalent="P" action="addProcedure:" />
<menuItem title="Delete" action="delete:" />
</menu>
<menu title="Tools">
<menuItem title="Inspector" keyEquivalent="i"
action="showInspector:" />
<menuItem title="Generate SQL" action="generateSQL:" />
<menuItem title="Generate ObjC Files.." action="createTemplates:" />
<menuItem title="DataBrowser" action="dataBrowser:" />
<menuItem title="Diagram Editor" action="showEditor:" />
</menu>
<menu title="Windows" type="windows">
<menuItem title="Close Window" action="performClose:"
keyEquivalent="w"/>
<menuItem title="Zoom Window" action="zoom:" />
<menuItem title="Miniaturize Window" action="performMiniaturize:"
keyEquivalent="m"/>
<menuSeparator/>
<menuItem title="Bring All to Front" action="arrangeInFront:"/>
</menu>
</menu>
</objects>
</gsmarkup>

View file

@ -0,0 +1,83 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<menu type="main" autoenablesItems="yes">
<menu title="Info" autoenablesItems="yes">
<menuItem title="About EOModelEditor"
action="orderFrontStandardAboutPanel:" />
<menuItem title="Preferences..." action="openPrefs:"/>
<menuItem title="Help..." action="orderFrontHelpPanel:"/>
</menu>
<menu title="Model">
<menuItem title="New..." keyEquivalent="n"
action="new:" />
<menuItem title="New From Database..."
action="newFromDatabase:" />
<menuItem title="Open" keyEquivalent="o" action="openDocument:"/>
<menuSeparator/>
<menuItem title="Save" keyEquivalent="s"
action="saveDocument:" />
<menuItem title="Save As..." keyEquivalent="S"
action="saveDocumentAs:" />
<menuItem title="Revert to Saved" keyEquivalent="u"
action="revert:" />
<menuSeparator/>
<menuItem title="Set Adaptor Info..." keyEquivalent="I"
action="setAdaptor:" />
<menuItem title="Switch Adaptor..."
action="switchAdaptor:" />
<menuItem title="Check Consistency..."
action="checkConsistency:" />
</menu>
<menu title="Edit" autoenablesItems="yes">
<menuItem title="Undo" keyEquivalent="z" action="undo:" />
<menuItem title="Redo" keyEquivalent="Z" action="redo:" />
<menuSeparator/>
<menuItem title="Cut" keyEquivalent="x"
action="cut:" />
<menuItem title="Copy" keyEquivalent="c"
action="copy:" />
<menuItem title="Paste" keyEquivalent="v"
action="paste:" />
<menuItem title="SelectAll" keyEquivalent="a"
action="selectAll:" />
</menu>
<menu title="Property" autoenablesItems="yes">
<menuItem title="Add Entity" keyEquivalent="E"
action="addEntity:" />
<menuItem title="Add Attribute" keyEquivalent="A"
action="addAttribute:" />
<menuItem title="Add Relationship" keyEquivalent="R"
action="addRelationship:" />
<menuItem title="Add Procedure" keyEquivalent="P" action="addProcedure:" />
<menuItem title="Delete" action="delete:" />
</menu>
<menu title="Tools">
<menuItem title="Inspector" keyEquivalent="i"
action="showInspector:" />
<menuItem title="Generate SQL" action="generateSQL:" />
<menuItem title="Generate ObjC Files.." action="createTemplates:" />
<menuItem title="DataBrowser" action="dataBrowser:" />
<menuItem title="Diagram Editor" action="showEditor:" />
</menu>
<menu title="Services" type="services"/>
<menu title="Windows" type="windows">
<menuItem title="Arrange" action="arrangeInFront:"/>
<menuItem title="Miniaturize" action="performMiniaturize:" keyEquivalent="m"/>
<menuItem title="Close" action="performClose:" keyEquivalent="w"/>
</menu>
<menuItem title="Hide" action="hide:" keyEquivalent="h"/>
<menuItem title="Quit" action="terminate:" keyEquivalent="q"/>
</menu>
</objects>
</gsmarkup>

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
DBModelerPrefs = {
Actions = (
"switchButtonChanged:",
"checkOnSaveChanged:",
"addBundle:",
"removeBundle:"
);
Outlets = (
prefsWindow,
consistencyCheckOnSave,
bundlesToLoad,
addBundleButton,
check_matrix,
removeBundleButton
);
Super = NSObject;
};
FirstResponder = {
Actions = (
"addBundle:",
"checkOnSaveChanged:",
"removeBundle:",
"switchButtonChanged:"
);
Super = NSObject;
};
}

View file

@ -0,0 +1,95 @@
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window title="SQL Generation" id="sqlgenWindow" delegate="#NSOwner" resizable="yes">
<vbox leftPadding="10" padding="10">
<box title="SQL Generation Options" topPadding="10"
leftPadding="15" rightPadding="15" width="425">
<hbox halign="wexpand" valign="top">
<vbox halign="left" valign="top" rightPadding="15">
<button id="dropDatabase" title="Drop Database"
type="switch" halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="dropTables" title="Drop Tables"
type="switch" halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="dropPKSupport"
title="Drop Primary Key Support" type="switch"
halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
</vbox>
<vbox halign="right" valign="top">
<button id="createDB" title="Create Database"
type="switch" halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="createTables" title="Create Tables"
type="switch" halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="createPKConstraints"
title="Primary Key Constraints" type="switch"
halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="createFKConstraints"
title="Foreign Key Constraints" type="switch"
halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
<button id="createPKSupport"
title="Create Primary Key Support"
type="switch" halign="left" valign="top"
action="switchChanged:" target="#NSOwner"
padding="1.5" />
</vbox>
</hbox>
</box>
<scrollView width="425" height="300"
borderType="bezel" leftPadding="15" rightPadding="15"
hasHorizontalScroller="no">
<textView id="sqlOutput"/>
</scrollView>
<hbox halign="left" padding="8">
<button id="executeSQL" title="Execute SQL"
type="momentaryPushIn" halign="left" valign="center"
action="executeSQL:" target="#NSOwner" width="115"
leftPadding="5" />
<button id="saveAs" title="Save As..."
type="momentaryPushIn" halign="left" valign="center"
action="saveAs:" target="#NSOwner" width="100" />
<button id="tables" title="Tables..."
type="momentaryPushIn" halign="left" valign="center"
action="showTables:" target="#NSOwner" width="100" />
</hbox>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#sqlgenWindow" key="window"/>
<outlet source="#NSOwner" target="#dropDatabase"
key="dropDatabaseSwitch" />
<outlet source="#NSOwner" target="#createDB"
key="createDatabaseSwitch"/>
<outlet source="#NSOwner" target="#dropTables"
key="dropTablesSwitch"/>
<outlet source="#NSOwner" target="#createTables"
key="createTablesSwitch"/>
<outlet source="#NSOwner" target="#dropPKSupport"
key="dropPKSwitch"/>
<outlet source="#NSOwner" target="#createPKSupport"
key="createPKSwitch"/>
<outlet source="#NSOwner" target="#createPKConstraints"
key="createPKConstraintsSwitch" />
<outlet source="#NSOwner" target="#createFKConstraints"
key="createFKConstraintsSwitch" />
<outlet source="#NSOwner" target="#sqlOutput" key="sqlOutput"/>
</connectors>
</gsmarkup>

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more