mirror of https://github.com/rusefi/RomRaider.git
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@586 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
078cbe6fd8
commit
7a1d5b32ab
|
@ -47,6 +47,9 @@ import enginuity.logger.utec.impl.UtecTuningEntityImpl;
|
|||
import enginuity.swing.LookAndFeelManager;
|
||||
|
||||
public class NewGUI extends JFrame implements ActionListener, TreeSelectionListener, TuningEntityListener{
|
||||
|
||||
private String version = "v0.5.0 alpha 1";
|
||||
|
||||
private JPanel mainJPanel = new JPanel();
|
||||
|
||||
private JMenuBar jMenuBar = new JMenuBar();
|
||||
|
@ -55,7 +58,7 @@ public class NewGUI extends JFrame implements ActionListener, TreeSelectionListe
|
|||
private JSplitPane splitPane = new JSplitPane();
|
||||
private EDesktopPane rightDesktopPane = new EDesktopPane();
|
||||
|
||||
private ETreeNode rootNode = new ETreeNode("Enginuity", new TableMetaData(TableMetaData.RESERVED_ROOT,0.0,0.0,new Object[0],null, null,false,"", "", null));
|
||||
private ETreeNode rootNode = new ETreeNode("Enginuity", new TableMetaData(TableMetaData.RESERVED_ROOT,0.0,0.0,new Object[0],null, null,false,"", "", "", null));
|
||||
private ETree leftJTree = new ETree(rootNode);
|
||||
|
||||
private NewGUI(){
|
||||
|
@ -89,6 +92,10 @@ public class NewGUI extends JFrame implements ActionListener, TreeSelectionListe
|
|||
setIconImage( img );
|
||||
|
||||
|
||||
// Set frame title
|
||||
this.setTitle("Enginuity "+this.version);
|
||||
|
||||
|
||||
// Set main JFrame size
|
||||
this.setSize(800,600);
|
||||
|
||||
|
@ -189,5 +196,38 @@ public class NewGUI extends JFrame implements ActionListener, TreeSelectionListe
|
|||
this.add(theToolBar, BorderLayout.NORTH);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getMapChangeCount(TuningEntity tuningEntity, String tableGroup){
|
||||
JInternalFrame[] allFrames = this.rightDesktopPane.getAllFrames();
|
||||
|
||||
int number = 0;
|
||||
for(int i = 0 ; i < allFrames.length; i++){
|
||||
EInternalFrame eInternalFrame = (EInternalFrame)allFrames[i];
|
||||
|
||||
if(eInternalFrame.getTableMetaData().getTableGroup().equals(tableGroup)){
|
||||
if(eInternalFrame.dataChanged()){
|
||||
number++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return number;
|
||||
|
||||
}
|
||||
|
||||
public void saveMaps(TuningEntity tuningEntity, String tableGroup){
|
||||
JInternalFrame[] allFrames = this.rightDesktopPane.getAllFrames();
|
||||
|
||||
for(int i = 0 ; i < allFrames.length; i++){
|
||||
EInternalFrame eInternalFrame = (EInternalFrame)allFrames[i];
|
||||
|
||||
if(eInternalFrame.getTableMetaData().getTableGroup().equals(tableGroup)){
|
||||
if(eInternalFrame.dataChanged()){
|
||||
eInternalFrame.saveDataToParentTuningEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ public class TableMetaData {
|
|||
private boolean isInvertedColoring;
|
||||
private String tableName;
|
||||
private String tableIdentifier;
|
||||
private String tableGroup;
|
||||
private int dimensions;
|
||||
private TuningEntity parentTuningEntity;
|
||||
|
||||
|
||||
public TableMetaData(int dimensions, double minValue, double maxValue, Object[] ignoredValues, String[] columnLabels, String[] rowLabels, boolean isInvertedColoring, String tableName, String tableIdentifier, TuningEntity parentTuningEntity) {
|
||||
public TableMetaData(int dimensions, double minValue, double maxValue, Object[] ignoredValues, String[] columnLabels, String[] rowLabels, boolean isInvertedColoring, String tableName, String tableIdentifier, String tableGroup, TuningEntity parentTuningEntity) {
|
||||
this.dimensions = dimensions;
|
||||
this.maxValue = maxValue;
|
||||
this.minValue = minValue;
|
||||
|
@ -34,6 +35,7 @@ public class TableMetaData {
|
|||
this.isInvertedColoring = isInvertedColoring;
|
||||
this.tableName = tableName;
|
||||
this.tableIdentifier = tableIdentifier;
|
||||
this.tableGroup = tableGroup;
|
||||
this.parentTuningEntity = parentTuningEntity;
|
||||
|
||||
System.out.println("Min:"+this.minValue+ " Max:"+this.maxValue + " Name:"+this.tableName+ " Inv:"+this.isInvertedColoring);
|
||||
|
@ -78,4 +80,8 @@ public class TableMetaData {
|
|||
public TuningEntity getParentTuningEntity() {
|
||||
return parentTuningEntity;
|
||||
}
|
||||
|
||||
public String getTableGroup() {
|
||||
return tableGroup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class EInternalFrame extends JInternalFrame implements InternalFrameListe
|
|||
|
||||
private ETable eTable;
|
||||
private TableMetaData tableMetaData;
|
||||
|
||||
|
||||
public EInternalFrame(TableMetaData tableMetaData, Double[][] data, Dimension tableDimensions){
|
||||
super(tableMetaData.getTableName(), true, true, true, true);
|
||||
this.tableMetaData = tableMetaData;
|
||||
|
@ -70,7 +70,7 @@ public class EInternalFrame extends JInternalFrame implements InternalFrameListe
|
|||
}
|
||||
};
|
||||
|
||||
TableModel tableModel = new ERowLabelTable(data[0].length, tableMetaData.getRowLabels());
|
||||
TableModel tableModel = new ETableRowLabel(data[0].length, tableMetaData.getRowLabels());
|
||||
eTable = new ETable(tableMetaData, data, columnModel);
|
||||
eTable.setBackground(Color.LIGHT_GRAY);
|
||||
|
||||
|
@ -111,6 +111,11 @@ public class EInternalFrame extends JInternalFrame implements InternalFrameListe
|
|||
}
|
||||
|
||||
public boolean dataChanged(){
|
||||
if(this.eTable.getTheModel().getData() != this.savedData.get(savedData.size()-1).getData()){
|
||||
System.out.println("Data not the same.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,6 +124,10 @@ public class EInternalFrame extends JInternalFrame implements InternalFrameListe
|
|||
return data;
|
||||
}
|
||||
|
||||
public void saveDataToParentTuningEntity(){
|
||||
this.tableMetaData.getParentTuningEntity().setTableData(this.tableMetaData.getTableIdentifier(), this.eTable.getTheModel().getData());
|
||||
}
|
||||
|
||||
public void saveDataState(){
|
||||
this.savedData.push(new ETableSaveState(this.getTableData()));
|
||||
//this.savedData.push(this.getTableData());
|
||||
|
@ -126,7 +135,12 @@ public class EInternalFrame extends JInternalFrame implements InternalFrameListe
|
|||
|
||||
public void revertDataState(){
|
||||
if(!this.savedData.isEmpty()){
|
||||
this.setTableData(this.savedData.pop().getData());
|
||||
if(this.savedData.size() > 1){
|
||||
this.setTableData(this.savedData.pop().getData());
|
||||
}else if(savedData.size() == 1){
|
||||
this.setTableData(this.savedData.peek().getData());
|
||||
}
|
||||
|
||||
//this.setTableData(this.savedData.pop());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package enginuity.NewGUI.etable;
|
|||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
public class ERowLabelTable extends AbstractTableModel{
|
||||
public class ETableRowLabel extends AbstractTableModel{
|
||||
|
||||
private int length;
|
||||
private String[] labels;
|
||||
private int counter = 0;
|
||||
|
||||
public ERowLabelTable(int length, String[] labels){
|
||||
public ETableRowLabel(int length, String[] labels){
|
||||
this.length = length;
|
||||
this.labels = labels;
|
||||
}
|
|
@ -23,7 +23,7 @@ public interface TuningEntity extends ActionListener{
|
|||
public Double[][] getTableData(String tableName);
|
||||
|
||||
// Push back modified data to the tuning entity
|
||||
public Double[][] setTableData(String tableName, Double[][] data);
|
||||
public void setTableData(String tableIdentifier, Double[][] data);
|
||||
|
||||
// Control methods
|
||||
public void init(TuningEntityListener listener);
|
||||
|
|
|
@ -9,9 +9,43 @@ import javax.swing.JToolBar;
|
|||
import enginuity.NewGUI.tree.ETreeNode;
|
||||
|
||||
public interface TuningEntityListener {
|
||||
|
||||
/**
|
||||
* Change the tree structure base on the passed root node
|
||||
*
|
||||
* @param rootNodeOfNewTree
|
||||
*/
|
||||
public void TreeStructureChanged(ETreeNode rootNodeOfNewTree);
|
||||
|
||||
/**
|
||||
* Prepends list of menu items to the menu bae
|
||||
*
|
||||
* @param items
|
||||
*/
|
||||
public void rebuildJMenuBar(Vector<JMenu> items);
|
||||
|
||||
/**
|
||||
* If a tuning entity has a custom tool bar to add, call this method.
|
||||
*
|
||||
* @param theToolBar
|
||||
*/
|
||||
public void setNewToolBar(JToolBar theToolBar);
|
||||
|
||||
/**
|
||||
* Return the number of maps that have changed belonging to the targeted tuning entity of the defined tableGroup
|
||||
*
|
||||
* @param tuningEntity
|
||||
* @param tableGroup
|
||||
* @return
|
||||
*/
|
||||
public int getMapChangeCount(TuningEntity tuningEntity, String tableGroup);
|
||||
|
||||
/**
|
||||
* Has the main GUI kick off the process of saving table data.
|
||||
*
|
||||
* @param tuningEntity
|
||||
* @param tableGroup
|
||||
* @param tableIdentifier
|
||||
*/
|
||||
public void saveMaps(TuningEntity tuningEntity, String tableGroup);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
private TuningEntityListener theTEL;
|
||||
private int fileChosen;
|
||||
private JFileChooser fileChooser = new JFileChooser();
|
||||
private TuningEntity parentEntity;
|
||||
private TuningEntity parentTuningEntity;
|
||||
|
||||
// private ECUEditor parent;
|
||||
private JButton openImage = new JButton(new ImageIcon("./graphics/icon-open.png"));
|
||||
|
@ -34,9 +34,9 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
private JButton refreshImage = new JButton(new ImageIcon("./graphics/icon-refresh.png"));
|
||||
private JButton closeImage = new JButton(new ImageIcon("./graphics/icon-close.png"));
|
||||
|
||||
public JutecToolBar(TuningEntityListener theTEL, TuningEntity parentEntity){
|
||||
public JutecToolBar(TuningEntityListener theTEL, TuningEntity parentTuningEntity){
|
||||
this.theTEL = theTEL;
|
||||
this.parentEntity = parentEntity;
|
||||
this.parentTuningEntity = parentTuningEntity;
|
||||
|
||||
this.setFloatable(false);
|
||||
this.add(openImage);
|
||||
|
@ -53,12 +53,16 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
refreshImage.setMaximumSize(new Dimension(50, 50));
|
||||
refreshImage.setBorder(createLineBorder(new Color(150, 150, 150), 0));
|
||||
|
||||
updateButtons();
|
||||
|
||||
openImage.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
refreshImage.addActionListener(this);
|
||||
|
||||
// Set initial button state
|
||||
this.openImage.setEnabled(true);
|
||||
this.saveImage.setEnabled(false);
|
||||
this.refreshImage.setEnabled(false);
|
||||
this.closeImage.setEnabled(false);
|
||||
}
|
||||
|
||||
public void updateButtons() {
|
||||
|
@ -69,15 +73,6 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
refreshImage.setToolTipText("Refresh " + file + " from saved copy");
|
||||
closeImage.setToolTipText("Close " + file);
|
||||
|
||||
if ("".equals(file)) {
|
||||
saveImage.setEnabled(false);
|
||||
refreshImage.setEnabled(false);
|
||||
closeImage.setEnabled(false);
|
||||
} else {
|
||||
saveImage.setEnabled(true);
|
||||
refreshImage.setEnabled(true);
|
||||
closeImage.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -98,21 +93,24 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
if(mapData != null){
|
||||
|
||||
// Initialise tree
|
||||
ETreeNode root = new ETreeNode("UTEC:"+UtecDataManager.getCurrentMapData().getMapName()+", "+UtecDataManager.getCurrentMapData().getMapComment(), new TableMetaData(TableMetaData.CATEGORY,0.0,0.0,new Object[0],null,null,false,"","", this.parentEntity));
|
||||
ETreeNode root = new ETreeNode("UTEC:"+UtecDataManager.getCurrentMapData().getMapName()+", "+UtecDataManager.getCurrentMapData().getMapComment(), new TableMetaData(TableMetaData.CATEGORY,0.0,0.0,new Object[0],null,null,false,"","", "", this.parentTuningEntity));
|
||||
|
||||
Object[] ignored = {new Double(-100.0)};
|
||||
ETreeNode fuel = new ETreeNode("Fuel", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMax")[0]), ignored,null,null, false, "Fuel" , "Fuel:"+mapData.getMapName(), this.parentEntity));
|
||||
ETreeNode fuel = new ETreeNode("Fuel", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMax")[0]), ignored,null,null, false, "Fuel" , "Fuel:"+mapData.getMapName(), mapData.getMapName(),this.parentTuningEntity));
|
||||
|
||||
Object[] ignored2 = {new Double(-100.0)};
|
||||
ETreeNode timing = new ETreeNode("Timing", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.timingMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.timingMapMax")[0]), ignored,null,null, false, "Timing" , "Timing:"+mapData.getMapName(), this.parentEntity));
|
||||
ETreeNode timing = new ETreeNode("Timing", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.timingMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.timingMapMax")[0]), ignored,null,null, false, "Timing" , "Timing:"+mapData.getMapName(), mapData.getMapName(),this.parentTuningEntity));
|
||||
|
||||
Object[] ignored3 = {new Double(-100.0)};
|
||||
ETreeNode boost = new ETreeNode("Boost", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.boostMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.boostMapMax")[0]), ignored, null,null,false, "Boost" , "Boost:"+mapData.getMapName(), this.parentEntity));
|
||||
ETreeNode boost = new ETreeNode("Boost", new TableMetaData(TableMetaData.DATA3D, Double.parseDouble(UtecProperties.getProperties("utec.boostMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.boostMapMax")[0]), ignored, null,null,false, "Boost" , "Boost:"+mapData.getMapName(), mapData.getMapName(), this.parentTuningEntity));
|
||||
root.add(fuel);
|
||||
root.add(timing);
|
||||
root.add(boost);
|
||||
|
||||
this.theTEL.TreeStructureChanged(root);
|
||||
|
||||
// Enable the save option
|
||||
this.saveImage.setEnabled(true);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -120,7 +118,10 @@ public class JutecToolBar extends JToolBar implements ActionListener {
|
|||
}
|
||||
} else if (e.getSource() == saveImage) {
|
||||
try {
|
||||
//((ECUEditorMenuBar) parent.getJMenuBar()).saveImage(parent.getLastSelectedRom());
|
||||
System.out.println("Calling save now.");
|
||||
int count = this.theTEL.getMapChangeCount(this.parentTuningEntity, UtecDataManager.getCurrentMapData().getMapName());
|
||||
System.out.println("Count =:"+count);
|
||||
|
||||
} catch (Exception ex) {
|
||||
// JOptionPane.showMessageDialog(parent, new DebugPanel(ex,parent.getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ public class UtecTuningEntityImpl implements TuningEntity{
|
|||
this.theTEL = theTEL;
|
||||
|
||||
// Initialise tree
|
||||
ETreeNode root = new ETreeNode("UTEC: No map selected....", new TableMetaData(TableMetaData.CATEGORY,0.0,0.0,new Object[0], null, null, false,"","", this));
|
||||
ETreeNode root = new ETreeNode("UTEC: No map selected....", new TableMetaData(TableMetaData.CATEGORY,0.0,0.0,new Object[0], null, null, false,"","","", this));
|
||||
|
||||
|
||||
// Inform main GUI of initial tree
|
||||
|
@ -337,8 +337,7 @@ public class UtecTuningEntityImpl implements TuningEntity{
|
|||
return new JutecToolBar(this.theTEL, this);
|
||||
}
|
||||
|
||||
public Double[][] setTableData(String tableName, Double[][] data) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public void setTableData(String tableIdentifier, Double[][] data) {
|
||||
System.out.println("utec save data requested");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue