From: kruland2607 Date: Tue, 3 Jul 2012 02:54:54 +0000 (+0000) Subject: If the simulation doesn't have data, open the edit dialog instead of issuing a warning. X-Git-Tag: upstream/12.09^2~131 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a73bd19ec91b7540ab51d03dc4ecc93a532d26c1;p=debian%2Fopenrocket If the simulation doesn't have data, open the edit dialog instead of issuing a warning. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@858 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java index c621dab2..2304aa9a 100644 --- a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java +++ b/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java @@ -179,10 +179,7 @@ implements Simulations.OnSimulationSelectedListener, OpenRocketSaverFragment.OnO Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(simulationId); // Check if there is data for this simulation. if ( sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0 ) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("The selected simulation does not have saved data."); - builder.setCancelable(true); - builder.show(); + // This shouldn't happen because the Simulations list does the check. return; } diff --git a/android/src/net/sf/openrocket/android/simulation/Simulations.java b/android/src/net/sf/openrocket/android/simulation/Simulations.java index 61ef2a41..805792b6 100644 --- a/android/src/net/sf/openrocket/android/simulation/Simulations.java +++ b/android/src/net/sf/openrocket/android/simulation/Simulations.java @@ -136,7 +136,11 @@ implements SharedPreferences.OnSharedPreferenceChangeListener simulationList.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView l, View v, int position, long id) { - if (listener != null ) { + Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(position); + // Check if there is data for this simulation. + if ( sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0 ) { + openEditor(position); + } else if (listener != null ) { listener.onSimulationSelected(position); } } @@ -147,10 +151,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener @Override public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - final SimulationEditFragment f = SimulationEditFragment.newInstance(position); - FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); - ft.add(f, wizardFrag); - ft.commit(); + openEditor(position); return true; } @@ -159,6 +160,13 @@ implements SharedPreferences.OnSharedPreferenceChangeListener simulationList.setAdapter(sims); } + + private void openEditor( int position ) { + final SimulationEditFragment f = SimulationEditFragment.newInstance(position); + FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); + ft.add(f, wizardFrag); + ft.commit(); + } private void addSimulation() { CurrentRocketHolder.getCurrentRocket().addNewSimulation();