package ckelling.baukasten;

import java.awt.*;

/**
 * Editor_PropertiesEditableMemory.java
 *
 * Fenster, um die besonderen zusätzlichen Eigenschaften eines
 * EditableMemory/TagMemory anzugeben:
 * Adreßraum, Bitbreite, Breite/Höhe der Bildschirmdarstellung in Zellen etc.
 *
 *	@author		Carsten Kelling
 *	@version	1.0.0, 29.06.97
 */
public class Editor_PropertiesEditableMemory extends Frame {
	private Editor 								parent_editor;
	private Editor_PropertiesRechnerKomponente	parent;


	public Editor_PropertiesEditableMemory(Editor_PropertiesRechnerKomponente parent, Editor parent_editor) {
		this.parent_editor = parent_editor;
		this.parent = parent;

		//{{INIT_CONTROLS
		GridBagLayout gridBagLayout;
		gridBagLayout = new GridBagLayout();
		setLayout(gridBagLayout);
		addNotify();
		resize(insets().left + insets().right + 282,insets().top + insets().bottom + 397);
		setFont(new Font("Helvetica", Font.PLAIN, 12));
		setBackground(new Color(12632256));
		labelPanel = new java.awt.Panel();
		labelPanel.setLayout(new GridLayout(0,1,5,5));
		labelPanel.reshape(insets().left + 10,insets().top + 10,189,320);
		GridBagConstraints gbc;
		gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.weightx = 1.5;
		gbc.weighty = 1.0;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.insets = new Insets(10,10,10,10);
		gridBagLayout.setConstraints(labelPanel, gbc);
		add(labelPanel);
		widthLabel = new java.awt.Label("Breite in Zellen",Label.RIGHT);
		widthLabel.reshape(0,0,189,22);
		labelPanel.add(widthLabel);
		heightLabel = new java.awt.Label("Höhe in Zellen",Label.RIGHT);
		heightLabel.reshape(0,27,189,22);
		labelPanel.add(heightLabel);
		cacheSizeLabel = new java.awt.Label("Wörter im Adreßraum",Label.RIGHT);
		cacheSizeLabel.reshape(0,54,189,22);
		cacheSizeLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
		labelPanel.add(cacheSizeLabel);
		lineSizeLabel = new java.awt.Label("Größe der 'lines'",Label.RIGHT);
		lineSizeLabel.reshape(0,81,189,22);
		lineSizeLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
		labelPanel.add(lineSizeLabel);
		bitWidthLabel = new java.awt.Label("Datenbreite (Bits)",Label.RIGHT);
		bitWidthLabel.reshape(0,108,189,22);
		labelPanel.add(bitWidthLabel);
		associativityLabel = new java.awt.Label("Assoziativität",Label.RIGHT);
		associativityLabel.reshape(0,135,189,22);
		associativityLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
		labelPanel.add(associativityLabel);
		writeModeLabel = new java.awt.Label("Schreibmodus",Label.RIGHT);
		writeModeLabel.reshape(0,162,189,22);
		writeModeLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
		labelPanel.add(writeModeLabel);
		replaceModeLabel = new java.awt.Label("Ersetzungsstrategie",Label.RIGHT);
		replaceModeLabel.reshape(0,189,189,22);
		replaceModeLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
		labelPanel.add(replaceModeLabel);
		programLabel = new java.awt.Label("Geladenes Programm",Label.RIGHT);
		programLabel.reshape(0,216,189,22);
		labelPanel.add(programLabel);
		editableLabel = new java.awt.Label("Editierbar",Label.RIGHT);
		editableLabel.reshape(0,243,189,22);
		labelPanel.add(editableLabel);
		opcodeLabel = new java.awt.Label("Opcodes anzeigen",Label.RIGHT);
		opcodeLabel.reshape(0,270,189,22);
		labelPanel.add(opcodeLabel);
		breakpointLabel = new java.awt.Label("Breakpoints zulassen",Label.RIGHT);
		breakpointLabel.reshape(0,297,189,22);
		labelPanel.add(breakpointLabel);
		choicePanel = new java.awt.Panel();
		choicePanel.setLayout(new GridLayout(0,1,5,5));
		choicePanel.reshape(insets().left + 209,insets().top + 14,62,320);
		gbc = new GridBagConstraints();
		gbc.gridx = 1;
		gbc.gridy = 0;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.insets = new Insets(14,0,6,10);
		gridBagLayout.setConstraints(choicePanel, gbc);
		add(choicePanel);
		widthChoice = new java.awt.Choice();
		widthChoice.addItem("1");
		widthChoice.addItem("2");
		widthChoice.addItem("4");
		widthChoice.addItem("8");
		try {
			widthChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		widthChoice.reshape(0,0,62,23);
		widthChoice.setBackground(new Color(16777215));
		choicePanel.add(widthChoice);
		heightChoice = new java.awt.Choice();
		heightChoice.addItem("4");
		heightChoice.addItem("8");
		try {
			heightChoice.select(1);
		} catch (IllegalArgumentException e) {
		}
		heightChoice.reshape(0,27,62,23);
		heightChoice.setBackground(new Color(16777215));
		choicePanel.add(heightChoice);
		cacheSizeChoice = new java.awt.Choice();
		cacheSizeChoice.addItem("8");
		cacheSizeChoice.addItem("16");
		cacheSizeChoice.addItem("32");
		cacheSizeChoice.addItem("256");
		try {
			cacheSizeChoice.select(3);
		} catch (IllegalArgumentException e) {
		}
		cacheSizeChoice.reshape(0,54,62,23);
		cacheSizeChoice.setBackground(new Color(16777215));
		choicePanel.add(cacheSizeChoice);
		lineSizeChoice = new java.awt.Choice();
		lineSizeChoice.addItem("1");
		lineSizeChoice.addItem("2");
		lineSizeChoice.addItem("4");
		try {
			lineSizeChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		lineSizeChoice.reshape(0,81,62,23);
		lineSizeChoice.setBackground(new Color(16777215));
		choicePanel.add(lineSizeChoice);
		bitWidthChoice = new java.awt.Choice();
		bitWidthChoice.addItem("8");
		bitWidthChoice.addItem("16");
		bitWidthChoice.addItem("32");
		try {
			bitWidthChoice.select(1);
		} catch (IllegalArgumentException e) {
		}
		bitWidthChoice.reshape(0,108,62,23);
		bitWidthChoice.setBackground(new Color(16777215));
		choicePanel.add(bitWidthChoice);
		associativityChoice = new java.awt.Choice();
		associativityChoice.addItem("direct mapped");
		associativityChoice.addItem("zweifach");
		associativityChoice.addItem("vierfach");
		associativityChoice.addItem("voll");
		try {
			associativityChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		associativityChoice.reshape(0,135,62,23);
		associativityChoice.setBackground(new Color(16777215));
		choicePanel.add(associativityChoice);
		associativityChoice.disable();
		writeModeChoice = new java.awt.Choice();
		writeModeChoice.addItem("write through");
		writeModeChoice.addItem("write back");
		try {
			writeModeChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		writeModeChoice.reshape(0,162,62,23);
		writeModeChoice.setBackground(new Color(16777215));
		choicePanel.add(writeModeChoice);
		writeModeChoice.disable();
		replaceModeChoice = new java.awt.Choice();
		replaceModeChoice.addItem("zufällig");
		replaceModeChoice.addItem("least recently used");
		try {
			replaceModeChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		replaceModeChoice.reshape(0,189,62,23);
		replaceModeChoice.setBackground(new Color(16777215));
		choicePanel.add(replaceModeChoice);
		replaceModeChoice.disable();
		programChoice = new java.awt.Choice();
		programChoice.addItem("Zero");
		programChoice.addItem("Address");
		programChoice.addItem("3Address");
		programChoice.addItem("VNR_LoadAbs");
		programChoice.addItem("VNR_LoadStore");
		programChoice.addItem("VNR_Calculate");
		programChoice.addItem("VNR_Jump");
		programChoice.addItem("AllCommands");
		programChoice.addItem("LoadStore");
		programChoice.addItem("LoadStore2");
		programChoice.addItem("Power");
		programChoice.addItem("CacheTest");
		programChoice.addItem("CacheTest2");
		programChoice.addItem("ReplaceTest");
		programChoice.addItem("BubbleSort");
		programChoice.addItem("MIPS_Instructions");
		programChoice.addItem("MIPS_Single");
		programChoice.addItem("MIPS_Random");
		try {
			programChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		programChoice.reshape(0,216,62,23);
		programChoice.setBackground(new Color(16777215));
		choicePanel.add(programChoice);
        programChoice.enable();
		editableChoice = new java.awt.Choice();
		editableChoice.addItem("Ja");
		editableChoice.addItem("Nein");
		try {
			editableChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		editableChoice.reshape(0,243,62,23);
		editableChoice.setBackground(new Color(16777215));
		choicePanel.add(editableChoice);
        editableChoice.enable();
		opcodeChoice = new java.awt.Choice();
		opcodeChoice.addItem("Ja");
		opcodeChoice.addItem("Nein");
		try {
			opcodeChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		opcodeChoice.reshape(0,270,62,23);
		opcodeChoice.setBackground(new Color(16777215));
		choicePanel.add(opcodeChoice);
        opcodeChoice.enable();
		breakpointChoice = new java.awt.Choice();
		breakpointChoice.addItem("Ja");
		breakpointChoice.addItem("Nein");
		try {
			breakpointChoice.select(0);
		} catch (IllegalArgumentException e) {
		}
		breakpointChoice.reshape(0,297,62,23);
		breakpointChoice.setBackground(new Color(16777215));
		choicePanel.add(breakpointChoice);
        breakpointChoice.enable();
		buttonPanel = new java.awt.Panel();
		buttonPanel.setLayout(new GridLayout(1,0,20,0));
		buttonPanel.reshape(insets().left + 10,insets().top + 356,261,23);
		gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 1;
		gbc.gridwidth = 2;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.insets = new Insets(10,10,10,10);
		gridBagLayout.setConstraints(buttonPanel, gbc);
		add(buttonPanel);
		buttonOK = new java.awt.Button("OK");
		buttonOK.reshape(0,0,120,23);
		buttonPanel.add(buttonOK);
		buttonCancel = new java.awt.Button("Abbrechen");
		buttonCancel.reshape(140,0,120,23);
		buttonPanel.add(buttonCancel);
		setTitle("Untitled");
		//}}

		//{{INIT_MENUS
		//}}
	}

	public Editor_PropertiesEditableMemory(String title, Editor_PropertiesRechnerKomponente parent, Editor parent_editor) {
	    this(parent, parent_editor);
	    setTitle(title);
	}

    public synchronized void show() {
    	move(50, 50);
    	super.show();
    }

	public boolean handleEvent(Event event) {
    	if (event.id == Event.WINDOW_DESTROY) {
            hide();         // hide the Frame
            parent.show();
            return true;
    	}
    	if ( (event.target == buttonCancel) && (event.id == Event.ACTION_EVENT) ) {
            hide();         // hide the Frame
            parent.show();
            return true;
    	}
    	if ( (event.target == buttonOK) && (event.id == Event.ACTION_EVENT) ) {
            hide();         // hide the Frame
            parent.show();
            return true;
    	}
		return super.handleEvent(event);
	}

	//{{DECLARE_CONTROLS
	java.awt.Panel labelPanel;
	java.awt.Label widthLabel;
	java.awt.Label heightLabel;
	java.awt.Label cacheSizeLabel;
	java.awt.Label lineSizeLabel;
	java.awt.Label bitWidthLabel;
	java.awt.Label associativityLabel;
	java.awt.Label writeModeLabel;
	java.awt.Label replaceModeLabel;
	java.awt.Label programLabel;
	java.awt.Label editableLabel;
	java.awt.Label opcodeLabel;
	java.awt.Label breakpointLabel;
	java.awt.Panel choicePanel;
	java.awt.Choice widthChoice;
	java.awt.Choice heightChoice;
	java.awt.Choice cacheSizeChoice;
	java.awt.Choice lineSizeChoice;
	java.awt.Choice bitWidthChoice;
	java.awt.Choice associativityChoice;
	java.awt.Choice writeModeChoice;
	java.awt.Choice replaceModeChoice;
	java.awt.Choice programChoice;
	java.awt.Choice editableChoice;
	java.awt.Choice opcodeChoice;
	java.awt.Choice breakpointChoice;
	java.awt.Panel buttonPanel;
	java.awt.Button buttonOK;
	java.awt.Button buttonCancel;
	//}}

	//{{DECLARE_MENUS
	//}}
}
