use of org.eclipse.ui.views.properties.PropertySheetEntry in project jbosstools-hibernate by jbosstools.
the class ExporterSettingsTab method createPropertySheet.
private Control createPropertySheet(Composite exportersComposite) {
propertySheet = new PropertySheetPage() {
public void handleEntrySelection(ISelection selection) {
super.handleEntrySelection(selection);
IStructuredSelection iss = (IStructuredSelection) selection;
IPropertyDescriptor propertyDescriptor = null;
if (!iss.isEmpty()) {
MyPropertySheetEntry mse = (MyPropertySheetEntry) iss.getFirstElement();
propertyDescriptor = mse.getMyDescriptor();
}
updateCurrentDescriptor(propertyDescriptor);
}
};
propertySheet.createControl(exportersComposite);
final PropertySheetEntry propertySheetEntry = new MyPropertySheetEntry();
propertySheetEntry.setPropertySourceProvider(new IPropertySourceProvider() {
public IPropertySource getPropertySource(Object object) {
if (object instanceof ExporterFactory) {
return new ExporterFactoryPropertySource((ExporterFactory) object) {
public void setPropertyValue(Object id, Object value) {
super.setPropertyValue(id, value);
dialogChanged();
}
};
} else {
return null;
}
}
});
propertySheet.setRootEntry(propertySheetEntry);
// propertySheetEntry.setValues( new Object[] { this });
getExporterTable().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection s = (IStructuredSelection) event.getSelection();
if (s.isEmpty()) {
if (add != null)
add.setEnabled(false);
if (remove != null)
remove.setEnabled(false);
if (edit != null)
edit.setEnabled(false);
propertySheetEntry.setValues(new Object[0]);
} else {
if (add != null)
add.setEnabled(true);
boolean hasSelection = false;
if (currentDescriptor != null) {
hasSelection = true;
}
if (remove != null)
remove.setEnabled(hasSelection);
if (edit != null)
edit.setEnabled(hasSelection);
ExporterFactory ep = (ExporterFactory) s.getFirstElement();
propertySheetEntry.setValues(new Object[] { ep });
// if(ep.isEnabled( configuration ))
}
}
});
Control control = propertySheet.getControl();
if (control instanceof Tree && !control.isDisposed()) {
Tree tree = (Tree) control;
tree.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
IPropertyDescriptor propertyDescriptor = null;
if (e.item != null && e.item.getData() != null) {
MyPropertySheetEntry mse = (MyPropertySheetEntry) e.item.getData();
propertyDescriptor = mse.getMyDescriptor();
}
updateCurrentDescriptor(propertyDescriptor);
}
});
}
return control;
}
Aggregations