Skip to content

Commit

Permalink
Offer simplified version to create LocalResourceManager
Browse files Browse the repository at this point in the history
Frequently LocalResourceManager(JFaceResources.getResources(), parent)
is used in client code. This add a helper method on JFaceResource to
simplify such call.

Fixed eclipse-platform#1208
  • Loading branch information
vogella committed Oct 13, 2023
1 parent ec6fff0 commit 5f47dac
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
/**
* Declare a private constructor to block instantiation.
*/
Expand Down

0 comments on commit 5f47dac

Please sign in to comment.