Skip to content

Commit

Permalink
Fix console icon [ci fast] (#4991)
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored May 10, 2024
1 parent 5ff4453 commit b8a2370
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions plugins/nf-console/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
// this is required by 'groovy-console'
api("com.github.javaparser:javaparser-core:3.25.8")

testImplementation(testFixtures(project(":nextflow")))
testImplementation project(':nextflow')
testImplementation "org.apache.groovy:groovy:4.0.21"
testImplementation "org.apache.groovy:groovy-nio:4.0.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package nextflow.ui.console

import javax.swing.UIManager
import java.awt.Taskbar
import java.awt.Toolkit

import groovy.util.logging.Slf4j
import nextflow.cli.CliOptions
Expand Down Expand Up @@ -53,8 +55,9 @@ class ConsoleRunner implements ConsoleExtension {

//when starting via main set the look and feel to system
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
loadDockIcon()

def console = new Nextflow(ConsoleRunner.getClassLoader())
final console = new Nextflow(ConsoleRunner.getClassLoader())
console.useScriptClassLoaderForScriptExecution = true
console.run()
if (args.length == 2)
Expand All @@ -64,6 +67,23 @@ class ConsoleRunner implements ConsoleExtension {
catch( IOException e ) {
log.warn("Can't open script file: ${args[1]}" )
}
}

static void loadDockIcon() {
final URL imageResource = ConsoleRunner.getResource("/nextflow-icon.png");
final defaultToolkit = Toolkit.getDefaultToolkit()
final image = defaultToolkit.getImage(imageResource)
final taskbar = Taskbar.getTaskbar()
try {
//set icon for mac os (and other systems which do support this method)
taskbar.setIconImage(image)
}
catch (final UnsupportedOperationException e) {
log.debug("The os does not support: 'taskbar.setIconImage'")
}
catch (final SecurityException e) {
log.debug("There was a security exception for: 'taskbar.setIconImage'")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import javax.swing.filechooser.FileFilter
import java.nio.file.Path
import java.nio.file.Paths

import groovy.transform.ThreadInterrupt
import groovy.console.ui.Console
import groovy.console.ui.OutputTransforms
import groovy.transform.ThreadInterrupt
import groovy.util.logging.Slf4j
import nextflow.NextflowMeta
import nextflow.Session
Expand Down Expand Up @@ -53,7 +53,7 @@ class Nextflow extends Console {
frame(
title: TITLE,
//location: [100,100], // in groovy 2.0 use platform default location
iconImage: imageIcon('/nextflow_icon_48x48.png').image,
iconImage: imageIcon('/nextflow-icon.png').image,
defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
) {
try {
Expand All @@ -73,7 +73,6 @@ class Nextflow extends Console {
Nextflow(ClassLoader loader) {
super(loader, new ScriptBinding())
this.scriptConfig = createScriptConfig()

NextflowMeta.instance.enableDsl2()
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2020-2021. Seqera Labs, S.L.
*
* All Rights reserved
*
*/

package nextflow.ui.console

import spock.lang.Specification

/**
*
* @author Paolo Di Tommaso <[email protected]>
*/
class ConsoleRunnerTest extends Specification{

def 'should load nextflow icon' () {
expect:
ConsoleRunner.getResource("/nextflow-icon.png")
}

}

0 comments on commit b8a2370

Please sign in to comment.