本文整理汇总了Java中org.commcare.suite.model.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.commcare.suite.model包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prompt
import org.commcare.suite.model.Action; //导入依赖的package包/类
@Override
public void prompt(PrintStream out) {
int maxLength = String.valueOf(mChoices.length).length();
out.println(CliUtils.pad("", maxLength + 1) + mHeader);
out.println("==============================================================================================");
for (int i = 0; i < mChoices.length; ++i) {
String d = rows[i];
out.println(CliUtils.pad(String.valueOf(i), maxLength) + ")" + d);
}
if(actions != null) {
int actionCount = 0;
for (Action action : actions) {
out.println();
out.println("action " + actionCount + ") " + action.getDisplay().evaluate().getName());
actionCount += 1;
}
}
}
示例2: parse
import org.commcare.suite.model.Action; //导入依赖的package包/类
public Action parse() throws InvalidStructureException, IOException, XmlPullParserException {
this.checkNode(NAME_ACTION);
DisplayUnit display = null;
Vector<StackOperation> stackOps = new Vector<StackOperation>();
while (nextTagInBlock(NAME_ACTION)) {
if (parser.getName().equals("display")) {
display = parseDisplayBlock();
} else if (parser.getName().equals("stack")) {
StackOpParser sop = new StackOpParser(parser);
while (this.nextTagInBlock("stack")) {
stackOps.addElement(sop.parse());
}
}
}
if (display == null) {
throw new InvalidStructureException("<action> block must define a <display> element", parser);
}
if (stackOps.size() == 0) {
throw new InvalidStructureException("An <action> block must define at least one stack operation", parser);
}
return new Action(display, stackOps);
}
示例3: prompt
import org.commcare.suite.model.Action; //导入依赖的package包/类
@Override
public void prompt(PrintStream out) {
int maxLength = String.valueOf(mChoices.length).length();
out.println(ScreenUtils.pad("", maxLength + 1) + mHeader);
out.println("==============================================================================================");
for (int i = 0; i < mChoices.length; ++i) {
String d = rows[i];
out.println(ScreenUtils.pad(String.valueOf(i), maxLength) + ")" + d);
}
if (actions != null) {
int actionCount = 0;
for (Action action : actions) {
out.println();
out.println("action " + actionCount + ") " + action.getDisplay().evaluate().getName());
actionCount += 1;
}
}
}
示例4: stepBackFromStackPush
import org.commcare.suite.model.Action; //导入依赖的package包/类
/**
* Confirm that when stepping back after a stack push, we remove all pushed data
*/
@Test
public void stepBackFromStackPush() throws Exception {
MockApp mApp = new MockApp("/case_title_form_loading/");
SessionWrapper session = mApp.getSession();
session.setCommand("m0");
session.setComputedDatum();
EntityDatum entityDatum = (EntityDatum) session.getNeededDatum();
Vector<Action> actions = session.getDetail(entityDatum.getShortDetail()).getCustomActions(session.getEvaluationContext());
if (actions == null || actions.isEmpty()) {
Assert.fail("Detail screen stack action was missing from app!");
}
//We're using the second action for this screen which requires us to still need another datum
Action dblManagement = actions.elementAt(1);
assertEquals(1, session.getFrame().getSteps().size());
session.executeStackOperations(dblManagement.getStackOperations(), session.getEvaluationContext());
assertEquals(5, session.getFrame().getSteps().size());
session.stepBack();
assertEquals(1, session.getFrame().getSteps().size());
}
示例5: testActionParsing
import org.commcare.suite.model.Action; //导入依赖的package包/类
@Test
public void testActionParsing() throws Exception {
MockApp mApp = new MockApp("/complex_stack/");
SessionWrapper session = mApp.getSession();
session.setCommand("test-actions");
assertEquals(SessionFrame.STATE_DATUM_VAL, session.getNeededData());
EntityDatum entityDatum = (EntityDatum)session.getNeededDatum();
assertEquals("case_id", entityDatum.getDataId());
EvaluationContext ec = session.getEvaluationContext();
Vector<Action> actions = session.getDetail(entityDatum.getShortDetail()).getCustomActions(ec);
// Only 2 of the 3 actions should be returned, because 1 has a relevant condition of false()
assertEquals(2, actions.size());
Action actionToInspect = actions.get(1);
assertTrue(actionToInspect.hasActionBarIcon());
assertEquals("Jump to Menu 2 Form 1", actionToInspect.getDisplay().getText().evaluate(ec));
assertEquals(1, actionToInspect.getStackOperations().size());
}
示例6: buildActionView
import org.commcare.suite.model.Action; //导入依赖的package包/类
public static void buildActionView(FrameLayout actionCardView,
Action action,
CommCareActivity commCareActivity) {
DisplayData displayData = action.getDisplay().evaluate();
setupActionAudio(displayData.getAudioURI(), actionCardView);
setupActionImage(displayData.getImageURI(), actionCardView, commCareActivity);
TextView text = (TextView)actionCardView.findViewById(R.id.text);
text.setText(displayData.getName().toUpperCase());
setupActionClickListener(actionCardView, action, commCareActivity);
}
示例7: setupActionClickListener
import org.commcare.suite.model.Action; //导入依赖的package包/类
private static void setupActionClickListener(FrameLayout actionCardView,
final Action action,
final CommCareActivity commCareActivity) {
CardView cardView = (CardView)actionCardView.findViewById(R.id.card_body);
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EntitySelectActivity.triggerDetailAction(action, commCareActivity);
}
});
}
示例8: setupActionOptionsMenu
import org.commcare.suite.model.Action; //导入依赖的package包/类
private void setupActionOptionsMenu(Menu menu) {
if (shortSelect != null && !hideActionsFromOptionsMenu) {
int indexToAddActionAt = MENU_ACTION;
for (Action action : shortSelect.getCustomActions(evalContext())) {
if (action != null) {
ViewUtil.addActionToMenu(this, action, menu, indexToAddActionAt, MENU_ACTION_GROUP);
indexToAddActionAt += 1;
}
}
entitySelectSearchUI.setupActionImage(this.customCallout);
}
}
示例9: triggerDetailAction
import org.commcare.suite.model.Action; //导入依赖的package包/类
public static void triggerDetailAction(Action action, CommCareActivity activity) {
try {
CommCareApplication.instance().getCurrentSessionWrapper().executeStackActions(action.getStackOperations());
} catch (XPathTypeMismatchException e) {
UserfacingErrorHandling.logErrorAndShowDialog(activity, e, true);
return;
}
activity.setResult(HomeScreenBaseActivity.RESULT_RESTART);
activity.finish();
}
示例10: EntityListAdapter
import org.commcare.suite.model.Action; //导入依赖的package包/类
public EntityListAdapter(CommCareActivity activity, Detail detail,
List<TreeReference> references,
List<Entity<TreeReference>> full, NodeEntityFactory factory,
boolean hideActions, List<Action> actions, boolean inAwesomeMode) {
super(full, detail, factory);
this.detail = detail;
this.selectActivityInAwesomeMode = inAwesomeMode;
this.actions = actions;
if (actions == null || actions.isEmpty() || hideActions) {
actionsCount = 0;
dividerCount = 0;
} else {
actionsCount = actions.size();
dividerCount = 2;
}
this.full = full;
this.references = references;
this.commCareActivity = activity;
this.observers = new ArrayList<>();
this.mNodeFactory = factory;
if (android.os.Build.VERSION.SDK_INT >= 14) {
mImageLoader = new CachingAsyncImageLoader(commCareActivity);
} else {
mImageLoader = null;
}
this.usesCaseTiles = detail.usesEntityTileView();
this.mFuzzySearchEnabled = MainConfigurablePreferences.isFuzzySearchEnabled();
setCurrent(new ArrayList<>(full));
}
示例11: parse
import org.commcare.suite.model.Action; //导入依赖的package包/类
@Override
public Action parse() throws InvalidStructureException, IOException, XmlPullParserException {
this.checkNode(NAME_ACTION);
String iconForActionBarPlacement = parser.getAttributeValue(null, "action-bar-icon");
DisplayUnit display = null;
Vector<StackOperation> stackOps = new Vector<>();
XPathExpression relevantExpr = parseRelevancyExpr();
while (nextTagInBlock(NAME_ACTION)) {
if (parser.getName().equals("display")) {
display = parseDisplayBlock();
} else if (parser.getName().equals("stack")) {
StackOpParser sop = new StackOpParser(parser);
while (this.nextTagInBlock("stack")) {
stackOps.addElement(sop.parse());
}
}
}
if (display == null) {
throw new InvalidStructureException("<action> block must define a <display> element", parser);
}
if (stackOps.size() == 0) {
throw new InvalidStructureException("An <action> block must define at least one stack operation", parser);
}
return new Action(display, stackOps, relevantExpr, iconForActionBarPlacement);
}
示例12: basicMarkRewindTest
import org.commcare.suite.model.Action; //导入依赖的package包/类
/**
* Test rewinding and set needed datum occurs correctly
*/
@Test
public void basicMarkRewindTest() throws Exception {
MockApp mockApp = new MockApp("/stack-frame-copy-app/");
SessionWrapper session = mockApp.getSession();
session.setCommand("child-visit");
assertEquals(SessionFrame.STATE_DATUM_VAL, session.getNeededData());
assertEquals("mother_case_1", session.getNeededDatum().getDataId());
session.setDatum("mother_case_1", "nancy");
// perform 'claim' action
Detail shortDetail = session.getPlatform().getDetail("case-list");
Action action = shortDetail.getCustomActions(session.getEvaluationContext()).firstElement();
// queue up action
boolean didRewindOrNewFrame = session.executeStackOperations(action.getStackOperations(), session.getEvaluationContext());
assertFalse(didRewindOrNewFrame);
// test backing out of action
session.stepBack();
assertEquals("child_case_1", session.getNeededDatum().getDataId());
assertEquals(SessionFrame.STATE_DATUM_VAL, session.getFrame().getSteps().lastElement().getType());
// queue up action again
session.executeStackOperations(action.getStackOperations(), session.getEvaluationContext());
// finish action
didRewindOrNewFrame = session.finishExecuteAndPop(session.getEvaluationContext());
assertTrue(didRewindOrNewFrame);
// ensure we don't need any more data to perform the visit
assertEquals(SessionFrame.STATE_COMMAND_ID, session.getNeededData());
CaseTestUtils.xpathEvalAndAssert(session.getEvaluationContext(),
"instance('session')/session/data/child_case_1", "billy");
didRewindOrNewFrame = session.finishExecuteAndPop(session.getEvaluationContext());
assertFalse(didRewindOrNewFrame);
assertTrue(session.getFrame().isDead());
}
示例13: setPendingAction
import org.commcare.suite.model.Action; //导入依赖的package包/类
public void setPendingAction(Action pendingAction) {
this.mPendingAction = pendingAction;
}
示例14: getAction
import org.commcare.suite.model.Action; //导入依赖的package包/类
private Action getAction(int position) {
int baseActionPosition = dividerPosition + 1;
return actions.get(position - baseActionPosition);
}
示例15: testDoubleManagementAndOverlappingStack
import org.commcare.suite.model.Action; //导入依赖的package包/类
@Test
public void testDoubleManagementAndOverlappingStack() throws Exception {
mApp = new MockApp("/complex_stack/");
SessionWrapper session = mApp.getSession();
Assert.assertEquals(SessionFrame.STATE_COMMAND_ID, session.getNeededData());
session.setCommand("m0");
Assert.assertEquals(SessionFrame.STATE_DATUM_COMPUTED, session.getNeededData());
session.setComputedDatum();
Assert.assertEquals(SessionFrame.STATE_DATUM_VAL, session.getNeededData());
EntityDatum entityDatum = (EntityDatum)session.getNeededDatum();
Assert.assertEquals("case_id", entityDatum.getDataId());
Vector<Action> actions = session.getDetail(entityDatum.getShortDetail()).getCustomActions();
if(actions == null || actions.isEmpty()) {
Assert.fail("Detail screen stack action was missing from app!");
}
Action dblManagement = actions.firstElement();
session.executeStackOperations(dblManagement.getStackOperations(), session.getEvaluationContext());
if(session.getNeededData() != null) {
Assert.fail("After executing stack frame steps, session should be redirected");
}
Assert.assertEquals("http://commcarehq.org/test/placeholder_destination", session.getForm());
EvaluationContext ec = session.getEvaluationContext();
CaseTestUtils.xpathEvalAndCompare(ec,"count(instance('session')/session/data/calculated_data)", 1);
CaseTestUtils.xpathEvalAndCompare(ec,"instance('session')/session/data/calculated_data", "new");
}