use of sw_emulator.swing.main.Project in project jc64 by ice00.
the class JDisassemblerFrame method projectNew.
/**
* Project new user action
*/
private void projectNew() {
if (project != null && !project.equals(savedProject)) {
int input = JOptionPane.showConfirmDialog(this, "Project not saved. Save it? (No=not save it)", "Information", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (input == JOptionPane.CANCEL_OPTION)
return;
else if (input == JOptionPane.OK_OPTION)
projectSave();
}
project = new Project();
savedProject = project.clone();
projectFile = null;
jProjectDialog.setUp(project);
jProjectDialog.setVisible(true);
setTitle("JC64dis (<new>)");
jPanelPerc.setPerc(-1);
if (project.file == null || "".equals(project.file)) {
project = null;
savedProject = null;
rSyntaxTextAreaSource.setText("");
rSyntaxTextAreaDis.setText("");
dataTableModelMemory.setData(null);
dataTableModelMemory.fireTableDataChanged();
} else {
dataTableModelMemory.setData(project.memory);
dataTableModelMemory.fireTableDataChanged();
execute(SOURCE_DISASS);
}
}
use of sw_emulator.swing.main.Project in project jc64 by ice00.
the class JDisassemblerFrame method projectMerge.
/**
* Collaborative merge of another user contribution
*/
private void projectMerge() {
if (project == null) {
JOptionPane.showMessageDialog(this, "You must be inside a project to merge it with another!", "Information", JOptionPane.WARNING_MESSAGE);
return;
}
int retVal = projectMergeFile.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File mergeFile = projectMergeFile.getSelectedFile();
Project mergeProject = new Project();
if (!FileManager.instance.readProjectFile(mergeFile, mergeProject)) {
JOptionPane.showMessageDialog(this, "Error reading project file", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// test that the projects are of the same
if ((Arrays.hashCode(mergeProject.inB) != Arrays.hashCode(project.inB))) {
JOptionPane.showMessageDialog(this, "Byte data of the projects are different: they are not of the same source", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (project.fileType == FileType.CRT && project.chip != mergeProject.chip) {
JOptionPane.showMessageDialog(this, "You are disassembe different chip inside a CRT image", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (MPR.hashCode(mergeProject.mpr) != MPR.hashCode(project.mpr)) {
JOptionPane.showMessageDialog(this, "Byte data of MPR in projects are different: they are not of the same source", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// take name/description from secondary only if not present in primary
if (project.name == null || "".equals(project.name))
project.name = mergeProject.name;
if (project.description == null || "".equals(project.description))
project.description = mergeProject.description;
// copy constant
for (int i = 0; i < Constant.COLS; i++) {
for (int j = 0; i < Constant.ROWS; j++) {
if (project.constant.table[i][j] == null || "".equals(project.constant.table[i][j]))
project.constant.table[i][j] = mergeProject.constant.table[i][j];
}
}
MemoryDasm memProject;
MemoryDasm memMerge;
// scan all memory locations
for (int i = 0; i < project.memory.length; i++) {
memProject = project.memory[i];
memMerge = mergeProject.memory[i];
// apply secondary information if primary are not defined
if (memProject.userBlockComment == null || "".equals(memProject.userBlockComment))
memProject.userBlockComment = memMerge.userBlockComment;
if (memProject.userComment == null || "".equals(memProject.userComment))
memProject.userComment = memMerge.userComment;
if (memProject.userLocation == null || "".equals(memProject.userLocation))
memProject.userLocation = memMerge.userLocation;
if (memProject.isInside) {
if (!memProject.isCode && !memProject.isData && !memProject.isGarbage) {
memProject.isCode = memMerge.isCode;
memProject.isData = memMerge.isData;
memProject.isGarbage = memMerge.isGarbage;
}
if (memProject.related == -1) {
memProject.related = memMerge.related;
memProject.type = memMerge.type;
}
if (memProject.dataType != DataType.NONE)
memProject.dataType = memMerge.dataType;
if (memProject.index == -1)
memProject.index = memMerge.index;
}
}
// check relocate
if (project.relocates == null)
project.relocates = mergeProject.relocates;
// check patch
if (project.patches == null)
project.patches = mergeProject.patches;
else if (mergeProject.patches != null) {
// copy the value in the list
Patch[] patches2 = new Patch[project.patches.length + mergeProject.patches.length];
System.arraycopy(project.patches, 0, patches2, 0, project.patches.length);
for (int i = 0; i < mergeProject.patches.length; i++) {
patches2[project.patches.length + i] = mergeProject.patches[i];
}
project.patches = patches2;
}
dataTableModelMemory.fireTableDataChanged();
}
}
use of sw_emulator.swing.main.Project in project jc64 by ice00.
the class JDisassemblerFrame method projectOpen.
/**
* Project open user action
*/
private void projectOpen() {
if (project != null && !project.equals(savedProject)) {
int input = JOptionPane.showConfirmDialog(this, "Project not saved. Save it? (No=not save it)", "Information", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (input == JOptionPane.CANCEL_OPTION)
return;
else if (input == JOptionPane.OK_OPTION)
projectSave();
}
int retVal = projectChooserFile.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
projectFile = projectChooserFile.getSelectedFile();
m_prefNode.put(LAST_DIR_PROJECT, projectFile.getPath());
project = new Project();
setTitle("JC64dis (" + projectFile.getName() + ")");
if (!FileManager.instance.readProjectFile(projectFile, project)) {
JOptionPane.showMessageDialog(this, "Error reading project file", "Error", JOptionPane.ERROR_MESSAGE);
} else {
if (option.pedantic)
JOptionPane.showMessageDialog(this, "File read", "Information", JOptionPane.INFORMATION_MESSAGE);
execute(SOURCE_DISASS);
}
savedProject = project.clone();
dataTableModelMemory.setData(project.memory);
dataTableModelMemory.fireTableDataChanged();
}
}
use of sw_emulator.swing.main.Project in project jc64 by ice00.
the class JDisassemblerFrame method recent.
/**
* Load a recent file
*
* @param pos the position i nrecent
*/
private void recent(int pos) {
if (project != null && !project.equals(savedProject)) {
int input = JOptionPane.showConfirmDialog(this, "Project not saved. Save it? (No=not save it)", "Information", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (input == JOptionPane.CANCEL_OPTION)
return;
else if (input == JOptionPane.OK_OPTION)
projectSave();
}
projectFile = new File(recentFile.get(pos));
project = new Project();
setTitle("JC64dis (" + projectFile.getName() + ")");
if (!FileManager.instance.readProjectFile(projectFile, project)) {
JOptionPane.showMessageDialog(this, "Error reading project file", "Error", JOptionPane.ERROR_MESSAGE);
} else {
if (option.pedantic)
JOptionPane.showMessageDialog(this, "File read", "Information", JOptionPane.INFORMATION_MESSAGE);
execute(SOURCE_DISASS);
}
savedProject = project.clone();
dataTableModelMemory.setData(project.memory);
dataTableModelMemory.fireTableDataChanged();
}
use of sw_emulator.swing.main.Project in project jc64 by ice00.
the class JDisassemblerFrame method undo.
/**
* Undo project at given index
*
* @param index the index
*/
private void undo(int index) {
String key = null;
switch(index) {
case 0:
key = jMenuItemUndo1.getText();
break;
case 1:
key = jMenuItemUndo2.getText();
break;
case 2:
key = jMenuItemUndo3.getText();
break;
case 3:
key = jMenuItemUndo4.getText();
break;
case 4:
key = jMenuItemUndo5.getText();
break;
case 5:
key = jMenuItemUndo6.getText();
break;
case 6:
key = jMenuItemUndo7.getText();
break;
case 7:
key = jMenuItemUndo8.getText();
break;
case 8:
key = jMenuItemUndo9.getText();
break;
}
Project search = undo.retrieve(key);
if (search != null) {
project = search;
dataTableModelMemory.setData(project.memory);
dataTableModelMemory.fireTableDataChanged();
if (option.forceCompilation)
disassembly(false);
}
}
Aggregations