Skip to content

Commit 2e23c0b

Browse files
committed
got rid of ViewPropEdit 'deleted' whose use I didn't understand, and added cancelation of side search on TextArea blur
1 parent 4b8bf06 commit 2e23c0b

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

src/org/argmap/client/ModeEdit.java

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
import com.google.gwt.user.client.ui.HTMLTable;
4444
import com.google.gwt.user.client.ui.Label;
4545
import com.google.gwt.user.client.ui.PopupPanel;
46-
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
4746
import com.google.gwt.user.client.ui.ResizeComposite;
4847
import com.google.gwt.user.client.ui.ScrollPanel;
4948
import com.google.gwt.user.client.ui.SplitLayoutPanel;
5049
import com.google.gwt.user.client.ui.TextBox;
5150
import com.google.gwt.user.client.ui.Tree;
5251
import com.google.gwt.user.client.ui.TreeItem;
5352
import com.google.gwt.user.client.ui.VerticalPanel;
53+
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
5454

5555
public class ModeEdit extends ResizeComposite implements KeyUpHandler,
5656
OpenHandler<TreeItem>, CloseHandler<TreeItem>,
@@ -279,7 +279,8 @@ public void onSuccess() {
279279
// propView.logNodeRecursive(0, "em.em.cb", true);
280280
}
281281
tree.resetState();
282-
if (Log.on) tree.logTree(log);
282+
if (Log.on)
283+
tree.logTree(log);
283284

284285
updateTimer.start();
285286
log.finish();
@@ -388,7 +389,9 @@ public void call(PartialTrees results) {
388389
List<ViewProp> viewProps = new ArrayList<ViewProp>(
389390
loadedProps.get(node.id));
390391
for (ViewProp viewProp : viewProps) {
391-
log.logln("prossesing ViewProp:" + viewProp);
392+
log
393+
.logln("prossesing ViewProp:"
394+
+ viewProp);
392395
updateNode(viewProp, node, results);
393396
}
394397
} else if (node instanceof Argument) {
@@ -743,24 +746,30 @@ public void call(PartialTrees trees) {
743746
}
744747
});
745748
} else {
746-
ArgMap.messageTimed(
747-
"Cannot link to existing proposition when proposition currently being edited has children",
748-
MessageType.ERROR);
749+
ArgMap
750+
.messageTimed(
751+
"Cannot link to existing proposition when proposition currently being edited has children",
752+
MessageType.ERROR);
749753
}
750754
}
751755

752-
public void sideSearch(ViewPropEdit viewProp) {
756+
private void cancelSideSearch() {
753757
if (sideSearch != null) {
754758
sideSearch.cancelSearch();
755759
sideSearch = null;
756760
}
761+
hideSearchBox();
762+
}
763+
764+
public void sideSearch(ViewPropEdit viewProp) {
765+
cancelSideSearch();
757766

758767
sideSearchResults.removeAllRows();
759768
sideSearchContinueButton.setVisible(false);
760769

761770
String searchString = viewProp.getTextAreaContent().trim();
762771
if (!searchString.equals("") && viewProp.getChildCount() == 0
763-
&& !viewProp.deleted) {
772+
/* && !viewProp.deleted */) {
764773
List<Long> filterIDs = new ArrayList<Long>();
765774
filterIDs.addAll(viewProp.getAncestorIDs());
766775
if (viewProp.getParent() != null) {
@@ -1040,7 +1049,8 @@ public void run() {
10401049
}
10411050

10421051
schedule(currentFrequency);
1043-
if (on) getUpdatesAndApply();
1052+
if (on)
1053+
getUpdatesAndApply();
10441054
}
10451055

10461056
public void start() {
@@ -1129,9 +1139,17 @@ public void setViewProp(ViewPropEdit viewProp) {
11291139
}
11301140
}
11311141

1142+
public void cancelSearch() {
1143+
viewProp = null;
1144+
cancelSideSearch();
1145+
cancel();
1146+
}
1147+
11321148
@Override
11331149
public void run() {
1134-
sideSearch(viewProp);
1150+
if (viewProp != null) {
1151+
sideSearch(viewProp);
1152+
}
11351153
}
11361154

11371155
@Override
@@ -1302,8 +1320,8 @@ public void onOpen(OpenEvent<TreeItem> event) {
13021320
if (!source.isLoaded()) {
13031321
loadFromServer(source, 2, 1);
13041322
} else {
1305-
List<ViewNode> list = new ArrayList<ViewNode>(
1306-
source.getChildCount());
1323+
List<ViewNode> list = new ArrayList<ViewNode>(source
1324+
.getChildCount());
13071325
for (int i = 0; i < source.getChildCount(); i++) {
13081326
if (!source.getChild(i).isLoaded()) {
13091327
list.add(source.getChild(i));

src/org/argmap/client/ViewPropEdit.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.argmap.client.ServerComm.LocalCallback;
88
import org.argmap.client.StarRating.RatingHandler;
99

10+
import com.google.gwt.event.dom.client.BlurEvent;
11+
import com.google.gwt.event.dom.client.BlurHandler;
1012
import com.google.gwt.event.dom.client.ChangeEvent;
1113
import com.google.gwt.event.dom.client.ChangeHandler;
1214
import com.google.gwt.event.dom.client.ClickEvent;
@@ -27,7 +29,7 @@
2729
import com.google.gwt.user.client.ui.TextArea;
2830

2931
public class ViewPropEdit extends ViewProp implements ClickHandler,
30-
KeyDownHandler, KeyUpHandler, FocusHandler, ChangeHandler,
32+
KeyDownHandler, KeyUpHandler, FocusHandler, BlurHandler, ChangeHandler,
3133
MouseOverHandler, MouseOutHandler, SavableNode, RatingHandler {
3234

3335
private static ViewPropEdit lastPropositionWithFocus = null;
@@ -46,7 +48,7 @@ public class ViewPropEdit extends ViewProp implements ClickHandler,
4648
"probably true (~75% chance of being true)",
4749
"definitely true (~100% chance of being true)" };
4850

49-
boolean deleted = false;
51+
// boolean deleted = false;
5052

5153
public static ViewPropEdit getLastPropositionWithFocus() {
5254
return lastPropositionWithFocus;
@@ -97,6 +99,7 @@ public ViewPropEdit(Proposition prop) {
9799
textArea.addKeyDownHandler(this);
98100
textArea.addKeyUpHandler(this);
99101
textArea.addFocusHandler(this);
102+
textArea.addBlurHandler(this);
100103
textArea.addChangeHandler(this);
101104
focusPanel.addFocusHandler(this);
102105
focusPanel.addMouseOverHandler(this);
@@ -344,7 +347,13 @@ public void call(Void t) {
344347
}
345348
});
346349
}
350+
}
347351

352+
@Override
353+
public void onBlur(BlurEvent event) {
354+
if (event.getSource() == textArea) {
355+
getEditMode().sideSearchTimer.cancelSearch();
356+
}
348357
}
349358

350359
public void onFocus(FocusEvent event) {
@@ -710,7 +719,7 @@ public void removePropositionAndMaybeParentArgument_DELETE_ME() {
710719
// parent arguments if this proposition is top level.
711720
getTree().removeItem(this);
712721
ServerComm.deleteProp(this.proposition);
713-
deleted = true;
722+
// deleted = true;
714723
return;
715724
}
716725

@@ -775,7 +784,7 @@ public void removePropositionAndMaybeParentArgument_DELETE_ME() {
775784
}
776785
ServerComm.deleteProp(this.proposition);
777786

778-
deleted = true;
787+
// deleted = true;
779788

780789
/*
781790
* this must come after the ServerComm.removeProposition() otherwise it

war/WEB-INF/appengine-generated/datastore-indexes-auto.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<!-- Indices written at Sun, 12 Dec 2010 15:16:07 EST -->
1+
<!-- Indices written at Sun, 12 Dec 2010 18:41:39 EST -->
22

33
<datastore-indexes>
44

5-
<!-- Used 24 times in query history -->
5+
<!-- Used 28 times in query history -->
66
<datastore-index kind="Proposition" ancestor="false" source="auto">
77
<property name="root" direction="asc"/>
88
<property name="created" direction="desc"/>

0 commit comments

Comments
 (0)