Version: 1.2.1 (using KDE 3.2.1, (testing/unstable)) Compiler: gcc version 3.3.3 (Debian) OS: Linux (i686) release 2.6.4-1-686 When creating an interface there is no way to change it into a class later on. This can be quite annoying when you have added a dusin method and then suddenly decide that the interface should be a superclass instead. Alternativly it should be possible to copy the methods/fields from a class/interface to another class/interface.
Good idea. IMHO the best way to implement this would be to abandon the static UMLClass/UMLInterface distinction and instead only use UMLClassifier which would then have a flag, isInterface, that can be changed. Something to look into after 1.3.
It is a wish and not a bug.
ClassWidget and InterfaceWidget will be removed shortly (their specific functions are being merged into ClassifierWidget.)
SVN commit 417540 by okellogg: Make the distinction between class and interface changeable at run time. CCBUG:79433 M +0 -4 Makefile.am M +4 -4 associationwidget.cpp M +2 -2 associationwidget.h D class.cpp D class.h M +217 -19 classifier.cpp M +109 -20 classifier.h M +2 -4 classifiercodedocument.cpp M +340 -17 classifierwidget.cpp M +192 -29 classifierwidget.h M +4 -4 classimport.cpp M +2 -3 classimport.h M +8 -9 classparser/cpptree2uml.cpp M +4 -4 classparser/cpptree2uml.h D classwidget.cpp D classwidget.h M +1 -3 clipboard/umlclipboard.cpp M +1 -1 clipboard/umldrag.cpp M +2 -4 codegenerator.cpp M +8 -26 codegenerators/adawriter.cpp M +11 -10 codegenerators/aswriter.cpp M +3 -8 codegenerators/classifierinfo.cpp M +1 -1 codegenerators/classifierinfo.h M +10 -10 codegenerators/cppheadercodedocument.cpp M +18 -41 codegenerators/cppwriter.cpp M +7 -7 codegenerators/idlwriter.cpp M +2 -2 codegenerators/javacodeclassfielddeclarationblock.cpp M +4 -10 codegenerators/javawriter.cpp M +3 -4 codegenerators/jswriter.cpp M +6 -9 codegenerators/perlwriter.cpp M +2 -2 codegenerators/perlwriter.h M +6 -9 codegenerators/php5writer.cpp M +1 -1 codegenerators/php5writer.h M +7 -7 codegenerators/phpwriter.cpp M +1 -1 codegenerators/phpwriter.h M +1 -2 codegenerators/simplecodegenerator.cpp M +1 -2 codegenerators/simplecodegenerator.h M +5 -5 codegenerators/sqlwriter.cpp M +1 -1 codegenerators/sqlwriter.h M +7 -10 codegenerators/xmlschemawriter.cpp M +0 -4 datatype.cpp M +0 -5 datatype.h M +1 -2 diagram/diagram.cpp M +15 -24 dialogs/classifierlistpage.cpp M +3 -1 dialogs/classifierlistpage.h M +10 -17 dialogs/classoptionspage.cpp M +2 -1 dialogs/classwizard.cpp M +2 -2 dialogs/classwizard.h M +10 -7 dialogs/codeeditor.cpp M +0 -1 dialogs/parmpropdlg.cpp M +0 -1 dialogs/umlattributedialog.cpp M +0 -1 dialogs/umlentityattributedialog.cpp M +0 -1 dialogs/umloperationdialog.cpp M +2 -2 dialogs/umltemplatedialog.cpp M +0 -1 dialogs/umlviewdialog.cpp M +0 -2 entity.h M +2 -4 enum.h M +6 -7 idlimport.cpp D interface.cpp D interface.h D interfacewidget.cpp D interfacewidget.h M +4 -6 listpopupmenu.cpp M +8 -7 package.cpp M +4 -6 package.h M +29 -36 refactoring/refactoringassistant.cpp M +0 -1 refactoring/refactoringassistant.h M +1 -0 uml.cpp D umlclasslist.h M +54 -73 umldoc.cpp M +2 -12 umldoc.h D umlinterfacelist.h M +11 -8 umllistview.cpp M +4 -4 umllistviewitem.cpp M +2 -2 umlobject.h M +21 -23 umlview.cpp M +3 -3 umlwidget.cpp
SVN commit 418189 by okellogg: Add menu items and logic to change interface into class and vice versa. BUG:79433 M +5 -1 ChangeLog M +6 -0 umbrello/classifier.cpp M +26 -5 umbrello/classifierwidget.cpp M +16 -7 umbrello/listpopupmenu.cpp M +4 -0 umbrello/listpopupmenu.h M +7 -0 umbrello/umllistview.cpp M +5 -0 umbrello/umllistview.h
I have reopened this bug because there are some issues related to it: -if an interface drawn as a circle is transformed to a class, the class keeps being drawn as a circle. -if a class with hidden stereotype is transformed to an interface, the interface doesn't show the stereotype, and this can't be changed. -if an interface is transformed to a class, the class doesn't show the attributes by default.
SVN commit 557369 by danxuliu: Fixes to some issues changing interface into class and vice versa. BUG:79433 M +27 -10 classifierwidget.cpp M +16 -5 classifierwidget.h --- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifierwidget.cpp #557368:557369 @@ -300,7 +300,7 @@ if (!m_pObject) { return UMLWidget::calculateSize(); } - if (m_bDrawAsCircle) { + if (getClassifier()->isInterface() && m_bDrawAsCircle) { return calculateAsCircleSize(); } @@ -453,18 +453,12 @@ case ListPopupMenu::mt_ChangeToClass: case ListPopupMenu::mt_ChangeToClass_Selection: - WidgetBase::m_Type = Uml::wt_Class; - getClassifier()->setInterface(false); - updateComponentSize(); - update(); + changeToClass(); break; case ListPopupMenu::mt_ChangeToInterface: case ListPopupMenu::mt_ChangeToInterface_Selection: - WidgetBase::m_Type = Uml::wt_Interface; - getClassifier()->setInterface(true); - updateComponentSize(); - update(); + changeToInterface(); break; default: @@ -530,7 +524,7 @@ else p.setBrush( m_pView->viewport()->backgroundColor() ); - if (m_bDrawAsCircle) { + if (getClassifier()->isInterface() && m_bDrawAsCircle) { drawAsCircle(p, offsetX, offsetY); return; } @@ -727,6 +721,29 @@ update(); } +void ClassifierWidget::changeToClass() { + WidgetBase::setBaseType(Uml::wt_Class); + getClassifier()->setInterface(false); + + const Settings::OptionState& ops = m_pView->getOptionState(); + m_bShowAttributes = ops.classState.showAtts; + m_bShowStereotype = ops.classState.showStereoType; + + updateComponentSize(); + update(); +} + +void ClassifierWidget::changeToInterface() { + WidgetBase::setBaseType(Uml::wt_Interface); + getClassifier()->setInterface(true); + + m_bShowAttributes = false; + m_bShowStereotype = true; + + updateComponentSize(); + update(); +} + void ClassifierWidget::saveToXMI(QDomDocument & qDoc, QDomElement & qElement) { QDomElement conceptElement; UMLClassifier *umlc = getClassifier(); --- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifierwidget.h #557368:557369 @@ -1,8 +1,3 @@ -/* - * copyright (C) 2004 - * Umbrello UML Modeller Authors <uml-devel@ uml.sf.net> - */ - /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * @@ -10,6 +5,8 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * + * copyright (C) 2004-2006 * + * Umbrello UML Modeller Authors <uml-devel@ uml.sf.net> * ***************************************************************************/ #ifndef CLASSIFIERWIDGET_H @@ -235,6 +232,20 @@ void setDrawAsCircle(bool drawAsCircle); /** + * Changes this classifier from an interface to a class. + * Attributes and stereotype visibility is got from the view OptionState. + * This widget is also updated. + */ + void changeToClass(); + + /** + * Changes this classifier from a class to an interface. + * Attributes are hidden and stereotype is shown. + * This widget is also updated. + */ + void changeToInterface(); + + /** * Set the AssociationWidget when this ClassWidget acts as * an association class. */
SVN commit 623034 by okellogg: Merge of class UMLDatatype into UMLClassifier prepares for runtime type change in a similar way as already done for UMLInterface. Runtime type change is required by programming language import when the initial guess of an object type was wrong and the correct type is discovered later in the parse. CCBUG:79433 M +0 -1 Makefile.am M +77 -22 classifier.cpp M +34 -8 classifier.h M +3 -3 classifierwidget.cpp M +3 -3 codegenerators/javaclassifiercodedocument.cpp M +2 -2 codegenerators/rubyclassifiercodedocument.cpp M +1 -2 codeimport/cppimport.cpp M +3 -4 codeimport/import_utils.cpp M +3 -2 codeimport/javaimport.cpp M +3 -3 codeimport/kdevcppparser/cpptree2uml.cpp D datatype.cpp D datatype.h M +3 -3 datatypewidget.cpp M +4 -4 datatypewidget.h M +8 -9 dialogs/umlentityattributedialog.cpp M +11 -7 object_factory.cpp M +2 -2 petaltree2uml.cpp D umldatatypelist.h M +5 -5 umldoc.cpp M +3 -4 umldoc.h M +7 -4 umllistview.cpp M +2 -2 umlobject.h M +8 -9 umlview.cpp M +4 -4 widget_factory.cpp