public int getSelectedPriority() { String selected = selectionHandler.getSelectedKey(); if (selected == null) { return -1; } int idx = priorityItemList.indexOf(selected); return Priority.get(idx).getOrdinal(); }
public void notifyChange() { String value = searchSelectionHandler.getSelectedValue(); if (value == null) { value = ""; } assignee.setName(value); notifyChangeCommand.execute(); }
public void clear() { variableSearchSelectionHandler.clearSelection(); functionSearchSelectionHandler.clearSelection(); functionSearchService.clear(); removeParams(); clearErrors(); }
private void checkHandlerSelectedValue(String value) { assertEquals(value, handler.getSelectedKey()); assertEquals(value, handler.getSelectedValue()); assertEquals(value, handler.getDropDownMenuHeader()); } }
void onVariableChange() { clearErrors(); String variable = variableSearchSelectionHandler.getSelectedKey(); if (!isEmpty(variable)) { String type = variableSearchService.getOptionType(variable); functionSearchService.reload(type, () -> { functionSearchSelectionHandler.clearSelection(); view.getConditionSelectorDropDown().clear(); onConditionChange(); }); } else { functionSearchService.clear(); functionSearchSelectionHandler.clearSelection(); view.getConditionSelectorDropDown().clear(); view.setVariableError(translationService.getValue(VARIABLE_NOT_SELECTED_ERROR)); applyChange(); } }
@Test public void testSelectKeyWithoutSelectedValue() { LiveSearchSelectorItem firstItem = createItem("a"); handler.registerItem(firstItem); LiveSearchSelectorItem secondItem = createItem("b"); handler.registerItem(secondItem); LiveSearchSelectorItem thirdItem = createItem(SELECTED_ITEM_TEXT); handler.registerItem(thirdItem); handler.selectKey("a"); verify(handler).selectItem(firstItem); verify(firstItem).select(); checkHandlerSelectedValue("a"); handler.selectKey("b"); verify(handler).selectItem(secondItem); verify(secondItem).select(); verify(firstItem).reset(); checkHandlerSelectedValue("b"); handler.selectKey(SELECTED_ITEM_TEXT); verify(handler).selectItem(thirdItem); verify(thirdItem).select(); verify(secondItem).reset(); checkHandlerSelectedValue(SELECTED_ITEM_TEXT); }
@Override public void selectKey(TYPE key) { if(selectedItem != null && selectedItem.getKey().equals(key)) { return; } visibleItems.stream() .filter(item -> item.getKey().equals(key)) .findFirst() .ifPresent(item -> selectItem(item)); }
protected LiveSearchSelectorItem doTestSelectItem() { LiveSearchSelectorItem item = createItem(SELECTED_ITEM_TEXT); handler.registerItem(item); handler.selectItem(item); verify(item).select(); checkHandlerSelectedValue(SELECTED_ITEM_TEXT); verify(callback).execute(); return item; }
/** * For facilitating testing */ SingleLiveSearchSelectionHandler<String> newVariableSelectionHandler() { return new SingleLiveSearchSelectionHandler<>(); }
@Override public void selectKey(TYPE key) { if(selectedItem != null && selectedItem.getKey().equals(key)) { return; } visibleItems.stream() .filter(item -> item.getKey().equals(key)) .findFirst() .ifPresent(item -> selectItem(item)); }
@Test public void testSelectSecondItem() { LiveSearchSelectorItem firstItem = doTestSelectItem(); String secondSelected = SELECTED_ITEM_TEXT + "2"; LiveSearchSelectorItem secondItem = createItem(secondSelected); handler.registerItem(secondItem); handler.selectItem(secondItem); verify(secondItem).select(); verify(firstItem).reset(); checkHandlerSelectedValue(secondSelected); }
/** * For facilitating testing */ SingleLiveSearchSelectionHandler<String> newFunctionSelectionHandler() { return new SingleLiveSearchSelectionHandler<>(); }
public int getSelectedPriority() { String selected = selectionHandler.getSelectedKey(); if (selected == null) { return -1; } int idx = priorityItemList.indexOf(selected); return Priority.get(idx).getOrdinal(); }
public String getSelectedValue() { String hint = selectionHandler.getSelectedValue(); Entry entry = getEntryByHint(hint); return entry.getValue(); }
@Override public void registerItem(final LiveSearchSelectorItem<TYPE> item) { if(selectedItem != null && selectedItem.getKey().equals(item.getKey())) { visibleItems.remove(selectedItem); item.select(); selectedItem = item; } item.setSelectionCallback(() -> selectItem(item)); visibleItems.add(item); }
@Test public void testClearSelection() { LiveSearchSelectorItem item = doTestSelectItem(); handler.clearSelection(); verify(item).reset(); checkHandlerSelectedValue(null); }
public PerspectiveActivity getSelectedPerspective() { String selected = selectionHandler.getSelectedKey(); if (selected == null) { return null; } SyncBeanDef beanDef = activityBeansCache.getActivity(selected); PerspectiveActivity p = (PerspectiveActivity) beanDef.getInstance(); return p; }
public String getSelectedValue() { String hint = selectionHandler.getSelectedValue(); Entry entry = getEntryByHint(hint); return entry.getValue(); }
@Override public void registerItem(final LiveSearchSelectorItem<TYPE> item) { if(selectedItem != null && selectedItem.getKey().equals(item.getKey())) { visibleItems.remove(selectedItem); item.select(); selectedItem = item; } item.setSelectionCallback(() -> selectItem(item)); visibleItems.add(item); }
public PerspectiveActivity getSelectedPerspective() { String selected = selectionHandler.getSelectedKey(); if (selected == null) { return null; } SyncBeanDef beanDef = activityBeansCache.getActivity(selected); PerspectiveActivity p = (PerspectiveActivity) beanDef.getInstance(); return p; }