Skip to content

Commit

Permalink
almost working to not change context on transciprt open edit (#2340)
Browse files Browse the repository at this point in the history
* almost working to not change context on transciprt open edit

* cleaned up

* removed imports
  • Loading branch information
nathandunn committed Dec 18, 2019
1 parent a3d528d commit d67eb41
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 40 deletions.
57 changes: 23 additions & 34 deletions src/gwt/org/bbop/apollo/gwt/client/AnnotatorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.gwtbootstrap3.client.ui.TextBox;
import org.gwtbootstrap3.client.ui.*;
import org.gwtbootstrap3.client.ui.constants.ButtonType;
import org.gwtbootstrap3.client.ui.constants.IconType;
import org.gwtbootstrap3.extras.bootbox.client.Bootbox;

import java.util.Date;
Expand Down Expand Up @@ -285,21 +284,12 @@ public void onResponseReceived(Request request, Response response) {
} else {
requestIndex = localRequestValue;
}
Integer annotationCount = (int) returnValue.isObject().get(FeatureStringEnum.ANNOTATION_COUNT.getValue()).isNumber().doubleValue();

int annotationCount = (int) returnValue.isObject().get(FeatureStringEnum.ANNOTATION_COUNT.getValue()).isNumber().doubleValue();
JSONArray jsonArray = returnValue.isObject().get(FeatureStringEnum.FEATURES.getValue()).isArray();

dataGrid.setRowCount(annotationCount, true);
final List<AnnotationInfo> annotationInfoList = AnnotationInfoConverter.convertFromJsonArray(jsonArray);
dataGrid.setRowData(start, annotationInfoList);
if (annotationInfoList.size() == 1) {
selectedAnnotationInfo = annotationInfoList.get(0);
String type = selectedAnnotationInfo.getType();
if (!type.equals("repeat_region") && !type.equals("transposable_element")) {
toggleOpen(1, selectedAnnotationInfo);
}

}

Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
Expand Down Expand Up @@ -651,12 +641,6 @@ private static void reselectSubTab() {

}

public static void fireAnnotationInfoChangeEvent(AnnotationInfo annotationInfo) {
// this method is for firing AnnotationInfoChangeEvent for single level features such as transposable_element and repeat_region
AnnotationInfoChangeEvent annotationInfoChangeEvent = new AnnotationInfoChangeEvent(annotationInfo, AnnotationInfoChangeEvent.Action.SET_FOCUS);
Annotator.eventBus.fireEvent(annotationInfoChangeEvent);
}

public void toggleOpen(int index, AnnotationInfo annotationInfo) {
if (showingTranscripts.contains(annotationInfo.getUniqueName())) {
showingTranscripts.remove(annotationInfo.getUniqueName());
Expand All @@ -670,6 +654,14 @@ public void toggleOpen(int index, AnnotationInfo annotationInfo) {
}
}

public void addOpenTranscript(String uniqueName){
showingTranscripts.add(uniqueName);
}

public void removeOpenTranscript(String uniqueName){
showingTranscripts.remove(uniqueName);
}

private void initializeTable() {
// View friends.
SafeHtmlRenderer<String> anchorRenderer = new AbstractSafeHtmlRenderer<String>() {
Expand Down Expand Up @@ -840,7 +832,6 @@ private Boolean isSearchDirty() {
if(userField.getSelectedIndex()>0) return true;
if(goOnlyCheckBox.getValue()) return true;
if(uniqueNameCheckBox.getValue()) return true;
if(uniqueNameCheckBox.getValue()) return true;
if(nameSearchBox.getText().trim().length()>0) return true;
if(sequenceList.getValue().trim().length()>0) return true;

Expand Down Expand Up @@ -877,23 +868,8 @@ public void setShowAllSequences(ClickEvent clickEvent) {


private void handleDetails() {
// if (showDetails) {
// toggleAnnotation.setText("Hide Details");
// toggleAnnotation.setIcon(IconType.EYE_SLASH);
// } else {
// toggleAnnotation.setText("Show Details");
// toggleAnnotation.setIcon(IconType.INFO_CIRCLE);
// }

tabPanel.setVisible(showDetails && singleSelectionModel.getSelectedObject() != null);
}
//
// @UiHandler("toggleAnnotation")
// void toggleAnnotation(ClickEvent clickEvent) {
// showDetails = !showDetails;
// handleDetails();
// }


private static AnnotationInfo getChildAnnotation(AnnotationInfo annotationInfo, String uniqueName) {
for (AnnotationInfo childAnnotation : annotationInfo.getChildAnnotations()) {
Expand All @@ -914,11 +890,16 @@ public void enableGoto(int geneIndex, String uniqueName) {
selectedChildUniqueName = selectedAnnotationInfo.getUniqueName();
}

public void setSelectedAnnotationInfo(AnnotationInfo annotationInfo){
selectedAnnotationInfo = annotationInfo;
updateAnnotationInfo(selectedAnnotationInfo);
}

// used by javascript function
public void displayTranscript(int geneIndex, String uniqueName) {

// for some reason doesn't like call enableGoto
enableGoto(geneIndex, uniqueName);
// enableGoto(geneIndex, uniqueName);

// for some reason doesn't like call gotoAnnotation
Integer min = selectedAnnotationInfo.getMin() - 50;
Expand Down Expand Up @@ -961,7 +942,9 @@ public CustomTableBuilder() {
protected void buildRowImpl(AnnotationInfo rowValue, int absRowIndex) {
buildAnnotationRow(rowValue, absRowIndex, false);

GWT.log("show transcript size: "+showingTranscripts.size());
if (showingTranscripts.contains(rowValue.getUniqueName())) {
GWT.log("showing transcripts IS included"+rowValue.getUniqueName());
// add some random rows
Set<AnnotationInfo> annotationInfoSet = rowValue.getChildAnnotations();
if (annotationInfoSet.size() > 0) {
Expand All @@ -970,13 +953,19 @@ protected void buildRowImpl(AnnotationInfo rowValue, int absRowIndex) {
}
}
}
else{
GWT.log("showing transcripts is not included"+rowValue.getUniqueName());
}

}

private void buildAnnotationRow(final AnnotationInfo rowValue, int absRowIndex, boolean showTranscripts) {

TableRowBuilder row = startRow();
TableCellBuilder td = row.startTD();

GWT.log("buildingg rows with "+ absRowIndex + " "+ showTranscripts);

td.style().outlineStyle(Style.OutlineStyle.NONE).endStyle();
if (showTranscripts) {
// TODO: this is ugly, but it works
Expand Down
7 changes: 7 additions & 0 deletions src/gwt/org/bbop/apollo/gwt/client/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,13 @@ public static SequenceInfo getCurrentSequence() {
return currentSequence;
}

public void addOpenTranscript(String uniqueName){ annotatorPanel.addOpenTranscript(uniqueName);}
public void removeOpenTranscript(String uniqueName){ annotatorPanel.removeOpenTranscript(uniqueName);}

public void setSelectedAnnotationInfo(AnnotationInfo annotationInfo){
GWT.log("setting the selected annotaiton info: "+annotationInfo.getType()+ " "+ annotationInfo.getUniqueName());
annotatorPanel.setSelectedAnnotationInfo(annotationInfo);
}

public String getCommonDataDirectory() {
return commonDataDirectory;
Expand Down
11 changes: 5 additions & 6 deletions src/gwt/org/bbop/apollo/gwt/client/TranscriptDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.HasDirection;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
Expand All @@ -19,7 +18,6 @@
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import org.bbop.apollo.gwt.client.dto.AnnotationInfo;
import org.bbop.apollo.gwt.client.event.AnnotationInfoChangeEvent;
import org.bbop.apollo.gwt.client.rest.AnnotationRestService;
import org.bbop.apollo.gwt.client.rest.AvailableStatusRestService;
import org.bbop.apollo.gwt.client.rest.RestService;
Expand All @@ -41,7 +39,8 @@ public class TranscriptDetailPanel extends Composite {

private AnnotationInfo internalAnnotationInfo;

interface AnnotationDetailPanelUiBinder extends UiBinder<Widget, TranscriptDetailPanel> { }
interface AnnotationDetailPanelUiBinder extends UiBinder<Widget, TranscriptDetailPanel> {
}

private static AnnotationDetailPanelUiBinder ourUiBinder = GWT.create(AnnotationDetailPanelUiBinder.class);

Expand Down Expand Up @@ -142,11 +141,11 @@ public void onResponseReceived(Request request, Response response) {
// parse to make sure we return the complete amount
try {
JSONValue returnValue = JSONParser.parseStrict(response.getText());
GWT.log("Return: "+returnValue.toString());
GWT.log("Return: " + returnValue.toString());
Bootbox.confirm("Success. Reload page to reflect results?", new ConfirmCallback() {
@Override
public void callback(boolean result) {
if(result){
if (result) {
Window.Location.reload();
}
}
Expand Down Expand Up @@ -210,11 +209,11 @@ public void updateData(AnnotationInfo annotationInfo) {

private void updateTranscript() {
final AnnotationInfo updatedInfo = this.internalAnnotationInfo;
MainPanel.getInstance().setSelectedAnnotationInfo(updatedInfo);
enableFields(false);
RequestCallback requestCallback = new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
// Annotator.eventBus.fireEvent(new AnnotationInfoChangeEvent(updatedInfo, AnnotationInfoChangeEvent.Action.UPDATE));
enableFields(true);
}

Expand Down

0 comments on commit d67eb41

Please sign in to comment.