Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/2039[#2039]: IDE logo not shown in mac task bar
* https://github.com/devonfw/IDEasy/issues/2176[#2176]: Support 7z archive extraction
* https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64
* https://github.com/devonfw/IDEasy/issues/1784[#1784]: GUI now supports displaying progress bars
Expand Down
27 changes: 26 additions & 1 deletion gui/src/main/java/com/devonfw/ide/gui/App.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.devonfw.ide.gui;

import java.awt.Taskbar;
import java.awt.Toolkit;
import java.io.IOException;
import java.net.URL;

import javafx.application.Application;
import javafx.application.Platform;
Expand All @@ -20,6 +23,7 @@
import com.devonfw.ide.gui.context.TaskManager;
import com.devonfw.ide.gui.modal.IdeDialog;
import com.devonfw.ide.gui.nls.NlsService;
import com.devonfw.tools.ide.os.SystemInfoImpl;
import com.devonfw.tools.ide.variable.IdeVariables;
import com.devonfw.tools.ide.version.IdeVersion;

Expand All @@ -28,6 +32,11 @@
*/
public class App extends Application {

/**
* Path to icon file used for GUI of IDEasy starting from {@code gui/src/main/resources}
*/
public static final String ICON_PATH = "com/devonfw/ide/gui/assets/devonfw.png";

Parent root;

private Stage primaryStage;
Expand Down Expand Up @@ -59,7 +68,11 @@ public void start(Stage primaryStage) throws IOException {
Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
Scene scene = new Scene(root, bounds.getWidth() / 2, bounds.getHeight() / 2);

Image icon = new Image("com/devonfw/ide/gui/assets/devonfw.png");
if (SystemInfoImpl.INSTANCE.isMac()) {
setIconInMacOsDock();
}

Image icon = new Image(ICON_PATH);
primaryStage.getIcons().add(icon);
primaryStage.setTitle("IDEasy - version " + IdeVersion.getVersionString());
primaryStage.setScene(scene);
Expand Down Expand Up @@ -119,6 +132,18 @@ private Parent loadMainView() throws IOException {
return fxmlLoader.load();
}

private void setIconInMacOsDock() {
try {
Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
URL imageResource = getClass().getClassLoader().getResource(ICON_PATH);
java.awt.Image image = defaultToolkit.getImage(imageResource);

Taskbar taskbar = Taskbar.getTaskbar();
taskbar.setIconImage(image);
} catch (UnsupportedOperationException e) {
LOG.error("Failed to set IDEasy icon in MacOS dock. ", e);
}
}

@SuppressWarnings("MissingJavadoc")
public static void main(String[] args) {
Expand Down
Loading