Editor Bug Fixes:

- Fix for category node open issue.  Double click on node causes the node to open and then close.
 - Made editor pane's private.  Updated logger to access through get methods.
This commit is contained in:
Scotthew 2014-12-28 17:21:12 -08:00
parent 855332c0bc
commit b631fd2c12
4 changed files with 92 additions and 64 deletions

View File

@ -68,10 +68,10 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
import com.romraider.net.BrowserControl;
import com.romraider.Settings;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.maps.Rom;
import com.romraider.net.BrowserControl;
import com.romraider.net.URL;
import com.romraider.swing.AbstractFrame;
import com.romraider.swing.CustomToolbarLayout;
@ -95,8 +95,10 @@ public class ECUEditor extends AbstractFrame {
private final RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images");
private final RomTree imageList = new RomTree(imageRoot);
public MDIDesktopPane rightPanel = new MDIDesktopPane();
public JProgressPane statusPanel = new JProgressPane();
private final MDIDesktopPane rightPanel = new MDIDesktopPane();
private final JProgressPane statusPanel = new JProgressPane();
private final JScrollPane leftScrollPane;
private final JScrollPane rightScrollPane;
private JSplitPane splitPane = new JSplitPane();
private Rom lastSelectedRom = null;
private ECUEditorToolBar toolBar;
@ -121,9 +123,9 @@ public class ECUEditor extends AbstractFrame {
setExtendedState(MAXIMIZED_BOTH);
}
JScrollPane rightScrollPane = new JScrollPane(rightPanel,
rightScrollPane = new JScrollPane(rightPanel,
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
JScrollPane leftScrollPane = new JScrollPane(imageList,
leftScrollPane = new JScrollPane(imageList,
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScrollPane, rightScrollPane);
@ -526,6 +528,14 @@ public class ECUEditor extends AbstractFrame {
public MDIDesktopPane getRightPanel() {
return this.rightPanel;
}
public JScrollPane getLeftScrollPane() {
return this.leftScrollPane;
}
public JScrollPane getRightScrollPane() {
return this.rightScrollPane;
}
}
class LaunchLoggerWorker extends SwingWorker<Void, Void> {

View File

@ -19,7 +19,6 @@
package com.romraider.logger.ecu;
import com.romraider.net.BrowserControl;
import static com.romraider.Version.LOGGER_DEFS_URL;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.Version.VERSION;
@ -178,6 +177,7 @@ import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.core.ExternalDataSourceLoader;
import com.romraider.logger.external.core.ExternalDataSourceLoaderImpl;
import com.romraider.net.BrowserControl;
import com.romraider.swing.AbstractFrame;
import com.romraider.swing.SetFont;
import com.romraider.util.FormatFilename;
@ -297,12 +297,12 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
// fail until we actually try to use them since the logger requires
// these libraries, this is a hard error here
if (!JREChecker.is32bit()) {
showMessageDialog(null,
"Incompatible JRE detected.\n" +
PRODUCT_NAME +
" ECU Logger requires a 32-bit JRE.\nLogger will now exit.",
"JRE Incompatibility Error",
ERROR_MESSAGE);
showMessageDialog(null,
"Incompatible JRE detected.\n" +
PRODUCT_NAME +
" ECU Logger requires a 32-bit JRE.\nLogger will now exit.",
"JRE Incompatibility Error",
ERROR_MESSAGE);
// this will generate a NullPointerException because we never got
// things started
WindowEvent e = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
@ -339,20 +339,20 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
}
else {
bootstrap();
ecuEditor.statusPanel.update("Loading ECU Defs...", 20);
ecuEditor.getStatusPanel().update("Loading ECU Defs...", 20);
loadEcuDefs();
ecuEditor.statusPanel.update("Loading Plugins...", 40);
ecuEditor.getStatusPanel().update("Loading Plugins...", 40);
loadLoggerPlugins();
ecuEditor.statusPanel.update("Loading ECU Parameters...", 60);
ecuEditor.getStatusPanel().update("Loading ECU Parameters...", 60);
loadLoggerParams();
ecuEditor.statusPanel.update("Starting Logger...", 80);
ecuEditor.getStatusPanel().update("Starting Logger...", 80);
initControllerListeners();
initUserInterface();
ecuEditor.statusPanel.update("Complete...", 100);
ecuEditor.getStatusPanel().update("Complete...", 100);
initDataUpdateHandlers();
startPortRefresherThread();
if (!isLogging()) startLogging();
ecuEditor.statusPanel.update("Ready...",0);
ecuEditor.getStatusPanel().update("Ready...",0);
}
}
@ -610,7 +610,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
final File profileFile = new File(path);
if (profileFile.exists()) {
reportMessageInTitleBar(
"Profile: " + FormatFilename.getShortName(profileFile));
"Profile: " + FormatFilename.getShortName(profileFile));
}
return true;
}
@ -643,7 +643,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private boolean applyUserProfile(UserProfile profile) {
if (profile != null) {
final String profileProto =
final String profileProto =
profile.getProtocol() == null ? "SSM" : profile.getProtocol();
if (!profileProto.equalsIgnoreCase(getSettings().getLoggerProtocol())) {
@ -651,10 +651,10 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
Object[] options = {"Load", "Cancel"};
final String message = String.format(
"This profile was created for logging protocol %s.%n" +
"Some parameters may not be selected by this profile if%n" +
"you load it. Change protocols in the Settings menu%n" +
"then reload this profile.",
profileProto);
"Some parameters may not be selected by this profile if%n" +
"you load it. Change protocols in the Settings menu%n" +
"then reload this profile.",
profileProto);
int answer = showOptionDialog(this,
message,
"Protocol Mismatch", DEFAULT_OPTION, WARNING_MESSAGE, null, options, options[1]);
@ -1242,24 +1242,24 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
logToFileButton.setBackground(GREEN);
logToFileButton.setOpaque(true);
logToFileButton.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (logToFileButton.isSelected() && controller.isStarted()) {
fileUpdateHandler.start();
logToFileButton.setBackground(RED);
logToFileButton.setText(LOG_TO_FILE_STOP);
}
else {
fileUpdateHandler.stop();
if (!controller.isStarted()) statusIndicator.stopped();
logToFileButton.setBackground(GREEN);
logToFileButton.setSelected(false);
logToFileButton.setText(LOG_TO_FILE_START);
new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (logToFileButton.isSelected() && controller.isStarted()) {
fileUpdateHandler.start();
logToFileButton.setBackground(RED);
logToFileButton.setText(LOG_TO_FILE_STOP);
}
else {
fileUpdateHandler.stop();
if (!controller.isStarted()) statusIndicator.stopped();
logToFileButton.setBackground(GREEN);
logToFileButton.setSelected(false);
logToFileButton.setText(LOG_TO_FILE_START);
}
}
}
}
);
);
logToFileButton.getInputMap(
WHEN_IN_FOCUSED_WINDOW).put(
getKeyStroke(LOG_TO_FILE_FK), "toggleFileLogging");

View File

@ -47,6 +47,7 @@ public class RomTree extends JTree implements MouseListener {
addMouseListener(this);
setCellRenderer(new RomCellRenderer());
setFont(new Font("Tahoma", Font.PLAIN, 11));
setToggleClickCount(SettingsManager.getSettings().getTableClickCount());
// key binding actions
Action tableSelectAction = new AbstractAction() {
@ -55,8 +56,15 @@ public class RomTree extends JTree implements MouseListener {
@Override
public void actionPerformed(ActionEvent e) {
try{
Object selectedRow = getSelectionPath().getLastPathComponent();
showTable(selectedRow);
Object selectedRow = getLastSelectedPathComponent();
/* if nothing is selected */
if (selectedRow == null) {
return;
}
if(selectedRow instanceof TableTreeNode) {
showTable(selectedRow);
}
setLastSelectedRom(selectedRow);
}catch(NullPointerException ex) {
}
@ -76,21 +84,15 @@ public class RomTree extends JTree implements MouseListener {
@Override
public void mouseClicked(MouseEvent e) {
try{
Object selectedRow = getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
Object selectedRow = getLastSelectedPathComponent();
/* if nothing is selected */
if (selectedRow == null) {
return;
}
if(selectedRow instanceof TableTreeNode) {
if (e.getClickCount() >= SettingsManager.getSettings().getTableClickCount()) {
showTable(selectedRow);
}
} else if(selectedRow instanceof Rom || selectedRow instanceof CategoryTreeNode) {
if (e.getClickCount() >= SettingsManager.getSettings().getTableClickCount()) {
if(isCollapsed(getRowForLocation(e.getX(),e.getY()))) {
expandRow(getRowForLocation(e.getX(),e.getY()));
}
else {
collapseRow(getRowForLocation(e.getX(),e.getY()));
}
}
if(e.getClickCount() >= SettingsManager.getSettings().getTableClickCount()
&& selectedRow instanceof TableTreeNode) {
showTable(selectedRow);
}
setLastSelectedRom(selectedRow);
@ -111,18 +113,32 @@ public class RomTree extends JTree implements MouseListener {
}
private void setLastSelectedRom(Object selectedNode) {
if (selectedNode instanceof TableTreeNode || selectedNode instanceof CategoryTreeNode || selectedNode instanceof Rom) {
Object lastSelectedPathComponent = getLastSelectedPathComponent();
if(lastSelectedPathComponent instanceof Rom) {
Rom node = (Rom) lastSelectedPathComponent;
if(null != node) {
getEditor().setLastSelectedRom(node);
}
}
if (selectedNode == null || selectedNode instanceof RomTreeRootNode) {
return;
}
Rom romNode = getRomNode(selectedNode);
if(romNode == null) {
return;
}
getEditor().setLastSelectedRom(romNode);
getEditor().refreshUI();
}
private Rom getRomNode(Object currentNode){
if(currentNode == null) {
return null;
} else if(currentNode instanceof Rom) {
return (Rom)currentNode;
} else if(currentNode instanceof TableTreeNode) {
return getRomNode(((TableTreeNode)currentNode).getParent());
} else if(currentNode instanceof CategoryTreeNode) {
return getRomNode(((CategoryTreeNode)currentNode).getParent());
}else {
return null;
}
}
@Override
public void mousePressed(MouseEvent e) {
}

View File

@ -989,6 +989,8 @@ public class SettingsForm extends JFrame implements MouseListener {
getSettings().setTableClickCount(2);
}
getEditor().getImageList().setToggleClickCount(getSettings().getTableClickCount());
if(1 == tableClickBehavior.getSelectedIndex()) { // open/close frame
getSettings().setTableClickBehavior(1);
} else { // open/focus frame