Mercurial > hg > ccmieditor
changeset 2:4b2f975e35fa
Minor Bug fixes
author | Fiore Martin <fiore@eecs.qmul.ac.uk> |
---|---|
date | Mon, 06 Feb 2012 12:54:06 +0000 |
parents | 71ff0735df5a |
children | 9e67171477bc |
files | java/src/uk/ac/qmul/eecs/ccmi/gui/DiagramTree.java java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.java java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.properties java/src/uk/ac/qmul/eecs/ccmi/gui/EditorFrame.java java/src/uk/ac/qmul/eecs/ccmi/gui/NodePopupMenu.java java/src/uk/ac/qmul/eecs/ccmi/gui/PropertyEditorDialog.java java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.java java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.properties java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/Wizard.java |
diffstat | 9 files changed, 26 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/DiagramTree.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/DiagramTree.java Mon Feb 06 12:54:06 2012 +0000 @@ -34,8 +34,6 @@ import javax.swing.KeyStroke; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; @@ -70,24 +68,6 @@ setEditable(false); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); overwriteTreeKeystrokes(); - this.addTreeSelectionListener(new TreeSelectionListener(){ - @Override - public void valueChanged(TreeSelectionEvent evt) { - if(treeSelectionListenerGateOpen){ - final DiagramModelTreeNode treeNode = (DiagramModelTreeNode)evt.getPath().getLastPathComponent(); - if(treeNode instanceof DiagramElement){ - SoundFactory.getInstance().play(((DiagramElement)treeNode).getSound(), new PlayerListener(){ - @Override - public void playEnded() { - NarratorFactory.getInstance().speak(treeNode.spokenText()); - } - }); - }else{ - NarratorFactory.getInstance().speak(treeNode.spokenText()); - } - } - } - }); /* don't use the swing focus system as we provide one on our own */ setFocusTraversalKeysEnabled(false); getAccessibleContext().setAccessibleName(""); @@ -168,7 +148,6 @@ public void jump(JumpTo jumpTo){ final Narrator narrator = NarratorFactory.getInstance(); TreePath oldPath; - treeSelectionListenerGateOpen = false; switch(jumpTo){ case REFERENCE : oldPath = getSelectionPath(); @@ -250,7 +229,6 @@ /* it speaks anyway as we set up the playerListener in the EditorFrame class. No need to use narrator then */ SoundFactory.getInstance().play(SoundEvent.CANCEL); InteractionLog.log(INTERACTIONLOG_SOURCE,"cancel select type to jump dialog",""); - treeSelectionListenerGateOpen = true; return; } /* we search in the root which type tree node has getName() equal to the selected one */ @@ -279,11 +257,10 @@ SoundFactory.getInstance().play(SoundEvent.ERROR ,new PlayerListener(){ @Override public void playEnded() { - narrator.speak("speech.no_bookmarks"); + narrator.speak(resources.getString("speech.no_bookmarks")); } }); InteractionLog.log(INTERACTIONLOG_SOURCE,"no bookmarks available",""); - treeSelectionListenerGateOpen = true; return; } @@ -315,7 +292,6 @@ /* it speaks anyway, as we set up the speech in the EditorFrame class. no need to use the narrator then */ SoundFactory.getInstance().play(SoundEvent.CANCEL); InteractionLog.log(INTERACTIONLOG_SOURCE,"cancel select bookmark dialog",""); - treeSelectionListenerGateOpen = true; return; } break; @@ -323,21 +299,18 @@ } InteractionLog.log(INTERACTIONLOG_SOURCE,"jumped to "+jumpTo.toString(),((DiagramModelTreeNode)getSelectionPath().getLastPathComponent()).getName()); SoundFactory.getInstance().play(SoundEvent.JUMP); - treeSelectionListenerGateOpen = true; } public void jumpTo(final DiagramElement de){ TreePath oldPath = getSelectionPath(); collapseAll((DiagramModelTreeNode)oldPath.getLastPathComponent(),de); setSelectionPath(new TreePath(de.getPath())); - treeSelectionListenerGateOpen = false; SoundFactory.getInstance().play( SoundEvent.JUMP, new PlayerListener(){ @Override public void playEnded() { NarratorFactory.getInstance().speak(MessageFormat.format(resources.getString("speech.jump"),de.spokenText())); } }); - treeSelectionListenerGateOpen = true; } /* collapse all the nodes in the path from "from" to "to" upwards(with the same direction as going from a leaf to the root)*/ @@ -354,6 +327,18 @@ //do nothing as the tree does not have to be editable with mouse } + @Override + protected void processKeyEvent(KeyEvent e){ + /* allow only cursor keys, tab key, delete, and actions (CTRL+something) */ + if(e.getKeyChar() == KeyEvent.CHAR_UNDEFINED + || e.getKeyCode() == KeyEvent.VK_TAB + || e.getKeyCode() == KeyEvent.VK_SPACE + || e.getKeyCode() == KeyEvent.VK_DELETE + || e.isControlDown() + || e.isAltDown()) + super.processKeyEvent(e); + } + private void overwriteTreeKeystrokes() { /* overwrite the keys. up and down arrow are overwritten so that it loops when the top and the */ /* bottom are reached rather than getting stuck */ @@ -375,7 +360,6 @@ nextTreeNode = (DiagramModelTreeNode)parent.getFirstChild(); loop = SoundEvent.LIST_BOTTOM_REACHED; } - treeSelectionListenerGateOpen = false; setSelectionPath(new TreePath(nextTreeNode.getPath())); final InputStream finalSound = getTreeNodeSound(nextTreeNode); final String currentPathSpeech = currentPathSpeech(); @@ -385,7 +369,6 @@ NarratorFactory.getInstance().speak(currentPathSpeech); } }); - treeSelectionListenerGateOpen = true; InteractionLog.log(INTERACTIONLOG_SOURCE,"move down",nextTreeNode.toString()); }}); @@ -404,7 +387,6 @@ previousTreeNode = (DiagramModelTreeNode)parent.getLastChild(); loop = SoundEvent.LIST_TOP_REACHED; } - treeSelectionListenerGateOpen = false; setSelectionPath(new TreePath(previousTreeNode.getPath())); final InputStream finalSound = getTreeNodeSound(previousTreeNode); final String currentPathSpeech = currentPathSpeech(); @@ -414,7 +396,6 @@ NarratorFactory.getInstance().speak(currentPathSpeech); } }); - treeSelectionListenerGateOpen = true; InteractionLog.log(INTERACTIONLOG_SOURCE,"move up",previousTreeNode.toString()); }}); @@ -429,7 +410,6 @@ InteractionLog.log(INTERACTIONLOG_SOURCE,"move right","border reached"); } else{ - treeSelectionListenerGateOpen = false; expandPath(path); setSelectionPath(new TreePath(((DiagramModelTreeNode)treeNode.getFirstChild()).getPath())); final String currentPathSpeech = currentPathSpeech(); @@ -439,7 +419,6 @@ NarratorFactory.getInstance().speak(currentPathSpeech); } }); - treeSelectionListenerGateOpen = true; InteractionLog.log(INTERACTIONLOG_SOURCE,"move right",((DiagramModelTreeNode)treeNode.getFirstChild()).toString()); } } @@ -457,7 +436,6 @@ InteractionLog.log(INTERACTIONLOG_SOURCE,"move left","border reached"); } else{ - treeSelectionListenerGateOpen = false; TreePath newPath = new TreePath(((DiagramModelTreeNode)parent).getPath()); setSelectionPath(newPath); collapsePath(newPath); @@ -469,7 +447,6 @@ } }); InteractionLog.log(INTERACTIONLOG_SOURCE,"move left",((DiagramModelTreeNode)parent).toString()); - treeSelectionListenerGateOpen = true; } } }); @@ -602,7 +579,6 @@ private List<Node> selectedNodes; private Diagram diagram; private ResourceBundle resources; - private boolean treeSelectionListenerGateOpen; private static final char SELECTED_NODE_MARK_BEGIN = '<'; private static final char SELECTED_NODE_MARK_END = '>'; private static final String INTERACTIONLOG_SOURCE = "TREE";
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.java Mon Feb 06 12:54:06 2012 +0000 @@ -89,7 +89,7 @@ iLog("cancel rename edge dialog",DiagramElement.toLogString(edgeRef)); else /* edge has been locked at selection time */ - modelUpdater.setName(edgeRef,name); + modelUpdater.setName(edgeRef,name.trim()); modelUpdater.yieldLock(edgeRef, Lock.NAME); } });
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.properties Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/EdgePopupMenu.properties Mon Feb 06 12:54:06 2012 +0000 @@ -1,7 +1,7 @@ menu.set_label=Set Label -menu.choose_arrow_head=Choose Arrow Head +menu.choose_arrow_head=Set Arrow Head menu.set_name=Set Name dialog.lock_failure.end=Edge end is being edited by another user
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/EditorFrame.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/EditorFrame.java Mon Feb 06 12:54:06 2012 +0000 @@ -514,6 +514,7 @@ EditorFrame.this, MessageFormat.format(resources.getString("dialog.template_created"), diagram.getName()), SpeechOptionPane.INFORMATION_MESSAGE); + SoundFactory.getInstance().play(SoundEvent.OK,null); } }) ); @@ -556,6 +557,7 @@ EditorFrame.this, MessageFormat.format(resources.getString("dialog.template_created"), diagram.getName()), SpeechOptionPane.INFORMATION_MESSAGE); + SoundFactory.getInstance().play(SoundEvent.OK,null); } } )); @@ -962,12 +964,12 @@ } } catch (ConnectNodesException cne) { final String message = cne.getLocalizedMessage(); - SoundFactory.getInstance().setPlayerListener(new PlayerListener(){ + SoundFactory.getInstance().play(SoundEvent.ERROR, new PlayerListener(){ @Override public void playEnded() { NarratorFactory.getInstance().speak(message); } - }, SoundEvent.ERROR); + }); SoundFactory.getInstance().play(SoundEvent.ERROR); iLog("insert edge error",message); }
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/NodePopupMenu.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/NodePopupMenu.java Mon Feb 06 12:54:06 2012 +0000 @@ -65,7 +65,7 @@ iLog("cancel rename node dialog",DiagramElement.toLogString(nodeRef)); else /* node has been locked at selection time */ - modelUpdater.setName(nodeRef, name); + modelUpdater.setName(nodeRef, name.trim()); modelUpdater.yieldLock(nodeRef, Lock.NAME); }
--- a/java/src/uk/ac/qmul/eecs/ccmi/gui/PropertyEditorDialog.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/gui/PropertyEditorDialog.java Mon Feb 06 12:54:06 2012 +0000 @@ -178,6 +178,8 @@ properties.clear(model.getColumnName(0)); for(int j=0; j< model.getRowCount();j++){ String value = model.getValueAt(j, 0).toString(); + if(value != null) + value = value.trim(); if(!value.equals("")){ properties.addValue(model.getColumnName(0),value , model.getIndexesAt(j)); }
--- a/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.java Mon Feb 06 12:54:06 2012 +0000 @@ -67,6 +67,7 @@ button.addChangeListener(new javax.swing.event.ChangeListener(){ @Override public void stateChanged(ChangeEvent e) { + /* keep the button disabled until finished is not true */ ((JButton)e.getSource()).setEnabled(finished); } });
--- a/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.properties Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.properties Mon Feb 06 12:54:06 2012 +0000 @@ -20,7 +20,7 @@ panel.home.choice.finish=Finish Editing Template panel.diagram_name.title=Enter Diagram Name -panel.diagram_name.title.editing_existing_diagram=Enter Diagram Name (different from the starting diagram's) +panel.diagram_name.title.editing_existing_diagram=Enter Diagram Name (different from the initial diagram's) panel.nodes.title=Select Action to perform for Nodes panel.nodes.actions.add=Add New Node
--- a/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/Wizard.java Tue Jan 10 11:39:43 2012 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/Wizard.java Mon Feb 06 12:54:06 2012 +0000 @@ -112,7 +112,8 @@ options); if(result == SpeechSummaryPane.CANCEL){ // user wants to continue editing - SoundFactory.getInstance().play(SoundEvent.CANCEL); + /* null arg will avoid default playerListener which speaks out the focused component */ + SoundFactory.getInstance().play(SoundEvent.CANCEL,null); return; } /* create the actual diagram (it will be return to the client class by execute()) */