|
From: Gerard F. <ger...@us...> - 2002-03-17 22:56:31
|
Update of /cvsroot/kuml/kuml_old/kuml/data
In directory usw-pr-cvs1:/tmp/cvs-serv1995/kuml/data
Modified Files:
classes.cpp element.cpp package.cpp repository.cpp
Log Message:
2002-03-17 Gerard Flynn <ger...@li...>
* save/load of classes in class diagrams now works, connexions still
broken
* added loaded classes to the "project" package (multiple packages are
not supported at this time)
* changed the initial sizes of the 2 halfs of the kUML screen so that
most space is reserved for the diagram (KumlApp::initView)
* changed Classes::writeAsKuml to output the class name
* added loading of drawingclass to Diagram::readAsKuml
VS: Committing in .
VS:
VS: Modified Files:
VS: ChangeLog kuml/iokumlutility.cpp kuml/kuml.cpp
VS: kuml/kumlview.cpp kuml/kumlview.h kuml/data/classes.cpp
VS: kuml/data/element.cpp kuml/data/package.cpp
VS: kuml/data/repository.cpp kuml/diagrams/diagram.cpp
VS: kuml/diagrams/diagramloader.cpp kuml/drawobj/drawingclass.cpp
VS: kuml/drawobj/drawingclass.h kuml/drawobj/drawingrect.cpp
VS: kuml/overview/winoverview.cpp
VS: ----------------------------------------------------------------------
Index: classes.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml_old/kuml/data/classes.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** classes.cpp 8 Oct 2000 04:21:58 -0000 1.1.1.1
--- classes.cpp 17 Mar 2002 22:56:28 -0000 1.2
***************
*** 27,31 ****
////////////////////////////////////////////////////////////////////////
void Classes::writeAsKuml(IOKumlUtility &stream) {
! stream.writeGroupItem("class");
// Write all properties
SimpleElement::writeAsKuml(stream);
--- 27,31 ----
////////////////////////////////////////////////////////////////////////
void Classes::writeAsKuml(IOKumlUtility &stream) {
! stream.writeGroupItem( "class", getName() );
// Write all properties
SimpleElement::writeAsKuml(stream);
***************
*** 72,75 ****
--- 72,77 ----
int type;
+ ASSERT( Repository::getRepository()->getPackage( "project" ) != NULL );
+ setParent( Repository::getRepository()->getPackage( "project" ) );
while((type = stream.readStatement()) != IOKumlUtility::CloseGroup) {
switch(type) {
Index: element.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml_old/kuml/data/element.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** element.cpp 8 Oct 2000 04:22:02 -0000 1.1.1.1
--- element.cpp 17 Mar 2002 22:56:28 -0000 1.2
***************
*** 60,67 ****
Element::Element() : IOInterface()
{
! miComputeId ();
! // Darius:
! parent = NULL;
! stereotype = NULL;
}
--- 60,67 ----
Element::Element() : IOInterface()
{
! miComputeId ();
! // Darius:
! parent = NULL;
! stereotype = NULL;
}
***************
*** 69,83 ****
Element::Element(const QString & name) : IOInterface()
{
! miComputeId ();
! this->name = name;
! // Darius:
! parent = NULL;
! stereotype = NULL;
}
/////////////////////////////////////////////////
Element::~Element() {
! if(stereotype)
! delete stereotype;
}
--- 69,83 ----
Element::Element(const QString & name) : IOInterface()
{
! miComputeId ();
! this->name = name;
! // Darius:
! parent = NULL;
! stereotype = NULL;
}
/////////////////////////////////////////////////
Element::~Element() {
! if(stereotype)
! delete stereotype;
}
***************
*** 97,108 ****
Path* Element::getPath() {
! Path* path = NULL;
! if (parent != NULL) {
! path = parent->getPath();
! } else {
! path = new Path();
! }
! path->append(getName());
! return path;
}
--- 97,108 ----
Path* Element::getPath() {
! Path* path = NULL;
! if (parent != NULL) {
! path = parent->getPath();
! } else {
! path = new Path();
! }
! path->append(getName());
! return path;
}
***************
*** 111,130 ****
void Element::readAsKuml(IOKumlUtility &stream) {
int type;
!
while((type = stream.readStatement()) != IOKumlUtility::CloseGroup) {
switch(type) {
! case IOKumlUtility::Assignment:
! if (stream.getAssignmentName() == "name") {
name = stream.getAssignmentValue();
continue;
! }
! if (stream.getAssignmentName() == "description") {
description = stream.getAssignmentValue();
continue;
! }
!
! case IOKumlUtility::Error:
! debug("usecase::readAsKuml(): Parse error !");
! break;
}
}
--- 111,130 ----
void Element::readAsKuml(IOKumlUtility &stream) {
int type;
!
while((type = stream.readStatement()) != IOKumlUtility::CloseGroup) {
switch(type) {
! case IOKumlUtility::Assignment:
! if (stream.getAssignmentName() == "name") {
name = stream.getAssignmentValue();
continue;
! }
! if (stream.getAssignmentName() == "description") {
description = stream.getAssignmentValue();
continue;
! }
!
! case IOKumlUtility::Error:
! debug("usecase::readAsKuml(): Parse error !");
! break;
}
}
***************
*** 133,193 ****
////////////////////////////////////////////////////////////////////////
void Element::setStereotype(Stereotype *st) {
! // Delete a previous stereotype object
! if(stereotype)
! delete stereotype;
!
! stereotype = st;
}
////////////////////////////////////////////////////////////////////////
void Element::setStereotype(const QString &name, const QString &baseClass = NULL) {
! if(stereotype == NULL) {
! if(name.isEmpty() == false)
! stereotype = new Stereotype(name, baseClass);
! } else
! if(name.isEmpty()) {
! delete stereotype;
! stereotype = NULL;
! } else {
! stereotype->setName(name);
! stereotype->setBaseClass(baseClass);
! }
!
! /* if((stereotype == NULL) && (!name.isEmpty()))
! stereotype = new Stereotype(name, baseClass);
else {
! // Pass an empty name to delete the stereotype object
! if(name.isEmpty()) {
! delete stereotype;
! stereotype = NULL;
! }
! else {
! stereotype->setName(name);
! stereotype->setBaseClass(baseClass);
! }
} */
}
////////////////////////////////////////////////////////////////////////
Stereotype *Element::getStereotype() {
! return stereotype;
}
////////////////////////////////////////////////////////////////////////
void Element::setName( const QString newName ) throw ( InvalidNameException ) {
if ( newName == 0 || newName == "" ) {
! throw InvalidNameException("The name can not be empty");
} else if (newName == name) {
! // Then do nothing, it would be quite pointless...
! return;
}
- ASSERT(parent != NULL);
- if (!parent->containsElement(newName)) {
- parent->removeElement(this);
- name = newName;
- parent->addElement(this);
- } else {
- throw InvalidNameException("That name is a duplicate name");
- }
}
--- 133,198 ----
////////////////////////////////////////////////////////////////////////
void Element::setStereotype(Stereotype *st) {
! // Delete a previous stereotype object
! if(stereotype)
! delete stereotype;
!
! stereotype = st;
}
////////////////////////////////////////////////////////////////////////
void Element::setStereotype(const QString &name, const QString &baseClass = NULL) {
! if(stereotype == NULL) {
! if(name.isEmpty() == false)
! stereotype = new Stereotype(name, baseClass);
! } else
! if(name.isEmpty()) {
! delete stereotype;
! stereotype = NULL;
! } else {
! stereotype->setName(name);
! stereotype->setBaseClass(baseClass);
! }
!
! /* if((stereotype == NULL) && (!name.isEmpty()))
! stereotype = new Stereotype(name, baseClass);
else {
! // Pass an empty name to delete the stereotype object
! if(name.isEmpty()) {
! delete stereotype;
! stereotype = NULL;
! }
! else {
! stereotype->setName(name);
! stereotype->setBaseClass(baseClass);
! }
} */
}
////////////////////////////////////////////////////////////////////////
Stereotype *Element::getStereotype() {
! return stereotype;
}
////////////////////////////////////////////////////////////////////////
void Element::setName( const QString newName ) throw ( InvalidNameException ) {
+
+ debug( "In Element::setName" );
if ( newName == 0 || newName == "" ) {
! throw InvalidNameException("The name can not be empty");
} else if (newName == name) {
! // Then do nothing, it would be quite pointless...
! return;
! }
! debug( QString( " newName = " ) + newName );
! cerr << " &parent: " << parent << endl;
! ASSERT(parent != NULL);
! if (!parent->containsElement(newName)) {
! debug( " in if" );
! parent->removeElement(this);
! name = newName;
! parent->addElement(this);
! } else {
! throw InvalidNameException("That name is a duplicate name");
}
}
Index: package.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml_old/kuml/data/package.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** package.cpp 8 Oct 2000 04:22:03 -0000 1.1.1.1
--- package.cpp 17 Mar 2002 22:56:28 -0000 1.2
***************
*** 27,36 ****
////////////////////////////////////////////////////////////
Package::Package(const char* name) : SimpleElement( name) {
! classMap = new ElementMap();
! packageMap = new ElementMap();
! useCaseMap = new ElementMap();
! actorMap = new ElementMap();
! associationMap = new ElementMap();
! generalizationMap = new ElementMap();
}
--- 27,38 ----
////////////////////////////////////////////////////////////
Package::Package(const char* name) : SimpleElement( name) {
!
! debug( QString( "Call to Package constructor, name : " ) + QString( name ) );
! classMap = new ElementMap();
! packageMap = new ElementMap();
! useCaseMap = new ElementMap();
! actorMap = new ElementMap();
! associationMap = new ElementMap();
! generalizationMap = new ElementMap();
}
***************
*** 371,373 ****
void Package::readAsKuml(IOKumlUtility& stream) {
! }
\ No newline at end of file
--- 373,375 ----
void Package::readAsKuml(IOKumlUtility& stream) {
! }
Index: repository.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml_old/kuml/data/repository.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** repository.cpp 8 Oct 2000 04:22:04 -0000 1.1.1.1
--- repository.cpp 17 Mar 2002 22:56:28 -0000 1.2
***************
*** 30,34 ****
///////////////////////////////////////////////////////////
Repository::Repository(void) : Package("project") {
! setParent(NULL);
}
--- 30,34 ----
///////////////////////////////////////////////////////////
Repository::Repository(void) : Package("project") {
! setParent(NULL);
}
***************
*** 41,48 ****
*/
Repository* Repository::getRepository() {
! if (singleton == 0) {
! singleton = new Repository();
! }
! return singleton;
}
--- 41,48 ----
*/
Repository* Repository::getRepository() {
! if (singleton == 0) {
! singleton = new Repository();
! }
! return singleton;
}
***************
*** 51,80 ****
*/
Repository::~Repository() {
! if(singleton) {
! delete singleton;
! singleton = 0;
! }
! // Package::~Package();
}
///////////////////////////////////////////////////////////
bool Repository::containsElement(Element* element) {
! return Package::containsElement( element->getName() );
}
///////////////////////////////////////////////////////////
bool Repository::containsElement( Path path ) {
! return (getElement(path) != NULL);
}
///////////////////////////////////////////////////////////
bool Repository::containsPackage( Path path ) {
! Element* e = getElement( path );
! PackageChecker pc;
! if ( e == NULL || !pc.isPackage(e)) {
! return false;
! } else {
! return true;
! }
}
--- 51,80 ----
*/
Repository::~Repository() {
! if(singleton) {
! delete singleton;
! singleton = 0;
! }
! // Package::~Package();
}
///////////////////////////////////////////////////////////
bool Repository::containsElement(Element* element) {
! return Package::containsElement( element->getName() );
}
///////////////////////////////////////////////////////////
bool Repository::containsElement( Path path ) {
! return (getElement(path) != NULL);
}
///////////////////////////////////////////////////////////
bool Repository::containsPackage( Path path ) {
! Element* e = getElement( path );
! PackageChecker pc;
! if ( e == NULL || !pc.isPackage(e)) {
! return false;
! } else {
! return true;
! }
}
***************
*** 83,90 ****
*/
Element* Repository::takeElement( const char* name ) {
! Element* e = getElement( name );
! if ( e != 0 ) {
! removeElement( e );
! }
return e;
}
--- 83,90 ----
*/
Element* Repository::takeElement( const char* name ) {
! Element* e = getElement( name );
! if ( e != 0 ) {
! removeElement( e );
! }
return e;
}
***************
*** 92,130 ****
/////////////////////////////////////////////////////////////////
Element* Repository::getElement( Path path ) {
!
! // If the path is empty, just return this.
! if ( path.count() == 0 || ( path.count() == 1 &&
! ( path.at( 0 ) == NULL || path.at( 0 ) == "" ))) {
! return this;
! } else {
! PackageChecker packageChecker;
! Package* currentPackage = this;
! Element* element = NULL;
! char* name = NULL;
!
! for (unsigned int i = 0; i < path.count(); i++) {
! name = path.at( i );
! element = currentPackage->getElement( name );
! if (element != NULL && packageChecker.isPackage( element )) {
currentPackage = (Package*)element;
! // else if no element or we arrived at a dead end in the path.
! } else if (element == NULL || (element != NULL && path.count() < i+1)) {
! return NULL;
! }
! }
! // The code will reach here if the requested element IS a package.
! return element;
! }
}
/////////////////////////////////////////////////////////////////
Package* Repository::getPackage( Path path ) {
! Element* e = getElement( path );
PackageChecker pc;
! if (pc.isPackage( e )) {
! return (Package*)e;
! } else {
! return NULL;
! }
}
--- 92,130 ----
/////////////////////////////////////////////////////////////////
Element* Repository::getElement( Path path ) {
!
! // If the path is empty, just return this.
! if ( path.count() == 0 || ( path.count() == 1 &&
! ( path.at( 0 ) == NULL || path.at( 0 ) == "" ))) {
! return this;
! } else {
! PackageChecker packageChecker;
! Package* currentPackage = this;
! Element* element = NULL;
! char* name = NULL;
!
! for (unsigned int i = 0; i < path.count(); i++) {
! name = path.at( i );
! element = currentPackage->getElement( name );
! if (element != NULL && packageChecker.isPackage( element )) {
currentPackage = (Package*)element;
! // else if no element or we arrived at a dead end in the path.
! } else if (element == NULL || (element != NULL && path.count() < i+1)) {
! return NULL;
! }
! }
! // The code will reach here if the requested element IS a package.
! return element;
! }
}
/////////////////////////////////////////////////////////////////
Package* Repository::getPackage( Path path ) {
! Element* e = getElement( path );
PackageChecker pc;
! if (pc.isPackage( e )) {
! return (Package*)e;
! } else {
! return NULL;
! }
}
***************
*** 134,162 ****
*/
void Repository::readAsKuml(IOKumlUtility& stream) {
! int type;
Element* e = 0;
while((type = stream.readStatement()) != IOKumlUtility::CloseGroup) {
! switch (type) {
! case IOKumlUtility::GroupItem: {
! if(stream.getGroupType() == "class") {
! // PENDING (JF): We need a bunch more checks here, or a better way to do this.
! // This is (once again) making use of RTTI of some form and probably should be
! // (at the very least) captured in some deserialization mechanism sepperate from
! // this class.
! e = new Classes("");
! e->readAsKuml(stream);
! addElement( e );
! }
! break;
! } case IOKumlUtility::Error: {
! debug("Repository::readAsKuml(): Parse error !");
! break;
! } default: {
! debug("Unexpected groupType: " + stream.getGroupType());
! break;
! }
! } // end switch
! } // end while
!
}
--- 134,161 ----
*/
void Repository::readAsKuml(IOKumlUtility& stream) {
! int type;
Element* e = 0;
while((type = stream.readStatement()) != IOKumlUtility::CloseGroup) {
! switch (type) {
! case IOKumlUtility::GroupItem: {
! if(stream.getGroupType() == "class") {
! // PENDING (JF): We need a bunch more checks here, or a better way to do this.
! // This is (once again) making use of RTTI of some form and probably should be
! // (at the very least) captured in some deserialization mechanism sepperate from
! // this class.
! e = new Classes("");
! e->readAsKuml(stream);
! addElement( e );
! }
! break;
! } case IOKumlUtility::Error: {
! debug("Repository::readAsKuml(): Parse error !");
! break;
! } default: {
! debug("Unexpected groupType: " + stream.getGroupType());
! break;
! }
! } // end switch
! } // end while
}
***************
*** 165,169 ****
*/
void Repository::writeAsKuml(IOKumlUtility& stream) {
! stream.writeGroupItem("classrepository");
// The entire state of the repository consists of nothing more than
--- 164,168 ----
*/
void Repository::writeAsKuml(IOKumlUtility& stream) {
! stream.writeGroupItem("classrepository");
// The entire state of the repository consists of nothing more than
***************
*** 171,178 ****
// writing each of them to the stream.
/*ElementIterator* itr = getElementIterator();
! for ( itr->toFirst(); itr->current(); ++(*itr) ) {
! itr->current()->writeAsKuml( stream );
! }*/
!
stream.closeGroup();
}
--- 170,177 ----
// writing each of them to the stream.
/*ElementIterator* itr = getElementIterator();
! for ( itr->toFirst(); itr->current(); ++(*itr) ) {
! itr->current()->writeAsKuml( stream );
! }*/
!
stream.closeGroup();
}
|