You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by ia...@apache.org on 2015/07/13 14:54:36 UTC

[18/34] incubator-taverna-mobile git commit: implemented workflow run Results. Results now show up in a new screen

implemented workflow run Results. Results now show up in a new screen


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/commit/ee887f37
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/ee887f37
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/ee887f37

Branch: refs/heads/master
Commit: ee887f37a5de9351cf18f248387e20d5a56c4f62
Parents: 6d7108e
Author: larrytech7 <la...@gmail.com>
Authored: Thu Jul 9 17:33:32 2015 +0100
Committer: larrytech7 <la...@gmail.com>
Committed: Thu Jul 9 17:33:32 2015 +0100

----------------------------------------------------------------------
 .../taverna/mobile/activities/RunResult.java    |  39 +----
 .../mobile/fragments/WorkflowItemFragment.java  |   4 +-
 .../fragments/workflowdetails/RunFragment.java  | 144 +++++++++++++++++++
 .../workflowdetails/WorkflowdetailFragment.java |   9 +-
 app/src/main/res/layout/fragment_run_result.xml | 123 +++++++++++++++-
 app/src/main/res/menu/run_result.xml            |   9 +-
 app/src/main/res/values/strings.xml             |   3 +
 7 files changed, 283 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java b/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java
index 2ae1a53..23d4c27 100644
--- a/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java
+++ b/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java
@@ -1,17 +1,12 @@
 package org.apache.taverna.mobile.activities;
 
-import android.support.v7.app.ActionBarActivity;
-import android.support.v7.app.ActionBar;
-import android.support.v4.app.Fragment;
 import android.os.Bundle;
-import android.view.LayoutInflater;
+import android.support.v7.app.ActionBarActivity;
 import android.view.Menu;
 import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.os.Build;
 
 import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.fragments.workflowdetails.RunFragment;
 
 public class RunResult extends ActionBarActivity {
 
@@ -21,47 +16,21 @@ public class RunResult extends ActionBarActivity {
         setContentView(R.layout.activity_run_result);
         if (savedInstanceState == null) {
             getSupportFragmentManager().beginTransaction()
-                    .add(R.id.container, new PlaceholderFragment())
+                    .add(R.id.container, RunFragment.newInstance())
                     .commit();
         }
     }
 
-
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // Inflate the menu; this adds items to the action bar if it is present.
-        getMenuInflater().inflate(R.menu.run_result, menu);
-        return true;
+        return false;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        // Handle action bar item clicks here. The action bar will
-        // automatically handle clicks on the Home/Up button, so long
-        // as you specify a parent activity in AndroidManifest.xml.
-        int id = item.getItemId();
-
-        //noinspection SimplifiableIfStatement
-        if (id == R.id.action_settings) {
-            return true;
-        }
 
         return super.onOptionsItemSelected(item);
     }
 
-    /**
-     * A placeholder fragment containing a simple view.
-     */
-    public static class PlaceholderFragment extends Fragment {
-
-        public PlaceholderFragment() {
-        }
-
-        @Override
-        public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                                 Bundle savedInstanceState) {
-            View rootView = inflater.inflate(R.layout.fragment_run_result, container, false);
-            return rootView;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
index fd53c44..a2e2a4d 100644
--- a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
+++ b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
@@ -262,9 +262,7 @@ public class WorkflowItemFragment extends Fragment implements SwipeRefreshLayout
                         ladapter.addWorkflow(workflow);
                     }
                 }
-            else {
-                Toast.makeText(getActivity(), "No workflows available", Toast.LENGTH_SHORT).show();
-            }
+
             mListView.swapAdapter(ladapter, true);
             if (ladapter.getItemCount() == 0)
                 Toast.makeText(getActivity(), "No workflows found matching criteria", Toast.LENGTH_SHORT).show();

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/RunFragment.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/RunFragment.java b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/RunFragment.java
new file mode 100644
index 0000000..c1d8cdf
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/RunFragment.java
@@ -0,0 +1,144 @@
+package org.apache.taverna.mobile.fragments.workflowdetails;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.w3c.dom.Text;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Use the {@link RunFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+public class RunFragment extends Fragment implements View.OnClickListener{
+
+    private View rootView;
+    private static int RUNID;
+    private TextView runIdTextView,runNameTextView;
+    private ImageButton status;
+    private  TextView runStateTextView, runStartTime,runEndTime, runInputsText;
+    private  Button downloadOutput,downloadLogs;
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment RunFragment.
+     */
+    public static RunFragment newInstance() {
+        RunFragment fragment = new RunFragment();
+        Bundle args = new Bundle();
+        fragment.setArguments(args);
+        RUNID = 0 ;
+        return fragment;
+    }
+
+    public RunFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setHasOptionsMenu(true);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+        rootView = inflater.inflate(R.layout.fragment_run_result, container, false);
+         runIdTextView = (TextView) rootView.findViewById(R.id.textview_runid);
+         runNameTextView = (TextView) rootView.findViewById(R.id.textView_runName);
+         status = (ImageButton) rootView.findViewById(R.id.statusButton);
+         runStateTextView = (TextView) rootView.findViewById(R.id.statusTextView);
+         runStartTime = (TextView) rootView.findViewById(R.id.start_time);
+         runEndTime = (TextView) rootView.findViewById(R.id.runfinish);
+         runInputsText = (TextView) rootView.findViewById(R.id.runinputsTextView);
+         downloadOutput = (Button) rootView.findViewById(R.id.buttonWorkflowDownloadOutput);
+         downloadLogs = (Button) rootView.findViewById(R.id.downloadRunLogs);
+
+        return rootView;
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu,MenuInflater menuInflater) {
+        // Inflate the menu; this adds items to the action bar if it is present.
+        menuInflater.inflate(R.menu.run_result, menu);
+        return;
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        String runresult = getActivity().getIntent().getStringExtra("runresult");
+        try{
+            JSONObject resultObject = new JSONObject(runresult);
+            String runName = resultObject.getString("name");
+            String runId = ""+resultObject.get("id");
+            String runState = resultObject.getString("state");
+            String runStarted = resultObject.getString("start_time");
+            String runEnded = resultObject.getString("finish_time");
+            String runInputs = resultObject.getString("inputs");
+
+                runIdTextView.setText(runId);
+                runNameTextView.setText(runName);
+
+                if(runState.contains("Pending"))
+                    status.setImageResource(android.R.drawable.presence_busy);
+            else if (runState.contains("Running"))
+                    status.setImageResource(android.R.drawable.presence_away);
+            else if (runState.contains("Finished"))
+                    status.setImageResource(android.R.drawable.presence_online);
+            else if (runState.contains("Failed"))
+                    status.setImageResource(android.R.drawable.presence_offline);
+            else
+                status.setImageResource(android.R.drawable.presence_invisible);
+
+                runStateTextView.setText(runState);
+                runStartTime.setHint(runStarted);
+                runEndTime.setHint(runEnded);
+                runInputsText.setText(runInputs);
+
+                downloadOutput.setOnClickListener(this);
+                downloadLogs.setOnClickListener(this);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        // Handle action bar item clicks here. The action bar will
+        // automatically handle clicks on the Home/Up button, so long
+        // as you specify a parent activity in AndroidManifest.xml.
+        int id = item.getItemId();
+        if (id == R.id.action_refresh) {
+            //TODO start task to retrieve current status of workflow and further details
+            return true;
+        }
+
+        return super.onOptionsItemSelected(item);
+    }
+
+    private void reloadRunResult(){
+        //TODO reload the run results when refreshed
+    }
+
+    @Override
+    public void onClick(View view) {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
index e0aa350..bbc0fc6 100644
--- a/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
+++ b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
@@ -31,6 +31,7 @@ import android.app.LoaderManager;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.content.Loader;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -56,6 +57,7 @@ import android.widget.ZoomControls;
 
 import org.apache.taverna.mobile.R;
 import org.apache.taverna.mobile.activities.DashboardMainActivity;
+import org.apache.taverna.mobile.activities.RunResult;
 import org.apache.taverna.mobile.tavernamobile.TavernaPlayerAPI;
 import org.apache.taverna.mobile.tavernamobile.User;
 import org.apache.taverna.mobile.tavernamobile.Workflow;
@@ -194,7 +196,7 @@ public class WorkflowdetailFragment extends Fragment implements View.OnClickList
     @Override
     public void onResume() {
         super.onResume();
-        if(!LOAD_STATE)
+     //   if(!LOAD_STATE)
             getActivity().getLoaderManager().initLoader(1, null, this).forceLoad();
     }
 
@@ -204,7 +206,6 @@ public class WorkflowdetailFragment extends Fragment implements View.OnClickList
         LOAD_STATE = true;
     }
 
-
     @Override
     public Loader<Workflow> onCreateLoader(int i, Bundle bundle) {
         progressDialog.show();
@@ -645,6 +646,10 @@ public class WorkflowdetailFragment extends Fragment implements View.OnClickList
             Log.i("RUN OutPut", s);
             progressDialog.dismiss();
             //TODO startup the runActivity to display the run results
+            Intent runIntent = new Intent();
+            runIntent.setClass(this.context, RunResult.class);
+            runIntent.putExtra("runresult", s);
+            startActivity(runIntent);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/res/layout/fragment_run_result.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/fragment_run_result.xml b/app/src/main/res/layout/fragment_run_result.xml
index ccb985c..ee8cc46 100644
--- a/app/src/main/res/layout/fragment_run_result.xml
+++ b/app/src/main/res/layout/fragment_run_result.xml
@@ -1,12 +1,125 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
     android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     android:paddingBottom="@dimen/activity_vertical_margin"
-    tools:context="org.apache.taverna.mobile.activities.RunResult$PlaceholderFragment">
+    tools:context="org.apache.taverna.mobile.activities.RunResult$PlaceholderFragment"
+    android:orientation="vertical"
+    >
 
-    <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
-        android:layout_height="wrap_content" />
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="10dp">
 
-</RelativeLayout>
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:id="@+id/textView_runName"
+            android:layout_weight="2" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="@drawable/abc_btn_radio_to_on_mtrl_000"
+            android:id="@+id/textview_runid"
+            android:layout_gravity="left"
+            android:layout_weight="1"
+            android:text="1"
+            android:gravity="center" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="10dp">
+
+        <ImageButton
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/statusButton"
+            android:src="@android:drawable/presence_online"
+            android:background="#eee" />
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="Medium Text"
+            android:id="@+id/statusTextView" />
+    </LinearLayout>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:text="@string/runstarted"
+        android:id="@+id/textView11"
+        android:gravity="center"
+        android:layout_gravity="center_horizontal"
+        android:textSize="25dp" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:id="@+id/start_time"
+        android:hint="started" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:text="@string/run_finishtime"
+        android:id="@+id/textView12"
+        android:textSize="25dp"
+        android:layout_gravity="center_horizontal" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:id="@+id/runfinish"
+        android:hint="finish" />
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:text="inputs from run"
+        android:id="@+id/runinputsTextView"
+        android:minLines="5"
+        android:layout_marginTop="10dp"
+        android:layout_weight="1.5"
+        android:layout_marginBottom="10dp" />
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <Button
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="download output"
+            android:id="@+id/buttonWorkflowDownloadOutput"
+            android:layout_weight="1"
+            android:background="#1F9FEA"
+            android:layout_marginRight="5dp" />
+
+        <Button
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="Download Logs"
+            android:id="@+id/downloadRunLogs"
+            android:layout_gravity="center_horizontal"
+            android:layout_weight="1"
+            android:background="#1F9FEA"
+            android:layout_marginLeft="5dp" />
+    </LinearLayout>
+
+</LinearLayout>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/res/menu/run_result.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/menu/run_result.xml b/app/src/main/res/menu/run_result.xml
index 35d088f..e10c15a 100644
--- a/app/src/main/res/menu/run_result.xml
+++ b/app/src/main/res/menu/run_result.xml
@@ -1,7 +1,10 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
-    tools:context="org.apache.taverna.mobile.activities.RunResult">
-    <item android:id="@+id/action_settings" android:title="@string/action_settings"
-        android:orderInCategory="100" app:showAsAction="never" />
+    tools:context="org.apache.taverna.mobile.fragments.workflowdetails.RunFragment">
+
+    <item android:id="@+id/action_refresh"
+        android:title="Refresh"
+        app:showAsAction="always|withText"
+        android:icon="@android:drawable/stat_notify_sync"/>
 </menu>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/ee887f37/app/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cd8c074..d785370 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -94,5 +94,8 @@ limitations under the License.
     <string name="playerpass">Password</string>
     <string name="myexperimenttitle">Configure MyExperiment Account</string>
     <string name="myexperimentsummary">Username used to login to MyExperiment</string>
+    <string name="title_activity_run_result">Workflow Run Result</string>
+    <string name="runstarted">Run Started</string>
+    <string name="run_finishtime">Run finish Time</string>
 
 </resources>