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.os.win32.OSSupportWin32.java
@Override public final Rectangle getTabItemBounds(Object tabItemObject) { TabFolder tabFolder = ((TabItem) tabItemObject).getParent(); int index = ArrayUtils.indexOf(tabFolder.getItems(), tabItemObject); int[] bounds = new int[4]; getTabItemBounds(tabFolder, index, bounds); // convert into Rectangle int borderOffset = (tabFolder.getStyle() & SWT.BORDER) != 0 ? 2 : 0; int x = bounds[0]/*itemRect.left*/ + borderOffset; int y = bounds[2]/*itemRect.top*/ + borderOffset; int width = bounds[1]/*itemRect.right*/ - bounds[0]/*itemRect.left*/; int height = bounds[3]/*itemRect.bottom*/ - bounds[2]/*itemRect.top*/; return new Rectangle(x, y, width, height); }
From source file:org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.TextSwtObservableInfo.java
public static List<String> getEventsSources(int[] updateEvents) { List<String> updateEventStrings = Lists.newArrayList(); if (updateEvents.length == 1) { int updateEventTypeIndex = ArrayUtils.indexOf(VALID_UPDATE_EVENT_TYPES, updateEvents[0]); Assert.isTrue(updateEventTypeIndex >= 0 && updateEventTypeIndex < VALID_UPDATE_EVENT_TYPES.length); updateEventStrings.add(TEXT_EVENTS[updateEventTypeIndex]); } else {/*from w w w. ja v a2s . c om*/ for (int i = 0; i < updateEvents.length; i++) { int eventValue = updateEvents[i]; int updateEventTypeIndex = ArrayUtils.indexOf(VALID_UPDATE_EVENT_TYPES, eventValue); Assert.isTrue(eventValue != SWT.NONE && updateEventTypeIndex >= 0 && updateEventTypeIndex < VALID_UPDATE_EVENT_TYPES.length); updateEventStrings.add(TEXT_EVENTS[updateEventTypeIndex]); } } return updateEventStrings; }
From source file:org.eclipse.wb.internal.rcp.databinding.xwt.model.BindingInfo.java
public void setMode(String mode) { if (mode == null) { m_mode = 0;//from ww w . j a v a2 s. c om } else { m_mode = ArrayUtils.indexOf(modes, mode.toLowerCase()); if (m_mode == -1) { m_mode = 0; } } }
From source file:org.eclipse.wb.internal.rcp.databinding.xwt.model.BindingInfo.java
public void setTrigger(String trigger) { if (trigger == null) { m_trigger = 0;/* w w w . j a v a 2 s .c om*/ } else { m_trigger = ArrayUtils.indexOf(triggers, trigger.toLowerCase()); if (m_trigger == -1) { m_trigger = 0; } } }
From source file:org.eclipse.wb.internal.rcp.model.widgets.AbstractPositionCompositeInfo.java
/** * Moves existing {@link ControlInfo} and associates it with this * {@link AbstractPositionCompositeInfo} using method with given name. */// w ww . j a v a 2s.com public final void command_MOVE(ControlInfo control, String methodName) throws Exception { // prepare "nextControl", to add before it ControlInfo nextControl = null; { int index = ArrayUtils.indexOf(m_methods, methodName); Assert.isLegal(index >= 0, "Invalid method: " + methodName); for (int i = index + 1; i < m_methods.length; i++) { String method = m_methods[i]; ControlInfo methodControl = getControl(method); if (methodControl != null && methodControl != control) { nextControl = methodControl; break; } } } // do move AssociationObject association = getAssociation_(methodName); JavaInfoUtils.move(control, association, this, nextControl); }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormLayoutConverter.java
/** * @return the {@link Alignment} corresponding to the minimum delta value. *//*from www .j a v a 2s.c o m*/ private static Alignment getAlignment(int[] deltas, Alignment[] alignments) { int minimum; { minimum = Integer.MAX_VALUE; for (int i = 0; i < deltas.length; i++) { int delta = deltas[i]; minimum = Math.min(minimum, delta); } } // return corresponding alignment return alignments[ArrayUtils.indexOf(deltas, minimum)]; }
From source file:org.eclipse.wb.internal.swing.MigLayout.model.MigLayoutConverter.java
/** * @return the {@link Alignment} corresponding to the minimum delta value. */// w ww . ja v a2s . co m private static <A extends Enum<?>> A getAlignment(int[] deltas, A[] alignments) { int minimum; { minimum = Integer.MAX_VALUE; for (int i = 0; i < deltas.length; i++) { int delta = deltas[i]; minimum = Math.min(minimum, delta); } } // return corresponding alignment return alignments[ArrayUtils.indexOf(deltas, minimum)]; }
From source file:org.eclipse.wb.internal.xwt.model.property.editor.style.impl.SelectionStylePropertyImpl.java
public SelectionStylePropertyImpl(StylePropertyEditor editor, String title, long[] flags, String[] sFlags, long defaultFlag) { super(editor, title); m_flags = flags;// ww w . ja v a2 s . co m m_sFlags = sFlags; m_defaultIndex = ArrayUtils.indexOf(m_flags, defaultFlag); }
From source file:org.eclipse.wb.internal.xwt.model.property.editor.style.impl.SelectionStylePropertyImpl.java
@Override public void setValue(Property property, Object value) throws Exception { long style = getStyle(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];//from ww w.java 2 s. c om } } setStyleValue(property, style); }
From source file:org.eclipse.wb.internal.xwt.model.widgets.AbstractPositionCompositeInfo.java
/** * @return the {@link ControlInfo} to use as reference when move into given position. *//*from w ww.ja v a 2s . com*/ private ControlInfo getNextControl(ControlInfo movingControl, String property) { int index = ArrayUtils.indexOf(m_properties, property); Assert.isLegal(index >= 0, "Invalid position: " + property); for (int i = index + 1; i < m_properties.length; i++) { String method = m_properties[i]; ControlInfo propertyControl = getControl(method); if (propertyControl != null && propertyControl != movingControl) { return propertyControl; } } return null; }