From c679cc5e0b230c59517b89d50eb5b94dfe4a382a Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 10 Feb 2021 00:19:36 +0000 Subject: [PATCH] JAL-3521 Change grouped Jalview windows on linux taskbar to have name Jalview --- src/jalview/gui/Desktop.java | 109 +++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 44 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 21a0e37..e9cc8e9 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -20,34 +20,6 @@ */ package jalview.gui; -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.bin.Cache; -import jalview.bin.Jalview; -import jalview.io.BackupFiles; -import jalview.io.DataSourceType; -import jalview.io.FileFormat; -import jalview.io.FileFormatException; -import jalview.io.FileFormatI; -import jalview.io.FileFormats; -import jalview.io.FileLoader; -import jalview.io.FormatAdapter; -import jalview.io.IdentifyFile; -import jalview.io.JalviewFileChooser; -import jalview.io.JalviewFileView; -import jalview.jbgui.GSplitFrame; -import jalview.jbgui.GStructureViewer; -import jalview.project.Jalview2XML; -import jalview.structure.StructureSelectionManager; -import jalview.urls.IdOrgSettings; -import jalview.util.ImageMaker; -import jalview.util.MessageManager; -import jalview.util.Platform; -import jalview.util.UrlConstants; -import jalview.viewmodel.AlignmentViewport; -import jalview.ws.params.ParamManager; -import jalview.ws.utils.UrlDownloadClient; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -80,6 +52,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.lang.reflect.Field; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; @@ -120,6 +93,34 @@ import javax.swing.event.InternalFrameEvent; import org.stackoverflowusers.file.WindowsShortcut; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; +import jalview.bin.Jalview; +import jalview.io.BackupFiles; +import jalview.io.DataSourceType; +import jalview.io.FileFormat; +import jalview.io.FileFormatException; +import jalview.io.FileFormatI; +import jalview.io.FileFormats; +import jalview.io.FileLoader; +import jalview.io.FormatAdapter; +import jalview.io.IdentifyFile; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.jbgui.GSplitFrame; +import jalview.jbgui.GStructureViewer; +import jalview.project.Jalview2XML; +import jalview.structure.StructureSelectionManager; +import jalview.urls.IdOrgSettings; +import jalview.util.ImageMaker; +import jalview.util.MessageManager; +import jalview.util.Platform; +import jalview.util.UrlConstants; +import jalview.viewmodel.AlignmentViewport; +import jalview.ws.params.ParamManager; +import jalview.ws.utils.UrlDownloadClient; + /** * Jalview Desktop * @@ -344,7 +345,8 @@ public class Desktop extends jalview.jbgui.GDesktop instance = this; doConfigureStructurePrefs(); - setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION")); + String title = "Jalview " + Cache.getProperty("VERSION"); + setTitle(title); /* if (!Platform.isAMac()) { @@ -369,6 +371,20 @@ public class Desktop extends jalview.jbgui.GDesktop // t.printStackTrace(); } + if (Platform.isLinux()) + { + try + { + Toolkit xToolkit = Toolkit.getDefaultToolkit(); + Field awtAppClassNameField = xToolkit.getClass() + .getDeclaredField("awtAppClassName"); + awtAppClassNameField.setAccessible(true); + awtAppClassNameField.set(xToolkit, "Jalview"); + } catch (Exception e) + { + Cache.log.debug("Could not set awtAppClassName"); + } + } addWindowListener(new WindowAdapter() { @@ -957,7 +973,8 @@ public class Desktop extends jalview.jbgui.GDesktop KeyStroke ctrlWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK); KeyStroke cmdWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, - jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()); + jalview.util.ShortcutKeyMaskExWrapper + .getMenuShortcutKeyMaskEx()); InputMap inputMap = frame .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); @@ -1070,8 +1087,9 @@ public class Desktop extends jalview.jbgui.GDesktop public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport) { String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); - JalviewFileChooser chooser = JalviewFileChooser - .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat, BackupFiles.getEnabled()); + JalviewFileChooser chooser = JalviewFileChooser.forRead( + Cache.getProperty("LAST_DIRECTORY"), fileFormat, + BackupFiles.getEnabled()); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle( @@ -1696,8 +1714,10 @@ public class Desktop extends jalview.jbgui.GDesktop "Jalview Project (old)" }; JalviewFileChooser chooser = new JalviewFileChooser( Cache.getProperty("LAST_DIRECTORY"), suffix, desc, - "Jalview Project", true, BackupFiles.getEnabled()); // last two booleans: allFiles, - // allowBackupFiles + "Jalview Project", true, BackupFiles.getEnabled()); // last two + // booleans: + // allFiles, + // allowBackupFiles chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.restore_state")); @@ -1926,9 +1946,7 @@ public class Desktop extends jalview.jbgui.GDesktop // FIXME: ideally should use UI interface API FeatureSettings viewFeatureSettings = (af.featureSettings != null - && af.featureSettings.isOpen()) - ? af.featureSettings - : null; + && af.featureSettings.isOpen()) ? af.featureSettings : null; Rectangle fsBounds = af.getFeatureSettingsGeometry(); for (int i = 0; i < size; i++) { @@ -1961,7 +1979,8 @@ public class Desktop extends jalview.jbgui.GDesktop addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - // and materialise a new feature settings dialog instance for the new alignframe + // and materialise a new feature settings dialog instance for the new + // alignframe // (closes the old as if 'OK' was pressed) if (ap == af.alignPanel && newaf.featureSettings != null && newaf.featureSettings.isOpen() @@ -2032,8 +2051,7 @@ public class Desktop extends jalview.jbgui.GDesktop } } // refresh the feature setting UI for the source frame if it exists - if (source.featureSettings != null - && source.featureSettings.isOpen()) + if (source.featureSettings != null && source.featureSettings.isOpen()) { source.showFeatureSettingsUI(); } @@ -2387,9 +2405,12 @@ public class Desktop extends jalview.jbgui.GDesktop */ protected void addQuitHandler() { - getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, - jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()), + getRootPane() + .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + KeyStroke + .getKeyStroke(KeyEvent.VK_Q, + jalview.util.ShortcutKeyMaskExWrapper + .getMenuShortcutKeyMaskEx()), "Quit"); getRootPane().getActionMap().put("Quit", new AbstractAction() { @@ -2587,7 +2608,7 @@ public class Desktop extends jalview.jbgui.GDesktop */ public void startServiceDiscovery(boolean blocking) { - startServiceDiscovery(blocking,false); + startServiceDiscovery(blocking, false); } /** -- 1.7.10.2