Bug 109645 - CompartmentResizeHandle broken for compartment edit parts that enclose the compartment with another figure
Summary: CompartmentResizeHandle broken for compartment edit parts that enclose the co...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Tooling (ARCHIVED)
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Steven R. Shaw CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2005-09-15 14:19 EDT by Min Idzelis CLA
Modified: 2010-07-19 12:18 EDT (History)
0 users

See Also:


Attachments
Fix (1.39 KB, patch)
2005-09-15 14:19 EDT, Min Idzelis CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Min Idzelis CLA 2005-09-15 14:19:22 EDT
If a CompartmentEditPart's createFigure() method creates a Figure other than a
subclass of ResizableCompartmentEditPart, CompartmentResizeHandle breaks with a
ClassCastException. You can fix this if you use the existing method on
CompartmentEditPart that returns the ResizableCompartmentFigure -
getCompartmentFigure(). 

Patch attached.
Comment 1 Min Idzelis CLA 2005-09-15 14:19:54 EDT
Created attachment 27181 [details]
Fix
Comment 2 Steven R. Shaw CLA 2005-09-21 12:11:11 EDT
Looks like there is some slight logic problem in the received patch.  The 
signature of getCompartmentFigure on the ResizableCompartmentEditPart returns 
a ResizableCompartmentFigure.  This is not in the hierarchy of the 
GatedPaneFigure and consequently the 2 lines: 
if( compartmentFigure instanceof GatedPaneFigure ){
			return ((GatedPaneFigure)
compartmentFigure).getElementPane();
		}
will never get executed.  Also it is assuming that the owner is 
ResizableCompartmentEditPart, but there is no constraint in the constructor 
enforcing this.

I would suggest the following changes to the patch:

protected IFigure getCompartmentFigure()
{
   if (getOwner() instanceof ResizableCompartmentEditPart) {
      return ((ResizableCompartmentEditPart)getOwner()).getCompartmentFigure();
   }
   else if( getOwner().getFigure() instanceof GatedPaneFigure ){
      return ((GatedPaneFigure)getOwner().getFigure()).getElementPane();
   }
		
   return getOwner().getFigure();
}
Comment 3 Min Idzelis CLA 2005-09-21 12:43:54 EDT
Your suggestion works for me. Thanks.
Comment 4 Steven R. Shaw CLA 2005-09-21 17:52:14 EDT
- Fixed CompartmentResizeHandle#getCompartmentFigure() to check owner type and 
utilize method to get compartment figure from the 
ResizableCompartmentEditPart.  Otherwise, it will fall through to existing 
code (modified patch from Min).
Comment 5 Eclipse Webmaster CLA 2010-07-19 12:18:06 EDT
[GMF Restructure] Bug 319140 : product GMF and component
UI was the original product and component for this bug