~tapaal-contributor/tapaal/autodetect-lens-check2

« back to all changes in this revision

Viewing changes to src/pipe/gui/CreateGui.java

merged in lp:~yrke/tapaal/evenMore-gui-cleanup doing GUI cleanup and fixing memory access check, about menu in Mac, exception in verification and reenabled quick draw

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package pipe.gui;
2
2
 
 
3
import java.awt.*;
3
4
import java.io.InputStream;
4
5
import java.util.ArrayList;
5
6
import java.util.List;
6
 
 
7
7
import com.sun.jna.Platform;
 
8
import dk.aau.cs.debug.Logger;
8
9
import net.tapaal.TAPAAL;
 
10
import net.tapaal.resourcemanager.ResourceManager;
9
11
import pipe.dataLayer.DataLayer;
10
12
import pipe.gui.canvas.DrawingSurfaceImpl;
11
 
import pipe.gui.handler.SpecialMacHandler;
12
13
import dk.aau.cs.gui.TabContent;
13
14
 
14
 
 
15
15
public class CreateGui {
16
16
 
17
17
        private final static GuiFrame appGui = new GuiFrame(TAPAAL.getProgramName());
21
21
 
22
22
        public static void init() {
23
23
 
24
 
        if (Platform.isMac()){
25
 
                        try {
26
 
                                SpecialMacHandler.postprocess();
27
 
                        } catch (NoClassDefFoundError e) {
28
 
                                //Failed loading special mac handler, ignore and run program without MacOS integration
29
 
                        }
30
 
                }
 
24
            try {
 
25
            Desktop.getDesktop().setAboutHandler(e -> appGuiController.showAbout());
 
26
        } catch (SecurityException | UnsupportedOperationException ignored) {
 
27
            Logger.log("Failed to set native about handler");
 
28
        }
 
29
 
 
30
            try {
 
31
                Desktop.getDesktop().setQuitHandler(
 
32
                    (e, response) -> {
 
33
                        appGuiController.exit();
 
34
                        response.cancelQuit(); //If we get here the request was canceled.
 
35
                    }
 
36
                );
 
37
 
 
38
        } catch (SecurityException | UnsupportedOperationException ignored) {
 
39
                Logger.log("Failed to set native quit handler");
 
40
        }
 
41
 
 
42
        try {
 
43
            Image appImage = ResourceManager.getIcon("icon.png").getImage();
 
44
            Taskbar.getTaskbar().setIconImage(appImage);
 
45
 
 
46
        } catch (SecurityException | UnsupportedOperationException ignored) {
 
47
            Logger.log("Failed to set DockIcon");
 
48
        }
31
49
 
32
50
                appGui.setVisible(true);
33
51
                appGuiController.checkForUpdate(false);