// Path: simulator/src/org/z64sim/memory/Memory.java
// public class Memory {
// 
//     private static MemoryTopComponent window = null;
//     //private static Program program = null;
//     private static Program program = new Program(); // aggiunto per evitare nullPointerException
// 
//     // This class cannot be instantiated
//     private Memory() {
//     }
// 
//     public static Program getProgram() {
//         return program;
//     }
// 
//     public static void setProgram(Program program) {
//         Memory.program = program;
//     }
//     
//     public static void setWindow(MemoryTopComponent w) {
//         Memory.window = w;
//     }
// 
//     public static MemoryTopComponent getWindow() {
//         return Memory.window;
//     }
// 
//     public static void redrawMemory() {
//         if (Memory.window != null) {
//             Memory.window.memoryTable.setModel(new MemoryTableModel());
//             int _startRow = (int) (Memory.program._start / 8);
// 
//             // Select the row corresponding to the entry point
//             Memory.window.memoryTable.setRowSelectionInterval(_startRow, _startRow);
// 
//             // Scroll to that row
//             Memory.window.memoryTable.scrollRectToVisible(new Rectangle(Memory.window.memoryTable.getCellRect(_startRow, 0, true)));
// 
//             // Show the panel
//             Memory.window.requestVisible();
//         }
//         
//     }
// 
// }
// 
// Path: simulator/src/org/z64sim/simulator/Simulator.java
// public class Simulator {
//     
//     private static SimulatorMulticycleTopComponent multicycleWindow = null;
//     
//     private Simulator() {}
//     
//     public static synchronized void setMulticycle(SimulatorMulticycleTopComponent mc)  {
//         Simulator.multicycleWindow = mc;
//     }
//     
//     public static synchronized void resetMulticycle(SimulatorMulticycleTopComponent mc)  {
//         if(Simulator.multicycleWindow == mc)
//             Simulator.multicycleWindow = null;
//     }
//     
//     public static boolean activate() {
//         if(multicycleWindow != null) {
//             multicycleWindow.requestFocusInWindow();
//             multicycleWindow.checkEnabled();
//             return true;
//         }
//         return false;
//     }
//     
// }


import javax.swing.JOptionPane;
import org.jdesktop.beansbinding.Converter;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
import org.z64sim.memory.Memory;
import org.z64sim.simulator.Simulator;
    // End of variables declaration//GEN-END:variables

    @Override
    public void componentOpened() {
        checkEnabled();

        // Register this window as the current Multicycle Simulator
        Simulator.setMulticycle(this);
    }

    @Override
    public void componentClosed() {
        // Deregister as the current Multicycle Simulator
        Simulator.resetMulticycle(this);
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }

    public void checkEnabled() {
        // Check whether there is an assembled file. If not, disable 'run' buttons
// Path: simulator/src/org/z64sim/memory/Memory.java
// public class Memory {
// 
//     private static MemoryTopComponent window = null;
//     //private static Program program = null;
//     private static Program program = new Program(); // aggiunto per evitare nullPointerException
// 
//     // This class cannot be instantiated
//     private Memory() {
//     }
// 
//     public static Program getProgram() {
//         return program;
//     }
// 
//     public static void setProgram(Program program) {
//         Memory.program = program;
//     }
//     
//     public static void setWindow(MemoryTopComponent w) {
//         Memory.window = w;
//     }
// 
//     public static MemoryTopComponent getWindow() {
//         return Memory.window;
//     }
// 
//     public static void redrawMemory() {
//         if (Memory.window != null) {
//             Memory.window.memoryTable.setModel(new MemoryTableModel());
//             int _startRow = (int) (Memory.program._start / 8);
// 
//             // Select the row corresponding to the entry point
//             Memory.window.memoryTable.setRowSelectionInterval(_startRow, _startRow);
// 
//             // Scroll to that row
//             Memory.window.memoryTable.scrollRectToVisible(new Rectangle(Memory.window.memoryTable.getCellRect(_startRow, 0, true)));
// 
//             // Show the panel
//             Memory.window.requestVisible();
//         }
//         
//     }
// 
// }
// 
// Path: simulator/src/org/z64sim/simulator/Simulator.java
// public class Simulator {
//     
//     private static SimulatorMulticycleTopComponent multicycleWindow = null;
//     
//     private Simulator() {}
//     
//     public static synchronized void setMulticycle(SimulatorMulticycleTopComponent mc)  {
//         Simulator.multicycleWindow = mc;
//     }
//     
//     public static synchronized void resetMulticycle(SimulatorMulticycleTopComponent mc)  {
//         if(Simulator.multicycleWindow == mc)
//             Simulator.multicycleWindow = null;
//     }
//     
//     public static boolean activate() {
//         if(multicycleWindow != null) {
//             multicycleWindow.requestFocusInWindow();
//             multicycleWindow.checkEnabled();
//             return true;
//         }
//         return false;
//     }
//     
// }


// Path: simulator/src/org/z64sim/simulator/multicycle/SimulatorMulticycleTopComponent.java
import javax.swing.JOptionPane;
import org.jdesktop.beansbinding.Converter;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
import org.z64sim.memory.Memory;
import org.z64sim.simulator.Simulator;

    // End of variables declaration//GEN-END:variables

    @Override
    public void componentOpened() {
        checkEnabled();

        // Register this window as the current Multicycle Simulator
        Simulator.setMulticycle(this);
    }

    @Override
    public void componentClosed() {
        // Deregister as the current Multicycle Simulator
        Simulator.resetMulticycle(this);
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }

    public void checkEnabled() {
        // Check whether there is an assembled file. If not, disable 'run' buttons
        if (Memory.getProgram() == null || Memory.getProgram()._start == -1) { // Entry point can never be zero in a real program