Support Mac Drop-on-Dock file events

This commit is contained in:
Reinhard Pointner 2016-03-19 15:35:09 +00:00
parent adda35edd4
commit 52e96f4890
3 changed files with 11 additions and 1 deletions

View File

@ -232,6 +232,7 @@ public class Main {
MacAppUtilities.initializeApplication();
MacAppUtilities.setWindowCanFullScreen(frame);
MacAppUtilities.setDefaultMenuBar(FileBotMenuBar.createHelp());
MacAppUtilities.setOpenFileHandler(openFiles -> eventBus.post(new FileTransferable(openFiles)));
} else if (isUbuntuApp()) {
// Ubuntu specific configuration
String options = System.getenv("JAVA_TOOL_OPTIONS");

View File

@ -11,6 +11,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import javax.swing.JMenuBar;
@ -135,6 +136,14 @@ public class MacAppUtilities {
}
}
public static void setOpenFileHandler(Consumer<List<File>> handler) {
try {
Application.getApplication().setOpenFileHandler(evt -> handler.accept(evt.getFiles()));
} catch (Throwable t) {
debug.log(Level.WARNING, t.getMessage(), t);
}
}
public static void initializeApplication() {
// improved UI defaults
UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant"));

View File

@ -179,7 +179,7 @@ public class MainFrame extends JFrame {
if (builder != null) {
if (builder.equals(selectedBuilder)) {
selectedPanel = panel;
} else {
} else if (panel.isVisible()) {
panel.setVisible(false);
eventBus.unregister(panel);
}