mirror of https://github.com/rusefi/RomRaider.git
Almost back to normal
This commit is contained in:
parent
4c16c44c51
commit
fd092e84e5
|
@ -113,7 +113,6 @@ public class ECUEditor extends AbstractFrame {
|
|||
private TableToolBar tableToolBar;
|
||||
private final JPanel toolBarPanel = new JPanel();
|
||||
private OpenImageWorker openImageWorker;
|
||||
private CloseImageWorker closeImageWorker;
|
||||
private SetUserLevelWorker setUserLevelWorker;
|
||||
private LaunchLoggerWorker launchLoggerWorker;
|
||||
private final ImageIcon editorIcon = new ImageIcon(getClass().getResource(
|
||||
|
@ -389,10 +388,26 @@ public class ECUEditor extends AbstractFrame {
|
|||
}
|
||||
|
||||
public void closeImage() {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
closeImageWorker = new CloseImageWorker(getLastSelectedRom());
|
||||
closeImageWorker.addPropertyChangeListener(getStatusPanel());
|
||||
closeImageWorker.execute();
|
||||
Rom rom = getLastSelectedRom();
|
||||
ECUEditor editor = ECUEditorManager.getECUEditor();
|
||||
RomTreeRootNode imageRoot = editor.getImageRoot();
|
||||
|
||||
rom.clearData();
|
||||
rom.removeFromParent();
|
||||
rom = null;
|
||||
|
||||
if (imageRoot.getChildCount() > 0) {
|
||||
editor.setLastSelectedRom((Rom) imageRoot.getChildAt(0));
|
||||
} else {
|
||||
// no other images open
|
||||
editor.setLastSelectedRom(null);
|
||||
}
|
||||
|
||||
editor.refreshTableCompareMenus();
|
||||
editor.getStatusPanel().setStatus(ECUEditor.rb.getString("STATUSREADY"));
|
||||
editor.setCursor(null);
|
||||
editor.refreshUI();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
public void closeAllImages() {
|
||||
|
@ -590,9 +605,8 @@ class LaunchLoggerWorker extends SwingWorker<Void, Void> {
|
|||
}
|
||||
}
|
||||
|
||||
//Do we really need this? Cant be compute intensive
|
||||
class SetUserLevelWorker extends SwingWorker<Void, Void> {
|
||||
public SetUserLevelWorker() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
|
@ -622,45 +636,6 @@ class SetUserLevelWorker extends SwingWorker<Void, Void> {
|
|||
}
|
||||
}
|
||||
|
||||
class CloseImageWorker extends SwingWorker<Void, Void> {
|
||||
Rom rom;
|
||||
|
||||
public CloseImageWorker(Rom romToRemove) {
|
||||
this.rom = romToRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
ECUEditor editor = ECUEditorManager.getECUEditor();
|
||||
RomTreeRootNode imageRoot = editor.getImageRoot();
|
||||
|
||||
rom.clearData();
|
||||
rom.removeFromParent();
|
||||
rom = null;
|
||||
|
||||
if (imageRoot.getChildCount() > 0) {
|
||||
editor.setLastSelectedRom((Rom) imageRoot.getChildAt(0));
|
||||
} else {
|
||||
// no other images open
|
||||
editor.setLastSelectedRom(null);
|
||||
}
|
||||
|
||||
editor.refreshTableCompareMenus();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
ECUEditor editor = ECUEditorManager.getECUEditor();
|
||||
editor.getStatusPanel().setStatus(ECUEditor.rb.getString("STATUSREADY"));
|
||||
setProgress(0);
|
||||
editor.setCursor(null);
|
||||
editor.refreshUI();
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
|
||||
class OpenImageWorker extends SwingWorker<Void, Void> {
|
||||
private final File inputFile;
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ public class DataCell {
|
|||
|
||||
private void updateView() {
|
||||
if(view != null)
|
||||
view.repaint();
|
||||
view.drawCell();
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
|
|
|
@ -81,6 +81,8 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
|
|||
this.addMouseListener(this);
|
||||
|
||||
cell.setDataView(this);
|
||||
this.y = cell.getIndexInTable();
|
||||
this.setPreferredSize(getSettings().getCellSize());
|
||||
}
|
||||
|
||||
public DataCellView(DataCell cell, TableView view, int x, int y) {
|
||||
|
@ -88,12 +90,12 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
|
|||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.setPreferredSize(getSettings().getCellSize());
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
if(!tableView.getTable().isStaticDataTable() && this.isSelected != selected) {
|
||||
this.isSelected = selected;
|
||||
drawCell();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,13 +386,21 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
|
|||
// Hide and dispose all frames.
|
||||
for(TableTreeNode tableTreeNode : tableNodes) {
|
||||
TableFrame frame = tableTreeNode.getFrame();
|
||||
|
||||
if(frame != null) {
|
||||
frame.getTableView().setVisible(false);
|
||||
frame.setVisible(false);
|
||||
|
||||
try {
|
||||
frame.setClosed(true);
|
||||
} catch (PropertyVetoException e) {
|
||||
; // Do nothing.
|
||||
}
|
||||
frame.dispose();
|
||||
|
||||
frame.getTableView().setTable(null);
|
||||
frame.setTableView(null);
|
||||
}
|
||||
}
|
||||
|
||||
tableNodes.clear();
|
||||
|
|
|
@ -500,9 +500,6 @@ public abstract class Table implements Serializable {
|
|||
this.minCompare = minCompare;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setRevertPoint() {
|
||||
for (DataCell cell : data) {
|
||||
cell.setRevertPoint();
|
||||
|
@ -632,8 +629,6 @@ public abstract class Table implements Serializable {
|
|||
|
||||
public void setCurrentScale(Scale curScale) {
|
||||
this.curScale = curScale;
|
||||
|
||||
if(tableView!=null) tableView.repaint();
|
||||
}
|
||||
|
||||
public Settings getSettings()
|
||||
|
|
|
@ -43,6 +43,13 @@ public class Table1D extends Table {
|
|||
return axisParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentScale(Scale curScale) {
|
||||
this.curScale = curScale;
|
||||
|
||||
if(tableView!=null) tableView.drawTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] saveFile(byte[] binData) {
|
||||
return binData;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.awt.BorderLayout;
|
|||
import javax.swing.JLabel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.romraider.maps.Table.TableType;
|
||||
import com.romraider.util.NumberUtil;
|
||||
|
||||
public class Table1DView extends TableView {
|
||||
|
@ -34,6 +35,7 @@ public class Table1DView extends TableView {
|
|||
public Table1DView(Table1D table) {
|
||||
super(table);
|
||||
this.table = table;
|
||||
|
||||
populateTableVisual();
|
||||
}
|
||||
|
||||
|
@ -49,9 +51,12 @@ public class Table1DView extends TableView {
|
|||
|
||||
@Override
|
||||
public void populateTableVisual() {
|
||||
super.populateTableVisual();
|
||||
|
||||
//Only populate the rest if we aren't an axis
|
||||
if(table.getType() == TableType.TABLE_1D) {
|
||||
centerLayout.setRows(1);
|
||||
centerLayout.setColumns(table.getDataSize());
|
||||
super.populateTableVisual();
|
||||
|
||||
// add to table
|
||||
for (int i = 0; i < table.getDataSize(); i++) {
|
||||
|
@ -74,10 +79,11 @@ public class Table1DView extends TableView {
|
|||
|
||||
if(presetPanel != null) presetPanel.populatePanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " (1D)";
|
||||
return table.toString() + " View";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -164,7 +164,7 @@ public class Table2D extends Table {
|
|||
}
|
||||
this.curScale = curScale;
|
||||
|
||||
if(tableView != null) tableView.repaint();
|
||||
if(tableView != null) tableView.drawTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,9 +87,10 @@ public class Table2DView extends TableView {
|
|||
|
||||
@Override
|
||||
public void populateTableVisual(){
|
||||
super.populateTableVisual();
|
||||
|
||||
centerLayout.setRows(2);
|
||||
centerLayout.setColumns(table.getDataSize());
|
||||
super.populateTableVisual();
|
||||
|
||||
// add to table
|
||||
for (int i = 0; i < axis.getTable().getDataSize(); i++) {
|
||||
|
|
|
@ -328,7 +328,9 @@ public class Table3D extends Table {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.curScale = curScale;
|
||||
if(tableView!=null) tableView.drawTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -85,7 +85,7 @@ public class Table3DView extends TableView {
|
|||
for(DataCellView[] column : data) {
|
||||
for(DataCellView cell : column) {
|
||||
if(null != cell) {
|
||||
cell.repaint();
|
||||
cell.drawCell();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,30 +99,22 @@ public class Table3DView extends TableView {
|
|||
}
|
||||
|
||||
@Override
|
||||
//TODO
|
||||
public void populateTableVisual() {
|
||||
// fill first empty cell
|
||||
centerPanel.add(new JLabel());
|
||||
centerLayout.setColumns(xAxis.getTable().getDataSize());
|
||||
centerLayout.setRows(yAxis.getTable().getDataSize());
|
||||
centerLayout.setColumns(table.getSizeX()+1);
|
||||
centerLayout.setRows(table.getSizeY()+1);
|
||||
|
||||
// temporarily remove lock
|
||||
boolean tempLock = table.locked;
|
||||
table.locked = false;
|
||||
|
||||
// populate axes
|
||||
try {
|
||||
xAxis.populateTableVisual();
|
||||
yAxis.populateTableVisual();
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
for (int x = 0; x < xAxis.getTable().getDataSize(); x++) {
|
||||
centerPanel.add(xAxis.getDataCell(x));
|
||||
}
|
||||
|
||||
|
||||
data = new DataCellView[xAxis.getTable().getDataSize()][yAxis.getTable().getDataSize()];
|
||||
data = new DataCellView[table.getSizeX()][table.getSizeY()];
|
||||
|
||||
int iMax = table.getSwapXY() ? xAxis.getTable().getDataSize() : yAxis.getTable().getDataSize();
|
||||
int jMax = table.getSwapXY() ? yAxis.getTable().getDataSize() : xAxis.getTable().getDataSize();
|
||||
|
@ -142,7 +134,6 @@ public class Table3DView extends TableView {
|
|||
data[x][y].setForeground(Color.GRAY);
|
||||
}
|
||||
|
||||
|
||||
data[x][y] = new DataCellView(table.get3dData()[x][y], this, x,y);
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +187,7 @@ public class Table3DView extends TableView {
|
|||
xAxisLabel.setBorder(new EmptyBorder(2, 4, 2, 4));
|
||||
|
||||
if(presetPanel != null) presetPanel.populatePanel();
|
||||
drawTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -494,6 +494,10 @@ public abstract class TableView extends JPanel implements Serializable {
|
|||
return table.getTableFrame();
|
||||
}
|
||||
|
||||
public void setTable(Table t) {
|
||||
this.table = t;
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
@ -567,11 +571,6 @@ public abstract class TableView extends JPanel implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void repaint() {
|
||||
drawTable();
|
||||
}
|
||||
|
||||
public void startHighlight(int x, int y) {
|
||||
this.highlightY = y;
|
||||
this.highlightX = x;
|
||||
|
@ -880,6 +879,10 @@ public abstract class TableView extends JPanel implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return table.getName();
|
||||
}
|
||||
|
||||
public static void showBadScalePopup(Table table, Scale scale) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new GridLayout(4, 1));
|
||||
|
|
|
@ -121,8 +121,9 @@ public class RomTree extends JTree implements MouseListener {
|
|||
v = new Table3DView((Table3D)node.getTable());
|
||||
else
|
||||
return;
|
||||
Rom rom = getRomNode(node);
|
||||
|
||||
f = new TableFrame("Title", v);
|
||||
f = new TableFrame(node.getTable().getName() + " | " + rom.getFileName(), v);
|
||||
}
|
||||
getEditor().displayTable(f);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener,
|
|||
private static final long serialVersionUID = -2651279694660392351L;
|
||||
private static final ResourceBundle rb = new ResourceUtil().getBundle(
|
||||
TableFrame.class.getName());
|
||||
private final TableView tableView;
|
||||
private TableView tableView;
|
||||
private TableMenuBar tableMenuBar = null;
|
||||
|
||||
public TableFrame(String title, TableView tableView) {
|
||||
|
@ -120,6 +120,10 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener,
|
|||
return tableView;
|
||||
}
|
||||
|
||||
public void setTableView(TableView v) {
|
||||
tableView = v;
|
||||
}
|
||||
|
||||
public ECUEditor getEditor() {
|
||||
return ECUEditorManager.getECUEditor();
|
||||
}
|
||||
|
|
|
@ -348,6 +348,9 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
}
|
||||
|
||||
public void updateTableToolBar(Table selectedTable) {
|
||||
//Select the parent Table always instead?
|
||||
//if(selectedTable instanceof Table1D)selectedTable = ((Table1D)selectedTable).getAxisParent();
|
||||
|
||||
if(selectedTable == null && this.selectedTable == null) {
|
||||
// Skip if the table is the same to avoid multiple updates
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue