Package net.sf.soundcomp.ide

Source Code of net.sf.soundcomp.ide.MainFrame$AudioFilesFilter

/*
* Copyright (C) SoundComp Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; in version 2.1
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

package net.sf.soundcomp.ide;

import javax.swing.ButtonGroup;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import java.util.prefs.BackingStoreException;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.util.EventObject;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ActionMap;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JToolBar;
import javax.swing.JToolBar.Separator;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.ChangeEvent;
import javax.swing.event.MenuEvent;
import javax.swing.event.PopupMenuEvent;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import java.awt.event.MouseListener;
import java.awt.font.TextAttribute;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.prefs.Preferences;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuListener;
import javax.swing.event.PopupMenuListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
import net.sf.soundcomp.ide.dialog.AboutDialog;
import net.sf.soundcomp.ide.dialog.ColorDialog;
import net.sf.soundcomp.ide.dialog.FindDialog;
import net.sf.soundcomp.ide.dialog.FontDialog;
import net.sf.soundcomp.ide.dialog.GotoDialog;
import net.sf.soundcomp.ide.dialog.ImageResizeDialog;
import net.sf.soundcomp.ide.javahelp.JavaHelp;
import net.sf.soundcomp.ide.dialog.OptionsDialog;
import net.sf.soundcomp.ide.grapheditor.panel.GraphPanel;
import net.sf.soundcomp.ide.scripteditor.panel.TextPanel;
import net.sf.soundcomp.ide.util.BareBonesBrowserLaunch;
import net.sf.soundcomp.ide.waveeditor.panel.AudioPanel;
import org.jdesktop.application.Application.ExitListener;
import org.xbup.library.audio.swing.XBWavePanel.DrawMode;
import org.xbup.library.audio.xbplugins.AudioFileFilter;

/**
* SoundCompIDE Main Frame.
*
* @version 0.1.0 2011/05/26
* @author SoundComp Project (http://soundcomp.sf.net)
*/
public class MainFrame extends FrameView {

    private ResourceMap resourceMap;
    private static Preferences preferences = Preferences.userNodeForPackage(MainFrame.class);
    private JFileChooser openFC, saveFC;
    private List<String> recentFiles = null;
    private String frameTitle;

//    private ChangeListener caretChangeListener;

    private AboutDialog aboutDialog;
    private OptionsDialog optionsDialog = null;
    private FindDialog findDialog = null;
    private GotoDialog gotoDialog = null;
    private JavaHelp javaHelp;
    private final String DIALOG_MENU_SUFIX = "...";

    private String activeStatusPanel;
    private JPanel activePanel;
    private TextPanel textPanel;
    private AudioPanel audioPanel;
    private GraphPanel graphPanel;

    private ChangeListener caretChangeListener;

    public MainFrame(SingleFrameApplication app) {
        super(app);
        init();
    }

    private void init() {
        resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(MainFrame.class);

        getFrame().setIconImage(resourceMap.getImageIcon("Application.icon").getImage());

        // Create File Choosers
        openFC = new JFileChooser();
        openFC.setAcceptAllFileFilterUsed(false);
        saveFC = new JFileChooser();
        saveFC.setAcceptAllFileFilterUsed(false);

        initComponents();

//        activePanel.addPropertyChangeListener(new PropertyChangePassing(this));

        // Ask for confirmation on exit
        getApplication().addExitListener(new ExitListener() {
            public boolean canExit(EventObject arg0) {
                return releaseFile();
            }
            public void willExit(EventObject arg0) {
                if (preferences != null) saveState(preferences);
            }
        });
        // Setup proper closing for this frame
        getFrame().setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        getFrame().addWindowListener(new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent e) {
                getApplication().exit();
            }
        });

        activeStatusPanel = "default";
        ((CardLayout) statusPanel.getLayout()).show(statusPanel,activeStatusPanel);

        // Open file from command line
        /*
        String fileName = ((SoundCompIDE) app).getFileName();
        if (!"".equals(fileName)) {
            setFileName(fileName);
            activePanel.loadFromFile();
        } */

        // Caret position listener
/*        caretChangeListener = new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
//                Point pos = activePanel.getCaretPosition();
                Point pos = new Point();
                jTextField1.setText(Long.toString((long) pos.getX()) +":"+ Long.toString((long) pos.getY()));
            }
        }; */

        // Actions on change of look&feel
        UIManager.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                SwingUtilities.updateComponentTreeUI(getFrame());
                SwingUtilities.updateComponentTreeUI(mainPopupMenu);
                SwingUtilities.updateComponentTreeUI(openFC);
                SwingUtilities.updateComponentTreeUI(saveFC);
                if (aboutDialog != null) SwingUtilities.updateComponentTreeUI(aboutDialog);
                if (optionsDialog != null) SwingUtilities.updateComponentTreeUI(optionsDialog);
            }
        });

        // Show hints in status bar for main menu and popup menu
        for (int i = 0; i < menuBar.getComponentCount(); i++) {
            JMenu menu = (JMenu) menuBar.getComponent(i);
            menu.addMenuListener(new MenuListener() {

                public void menuSelected(MenuEvent e) {
                    ((CardLayout) statusPanel.getLayout()).show(statusPanel, "main");
                    statusLabel.setText(((JMenu) e.getSource()).getToolTipText());
                    ToolTipManager.sharedInstance().setEnabled(false);
                }

                public void menuDeselected(MenuEvent e) {
                    ((CardLayout) statusPanel.getLayout()).show(statusPanel, activeStatusPanel);
                    ToolTipManager.sharedInstance().setEnabled(true);
                }

                public void menuCanceled(MenuEvent e) {
                }
            });
            initMenu(menu.getPopupMenu());
        }

        mainPopupMenu.addPopupMenuListener(new PopupMenuListener() {
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                ((CardLayout) statusPanel.getLayout()).show(statusPanel, "main");
                statusLabel.setText(((JPopupMenu) e.getSource()).getToolTipText());
                statusLabel.setForeground(Color.BLACK);
                ToolTipManager.sharedInstance().setEnabled(false);
            }

            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                ((CardLayout) statusPanel.getLayout()).show(statusPanel, activeStatusPanel);
                ToolTipManager.sharedInstance().setEnabled(true);
            }

            public void popupMenuCanceled(PopupMenuEvent e) {
            }
        });
        //activePanel.setPopupMenu(mainPopupMenu);
        initMenu(mainPopupMenu);

        frameTitle = resourceMap.getString("Application.title");
        loadPreferences(preferences);

        recentFiles = new ArrayList<String>();
        loadState(preferences);

        mainTabbedPane.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent event) {
                activePanel = (JPanel) mainTabbedPane.getSelectedComponent();
                ApplicationPanel panel = (ApplicationPanel) activePanel;
                setStatusPanel(panel.getPanelName());
            }
        });

        javaHelp = new JavaHelp();
        javaHelp.setup(helpContextMenuItem);
       
        textPanel = new TextPanel();
        audioPanel = new AudioPanel();
        audioPanel.setPopupMenu(audioPopupMenu);
        graphPanel = new GraphPanel();
        graphPanel.setComponentPopupMenu(graphPopupMenu);
        addFramePanel(textPanel, textPanel.getPanelName());
        addFramePanel(audioPanel, audioPanel.getPanelName());
        addFramePanel(graphPanel, graphPanel.getPanelName());
        addStatusPanel(textEditorStatusPanel, textPanel.getPanelName());
        addStatusPanel(audioStatusPanel, audioPanel.getPanelName());
        addStatusPanel(emptyStatusPanel, graphPanel.getPanelName());

        textPanel.setPopupMenu(sourcePopupMenu);

        // Caret position listener
        caretChangeListener = new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                Point pos = textPanel.getCaretPosition();
                cursorPositionTextField.setText(Long.toString((long) pos.getX()) +":"+ Long.toString((long) pos.getY()));
            }
        };
        textPanel.attachCaretListener(caretChangeListener);

        javax.swing.filechooser.FileFilter filter;
        filter = new AllFilesFilter();
        openFC.addChoosableFileFilter(new TXTFilesFilter());
        openFC.addChoosableFileFilter(new SoundCompFilesFilter());
        openFC.addChoosableFileFilter(new AudioFilesFilter());
        openFC.addChoosableFileFilter(filter);
        openFC.setFileFilter(filter);
        saveFC.addChoosableFileFilter(new TXTFilesFilter());
        saveFC.addChoosableFileFilter(new SoundCompFilesFilter());
        saveFC.addChoosableFileFilter(new AudioFilesFilter());
        saveFC.addChoosableFileFilter(filter);
        saveFC.setFileFilter(filter);
       
        loadTextPanelPreferences(preferences);
    }

    /** Loading options from given preferences */
    private void loadPreferences(Preferences prefs) {
        String look = prefs.get("lookAndFeel","");
        if (!look.equals("")) {
            try {
                UIManager.setLookAndFeel(look);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedLookAndFeelException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        if (!Boolean.valueOf(prefs.get("showToolbar", Boolean.toString(true)))) viewToolBarCheckBoxMenuItem.doClick();
        if (!Boolean.valueOf(prefs.get("showToolbarCaptions", Boolean.toString(true)))) viewCaptionsCheckBoxMenuItem.doClick();
        if (!Boolean.valueOf(prefs.get("showStatusbar", Boolean.toString(true)))) viewStatusBarCheckBoxMenuItem.doClick();
    }

    /** Loading options from given preferences */
    private void loadTextPanelPreferences(Preferences prefs) {
        if (Boolean.valueOf(prefs.get("wrapText", Boolean.toString(false)))) viewWordWrapCheckBoxMenuItem.doClick();

        String value;
        Integer rgb;
        if (Boolean.FALSE.equals(Boolean.valueOf(prefs.get("colorDefault", Boolean.toString(true))))) {
            Color[] colors = textPanel.getDefaultColors().clone();
            rgb = Integer.valueOf(prefs.get("colorText",null));
            if (rgb != null) colors[0] = new Color(rgb);
            rgb = Integer.valueOf(prefs.get("colorTextBackground",null));
            if (rgb != null) colors[1] = new Color(rgb);
            rgb = Integer.valueOf(prefs.get("colorTextSelection",null));
            if (rgb != null) colors[2] = new Color(rgb);
            rgb = Integer.valueOf(prefs.get("colorTextBackSelection",null));
            if (rgb != null) colors[3] = new Color(rgb);
            rgb = Integer.valueOf(prefs.get("colorTextFind",null));
            if (rgb != null) colors[4] = new Color(rgb);
            textPanel.setCurrentColors(colors);
        } else textPanel.setCurrentColors(textPanel.getDefaultColors());

        if (Boolean.FALSE.equals(Boolean.valueOf(prefs.get("fontDefault", Boolean.toString(true))))) {
            Boolean flag;
            Map<TextAttribute,Object> attribs = new HashMap<TextAttribute,Object>();
            value = prefs.get("font.family", null);
            if (value != null) attribs.put(TextAttribute.FAMILY, value);
            value = prefs.get("font.size", null);
            if (value != null) attribs.put(TextAttribute.SIZE, new Integer(value).floatValue());
            flag = Boolean.valueOf(prefs.get("font.underline", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
            flag = Boolean.valueOf(prefs.get("font.strikethrough", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
            flag = Boolean.valueOf(prefs.get("font.bold", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
            flag = Boolean.valueOf(prefs.get("font.italic", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
            flag = Boolean.valueOf(prefs.get("font.subscript", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB);
            flag = Boolean.valueOf(prefs.get("font.superscript", null));
            if (Boolean.TRUE.equals(flag)) attribs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);
            textPanel.setCurrentFont(textPanel.getDefaultFont().deriveFont(attribs));
        } else textPanel.setCurrentFont(textPanel.getDefaultFont());
    }

    private void loadState(Preferences prefs) {
        recentFiles.clear();
        int recent = 1;
        while (recent < 14) {
            String fileName = prefs.get("recentFile."+String.valueOf(recent), null);
            if (fileName == null) break;
            recentFiles.add(fileName);
            recent++;
        }
        rebuildRecentFilesMenu();
    }

    private void saveState(Preferences prefs) {
        for (int i = 0; i < recentFiles.size(); i++) {
            prefs.put("recentFile."+String.valueOf(i+1), recentFiles.get(i));
        }
        prefs.remove("recentFile."+String.valueOf(recentFiles.size()+1));
        try {
            prefs.flush();
        } catch (BackingStoreException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void rebuildRecentFilesMenu() {
        fileOpenRecentMenu.removeAll();
        for (int recentFileIndex = 0; recentFileIndex < recentFiles.size(); recentFileIndex++) {
            File file = new File(recentFiles.get(recentFileIndex));
            JMenuItem menuItem = new JMenuItem(file.getName());
            menuItem.setToolTipText(recentFiles.get(recentFileIndex));
            menuItem.setIcon(FileSystemView.getFileSystemView().getSystemIcon(file));
            menuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    if (e.getSource() instanceof JMenuItem) {
                        JMenuItem menuItem = (JMenuItem) e.getSource();
                        for (int itemIndex = 0; itemIndex < fileOpenRecentMenu.getItemCount(); itemIndex++) {
                            if ( menuItem.equals(fileOpenRecentMenu.getItem(itemIndex))) {
                                loadFromFile(recentFiles.get(itemIndex));
                            }
                        }
                    }
                }
            });

            fileOpenRecentMenu.add(menuItem);
        }
        initMenuItem(fileOpenRecentMenu);
        fileOpenRecentMenu.setEnabled(recentFiles.size() > 0);
    }

    public void initMenu(JPopupMenu menu) {
        int j = 0;
        while (j < menu.getComponentCount()) {
            initMenuItem(menu.getComponent(j));
            j++;
        }
    }

    public void initMenuItem(Object menuItem) {
        if (menuItem instanceof JMenuItem) {
            ((JMenuItem) menuItem).addMouseListener(new MouseListener() {

                public void mouseClicked(MouseEvent e) {
                }

                public void mousePressed(MouseEvent e) {
                }

                public void mouseReleased(MouseEvent e) {
                }

                public void mouseEntered(MouseEvent e) {
                    JMenuItem menuItem = (JMenuItem) e.getSource();
                    if (!menuItem.isEnabled()) {
                        statusLabel.setText(menuItem.getToolTipText());
                        statusLabel.setForeground(Color.GRAY);
                    }
                }

                public void mouseExited(MouseEvent e) {
                    JMenuItem menuItem = (JMenuItem) e.getSource();
                    if (!menuItem.isEnabled()) {
                        statusLabel.setText("");
                        statusLabel.setForeground(Color.BLACK);
                    }
                }
            });
            ((JMenuItem) menuItem).addChangeListener(new ChangeListener() {

                public void stateChanged(ChangeEvent e) {
                    JMenuItem menuItem = (JMenuItem) e.getSource();
                    statusLabel.setText(menuItem.getToolTipText());
                    statusLabel.setForeground(Color.BLACK);
                }
            });
            if (menuItem instanceof JMenu) {
                initMenu(((JMenu) menuItem).getPopupMenu());
            }
        } else if (menuItem instanceof JSeparator) {
            ((JSeparator) menuItem).addMouseListener(new MouseListener() {
                public void mouseClicked(MouseEvent e) {
                }

                public void mousePressed(MouseEvent e) {
                }

                public void mouseReleased(MouseEvent e) {
                }

                public void mouseEntered(MouseEvent e) {
                    statusLabel.setText("");
                }

                public void mouseExited(MouseEvent e) {
                }
            });
        }
    }

    private void setFileName(String fileName) {
//        activePanel.setFileName(fileName);
        if (!"".equals(fileName)) {
            File file = new File(fileName);
// TODO:            SoundCompIDE.getApplication().getMainFrame().setTitle(file.getName() + " - " + frameTitle);
        } // TODO: else SoundCompIDE.getApplication().getMainFrame().setTitle(frameTitle);
    }

    public void updateItem() {
//        activePanel.updateItem();
    }

    // TODO: Ordering
    private Map<String, JPanel> tabs = new HashMap<String, JPanel>();
    private Map<String, Long> tabModules = new HashMap<String, Long>();
    public void addFramePanel(JPanel panel, String panelName) {
        tabs.put(panelName, panel);
//        tabModules.put(panelName, getModuleRepository().getActiveModule());
        activePanel = panel;
        // Ugly hack for ordering
        if (tabs.size() == 3) {
            mainTabbedPane.addTab("Source", tabs.get("Source"));
            mainTabbedPane.addTab("Graph", tabs.get("Graph"));
            mainTabbedPane.addTab("Wave", tabs.get("Wave"));
            activePanel = tabs.get("Source");
            mainTabbedPane.setSelectedComponent(activePanel);
        }
    }

    public JFileChooser getOpenFC() {
        return openFC;
    }

    /**
     * @return the activePanel
     */
    public JPanel getActivePanel() {
        return activePanel;
    }

    public void addStatusPanel(JPanel panel, String panelName) {
        statusPanel.add(panel, "_" + panelName);
        setStatusPanel(panelName);
    }

    public void setStatusPanel(String panelName) {
        ((CardLayout) statusPanel.getLayout()).show(statusPanel,"_" + panelName);
        activeStatusPanel = "_" + panelName;
    }

    public ApplicationPanel getSpecificPanel(int i) {
        // TODO: This is temporary stub
        return (ApplicationPanel) mainTabbedPane.getComponentAt(i);
    }

    private class PropertyChangePassing implements PropertyChangeListener {

        private MainFrame target;
       
        public PropertyChangePassing(MainFrame target) {
            this.target = target;
        }
       
        public void propertyChange(PropertyChangeEvent evt) {
            target.firePropertyChange(evt);
        }
    };

    /**
     * Try to release and warn if document was modified
     *
     * @return true if successfull
     */
    private boolean releaseFile() {
/*        while (activePanel.isModified()) {
            Object[] options = {
                resourceMap.getString("Question.modified_save"),
                resourceMap.getString("Question.modified_discard"),
                resourceMap.getString("Question.modified_cancel")
            };
            int result = JOptionPane.showOptionDialog(
                    SoundCompIDE.getApplication().getMainFrame(),
                    resourceMap.getString("Question.modified"),
                    resourceMap.getString("Question.modified_title"),
                    JOptionPane.YES_NO_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null, options, options[0]);
            if (result == JOptionPane.NO_OPTION) return true;
            if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) return false;
            actionFileSave();
        } */
        return true;
    }

    /**
     * Ask whether it's allows to overwrite file.
     *
     * @return true if allowed
     */
    private boolean overwriteFile() {
        Object[] options = {
            resourceMap.getString("Question.overwrite_save"),
            resourceMap.getString("Question.modified_cancel")
        };
        int result = JOptionPane.showOptionDialog(
                ((SingleFrameApplication) getApplication()).getMainFrame(),
                resourceMap.getString("Question.overwrite"),
                resourceMap.getString("Question.overwrite_title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null, options, options[0]);
        if (result == JOptionPane.YES_OPTION) return true;
        if (result == JOptionPane.NO_OPTION || result == JOptionPane.CLOSED_OPTION) return false;
        return false;
    }

    public boolean isPasteEnabled() {
        if (getActivePanel() == null) return false;
        return false; //activePanel.isPasteEnabled();
    }
   
    public boolean isUndoAvailable() {
        return false; //activePanel.canUndo();
    }

    public boolean isRedoAvailable() {
        return false; //activePanel.canRedo();
    }

    public boolean isToolBarEnabled() {
        return toolBar.isVisible();
    }
   
    public boolean isStatusBarEnabled() {
        return statusBar.isVisible();
    }
   
    public boolean isFalse() {
        return false;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new JPanel();
        toolBar = new JToolBar();
        jButton1 = new JButton();
        jButton2 = new JButton();
        jButton3 = new JButton();
        jSeparator5 = new Separator();
        jButton9 = new JButton();
        jButton10 = new JButton();
        jSeparator4 = new Separator();
        jButton5 = new JButton();
        jButton6 = new JButton();
        jButton7 = new JButton();
        jButton8 = new JButton();
        jSeparator11 = new Separator();
        jButton11 = new JButton();
        mainTabbedPane = new JTabbedPane();
        menuBar = new JMenuBar();
        JMenu fileMenu = new JMenu();
        fileNewMenuItem = new JMenuItem();
        JMenuItem fileOpenMenuItem = new JMenuItem();
        fileOpenRecentMenu = new JMenu();
        fileSaveMenuItem = new JMenuItem();
        fileSaveAsMenuItem = new JMenuItem();
        jSeparator9 = new JSeparator();
        filePrintMenuItem = new JMenuItem();
        jSeparator12 = new JPopupMenu.Separator();
        JMenuItem exitMenuItem = new JMenuItem();
        editMenu = new JMenu();
        editUndoMenuItem = new JMenuItem();
        editRedoMenuItem = new JMenuItem();
        jSeparator2 = new JSeparator();
        editCutMenuItem = new JMenuItem();
        editCopyMenuItem = new JMenuItem();
        editPasteMenuItem = new JMenuItem();
        editDeleteMenuItem = new JMenuItem();
        editSelectAllMenuItem = new JMenuItem();
        jSeparator7 = new JPopupMenu.Separator();
        editGotoMenuItem = new JMenuItem();
        jSeparator8 = new JPopupMenu.Separator();
        editFindMenuItem = new JMenuItem();
        editFindAgainMenuItem = new JMenuItem();
        editFindReplaceMenuItem = new JMenuItem();
        viewMenu = new JMenu();
        viewToolBarCheckBoxMenuItem = new JCheckBoxMenuItem();
        viewCaptionsCheckBoxMenuItem = new JCheckBoxMenuItem();
        viewStatusBarCheckBoxMenuItem = new JCheckBoxMenuItem();
        jSeparator6 = new JPopupMenu.Separator();
        viewWordWrapCheckBoxMenuItem = new JCheckBoxMenuItem();
        jSeparator16 = new JPopupMenu.Separator();
        viewDrawModeMenu = new JMenu();
        viewDrawModeDotsMenuItem = new JRadioButtonMenuItem();
        viewDrawModeLinesMenuItem = new JRadioButtonMenuItem();
        viewDrawModeIntegralMenuItem = new JRadioButtonMenuItem();
        viewZoomMenu = new JMenu();
        viewZoom25MenuItem = new JRadioButtonMenuItem();
        viewZoom50MenuItem = new JRadioButtonMenuItem();
        viewZoom100MenuItem = new JRadioButtonMenuItem();
        viewZoom200MenuItem = new JRadioButtonMenuItem();
        viewZoom400MenuItem = new JRadioButtonMenuItem();
        audioMenu = new JMenu();
        jMenuItem2 = new JMenuItem();
        jMenuItem3 = new JMenuItem();
        jMenuItem4 = new JMenuItem();
        jSeparator17 = new JPopupMenu.Separator();
        audioResizeMenuItem = new JMenuItem();
        audioToolMenu = new JMenu();
        toolSelectionMenuItem = new JRadioButtonMenuItem();
        toolPencilMenuItem = new JRadioButtonMenuItem();
        audioTransformMenu = new JMenu();
        audioTransformMirrorMenuItem = new JMenuItem();
        optionMenu = new JMenu();
        setFontMenuItem = new JMenuItem();
        setColorsMenuItem = new JMenuItem();
        jSeparator3 = new JPopupMenu.Separator();
        toolsOptionsMenuItem = new JMenuItem();
        JMenu helpMenu = new JMenu();
        helpContextMenuItem = new JMenuItem();
        helpOnlineMenuItem = new JMenuItem();
        jSeparator1 = new JPopupMenu.Separator();
        JMenuItem aboutMenuItem = new JMenuItem();
        statusBar = new JPanel();
        JSeparator statusPanelSeparator = new JSeparator();
        statusPanel = new JPanel();
        emptyStatusPanel = new JPanel();
        mainStatusPanel = new JPanel();
        statusLabel = new JLabel();
        progressStatusPanel = new JPanel();
        jProgressBar1 = new JProgressBar();
        jButton4 = new JButton();
        busyStatusPanel = new JPanel();
        jProgressBar2 = new JProgressBar();
        textEditorStatusPanel = new JPanel();
        cursorPositionTextField = new JTextField();
        encodingLabel = new JLabel();
        encodingTextField = new JTextField();
        audioStatusPanel = new JPanel();
        currentPositionTextField = new JTextField();
        playerControlToolBar = new JToolBar();
        jButton12 = new JButton();
        StatusIconsPanel = new JPanel();
        mainPopupMenu = new JPopupMenu();
        popupItemOpenMenuItem = new JMenuItem();
        popupItemAddMenuItem = new JMenuItem();
        popupItemModifyMenuItem = new JMenuItem();
        jSeparator14 = new JPopupMenu.Separator();
        popupUndoMenuItem = new JMenuItem();
        popupRedoMenuItem = new JMenuItem();
        jSeparator10 = new JSeparator();
        popupCutMenuItem = new JMenuItem();
        popupCopyMenuItem = new JMenuItem();
        popupPasteMenuItem = new JMenuItem();
        popupDeleteMenuItem = new JMenuItem();
        toolMenu = new JMenu();
        graphPopupMenu = new JPopupMenu();
        popupAddNodeMenuItem = new JMenuItem();
        popupRemoveNodeMenuItem = new JMenuItem();
        sourcePopupMenu = new JPopupMenu();
        jMenuItem15 = new JMenuItem();
        jMenuItem16 = new JMenuItem();
        jSeparator13 = new JSeparator();
        jMenuItem7 = new JMenuItem();
        jMenuItem8 = new JMenuItem();
        jMenuItem9 = new JMenuItem();
        jMenuItem10 = new JMenuItem();
        jSeparator15 = new JSeparator();
        jMenuItem1 = new JMenuItem();
        zoomButtonGroup = new ButtonGroup();
        toolsModeButtonGroup = new ButtonGroup();
        drawModeButtonGroup = new ButtonGroup();
        audioPopupMenu = new JPopupMenu();
        jMenuItem17 = new JMenuItem();
        jMenuItem18 = new JMenuItem();
        jSeparator18 = new JSeparator();
        jMenuItem11 = new JMenuItem();
        jMenuItem12 = new JMenuItem();
        jMenuItem13 = new JMenuItem();
        jMenuItem14 = new JMenuItem();
        jSeparator19 = new JSeparator();
        jMenuItem5 = new JMenuItem();
        popupviewDrawModeMenu = new JMenu();
        viewDrawModeDotsMenuItem1 = new JRadioButtonMenuItem();
        viewDrawModeLinesMenuItem1 = new JRadioButtonMenuItem();
        viewDrawModeIntegralMenuItem1 = new JRadioButtonMenuItem();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new BorderLayout());

        toolBar.setFloatable(false);
        toolBar.setRollover(true);
        toolBar.setName("toolBar"); // NOI18N

        ActionMap actionMap = Application.getInstance(SoundCompIDE.class).getContext().getActionMap(MainFrame.class, this);
        jButton1.setAction(actionMap.get("actionFileNew")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton1);

        jButton2.setAction(actionMap.get("actionFileOpen")); // NOI18N
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton2);

        jButton3.setAction(actionMap.get("actionFileSave")); // NOI18N
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton3.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton3);

        jSeparator5.setName("jSeparator5"); // NOI18N
        toolBar.add(jSeparator5);

        jButton9.setAction(actionMap.get("actionEditUndo")); // NOI18N
        jButton9.setFocusable(false);
        jButton9.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton9.setName("jButton9"); // NOI18N
        jButton9.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton9);

        jButton10.setAction(actionMap.get("actionEditRedo")); // NOI18N
        jButton10.setFocusable(false);
        jButton10.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton10.setName("jButton10"); // NOI18N
        jButton10.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton10);

        jSeparator4.setName("jSeparator4"); // NOI18N
        toolBar.add(jSeparator4);

        jButton5.setAction(actionMap.get("cut"));
        ResourceMap resourceMap = Application.getInstance(SoundCompIDE.class).getContext().getResourceMap(MainFrame.class);
        jButton5.setText(resourceMap.getString("actionEditCut.Action.text")); // NOI18N
        jButton5.setToolTipText(resourceMap.getString("actionEditCut.Action.shortDescription")); // NOI18N
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton5.setName("jButton5"); // NOI18N
        jButton5.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton5);

        jButton6.setAction(actionMap.get("copy"));
        jButton6.setText(resourceMap.getString("actionEditCopy.Action.text")); // NOI18N
        jButton6.setToolTipText(resourceMap.getString("actionEditCopy.Action.shortDescription")); // NOI18N
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton6.setName("jButton6"); // NOI18N
        jButton6.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton6);

        jButton7.setAction(actionMap.get("paste"));
        jButton7.setText(resourceMap.getString("actionEditPaste.Action.text")); // NOI18N
        jButton7.setToolTipText(resourceMap.getString("actionEditPaste.Action.shortDescription")); // NOI18N
        jButton7.setFocusable(false);
        jButton7.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton7.setName("jButton7"); // NOI18N
        jButton7.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton7);

        jButton8.setAction(actionMap.get("delete"));
        jButton8.setText(resourceMap.getString("actionEditDelete.Action.text")); // NOI18N
        jButton8.setToolTipText(resourceMap.getString("actionEditDelete.Action.shortDescription")); // NOI18N
        jButton8.setFocusable(false);
        jButton8.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton8.setName("jButton8"); // NOI18N
        jButton8.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton8);

        jSeparator11.setName("jSeparator11"); // NOI18N
        toolBar.add(jSeparator11);

        jButton11.setAction(actionMap.get("actionEditFind")); // NOI18N
        jButton11.setFocusable(false);
        jButton11.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton11.setName("jButton11"); // NOI18N
        jButton11.setVerticalTextPosition(SwingConstants.BOTTOM);
        toolBar.add(jButton11);

        mainPanel.add(toolBar, BorderLayout.NORTH);

        mainTabbedPane.setName("mainTabbedPane"); // NOI18N
        mainPanel.add(mainTabbedPane, BorderLayout.CENTER);

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        fileNewMenuItem.setAction(actionMap.get("actionFileNew")); // NOI18N
        fileNewMenuItem.setName("fileNewMenuItem"); // NOI18N
        fileMenu.add(fileNewMenuItem);

        fileOpenMenuItem.setAction(actionMap.get("actionFileOpen")); // NOI18N
        fileOpenMenuItem.setName("fileOpenMenuItem"); // NOI18N
        fileMenu.add(fileOpenMenuItem);

        fileOpenRecentMenu.setText(resourceMap.getString("fileOpenRecentMenu.text")); // NOI18N
        fileOpenRecentMenu.setToolTipText(resourceMap.getString("fileOpenRecentMenu.toolTipText")); // NOI18N
        fileOpenRecentMenu.setEnabled(false);
        fileOpenRecentMenu.setName("fileOpenRecentMenu"); // NOI18N
        fileMenu.add(fileOpenRecentMenu);

        fileSaveMenuItem.setAction(actionMap.get("actionFileSave")); // NOI18N
        fileSaveMenuItem.setName("fileSaveMenuItem"); // NOI18N
        fileMenu.add(fileSaveMenuItem);

        fileSaveAsMenuItem.setAction(actionMap.get("actionFileSaveAs")); // NOI18N
        fileSaveAsMenuItem.setName("fileSaveAsMenuItem"); // NOI18N
        fileMenu.add(fileSaveAsMenuItem);

        jSeparator9.setName("jSeparator9"); // NOI18N
        fileMenu.add(jSeparator9);

        filePrintMenuItem.setAction(actionMap.get("actionFilePrint")); // NOI18N
        filePrintMenuItem.setName("filePrintMenuItem"); // NOI18N
        fileMenu.add(filePrintMenuItem);

        jSeparator12.setName("jSeparator12"); // NOI18N
        fileMenu.add(jSeparator12);

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText(resourceMap.getString("editMenu.text")); // NOI18N
        editMenu.setName("editMenu"); // NOI18N
        editMenu.setRolloverEnabled(true);

        editUndoMenuItem.setAction(actionMap.get("actionEditUndo")); // NOI18N
        editUndoMenuItem.setName("editUndoMenuItem"); // NOI18N
        editMenu.add(editUndoMenuItem);

        editRedoMenuItem.setAction(actionMap.get("actionEditRedo")); // NOI18N
        editRedoMenuItem.setName("editRedoMenuItem"); // NOI18N
        editMenu.add(editRedoMenuItem);

        jSeparator2.setName("jSeparator2"); // NOI18N
        editMenu.add(jSeparator2);

        editCutMenuItem.setAction(actionMap.get("cut"));
        editCutMenuItem.setText(resourceMap.getString("actionEditCut.Action.text")); // NOI18N
        editCutMenuItem.setToolTipText(resourceMap.getString("actionEditCut.Action.shortDescription")); // NOI18N
        editCutMenuItem.setEnabled(false);
        editCutMenuItem.setName("editCutMenuItem"); // NOI18N
        editMenu.add(editCutMenuItem);

        editCopyMenuItem.setAction(actionMap.get("copy"));
        editCopyMenuItem.setText(resourceMap.getString("actionEditCopy.Action.text")); // NOI18N
        editCopyMenuItem.setToolTipText(resourceMap.getString("actionEditCopy.Action.shortDescription")); // NOI18N
        editCopyMenuItem.setEnabled(false);
        editCopyMenuItem.setName("editCopyMenuItem"); // NOI18N
        editMenu.add(editCopyMenuItem);

        editPasteMenuItem.setAction(actionMap.get("paste"));
        editPasteMenuItem.setText(resourceMap.getString("actionEditPaste.Action.text")); // NOI18N
        editPasteMenuItem.setToolTipText(resourceMap.getString("actionEditPaste.Action.shortDescription")); // NOI18N
        editPasteMenuItem.setEnabled(false);
        editPasteMenuItem.setName("editPasteMenuItem"); // NOI18N
        editMenu.add(editPasteMenuItem);

        editDeleteMenuItem.setAction(actionMap.get("delete"));
        editDeleteMenuItem.setText(resourceMap.getString("actionEditDelete.Action.text")); // NOI18N
        editDeleteMenuItem.setToolTipText(resourceMap.getString("actionEditDelete.Action.shortDescription")); // NOI18N
        editDeleteMenuItem.setEnabled(false);
        editDeleteMenuItem.setName("editDeleteMenuItem"); // NOI18N
        editMenu.add(editDeleteMenuItem);

        editSelectAllMenuItem.setAction(actionMap.get("actionEditSelectAll")); // NOI18N
        editSelectAllMenuItem.setName("editSelectAllMenuItem"); // NOI18N
        editMenu.add(editSelectAllMenuItem);

        jSeparator7.setName("jSeparator7"); // NOI18N
        editMenu.add(jSeparator7);

        editGotoMenuItem.setAction(actionMap.get("actionEditGoto")); // NOI18N
        editGotoMenuItem.setName("editGotoMenuItem"); // NOI18N
        editMenu.add(editGotoMenuItem);

        jSeparator8.setName("jSeparator8"); // NOI18N
        editMenu.add(jSeparator8);

        editFindMenuItem.setAction(actionMap.get("actionEditFind")); // NOI18N
        editFindMenuItem.setName("editFindMenuItem"); // NOI18N
        editMenu.add(editFindMenuItem);

        editFindAgainMenuItem.setAction(actionMap.get("actionFindAgain")); // NOI18N
        editFindAgainMenuItem.setName("editFindAgainMenuItem"); // NOI18N
        editMenu.add(editFindAgainMenuItem);

        editFindReplaceMenuItem.setAction(actionMap.get("actionEditReplace")); // NOI18N
        editFindReplaceMenuItem.setName("editFindReplaceMenuItem"); // NOI18N
        editMenu.add(editFindReplaceMenuItem);

        menuBar.add(editMenu);

        viewMenu.setText(resourceMap.getString("viewMenu.text")); // NOI18N

        viewToolBarCheckBoxMenuItem.setAction(actionMap.get("actionViewToolbar")); // NOI18N
        viewToolBarCheckBoxMenuItem.setSelected(true);
        viewToolBarCheckBoxMenuItem.setName("viewToolBarCheckBoxMenuItem"); // NOI18N
        viewMenu.add(viewToolBarCheckBoxMenuItem);

        viewCaptionsCheckBoxMenuItem.setAction(actionMap.get("actionViewCaptions")); // NOI18N
        viewCaptionsCheckBoxMenuItem.setSelected(true);
        viewCaptionsCheckBoxMenuItem.setName("viewCaptionsCheckBoxMenuItem"); // NOI18N
        viewMenu.add(viewCaptionsCheckBoxMenuItem);

        viewStatusBarCheckBoxMenuItem.setAction(actionMap.get("actionViewStatusBar")); // NOI18N
        viewStatusBarCheckBoxMenuItem.setSelected(true);
        viewStatusBarCheckBoxMenuItem.setName("viewStatusBarCheckBoxMenuItem"); // NOI18N
        viewMenu.add(viewStatusBarCheckBoxMenuItem);

        jSeparator6.setName("jSeparator6"); // NOI18N
        viewMenu.add(jSeparator6);

        viewWordWrapCheckBoxMenuItem.setText(resourceMap.getString("viewWordWrapCheckBoxMenuItem.text")); // NOI18N
        viewWordWrapCheckBoxMenuItem.setToolTipText(resourceMap.getString("viewWordWrapCheckBoxMenuItem.toolTipText")); // NOI18N
        viewWordWrapCheckBoxMenuItem.setName("viewWordWrapCheckBoxMenuItem"); // NOI18N
        viewWordWrapCheckBoxMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                viewWordWrapCheckBoxMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(viewWordWrapCheckBoxMenuItem);

        jSeparator16.setName("jSeparator16"); // NOI18N
        viewMenu.add(jSeparator16);

        viewDrawModeMenu.setText(resourceMap.getString("viewDrawModeMenu.text")); // NOI18N
        viewDrawModeMenu.setName("viewDrawModeMenu"); // NOI18N

        viewDrawModeDotsMenuItem.setAction(actionMap.get("actionDrawModeDots")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeDotsMenuItem);
        viewDrawModeDotsMenuItem.setName("viewDrawModeDotsMenuItem"); // NOI18N
        viewDrawModeMenu.add(viewDrawModeDotsMenuItem);

        viewDrawModeLinesMenuItem.setAction(actionMap.get("actionDrawModeLines")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeLinesMenuItem);
        viewDrawModeLinesMenuItem.setSelected(true);
        viewDrawModeLinesMenuItem.setName("viewDrawModeLinesMenuItem"); // NOI18N
        viewDrawModeMenu.add(viewDrawModeLinesMenuItem);

        viewDrawModeIntegralMenuItem.setAction(actionMap.get("actionDrawModeIntegral")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeIntegralMenuItem);
        viewDrawModeIntegralMenuItem.setName("viewDrawModeIntegralMenuItem"); // NOI18N
        viewDrawModeMenu.add(viewDrawModeIntegralMenuItem);

        viewMenu.add(viewDrawModeMenu);

        viewZoomMenu.setText(resourceMap.getString("viewZoomMenu.text")); // NOI18N
        viewZoomMenu.setEnabled(false);
        viewZoomMenu.setName("viewZoomMenu"); // NOI18N

        viewZoom25MenuItem.setAction(actionMap.get("viewZoom25")); // NOI18N
        zoomButtonGroup.add(viewZoom25MenuItem);
        viewZoom25MenuItem.setName("viewZoom25MenuItem"); // NOI18N
        viewZoomMenu.add(viewZoom25MenuItem);

        viewZoom50MenuItem.setAction(actionMap.get("viewZoom50")); // NOI18N
        zoomButtonGroup.add(viewZoom50MenuItem);
        viewZoom50MenuItem.setName("viewZoom50MenuItem"); // NOI18N
        viewZoomMenu.add(viewZoom50MenuItem);

        viewZoom100MenuItem.setAction(actionMap.get("viewZoom100")); // NOI18N
        zoomButtonGroup.add(viewZoom100MenuItem);
        viewZoom100MenuItem.setSelected(true);
        viewZoom100MenuItem.setName("viewZoom100MenuItem"); // NOI18N
        viewZoomMenu.add(viewZoom100MenuItem);

        viewZoom200MenuItem.setAction(actionMap.get("viewZoom200")); // NOI18N
        zoomButtonGroup.add(viewZoom200MenuItem);
        viewZoom200MenuItem.setName("viewZoom200MenuItem"); // NOI18N
        viewZoomMenu.add(viewZoom200MenuItem);

        viewZoom400MenuItem.setAction(actionMap.get("viewZoom400")); // NOI18N
        zoomButtonGroup.add(viewZoom400MenuItem);
        viewZoom400MenuItem.setName("viewZoom400MenuItem"); // NOI18N
        viewZoomMenu.add(viewZoom400MenuItem);

        viewMenu.add(viewZoomMenu);

        menuBar.add(viewMenu);

        audioMenu.setText(resourceMap.getString("audioMenu.text")); // NOI18N
        audioMenu.setName("audioMenu"); // NOI18N

        jMenuItem2.setAction(actionMap.get("actionPlayerPlay")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        audioMenu.add(jMenuItem2);

        jMenuItem3.setAction(actionMap.get("actionPlayerPause")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        audioMenu.add(jMenuItem3);

        jMenuItem4.setAction(actionMap.get("actionPlayerStop")); // NOI18N
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        audioMenu.add(jMenuItem4);

        jSeparator17.setName("jSeparator17"); // NOI18N
        audioMenu.add(jSeparator17);

        audioResizeMenuItem.setAction(actionMap.get("pictResizeAction")); // NOI18N
        audioResizeMenuItem.setName("audioResizeMenuItem"); // NOI18N
        audioMenu.add(audioResizeMenuItem);

        audioToolMenu.setText(resourceMap.getString("audioToolMenu.text")); // NOI18N
        audioToolMenu.setName("audioToolMenu"); // NOI18N

        toolSelectionMenuItem.setAction(actionMap.get("actionToolsSelection")); // NOI18N
        toolSelectionMenuItem.setSelected(true);
        toolSelectionMenuItem.setName("toolSelectionMenuItem"); // NOI18N
        audioToolMenu.add(toolSelectionMenuItem);

        toolPencilMenuItem.setAction(actionMap.get("actionToolPencil")); // NOI18N
        toolPencilMenuItem.setName("toolPencilMenuItem"); // NOI18N
        audioToolMenu.add(toolPencilMenuItem);

        audioMenu.add(audioToolMenu);

        audioTransformMenu.setText(resourceMap.getString("audioTransformMenu.text")); // NOI18N
        audioTransformMenu.setEnabled(false);
        audioTransformMenu.setName("audioTransformMenu"); // NOI18N

        audioTransformMirrorMenuItem.setAction(actionMap.get("pictRotateMirror")); // NOI18N
        audioTransformMirrorMenuItem.setName("audioTransformMirrorMenuItem"); // NOI18N
        audioTransformMenu.add(audioTransformMirrorMenuItem);

        audioMenu.add(audioTransformMenu);

        menuBar.add(audioMenu);

        optionMenu.setText(resourceMap.getString("optionMenu.text")); // NOI18N
        optionMenu.setName("optionMenu"); // NOI18N

        setFontMenuItem.setText(resourceMap.getString("setFontMenuItem.text")); // NOI18N
        setFontMenuItem.setToolTipText(resourceMap.getString("setFontMenuItem.toolTipText")); // NOI18N
        setFontMenuItem.setName("setFontMenuItem"); // NOI18N
        setFontMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                setFontMenuItemActionPerformed(evt);
            }
        });
        optionMenu.add(setFontMenuItem);

        setColorsMenuItem.setText(resourceMap.getString("setColorsMenuItem.text")); // NOI18N
        setColorsMenuItem.setToolTipText(resourceMap.getString("setColorsMenuItem.toolTipText")); // NOI18N
        setColorsMenuItem.setName("setColorsMenuItem"); // NOI18N
        setColorsMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                setColorsMenuItemActionPerformed(evt);
            }
        });
        optionMenu.add(setColorsMenuItem);

        jSeparator3.setName("jSeparator3"); // NOI18N
        optionMenu.add(jSeparator3);

        toolsOptionsMenuItem.setAction(actionMap.get("actionToolsOptions")); // NOI18N
        toolsOptionsMenuItem.setName("toolsOptionsMenuItem"); // NOI18N
        optionMenu.add(toolsOptionsMenuItem);

        menuBar.add(optionMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        helpContextMenuItem.setAction(actionMap.get("actionHelpContext")); // NOI18N
        helpContextMenuItem.setName("helpContextMenuItem"); // NOI18N
        helpMenu.add(helpContextMenuItem);

        helpOnlineMenuItem.setAction(actionMap.get("actionHelpOnline")); // NOI18N
        helpOnlineMenuItem.setName("helpOnlineMenuItem"); // NOI18N
        helpMenu.add(helpOnlineMenuItem);

        jSeparator1.setName("jSeparator1"); // NOI18N
        helpMenu.add(jSeparator1);

        aboutMenuItem.setAction(actionMap.get("actionHelpAbout")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);
        JMenuItem[] menuItems = { aboutMenuItem, fileOpenMenuItem, fileSaveAsMenuItem, toolsOptionsMenuItem, filePrintMenuItem, editFindMenuItem, editFindReplaceMenuItem, editGotoMenuItem, audioResizeMenuItem, setColorsMenuItem, setFontMenuItem, helpContextMenuItem, helpOnlineMenuItem };
        for (JMenuItem item : menuItems) {
            item.setText(item.getText()+DIALOG_MENU_SUFIX);
        }

        statusBar.setName("statusBar"); // NOI18N
        statusBar.setLayout(new BorderLayout());

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
        statusBar.add(statusPanelSeparator, BorderLayout.NORTH);

        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setPreferredSize(new Dimension(649, 26));
        statusPanel.setRequestFocusEnabled(false);
        statusPanel.setLayout(new CardLayout());

        emptyStatusPanel.setName("emptyStatusPanel"); // NOI18N

        GroupLayout emptyStatusPanelLayout = new GroupLayout(emptyStatusPanel);
        emptyStatusPanel.setLayout(emptyStatusPanelLayout);
        emptyStatusPanelLayout.setHorizontalGroup(
            emptyStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 640, Short.MAX_VALUE)
        );
        emptyStatusPanelLayout.setVerticalGroup(
            emptyStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );

        statusPanel.add(emptyStatusPanel, "default");

        mainStatusPanel.setName("mainStatusPanel"); // NOI18N
        mainStatusPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

        statusLabel.setName("statusLabel"); // NOI18N
        mainStatusPanel.add(statusLabel);

        statusPanel.add(mainStatusPanel, "main");

        progressStatusPanel.setName("progressStatusPanel"); // NOI18N

        jProgressBar1.setIndeterminate(true);
        jProgressBar1.setMinimumSize(new Dimension(10, 10));
        jProgressBar1.setName("jProgressBar1"); // NOI18N
        jProgressBar1.setRequestFocusEnabled(false);
        jProgressBar1.setStringPainted(true);

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setEnabled(false);
        jButton4.setMinimumSize(new Dimension(67, 15));
        jButton4.setName("jButton4"); // NOI18N
        jButton4.setPreferredSize(new Dimension(75, 20));

        GroupLayout progressStatusPanelLayout = new GroupLayout(progressStatusPanel);
        progressStatusPanel.setLayout(progressStatusPanelLayout);
        progressStatusPanelLayout.setHorizontalGroup(
            progressStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(Alignment.TRAILING, progressStatusPanelLayout.createSequentialGroup()
                .addComponent(jProgressBar1, GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jButton4, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE))
        );
        progressStatusPanelLayout.setVerticalGroup(
            progressStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(progressStatusPanelLayout.createParallelGroup(Alignment.BASELINE)
                .addComponent(jButton4, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addComponent(jProgressBar1, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE))
        );

        statusPanel.add(progressStatusPanel, "initCat");

        busyStatusPanel.setName("busyStatusPanel"); // NOI18N

        jProgressBar2.setIndeterminate(true);
        jProgressBar2.setName("jProgressBar2"); // NOI18N
        jProgressBar2.setRequestFocusEnabled(false);
        jProgressBar2.setStringPainted(true);

        GroupLayout busyStatusPanelLayout = new GroupLayout(busyStatusPanel);
        busyStatusPanel.setLayout(busyStatusPanelLayout);
        busyStatusPanelLayout.setHorizontalGroup(
            busyStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(jProgressBar2, GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
        );
        busyStatusPanelLayout.setVerticalGroup(
            busyStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(jProgressBar2, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
        );

        statusPanel.add(busyStatusPanel, "busy");

        textEditorStatusPanel.setName("textEditorStatusPanel"); // NOI18N

        cursorPositionTextField.setEditable(false);
        cursorPositionTextField.setHorizontalAlignment(JTextField.CENTER);
        cursorPositionTextField.setText("1:1"); // NOI18N
        cursorPositionTextField.setToolTipText(resourceMap.getString("cursorPositionTextField.toolTipText")); // NOI18N
        cursorPositionTextField.setName("cursorPositionTextField"); // NOI18N

        encodingLabel.setName("encodingLabel"); // NOI18N

        encodingTextField.setEditable(false);
        encodingTextField.setHorizontalAlignment(JTextField.CENTER);
        encodingTextField.setText("UTF-8"); // NOI18N
        encodingTextField.setToolTipText(resourceMap.getString("encodingTextField.toolTipText")); // NOI18N
        encodingTextField.setName("encodingTextField"); // NOI18N

        GroupLayout textEditorStatusPanelLayout = new GroupLayout(textEditorStatusPanel);
        textEditorStatusPanel.setLayout(textEditorStatusPanelLayout);
        textEditorStatusPanelLayout.setHorizontalGroup(
            textEditorStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(textEditorStatusPanelLayout.createSequentialGroup()
                .addComponent(cursorPositionTextField, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED, 427, Short.MAX_VALUE)
                .addComponent(encodingLabel)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(encodingTextField, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        textEditorStatusPanelLayout.setVerticalGroup(
            textEditorStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(textEditorStatusPanelLayout.createParallelGroup(Alignment.BASELINE)
                .addComponent(cursorPositionTextField, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addComponent(encodingTextField, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
                .addComponent(encodingLabel))
        );

        statusPanel.add(textEditorStatusPanel, "Source");

        audioStatusPanel.setName("audioStatusPanel"); // NOI18N

        currentPositionTextField.setEditable(false);
        currentPositionTextField.setHorizontalAlignment(JTextField.CENTER);
        currentPositionTextField.setText("0:00.00"); // NOI18N
        currentPositionTextField.setToolTipText(resourceMap.getString("currentPositionTextField.toolTipText")); // NOI18N
        currentPositionTextField.setName("currentPositionTextField"); // NOI18N

        playerControlToolBar.setFloatable(false);
        playerControlToolBar.setRollover(true);
        playerControlToolBar.setName("playerControlToolBar"); // NOI18N

        jButton12.setAction(actionMap.get("actionPlayerPlay")); // NOI18N
        jButton12.setText(resourceMap.getString("jButton12.text")); // NOI18N
        jButton12.setFocusable(false);
        jButton12.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton12.setName("jButton12"); // NOI18N
        jButton12.setVerticalTextPosition(SwingConstants.BOTTOM);
        playerControlToolBar.add(jButton12);

        GroupLayout audioStatusPanelLayout = new GroupLayout(audioStatusPanel);
        audioStatusPanel.setLayout(audioStatusPanelLayout);
        audioStatusPanelLayout.setHorizontalGroup(
            audioStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(audioStatusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(playerControlToolBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31)
                .addComponent(currentPositionTextField, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(469, Short.MAX_VALUE))
        );
        audioStatusPanelLayout.setVerticalGroup(
            audioStatusPanelLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(currentPositionTextField, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
            .addComponent(playerControlToolBar, GroupLayout.PREFERRED_SIZE, 26, Short.MAX_VALUE)
        );

        statusPanel.add(audioStatusPanel, "Wave");

        statusBar.add(statusPanel, BorderLayout.CENTER);

        StatusIconsPanel.setName("StatusIconsPanel"); // NOI18N

        GroupLayout StatusIconsPanelLayout = new GroupLayout(StatusIconsPanel);
        StatusIconsPanel.setLayout(StatusIconsPanelLayout);
        StatusIconsPanelLayout.setHorizontalGroup(
            StatusIconsPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 16, Short.MAX_VALUE)
        );
        StatusIconsPanelLayout.setVerticalGroup(
            StatusIconsPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );

        statusBar.add(StatusIconsPanel, BorderLayout.EAST);

        mainPopupMenu.setName("mainPopupMenu"); // NOI18N

        popupItemOpenMenuItem.setAction(actionMap.get("actionItemOpen")); // NOI18N
        popupItemOpenMenuItem.setName("popupItemOpenMenuItem"); // NOI18N
        mainPopupMenu.add(popupItemOpenMenuItem);

        popupItemAddMenuItem.setAction(actionMap.get("actionItemAdd")); // NOI18N
        popupItemAddMenuItem.setName("popupItemAddMenuItem"); // NOI18N
        mainPopupMenu.add(popupItemAddMenuItem);

        popupItemModifyMenuItem.setAction(actionMap.get("actionItemModify")); // NOI18N
        popupItemModifyMenuItem.setName("popupItemModifyMenuItem"); // NOI18N
        mainPopupMenu.add(popupItemModifyMenuItem);

        jSeparator14.setName("jSeparator14"); // NOI18N
        mainPopupMenu.add(jSeparator14);

        popupUndoMenuItem.setAction(actionMap.get("actionEditUndo")); // NOI18N
        popupUndoMenuItem.setName("popupUndoMenuItem"); // NOI18N
        mainPopupMenu.add(popupUndoMenuItem);

        popupRedoMenuItem.setAction(actionMap.get("actionEditRedo")); // NOI18N
        popupRedoMenuItem.setName("popupRedoMenuItem"); // NOI18N
        mainPopupMenu.add(popupRedoMenuItem);

        jSeparator10.setName("jSeparator10"); // NOI18N
        mainPopupMenu.add(jSeparator10);

        popupCutMenuItem.setAction(actionMap.get("cut"));
        popupCutMenuItem.setName("popupCutMenuItem"); // NOI18N
        mainPopupMenu.add(popupCutMenuItem);

        popupCopyMenuItem.setAction(actionMap.get("copy"));
        popupCopyMenuItem.setName("popupCopyMenuItem"); // NOI18N
        mainPopupMenu.add(popupCopyMenuItem);

        popupPasteMenuItem.setAction(actionMap.get("paste"));
        popupPasteMenuItem.setName("popupPasteMenuItem"); // NOI18N
        mainPopupMenu.add(popupPasteMenuItem);

        popupDeleteMenuItem.setAction(actionMap.get("delete"));
        popupDeleteMenuItem.setName("popupDeleteMenuItem"); // NOI18N
        mainPopupMenu.add(popupDeleteMenuItem);
        JMenuItem[] popupItems = { };
        for (JMenuItem item : popupItems) {
            item.setText(item.getText()+DIALOG_MENU_SUFIX);
        }

        toolMenu.setText(resourceMap.getString("toolMenu.text")); // NOI18N
        toolMenu.setName("toolMenu"); // NOI18N

        graphPopupMenu.setName("graphPopupMenu"); // NOI18N

        popupAddNodeMenuItem.setAction(actionMap.get("actionGraphAddNode")); // NOI18N
        popupAddNodeMenuItem.setName("popupAddNodeMenuItem"); // NOI18N
        graphPopupMenu.add(popupAddNodeMenuItem);

        popupRemoveNodeMenuItem.setAction(actionMap.get("actionGraphRemoveNode")); // NOI18N
        popupRemoveNodeMenuItem.setName("popupRemoveNodeMenuItem"); // NOI18N
        graphPopupMenu.add(popupRemoveNodeMenuItem);

        sourcePopupMenu.setName("sourcePopupMenu"); // NOI18N

        jMenuItem15.setAction(actionMap.get("actionEditUndo")); // NOI18N
        jMenuItem15.setName("jMenuItem15"); // NOI18N
        sourcePopupMenu.add(jMenuItem15);

        jMenuItem16.setAction(actionMap.get("actionEditRedo")); // NOI18N
        jMenuItem16.setName("jMenuItem16"); // NOI18N
        sourcePopupMenu.add(jMenuItem16);

        jSeparator13.setName("jSeparator13"); // NOI18N
        sourcePopupMenu.add(jSeparator13);

        jMenuItem7.setAction(actionMap.get("cut"));
        jMenuItem7.setName("jMenuItem7"); // NOI18N
        sourcePopupMenu.add(jMenuItem7);

        jMenuItem8.setAction(actionMap.get("copy"));
        jMenuItem8.setName("jMenuItem8"); // NOI18N
        sourcePopupMenu.add(jMenuItem8);

        jMenuItem9.setAction(actionMap.get("paste"));
        jMenuItem9.setName("jMenuItem9"); // NOI18N
        sourcePopupMenu.add(jMenuItem9);

        jMenuItem10.setAction(actionMap.get("delete"));
        jMenuItem10.setName("jMenuItem10"); // NOI18N
        sourcePopupMenu.add(jMenuItem10);

        jSeparator15.setName("jSeparator15"); // NOI18N
        sourcePopupMenu.add(jSeparator15);

        jMenuItem1.setAction(actionMap.get("actionEditSelectAll")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        sourcePopupMenu.add(jMenuItem1);

        audioPopupMenu.setName("audioPopupMenu"); // NOI18N

        jMenuItem17.setAction(actionMap.get("actionEditUndo")); // NOI18N
        jMenuItem17.setName("jMenuItem17"); // NOI18N
        audioPopupMenu.add(jMenuItem17);

        jMenuItem18.setAction(actionMap.get("actionEditRedo")); // NOI18N
        jMenuItem18.setName("jMenuItem18"); // NOI18N
        audioPopupMenu.add(jMenuItem18);

        jSeparator18.setName("jSeparator18"); // NOI18N
        audioPopupMenu.add(jSeparator18);

        jMenuItem11.setAction(actionMap.get("cut"));
        jMenuItem11.setText(resourceMap.getString("jMenuItem11.text")); // NOI18N
        jMenuItem11.setToolTipText(resourceMap.getString("jMenuItem11.toolTipText")); // NOI18N
        jMenuItem11.setName("jMenuItem11"); // NOI18N
        audioPopupMenu.add(jMenuItem11);

        jMenuItem12.setAction(actionMap.get("copy"));
        jMenuItem12.setText(resourceMap.getString("jMenuItem12.text")); // NOI18N
        jMenuItem12.setToolTipText(resourceMap.getString("jMenuItem12.toolTipText")); // NOI18N
        jMenuItem12.setName("jMenuItem12"); // NOI18N
        audioPopupMenu.add(jMenuItem12);

        jMenuItem13.setAction(actionMap.get("paste"));
        jMenuItem13.setText(resourceMap.getString("jMenuItem13.text")); // NOI18N
        jMenuItem13.setToolTipText(resourceMap.getString("jMenuItem13.toolTipText")); // NOI18N
        jMenuItem13.setName("jMenuItem13"); // NOI18N
        audioPopupMenu.add(jMenuItem13);

        jMenuItem14.setAction(actionMap.get("delete"));
        jMenuItem14.setText(resourceMap.getString("jMenuItem14.text")); // NOI18N
        jMenuItem14.setToolTipText(resourceMap.getString("jMenuItem14.toolTipText")); // NOI18N
        jMenuItem14.setName("jMenuItem14"); // NOI18N
        audioPopupMenu.add(jMenuItem14);

        jSeparator19.setName("jSeparator19"); // NOI18N
        audioPopupMenu.add(jSeparator19);

        jMenuItem5.setAction(actionMap.get("actionEditSelectAll")); // NOI18N
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        audioPopupMenu.add(jMenuItem5);

        popupviewDrawModeMenu.setText(resourceMap.getString("popupviewDrawModeMenu.text")); // NOI18N
        popupviewDrawModeMenu.setName("popupviewDrawModeMenu"); // NOI18N

        viewDrawModeDotsMenuItem1.setAction(actionMap.get("actionDrawModeDots")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeDotsMenuItem1);
        viewDrawModeDotsMenuItem1.setName("viewDrawModeDotsMenuItem1"); // NOI18N
        popupviewDrawModeMenu.add(viewDrawModeDotsMenuItem1);

        viewDrawModeLinesMenuItem1.setAction(actionMap.get("actionDrawModeLines")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeLinesMenuItem1);
        viewDrawModeLinesMenuItem1.setName("viewDrawModeLinesMenuItem1"); // NOI18N
        popupviewDrawModeMenu.add(viewDrawModeLinesMenuItem1);

        viewDrawModeIntegralMenuItem1.setAction(actionMap.get("actionDrawModeIntegral")); // NOI18N
        drawModeButtonGroup.add(viewDrawModeIntegralMenuItem1);
        viewDrawModeIntegralMenuItem1.setName("viewDrawModeIntegralMenuItem1"); // NOI18N
        popupviewDrawModeMenu.add(viewDrawModeIntegralMenuItem1);

        audioPopupMenu.add(popupviewDrawModeMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusBar);
        setToolBar(toolBar);
    }// </editor-fold>//GEN-END:initComponents

    private void setFontMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_setFontMenuItemActionPerformed
        if (activePanel instanceof TextPanel) {
            FontDialog dlg = new FontDialog(((SingleFrameApplication) getApplication()).getMainFrame(), true);
            dlg.setLocationRelativeTo(dlg.getParent());
            ((TextPanel)activePanel).showFontDialog(dlg);
        }
}//GEN-LAST:event_setFontMenuItemActionPerformed

    private void setColorsMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_setColorsMenuItemActionPerformed
        if (activePanel instanceof TextPanel) {
            ColorDialog dlg = new ColorDialog(((SingleFrameApplication) getApplication()).getMainFrame(), true);
            dlg.setLocationRelativeTo(dlg.getParent());
            ((TextPanel)activePanel).showColorDialog(dlg);
        }
}//GEN-LAST:event_setColorsMenuItemActionPerformed

    private void viewWordWrapCheckBoxMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_viewWordWrapCheckBoxMenuItemActionPerformed
        if (activePanel instanceof TextPanel) {
            viewWordWrapCheckBoxMenuItem.setSelected(((TextPanel)activePanel).changeLineWrap());
        }
}//GEN-LAST:event_viewWordWrapCheckBoxMenuItemActionPerformed

    @Action
    public void actionFileOpen() {
        if (!releaseFile()) return;
        if (openFC.showOpenDialog(((SingleFrameApplication) getApplication()).getMainFrame()) == JFileChooser.APPROVE_OPTION) {
            String fileName = openFC.getSelectedFile().getAbsolutePath();
            setFileName(fileName);
          
            FileFilter fileFilter = openFC.getFileFilter();
            if (fileFilter instanceof AudioFileFilter) {
                audioPanel.setFileName(fileName);
                audioPanel.loadFromFile();
            } else if ((fileFilter instanceof TXTFilesFilter)||(fileFilter instanceof SoundCompFilesFilter)) {
                textPanel.setFileName(fileName);
                textPanel.loadFromFile();
            } else {
                loadFromFile(fileName);
                return;
            }
            // Update recent files list
            if (recentFiles.contains(fileName)) recentFiles.remove(fileName);
            recentFiles.add(0, fileName);
            if (recentFiles.size() > 15) recentFiles.remove(14);
            rebuildRecentFilesMenu();
        }
    }

    private void loadFromFile(String fileName) {
        setFileName(fileName);
        if ("wav".equals(getExtension(new File(fileName)).toLowerCase())) {
           audioPanel.setFileName(fileName);
           audioPanel.loadFromFile();
        } else {
           textPanel.setFileName(fileName);
           textPanel.loadFromFile();
        }
//        activePanel.loadFromFile();
//        activePanel.updateItem();
//        activePanel.reportStructureChange(null);

        // Update recent files list
        if (recentFiles.contains(fileName)) recentFiles.remove(fileName);
        recentFiles.add(0, fileName);
        if (recentFiles.size() > 15) recentFiles.remove(14);
        rebuildRecentFilesMenu();
    }

    @Action
    public void actionFileSave() {
        // TODO: Set button grayed when saved and no changes were made.
        // TODO: jButton3.setIcon(jButton3.getDisabledIcon());
/*        if ((!"".equals(activePanel.getFileName()))&&(activePanel.getFileName() != null)) {
            activePanel.saveToFile();
        } else actionFileSaveAs(); */
    }

    @Action
    public void actionFileNew() {
        if (releaseFile()) {
//            activePanel.newFile();
            setFileName("");
        }
    }

    @Action
    public void actionFileSaveAs() {
        if (saveFC.showSaveDialog(((SingleFrameApplication) getApplication()).getMainFrame()) == JFileChooser.APPROVE_OPTION) {
            if (new File(saveFC.getSelectedFile().getAbsolutePath()).exists()) {
                if (!overwriteFile()) return;
            }
            setFileName(saveFC.getSelectedFile().getAbsolutePath());
/*            if (saveFC.getFileFilter().getDescription().equals(resourceMap.getString("filter_file_xbt"))) {
                activePanel.setFileMode(2);
            } else activePanel.setFileMode(1); */
            actionFileSave();          
        }
    }

    @Action (enabledProperty = "undoAvailable")
    public void actionEditUndo() {
        if (activePanel instanceof TextPanel) ((TextPanel)activePanel).getUndo().undo();
//        activePanel.performUndo();
//        activePanel.getDoc().processSpec();
        firePropertyChange("undoAvailable", false, true);
        firePropertyChange("redoAvailable", false, true);
    }

    @Action(enabledProperty = "redoAvailable")
    public void actionEditRedo() {
        if (activePanel instanceof TextPanel) ((TextPanel)activePanel).getUndo().redo();
//        activePanel.performRedo();
//        activePanel.getDoc().processSpec();
        firePropertyChange("undoAvailable", false, true);
        firePropertyChange("redoAvailable", false, true);
    }

    @Action(selectedProperty = "toolBarEnabled")
    public void actionViewToolbar() {
        toolBar.setVisible(!toolBar.isVisible());
        viewCaptionsCheckBoxMenuItem.setEnabled(toolBar.isVisible());
    }

    @Action(selectedProperty = "statusBarEnabled")
    public void actionViewStatusBar() {
        statusBar.setVisible(!statusBar.isVisible());
    }

    @Action
    public void actionToolsOptions() {
        optionsDialog = new OptionsDialog(((SingleFrameApplication) getApplication()).getMainFrame(),true);
        optionsDialog.setPreferenceReader(new OptionsDialog.PreferencesReader() {
            public void loadPreferences(Preferences prefs) {
                loadPreferences(prefs);
            }
        });
        optionsDialog.setLocationRelativeTo(optionsDialog.getParent());
        optionsDialog.setVisible(true);
    }

    public boolean isEditEnabled() {
        if (activePanel == null) return false;
        return false; // activePanel.isEditEnabled();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private JPanel StatusIconsPanel;
    private JMenu audioMenu;
    private JPopupMenu audioPopupMenu;
    private JMenuItem audioResizeMenuItem;
    private JPanel audioStatusPanel;
    private JMenu audioToolMenu;
    private JMenu audioTransformMenu;
    private JMenuItem audioTransformMirrorMenuItem;
    private JPanel busyStatusPanel;
    private JTextField currentPositionTextField;
    private JTextField cursorPositionTextField;
    private ButtonGroup drawModeButtonGroup;
    private JMenuItem editCopyMenuItem;
    private JMenuItem editCutMenuItem;
    private JMenuItem editDeleteMenuItem;
    private JMenuItem editFindAgainMenuItem;
    private JMenuItem editFindMenuItem;
    private JMenuItem editFindReplaceMenuItem;
    private JMenuItem editGotoMenuItem;
    private JMenu editMenu;
    private JMenuItem editPasteMenuItem;
    private JMenuItem editRedoMenuItem;
    private JMenuItem editSelectAllMenuItem;
    private JMenuItem editUndoMenuItem;
    private JPanel emptyStatusPanel;
    private JLabel encodingLabel;
    private JTextField encodingTextField;
    private JMenuItem fileNewMenuItem;
    private JMenu fileOpenRecentMenu;
    private JMenuItem filePrintMenuItem;
    private JMenuItem fileSaveAsMenuItem;
    private JMenuItem fileSaveMenuItem;
    private JPopupMenu graphPopupMenu;
    private JMenuItem helpContextMenuItem;
    private JMenuItem helpOnlineMenuItem;
    private JButton jButton1;
    private JButton jButton10;
    private JButton jButton11;
    private JButton jButton12;
    private JButton jButton2;
    private JButton jButton3;
    private JButton jButton4;
    private JButton jButton5;
    private JButton jButton6;
    private JButton jButton7;
    private JButton jButton8;
    private JButton jButton9;
    private JMenuItem jMenuItem1;
    private JMenuItem jMenuItem10;
    private JMenuItem jMenuItem11;
    private JMenuItem jMenuItem12;
    private JMenuItem jMenuItem13;
    private JMenuItem jMenuItem14;
    private JMenuItem jMenuItem15;
    private JMenuItem jMenuItem16;
    private JMenuItem jMenuItem17;
    private JMenuItem jMenuItem18;
    private JMenuItem jMenuItem2;
    private JMenuItem jMenuItem3;
    private JMenuItem jMenuItem4;
    private JMenuItem jMenuItem5;
    private JMenuItem jMenuItem7;
    private JMenuItem jMenuItem8;
    private JMenuItem jMenuItem9;
    private JProgressBar jProgressBar1;
    private JProgressBar jProgressBar2;
    private JPopupMenu.Separator jSeparator1;
    private JSeparator jSeparator10;
    private Separator jSeparator11;
    private JPopupMenu.Separator jSeparator12;
    private JSeparator jSeparator13;
    private JPopupMenu.Separator jSeparator14;
    private JSeparator jSeparator15;
    private JPopupMenu.Separator jSeparator16;
    private JPopupMenu.Separator jSeparator17;
    private JSeparator jSeparator18;
    private JSeparator jSeparator19;
    private JSeparator jSeparator2;
    private JPopupMenu.Separator jSeparator3;
    private Separator jSeparator4;
    private Separator jSeparator5;
    private JPopupMenu.Separator jSeparator6;
    private JPopupMenu.Separator jSeparator7;
    private JPopupMenu.Separator jSeparator8;
    private JSeparator jSeparator9;
    private JPanel mainPanel;
    private JPopupMenu mainPopupMenu;
    private JPanel mainStatusPanel;
    private JTabbedPane mainTabbedPane;
    private JMenuBar menuBar;
    private JMenu optionMenu;
    private JToolBar playerControlToolBar;
    private JMenuItem popupAddNodeMenuItem;
    private JMenuItem popupCopyMenuItem;
    private JMenuItem popupCutMenuItem;
    private JMenuItem popupDeleteMenuItem;
    private JMenuItem popupItemAddMenuItem;
    private JMenuItem popupItemModifyMenuItem;
    private JMenuItem popupItemOpenMenuItem;
    private JMenuItem popupPasteMenuItem;
    private JMenuItem popupRedoMenuItem;
    private JMenuItem popupRemoveNodeMenuItem;
    private JMenuItem popupUndoMenuItem;
    private JMenu popupviewDrawModeMenu;
    private JPanel progressStatusPanel;
    private JMenuItem setColorsMenuItem;
    private JMenuItem setFontMenuItem;
    private JPopupMenu sourcePopupMenu;
    private JPanel statusBar;
    private JLabel statusLabel;
    private JPanel statusPanel;
    private JPanel textEditorStatusPanel;
    private JToolBar toolBar;
    private JMenu toolMenu;
    private JRadioButtonMenuItem toolPencilMenuItem;
    private JRadioButtonMenuItem toolSelectionMenuItem;
    private ButtonGroup toolsModeButtonGroup;
    private JMenuItem toolsOptionsMenuItem;
    private JCheckBoxMenuItem viewCaptionsCheckBoxMenuItem;
    private JRadioButtonMenuItem viewDrawModeDotsMenuItem;
    private JRadioButtonMenuItem viewDrawModeDotsMenuItem1;
    private JRadioButtonMenuItem viewDrawModeIntegralMenuItem;
    private JRadioButtonMenuItem viewDrawModeIntegralMenuItem1;
    private JRadioButtonMenuItem viewDrawModeLinesMenuItem;
    private JRadioButtonMenuItem viewDrawModeLinesMenuItem1;
    private JMenu viewDrawModeMenu;
    private JMenu viewMenu;
    private JCheckBoxMenuItem viewStatusBarCheckBoxMenuItem;
    private JCheckBoxMenuItem viewToolBarCheckBoxMenuItem;
    private JCheckBoxMenuItem viewWordWrapCheckBoxMenuItem;
    private JRadioButtonMenuItem viewZoom100MenuItem;
    private JRadioButtonMenuItem viewZoom200MenuItem;
    private JRadioButtonMenuItem viewZoom25MenuItem;
    private JRadioButtonMenuItem viewZoom400MenuItem;
    private JRadioButtonMenuItem viewZoom50MenuItem;
    private JMenu viewZoomMenu;
    private ButtonGroup zoomButtonGroup;
    // End of variables declaration//GEN-END:variables

    /**
     * Get the extension part of file name.
     *
     * @param file Source file
     * @return extension part of file name
     */
    public static String getExtension(File file) {
        String ext = null;
        String str = file.getName();
        int i = str.lastIndexOf('.');

        if (i > 0 &&  i < str.length() - 1) ext = str.substring(i+1).toLowerCase();
        return ext;
    }

    public class AllFilesFilter extends FileFilter {

        public boolean accept(File f) {
            return true;
        }

        public String getDescription() {
            return resourceMap.getString("filter_file_all");
        }
    }

    public class TXTFilesFilter extends FileFilter {

        public boolean accept(File f) {
            if (f.isDirectory()) return true;
            String extension = getExtension(f);
            if (extension != null) return "txt".equals(extension);
            return false;
        }

        public String getDescription() {
            return resourceMap.getString("filter_file_txt");
        }
    }

    public class SoundCompFilesFilter extends FileFilter {

        public boolean accept(File f) {
            if (f.isDirectory()) return true;
            String extension = getExtension(f);
            if (extension != null) return "sc".equals(extension);
            return false;
        }

        public String getDescription() {
            return resourceMap.getString("filter_file_sc");
        }
    }

    @Action
    public void actionHelpAbout() {
        if (aboutDialog == null) aboutDialog = new AboutDialog(((SingleFrameApplication) getApplication()).getMainFrame());
        aboutDialog.setLocationRelativeTo(aboutDialog.getParent());
//        SoundCompIDE.getApplication().show(aboutBox);
        aboutDialog.setVisible(true);
    }

    @Action
    public void actionViewCaptions() {
        boolean flag = !viewCaptionsCheckBoxMenuItem.isSelected();
        viewCaptionsCheckBoxMenuItem.setSelected(!flag);
        Component[] comps = toolBar.getComponents();
        for (int i = 0; i < comps.length; i++) {
            if (comps[i] instanceof JButton) {
                ((JButton) comps[i]).setHideActionText(flag);
            }
        }
    }

    @Action
    public void actionHelpContext() {
    }

    @Action
    public void actionHelpOnline() {
        BareBonesBrowserLaunch.openURL("http://sf.net/apps/mediawiki/soundcomp/");
    }

    @Action()
    public void actionEditFind() {
        initFindDialog();
        findDialog.setShallReplace(false);
        findDialog.setSelected();
        findDialog.setLocationRelativeTo(findDialog.getParent());
        findDialog.setVisible(true);
        if (findDialog.getResultOption() == JOptionPane.OK_OPTION) {
            textPanel.findText(findDialog);
        }
    }

    @Action()
    public void actionEditReplace() {
        initFindDialog();
        findDialog.setShallReplace(true);
        findDialog.setSelected();
        findDialog.setLocationRelativeTo(findDialog.getParent());
        findDialog.setVisible(true);
        if (findDialog.getResultOption() == JOptionPane.OK_OPTION) {
            textPanel.findText(findDialog);
        }
    }

    @Action
    public void actionFilePrint() {
        textPanel.printFile();
    }

    @Action
    public void actionEditGoto() {
        initGotoDialog();
        gotoDialog.setMaxLine(textPanel.getLineCount());
        gotoDialog.setCharPos(1);
        gotoDialog.setLocationRelativeTo(gotoDialog.getParent());
        gotoDialog.setVisible(true);
        if (gotoDialog.getResultOption() == JOptionPane.OK_OPTION) {
            textPanel.gotoLine(gotoDialog.getLine());
            textPanel.gotoRelative(gotoDialog.getCharPos());
        }
    }

    @Action
    public void actionFindAgain() {
        initFindDialog();
        findDialog.setShallReplace(false);
        textPanel.findText(findDialog);
    }

    public void initFindDialog() {
        if (findDialog == null) findDialog = new FindDialog(((SingleFrameApplication) getApplication()).getMainFrame(),true);
    }

    public void initGotoDialog() {
        if (gotoDialog == null) gotoDialog = new GotoDialog(((SingleFrameApplication) getApplication()).getMainFrame(), true);
    }

    @Action
    public void actionGraphAddNode() {
        graphPanel.addNode("Node");
    }

    @Action
    public void actionGraphRemoveNode() {
    }

    @Action
    public void actionEditSelectAll() {
        if (activePanel instanceof TextPanel) {
            ((TextPanel)activePanel).performSelectAll();
        } else if (activePanel instanceof AudioPanel) {
            ((AudioPanel)activePanel).performSelectAll();
        }
    }

    public class XBSFilesFilter extends FileFilter {

        public boolean accept(File f) {
            if (f.isDirectory()) return true;
            String extension = getExtension(f);
            if (extension != null) {
                if (extension.length()<3) return false;
                return "xbs".contains(extension.substring(0,3));
            }
            return false;
        }

        public String getDescription() {
            return resourceMap.getString("filter_file_xbs");
        }
    }

    public class AudioFilesFilter extends FileFilter {

        public boolean accept(File f) {
            if (f.isDirectory()) return true;
            String extension = getExtension(f);
            if (extension != null) {
                if (extension.length()<3) return false;
                return "wav".contains(extension.substring(0,3));
            }
            return false;
        }

        public String getDescription() {
            return resourceMap.getString("filter_file_audio");
        }
    }

    private String[] formats;
    @Action
    public void viewZoom50() {
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).scale(0.5);
    }

    @Action
    public void viewZoom25() {
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).scale(0.25);
    }

    @Action
    public void viewZoom100() {
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).scale(1);
    }

    @Action
    public void viewZoom200() {
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).scale(2);
    }

    @Action
    public void viewZoom400() {
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).scale(4);
    }

    @Action
    public void pictResizeAction() {
        ImageResizeDialog dlg = new ImageResizeDialog(((SingleFrameApplication) getApplication()).getMainFrame(), true);
        dlg.setLocationRelativeTo(dlg.getParent());
        if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).showResizeDialog(dlg);
//        activePanel.setToolColor(dlg.getColorPanel().getTextColor());
    }

    @Action
    public void pictRotateMirror() {

    }

    @Action
    public void toolPencil() {

    }

    @Action
    public void actionPlayerPlay() {
        audioPanel.performPlay();
    }

    @Action
    public void actionPlayerPause() {
        //if (activePanel instanceof AudioPanel) ((AudioPanel)activePanel).performPause();
    }

    @Action
    public void actionPlayerStop() {
        audioPanel.performStop();
    }

    @Action
    public void actionToolPencil() {
    }

    @Action
    public void actionToolsSelection() {
    }

    @Action
    public void actionDrawModeDots() {
        audioPanel.setDrawMode(DrawMode.DOTS_MODE);
    }

    @Action
    public void actionDrawModeLines() {
        audioPanel.setDrawMode(DrawMode.LINE_MODE);
    }

    @Action
    public void actionDrawModeIntegral() {
        audioPanel.setDrawMode(DrawMode.INTEGRAL_MODE);
    }
}
TOP

Related Classes of net.sf.soundcomp.ide.MainFrame$AudioFilesFilter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.