package net.katsuster.strview.gui;

import java.awt.event.*;
import javax.swing.*;

/**
 * <p>
 * ストリームの構造を表示するウインドウです。
 * </p>
 *
 * <p>
 * ViewerPanel を 1つだけ表示できます。
 * </p>
 */
public class ViewerWindow extends JFrame {
    private static final long serialVersionUID = 1L;

    private ViewerPanel viewer;

    public ViewerWindow(ViewerPanel p) {
        viewer = p;

        setTitle(p.getName());
        setResizable(true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        //メニューを作成する
        JMenuBar topMenuBar = new JMenuBar();
        JMenu menuFile = new JMenu("ファイル(F)");
        menuFile.setMnemonic('f');

        Action actionOpen = new ActionFileOpen(this, "開く(O)...");
        actionOpen.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_O);
        menuFile.add(actionOpen);
        menuFile.addSeparator();
        Action actionClose = new ActionClose(this, "閉じる(C)");
        actionClose.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
        menuFile.add(actionClose);

        JMenu menuSetting = new JMenu("設定(S)");
        menuSetting.setMnemonic('s');

        Action actionFont = new ActionFont(this, "フォント(F)...");
        actionFont.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_F);
        menuSetting.add(actionFont);

        topMenuBar.add(menuFile);
        topMenuBar.add(menuSetting);
        setJMenuBar(topMenuBar);

        getContentPane().add(p);
    }

    public ViewerPanel getViewer() {
        return viewer;
    }

    public void addHelperViewer(ViewerWindow w) {
        viewer.addHelperViewer(w.getViewer());
    }

    public void removeHelperViewer(ViewerWindow w) {
        viewer.removeHelperViewer(w.getViewer());
    }

    public class ActionFont extends AbstractAction {
        private static final long serialVersionUID = 1L;
        private JFrame parent;

        public ActionFont(JFrame f, String name) {
            super(name);
            parent = f;
        }

        public ActionFont(JFrame f, String name, Icon icon) {
            super(name, icon);
            parent = f;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            JFontChooser chooser = new JFontChooser();

            chooser.setSelectedFont(viewer.getFont());
            int res = chooser.showDialog(parent);
            if (res == JFontChooser.OK_OPTION) {
                viewer.setFont(chooser.getSelectedFont());
            }
        }
    }
}

@@ -29,16 +29,35 @@
 w.gui;%0A%0A
+import java.awt.*;%0A
 import j
@@ -96,16 +96,133 @@
 ing.*;%0A%0A
+import net.katsuster.strview.media.*;%0Aimport net.katsuster.strview.util.*;%0Aimport net.katsuster.strview.util.bit.*;%0A%0A
 /**%0A * %3C
@@ -436,16 +436,80 @@
  viewer;
+%0A    JComboBox%3CFileTypeItem%3E cmbType;%0A    FileTypeItem fileType;
 %0A%0A    pu
@@ -1565,30 +1565,535 @@
     
-getContentPane().add(p
+//%E4%B8%8B%E5%81%B4%E3%80%81%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E7%A8%AE%E5%88%A5%E9%81%B8%E6%8A%9E%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%0A        JPanel typeTool = new JPanel();%0A        typeTool.setLayout(new FlowLayout(FlowLayout.RIGHT));%0A%0A        cmbType = new JComboBox%3C%3E();%0A        cmbType.addItemListener(new FileTypeChanged());%0A        typeTool.add(cmbType);%0A%0A        JButton btnOpen = new JButton(%22Open%22);%0A        btnOpen.setEnabled(false);%0A        typeTool.add(btnOpen);%0A%0A        getContentPane().setLayout(new BorderLayout());%0A        getContentPane().add(p, BorderLayout.CENTER);%0A        getContentPane().add(typeTool, BorderLayout.SOUTH
 );%0A 
@@ -3129,11 +3129,233 @@
  %7D%0A    %7D
+%0A%0A    public class FileTypeChanged implements ItemListener %7B%0A        private static final long serialVersionUID = 1L;%0A%0A        public void itemStateChanged(ItemEvent e) %7B%0A            //TODO: implemented yet%0A        %7D%0A    %7D
 %0A%7D%0A

Add combo box for opening as other format.