List of usage examples for org.apache.commons.lang ArrayUtils indexOf
public static int indexOf(boolean[] array, boolean valueToFind)
Finds the index of the given value in the array.
From source file:org.eclipse.wb.internal.core.model.description.helpers.FactoryDescriptionHelper.java
/** * @return the {@link ParameterDescription} with name specified as first word of * <code>parameterString</code>. *///from w w w. j av a 2 s .c o m private static ParameterDescription getJavaDocParameter(FactoryMethodDescription description, String[] parameterNames, String parameterString) { String parameterName = StringUtils.split(parameterString)[0]; // prepare parameter index int parameterIndex; if (StringUtils.isNumeric(parameterName)) { parameterIndex = Integer.parseInt(parameterName); } else { parameterIndex = ArrayUtils.indexOf(parameterNames, parameterName); } // validate index if (parameterIndex < 0 || parameterIndex >= parameterNames.length) { throw new IllegalArgumentException("Invalid parameter string " + parameterName); } // OK, return parameter description return description.getParameter(parameterIndex); }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.EnumerationStylePropertyImpl.java
@Override public long getFlag(String sFlag) { int index = ArrayUtils.indexOf(m_sValues, sFlag); return index != ArrayUtils.INDEX_NOT_FOUND ? m_values[index] : 0; }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.EnumerationStylePropertyImpl.java
@Override public String getFlagValue(Property property) throws Exception { long value = getStyleValue(property) & m_flagsClearMask; int index = ArrayUtils.indexOf(m_values, value); return index != ArrayUtils.INDEX_NOT_FOUND ? m_sValues[index] : null; }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.EnumerationStylePropertyImpl.java
@Override public void setValue(Property property, Object value) throws Exception { long style = getStyleValue(property) & m_enumClearMask; if (value != Property.UNKNOWN_VALUE) { String sValue = (String) value; style |= m_values[ArrayUtils.indexOf(m_sValues, sValue)]; }/* w w w.j av a 2s . co m*/ setStyleValue(property, style); }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.MacroStylePropertyImpl.java
@Override public long getFlag(String sFlag) { return m_flags[ArrayUtils.indexOf(m_sFlags, sFlag)]; }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.SelectionStylePropertyImpl.java
public SelectionStylePropertyImpl(AbstractStylePropertyEditor editor, String title, long[] flags, String[] sFlags, long defaultFlag) { super(editor, title); m_flags = flags;/*from ww w .j a v a 2 s .c om*/ m_sFlags = sFlags; m_defaultIndex = ArrayUtils.indexOf(m_flags, defaultFlag); }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.SelectionStylePropertyImpl.java
@Override public void setValue(Property property, Object value) throws Exception { long style = getStyleValue(property) ^ getCurrentFlag(property); if (value != Property.UNKNOWN_VALUE) { String sFlag = (String) value; int index = ArrayUtils.indexOf(m_sFlags, sFlag); if (index != m_defaultIndex) { style |= m_flags[index];/*w w w . j a va2 s. co m*/ } } setStyleValue(property, style); }
From source file:org.eclipse.wb.internal.core.utils.ui.dialogs.color.ColorsGridComposite.java
/** * @return the rectangle for given color or <code>null</code> if <code>null</code> color given *///from w w w . j ava 2 s . co m private Rectangle getCellRectForColor(ColorInfo colorInfo) { if (colorInfo == null) { return null; } int index = ArrayUtils.indexOf(m_colors, colorInfo); return getCellRectForIndex(index); }
From source file:org.eclipse.wb.internal.css.dialogs.style.LengthValueEditor.java
private void updateControlsFromValue() { if (m_value.hasValue()) { String newValue = m_value.getValue(); if (!newValue.equals(m_valueCombo.getText())) { m_valueCombo.setText(newValue); }// ww w . j av a2s. com } else { m_valueCombo.setText(""); } // if (m_value.hasUnit()) { int index = ArrayUtils.indexOf(LengthValue.UNIT_NAMES, m_value.getUnit()); if (m_unitCombo.getSelectionIndex() != index) { m_unitCombo.select(index); } } if (!m_value.requiresUnit()) { m_unitCombo.setEnabled(false); } }
From source file:org.eclipse.wb.internal.css.semantics.BorderProperty.java
@Override public void parse(CssRuleNode rule) { m_width.clear();/*from w ww . ja v a 2 s.c om*/ m_style.clear(); m_color.clear(); for (CssDeclarationNode declaration : rule.getDeclarations()) { String property = declaration.getProperty().getValue(); String value = declaration.getValue().getValue(); // try to set single value { m_width.set(property, value); m_style.set(property, value); m_color.set(property, value); } // try to find shorthand { // determine side int side = -1; if ("border".equals(property)) { side = ALL_SIDES; } else if (property.startsWith("border-")) { side = ArrayUtils.indexOf(AbstractSidedProperty.SIDE_NAMES, property.substring("border-".length())); } // if side found, parse value if (side != -1) { clear(side); String[] parts = StringUtils.split(value); label_parts: for (int i = 0; i < parts.length; i++) { String part = parts[i]; // style if (ArrayUtils.indexOf(STYLES, part) != -1) { setSideValue(m_style, side, part); continue; } // width { // ends with unit for (int j = 0; j < LengthValue.UNIT_NAMES.length; j++) { String unit = LengthValue.UNIT_NAMES[j]; if (part.endsWith(unit)) { setSideValue(m_width, side, part); continue label_parts; } } // named width if (ArrayUtils.contains(SPECIAL_WIDTHS, part)) { setSideValue(m_width, side, part); continue; } } // if part is not style and not width, we consider it as color setSideValue(m_color, side, part); } } } } }