List of usage examples for java.util List indexOf
int indexOf(Object o);
From source file:com.nextep.designer.sqlclient.ui.services.impl.SQLClientService.java
private boolean isGrantedForInsert(ISQLRowModificationStatus status, ISQLRowResult row, IBasicTable table) { final List<String> selectedColumnNames = new ArrayList<String>(); // Upper-casing column names as JDBC metadata may alter case on column names for (String columnName : status.getRowColumnNames()) { selectedColumnNames.add(columnName.toUpperCase()); }// ww w . jav a2 s . c o m // Checking whether NOT NULL columns have correct not null row values for (IBasicColumn column : table.getColumns()) { if (column.isNotNull()) { int columnIndex = selectedColumnNames.indexOf(column.getName().toUpperCase()); if (columnIndex >= 0) { final Object columnValue = row.getValues().get(columnIndex); // If value is null we stop, as the row is not yet granted if (columnValue == null) { return false; } } } } // Every column value passed the NOT NULL check return true; }
From source file:com.twinsoft.convertigo.beans.core.RequestableStep.java
/** * Get representation of order for quick sort of a given database object. */// w w w .j av a 2s.c o m @Override public Object getOrder(Object object) throws EngineException { if (object instanceof Variable) { List<Long> ordered = orderedVariables.get(0); long time = ((Variable) object).priority; if (ordered.contains(time)) return (long) ordered.indexOf(time); else throw new EngineException("Corrupted variable for step \"" + getName() + "\". Variable \"" + ((Variable) object).getName() + "\" with priority \"" + time + "\" isn't referenced anymore."); } else return super.getOrder(object); }
From source file:ch.systemsx.cisd.openbis.generic.server.business.importer.DatabaseInstanceImporter.java
private int[] createIndexMap(String tableName, SimpleDatabaseMetaData currentMetaData, SimpleDatabaseMetaData metaData) { final SimpleTableMetaData tableMetaData = metaData.tryToGetTableMetaData(tableName); final SimpleTableMetaData currentTableMetaData = currentMetaData.tryToGetTableMetaData(tableName); List<String> columnNames = tableMetaData.getColumnNames(); int tableColumnsCount = columnNames.size(); List<String> currentColumnNames = currentTableMetaData.getColumnNames(); int currentTableColumnsCount = currentColumnNames.size(); if (tableColumnsCount != currentTableColumnsCount) { throw new UserFailureException("Current table has " + currentTableColumnsCount + " columns but imported one " + tableColumnsCount + " columns."); }/*w w w. j ava 2 s . co m*/ final int[] indexMap = new int[tableColumnsCount]; for (int i = 0; i < indexMap.length; i++) { String currentColumnName = currentColumnNames.get(i); indexMap[i] = columnNames.indexOf(currentColumnName); } return indexMap; }
From source file:com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl.java
@Override public int indexOfId(K itemId) { if (itemId == null) return -1; Collection<T> collection = getCollection(); if (CollectionUtils.isNotEmpty(collection)) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.indexOf(currentItem); }/* w ww .j a va 2s.co m*/ return -1; }
From source file:com.all.client.model.LocalPlaylist.java
public final void _moveTracks(List<Track> movedTracks, int row) { int currentRow = row; List<Track> tracks = null; if (!isSmartPlaylist()) { tracks = new ArrayList<Track>(getTracks()); } else {//from w w w. j av a2 s.c o m tracks = getTracks(); } for (Track track : movedTracks) { int indexOf = tracks.indexOf(track); if (indexOf >= 0 && indexOf <= currentRow) { currentRow--; } } tracks.removeAll(movedTracks); tracks.addAll(currentRow, movedTracks); if (!isSmartPlaylist()) { int i = 0; for (Track track : tracks) { PlaylistTrack playlistTrack = getPlaylistTrack(track); playlistTrack.setTrackPosition(i); i++; } } }
From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java
@Override public boolean saveSettings(Element element) { element.addAttribute("horizontalScroll", String.valueOf(table.isHorizontalScrollEnabled())); saveFontPreferences(element);//from w w w . java 2 s .c om Element columnsElem = element.element("columns"); if (columnsElem != null) { element.remove(columnsElem); } columnsElem = element.addElement("columns"); final List<TableColumn> visibleTableColumns = table.getColumns(); final List<Table.Column> visibleColumns = new ArrayList<>(); for (TableColumn tableColumn : visibleTableColumns) { visibleColumns.add((Table.Column) tableColumn.getIdentifier()); } List<TableColumn> columns = table.getColumns(true); Collections.sort(columns, new Comparator<TableColumn>() { @SuppressWarnings("SuspiciousMethodCalls") @Override public int compare(TableColumn col1, TableColumn col2) { if (col1 instanceof TableColumnExt && !((TableColumnExt) col1).isVisible()) { return 1; } if (col2 instanceof TableColumnExt && !((TableColumnExt) col2).isVisible()) { return -1; } int i1 = visibleColumns.indexOf(col1.getIdentifier()); int i2 = visibleColumns.indexOf(col2.getIdentifier()); return Integer.compare(i1, i2); } }); for (TableColumn column : columns) { Element colElem = columnsElem.addElement("column"); colElem.addAttribute("id", column.getIdentifier().toString()); int width = column.getWidth(); colElem.addAttribute("width", String.valueOf(width)); if (column instanceof TableColumnExt) { Boolean visible = ((TableColumnExt) column).isVisible(); colElem.addAttribute("visible", visible.toString()); } } if (table.getRowSorter() != null) { TableColumn sortedColumn = table.getSortedColumn(); List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys(); if (sortedColumn != null && !sortKeys.isEmpty()) { columnsElem.addAttribute("sortColumn", String.valueOf(sortedColumn.getIdentifier())); columnsElem.addAttribute("sortOrder", sortKeys.get(0).getSortOrder().toString()); } } return true; }
From source file:com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl.java
@Override public K nextItemId(K itemId) { if (itemId == null) return null; Collection<T> collection = getCollection(); if ((collection != null) && !collection.isEmpty() && !itemId.equals(lastItemId())) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.get(list.indexOf(currentItem) + 1).getId(); }//w w w .j av a 2 s.c om return null; }
From source file:com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl.java
@Override public K prevItemId(K itemId) { if (itemId == null) return null; Collection<T> collection = getCollection(); if ((collection != null) && !collection.isEmpty() && !itemId.equals(firstItemId())) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.get(list.indexOf(currentItem) - 1).getId(); }/* w ww .ja va 2 s .com*/ return null; }
From source file:com.shootoff.config.Configuration.java
private void readConfigurationFile() throws IOException, ConfigurationException { Properties prop = new Properties(); InputStream inputStream;//from w ww . j a va 2 s .co m if (configInput != null) { inputStream = configInput; } else { inputStream = new FileInputStream(configName); } if (inputStream != null) { prop.load(inputStream); } else { throw new FileNotFoundException("Could not read configuration file " + configName); } if (prop.containsKey(WEBCAMS_PROP)) { List<String> webcamNames = new ArrayList<String>(); List<String> webcamInternalNames = new ArrayList<String>(); for (String nameString : prop.getProperty(WEBCAMS_PROP).split(",")) { String[] names = nameString.split(":"); if (names.length > 1) { webcamNames.add(names[0]); webcamInternalNames.add(names[1]); } } for (Camera webcam : Camera.getWebcams()) { int cameraIndex = webcamInternalNames.indexOf(webcam.getName()); if (cameraIndex >= 0) { webcams.put(webcamNames.get(cameraIndex), webcam); } } } if (prop.containsKey(DETECTION_RATE_PROP)) { setDetectionRate(Integer.parseInt(prop.getProperty(DETECTION_RATE_PROP))); } if (prop.containsKey(LASER_INTENSITY_PROP)) { setLaserIntensity(Integer.parseInt(prop.getProperty(LASER_INTENSITY_PROP))); } if (prop.containsKey(MARKER_RADIUS_PROP)) { setMarkerRadius(Integer.parseInt(prop.getProperty(MARKER_RADIUS_PROP))); } if (prop.containsKey(IGNORE_LASER_COLOR_PROP)) { String colorName = prop.getProperty(IGNORE_LASER_COLOR_PROP); if (!colorName.equals("None")) { setIgnoreLaserColor(true); setIgnoreLaserColorName(colorName); } } if (prop.containsKey(USE_RED_LASER_SOUND_PROP)) { setUseRedLaserSound(Boolean.parseBoolean(prop.getProperty(USE_RED_LASER_SOUND_PROP))); } if (prop.containsKey(RED_LASER_SOUND_PROP)) { setRedLaserSound(new File(prop.getProperty(RED_LASER_SOUND_PROP))); } if (prop.containsKey(USE_GREEN_LASER_SOUND_PROP)) { setUseGreenLaserSound(Boolean.parseBoolean(prop.getProperty(USE_GREEN_LASER_SOUND_PROP))); } if (prop.containsKey(GREEN_LASER_SOUND_PROP)) { setGreenLaserSound(new File(prop.getProperty(GREEN_LASER_SOUND_PROP))); } if (prop.containsKey(USE_VIRTUAL_MAGAZINE_PROP)) { setUseVirtualMagazine(Boolean.parseBoolean(prop.getProperty(USE_VIRTUAL_MAGAZINE_PROP))); } if (prop.containsKey(VIRTUAL_MAGAZINE_CAPACITY_PROP)) { setVirtualMagazineCapacity(Integer.parseInt(prop.getProperty(VIRTUAL_MAGAZINE_CAPACITY_PROP))); } if (prop.containsKey(USE_MALFUNCTIONS_PROP)) { setMalfunctions(Boolean.parseBoolean(prop.getProperty(USE_MALFUNCTIONS_PROP))); } if (prop.containsKey(MALFUNCTIONS_PROBABILITY_PROP)) { setMalfunctionsProbability(Float.parseFloat(prop.getProperty(MALFUNCTIONS_PROBABILITY_PROP))); } validateConfiguration(); }
From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java
private void updateFilter() { if (highlighter != null) { jConquersTable.removeHighlighter(highlighter); }/*from w ww . j a va 2s.co m*/ final List<String> columns = new LinkedList<>(); for (Object o : jXColumnList.getSelectedValues()) { columns.add((String) o); } if (!jFilterRows.isSelected()) { jConquersTable.setRowFilter(null); final List<Integer> relevantCols = new LinkedList<>(); List<TableColumn> cols = jConquersTable.getColumns(true); for (int i = 0; i < jConquersTable.getColumnCount(); i++) { TableColumnExt col = jConquersTable.getColumnExt(i); if (col.isVisible() && columns.contains(col.getTitle())) { relevantCols.add(cols.indexOf(col)); } } for (Integer col : relevantCols) { PatternPredicate patternPredicate0 = new PatternPredicate( (jFilterCaseSensitive.isSelected() ? "" : "(?i)") + Matcher.quoteReplacement(jTextField1.getText()), col); MattePainter mp = new MattePainter(new Color(0, 0, 0, 120)); highlighter = new PainterHighlighter( new HighlightPredicate.NotHighlightPredicate(patternPredicate0), mp); jConquersTable.addHighlighter(highlighter); } } else { jConquersTable.setRowFilter(new RowFilter<TableModel, Integer>() { @Override public boolean include(Entry<? extends TableModel, ? extends Integer> entry) { final List<Integer> relevantCols = new LinkedList<>(); List<TableColumn> cols = jConquersTable.getColumns(true); for (int i = 0; i < jConquersTable.getColumnCount(); i++) { TableColumnExt col = jConquersTable.getColumnExt(i); if (col.isVisible() && columns.contains(col.getTitle())) { relevantCols.add(cols.indexOf(col)); } } for (Integer col : relevantCols) { if (jFilterCaseSensitive.isSelected()) { if (entry.getStringValue(col).contains(jTextField1.getText())) { return true; } } else { if (entry.getStringValue(col).toLowerCase() .contains(jTextField1.getText().toLowerCase())) { return true; } } } return false; } }); } }