Skip to content

Commit

Permalink
Fixes java-decompiler#13, Adds "Dropping files onto the OSX Dock icon"
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Apr 18, 2015
1 parent 82075c8 commit beb8418
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies {
compile 'org.codehaus.groovy:groovy:2.4.0'
compile 'org.codehaus.groovy:groovy-swing:2.4.0'
compile 'org.codehaus.groovy:groovy-xml:2.4.0'
provided 'com.yuvimasory:orange-extensions:1.3.0'
compile project(':api')
runtime project(':services')
}
8 changes: 4 additions & 4 deletions app/src/main/groovy/jd/gui/App.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import javax.swing.JOptionPane
import jd.gui.controller.MainController

class App {
static MainController controller

static void main(String[] args) {
if (args.contains("-h")) {
Expand All @@ -31,10 +32,9 @@ Option:
swing.lookAndFeel(configuration.lookAndFeel)

// Create main controller and show main frame
new MainController(swing, configuration).with {
show()
openFiles(args.collect { new File(it) })
}
controller = new MainController(swing, configuration)
controller.show()
controller.openFiles(args.collect { new File(it) })
}
}
}
31 changes: 31 additions & 0 deletions app/src/main/groovy/jd/gui/OsxApp.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package jd.gui

import com.apple.eawt.AppEvent
import com.apple.eawt.Application
import com.apple.eawt.OpenFilesHandler
import com.apple.eawt.QuitHandler
import com.apple.eawt.QuitResponse

class OsxApp extends App {

static void main(String[] args) {
// Create an instance of the mac OSX Application class
def application = new Application()

App.main(args)

// Add an handle invoked when the application is asked to open a list of files
application.setOpenFileHandler(new OpenFilesHandler() {
void openFiles(AppEvent.OpenFilesEvent e) {
controller.openFiles(e.files)
}
})

// Add an handle invoked when the application is asked to quit
application.setQuitHandler(new QuitHandler() {
void handleQuitRequestWith(AppEvent.QuitEvent e, QuitResponse response) {
System.exit(0)
}
})
}
}
27 changes: 16 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ allprojects {
repositories {
mavenCentral()
}

configurations {
provided
compile.extendsFrom provided
}
}

// 'cleanIdea' task extension //
Expand All @@ -35,17 +40,17 @@ subprojects.each { subproject ->
}

jar {
dependsOn subprojects.tasks['classes']
manifest {
attributes 'Main-Class': 'jd.gui.App', 'SplashScreen-Image': 'images/Icon_java_128.png'
}
def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.compile
}
from { deps.unique().collect { it.isDirectory() ? it : zipTree(it) } }
dependsOn subprojects.tasks['classes']
manifest {
attributes 'Main-Class': 'jd.gui.App', 'SplashScreen-Image': 'images/Icon_java_128.png'
}
def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.runtime - subproject.configurations.provided
}
from { deps.unique().collect { it.isDirectory() ? it : zipTree(it) } }
}

// Distribution for OSX //
Expand Down
2 changes: 1 addition & 1 deletion src/osx/dist/JD-GUI.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</array>
<key>JavaX</key>
<dict>
<key>MainClass</key> <string>jd.gui.App</string>
<key>MainClass</key> <string>jd.gui.OsxApp</string>
<key>JVMVersion</key> <string>1.7+</string>
<key>ClassPath</key> <string>$JAVAROOT/jd-gui-1.0.0.jar</string>
<key>WorkingDirectory</key> <string>$JAVAROOT</string>
Expand Down

0 comments on commit beb8418

Please sign in to comment.