OSDN Git Service

original
[gb-231r1-is01/GB_2.3_IS01.git] / sdk / sdkmanager / libs / sdklib / src / com / android / sdklib / internal / repository / ITaskMonitor.java
diff --git a/sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java b/sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java
new file mode 100644 (file)
index 0000000..e08e27c
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * Copyright (C) 2009 The Android Open Source Project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.android.sdklib.internal.repository;\r
+\r
+\r
+/**\r
+ * A monitor interface for a {@link ITask}.\r
+ * <p/>\r
+ * Depending on the task factory that created the task, there might not be any UI\r
+ * or it might not implement all the methods, in which case calling them would be\r
+ * a no-op but is guaranteed not to crash.\r
+ * <p/>\r
+ * If the task runs in a non-UI worker thread, the task factory implementation\r
+ * will take care of the update the UI in the correct thread. The task itself\r
+ * must not have to deal with it.\r
+ */\r
+public interface ITaskMonitor {\r
+\r
+    /**\r
+     * Sets the description in the current task dialog.\r
+     * This method can be invoked from a non-UI thread.\r
+     */\r
+    public void setDescription(String descriptionFormat, Object...args);\r
+\r
+    /**\r
+     * Sets the result text in the current task dialog.\r
+     * This method can be invoked from a non-UI thread.\r
+     */\r
+    public void setResult(String resultFormat, Object...args);\r
+\r
+    /**\r
+     * Sets the max value of the progress bar.\r
+     * This method can be invoked from a non-UI thread.\r
+     *\r
+     * This method MUST be invoked once before using {@link #incProgress(int)} or\r
+     * {@link #getProgress()} or {@link #createSubMonitor(int)}. Callers are\r
+     * discouraged from using more than once -- implementations can either discard\r
+     * the next calls or behave incoherently.\r
+     */\r
+    public void setProgressMax(int max);\r
+\r
+    /**\r
+     * Increments the current value of the progress bar.\r
+     * This method can be invoked from a non-UI thread.\r
+     *\r
+     * Callers MUST use setProgressMax before using this method.\r
+     */\r
+    public void incProgress(int delta);\r
+\r
+    /**\r
+     * Returns the current value of the progress bar,\r
+     * between 0 and up to {@link #setProgressMax(int)} - 1.\r
+     *\r
+     * Callers MUST use setProgressMax before using this method.\r
+     */\r
+    public int getProgress();\r
+\r
+    /**\r
+     * Returns true if the user requested to cancel the operation.\r
+     * It is up to the task thread to pool this and exit as soon\r
+     * as possible.\r
+     */\r
+    public boolean isCancelRequested();\r
+\r
+    /**\r
+     * Creates a sub-monitor that will use up to tickCount on the progress bar.\r
+     * tickCount must be 1 or more.\r
+     */\r
+    public ITaskMonitor createSubMonitor(int tickCount);\r
+\r
+    /**\r
+     * Display a yes/no question dialog box.\r
+     *\r
+     * Implementations MUST allow this to be called from any thread, e.g. by\r
+     * making sure the dialog is opened synchronously in the ui thread.\r
+     *\r
+     * @param title The title of the dialog box\r
+     * @param message The error message\r
+     * @return true if YES was clicked.\r
+     */\r
+    public boolean displayPrompt(final String title, final String message);\r
+\r
+}\r