// Editing
//
////////////////////////////////////////////////////////////////////////////
@Override
protected void openDialog(Property property) throws Exception {
ElementTreeSelectionDialog selectionDialog;
{
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);
}
}