// 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();
//         }
//         
//     }
// 
// }


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;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.z64sim.memory.window;


/**
 * Top component which displays something.
 */
@ConvertAsProperties(
        dtd = "-//org.z64sim.memory//Memory//EN",
        autostore = false
)
@TopComponent.Description(
        preferredID = "MemoryTopComponent",
        iconBase = "org/z64sim/memory/window/memory.png",
        persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
)
@TopComponent.Registration(mode = "properties", openAtStartup = true)
@ActionID(category = "Window", id = "org.z64sim.memory.MemoryTopComponent")
@ActionReference(path = "Menu/Window", position = 3)
@TopComponent.OpenActionRegistration(
        displayName = "#CTL_MemoryAction",
        preferredID = "MemoryTopComponent"
)
@Messages({
    "CTL_MemoryAction=Memory",
    "CTL_MemoryTopComponent=Memory View",
    "HINT_MemoryTopComponent=This window allows to explore/modify memory content"
})
public final class MemoryTopComponent extends TopComponent {

    public MemoryTopComponent() {
        initComponents();
        setName(Bundle.CTL_MemoryTopComponent());
        setToolTipText(Bundle.HINT_MemoryTopComponent());
// 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/memory/window/MemoryTopComponent.java
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;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.z64sim.memory.window;


/**
 * Top component which displays something.
 */
@ConvertAsProperties(
        dtd = "-//org.z64sim.memory//Memory//EN",
        autostore = false
)
@TopComponent.Description(
        preferredID = "MemoryTopComponent",
        iconBase = "org/z64sim/memory/window/memory.png",
        persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
)
@TopComponent.Registration(mode = "properties", openAtStartup = true)
@ActionID(category = "Window", id = "org.z64sim.memory.MemoryTopComponent")
@ActionReference(path = "Menu/Window", position = 3)
@TopComponent.OpenActionRegistration(
        displayName = "#CTL_MemoryAction",
        preferredID = "MemoryTopComponent"
)
@Messages({
    "CTL_MemoryAction=Memory",
    "CTL_MemoryTopComponent=Memory View",
    "HINT_MemoryTopComponent=This window allows to explore/modify memory content"
})
public final class MemoryTopComponent extends TopComponent {

    public MemoryTopComponent() {
        initComponents();
        setName(Bundle.CTL_MemoryTopComponent());
        setToolTipText(Bundle.HINT_MemoryTopComponent());
        Memory.setWindow(this);