This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git
The following commit(s) were added to refs/heads/master by this push:
new 90f0357 HOP-2177, HOP-2243
new 3c8fa60 Merge pull request #422 from nadment/HOP-2177
90f0357 is described below
commit 90f03574d7339a2b6e3a12ef8e29b0680866f98a
Author: nadment <[email protected]>
AuthorDate: Sun Nov 29 19:09:52 2020 +0100
HOP-2177, HOP-2243
---
.../core/dialog/HopDescribedVariablesDialog.java | 5 +-
.../org/apache/hop/ui/core/gui/GuiResource.java | 65 +++++++++++++---------
2 files changed, 43 insertions(+), 27 deletions(-)
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/dialog/HopDescribedVariablesDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/HopDescribedVariablesDialog.java
index 016f93d..1fa25f4 100644
---
a/ui/src/main/java/org/apache/hop/ui/core/dialog/HopDescribedVariablesDialog.java
+++
b/ui/src/main/java/org/apache/hop/ui/core/dialog/HopDescribedVariablesDialog.java
@@ -27,6 +27,7 @@ import org.apache.hop.core.Const;
import org.apache.hop.core.config.DescribedVariable;
import org.apache.hop.core.variables.Variables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.ui.core.ConstUi;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.WindowProperty;
@@ -83,7 +84,8 @@ public class HopDescribedVariablesDialog extends Dialog {
Display display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX );
- shell.setImage( GuiResource.getInstance().getImagePipelineGraph() );
+ shell.setText( BaseMessages.getString( PKG,
"HopDescribedVariablesDialog.Title" ) );
+ shell.setImage(
GuiResource.getInstance().getImage("ui/images/variable.svg",
ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE) );
props.setLook( shell );
FormLayout formLayout = new FormLayout();
@@ -91,7 +93,6 @@ public class HopDescribedVariablesDialog extends Dialog {
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout( formLayout );
- shell.setText( BaseMessages.getString( PKG,
"HopDescribedVariablesDialog.Title" ) );
int margin = props.getMargin();
diff --git a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
index de1ee65..fa91905 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
@@ -2090,46 +2090,61 @@ public class GuiResource {
}
/**
- * Loads an image from a location once. The second time, the image comes
from a cache. Because of this, it's important
- * to never dispose of the image you get from here. (easy!) The images are
automatically disposed when the application
- * ends.
+ * Loads an image from a location once. The second time, the image comes
from a cache. Because of
+ * this, it's important to never dispose of the image you get from here.
(easy!) The images are
+ * automatically disposed when the application ends.
*
* @param location the location of the image resource to load
- * @param width The height to resize the image to
- * @param height The width to resize the image to
+ * @param width The height to resize the image to
+ * @param height The width to resize the image to
* @return the loaded image
*/
- public Image getImage( String location, int width, int height ) {
- Image image = imageMap.get( location );
- if ( image == null ) {
- SwtUniversalImage svg = SwtSvgImageUtil.getImage( display, location );
- int realWidth = (int) Math.round( zoomFactor * width );
- int realHeight = (int) Math.round( zoomFactor * height );
- image = new Image( display, svg.getAsBitmapForSize( display, realWidth,
realHeight ), SWT.IMAGE_COPY );
+ public Image getImage(String location, int width, int height) {
+ StringBuilder builder = new StringBuilder(location);
+ builder.append('|');
+ builder.append(width);
+ builder.append('|');
+ builder.append(height);
+ String key = builder.toString();
+
+ Image image = imageMap.get(key);
+ if (image == null) {
+ SwtUniversalImage svg = SwtSvgImageUtil.getImage(display, location);
+ int realWidth = (int) Math.round(zoomFactor * width);
+ int realHeight = (int) Math.round(zoomFactor * height);
+ image = new Image(display, svg.getAsBitmapForSize(display, realWidth,
realHeight), SWT.IMAGE_COPY);
svg.dispose();
- imageMap.put( location, image );
+ imageMap.put(key, image);
}
return image;
}
/**
- * Loads an image from a location once. The second time, the image comes
from a cache. Because of this, it's important
- * to never dispose of the image you get from here. (easy!) The images are
automatically disposed when the application
- * ends.
+ * Loads an image from a location once. The second time, the image comes
from a cache. Because of
+ * this, it's important to never dispose of the image you get from here.
(easy!) The images are
+ * automatically disposed when the application ends.
*
- * @param location the location of the image resource to load
+ * @param location the location of the image resource to load
* @param classLoader the ClassLoader to use to locate resources
- * @param width The height to resize the image to
- * @param height The width to resize the image to
+ * @param width The height to resize the image to
+ * @param height The width to resize the image to
* @return the loaded image
*/
- public Image getImage( String location, ClassLoader classLoader, int width,
int height ) {
- Image image = imageMap.get( location );
- if ( image == null ) {
- SwtUniversalImage svg = SwtSvgImageUtil.getUniversalImage( display,
classLoader, location );
- image = new Image( display, getZoomedImaged( svg, display, width, height
), SWT.IMAGE_COPY );
+ public Image getImage(String location, ClassLoader classLoader, int width,
int height) {
+ // Build image key for a specific size
+ StringBuilder builder = new StringBuilder(location);
+ builder.append('|');
+ builder.append(width);
+ builder.append('|');
+ builder.append(height);
+ String key = builder.toString();
+
+ Image image = imageMap.get(key);
+ if (image == null) {
+ SwtUniversalImage svg = SwtSvgImageUtil.getUniversalImage(display,
classLoader, location);
+ image = new Image(display, getZoomedImaged(svg, display, width, height),
SWT.IMAGE_COPY);
svg.dispose();
- imageMap.put( location, image );
+ imageMap.put(location, image);
}
return image;
}