public class StringResources {
    private HashMap<String, String> strings;

    private static StringResources instance = null;


    private StringResources() {
        this.strings = new HashMap<String, String>();
        strings.put("app_name", _("Περιβάλλον Ανάπτυξης Για Τη ΓΛΩΣΣΑ"));
        strings.put("app_version", "0.0.6");

        strings.put("file", _("_Αρχείο"));
        strings.put("file_new", _("_Δημιουργία"));
        strings.put("tooltip_file_new", _("Δημιουργία νέου αρχείου"));
        strings.put("file_open", _("_Άνοιγμα"));
        strings.put("tooltip_file_open", _("Άνοιγμα αρχείου"));
        strings.put("file_save", _("Α_ποθήκευση"));
        strings.put("tooltip_file_save", _("Αποθήκευση αρχείου"));
        strings.put("file_save_as", _("Απ_οθήκευση Ως..."));
        strings.put("tooltip_file_save_as", _("Αποθήκευση αρχείου ως..."));
        strings.put("export_html", _("Εξα_γωγή ως έγγραφο HTML..."));
        strings.put("tooltip_export_html",_("Εξαγωγή ως έγγραφο HTML..."));
        strings.put("file_print", _("_Εκτύπωση"));
        strings.put("tooltip_file_print", _("Εκτύπωση αρχείου"));
        strings.put("app_exit", _("Έ_ξοδος"));

        strings.put("edit", _("_Επεξεργασία"));
        strings.put("edit_undo", _("_Αναίρεση"));
        strings.put("tooltip_edit_undo", _("Αναίρεση"));
        strings.put("edit_redo", _("Α_κύρωση αναίρεσης"));
        strings.put("tooltip_edit_redo", _("Ακύρωση αναίρεσης"));
        strings.put("edit_cut", _("Α_ποκοπή"));
        strings.put("tooltip_edit_cut", _("Αποκοπή"));
        strings.put("edit_copy", _("Α_ντιγραφή"));
        strings.put("tooltip_edit_copy", _("Αντιγραφή"));
        strings.put("edit_paste", _("Επ_ικόλληση"));
        strings.put("tooltip_edit_paste", _("Επικόλληση"));
        strings.put("edit_delete", _("_Διαγραφή"));
        strings.put("tooltip_edit_delete", _("Διαγραφή"));
        strings.put("edit_select_all", _("Επι_λογή όλων"));
        strings.put("tooltip_edit_select_all", _("Επιλογή όλων"));

        strings.put("help", _("_Βοήθεια"));
        strings.put("show_help_contents", _("_Προβολή περιεχομένων βοήθειας"));
        strings.put("show_about_dialog", _("_Σχετικά με την εφαρμογή"));


        strings.put("program", _("_Πρόγραμμα"));
        strings.put("run", _("_Εκτέλεση"));
        strings.put("tooltip_run", _("Εκτέλεση"));
        strings.put("run_step_by_step", _("Εκτέλεση _βήμα προς βήμα"));
        strings.put("tooltip_run_step_by_step", _("Εκτέλεση βήμα προς βήμα"));
        strings.put("stop", _("_Διακοπή εκτέλεσης"));
        strings.put("tooltip_stop", _("Διακοπή εκτέλεσης"));
        strings.put("tooltip_execution_speed", _("Ταχύτητα εκτέλεσης (%)"));
        strings.put("use_input_file", _("_Χρήση αρχείου εισόδου"));
        strings.put("tooltip_use_input_file", _("Χρήση αρχείου εισόδου"));

        strings.put("untitled", _("Ανώνυμο"));
        strings.put("cursor_col", _("Στήλη"));
        strings.put("cursor_line", _("Γραμμή"));
        strings.put("modified", _("Τροποποιημένο"));

        strings.put("messages", _("Μηνύματα"));
        strings.put("runtime_window", _("Παράθυρο εκτέλεσης"));
        strings.put("input_file", _("Αρχείο εισόδου"));

        strings.put("save_file", _("Αποθήκευση αρχείου"));
        strings.put("open_file", _("Άνοιγμα αρχείου"));
        strings.put("glossa_files", _("Αρχεία κώδικα της ΓΛΩΣΣΑΣ (*.gls)"));
        strings.put("glossa_diermhneyths_files", _("Αρχεία του ΔΙΕΡΜΗΝΕΥΤΗ(*.γλώσσα)"));
        strings.put("all_files", _("Όλα τα αρχεία"));
        strings.put("html_files", _("Αρχεία HTML(*.html)"));
        strings.put("txt_files", _("Αρχεία απλού κειμένου(*.txt)"));
        strings.put("msg_file_modified", _("Το αρχείο '%1$s' έχει αλλάξει! Θέλετε να αποθηκεύσετε τις αλλαγές;"));
        strings.put("msg_input_file_modified", _("Το αρχείο εισόδου έχει αλλάξει! Θέλετε να αποθηκεύσετε τις αλλαγές;"));
        strings.put("msg_file_exists", _("Το αρχείο '%1$s' υπάρχει ήδη! Θέλετε να συνεχίσετε;"));
        strings.put("msg_file_exists_secondary", _("Τα τρέχοντα περιεχόμενα το αρχείου θα χαθούν!"));
        strings.put("msg_interpreter_running", _("Ο διερμηνευτής \"τρέχει\" ακόμη! Θέλετε να τερματίσετε την εκτέλεση;"));

        strings.put("type", _("Τύπος"));
        strings.put("position", _("Θέση"));
        strings.put("message", _("Μήνυμα"));

        strings.put("error", _("Σφάλμα"));
        strings.put("warning", _("Προειδοποίηση"));

        strings.put("submit", _("Υποβολή"));
        strings.put("type_here", _("Πληκτρολογήστε εδώ και πατήστε το Enter"));

        strings.put("preferences", _("Προτιμήσεις"));
        strings.put("font", _("Γραμματοσειρά"));
        strings.put("editor_scheme", _("Χρώματα επεξεργαστή κώδικα"));
        
        strings.put("commands", _("Εντολές"));
        strings.put("commands_list", _("Λίστα εντολών"));
    }

    public static StringResources getInstance(){
        if(instance == null){
            instance = new StringResources();
        }
        return instance;
    }

    public String getString(String key){
        return strings.get(key);
    }


} public class MenuBar extends org.gnome.gtk.MenuBar{

    public MenuBar() {
        this.append(new FileMenu());
        this.append(new EditMenu());
        this.append(new ProgramMenu());
        //TODO: Help and About dialogs
        this.append(new HelpMenu());
        this.setExpandVertical(false);
    }

} public class MainToolbar extends Toolbar{

    private final Entry searchBox;
    private final Scale scale;
    private static MainToolbar instance = null;

    public static MainToolbar getInstance(){
        if(instance == null){
            instance = new MainToolbar();
        }
        return instance;
    }

    private MainToolbar() {
        this.getStyleContext().addClass(StyleClass.PRIMARY_TOOLBAR);

        add(NewFileAction.getInstance().createToolItem());
        add(OpenFileAction.getInstance().createToolItem());
        add(SaveFileAction.getInstance().createToolItem());

        add(new SeparatorToolItem());

        add(PrintAction.getInstance().createToolItem());

        add(new SeparatorToolItem());

        add(UndoAction.getInstance().createToolItem());
        add(RedoAction.getInstance().createToolItem());

        add(new SeparatorToolItem());

        add(CutAction.getInstance().createToolItem());
        add(CopyAction.getInstance().createToolItem());
        add(PasteAction.getInstance().createToolItem());

        add(new SeparatorToolItem());


        StringResources strRes = StringResources.getInstance();

        add(RunAction.getInstance().createToolItem());
        add(ToggleStepByStepAction.getInstance().createToolItem());
        add(StopAction.getInstance().createToolItem());
        add(ToggleUseInputFileAction.getInstance().createToolItem());


        ToolItem wrapper = new ToolItem();
        scale = new Scale(Orientation.HORIZONTAL, new Adjustment(100, 0, 120, 1, 20, 20));
        scale.setSizeRequest(100, 20);
        scale.setValuePosition(PositionType.LEFT);
        scale.setDigits(0);
        scale.setTooltipText(strRes.getString("tooltip_execution_speed"));
        wrapper.add(scale);
        add(wrapper);

        SeparatorToolItem expander = new SeparatorToolItem();
        expander.setDraw(false);
        expander.setExpand(true);
        add(expander);

        wrapper = new ToolItem();
        searchBox = new Entry();
        searchBox.setIconFromStock(EntryIconPosition.PRIMARY, Stock.FIND);
        wrapper.add(searchBox);
        searchBox.connect(new Entry.Changed() {

            public void onChanged(Entry source) {
                Editor.getInstance().getBuffer().highlightSearchTerm(source.getText());
            }
        });
        searchBox.connect(new Entry.Activate() {

            public void onActivate(Entry source) {
                Editor.getInstance().getBuffer().search(source.getText());
            }
        });
        add(wrapper);
        
    }

    public void setDelayControlsSensitive(boolean sensitive){
        this.scale.setSensitive(sensitive);
    }

    public int getDelayBetweenSteps(){
        return 5000 -  ((int)this.scale.getValue())*50;
    }

} public class BottomPane extends Notebook{
    private final Label messagesTabLabel;
    private final Label runtimeWindowTabLabel;
    private final Label inputFileTabLabel;
    private final InterpreterMessagesListView messagesListView;

    public BottomPane() {
        StringResources strRes = StringResources.getInstance();
        this.messagesTabLabel = new Label(strRes.getString("messages"));
        this.runtimeWindowTabLabel = new Label(strRes.getString("runtime_window"));
        this.inputFileTabLabel = new Label(strRes.getString("input_file"));

        this.messagesListView = new InterpreterMessagesListView();

        ScrolledWindow sc1 = new ScrolledWindow();
        sc1.add(messagesListView);
        this.appendPage(sc1, messagesTabLabel);
        this.appendPage(RuntimeWindow.getInstance(), runtimeWindowTabLabel);
        this.appendPage(InputFileWindow.getInstance(), inputFileTabLabel);
    }

    public InterpreterMessagesListView getMessagesListView(){
        return this.messagesListView;
    }



} public class EditorContainer extends ScrolledWindow{

    public EditorContainer() {
        super();
        this.add(Editor.getInstance());
    }

    


} public class MainWindowStatusbar extends Statusbar{
    private static  MainWindowStatusbar instance = null;

    private String cursorColText;
    private String cursorLineText;
    private String modifiedText;

    private int cursorCol;
    private int cursorLine;
    private boolean modified;
    private File srcFile;

    private MainWindowStatusbar() {
        StringResources strRes = StringResources.getInstance();
        this.cursorColText = strRes.getString("cursor_col");
        this.cursorLineText = strRes.getString("cursor_line");
        this.modifiedText = strRes.getString("modified");
        this.cursorCol = 0;
        this.cursorLine = 0;
        this.modified = false;
        this.srcFile = null;
        updateMessage();
    }

    public static MainWindowStatusbar getInstance(){
        if(instance == null){
            instance = new MainWindowStatusbar();
        }
        return instance;
    }

    public void updateCursor(int x, int y){
        this.cursorCol = x;
        this.cursorLine = y;
        updateMessage();
    }

    public void updateModified(boolean modified){
        this.modified = modified;
        updateMessage();
    }

    public void updateSrcFile(File f){
        this.srcFile = f;
        updateMessage();
    }

    public void updateMessage(){
        StringBuilder msg = new StringBuilder();
        msg.append(cursorLineText);
        msg.append(": ");
        msg.append(cursorLine+1);
        msg.append(", ");
        msg.append(cursorColText);
        msg.append(": ");
        msg.append(cursorCol+1);
        if(modified){
            msg.append(" | ");
            msg.append(modifiedText);
        }
        if(srcFile != null){
            msg.append(" | ");
            msg.append(srcFile.getAbsolutePath());
        }
        this.setMessage(msg.toString());
    }



} public class Preferences extends PreferencesStorage{

    private static Preferences instance;

    private final String DEFAULT_EDITOR_FONT_FAMILY = "Monospace";
    private final int DEFAULT_EDITOR_FONT_SIZE = 11;
    private final int DEFAULT_EDITOR_RIGHT_MARGIN_POSITION = 80;
    private final int DEFAULT_EDITOR_TAB_WIDTH = 4;
    private final boolean DEFAULT_EDITOR_SHOWS_LINE_NUMBERS = true;
    private final boolean DEFAULT_EDITOR_SHOWS_RIGHT_MARGIN = true;
    private final boolean DEFAULT_EDITOR_HIGLIGHTS_CURRENT_LINE = true;
    private final String DEFAULT_EDITOR_SCHEME = "glossa";

    public static Preferences getInstance(){
        if(instance == null){
            instance = new Preferences();
        }
        return instance;
    }

    private Preferences(){
        super("lingua");
    }

    @Override
    public void setupDefaultValues(){
        setValue("editor-font-family", DEFAULT_EDITOR_FONT_FAMILY);
        setValue("editor-font-size", String.valueOf(DEFAULT_EDITOR_FONT_SIZE));
        setValue("editor-shows-line-numbers", String.valueOf(DEFAULT_EDITOR_SHOWS_LINE_NUMBERS));
        setValue("editor-highlights-current-line", String.valueOf(DEFAULT_EDITOR_HIGLIGHTS_CURRENT_LINE));
        setValue("editor-shows-right-margin", String.valueOf(DEFAULT_EDITOR_SHOWS_RIGHT_MARGIN));
        setValue("editor-right-margin-position", String.valueOf(DEFAULT_EDITOR_RIGHT_MARGIN_POSITION));
        setValue("editor-tab-width", String.valueOf(DEFAULT_EDITOR_TAB_WIDTH));
        setValue("editor-scheme", DEFAULT_EDITOR_SCHEME);
    }

    public void apply(){
        String fontDescription = getPangoCompatibleFontDescriptionString();
        InputFileWindow.getInstance().setFont(fontDescription);

        RuntimeWindow.getInstance().setFont(fontDescription);

        Editor ed = Editor.getInstance();
        ed.setFont(fontDescription);
        ed.setShowLineNumbers(getEditorShowsLineNumbers());
        ed.setShowRightMargin(getEditorShowsRightMargin());
        ed.setRightMarginPosition(getEditorRightMarginPosition());
        ed.setTabWidth(getEditorTabWidth());
        ed.setHighlightCurrentLine(getEditorHighlightsCurrentLine());
        ed.getBuffer().setScheme(getEditorScheme());
    }

    public String getPangoCompatibleFontDescriptionString(){
        return getEditorFontFamily() + " " + getEditorFontSize();
    }

    /**
     * @return the editorFontFamily
     */
    public String getEditorFontFamily() {
        String result = getValue("editor-font-family");
        return result==null?DEFAULT_EDITOR_FONT_FAMILY:result;
    }

    /**
     * @param editorFontFamily the editorFontFamily to set
     */
    public void setEditorFontFamily(String editorFontFamily) {
        setValue("editor-font-family", editorFontFamily);
    }
    
    /**
     * @return the editorScheme or null for default
     */
    public String getEditorScheme() {
        String result = getValue("editor-scheme");
        return result==null?DEFAULT_EDITOR_SCHEME:result;
    }

    /**
     * @param editorScheme the editorFontFamily to set
     */
    public void setEditorScheme(String editorScheme) {
        setValue("editor-scheme", "".equals(editorScheme)?null:editorScheme);
    }

    /**
     * @return the editorFontSize
     */
    public int getEditorFontSize() {
        String result =  getValue("editor-font-size");
        return result==null?DEFAULT_EDITOR_FONT_SIZE:Integer.valueOf(result);
    }

    /**
     * @param editorFontSize the editorFontSize to set
     */
    public void setEditorFontSize(int editorFontSize) {
        setValue("editor-font-size", String.valueOf(editorFontSize));
    }

    /**
     * @return the editorShowsLineNumbers
     */
    public boolean getEditorShowsLineNumbers() {
        String result =  getValue("editor-shows-line-numbers");
        return result==null?DEFAULT_EDITOR_SHOWS_LINE_NUMBERS:Boolean.parseBoolean(result);
    }

    /**
     * @param editorShowsLineNumbers the editorShowsLineNumbers to set
     */
    public void setEditorShowsLineNumbers(boolean editorShowsLineNumbers) {
        setValue("editor-shows-line-numbers", String.valueOf(editorShowsLineNumbers));
    }

    /**
     * @return the editorHighlightsCurrentLine
     */
    public boolean getEditorHighlightsCurrentLine() {
        String result =  getValue("editor-highlights-current-line");
        return result==null?DEFAULT_EDITOR_HIGLIGHTS_CURRENT_LINE:Boolean.parseBoolean(result);
    }

    /**
     * @param editorHighlightsCurrentLine the editorHighlightsCurrentLine to set
     */
    public void setEditorHighlightsCurrentLine(boolean editorHighlightsCurrentLine) {
        setValue("editor-highlights-current-line", String.valueOf(editorHighlightsCurrentLine));
    }

    /**
     * @return the editorShowsRightMargin
     */
    public boolean getEditorShowsRightMargin() {
        String result =  getValue("editor-shows-right-margin");
        return result==null?DEFAULT_EDITOR_SHOWS_RIGHT_MARGIN:Boolean.parseBoolean(result);
    }

    /**
     * @param editorShowsRightMargin the editorShowsRightMargin to set
     */
    public void setEditorShowsRightMargin(boolean editorShowsRightMargin) {
        setValue("editor-shows-right-margin", String.valueOf(editorShowsRightMargin));
    }

    /**
     * @return the editorRightMarginPosition
     */
    public int getEditorRightMarginPosition() {
        String result =  getValue("editor-right-margin-position");
        return result==null?DEFAULT_EDITOR_RIGHT_MARGIN_POSITION:Integer.valueOf(result);
    }

    /**
     * @param editorRightMarginPosition the editorRightMarginPosition to set
     */
    public void setEditorRightMarginPosition(int editorRightMarginPosition) {
        setValue("editor-right-margin-position", String.valueOf(editorRightMarginPosition));
    }

    /**
     * @return the editorTabWidth
     */
    public int getEditorTabWidth() {
        String result =  getValue("editor-tab-width");
        return result==null?DEFAULT_EDITOR_TAB_WIDTH:Integer.valueOf(result);
    }

    /**
     * @param editorTabWidth the editorTabWidth to set
     */
    public void setEditorTabWidth(int editorTabWidth) {
        setValue("editor-tab-width", String.valueOf(editorTabWidth));
    }

    public String getDefaultEditorScemeId(){
        return DEFAULT_EDITOR_SCHEME;
    }


} public class IconResources {

    private static Pixbuf icon = loadIcon();

    private static Pixbuf loadIcon(){
        try {
            BufferedInputStream bis = new BufferedInputStream(IconResources.class.getResourceAsStream("/lingua/resources/icon.svg"));
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            byte[] buf = new byte[512];
            int read = 0;
            while ((read = bis.read(buf)) > -1) {
                buffer.write(buf, 0, read);
            }
            bis.close();
            buffer.flush();
            byte[] bytes = buffer.toByteArray();
            buffer.close();
            return new Pixbuf(bytes);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Pixbuf getIcon(){
        return icon;
    }
} public class RunAction extends Action{
    private static RunAction instance = null;

    public static RunAction getInstance(){
        if(instance == null){
            instance = new RunAction();
        }
        return instance;
    }


    private RunAction() {
        super("RunAction", StringResources.getInstance().getString("run"), StringResources.getInstance().getString("tooltip_run"), ActionIcon.MEDIA_PLAYBACK_START, new Activate() {

            public void onActivate(Action source) {
                MainWindow.getInstance().run();
            }
        });
        setAccelerator(MainWindow.getAcceleratorGroup(), Keyval.F5, ModifierType.NONE);
    }

} public class StopAction extends Action{
    private static StopAction instance = null;

    public static StopAction getInstance(){
        if(instance == null){
            instance = new StopAction();
        }
        return instance;
    }


    private StopAction() {
        super("StopAction", StringResources.getInstance().getString("stop"), StringResources.getInstance().getString("tooltip_stop"), ActionIcon.MEDIA_PLAYBACK_STOP, new Activate() {

            public void onActivate(Action source) {
                MainWindow.getInstance().stop();
            }
        });
        setAccelerator(MainWindow.getAcceleratorGroup(), Keyval.F7, ModifierType.NONE);
        setSensitive(false);
    }

} public class ToggleStepByStepAction extends ToggleAction{

    private static ToggleStepByStepAction instance = null;

    public static ToggleStepByStepAction getInstance(){
        if(instance == null){
            instance = new ToggleStepByStepAction();
        }
        return instance;
    }


    private ToggleStepByStepAction() {
        super("ToggleStepByStepAction", StringResources.getInstance().getString("run_step_by_step"), StringResources.getInstance().getString("tooltip_run_step_by_step"), Stock.MEDIA_NEXT, new StepByStepActionToggled());
        setAccelerator(MainWindow.getAcceleratorGroup(), Keyval.F8, ModifierType.NONE);
    }

} public class ToggleUseInputFileAction extends ToggleAction{

    private static ToggleUseInputFileAction instance = null;

    public static ToggleUseInputFileAction getInstance(){
        if(instance == null){
            instance = new ToggleUseInputFileAction();
        }
        return instance;
    }


    private ToggleUseInputFileAction() {
        super("ToggleUseInputFileAction", StringResources.getInstance().getString("use_input_file"), StringResources.getInstance().getString("tooltip_use_input_file"), Stock.FILE);
        setAccelerator(MainWindow.getAcceleratorGroup(), Keyval.F9, ModifierType.NONE);
    }

} public class DialogManager {

    public static boolean verifyStopInterpreter() {
        InterpreterStillRunningDialog dlg = new InterpreterStillRunningDialog();
        ResponseType response = dlg.run();
        dlg.hide();
        if (response == ResponseType.YES) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean handleModifiedBuffer(boolean isInputFileBuffer, String filename, BufferSaver dc) {
        FileModifiedMessageDialog dlg = new FileModifiedMessageDialog(isInputFileBuffer, filename);
        ResponseType response = dlg.run();
        dlg.hide();
        if (response == ResponseType.YES) { // The user selected to save the changes.
            return dc.saveFile(false);
        } else if (response == ResponseType.NO) {
            return true; // The user selected not to save the changes.
        }else{
            return false; // The user canceled;
        }
    }

    public static String showSaveDialog(SaveDialog saveDialog, File initialFile, String initialFileName) {
        saveDialog.setFilename(initialFileName, initialFile == null ? null : initialFile.getParent());
        ResponseType response = saveDialog.run();
        saveDialog.hide();
        String fname = saveDialog.getFilename();
        if ((response == ResponseType.OK) &&(fname!=null)){
            FileFilterWithExtension f = saveDialog.getFilter();
            String extension = f.getExtension();
            if(!fname.endsWith(extension)){
                fname += extension;
            }
            File target = new File(fname);
            if (target.exists()) {
                if (confirmOverwriteFile(target)) {
                    return target.getAbsolutePath();
                } else {
                    return null;
                }
            } else {
                return target.getAbsolutePath();
            }
        }
        return null;
    }

    public static String showExportToHTMLDialog(File initialFile, String initialFileName) {
        ExportToHTMLDialog saveDialog = ExportToHTMLDialog.getInstance();
        if(initialFileName.endsWith(".gls")){
            initialFileName = initialFileName.substring(0, initialFileName.length()-4);
            initialFileName = initialFileName.concat(".html");
        }
        saveDialog.setFilename(initialFileName, initialFile == null ? null : initialFile.getParent());
        ResponseType response = saveDialog.run();
        saveDialog.hide();
        String fname = saveDialog.getFilename();
        if ((response == ResponseType.OK) &&(fname!=null)){
            File target = new File(fname);
            if (target.exists()) {
                if (DialogManager.confirmOverwriteFile(target)) {
                    return target.getAbsolutePath();
                } else {
                    return null;
                }
            } else {
                return target.getAbsolutePath();
            }
        }
        return null;
    }

    public static boolean confirmOverwriteFile(File f) {
        FileExistsMessageDialog dlg = new FileExistsMessageDialog(f.getAbsolutePath());
        ResponseType response = dlg.run();
        dlg.hide();
        if (response == ResponseType.YES) {
            return true;
        } else {
            return false;
        }
    }

    public static String showOpenDialog(FileChooserDialog openDialog) {
        ResponseType response = openDialog.run();
        openDialog.hide();
        if (response == ResponseType.OK) {
            return openDialog.getFilename();
        }
        return null;
    }

}
import glossa.interpreter.Interpreter;
import glossa.interpreter.InterpreterListener;
import glossa.interpreter.symboltable.SymbolTable;
import lingua.resources.StringResources;
import lingua.ui.gtk.main_window.menus.MenuBar;
import lingua.ui.gtk.main_window.toolbars.MainToolbar;
import lingua.ui.gtk.main_window.widgets.BottomPane;
import lingua.ui.gtk.main_window.widgets.EditorContainer;
import lingua.ui.gtk.main_window.widgets.MainWindowStatusbar;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import lingua.preferences.Preferences;
import lingua.resources.IconResources;
import lingua.ui.gtk.main_window.actions.RunAction;
import lingua.ui.gtk.main_window.actions.StopAction;
import lingua.ui.gtk.main_window.actions.ToggleStepByStepAction;
import lingua.ui.gtk.main_window.actions.ToggleUseInputFileAction;
import lingua.ui.gtk.main_window.dialogs.io.DialogManager;
import lingua.ui.gtk.main_window.widgets.*;
import org.gnome.gdk.Event;
import org.gnome.gtk.AcceleratorGroup;
import org.gnome.gtk.Box;
import org.gnome.gtk.Gtk;
import org.gnome.gtk.Orientation;
import org.gnome.gtk.Paned;
import org.gnome.gtk.TextIter;
import org.gnome.gtk.Toolbar;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;
/*
 *  The MIT License
 * 
 *  Copyright 2012 Georgios Migdos <cyberpython@gmail.com>.
 * 
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 * 
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 * 
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *  THE SOFTWARE.
 */
package lingua.ui.gtk.main_window;


/**
 *
 * @author Georgios Migdos <cyberpython@gmail.com>
 */
public class MainWindow extends Window implements InterpreterListener{
    private static MainWindow instance;
    private final Box mainContainer;
    private final BottomPane bottomPane;
    private final SidePane sidePane;
    private final MainWindowStatusbar statusBar;
    private final MenuBar mainMenubar;
    private final Toolbar mainToolbar;
    private final EditorContainer editorContainer;