Bug 130793

Summary: importing java subinterface before superinterface results in superinterface not being treated as an interface
Product: [Applications] umbrello Reporter: JP Fournier <jfournier121>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Slackware   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description JP Fournier 2006-07-14 02:52:18 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Slackware Packages
Compiler:          gcc 3.4.4 
OS:                Linux

steps to reproduce:
- import ClassInfo.java (interface extends Info)
- import Info.java (interface)
- drag classes into class digram
- Info is missing <<interface>> stereotype

------------------------------


import java.io.*;
import java.beans.*;

public interface ClassInfo extends  Info {

	void build(ProjectOptions options) throws IOException;

	
//	void setDirectory(String dir );

	/** return a deep copy of the class info */
	ClassInfo copy();
	
	void setPackageName( String name );
	String getPackageName();
	
	//void setComment( String comment );
	//String getComment();
	
	//void addImport( String imports );
	String  getImports();
	void setImports(String imports);

	//void setVisibility( Visibility visibility );
	//Visibility getVisibility();

	//void addModifier( Modifier modifier);
	//Modifier[] getModifiers();

	//void setClassType( ClassType type );
	//ClassType getClassType();

	//void setClassName( String name );
	//String getClassName();

	void setSuperClass( String superClass );
	String getSuperClass();
	
	void setInterfaces( String implement );
	String  getInterfaces();

	//void addVariable( VariableInfo var );
	VariableInfo[] getVariables( );
	VariableInfo createVariable();
	void removeVariable( VariableInfo var );
	void clearVariables();

//	void addVariable( 	Visibility visibility,
//						boolean isStatic,
//						boolean isFinal,
//						Type type,
//						String name,
//						Visibility setVisibility,
//						Visibility getVisibility,
//						String description );

	MethodInfo[] getMethods();
	MethodInfo createMethod();
	void removeMethod( MethodInfo method );
	void clearMethods();
//
//    public void addPropertyChangeListener(PropertyChangeListener l ) ;
//
//    public void removePropertyChangeListener( PropertyChangeListener l );


}

-------------------------------------------

import java.io.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;


public interface Info extends  Serializable {


	/** return a deep copy of the class info */
	//ClassInfo copy();
	
	
	void setComment( String comment );
	String getComment();
	
	void setVisibility( Visibility visibility );
	Visibility getVisibility();

	void addModifier( Modifier modifier);
	Modifier[] getModifiers();
	void removeModifier( Modifier modifier );
	void clearModifiers();

		
	void setType( Type type );
	Type getType();

	void setName( String name );
	String getName();

    public void addPropertyChangeListener(PropertyChangeListener l ) ;

    public void removePropertyChangeListener( PropertyChangeListener l );


//	void addVariable( 	Visibility visibility,
//						boolean isStatic,
//						boolean isFinal,
//						Type type,
//						String name,
//						Visibility setVisibility,
//						Visibility getVisibility,
//						String description );


}
Comment 1 JP Fournier 2006-07-14 03:11:18 UTC
umbrello version - 1.5.4 - snapshot kdesdk-561582
Comment 2 Oliver Kellogg 2006-07-14 18:52:56 UTC
I see two possible ways for resolving this:
1) primitive - the mention of "interface" means that the superclass
   must also be an interface
2) thorough - On seeing the mention of ClassInfo in Info, the importer
   could try to find, open, and import the ClassInfo.java file before
   continuing with parsing Info.java
Comment 3 JP Fournier 2006-07-15 13:58:03 UTC
I took a stab at solving this bug using approach #1. diff is below.

regards

jp

jape@puma:~/tmp/uml/kdesdk-561582$ diff -c umbrello-561582/umbrello/import_utils.cpp umbrello/umbrello/import_utils.cpp
*** umbrello-561582/umbrello/import_utils.cpp   2006-07-15 07:24:49.000000000 -0400
--- umbrello/umbrello/import_utils.cpp  2006-07-15 07:37:24.000000000 -0400
***************
*** 321,326 ****
--- 321,328 ----
  }

  void createGeneralization(UMLClassifier *child, UMLClassifier *parent) {
+     // if the child is an interface, so is the parent.
+     parent->setInterface( child->isInterface());
      UMLAssociation *assoc = new UMLAssociation( Uml::at_Generalization,
                              child, parent );
      UMLDoc *umldoc = UMLApp::app()->getDocument();
Comment 4 Oliver Kellogg 2006-07-16 01:21:55 UTC
SVN commit 562840 by okellogg:

createGeneralization(UMLClassifier*, UMLClassifier*): If the child is an
interface then the parent must also be an interface.
Thanks to JP Fournier for helping.
BUG:130793


 M  +2 -0      ChangeLog  
 M  +3 -0      umbrello/import_utils.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #562839:562840
@@ -3,6 +3,8 @@
 * Bugs/wishes from http://bugs.kde.org:
 * Fix crash when importing classes from a java file (129107, 130093)
 * Crash after single click on the "UML Model" tree window (126560/129252)
+* Importing java subinterface before superinterface results in superinterface
+  not being treated as an interface (130793)
 
 Version 1.5.3
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/import_utils.cpp #562839:562840
@@ -321,6 +321,9 @@
 }
 
 void createGeneralization(UMLClassifier *child, UMLClassifier *parent) {
+    // if the child is an interface, so is the parent.
+    if (child->isInterface())
+        parent->setInterface(true);
     UMLAssociation *assoc = new UMLAssociation( Uml::at_Generalization,
                             child, parent );
     UMLDoc *umldoc = UMLApp::app()->getDocument();