-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer simplified version to create LocalResourceManager #1213
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import org.eclipse.jface.wizard.Wizard; | ||
import org.eclipse.swt.graphics.Font; | ||
import org.eclipse.swt.graphics.Image; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.FrameworkUtil; | ||
|
@@ -583,6 +584,23 @@ public static void setFontRegistry(FontRegistry registry) { | |
fontRegistry = registry; | ||
} | ||
|
||
|
||
/** | ||
* Creates a local registry that wraps the ResourceManager for the current | ||
* display. Anything allocated by this registry will be automatically cleaned up | ||
* with the given control is disposed. Note that registries created in this way | ||
* should not be used to allocate any resource that must outlive the given | ||
* control. | ||
* | ||
* shortcut for | ||
* <code>LocalResourceManager(JFaceResources.getResources(), owner)</code> | ||
* | ||
* @param owner control whose disposal will trigger cleanup of everything in the | ||
* registry. | ||
*/ | ||
static LocalResourceManager managerFor(Control owner) { | ||
return new LocalResourceManager(getResources(), owner); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use control.getData/setData to cache the instance created so multiple calls could be performed without creating multiple managers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you estimate how often that will hit the cache? |
||
} | ||
/** | ||
* Declare a private constructor to block instantiation. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this package private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch. Will be fixed with
#1218