List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_OBJECT_ARRAY
Object[] EMPTY_OBJECT_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_OBJECT_ARRAY.
Click Source Link
Object
array. From source file:com.google.gdt.eclipse.designer.model.widgets.GwtHierarchyProvider.java
@Override public Object[] getChildrenObjects(Object object) throws Exception { // com.google.gwt.user.cellview.client.CellTable if (isUserClass(object, "com.google.gwt.user.cellview.client.CellTable")) { List<?> columnList = CellTableInfo.getColumnObjects(object); return columnList.toArray(new Object[columnList.size()]); }// ww w .ja va 2s .c om // com.google.gwt.user.client.ui.IndexedPanel if (isUserClass(object, "com.google.gwt.user.client.ui.IndexedPanel")) { int widgetCount = (Integer) ReflectionUtils.invokeMethod(object, "getWidgetCount()"); Object widgets[] = new Object[widgetCount]; for (int i = 0; i < widgetCount; i++) { widgets[i] = ReflectionUtils.invokeMethod(object, "getWidget(int)", i); } return widgets; } // com.google.gwt.user.client.ui.IndexedPanel if (isUserClass(object, "com.google.gwt.user.client.ui.Composite")) { Object widget = ReflectionUtils.invokeMethod(object, "getWidget()"); if (widget != null) { return new Object[] { widget }; } } // com.google.gwt.user.client.Element if (isUserClass(object, "com.google.gwt.user.client.Element")) { Class<?> domClass = getEditorLoader().loadClass("com.google.gwt.user.client.DOM"); int childCount = (Integer) ReflectionUtils.invokeMethod(domClass, "getChildCount(com.google.gwt.user.client.Element)", object); Object children[] = new Object[childCount]; for (int i = 0; i < childCount; i++) { children[i] = ReflectionUtils.invokeMethod(domClass, "getChild(com.google.gwt.user.client.Element,int)", object, i); } return children; } // unknown return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:com.google.gdt.eclipse.designer.model.property.ImagePrototypePropertyEditor.java
@Override protected void openDialog(Property property) throws Exception { ElementTreeSelectionDialog selectionDialog; {/*from www .j av a2s . c om*/ selectionDialog = new ElementTreeSelectionDialog(m_parentShell, new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof ImageBundleInfo) { return ObjectsLabelProvider.INSTANCE.getImage(element); } if (element instanceof ImageBundlePrototypeDescription) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element; return prototype.getIcon(); } return null; } @Override public String getText(Object element) { if (element instanceof ImageBundleInfo) { return ObjectsLabelProvider.INSTANCE.getText(element); } if (element instanceof ImageBundlePrototypeDescription) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element; return prototype.getMethod().getName() + "()"; } return null; } }, new ITreeContentProvider() { public Object[] getElements(Object inputElement) { return ImageBundleContainerInfo.getBundles((JavaInfo) inputElement).toArray(); } public Object[] getChildren(Object parentElement) { if (parentElement instanceof ImageBundleInfo) { return ((ImageBundleInfo) parentElement).getPrototypes().toArray(); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } public Object getParent(Object element) { if (element instanceof ImageBundlePrototypeDescription) { return ((ImageBundlePrototypeDescription) element).getBundle(); } return null; } public boolean hasChildren(Object element) { return getChildren(element).length != 0; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }) { @Override public void create() { super.create(); getTreeViewer().expandAll(); } @Override protected Control createDialogArea(Composite parent) { return super.createDialogArea(parent); } }; // validator selectionDialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { if (selection.length == 1 && selection[0] instanceof ImageBundlePrototypeDescription) { return StatusUtils.OK_STATUS; } else { return StatusUtils.ERROR_STATUS; } } }); // configure selectionDialog.setAllowMultiple(false); selectionDialog.setTitle(property.getTitle()); selectionDialog.setMessage("Select prototype:"); // set input selectionDialog.setInput(m_rootJavaInfo); // set initial selection selectionDialog.setInitialSelection(property.getValue()); } // open dialog if (selectionDialog.open() == Window.OK) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) selectionDialog .getFirstResult(); property.setValue(prototype); } }
From source file:com.google.gdt.eclipse.designer.model.widgets.support.CssSupport.java
/** * @return <code>true</code> if one or more CSS files were modified (and schedules them for * reloading with next refresh). *///from w ww .jav a2s. co m boolean isModified() { waitRequestSet.clear(); waitApplySet.clear(); boolean modified = false; // check CSS files boolean hasModifiedCSSFiles = false; for (Map.Entry<IFile, Long> entry : filesStampMap.entrySet()) { IFile file = entry.getKey(); long storedStamp = entry.getValue(); long fileStamp = file.getModificationStamp(); if (fileStamp != storedStamp) { modified = true; filesStampMap.put(file, fileStamp); hasModifiedCSSFiles = true; } } // schedule CSS load waiting if (hasModifiedCSSFiles) { synchronized (waitRequestSet) { for (String resource : resources) { String waitRequestName = getWaitRequestName(resource); waitRequestSet.add(waitRequestName); } } } // if has modified CSS files, ask Browser for reload if (modified) { ExecutionUtils.runLog(new RunnableEx() { public void run() throws Exception { state.getHostModeSupport().invokeNativeVoid("__reload_css", ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY); } }); waitFor(); } // return final modification state return modified; }
From source file:com.google.gdt.eclipse.designer.mobile.preferences.device.DevicesPreferencePage.java
/** * Creates {@link CheckboxTreeViewer} for categories/devices. *//* w w w .ja v a 2s.c o m*/ private void createViewer(Composite parent) { m_viewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI); GridDataFactory.create(m_viewer.getTree()).grab().fill().hintC(50, 20); // content provider m_viewer.setContentProvider(new ITreeContentProvider() { public Object[] getElements(Object inputElement) { return DeviceManager.getCategories().toArray(); } public Object[] getChildren(Object parentElement) { if (parentElement instanceof CategoryInfo) { return ((CategoryInfo) parentElement).getDevices().toArray(); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } public boolean hasChildren(Object element) { return getChildren(element).length != 0; } public Object getParent(Object element) { if (element instanceof DeviceInfo) { return ((DeviceInfo) element).getCategory(); } return null; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); // label provider m_viewer.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof CategoryInfo) { return IMAGE_CATEGORY; } return IMAGE_DEVICE; } @Override public String getText(Object element) { if (element instanceof CategoryInfo) { CategoryInfo category = (CategoryInfo) element; return category.getName(); } else if (element instanceof DeviceInfo) { DeviceInfo device = (DeviceInfo) element; return device.getName() + " - " + device.getDisplayBounds().width + "x" + device.getDisplayBounds().height; } return null; } }); // set input m_viewer.setInput(this); refreshViewer(); refreshViewChecks(); // listeners m_viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { AbstractDeviceInfo element = (AbstractDeviceInfo) event.getElement(); commands_add(new ElementVisibilityCommand(element, event.getChecked())); } }); m_viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); updatePreview(); } }); m_viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (m_editButton.isEnabled()) { onEdit(); } } }); // DND configureDND(); }
From source file:net.navasoft.madcoin.backend.services.vo.request.SuccessRequestVOWrapper.java
/** * Gets the processing values./*ww w . ja va 2 s . c o m*/ * * @param service * the service * @since 27/07/2014, 06:49:08 PM */ @Override public void processValues(IService service) { if (isValidService(service)) { for (ProcessedField annotatedField : getTarget(service)) { for (Method accessor : filterMethods()) { Annotation annot = accessor.getAnnotation(ProcessingField.class); if (annot != null) { ProcessingField expectedReal = ((ProcessingField) annot); if (!ArrayUtils.contains(alreadyProcessed, expectedReal.expectedVariable())) { try { if (validateProcessAnnotations(annotatedField, expectedReal)) { Object requestValue = null; switch (expectedReal.precedence()) { case BASIC_OPTIONAL: requestValue = accessor.invoke(hidden, ArrayUtils.EMPTY_OBJECT_ARRAY); processed.put(expectedReal.expectedVariable(), requestValue); alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed, expectedReal.expectedVariable()); break; case BASIC_REQUIRED: requestValue = accessor.invoke(this.hidden, ArrayUtils.EMPTY_OBJECT_ARRAY); processed.put(expectedReal.expectedVariable(), requestValue); alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed, expectedReal.expectedVariable()); break; case COMPLEX_OPTIONAL: requestValue = expectedReal.helperClass().newInstance(); processed.put(expectedReal.expectedVariable(), expectedReal.helperClass() .getMethod(expectedReal.converterMethod(), ArrayUtils.EMPTY_CLASS_ARRAY) .invoke(requestValue, ArrayUtils.EMPTY_OBJECT_ARRAY)); alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed, expectedReal.expectedVariable()); break; case COMPLEX_REQUIRED: requestValue = expectedReal.helperClass().newInstance(); processed.put(expectedReal.expectedVariable(), expectedReal.helperClass() .getMethod(expectedReal.converterMethod(), ArrayUtils.EMPTY_CLASS_ARRAY) .invoke(requestValue, ArrayUtils.EMPTY_OBJECT_ARRAY)); alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed, expectedReal.expectedVariable()); break; default: break; } } } catch (IllegalAccessException e1) { } catch (IllegalArgumentException e1) { } catch (InvocationTargetException e1) { } catch (NoSuchMethodException e) { } catch (SecurityException e) { } catch (InstantiationException e) { } } } } } } }
From source file:com.opengamma.financial.analytics.model.YieldCurveNodeSensitivitiesHelper.java
public static Set<ComputedValue> getTimeLabelledSensitivitiesForCurve(final List<DoublesPair> resultList, final ValueSpecification resultSpec) { final int n = resultList.size(); final Double[] keys = new Double[n]; final double[] values = new double[n]; final Object[] labels = new Object[n]; LabelledMatrix1D<Double, Double> labelledMatrix = new DoubleLabelledMatrix1D( ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_DOUBLE_ARRAY); for (int i = 0; i < n; i++) { final DoublesPair pair = resultList.get(i); keys[i] = pair.first;//from www .j ava 2 s .c o m values[i] = pair.second; labels[i] = s_formatter.format(pair.first); labelledMatrix = labelledMatrix.add(pair.first, s_formatter.format(pair.first), pair.second, 1e-16); } return Collections.singleton(new ComputedValue(resultSpec, labelledMatrix)); }
From source file:com.google.gdt.eclipse.designer.uibinder.parser.UiBinderParser.java
/** * @return the instance of given {@link Class}. *///from w w w . j av a 2s .c om static Object createProvidedField(UiBinderContext context, Class<?> fieldType, String fieldName) throws Exception { try { return createObjectInstance(context, fieldName, fieldType, ArrayUtils.EMPTY_OBJECT_ARRAY); } catch (Throwable e) { throw new DesignerException(IExceptionConstants.UI_FIELD_EXCEPTION, e, fieldType.getName(), fieldName); } }
From source file:net.navasoft.madcoin.backend.services.vo.request.SuccessRequestVOWrapper.java
/** * Gets the error processing values.//from ww w . ja v a 2 s . c o m * * @return the error processing values * @since 27/07/2014, 06:49:08 PM */ @Override public ControllerExceptionArgument[] getErrorProcessingValues() { ControllerExceptionArgument[] errors = (ControllerExceptionArgument[]) Array .newInstance(ControllerExceptionArgument.class, 0); for (Method accessor : helper.getDeclaredMethods()) { for (Annotation expected : accessor.getAnnotations()) { if (expected.annotationType() == ProcessingErrorValue.class) { try { ProcessingErrorValue expectedReal = ((ProcessingErrorValue) expected); Object requestValue = null; switch (expectedReal.precedence()) { case BASIC_OPTIONAL: requestValue = accessor.invoke(hidden, ArrayUtils.EMPTY_OBJECT_ARRAY); requestValue = (requestValue != null) ? requestValue : "No data provided"; errors = (ControllerExceptionArgument[]) ArrayUtils.add(errors, new ControllerExceptionArgument(requestValue)); break; case BASIC_REQUIRED: requestValue = accessor.invoke(hidden, ArrayUtils.EMPTY_OBJECT_ARRAY); errors = (ControllerExceptionArgument[]) ArrayUtils.add(errors, new ControllerExceptionArgument(requestValue)); break; case COMPLEX_OPTIONAL: break; case COMPLEX_REQUIRED: break; default: break; } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } return errors; }
From source file:common.utils.ReflectionAssert.java
/** * All fields that have a getter with the same name will be checked by an assertNotNull. * Other fields will be ignored//from w w w .j a v a 2 s.c o m * * @param message * @param object */ public static void assertAccessablePropertiesNotNull(String message, Object object) { Set<Field> fields = ReflectionUtils.getAllFields(object.getClass()); for (Field field : fields) { Method getter = ReflectionUtils.getGetter(object.getClass(), field.getName(), false); if (getter != null) { Object result = null; try { result = getter.invoke(object, ArrayUtils.EMPTY_OBJECT_ARRAY); } catch (Exception e) { throw new UnitilsException(e); } String formattedMessage = formatMessage(message, "Property '" + field.getName() + "' in object '" + object.toString() + "' is null "); assertNotNull(formattedMessage, result); } } }
From source file:com.google.gdt.eclipse.designer.model.widgets.support.GwtState.java
/** * When we use images, browser requests images in background, so we should wait until all (local) * images are loaded before making screen shot. Note: waits no more than 500ms. *//*from w w w.j a v a2s . c o m*/ private void waitForImages() throws Exception { // System.out.println("*** start IMAGE wait"); long startWait = System.currentTimeMillis(); while (true) { boolean complete = m_hostModeSupport.invokeNativeBoolean("__waitForImages", ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY); if (complete) { break; } // do not wait more than 500ms if (System.currentTimeMillis() - startWait > 500) { break; } // wait more runMessagesLoop(); } // System.out.println("*** waiting for IMAGE done in " + (System.currentTimeMillis() - startWait) + "ms"); }