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:org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider.java
private void setEmptyProperties() { m_choosenClass = null;//www .j a v a 2 s. co m m_properties = Collections.emptyList(); m_propertiesViewer.getViewer().setInput(m_properties); m_propertiesViewer.setCheckedElements(ArrayUtils.EMPTY_OBJECT_ARRAY); // send loaded event if (m_supportListener != null) { m_supportListener.loadProperties(false); } }
From source file:org.eclipse.wb.internal.core.databinding.ui.providers.ObjectsTreeContentProvider.java
public Object[] getElements(Object input) { // case collection if (input instanceof Collection<?>) { Collection<?> inputCollection = (Collection<?>) input; return inputCollection.toArray(); }/* www .j a v a 2s. co m*/ // case array if (input instanceof Object[]) { return (Object[]) input; } // case direct object if (input instanceof ObjectInfo) { return getChildren(input); } // no input return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:org.eclipse.wb.internal.core.databinding.ui.providers.ObjectsTreeContentProvider.java
public Object[] getChildren(Object element) { if (element instanceof ObjectInfo) { // prepare info ObjectInfo info = (ObjectInfo) element; // prepare presentation final IObjectPresentation presentation = info.getPresentation(); if (presentation != null) { // get children return ExecutionUtils.runObjectLog(new RunnableObjectEx<Object[]>() { public Object[] runObject() throws Exception { return presentation.getChildrenTree().toArray(); }/* ww w . j a v a 2s . c om*/ }, ArrayUtils.EMPTY_OBJECT_ARRAY); } } return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:org.eclipse.wb.internal.core.databinding.ui.providers.ObserveTreeContentProvider.java
public Object[] getElements(Object input) { // case array if (input instanceof Object[]) { return (Object[]) input; }//w ww. j a v a 2 s.c o m // case collection if (input instanceof List<?>) { List<?> listInput = (List<?>) input; return listInput.toArray(); } // case direct object if (input instanceof IObserveInfo) { return getChildren(input); } // no input return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:org.eclipse.wb.internal.core.databinding.wizards.autobindings.DefaultAutomaticDatabindingProvider.java
private void setWidgetCompositeEnabled(boolean enabled) { // viewers state if (!enabled) { m_editorsViewer.setCheckedElements(ArrayUtils.EMPTY_OBJECT_ARRAY); if (m_strategiesViewer != null) { m_strategiesViewer.setCheckedElements(ArrayUtils.EMPTY_OBJECT_ARRAY); }/*from www. j av a 2 s.c o m*/ } // buttons state m_editorLabel.setEnabled(enabled); m_editorsViewer.getControl().setEnabled(enabled); if (m_strategiesViewer != null) { m_strategyLabel.setEnabled(enabled); m_strategiesViewer.getControl().setEnabled(enabled); } m_widgetComposite.setEnabled(enabled); }
From source file:org.eclipse.wb.internal.core.databinding.wizards.autobindings.DescriptorContainer.java
/** * Parse descriptors XML file./*from w w w . j a v a 2 s .c o m*/ * * @return {@link Map} with all descriptors. */ public static Map<String, DescriptorContainer> parseDescriptors(InputStream stream, final ClassLoader classLoader, final IImageLoader imageLoader) throws Exception { final Map<String, DescriptorContainer> containers = Maps.newHashMap(); // SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); parser.parse(stream, new DefaultHandler() { private DescriptorContainer m_container; private AbstractDescriptor m_descriptor; private Class<?> m_descriptorClass; // @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { try { if ("descriptors".equals(name)) { // create container m_container = new DescriptorContainer(); containers.put(attributes.getValue("name"), m_container); m_descriptorClass = classLoader.loadClass(attributes.getValue("class")); } else if ("descriptor".equals(name)) { // create descriptor m_descriptor = (AbstractDescriptor) m_descriptorClass.newInstance(); } else if (m_descriptor != null) { // fill attributes if (attributes.getLength() == 0) { // method without parameters ReflectionUtils.invokeMethod(m_descriptor, name + "()", ArrayUtils.EMPTY_OBJECT_ARRAY); } else { if (name.endsWith("Image")) { // special support for images try { ReflectionUtils.invokeMethod(m_descriptor, name + "(org.eclipse.swt.graphics.Image)", new Object[] { imageLoader.getImage(attributes.getValue("value")) }); } catch (Throwable e) { DesignerPlugin.log( "DescriptorContainer: error load image " + attributes.getValue("value"), e); } } else { // method with single String parameter ReflectionUtils.invokeMethod(m_descriptor, name + "(java.lang.String)", new Object[] { attributes.getValue("value") }); } } } } catch (Exception e) { throw new SAXException("startElement", e); } } @Override public void endElement(String uri, String localName, String name) throws SAXException { // clear state if ("descriptors".equals(name)) { m_container = null; } else if ("descriptor".equals(name)) { m_container.addDescriptor(m_descriptor); m_descriptor = null; } } }); // return containers; }
From source file:org.eclipse.wb.internal.core.editor.palette.dialogs.ImportArchiveDialog.java
private void chooseArchive(IFile jarIFile, File jarFile) { try {/* w w w . j av a2s .c o m*/ // prepare path boolean canFile = jarIFile == null; m_jarPath = canFile ? jarFile.getAbsolutePath() : jarIFile.getLocation().toPortableString(); // load elements over manifest boolean ignoreManifest = m_ignoreManifestButton.getSelection(); m_elements = Collections.emptyList(); if (!ignoreManifest) { JarInputStream jarStream = new JarInputStream( canFile ? new FileInputStream(jarFile) : jarIFile.getContents(true)); m_elements = extractElementsFromJarByManifest(jarStream); jarStream.close(); } // check load all elements if (ignoreManifest || m_elements.isEmpty()) { if (!ignoreManifest) { String message = MessageFormat.format(Messages.ImportArchiveDialog_hasManifestMessage, m_jarPath); ignoreManifest = MessageDialog.openQuestion(getShell(), Messages.ImportArchiveDialog_hasManifestTitle, message); } if (ignoreManifest) { JarInputStream jarStream = new JarInputStream( canFile ? new FileInputStream(jarFile) : jarIFile.getContents(true)); m_elements = extractElementsFromJarAllClasses(jarStream); jarStream.close(); } } // sets elements m_classesViewer.setInput(m_elements.toArray()); // handle jar combo int removeIndex = m_fileArchiveCombo.indexOf(m_jarPath); if (removeIndex != -1) { m_fileArchiveCombo.remove(removeIndex); } m_fileArchiveCombo.add(m_jarPath, 0); int archiveCount = m_fileArchiveCombo.getItemCount(); if (archiveCount > JAR_COMBO_SIZE) { m_fileArchiveCombo.remove(JAR_COMBO_SIZE, archiveCount - 1); } if (!m_fileArchiveCombo.getText().equals(m_jarPath)) { m_fileArchiveCombo.setText(m_jarPath); m_fileArchiveCombo.setSelection(new Point(0, m_jarPath.length())); } // handle category if (m_elements.isEmpty()) { m_categoryText.setText(""); } else { // convert 'foo.jar' to 'foo' String categoryName = canFile ? jarFile.getName() : jarIFile.getName(); m_categoryText.setText(categoryName.substring(0, categoryName.length() - JAR_SUFFIX.length())); } } catch (Throwable t) { m_jarPath = null; m_elements = Collections.emptyList(); m_classesViewer.setInput(ArrayUtils.EMPTY_OBJECT_ARRAY); m_categoryText.setText(""); } finally { calculateFinish(); } }
From source file:org.eclipse.wb.internal.core.model.creation.ThisCreationSupport.java
@Override public Object create(EvaluationContext context, ExecutionFlowFrameVisitor visitor) throws Exception { Class<?> componentClass = getComponentClass(); // prepare constructor String signature;/*from w w w. j a v a 2 s .c om*/ Constructor<?> constructor; Object[] argumentValues; if (m_invocation != null) { IMethodBinding methodBinding = AstNodeUtils.getSuperBinding(m_invocation); signature = AstNodeUtils.getMethodSignature(methodBinding); constructor = AstReflectionUtils.getConstructor(componentClass, m_invocation); List<Expression> arguments = DomGenerics.arguments(m_invocation); argumentValues = evaluateExpressions(context, arguments); argumentValues = AstReflectionUtils.updateForVarArgs(context.getClassLoader(), methodBinding, argumentValues); } else { signature = "<init>()"; constructor = ReflectionUtils.getConstructorBySignature(componentClass, "<init>()"); argumentValues = ArrayUtils.EMPTY_OBJECT_ARRAY; } if (constructor == null && !componentClass.isInterface()) { throw new DesignerException(ICoreExceptionConstants.EVAL_NO_CONSTRUCTOR, signature, componentClass.getName()); } // create Object try { Object object = create0(visitor, constructor, componentClass, argumentValues); m_javaInfo.setObject(object); duringParsing_createExposedChildren(); return object; } catch (DesignerException e) { throw e; } catch (Throwable e) { throw new DesignerException(ICoreExceptionConstants.EVAL_CGLIB, e, ReflectionUtils.getShortConstructorString(constructor), InvocationEvaluator.getArguments_toString(argumentValues), AstEvaluationEngine.getUserStackTrace(e)); } }
From source file:org.eclipse.wb.internal.core.model.JavaInfoUtils.java
/** * @return {@link Object}'s that represent given component. Usually this is just single object, * but in GWT components has two presentations: <code>UIObject</code> and its * <code>Element</code>. *///from w ww.j ava 2 s . c o m private static Object[] getComponentObjects(JavaInfo component) throws Exception { Object object = getComponentObject0(component); if (object == null) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } for (HierarchyProvider provider : getHierarchyProviders()) { Object[] objects = provider.getAliases(object); if (objects != null) { return objects; } } return new Object[] { object }; }
From source file:org.eclipse.wb.internal.core.nls.bundle.AbstractBundleSourceNewComposite.java
protected final void createPropertyGroup() { m_propertyGroup = new Group(this, SWT.NONE); GridDataFactory.create(m_propertyGroup).grabH().fillH(); GridLayoutFactory.create(m_propertyGroup).columns(3); m_propertyGroup.setText(Messages.AbstractBundleSourceNewComposite_propertiesGroup); {/*from w ww .j a v a 2 s . c o m*/ m_propertyPackageField = new PackageRootAndPackageSelectionDialogField(60, Messages.AbstractBundleSourceNewComposite_propertiesSourceFolder, Messages.AbstractBundleSourceNewComposite_propertiesSourceFolderBrowse, Messages.AbstractBundleSourceNewComposite_propertiesPackage, Messages.AbstractBundleSourceNewComposite_propertiesPackageBrowse); m_propertyPackageField.setDialogFieldListener(m_validateListener); m_propertyPackageField.doFillIntoGrid(m_propertyGroup, 3); // create property file field { m_propertyFileField = new StringButtonDialogField(new IStringButtonAdapter() { public void changeControlPressed(DialogField field) { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider()); dialog.setIgnoreCase(false); dialog.setTitle(Messages.AbstractBundleSourceNewComposite_propertiesChooseTitle); dialog.setMessage(Messages.AbstractBundleSourceNewComposite_propertiesChooseMessage); dialog.setElements(createFileListInput()); dialog.setFilter("*.properties"); // select file if (dialog.open() != Window.OK) { return; } IFile selectedFile = (IFile) dialog.getFirstResult(); // update property file field m_propertyFileField.setText(selectedFile.getName()); } /** * Return list of ".properties" files in current property package. */ private Object[] createFileListInput() { try { // prepare current package IPackageFragment currentPackage = m_propertyPackageField.getPackage(); if (currentPackage == null) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } // check each non-Java file in current package List<IFile> result = new ArrayList<IFile>(1); Object[] nonJava = currentPackage.getNonJavaResources(); for (int i = 0; i < nonJava.length; i++) { if (isPropertyFile(nonJava[i])) { result.add((IFile) nonJava[i]); } } // return result return result.toArray(); } catch (JavaModelException e) { DesignerPlugin.log(e); return new Object[0]; } } /** * Check that given object if IFile with ".properties" extension. */ private boolean isPropertyFile(Object o) { if (o instanceof IFile) { IFile file = (IFile) o; return ".properties".equals('.' + file.getFileExtension()); } return false; } }); m_propertyFileField.setDialogFieldListener(m_validateListener); m_propertyFileField.setLabelText(Messages.AbstractBundleSourceNewComposite_propertiesLabel); m_propertyFileField .setButtonLabel(Messages.AbstractBundleSourceNewComposite_propertiesChooseButton); createTextFieldControls(m_propertyGroup, m_propertyFileField, 3); } } }