Bug 24694 - [PropertiesView] Use factory method pattern in PropertySheetEntry (as in GEF)
Summary: [PropertiesView] Use factory method pattern in PropertySheetEntry (as in GEF)
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
: 39243 (view as bug list)
Depends on:
Blocks: 85089
  Show dependency tree
 
Reported: 2002-10-11 08:24 EDT by Scott Stanchfield CLA
Modified: 2005-03-31 11:29 EST (History)
2 users (show)

See Also:


Attachments
PropertySheetEntry with protected createChildEntry() method (21.73 KB, text/plain)
2004-08-13 09:04 EDT, Scott Stanchfield CLA
no flags Details
Patch to make PropertySheetEntry extensible (43.52 KB, patch)
2005-02-12 04:30 EST, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch to make PropertySheetEntry extensible (3.02 KB, patch)
2005-02-12 04:46 EST, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch to make PropertySheetEntry extensible (4.46 KB, patch)
2005-02-12 04:55 EST, Gunnar Wagenknecht CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Stanchfield CLA 2002-10-11 08:24:55 EDT
GEF's UndoablePropertySheetEntry defines

private void createChildEntries() {
	// get the current descriptors
	List descriptors = computeMergedPropertyDescriptors();

	// rebuild child entries using old when possible
	childEntries = createChildEntries(descriptors.size());
	for (int i = 0; i < descriptors.size(); i++) {
		IPropertyDescriptor d = (IPropertyDescriptor)descriptors.get
(i);
		// create new entry
		UndoablePropertySheetEntry entry = createChildEntry();
		entry.setDescriptor(d);
		entry.setParent(this);
		entry.setPropertySourceProvider(propertySourceProvider);
		entry.refreshValues();
		childEntries[i] = entry;
	}
}
protected UndoablePropertySheetEntry createChildEntry(){
	return new UndoablePropertySheetEntry();	
}


This allows one to subclass UndoablePropertySheetEntry and override 
createChildEntry to create instances of your subclass.

This same pattern should be used in Eclipse's base PropertySheetEntry so it 
can be easily subclassed and all children be created with the subclass' type. 
Currentlt, this is not possible, as its createChildEntries() method is private 
and doesn't use the factory method pattern to create the actual child 
instances.
Comment 1 Scott Stanchfield CLA 2004-08-13 09:04:19 EDT
Created attachment 13944 [details]
PropertySheetEntry with protected createChildEntry() method

This is an example of using template method and factory method to allow
subclasses of PropertySheetEntry. Such subclasses can be used to allow custom
sort order by prefixing the property display names as outlined in
http://javadude.com/eclipse/sortingpropertysheetentries.html.
Comment 2 Gunnar Wagenknecht CLA 2005-02-12 04:30:02 EST
Created attachment 17892 [details]
Patch to make PropertySheetEntry extensible

This patch can be applied against HEAD to make PropertySheetEntry extensible
(i.e. for the GEF undoable property sheet entry)
Comment 3 Gunnar Wagenknecht CLA 2005-02-12 04:46:07 EST
Created attachment 17893 [details]
Patch to make PropertySheetEntry extensible

This is a new version. (I accidentially hit the code formatter before).
Comment 4 Gunnar Wagenknecht CLA 2005-02-12 04:55:55 EST
Created attachment 17894 [details]
Patch to make PropertySheetEntry extensible

New version to address the GEF use case completely
Comment 5 Nick Edgar CLA 2005-03-21 16:19:25 EST
Patch applied, thanks Gunnar.

Is the createChildEntriesArray(int) method really necessary (I've already asked
Randy in bug 39243)?  I can't imagine why someone would need to override the
array type.
Comment 6 Nick Edgar CLA 2005-03-21 16:19:46 EST
I've cleaned up the Javadoc for the affected methods a bit too.
Comment 7 Nick Edgar CLA 2005-03-21 16:20:40 EST
*** Bug 39243 has been marked as a duplicate of this bug. ***
Comment 8 Nick Edgar CLA 2005-03-21 16:22:05 EST
Re comment #5, Randy responded with:
> That makes sense to me.  Perhaps that's an artifact of having copied the entire 
class at one point.

So I will remove createChildEntriesArray(int) unless someone screams.
Comment 9 Nick Edgar CLA 2005-03-21 16:24:26 EST
Randy and Scott, I'd appreciate if you could verify this for M6 (this is our API
freeze milestone).
Comment 10 Scott Stanchfield CLA 2005-03-21 23:33:43 EST
Looking at the patch (but not applying it), it looks good to me. Hits the 
things I wanted. Thanks much!

I agree that the createChildEntriesArray(int) isn't needed.

Thanks for taking care of this!
-- Scott
Comment 11 Nick Edgar CLA 2005-03-31 11:29:04 EST
Verified in I20050331-0800.