use of org.hwyl.sexytopo.model.table.TableCol in project sexytopo by richsmith.
the class TableActivity method onMenuItemClick.
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
final TableCol col = fieldToTableCol.get(cellBeingClicked);
final GraphToListTranslator.SurveyListEntry surveyEntry = fieldToSurveyEntry.get(cellBeingClicked);
Context context = this;
int itemId = menuItem.getItemId();
if (itemId == R.id.setActiveStation) {
Station newActive = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
getSurvey().setActiveStation(newActive);
syncTableWithSurvey();
return true;
} else if (itemId == R.id.graph_station_jump_to_plan) {
Station planStation = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
jumpToStation(planStation, PlanActivity.class);
return true;
} else if (itemId == R.id.graph_station_jump_to_ee) {
Station eeStation = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
jumpToStation(eeStation, ExtendedElevationActivity.class);
return true;
} else if (itemId == R.id.renameStation) {
Station toRename = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
if (toRename == Survey.NULL_STATION) {
showSimpleToast("Can't rename a splay end");
} else {
ManualEntry.renameStation(this, getSurvey(), toRename);
}
return true;
} else if (itemId == R.id.editLeg) {
Leg toEdit = surveyEntry.getLeg();
ManualEntry.editLeg(this, getSurvey(), toEdit);
return true;
} else if (itemId == R.id.moveRow) {
final Leg toMove = surveyEntry.getLeg();
requestMoveLeg(toMove);
return true;
} else if (itemId == R.id.upgradeRow) {
Leg toUpgrade = surveyEntry.getLeg();
SurveyUpdater.upgradeSplayToConnectedLeg(getSurvey(), toUpgrade, getInputMode());
syncTableWithSurvey();
return true;
} else if (itemId == R.id.deleteStation) {
Station toDelete = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
askAboutDeleting(context, toDelete, null);
return true;
} else if (itemId == R.id.deleteLeg) {
askAboutDeleting(context, surveyEntry.getFrom(), surveyEntry.getLeg());
return true;
} else if (itemId == R.id.deleteSplay) {
askAboutDeleting(context, surveyEntry.getFrom(), surveyEntry.getLeg());
return true;
} else {
return false;
}
}
use of org.hwyl.sexytopo.model.table.TableCol in project sexytopo by richsmith.
the class TableActivity method onLongClick.
@Override
public boolean onLongClick(View view) {
TextView textView = (TextView) view;
cellBeingClicked = textView;
TableCol col = fieldToTableCol.get(textView);
if (col == TableCol.FROM || col == TableCol.TO) {
showPopup(view, R.menu.table_station_selected, this);
} else {
final GraphToListTranslator.SurveyListEntry surveyEntry = fieldToSurveyEntry.get(cellBeingClicked);
Leg leg = surveyEntry.getLeg();
if (leg.hasDestination()) {
showPopup(view, R.menu.table_full_leg_selected, this);
} else {
showPopup(view, R.menu.table_splay_selected, this);
}
}
return true;
}
use of org.hwyl.sexytopo.model.table.TableCol in project sexytopo by richsmith.
the class TableActivity method syncTableWithSurvey.
public void syncTableWithSurvey() {
Survey survey = getSurvey();
stationsToTableIndex.clear();
List<GraphToListTranslator.SurveyListEntry> tableEntries = graphToListTranslator.toChronoListOfSurveyListEntries(survey);
if (tableEntries.size() == 0) {
Toast.makeText(getApplicationContext(), R.string.no_data, Toast.LENGTH_SHORT).show();
}
final TableLayout tableLayout = findViewById(R.id.BodyTable);
tableLayout.removeAllViews();
for (GraphToListTranslator.SurveyListEntry entry : tableEntries) {
TableRow tableRow = (TableRow) LayoutInflater.from(this).inflate(R.layout.table_row, null);
final Map<TableCol, Object> map = GraphToListTranslator.createMap(entry);
for (TableCol col : TableCol.values()) {
if (col == TableCol.COMMENT) {
continue;
}
String display = map.containsKey(col) ? col.format(map.get(col)) : "?";
int id = TABLE_COL_BY_ANDROID_ID.get(col);
TextView textView = tableRow.findViewById(id);
textView.setText(display);
if (isActiveStation(map.get(col))) {
textView.setBackgroundColor(GraphView.HIGHLIGHT_COLOUR.intValue);
}
if (entry.getLeg().hasDestination()) {
textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
} else {
textView.setTypeface(textView.getTypeface(), Typeface.NORMAL);
}
fieldToSurveyEntry.put(textView, entry);
fieldToTableCol.put(textView, col);
textView.setOnLongClickListener(this);
}
int rowCount = tableLayout.getChildCount();
tableLayout.addView(tableRow, rowCount);
if (entry.getLeg().hasDestination()) {
Station to = entry.getLeg().getDestination();
stationsToTableIndex.put(to, rowCount);
}
}
tableLayout.requestLayout();
}
use of org.hwyl.sexytopo.model.table.TableCol in project sexytopo by richsmith.
the class GraphToListTranslator method createMap.
public static Map<TableCol, Object> createMap(SurveyListEntry entry) {
Station from = entry.getFrom();
Leg leg = entry.getLeg();
Map<TableCol, Object> map = new HashMap<>();
if (leg.hasDestination() && leg.getDestination().hasComment()) {
map.put(TableCol.COMMENT, leg.getDestination().getComment());
}
if (leg.wasShotBackwards()) {
map.put(TableCol.FROM, leg.getDestination());
map.put(TableCol.TO, from);
leg = leg.asBacksight();
} else {
map.put(TableCol.FROM, from);
map.put(TableCol.TO, leg.getDestination());
}
map.put(TableCol.DISTANCE, leg.getDistance());
map.put(TableCol.AZIMUTH, leg.getAzimuth());
map.put(TableCol.INCLINATION, leg.getInclination());
return map;
}
Aggregations