OSDN Git Service

add menubar
authorankys <ankys@users.sourceforge.jp>
Sat, 7 May 2011 06:38:06 +0000 (15:38 +0900)
committerankys <ankys@users.sourceforge.jp>
Sat, 7 May 2011 06:38:06 +0000 (15:38 +0900)
build.sh
build_mac.sh
src/jp/sourceforge/posterdivider/Localization.java
src/jp/sourceforge/posterdivider/MainFrame.java

index f37fa01..370a1d1 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -2,6 +2,11 @@
 
 ITEXTVERSION=5.0.6
 
+find . \( -name "._*" -o -name ".DS_Store" -o -name "*~" \) -exec rm {} \;
+#find . \80( -name "._*" -o -name ".DS_Store" -o -name "*~" \80) -exec rm {} \80;
+rm -f .ant-targets-build.xml
+rm -f ../PosterDivider-src.zip ../PosterDivider.jar ../PosterDivider.dmg
+
 zip ../PosterDivider-src.zip `cat zipfilelist.txt`
 
 ln -s ../iText-${ITEXTVERSION}.jar iText.jar
index 3893eb7..a7d4d49 100755 (executable)
@@ -3,10 +3,6 @@
 VERSION=1.0.0.20110421
 ITEXTVERSION=5.0.6
 
-find . \( -name "._*" -o -name ".DS_Store" \) -exec rm {} \;
-#find . \80( -name "._*" -o -name ".DS_Store" \80) -exec rm {} \80;
-rm -f ../PosterDivider-src.zip ../PosterDivider.jar ../PosterDivider.dmg
-
 ./build.sh
 
 mkdir PosterDivider
index 5df291c..ad9e2ab 100755 (executable)
@@ -21,6 +21,10 @@ public class Localization {
        }
 
        public void addJapaneseMessages() {
+               addMessage("New", "新規");
+               addMessage("Open", "開く");
+               addMessage("Close", "閉じる");
+               addMessage("Output", "出力");
                addMessage("FileName", "ファイル名");
                addMessage("Change", "変更");
                addMessage("PageNum", "ページ番号");
index dab1c6a..e68925b 100755 (executable)
@@ -12,6 +12,9 @@ import java.awt.FileDialog;
 import java.awt.FlowLayout;
 import java.awt.Frame;
 import java.awt.Label;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
 import java.awt.Panel;
 import java.awt.TextField;
 import java.awt.event.ActionEvent;
@@ -113,6 +116,10 @@ public class MainFrame extends Frame {
                return str;
        }
 
+       private boolean checkFileLoaded() {
+               return this.ic != null;
+       }
+
        private void simulateOutput() {
                // 設定値が変更されたときに canvasPreview 等を更新する
 
@@ -164,7 +171,7 @@ public class MainFrame extends Frame {
        }
 
        public void outputPdf() {
-               if (ic == null) {
+               if (!checkFileLoaded()) {
                        labelMessage.setText(Lib.getMessage("No Input Files"));
                        this.validateTree();
                        return;
@@ -301,6 +308,36 @@ public class MainFrame extends Frame {
         * (changed) { numberFieldPosterSize_setValue(); simulateOutput(); } }
         */
 
+       private void menuItemNewWindow_actionPerformed() {
+               MainFrame frame = new MainFrame();
+               frame.setVisible(true);
+       }
+
+       private void menuItemOpenFile_actionPerformed() {
+               FileDialog fd = new FileDialog(this, null, FileDialog.LOAD);
+               fd.setVisible(true);
+
+               if (fd.getFile() != null) {
+                       String fileName = fd.getDirectory() + fd.getFile();
+                       if (checkFileLoaded()) {
+                               MainFrame frame = new MainFrame();
+                               frame.changeFile(fileName);
+                               frame.setVisible(true);
+                       }
+                       else {
+                               changeFile(fileName);
+                       }
+               }
+       }
+
+       private void menuItemCloseWindow_actionPerformed() {
+               this.dispose();
+       }
+
+       private void menuItemOutput_actionPerformed() {
+               outputPdf();
+       }
+
        private void buttonSrcFileChange_actionPerformed() {
                FileDialog fd = new FileDialog(this, null, FileDialog.LOAD);
                fd.setVisible(true);
@@ -684,6 +721,61 @@ public class MainFrame extends Frame {
        }
 
        private void mainFrame_initializeComponents() {
+               this.setTitle(Program.LOWERTITLE);
+               this.setSize(800, 600);
+               this.setLocationRelativeTo(null);
+               this.addWindowListener(new WindowListener() {
+                       public void windowActivated(WindowEvent e) {
+                       }
+
+                       public void windowClosed(WindowEvent e) {
+                       }
+
+                       public void windowClosing(WindowEvent e) {
+                               dispose();
+                       }
+
+                       public void windowDeactivated(WindowEvent e) {
+                       }
+
+                       public void windowDeiconified(WindowEvent e) {
+                       }
+
+                       public void windowIconified(WindowEvent e) {
+                       }
+
+                       public void windowOpened(WindowEvent e) {
+                               buttonOutput.requestFocus();
+                       }
+               });
+
+               MenuBar menuBar = new MenuBar();
+               Menu menuFile = new Menu("File");
+               MenuItem menuItemNewWindow = new MenuItem(Lib.getMessage("New"));
+               menuItemNewWindow.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               menuItemNewWindow_actionPerformed();
+                       }
+               });
+               MenuItem menuItemOpenFile = new MenuItem(Lib.getMessage("Open") + "...");
+               menuItemOpenFile.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               menuItemOpenFile_actionPerformed();
+                       }
+               });
+               MenuItem menuItemCloseWindow = new MenuItem(Lib.getMessage("Close"));
+               menuItemCloseWindow.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               menuItemCloseWindow_actionPerformed();
+                       }
+               });
+               MenuItem menuItemOutput = new MenuItem(Lib.getMessage("Output"));
+               menuItemOutput.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               menuItemOutput_actionPerformed();
+                       }
+               });
+
                labelSrcFile = new Label();
                labelSrcFile.setText(Lib.getMessage("FileName"));
 
@@ -934,33 +1026,13 @@ public class MainFrame extends Frame {
                        }
                });
 
-               this.setTitle(Program.LOWERTITLE);
-               this.setSize(800, 600);
-               this.setLocationRelativeTo(null);
-               this.addWindowListener(new WindowListener() {
-                       public void windowActivated(WindowEvent e) {
-                       }
-
-                       public void windowClosed(WindowEvent e) {
-                       }
-
-                       public void windowClosing(WindowEvent e) {
-                               dispose();
-                       }
-
-                       public void windowDeactivated(WindowEvent e) {
-                       }
+               menuFile.add(menuItemNewWindow);
+               menuFile.add(menuItemOpenFile);
+               menuFile.addSeparator();
+               menuFile.add(menuItemCloseWindow);
+               menuFile.add(menuItemOutput);
 
-                       public void windowDeiconified(WindowEvent e) {
-                       }
-
-                       public void windowIconified(WindowEvent e) {
-                       }
-
-                       public void windowOpened(WindowEvent e) {
-                               buttonOutput.requestFocus();
-                       }
-               });
+               menuBar.add(menuFile);
 
                Panel panelSrcFile = new Panel();
                panelSrcFile.setLayout(new FlowLayout(FlowLayout.LEFT));
@@ -1027,6 +1099,7 @@ public class MainFrame extends Frame {
                panelOutput.add(buttonOutput);
 
                this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+               this.setMenuBar(menuBar);
                this.add(panelSrcFile);
                this.add(panelSrc);
                this.add(panelSrcRect);