/*******************************************************************************
* Copyright (c) 2005, 2012 eBay Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package org.eclipse.vjet.eclipse.internal.ui.view.properties;
import java.util.Arrays;
import org.eclipse.mod.wst.jsdt.core.ast.IASTNode;
import org.eclipse.mod.wst.jsdt.core.ast.IArgument;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
/**
* {@link IPropertySource} adapter for {@link IArgument}'s 1 dimension array
*
* Ouyang
*
*/
public class AstNodesPropertySourceAdapter implements IPropertySource {
private IASTNode[] m_nodes;
private IPropertyDescriptor[] m_propertyDescriptors;
public AstNodesPropertySourceAdapter(IASTNode[] nodes) {
this.m_nodes = nodes;
this.m_propertyDescriptors = new IPropertyDescriptor[nodes.length];
for (int i = 0; i < this.m_propertyDescriptors.length; i++) {
this.m_propertyDescriptors[i] = new PropertyDescriptor(Integer
.valueOf(i), nodes[i].getClass().getSimpleName());
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
*/
public Object getEditableValue() {
return this;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
*/
public IPropertyDescriptor[] getPropertyDescriptors() {
return this.m_propertyDescriptors;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
*/
public Object getPropertyValue(Object id) {
if (!(id instanceof Integer)) {
return null;
}
return this.m_nodes[((Integer) id).intValue()];
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
*/
public boolean isPropertySet(Object id) {
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
*/
public void resetPropertyValue(Object id) {
// do nothing
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object,
* java.lang.Object)
*/
public void setPropertyValue(Object id, Object value) {
// do nothing
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return Arrays.toString(this.m_nodes);
}
}