|
26 | 26 | import com.google.gwt.event.dom.client.MouseOverHandler; |
27 | 27 | import com.google.gwt.user.client.ui.Button; |
28 | 28 | import com.google.gwt.user.client.ui.FlexTable; |
29 | | -import com.google.gwt.user.client.ui.TextArea; |
30 | 29 |
|
31 | 30 | public class ViewPropEdit extends ViewProp implements ClickHandler, |
32 | 31 | KeyDownHandler, KeyUpHandler, FocusHandler, BlurHandler, ChangeHandler, |
@@ -185,61 +184,6 @@ public void call(Void t) { |
185 | 184 | }); |
186 | 185 | } |
187 | 186 |
|
188 | | - public void onKeyDown_DELETE_ME(KeyDownEvent event) { |
189 | | - /* |
190 | | - * tell edit mode that there has been a user action so it doesn't |
191 | | - * throttle live updates (do it first in case the key press results in a |
192 | | - * deletion in which case the getEditMode() will return null) |
193 | | - */ |
194 | | - getEditMode().updateTimer.userAction(); |
195 | | - |
196 | | - int charCode = event.getNativeKeyCode(); |
197 | | - Object source = event.getSource(); |
198 | | - if (source == textArea) { |
199 | | - /* |
200 | | - * if it's a root proposition add an argument when user presses |
201 | | - * enter |
202 | | - */ |
203 | | - if (charCode == KeyCodes.KEY_ENTER && parentArgView() == null) { |
204 | | - onChange(null); |
205 | | - addArgument(true); |
206 | | - event.preventDefault(); |
207 | | - } |
208 | | - /* |
209 | | - * if it is not a root proposition, add a sibling proposition when |
210 | | - * user presses enter |
211 | | - */ |
212 | | - else if (charCode == KeyCodes.KEY_ENTER && parentArgView() != null) { |
213 | | - onChange(null); |
214 | | - addProposition(); |
215 | | - event.preventDefault(); |
216 | | - } |
217 | | - /* only do the following key actions if this is not a link */ |
218 | | - else if (proposition.linkCount <= 1) { |
219 | | - if (charCode == KeyCodes.KEY_BACKSPACE |
220 | | - && textArea.getCursorPos() == 0 |
221 | | - && textArea.getSelectionLength() == 0) { |
222 | | - removePropositionAndMaybeParentArgument_DELETE_ME(); |
223 | | - event.preventDefault(); |
224 | | - } else if (charCode == KeyCodes.KEY_DELETE |
225 | | - && textArea.getText().equals("")) { |
226 | | - removePropositionAndMaybeParentArgument_DELETE_ME(); |
227 | | - event.preventDefault(); |
228 | | - } else if (charCode == KeyCodes.KEY_DELETE |
229 | | - && textArea.getCursorPos() == textArea.getText() |
230 | | - .length() && textArea.getSelectionLength() == 0) { |
231 | | - removeNextProposition_DELETE_ME(); |
232 | | - event.preventDefault(); |
233 | | - } else { |
234 | | - getEditMode().editContentSaveTimer |
235 | | - .setNodeForTimedSave(this); |
236 | | - } |
237 | | - } else { |
238 | | - getEditMode().editContentSaveTimer.setNodeForTimedSave(this); |
239 | | - } |
240 | | - } |
241 | | - } |
242 | | - |
243 | 187 | @Override |
244 | 188 | public void onKeyDown(KeyDownEvent event) { |
245 | 189 | /* |
@@ -575,9 +519,6 @@ private void refocusFollowing(ViewNode node) { |
575 | 519 | } |
576 | 520 | } |
577 | 521 |
|
578 | | - /* |
579 | | - * TODO: what is deleted = true used for? |
580 | | - */ |
581 | 522 | private boolean handleKeyBackspaceOrDelete(int charCode) { |
582 | 523 | /* if the user has selected any text */ |
583 | 524 | if (textArea.getSelectionLength() != 0) { |
@@ -650,7 +591,6 @@ else if (charCode == KeyCodes.KEY_DELETE |
650 | 591 | if (isTopLevel() || getParent().getChildCount() > 1 |
651 | 592 | || parentArgumentHasTitle()) { |
652 | 593 | refocusFollowing(this); |
653 | | - // TODO set cursor position here, below and above |
654 | 594 | remove(); |
655 | 595 | ServerComm.deleteProp(this.proposition); |
656 | 596 | } else { |
@@ -691,109 +631,4 @@ private void mergePropsAndDeleteOne(ViewPropEdit firstProp, |
691 | 631 | deleteProp.remove(); |
692 | 632 | ServerComm.deleteProp(deleteProp.proposition); |
693 | 633 | } |
694 | | - |
695 | | - public void removeNextProposition_DELETE_ME() { |
696 | | - ViewArgEdit parentArgView = parentArgView(); |
697 | | - int thisIndex = parentArgView.getChildIndex(this); |
698 | | - ViewPropEdit nextPropView = ((ViewPropEdit) parentArgView |
699 | | - .getChild(thisIndex + 1)); |
700 | | - if (nextPropView != null && nextPropView.getChildCount() == 0 |
701 | | - && nextPropView.proposition.linkCount <= 1) { |
702 | | - int cursorPosition = textArea.getCursorPos(); |
703 | | - textArea.setText(textArea.getText() |
704 | | - + nextPropView.textArea.getText()); |
705 | | - textArea.setCursorPos(cursorPosition); |
706 | | - ServerComm.deleteProp(nextPropView.proposition); |
707 | | - nextPropView.remove(); |
708 | | - } |
709 | | - |
710 | | - } |
711 | | - |
712 | | - public void removePropositionAndMaybeParentArgument_DELETE_ME() { |
713 | | - if (this.getChildCount() != 0) // cannot delete a proposition with |
714 | | - // children...must delete children first |
715 | | - return; |
716 | | - |
717 | | - if (isTopLevel()) { // don't worry about setting the focus or dealing |
718 | | - // with subsequent or preceeding propositions or |
719 | | - // parent arguments if this proposition is top level. |
720 | | - getTree().removeItem(this); |
721 | | - ServerComm.deleteProp(this.proposition); |
722 | | - // deleted = true; |
723 | | - return; |
724 | | - } |
725 | | - |
726 | | - boolean parentArgViewRemoved = false; |
727 | | - ViewArgEdit parentArgView = parentArgView(); |
728 | | - int thisIndex = parentArgView.getChildIndex(this); |
729 | | - |
730 | | - /* if this is the parent argument's first proposition */ |
731 | | - if (thisIndex == 0) { |
732 | | - /* |
733 | | - * do nothing if textarea is not empty, user must first delete the |
734 | | - * text to delete a proposition when not combining propositions. |
735 | | - */ |
736 | | - if (!textArea.getText().equals("")) |
737 | | - return; |
738 | | - |
739 | | - /* if this is the only proposition of the argument */ |
740 | | - if (parentArgView.getChildCount() == 1) { |
741 | | - /* set the focus on the parent argument's proposition */ |
742 | | - ((ViewPropEdit) parentArgView.getParentItem()).textArea |
743 | | - .setFocus(true); |
744 | | - |
745 | | - /* |
746 | | - * remove the argument (which includes the proposition) from the |
747 | | - * tree |
748 | | - */ |
749 | | - parentArgView.remove(); |
750 | | - parentArgViewRemoved = true; |
751 | | - } |
752 | | - /* if there are other children */ |
753 | | - else { |
754 | | - /* set focus on the next proposition */ |
755 | | - ((ViewPropEdit) parentArgView.getChild(thisIndex + 1)).textArea |
756 | | - .setFocus(true); |
757 | | - /* just remove this proposition */ |
758 | | - parentArgView.removeItem(this); |
759 | | - } |
760 | | - /* |
761 | | - * if this is not the parent argument's first proposition we want to |
762 | | - * combine propositions |
763 | | - */ |
764 | | - } else if (thisIndex != 0) { |
765 | | - ViewPropEdit prePropView = ((ViewPropEdit) parentArgView |
766 | | - .getChild(thisIndex - 1)); |
767 | | - |
768 | | - /* |
769 | | - * cannot combine contents with a preceeding proposition that is a |
770 | | - * link |
771 | | - */ |
772 | | - if (prePropView.proposition.linkCount > 1) { |
773 | | - return; |
774 | | - } |
775 | | - TextArea preTextArea = prePropView.textArea; |
776 | | - int newCursorPosition = preTextArea.getText().length(); |
777 | | - String combinedText = preTextArea.getText() + textArea.getText(); |
778 | | - preTextArea.setText(combinedText); |
779 | | - preTextArea.setFocus(true); |
780 | | - preTextArea.setCursorPos(newCursorPosition); |
781 | | - prePropView.proposition.setContent(combinedText); |
782 | | - remove(); |
783 | | - prePropView.saveContentToServerIfChanged(); |
784 | | - } |
785 | | - ServerComm.deleteProp(this.proposition); |
786 | | - |
787 | | - // deleted = true; |
788 | | - |
789 | | - /* |
790 | | - * this must come after the ServerComm.removeProposition() otherwise it |
791 | | - * will fail on the server because the argumentView will still have |
792 | | - * children... (also the deleteProposition() probably wouldn't work out |
793 | | - * to well...) |
794 | | - */ |
795 | | - if (parentArgViewRemoved == true) { |
796 | | - ServerComm.deleteArg(parentArgView.argument); |
797 | | - } |
798 | | - } |
799 | 634 | } |
0 commit comments