patch for mac-specific file handler

This commit is contained in:
bancika
2020-09-07 08:47:50 +02:00
parent 94d713182e
commit 5164501228
2 changed files with 46 additions and 38 deletions
+1
View File
@@ -14,6 +14,7 @@
<classpathentry kind="lib" path="lib/balloontip-1.2.4.1.jar"/> <classpathentry kind="lib" path="lib/balloontip-1.2.4.1.jar"/>
<classpathentry kind="lib" path="lib/jep-2.4.1.jar"/> <classpathentry kind="lib" path="lib/jep-2.4.1.jar"/>
<classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/> <classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/>
<classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/> <classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/> <classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/> <classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
@@ -35,6 +35,7 @@ import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.PropertyInjector; import org.diylc.appframework.miscutils.PropertyInjector;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.core.IView; import org.diylc.core.IView;
import org.diylc.lang.LangUtil; import org.diylc.lang.LangUtil;
@@ -67,15 +68,15 @@ public class DIYLCStarter {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// Initialize splash screen // Initialize splash screen
DIYLCSplash splash = null; DIYLCSplash splash = null;
Exception splashException = null; Exception splashException = null;
try { try {
splash = new DIYLCSplash(); splash = new DIYLCSplash();
} catch (Exception e) { } catch (Exception e) {
System.out.println("Splash screen could not be initialized: " + e.getMessage()); System.out.println("Splash screen could not be initialized: " + e.getMessage());
splashException = e; splashException = e;
} }
URL url = DIYLCStarter.class.getResource("log4j.properties"); URL url = DIYLCStarter.class.getResource("log4j.properties");
Properties properties = new Properties(); Properties properties = new Properties();
@@ -119,7 +120,9 @@ public class DIYLCStarter {
for (int i = 0; i < fonts.length; i++) { for (int i = 0; i < fonts.length; i++) {
try { try {
LOG.info("Dynamically loading font: " + fonts[i].getName()); LOG.info("Dynamically loading font: " + fonts[i].getName());
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f); Font customFont =
Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath()))
.deriveFont(12f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// register the font // register the font
ge.registerFont(customFont); ge.registerFont(customFont);
@@ -141,11 +144,11 @@ public class DIYLCStarter {
String val = System.getProperty(SCRIPT_RUN); String val = System.getProperty(SCRIPT_RUN);
if (!"true".equals(val)) { if (!"true".equals(val)) {
int response = int response = JOptionPane.showConfirmDialog(null,
JOptionPane.showConfirmDialog(null, "It is not recommended to run DIYLC by clicking on the diylc.jar file.\n" "It is not recommended to run DIYLC by clicking on the diylc.jar file.\n"
+ "Please use diylc.exe on Windows or run.sh on OSX/Linux to ensure the best\n" + "Please use diylc.exe on Windows or run.sh on OSX/Linux to ensure the best\n"
+ "performance and reliability. Do you want to continue?", "DIYLC", JOptionPane.YES_NO_OPTION, + "performance and reliability. Do you want to continue?",
JOptionPane.WARNING_MESSAGE); "DIYLC", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (response != JOptionPane.YES_OPTION) { if (response != JOptionPane.YES_OPTION) {
System.exit(0); System.exit(0);
} }
@@ -153,7 +156,7 @@ public class DIYLCStarter {
MainFrame mainFrame = new MainFrame(); MainFrame mainFrame = new MainFrame();
Presenter presenter = mainFrame.getPresenter(); Presenter presenter = mainFrame.getPresenter();
// mainFrame.setLocationRelativeTo(null); // mainFrame.setLocationRelativeTo(null);
if (splash == null) { if (splash == null) {
LOG.warn("Splash screen could not be initialized", splashException); LOG.warn("Splash screen could not be initialized", splashException);
@@ -164,22 +167,26 @@ public class DIYLCStarter {
mainFrame.setVisible(true); mainFrame.setVisible(true);
SwingUtilities.invokeLater(() -> { // assign open file handler for Mac
Application.getApplication().setOpenFileHandler((AppEvent.OpenFilesEvent ofe) -> { if (Utils.isMac()) {
List<File> files = ofe.getFiles(); SwingUtilities.invokeLater(() -> {
if (files != null && files.size() > 0) { Application.getApplication().setOpenFileHandler((AppEvent.OpenFilesEvent ofe) -> {
String filePath = files.get(0).getAbsolutePath(); List<File> files = ofe.getFiles();
if (presenter.allowFileAction()) { if (files != null && files.size() > 0) {
presenter.loadProjectFromFile(filePath); String filePath = files.get(0).getAbsolutePath();
if (presenter.allowFileAction()) {
presenter.loadProjectFromFile(filePath);
}
} }
} });
}); });
}); }
if (args.length > 0) { if (args.length > 0) {
presenter.loadProjectFromFile(args[0]); presenter.loadProjectFromFile(args[0]);
} else { } else {
boolean showTemplates = ConfigurationManager.getInstance().readBoolean(TemplateDialog.SHOW_TEMPLATES_KEY, false); boolean showTemplates =
ConfigurationManager.getInstance().readBoolean(TemplateDialog.SHOW_TEMPLATES_KEY, false);
if (showTemplates) { if (showTemplates) {
TemplateDialog templateDialog = new TemplateDialog(mainFrame, mainFrame.getPresenter()); TemplateDialog templateDialog = new TemplateDialog(mainFrame, mainFrame.getPresenter());
if (!templateDialog.getFiles().isEmpty()) { if (!templateDialog.getFiles().isEmpty()) {