private void showMenuCreate() { Menu cm2 = new Menu("TrackListCreateContextMenu"); cm2.addOnClickListener( new OnClickListener() { @Override public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) { switch (((MenuItem) v).getMenuItemId()) { case MenuID.MI_P2P: GenTrackP2P(); return true; case MenuID.MI_PROJECT: GenTrackProjection(); return true; case MenuID.MI_CIRCLE: GenTrackCircle(); return true; } return false; } }); cm2.addItem(MenuID.MI_P2P, "Point2Point"); cm2.addItem(MenuID.MI_PROJECT, "Projection"); cm2.addItem(MenuID.MI_CIRCLE, "Circle"); cm2.Show(); }
@Override public Menu getContextMenu() { Menu cm = new Menu("TrackListContextMenu"); cm.addOnClickListener( new OnClickListener() { @Override public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) { Log.info(log, "[TrackListContextMenu] clicked " + ((MenuItem) v).getMenuItemId()); switch (((MenuItem) v).getMenuItemId()) { case MenuID.MI_GENERATE: showMenuCreate(); return true; case MenuID.MI_RENAME: if (TrackListView.that != null) { final TrackListViewItem selectedTrackItem = TrackListView.that.getSelectedItem(); StringInputBox.Show( WrapType.SINGLELINE, selectedTrackItem.getRoute().Name, Translation.Get("RenameTrack"), selectedTrackItem.getRoute().Name, new OnMsgBoxClickListener() { @Override public boolean onClick(int which, Object data) { String text = StringInputBox.editText.getText(); // Behandle das ergebniss switch (which) { case 1: // ok Clicket selectedTrackItem.getRoute().Name = text; TrackListView.that.notifyDataSetChanged(); break; case 2: // cancel clicket break; case 3: break; } return true; } }); TrackListView.that.notifyDataSetChanged(); return true; } return true; case MenuID.MI_LOAD: PlatformConnector.getFile( CB_UI_Settings.TrackFolder.getValue(), "*.gpx", Translation.Get("LoadTrack"), Translation.Get("load"), new IgetFileReturnListener() { @Override public void getFileReturn(String Path) { if (Path != null) { TrackColor = RouteOverlay.getNextColor(); RouteOverlay.MultiLoadRoute(Path, TrackColor); Log.debug(log, "Load Track :" + Path); if (TrackListView.that != null) TrackListView.that.notifyDataSetChanged(); } } }); return true; case MenuID.MI_SAVE: PlatformConnector.getFile( CB_UI_Settings.TrackFolder.getValue(), "*.gpx", Translation.Get("SaveTrack"), Translation.Get("save"), new IgetFileReturnListener() { TrackListViewItem selectedTrackItem = TrackListView.that.getSelectedItem(); @Override public void getFileReturn(String Path) { if (Path != null) { RouteOverlay.SaveRoute(Path, selectedTrackItem.getRoute()); Log.debug(log, "Load Track :" + Path); if (TrackListView.that != null) TrackListView.that.notifyDataSetChanged(); } } }); return true; case MenuID.MI_DELETE_TRACK: if (TrackListView.that != null) { TrackListViewItem selectedTrackItem = TrackListView.that.getSelectedItem(); if (selectedTrackItem == null) { Log.info( log, "[TrackListContextMenu] clicked " + MenuID.MI_DELETE_TRACK + " " + "NoTrackSelected"); GL_MsgBox.Show( Translation.Get("NoTrackSelected"), null, MessageBoxButtons.OK, MessageBoxIcon.Warning, new OnMsgBoxClickListener() { @Override public boolean onClick(int which, Object data) { // hier brauchen wir nichts machen! return true; } }); return true; } if (selectedTrackItem.getRoute().IsActualTrack) { Log.info( log, "[TrackListContextMenu] clicked " + MenuID.MI_DELETE_TRACK + " " + "IsActualTrack"); GL_MsgBox.Show( Translation.Get("IsActualTrack"), null, MessageBoxButtons.OK, MessageBoxIcon.Warning, null); return false; } Log.info( log, "[TrackListContextMenu] clicked " + MenuID.MI_DELETE_TRACK + " remove " + "selectedTrackItem"); RouteOverlay.remove(selectedTrackItem.getRoute()); selectedTrackItem = null; TrackListView.that.notifyDataSetChanged(); return true; } } return false; } }); TrackListViewItem selectedTrackItem = TrackListView.that.getSelectedItem(); cm.addItem(MenuID.MI_LOAD, "load"); cm.addItem(MenuID.MI_GENERATE, "generate"); // rename, save, delete darf nicht mit dem aktuellen Track gemacht werden.... if (selectedTrackItem != null && !selectedTrackItem.getRoute().IsActualTrack) { cm.addItem(MenuID.MI_RENAME, "rename"); cm.addItem(MenuID.MI_SAVE, "save"); cm.addItem(MenuID.MI_DELETE_TRACK, "delete"); } return cm; }