try {
IJavaProject javaProject = JavaCore.create(resource.getProject());
if(javaProject != null)
{
org.eclipse.jdt.core.search.IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{javaProject});
SelectionDialog sd = JavaUI.createTypeDialog(getShell(), new ApplicationWindow(getShell()), searchScope, 2, false);
sd.open();
Object objects[] = sd.getResult();
if(objects != null && objects.length > 0)
{
IType type = (IType)objects[0];
String fullyQualifiedName = type.getFullyQualifiedName('.');
valueText.setText(type.getFullyQualifiedName());
String[] interfaces = type.getSuperInterfaceNames();
boolean isList = false;
if ("java.lang.Object".equals(fullyQualifiedName)) isList = true; //$NON-NLS-1$
else {
for (int i=0; i<interfaces.length; i++) {
if (interfaces[i].equals("java.util.Collection") || interfaces[i].equals("java.util.List") || interfaces[i].equals("java.util.Set")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
isList = true;
break;
}
}
}
if (isList) {
singleBrowse.setEnabled(true);
singleLabel.setEnabled(true);
singleValueText.setEnabled(true);
}
else {
singleBrowse.setEnabled(false);
singleLabel.setEnabled(false);
singleValueText.setEnabled(false);
singleValueText.setText(""); //$NON-NLS-1$
}
}
}
else {
MessageDialog.openError(getShell(), Messages.ContextValueDialog_JAVA_PROJECT_ERROR, Messages.ContextValueDialog_MUST_BE_JAVA_PROJECT);
}
}
catch(JavaModelException _ex) { }
}
@Override
public void mouseDoubleClick(MouseEvent mouseevent)
{
}
@Override
public void mouseUp(MouseEvent mouseevent)
{
}
});
boolean enabled = false;
if (null != contextValue && null != contextValue.singularClass) enabled = true;
singleLabel = new Label(composite, SWT.NULL);
singleLabel.setEnabled(enabled);
singleLabel.setText(Messages.ContextValueDialog_LABEL_LIST_ENTRY_TYPE);
singleValueText = new Text(composite, SWT.BORDER);
singleValueText.setEnabled(enabled);
singleValueText.setBackground(new Color(null, 255, 255, 255));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 250;
singleValueText.setLayoutData(gd);
if (enabled) singleValueText.setText(contextValue.singularClass.getName());
singleBrowse = new Button(composite, 8);
singleBrowse.setEnabled(enabled);
singleBrowse.setText(Messages.ContextValueDialog_BUTTON_BROWSE);
singleBrowse.addMouseListener(new MouseListener() {
@Override
public void mouseDown(MouseEvent e)
{
try {
IJavaProject javaProject = JavaCore.create(resource.getProject());
if(javaProject != null)
{
org.eclipse.jdt.core.search.IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{javaProject});
SelectionDialog sd = JavaUI.createTypeDialog(getShell(), new ApplicationWindow(getShell()), searchScope, 2, false);
sd.open();
Object objects[] = sd.getResult();
if(objects != null && objects.length > 0)
{
IType type = (IType)objects[0];