Example usage for java.util List indexOf

List of usage examples for java.util List indexOf

Introduction

In this page you can find the example usage for java.util List indexOf.

Prototype

int indexOf(Object o);

Source Link

Document

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Usage

From source file:com.tesora.dve.sql.schema.PETable.java

private static void updateColumnPositions(final SchemaContext sc, final PEKey source, final PEKey in) {
    final List<PEColumn> updated = in.getColumns(sc);
    for (final PEColumn sourceCol : source.getColumns(sc)) {
        final int index = updated.indexOf(sourceCol);
        if (index > -1) {
            final PEColumn updatedCol = updated.get(index);
            updatedCol.setPosition(sourceCol.getPosition());
        }//from   w ww.j  a  va  2  s.  c o m
    }
}

From source file:com.googlecode.osde.internal.editors.contents.SupportedViewsPart.java

public void changeModel() {
    ISelection selection = supportedViewList.getSelection();
    IStructuredSelection structured = (IStructuredSelection) selection;
    Object selected = structured.getFirstElement();
    List<ContentModel> models = getContentModels();
    int selectedIndex = models.indexOf(selected);
    int size = models.size();
    ////from   www . j a v a 2s .  com
    displayInitialValue();
    //
    models = getContentModels();
    if ((selectedIndex != -1) && (size == models.size())) {
        ContentModel model = models.get(selectedIndex);
        supportedViewList.setSelection(new StructuredSelection(model));
    }
}

From source file:au.org.ala.delta.model.image.Image.java

private void move(ImageOverlay overlay, int amount) {
    List<ImageOverlay> overlays = getOverlays();
    int index = overlays.indexOf(overlay);
    if (index < 0) {
        throw new IllegalArgumentException("No overlay exists with id: " + overlay.getId());
    }//  ww w.j a  va  2  s.com
    overlay = overlays.remove(index);
    int newIndex = index + amount;
    newIndex = Math.max(0, index + amount);
    newIndex = Math.min(overlays.size() - 1, newIndex);
    overlays.add(newIndex, overlay);

    _impl.setOverlays(overlays);

    notifyObservers();
}

From source file:org.openeos.services.ui.form.abstractform.UIBeanSelectorProvider.java

@Override
@Transactional(readOnly = true)//from   ww  w  .  j av  a  2 s.  c  o  m
public SortedSet<T> getElements() {
    Criteria crit = sessionFactory.getCurrentSession().createCriteria(beanClass);
    if (sqlRestriction != null && formInstance instanceof BFormInstance<?, ?>) {
        Object value = ((BFormInstance<?, ?>) formInstance).getValue();
        if (value instanceof UIBeanImpl) {
            value = ((UIBeanImpl) value).getBeanWrapped();
        }
        crit.add(buildSqlRestriction(sqlRestriction, value));
    }
    final List<T> listElements = crit.list();
    TreeSet<T> result = new TreeSet<T>(new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            return Integer.compare(listElements.indexOf(o1), listElements.indexOf(o2));
        }
    });
    result.addAll(listElements);
    return result;
}

From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogCellModifier.java

private int getIndex(String property) {

    List<FilterProperties> list = (List<FilterProperties>) viewer.getData(Constants.PARTITION_KEYS);
    FilterProperties properties = new FilterProperties();
    properties.setPropertyname(property);

    return list.indexOf(properties);

}

From source file:net.sourceforge.atunes.kernel.modules.playlist.DynamicPlayList.java

@Override
public void remove(final Collection<? extends IAudioObject> list) {
    // First get all positions of objects to remove
    List<IPlayListAudioObject> playListAudioObjects = new ArrayList<IPlayListAudioObject>();
    for (IAudioObject ao : list) {
        List<IAudioObject> clonedList = new ArrayList<IAudioObject>(this.audioObjects.getList());
        while (clonedList.indexOf(ao) != -1) {
            int index = clonedList.indexOf(ao);
            PlayListAudioObject playListAudioObject = new PlayListAudioObject();
            playListAudioObject.setPosition(index);
            playListAudioObject.setAudioObject(ao);
            playListAudioObjects.add(playListAudioObject);
            clonedList = clonedList.subList(index + 1, clonedList.size());
        }/* ww w.  j a v  a  2  s.  c om*/
    }

    // Sort in reverse order to remove last index first and avoid shift
    Collections.sort(playListAudioObjects, new PlayListAudioObjectComparator());

    for (IPlayListAudioObject plao : playListAudioObjects) {
        this.audioObjects.remove(plao.getPosition());
    }
    notifyAudioObjectsRemoved(playListAudioObjects);
}

From source file:info.magnolia.photoreview.app.container.InstagramContainer.java

@Override
public int indexOfId(Object itemId) {
    List<String> keys = new ArrayList<String>(items.keySet());
    return keys.indexOf(itemId);
}

From source file:org.wallerlab.yoink.adaptive.smooth.SCMPWeightFactors.java

private double fadeMM(Coord centerCoord, List<Molecule> bufferMolecules, List<Integer> bufferIndices,
        double s_qm_out, double t_qm_out, Set<Integer> mmSet) {
    double fadeMM = 1.0;
    for (Integer molecularIndex : mmSet) {
        int index = bufferIndices.indexOf(molecularIndex);
        Molecule molecule = bufferMolecules.get(index);
        double currentDistance = closestDistanceToMoleculeCalculator.calculate(centerCoord, molecule);
        double lamdba = buloSmoothFunction.evaluate(currentDistance, s_qm_out, t_qm_out);
        fadeMM *= lamdba;//from  ww w.  j a  v  a  2  s  . c  o m
    }
    return fadeMM;
}

From source file:org.wallerlab.yoink.adaptive.smooth.SCMPWeightFactors.java

private double fadeQM(Coord centerCoord, List<Molecule> bufferMolecules, List<Integer> bufferIndices,
        double s_qm_out, double t_qm_out, List<Integer> qmSet) {
    double fadeQM = 1.0;
    for (Integer molecularIndex : qmSet) {
        int index = bufferIndices.indexOf(molecularIndex);
        Molecule molecule = bufferMolecules.get(index);
        double currentDistance = closestDistanceToMoleculeCalculator.calculate(centerCoord, molecule);
        double lamdba = scmpSmoothFunction.evaluate(currentDistance, s_qm_out, t_qm_out);
        fadeQM *= lamdba;/*from w  w  w. j  a  v a 2 s .c o  m*/
    }
    return fadeQM;
}

From source file:com.ocs.dynamo.domain.model.impl.EntityModelImpl.java

@Override
public void addAttributeModel(String attributeGroup, AttributeModel model, AttributeModel existingModel) {
    List<AttributeModel> group = attributeModels.get(attributeGroup);
    if (group.contains(existingModel)) {
        group.add(group.indexOf(existingModel), model);
    } else {//from   w  ww.  ja  v a 2  s  .c  om
        group.add(model);
    }
}