diff --git a/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java b/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java index 6f8c9adf64..92165e986e 100644 --- a/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java +++ b/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java @@ -210,8 +210,6 @@ protected static IPreferenceStore getPreferences() { /** The menu images. */ static Map menu_images = new HashMap(); - /** The max image height. */ - static int maxImageHeight = 0; /** The button padding. How much space between each experiment button */ static int buttonPadding = 4; @@ -231,7 +229,7 @@ protected static IPreferenceStore getPreferences() { GamaIcon.named(ThemeHelper.isDark() ? IGamaIcons.BUTTON_GUI : IGamaIcons.MENU_GUI).image()); images.put("new", GamaIcon.named(IGamaIcons.ADD_EXPERIMENT).image()); - for (Image im : images.values()) { maxImageHeight = Math.max(maxImageHeight, im.getBounds().height); } + //for (Image im : images.values()) { maxImageHeight = Math.max(maxImageHeight, im.getBounds().height); } } /** @@ -603,7 +601,6 @@ private void updateToolbar(final GamlEditorState newState, final boolean forceSt WorkbenchHelper.runInUI("Editor refresh", 50, m -> { if (toolbar == null || toolbar.isDisposed()) return; toolbar.wipe(SWT.LEFT, true); - toolbar.setDefaultHeight(maxImageHeight); final var c = state.getColor(); var msg = state.getStatus(); diff --git a/gama.ui.shared/src/gama/ui/shared/resources/GamaIcon.java b/gama.ui.shared/src/gama/ui/shared/resources/GamaIcon.java index 143a3fc3d2..6b443c0f42 100644 --- a/gama.ui.shared/src/gama/ui/shared/resources/GamaIcon.java +++ b/gama.ui.shared/src/gama/ui/shared/resources/GamaIcon.java @@ -86,15 +86,15 @@ public class GamaIcon { try { URL pngFolderURL = toFileURL(Platform.getBundle(IGamaIcons.PLUGIN_ID).getEntry(IGamaIcons.ICONS_PATH)); tmp = Path.of(new URI(pngFolderURL.getProtocol(), pngFolderURL.getPath(), null).normalize()); - } catch (Exception e) {} + } catch (Exception e) { + } PATH_TO_ICONS = tmp; } /** * Preload icons. * - * @param bundle - * the bundle + * @param bundle the bundle * @throws IOException */ public static void preloadAllIcons() throws IOException { @@ -107,26 +107,43 @@ public static void preloadAllIcons() throws IOException { /** * Returns the icon named after the path (eg "templates/square.template") * - * @param path - * the path + * @param path the path * @return the gama icon */ public static GamaIcon named(final String s) { try { // DEBUG.OUT("Looking for icon " + s); - if (s != null) return ICON_CACHE.get(s, () -> new GamaIcon(s)); - } catch (ExecutionException e) {} + if (s != null) + return ICON_CACHE.get(s, () -> new GamaIcon(s)); + } catch (ExecutionException e) { + } return named(MISSING); } + /** + * Creates a transparent icon of the desired and width (and 1px wide) + * + */ + + public static GamaIcon ofSize(int width, int height) { + final String name = "size" + width + "x" + height; + try { + return ICON_CACHE.get(name, () -> { + DEBUG.OUT(name + " not found. Building it"); + GamaImage bi = GamaImage.ofDimensions(width, height, true); + return new GamaIcon(name, bi); + }); + } catch (Exception e) { + return null; + } + } + /** * Creates a color icon, either a round square or a circle * - * @param gcolor - * the gcolor - * @param square - * the square + * @param gcolor the gcolor + * @param square the square * @return the image */ @@ -170,12 +187,9 @@ public static GamaIcon ofColor(final GamaUIColor gcolor, final boolean square) { /** * Constructor for images loaded from a plugin * - * @param c - * the code - * @param p - * the path (in the 'icons' folder) - * @param plugin - * the id of the plugin in which the 'icons' folder resides + * @param c the code + * @param p the path (in the 'icons' folder) + * @param plugin the id of the plugin in which the 'icons' folder resides */ private GamaIcon(final String c) { DEBUG.OUT("Creation of icon " + c, false); @@ -188,12 +202,11 @@ private GamaIcon(final String c) { } /** - * Instantiates a new gama icon directly from an image. We do not produce disabled versions + * Instantiates a new gama icon directly from an image. We do not produce + * disabled versions * - * @param name - * the name - * @param im - * the im + * @param name the name + * @param im the im */ private GamaIcon(final String path, final Image im, final Image disabled) { code = path; @@ -207,10 +220,8 @@ private GamaIcon(final String path, final Image im, final Image disabled) { * Instantiates a new gama icon. * * @author Alexis Drogoul (alexis.drogoul@ird.fr) - * @param path - * the path - * @param im - * the im + * @param path the path + * @param im the im * @date 13 sept. 2023 */ private GamaIcon(final String path, final GamaImage im) { @@ -220,15 +231,15 @@ private GamaIcon(final String path, final GamaImage im) { /** * Creates a SWT image from a Java BufferedImage. * - * @param bufferedImage - * the image. + * @param bufferedImage the image. * @return returns a SWT image. */ public static Image toSWTImage(final GamaImage im) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(im, "png", out); - } catch (IOException e) {} + } catch (IOException e) { + } ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); return new Image(Display.getCurrent(), new ImageData(in)); } @@ -247,10 +258,8 @@ private static class DisabledFilter extends RGBImageFilter { /** * Instantiates a new disabled filter. * - * @param min - * the min - * @param max - * the max + * @param min the min + * @param max the max */ DisabledFilter() { canFilterIndexColorModel = true; @@ -275,13 +284,13 @@ public int filterRGB(final int x, final int y, final int rgb) { * To buffered image. * * @author Alexis Drogoul (alexis.drogoul@ird.fr) - * @param img - * the img + * @param img the img * @return the buffered image * @date 15 sept. 2023 */ public static BufferedImage toBufferedImage(final java.awt.Image img) { - if (img instanceof BufferedImage) return (BufferedImage) img; + if (img instanceof BufferedImage) + return (BufferedImage) img; BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D bGr = bimage.createGraphics(); bGr.drawImage(img, 0, 0, null); @@ -292,8 +301,7 @@ public static BufferedImage toBufferedImage(final java.awt.Image img) { /** * Creates a SWT image from a Java BufferedImage. * - * @param bufferedImage - * the image. + * @param bufferedImage the image. * @return returns a SWT image. */ public static Image toDisabledSWTImage(final BufferedImage im) { @@ -302,7 +310,8 @@ public static Image toDisabledSWTImage(final BufferedImage im) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(toBufferedImage(gray), "png", out); - } catch (IOException e) {} + } catch (IOException e) { + } ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); return new Image(Display.getCurrent(), new ImageData(in)); } @@ -321,8 +330,7 @@ public static Image toDisabledSWTImage(final BufferedImage im) { * To checked SWT image. * * @author Alexis Drogoul (alexis.drogoul@ird.fr) - * @param im - * the im + * @param im the im * @return the image * @date 15 sept. 2023 */ @@ -330,7 +338,8 @@ public static Image toCheckedSWTImage(final GamaImage im) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(ImageOperators.darker(null, im, 0.5), "png", out); - } catch (IOException e) {} + } catch (IOException e) { + } ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); return new Image(Display.getCurrent(), new ImageData(in)); @@ -364,8 +373,11 @@ private Image image(final String key, final Callable imageCreator) { if (image == null) { try { image = imageCreator.call(); - } catch (Exception e) {} - if (image == null) { image = named(MISSING).image(); } + } catch (Exception e) { + } + if (image == null) { + image = named(MISSING).image(); + } if (JFaceResources.getImageRegistry().get(key) == null) { JFaceResources.getImageRegistry().put(key, image); } @@ -408,7 +420,9 @@ public Image checked() { * * @return the code */ - public String getCode() { return code; } + public String getCode() { + return code; + } /** * Compute URL. diff --git a/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbar2.java b/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbar2.java index 2df294de12..4ad8b2e940 100644 --- a/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbar2.java +++ b/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbar2.java @@ -57,58 +57,59 @@ public class GamaToolbar2 extends Composite { /** The has tooltip. */ private boolean hasTooltip; - /** The height. */ - int height; - /** The is visible. */ boolean isVisible = true; /** * Instantiates a new gama toolbar 2. * - * @param parent - * the parent - * @param style - * the style - * @param height - * the height - */ - public GamaToolbar2(final Composite parent, final int style, final int height) { + * @param parent the parent + * @param style the style + * @param height the height + */ + public GamaToolbar2(final Composite parent, final int style) { super(parent, SWT.NONE); - this.height = height; createLayout(); createToolbars(); } /** - * Empty to prevent the CSS engine from changing the color now and then (apparently randomly) + * Empty to prevent the CSS engine from changing the color now and then + * (apparently randomly) */ @Override public void setBackground(final Color c) { - // DEBUG.OUT("setBackground() Called by " + DEBUG.CALLER() + "." + DEBUG.METHOD()); + // DEBUG.OUT("setBackground() Called by " + DEBUG.CALLER() + "." + + // DEBUG.METHOD()); } /** * Sets the background color. * - * @param c - * the new background color + * @param c the new background color */ // Necessary to have the background color "stick" public void setBackgroundColor(final Color c) { - // DEBUG.OUT("setBackgroundColor() called by = " + DEBUG.METHOD() + " of " + DEBUG.CALLER()); + // DEBUG.OUT("setBackgroundColor() called by = " + DEBUG.METHOD() + " of " + + // DEBUG.CALLER()); // Calls super explicitly Color color = c; - if (color == null) { color = isDark() ? getShell().getBackground() : IGamaColors.WHITE.color(); } + if (color == null) { + color = isDark() ? getShell().getBackground() : IGamaColors.WHITE.color(); + } super.setBackground(color); GamaColors.setBackground(color, this, left, right); } @Override - public void setVisible(final boolean visible) { isVisible = visible; } + public void setVisible(final boolean visible) { + isVisible = visible; + } @Override - public boolean isVisible() { return isVisible; } + public boolean isVisible() { + return isVisible; + } /** * Creates the layout. @@ -128,11 +129,9 @@ public void createLayout() { public void createToolbars() { left = new GamaToolbarSimple(this, SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP | SWT.NO_FOCUS | SWT.INHERIT_FORCE); var data = new GridData(SWT.LEFT, SWT.CENTER, true, true); - data.minimumWidth = height * 2; left.setLayoutData(data); right = new GamaToolbarSimple(this, SWT.FLAT | SWT.HORIZONTAL | SWT.NO_FOCUS); data = new GridData(SWT.RIGHT, SWT.FILL, true, false); - data.minimumWidth = height * 2; right.setLayoutData(data); setBackgroundColor(null); } @@ -150,15 +149,14 @@ public void noLeftToolbar() { } @Override - protected void checkSubclass() {} + protected void checkSubclass() { + } /** * Sep. Width is not used anymore * - * @param width - * the n - * @param side - * the side + * @param width the n + * @param side the side * @return the tool item */ public ToolItem sep(final int width, final int side /* SWT.LEFT or SWT.RIGHT */) { @@ -168,8 +166,7 @@ public ToolItem sep(final int width, final int side /* SWT.LEFT or SWT.RIGHT */) /** * Sep. * - * @param side - * the side + * @param side the side * @return the tool item */ public ToolItem sep(final int side /* SWT.LEFT or SWT.RIGHT */) { @@ -179,14 +176,10 @@ public ToolItem sep(final int side /* SWT.LEFT or SWT.RIGHT */) { /** * Status. * - * @param image - * the image - * @param s - * the s - * @param color - * the color - * @param side - * the side + * @param image the image + * @param s the s + * @param color the color + * @param side the side * @return the tool item */ public ToolItem status(final Image image, final String s, final GamaUIColor color, @@ -200,16 +193,11 @@ public ToolItem status(final Image image, final String s, final GamaUIColor colo /** * Status. * - * @param image - * the image - * @param s - * the s - * @param l - * the l - * @param color - * the color - * @param side - * the side + * @param image the image + * @param s the s + * @param l the l + * @param color the color + * @param side the side * @return the tool item */ public ToolItem status(final Image image, final String s, final Selector l, final GamaUIColor color, @@ -224,17 +212,15 @@ public ToolItem status(final Image image, final String s, final Selector l, fina /** * Tooltip. * - * @param s - * the s - * @param rgb - * the rgb - * @param side - * the side + * @param s the s + * @param rgb the rgb + * @param side the side * @return the tool item */ public ToolItem tooltip(final String s, final GamaUIColor rgb, final int side /* SWT.LEFT or SWT.RIGHT */) { Color color = rgb == null ? getBackground() : rgb.color(); - if (s == null) return null; + if (s == null) + return null; hasTooltip = true; final var tb = getToolbar(side); wipe(side, false); @@ -257,10 +243,13 @@ public ToolItem tooltip(final String s, final GamaUIColor rgb, final int side /* final var reader = new BufferedReader(new StringReader(s)); var line = reader.readLine(); while (line != null) { - if (!line.trim().isEmpty()) { newString.append(line).append(System.lineSeparator()); } + if (!line.trim().isEmpty()) { + newString.append(line).append(System.lineSeparator()); + } line = reader.readLine(); } - } catch (final IOException exc) {} + } catch (final IOException exc) { + } label.setText(newString.toString()); // label.setFont(GamaFonts.getSmallFont()); label.setBackground(color/* .inactive() */); @@ -272,16 +261,11 @@ public ToolItem tooltip(final String s, final GamaUIColor rgb, final int side /* /** * Check. * - * @param image - * the image - * @param text - * the text - * @param tip - * the tip - * @param listener - * the listener - * @param side - * the side + * @param image the image + * @param text the text + * @param tip the tip + * @param listener the listener + * @param side the side * @return the tool item */ public ToolItem check(final String image, final String text, final String tip, final Selector listener, @@ -292,10 +276,8 @@ public ToolItem check(final String image, final String text, final String tip, f /** * Check. * - * @param command - * the command - * @param side - * the side + * @param command the command + * @param side the side * @return the tool item */ public ToolItem check(final GamaCommand command, final int side) { @@ -305,16 +287,11 @@ public ToolItem check(final GamaCommand command, final int side) { /** * Button. * - * @param image - * the image - * @param text - * the text - * @param tip - * the tip - * @param listener - * the listener - * @param side - * the side + * @param image the image + * @param text the text + * @param tip the tip + * @param listener the listener + * @param side the side * @return the tool item */ public ToolItem button(final String image, final String text, final String tip, final Selector listener, @@ -325,10 +302,8 @@ public ToolItem button(final String image, final String text, final String tip, /** * Button. * - * @param command - * the command - * @param side - * the side + * @param command the command + * @param side the side * @return the tool item */ public ToolItem button(final GamaCommand command, final int side) { @@ -338,14 +313,10 @@ public ToolItem button(final GamaCommand command, final int side) { /** * Button. * - * @param color - * the color - * @param text - * the text - * @param listener - * the listener - * @param side - * the side + * @param color the color + * @param text the text + * @param listener the listener + * @param side the side * @return the tool item */ public ToolItem button(final GamaUIColor color, final String text, final Selector listener, final int side) { @@ -357,14 +328,10 @@ public ToolItem button(final GamaUIColor color, final String text, final Selecto /** * Button. * - * @param color - * the color - * @param text - * the text - * @param image - * the image - * @param side - * the side + * @param color the color + * @param text the text + * @param image the image + * @param side the side * @return the tool item */ public ToolItem button(final GamaUIColor color, final String text, final Image image, final int side) { @@ -375,16 +342,11 @@ public ToolItem button(final GamaUIColor color, final String text, final Image i /** * Button. * - * @param color - * the color - * @param text - * the text - * @param image - * the image - * @param listener - * the listener - * @param side - * the side + * @param color the color + * @param text the text + * @param image the image + * @param listener the listener + * @param side the side * @return the tool item */ public ToolItem button(final GamaUIColor color, final String text, final Image image, final Selector listener, @@ -397,12 +359,9 @@ public ToolItem button(final GamaUIColor color, final String text, final Image i /** * Menu. * - * @param color - * the color - * @param text - * the text - * @param side - * the side + * @param color the color + * @param text the text + * @param side the side * @return the tool item */ public ToolItem menu(final GamaUIColor color, final String text, final int side) { @@ -413,16 +372,11 @@ public ToolItem menu(final GamaUIColor color, final String text, final int side) /** * Menu. * - * @param image - * the image - * @param text - * the text - * @param tip - * the tip - * @param listener - * the listener - * @param side - * the side + * @param image the image + * @param text the text + * @param tip the tip + * @param listener the listener + * @param side the side * @return the tool item */ public ToolItem menu(final String image, final String text, final String tip, final Selector listener, @@ -433,12 +387,9 @@ public ToolItem menu(final String image, final String text, final String tip, fi /** * Control. * - * @param c - * the c - * @param width - * the width - * @param side - * the side + * @param c the c + * @param width the width + * @param side the side * @return the tool item */ public ToolItem control(final Control c, final int width, final int side /* SWT.LEFT or SWT.RIGHT */) { @@ -454,8 +405,7 @@ public ToolItem control(final Control c, final int width, final int side /* SWT. /** * Refresh. * - * @param layout - * the layout + * @param layout the layout */ @Override public void requestLayout() { @@ -474,8 +424,8 @@ public void requestLayout() { // } /** - * Wipes the toolbar (left or right), including or not the simple tool items. Retuns the width of the toolbar once - * wiped. + * Wipes the toolbar (left or right), including or not the simple tool items. + * Retuns the width of the toolbar once wiped. * * @param side * @param includingToolItems @@ -486,7 +436,9 @@ public void wipe(final int side /* SWT.LEFT or SWT.RIGHT */, final boolean inclu for (final ToolItem t : items) { final var c = t.getControl(); if (c == null && includingToolItems || c != null) { - if (c != null) { c.dispose(); } + if (c != null) { + c.dispose(); + } t.dispose(); } } @@ -498,10 +450,8 @@ public void wipe(final int side /* SWT.LEFT or SWT.RIGHT */, final boolean inclu /** * Item. * - * @param item - * the item - * @param side - * the side + * @param item the item + * @param side the side */ public void item(final IContributionItem item, final int side) { item.fill(getToolbar(side), getToolbar(side).getItemCount()); @@ -510,42 +460,35 @@ public void item(final IContributionItem item, final int side) { /** * Creates the. * - * @param image - * the image - * @param text - * the text - * @param tip - * the tip - * @param listener - * the listener - * @param style - * the style - * @param forceText - * the force text - * @param control - * the control - * @param side - * the side + * @param image the image + * @param text the text + * @param tip the tip + * @param listener the listener + * @param style the style + * @param forceText the force text + * @param control the control + * @param side the side * @return the tool item */ private ToolItem create(final String image, final String text, final String tip, final SelectionListener listener, final int style, final boolean forceText, final Control control, final int side /* SWT.LEFT or SWT.RIGHT */) { final var tb = getToolbar(side); - // DOES NOT SEEM TO BE NECESSARY ANYMORE (SEE #3677) - // if ( tb.getItemCount() == 0 && PlatformHelper.isWindows()) { - // int h = height; - // if (control != null) { h = Math.max(h, control.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) + 4; } - // final var icon = GamaIcon.ofSize(getBackground(), 2, h); - // final var button = new ToolItem(tb, SWT.NONE); - // final var im = icon.image(); - // button.setImage(im); - // button.setDisabledImage(im); - // button.setEnabled(false); - // } + if (tb.getItemCount() == 0 && PlatformHelper.isWindows() && control != null) { + final var icon = GamaIcon.ofSize(2, GamaToolbarFactory.TOOLBAR_HEIGHT); + final var button = new ToolItem(tb, SWT.NONE); + final var im = icon.image(); + button.setImage(im); + button.setDisabledImage(im); + button.setEnabled(false); + } final var button = new ToolItem(tb, style); - if (text != null && forceText) { button.setText(text); } - if (tip != null) { button.setToolTipText(tip); } + if (text != null && forceText) { + button.setText(text); + } + if (tip != null) { + button.setToolTipText(tip); + } if (image != null) { button.setData(image); GamaIcon icon = GamaIcon.named(image); @@ -578,7 +521,9 @@ private ToolItem create(final String image, final String text, final String tip, private void normalizeToolbars() { // final int n = right.getItemCount(); var size = 0; - for (final ToolItem t : right.getItems()) { size += t.getWidth(); } + for (final ToolItem t : right.getItems()) { + size += t.getWidth(); + } ((GridData) right.getLayoutData()).minimumWidth = size; } @@ -603,10 +548,11 @@ public boolean hasTooltip() { /** * Sets the toogle action. * - * @param toggle - * the new toogle action + * @param toggle the new toogle action */ - public void setToogleAction(final ToggleAction toggle) { this.toggle = toggle; } + public void setToogleAction(final ToggleAction toggle) { + this.toggle = toggle; + } /** * Hide. @@ -624,28 +570,16 @@ public void show() { toggle.run(); // will make it true } - /** - * Sets the default height. - * - * @param height - * the new default height - */ - public void setDefaultHeight(final int height) { - this.height = height; - - } - /** * Check selection icon. * - * @param button - * the button - * @param tb - * the tb + * @param button the button + * @param tb the tb */ private void checkSelectionIcon(final ToolItem button) { String image = (String) button.getData(); - if (image == null) return; + if (image == null) + return; if (PlatformHelper.isMac() && GamaColors.isDark(getBackground()) && !ThemeHelper.isDark()) { if (button.getSelection()) { button.setImage(GamaIcon.named(image).checked()); @@ -658,10 +592,8 @@ private void checkSelectionIcon(final ToolItem button) { /** * Sets the selection. * - * @param item - * the item - * @param selected - * the selected + * @param item the item + * @param selected the selected */ public void setSelection(final ToolItem item, final boolean selected) { item.setSelection(selected); diff --git a/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbarFactory.java b/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbarFactory.java index f9728c2db7..9e36b46728 100644 --- a/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbarFactory.java +++ b/gama.ui.shared/src/gama/ui/shared/views/toolbar/GamaToolbarFactory.java @@ -56,10 +56,8 @@ public static class GamaComposite extends Composite { /** * Instantiates a new gama composite. * - * @param parent - * the parent - * @param displayer - * the displayer + * @param parent the parent + * @param displayer the displayer */ public GamaComposite(final Composite parent, final ITooltipDisplayer displayer) { super(parent, SWT.None); @@ -71,8 +69,7 @@ public GamaComposite(final Composite parent, final ITooltipDisplayer displayer) /** * Find tooltip displayer. * - * @param c - * the c + * @param c the c * @return the i tooltip displayer */ public static ITooltipDisplayer findTooltipDisplayer(final Control c) { @@ -83,13 +80,14 @@ public static ITooltipDisplayer findTooltipDisplayer(final Control c) { /** * Find gama composite. * - * @param c - * the c + * @param c the c * @return the gama composite */ public static GamaComposite findGamaComposite(final Control c) { - if (c instanceof Shell) return null; - if (c instanceof GamaComposite) return (GamaComposite) c; + if (c instanceof Shell) + return null; + if (c instanceof GamaComposite) + return (GamaComposite) c; return findGamaComposite(c.getParent()); } @@ -110,8 +108,7 @@ public static abstract class ToggleAction extends Action { /** * Sets the icon. * - * @param show - * the new icon + * @param show the new icon */ protected abstract void setIcon(boolean show); @@ -177,7 +174,7 @@ public static class ToggleOverlay extends Action { } /** The toolbar height. */ - public static final int TOOLBAR_HEIGHT = 24; // CORE_ICONS_HEIGHT.getValue();Ì + public static final int TOOLBAR_HEIGHT = 24; /** The toolbar sep. */ public static final int TOOLBAR_SEP = 4; @@ -185,10 +182,8 @@ public static class ToggleOverlay extends Action { /** * Creates a new GamaToolbar object. * - * @param view - * the view - * @param composite - * the composite + * @param view the view + * @param composite the composite * @return the composite */ private static Composite createIntermediateCompositeFor(final IToolbarDecoratedView view, @@ -240,8 +235,7 @@ public static FillLayout getLayoutForChild() { /** * Creates a new GamaToolbar object. * - * @param composite - * the composite + * @param composite the composite * @return the composite */ public static Composite createToolbarComposite(final Composite composite) { @@ -268,10 +262,8 @@ public static Composite createToolbarComposite(final Composite composite) { /** * Creates a new GamaToolbar object. * - * @param view - * the view - * @param composite - * the composite + * @param view the view + * @param composite the composite * @return the composite */ public static Composite createToolbars(final IToolbarDecoratedView view, final Composite composite) { @@ -281,8 +273,7 @@ public static Composite createToolbars(final IToolbarDecoratedView view, final C childComposite.setLayoutData(getLayoutDataForChild()); childComposite.setLayout(getLayoutForChild()); - final GamaToolbar2 tb = - new GamaToolbar2(toolbarComposite, SWT.FLAT | SWT.HORIZONTAL | SWT.NO_FOCUS, TOOLBAR_HEIGHT); + final GamaToolbar2 tb = new GamaToolbar2(toolbarComposite, SWT.FLAT | SWT.HORIZONTAL | SWT.NO_FOCUS); final GridData data = layoutDataForToolbar(); tb.setLayoutData(data); composite.addDisposeListener(e -> disposeToolbar(view, tb)); @@ -353,8 +344,8 @@ public void run() { * @return the grid data */ public static GridData layoutDataForToolbar() { - final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); - // data.minimumHeight = TOOLBAR_HEIGHT; + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.minimumHeight = TOOLBAR_HEIGHT; data.minimumWidth = TOOLBAR_HEIGHT * 2; return data; } @@ -362,22 +353,20 @@ public static GridData layoutDataForToolbar() { /** * Dispose toolbar. * - * @param view - * the view - * @param tb - * the tb + * @param view the view + * @param tb the tb */ public static void disposeToolbar(final IToolbarDecoratedView view, final GamaToolbar2 tb) { - if (tb != null && !tb.isDisposed()) { tb.dispose(); } + if (tb != null && !tb.isDisposed()) { + tb.dispose(); + } } /** * Builds the toolbar. * - * @param view - * the view - * @param tb - * the tb + * @param view the view + * @param tb the tb */ public static void buildToolbar(final IToolbarDecoratedView view, final GamaToolbar2 tb) { if (view instanceof IToolbarDecoratedView.Sizable) { @@ -397,13 +386,13 @@ public static void buildToolbar(final IToolbarDecoratedView view, final GamaTool b.install(tb); } if (view instanceof IToolbarDecoratedView.CSVExportable) { - final CSVExportationController csv = - new CSVExportationController((IToolbarDecoratedView.CSVExportable) view); + final CSVExportationController csv = new CSVExportationController( + (IToolbarDecoratedView.CSVExportable) view); csv.install(tb); } if (view instanceof IToolbarDecoratedView.LogExportable) { - final LogExportationController log = - new LogExportationController((IToolbarDecoratedView.LogExportable) view); + final LogExportationController log = new LogExportationController( + (IToolbarDecoratedView.LogExportable) view); log.install(tb); } @@ -414,8 +403,7 @@ public static void buildToolbar(final IToolbarDecoratedView view, final GamaTool /** * Visually update. * - * @param tb - * the tb + * @param tb the tb */ // public static void visuallyUpdate(final ToolBar tb) { // Not needed anymore in Eclipse 2021-09. See issue #3210 diff --git a/gama.ui.shared/src/gama/ui/shared/views/toolbar/ZoomController.java b/gama.ui.shared/src/gama/ui/shared/views/toolbar/ZoomController.java index 3b047ffe3f..5fec946c64 100644 --- a/gama.ui.shared/src/gama/ui/shared/views/toolbar/ZoomController.java +++ b/gama.ui.shared/src/gama/ui/shared/views/toolbar/ZoomController.java @@ -150,7 +150,7 @@ public void widgetSelected(final SelectionEvent e) { }, GamaIcon.named(IGamaIcons.PASTE).image()); } }; - menu.open(tb.getToolbar(SWT.RIGHT), trigger, tb.height, 96); + menu.open(tb.getToolbar(SWT.RIGHT), trigger, tb.getToolbar(SWT.RIGHT).getSize().y, 96); }, SWT.RIGHT); } cameraLocked = tb.check(IGamaIcons.CAMERA_LOCK, "Lock/unlock", "Lock/unlock view", e -> { view.toggleLock(); },