/** * Checks if a {@link CompoundButton} with a given text is checked. * * @param expectedClass the expected class, e.g. {@code CheckBox.class} or {@code * RadioButton.class} * @param text the text that is expected to be checked * @return {@code true} if {@code CompoundButton} is checked and {@code false} if it is not * checked */ public <T extends CompoundButton> boolean isButtonChecked(Class<T> expectedClass, String text) { waiter.waitForView(expectedClass, 0); ArrayList<T> list = viewFetcher.getCurrentViews(expectedClass); for (T button : list) { if (button.getText().equals(text) && button.isChecked()) return true; } return false; }
/** * Filters a collection of Views and returns a list that contains only Views with text that * matches a specified regular expression. * * @param views The collection of views to scan. * @param regex The text pattern to search for. * @return A list of views whose text matches the given regex. */ public static <T extends TextView> List<T> filterViewsByText(Iterable<T> views, Pattern regex) { final ArrayList<T> filteredViews = new ArrayList<T>(); for (T view : views) { if (view != null && regex.matcher(view.getText()).matches()) { filteredViews.add(view); } } return filteredViews; }
@Override public void bindView( final T itemData, final int position, final ItemDataClickListener imageClickListener) { expand.setLayoutParams(getParamsLayout(expand, itemData)); if (capitalized) { text.setText(itemData.getText().toUpperCase()); } else { text.setText(itemData.getText()); } setHandleInitiatedViewStatus(itemData, expand, count); setRelativeLayoutClickable(relativeLayout, itemData, imageClickListener, position); relativeLayout.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Toast.makeText(view.getContext(), "longclick", Toast.LENGTH_SHORT).show(); return false; } }); }
@NotNull public String getValue() { String text = myElement.getText(); final TextRange range = getRangeInElement(); try { return range.substring(text); } catch (StringIndexOutOfBoundsException e) { LOG.error( "Wrong range in reference " + this + ": " + range + ". Reference text: '" + text + "'", e); return text; } }
@NotNull protected String doExtract( final PsiDirectory targetDirectory, final String targetfileName, final T first, final T last, final Language includingLanguage) throws IncorrectOperationException { final PsiFile file = targetDirectory.createFile(targetfileName); Project project = targetDirectory.getProject(); final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); final Document document = documentManager.getDocument(file); document.replaceString(0, document.getTextLength(), first.getText().trim()); documentManager.commitDocument(document); CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()) .reformat(file); // TODO: adjustLineIndent final String relativePath = PsiFileSystemItemUtil.getRelativePath(first.getContainingFile(), file); if (relativePath == null) throw new IncorrectOperationException("Cannot extract!"); return relativePath; }
private void TActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_TActionPerformed // TODO add your handling code here: actualizaCampo(T.getText()); } // GEN-LAST:event_TActionPerformed
public static <T extends GrammarAST> List<String> nodesToStrings(List<T> nodes) { if (nodes == null) return null; List<String> a = new ArrayList<String>(); for (T t : nodes) a.add(t.getText()); return a; }