00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package ikayaki.gui;
00024
00025 import ikayaki.Project;
00026
00027 import javax.swing.*;
00028 import java.awt.*;
00029
00035 public class SettingsDialog extends JDialog {
00036
00037 private static final int DEVICE_SETTINGS = 1;
00038 private static final int PROGRAM_SETTINGS = 2;
00039 private static final int PRINT_PREVIEW = 3;
00040
00041 private static int dialogType;
00042 private static Project project;
00043 private static boolean printDirectly;
00044
00045 private SettingsDialog(Frame owner, String message) {
00046 super(owner, message, true);
00047 if (owner != null) {
00048 setLocationRelativeTo(owner);
00049 }
00050 }
00051
00056 protected void dialogInit() {
00057 super.dialogInit();
00058
00059 setResizable(false);
00060 setLayout(new BorderLayout());
00061 if (dialogType == DEVICE_SETTINGS) {
00062 add(new DeviceSettingsPanel(this), BorderLayout.CENTER);
00063 pack();
00064 } else if (dialogType == PROGRAM_SETTINGS) {
00065 add(new ProgramSettingsPanel(this), BorderLayout.CENTER);
00066 pack();
00067 } else if (dialogType == PRINT_PREVIEW) {
00068 add(new PrintPanel(this, project, printDirectly), BorderLayout.CENTER);
00069 this.setSize(500, 700);
00070
00071
00072
00073 } else {
00074 throw new IllegalArgumentException("dialogType = " + dialogType);
00075 }
00076 }
00077
00078 public static void showDeviceSettingsDialog(Frame owner, String message) {
00079 dialogType = DEVICE_SETTINGS;
00080 SettingsDialog d = new SettingsDialog(owner, message);
00081 d.setVisible(true);
00082 }
00083
00084 public static void showProgramSettingsDialog(Frame owner, String message) {
00085 dialogType = PROGRAM_SETTINGS;
00086 SettingsDialog d = new SettingsDialog(owner, message);
00087 d.setVisible(true);
00088 }
00089
00090 public static void showPrintPreview(Frame owner, String message, Project project, boolean printDirectly) {
00091 dialogType = PRINT_PREVIEW;
00092 SettingsDialog.project = project;
00093 SettingsDialog.printDirectly = printDirectly;
00094 SettingsDialog d = new SettingsDialog(owner, message);
00095 d.setVisible(true);
00096 }
00097 }
00098