List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:com.sbcc.edu.jrollspellchecker.MainWindow.java
public ArrayList<String> cycle(ArrayList<String> words) { //old cycle method before I refined the code more, no longer in use index = spellChecker.spellCheck(words); if (index == -1) { this.setStatus("Done checking."); return null; } else {// w w w. j a v a2 s. c om this.setSpellCheckVisibility(true); this.curWord.setText(words.get(index)); words.remove(index); //use regex //create a class with ArrayList spellCheckText.setSelection(spellCheckText.getText().indexOf(curWord.getText()), spellCheckText.getText().indexOf(curWord.getText()) + curWord.getText().length()); //System.out.println(curWord.getText().length()); //column += words.get(index).length() + 1; //spellCheckText.get //cycle(words); } return words; }
From source file:com.bluexml.side.form.clazz.utils.SynchronizeWithClass.java
protected void synchronizeMissingAssociations(FormContainer o, List<FormElement> children, AbstractClass real_class, Set<FormGroup> groups, String filterNS) { List<Association> allAssociations = real_class.getAllSourceAssociations(); // get FormElement that miss ArrayList<Association> missAtt = new ArrayList<Association>(); if (allAssociations != null) { missAtt.addAll(allAssociations); }/* w ww . j a v a 2s . c o m*/ for (FormElement formElement : children) { ModelElement ref = formElement.getRef(); if (ref != null && ref instanceof Association) { // linked element is attribute so remove this attribute from the missing list missAtt.remove(ref); } } EList<FormGroup> allSubGroups = o.getAllSubGroups(); groups.addAll(allSubGroups); // now we have the attribute missing list // initialize missing Field for (Association ass : missAtt) { FormElement fieldForAssociation = null; if (o instanceof FormClass || o instanceof FormWorkflow) { fieldForAssociation = ClassDiagramUtils.getModelChoiceFieldForAssociation(ass, real_class); } else if (o instanceof FormSearch) { fieldForAssociation = ClassDiagramUtils.transformAssociationIntoModelChoiceSearchField(ass, real_class); } if (WorkflowInitialization.filterFormElement(filterNS, fieldForAssociation)) { // get where to add the field FormGroup parent = null; // mybe a group exist with ref to the attribute container // search for matching group for (FormGroup formGroup : groups) { ModelElement ref = formGroup.getRef(); if (ref instanceof AbstractClass && ((AbstractClass) ref).getSourceAssociations().contains(ass)) { // matching group founded parent = formGroup; break; } } if (createMissingGroup && parent == null) { AbstractClass source = null; EList<AbstractClass> sources = ass.getSource(); if (sources.size() == 1) { source = sources.get(0); } else { EList<AbstractClass> allLinkedAbstractClass = real_class.getAllLinkedAbstractClass(); boolean contains = allLinkedAbstractClass.contains(sources.get(0)); if (contains) { source = sources.get(0); } else { source = sources.get(1); } } parent = ClassInitialization.createGroup(source); addChild(o, parent); } // add new Field to the parent if (parent == null) { parent = o; } addChild(parent, fieldForAssociation); } } }
From source file:com.flexive.faces.javascript.yui.YahooResultProvider.java
/** * Moves the given column to the new index in the user's result preferences. * * @param encodedLocation the location, encoded using fx:encodeEnum * @param encodedViewType the view type, encoded using fx:encodeEnum * @param columnKey the column key (i.e. the property/assignment name) * @param index the new index (0-based), taking into account that the column was previously removed from the list * @return nothing/*from ww w . j ava2 s . co m*/ * @since 3.1 */ public String reorderResultColumn(long typeId, String encodedViewType, String encodedLocation, String columnKey, int index) throws FxApplicationException { final ResultViewType viewType = (ResultViewType) EnumConverter.getValue(encodedViewType); final ResultLocation location = (ResultLocation) EnumConverter.getValue(encodedLocation); final ResultPreferences preferences = getResultPreferencesEngine().load(typeId, viewType, location); final ArrayList<ResultColumnInfo> columns = Lists.newArrayList(preferences.getSelectedColumns()); if (columnKey.indexOf('/') != -1) { // assignment --> prefix with # columnKey = "#" + columnKey; } // get column index for columnKey ResultColumnInfo column = null; for (ResultColumnInfo rci : columns) { if (rci.getPropertyName().equalsIgnoreCase(columnKey)) { column = rci; break; } } if (column == null) { throw new FxUpdateException("ex.jsf.searchResult.resultPreferences.columnNotFound", columnKey); } // move column to new position columns.remove(columns.indexOf(column)); columns.add(index, column); // store new result preferences getResultPreferencesEngine().saveInSource(new ResultPreferences(columns, preferences.getOrderByColumns(), preferences.getRowsPerPage(), preferences.getThumbBoxSize()), typeId, viewType, location); return "[]"; }
From source file:com.google.dart.engine.internal.element.ClassElementImpl.java
@Override public boolean hasNonFinalField() { ArrayList<ClassElement> classesToVisit = new ArrayList<ClassElement>(); HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); classesToVisit.add(this); while (!classesToVisit.isEmpty()) { ClassElement currentElement = classesToVisit.remove(0); if (visitedClasses.add(currentElement)) { // check fields for (FieldElement field : currentElement.getFields()) { if (!field.isFinal() && !field.isConst() && !field.isStatic() && !field.isSynthetic()) { return true; }/* w w w.j a v a 2s .com*/ } // check mixins for (InterfaceType mixinType : currentElement.getMixins()) { ClassElement mixinElement = mixinType.getElement(); classesToVisit.add(mixinElement); } // check super InterfaceType supertype = currentElement.getSupertype(); if (supertype != null) { ClassElement superElement = supertype.getElement(); if (superElement != null) { classesToVisit.add(superElement); } } } } // not found return false; }
From source file:com.google.dart.engine.internal.element.ClassElementImpl.java
private void collectAllSupertypes(ArrayList<InterfaceType> supertypes) { ArrayList<InterfaceType> typesToVisit = new ArrayList<InterfaceType>(); ArrayList<ClassElement> visitedClasses = new ArrayList<ClassElement>(); typesToVisit.add(this.getType()); while (!typesToVisit.isEmpty()) { InterfaceType currentType = typesToVisit.remove(0); ClassElement currentElement = currentType.getElement(); if (!visitedClasses.contains(currentElement)) { visitedClasses.add(currentElement); if (currentType != this.getType()) { supertypes.add(currentType); }//from w ww .j a v a 2 s . c o m InterfaceType supertype = currentType.getSuperclass(); if (supertype != null) { typesToVisit.add(supertype); } for (InterfaceType type : currentElement.getInterfaces()) { typesToVisit.add(type); } for (InterfaceType type : currentElement.getMixins()) { ClassElement element = type.getElement(); if (!visitedClasses.contains(element)) { supertypes.add(type); } } } } }
From source file:de.mycrobase.jcloudapp.Main.java
private void uploadFilesFromClipboard(List<File> data) { if (data != null && data.size() > 0) { setImageWorking();// w ww . j av a 2 s .com ArrayList<String> urls = new ArrayList<String>(); for (File f : data) { JSONObject drop = upload(f); // cancel all uploads on error if (drop == null) { setImageNormal(); return; } String url = getDropUrl(drop); System.out.println("Upload complete, URL:\n" + url); urls.add(url); } int n = urls.size(); String text = urls.remove(0); for (String s : urls) { text += " " + s; } setClipboard(text); String msg; if (n == 1) { msg = String.format("Item: %s", data.get(0).getName()); } else { msg = String.format("%d Items: %s", n, data.get(0).getName()); int nchars = msg.length(); for (int i = 1; i < data.size(); i++) { if (nchars + data.get(i).getName().length() > 140) { msg += ", ..."; break; } else { msg += ", " + data.get(i).getName(); nchars += data.get(i).getName().length(); } } } setImageNormal(); icon.displayMessage("Upload finished", msg, TrayIcon.MessageType.INFO); } }
From source file:com.twitter.ambrose.hive.HiveDAGTransformer.java
/** * Converts job properties to a DAGNode representation * /*from www . jav a2s .c om*/ * @param task * @return * hive 1.1.4 no MapredWork.getAllOperators function, so add it here */ public List<Operator<?>> getAllOperators(MapredWork myWork) { ArrayList<Operator<?>> opList = new ArrayList<Operator<?>>(); ArrayList<Operator<?>> returnList = new ArrayList<Operator<?>>(); if (myWork.getReducer() != null) { opList.add(myWork.getReducer()); } Map<String, ArrayList<String>> pa = myWork.getPathToAliases(); if (pa != null) { for (List<String> ls : pa.values()) { for (String a : ls) { Operator<?> op = myWork.getAliasToWork().get(a); if (op != null) { opList.add(op); } } } } //recursively add all children while (!opList.isEmpty()) { Operator<?> op = opList.remove(0); if (op.getChildOperators() != null) { opList.addAll(op.getChildOperators()); } returnList.add(op); } return returnList; }
From source file:fr.natoine.PortletAnnotation.PortletCreateAnnotation.java
private void doDeleteSelection(ActionRequest request, ActionResponse response) { if (request.getParameter("cpt_selection") != null) { int _index_selection_to_delete = Integer.parseInt(request.getParameter("cpt_selection")); if (request.getPortletSession().getAttribute("selections") != null) { ArrayList _selections = (ArrayList) request.getPortletSession().getAttribute("selections"); Object _selection_to_delete = _selections.get(_index_selection_to_delete); if (_selection_to_delete instanceof HighlightSelectionHTML) this.sendEvent("todelete", (HighlightSelectionHTML) _selection_to_delete, response); _selections.remove(_index_selection_to_delete); request.getPortletSession().setAttribute("selections", _selections); } else/* w ww . j ava2 s. c om*/ System.out.println( "[PortletCreationAnnotation.doDeleteSelection] selections attribute doesn't exist"); } else System.out.println("[PortletCreationAnnotation.doDeleteSelection] no selection to delete"); }
From source file:com.google.android.apps.dashclock.ExtensionManager.java
public List<ExtensionWithData> getInternalActiveExtensionsWithData() { // Extract the data from the all active extension cache List<ComponentName> internalActiveExtensions = getInternalActiveExtensionNames(); ArrayList<ExtensionWithData> activeExtensions = new ArrayList<>( Arrays.asList(new ExtensionWithData[internalActiveExtensions.size()])); synchronized (mActiveExtensions) { for (ExtensionWithData ewd : mActiveExtensions) { int pos = internalActiveExtensions.indexOf(ewd.listing.componentName()); if (pos >= 0) { activeExtensions.set(pos, ewd); }//from w w w . ja v a 2s . c om } } // Clean any null/unset data int count = activeExtensions.size(); for (int i = count - 1; i >= 0; i--) { if (activeExtensions.get(i) == null) { activeExtensions.remove(i); } } return activeExtensions; }
From source file:lyonlancer5.karasu.block.BlockRedstoneWire.java
/** * Creates a list of all horizontal sides that can get powered by a wire. * The list is ordered the same as the facingsHorizontal. * // w ww . j ava 2 s .c o m * @param worldIn World * @param pos Position of the wire * @return List of all facings that can get powered by this wire */ private List<EnumFacing> getSidesToPower(World worldIn, BlockPos pos) { ArrayList<EnumFacing> retval = Lists.<EnumFacing>newArrayList(); for (EnumFacing facing : facingsHorizontal) { if (isPowerSourceAt(worldIn, pos, facing)) retval.add(facing); } if (retval.isEmpty()) return Lists.<EnumFacing>newArrayList(facingsHorizontal); boolean northsouth = retval.contains(EnumFacing.NORTH) || retval.contains(EnumFacing.SOUTH); boolean eastwest = retval.contains(EnumFacing.EAST) || retval.contains(EnumFacing.WEST); if (northsouth) { retval.remove(EnumFacing.EAST); retval.remove(EnumFacing.WEST); } if (eastwest) { retval.remove(EnumFacing.NORTH); retval.remove(EnumFacing.SOUTH); } return retval; }